39 extern_cfg (String, ld_defaultuser); |
39 extern_cfg (String, ld_defaultuser); |
40 |
40 |
41 // ============================================================================= |
41 // ============================================================================= |
42 // ----------------------------------------------------------------------------- |
42 // ----------------------------------------------------------------------------- |
43 static int copyToClipboard() |
43 static int copyToClipboard() |
44 { List<LDObject*> objs = g_win->sel(); |
44 { QList<LDObject*> objs = g_win->sel(); |
45 int num = 0; |
45 int num = 0; |
46 |
46 |
47 // Clear the clipboard first. |
47 // Clear the clipboard first. |
48 qApp->clipboard()->clear(); |
48 qApp->clipboard()->clear(); |
49 |
49 |
106 } |
106 } |
107 |
107 |
108 // ============================================================================= |
108 // ============================================================================= |
109 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
110 static void doInline (bool deep) |
110 static void doInline (bool deep) |
111 { List<LDObject*> sel = g_win->sel(); |
111 { QList<LDObject*> sel = g_win->sel(); |
112 |
112 |
113 for (LDObject* obj : sel) |
113 for (LDObject* obj : sel) |
114 { // Get the index of the subfile so we know where to insert the |
114 { // Get the index of the subfile so we know where to insert the |
115 // inlined contents. |
115 // inlined contents. |
116 long idx = obj->getIndex(); |
116 long idx = obj->getIndex(); |
117 |
117 |
118 if (idx == -1) |
118 if (idx == -1) |
119 continue; |
119 continue; |
120 |
120 |
121 List<LDObject*> objs; |
121 QList<LDObject*> objs; |
122 |
122 |
123 if (obj->getType() == LDObject::Subfile) |
123 if (obj->getType() == LDObject::Subfile) |
124 objs = static_cast<LDSubfile*> (obj)->inlineContents ( |
124 objs = static_cast<LDSubfile*> (obj)->inlineContents ( |
125 (LDSubfile::InlineFlags) |
125 (LDSubfile::InlineFlags) |
126 ( (deep) ? LDSubfile::DeepInline : 0) | |
126 ( (deep) ? LDSubfile::DeepInline : 0) | |
157 } |
157 } |
158 |
158 |
159 // ============================================================================= |
159 // ============================================================================= |
160 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
161 DEFINE_ACTION (SplitQuads, 0) |
161 DEFINE_ACTION (SplitQuads, 0) |
162 { List<LDObject*> objs = g_win->sel(); |
162 { QList<LDObject*> objs = g_win->sel(); |
163 int num = 0; |
163 int num = 0; |
164 |
164 |
165 for (LDObject* obj : objs) |
165 for (LDObject* obj : objs) |
166 { if (obj->getType() != LDObject::Quad) |
166 { if (obj->getType() != LDObject::Quad) |
167 continue; |
167 continue; |
170 long index = obj->getIndex(); |
170 long index = obj->getIndex(); |
171 |
171 |
172 if (index == -1) |
172 if (index == -1) |
173 return; |
173 return; |
174 |
174 |
175 List<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles(); |
175 QList<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles(); |
176 |
176 |
177 // Replace the quad with the first triangle and add the second triangle |
177 // Replace the quad with the first triangle and add the second triangle |
178 // after the first one. |
178 // after the first one. |
179 LDFile::current()->setObject (index, triangles[0]); |
179 LDFile::current()->setObject (index, triangles[0]); |
180 LDFile::current()->insertObj (index + 1, triangles[1]); |
180 LDFile::current()->insertObj (index + 1, triangles[1]); |
256 } |
256 } |
257 |
257 |
258 // ============================================================================= |
258 // ============================================================================= |
259 // ----------------------------------------------------------------------------- |
259 // ----------------------------------------------------------------------------- |
260 DEFINE_ACTION (Borders, CTRL_SHIFT (B)) |
260 DEFINE_ACTION (Borders, CTRL_SHIFT (B)) |
261 { List<LDObject*> objs = g_win->sel(); |
261 { QList<LDObject*> objs = g_win->sel(); |
262 int num = 0; |
262 int num = 0; |
263 |
263 |
264 for (LDObject* obj : objs) |
264 for (LDObject* obj : objs) |
265 { if (obj->getType() != LDObject::Quad && obj->getType() != LDObject::Triangle) |
265 { if (obj->getType() != LDObject::Quad && obj->getType() != LDObject::Triangle) |
266 continue; |
266 continue; |
328 } |
328 } |
329 |
329 |
330 // ============================================================================= |
330 // ============================================================================= |
331 // ----------------------------------------------------------------------------- |
331 // ----------------------------------------------------------------------------- |
332 static void doMoveSelection (const bool up) |
332 static void doMoveSelection (const bool up) |
333 { List<LDObject*> objs = g_win->sel(); |
333 { QList<LDObject*> objs = g_win->sel(); |
334 LDObject::moveObjects (objs, up); |
334 LDObject::moveObjects (objs, up); |
335 g_win->buildObjList(); |
335 g_win->buildObjList(); |
336 } |
336 } |
337 |
337 |
338 // ============================================================================= |
338 // ============================================================================= |
398 } |
398 } |
399 |
399 |
400 // ============================================================================= |
400 // ============================================================================= |
401 // ----------------------------------------------------------------------------- |
401 // ----------------------------------------------------------------------------- |
402 DEFINE_ACTION (Invert, CTRL_SHIFT (W)) |
402 DEFINE_ACTION (Invert, CTRL_SHIFT (W)) |
403 { List<LDObject*> sel = g_win->sel(); |
403 { QList<LDObject*> sel = g_win->sel(); |
404 |
404 |
405 for (LDObject* obj : sel) |
405 for (LDObject* obj : sel) |
406 { obj->invert(); |
406 { obj->invert(); |
407 g_win->R()->compileObject (obj); |
407 g_win->R()->compileObject (obj); |
408 } |
408 } |
419 } |
419 } |
420 |
420 |
421 // ============================================================================= |
421 // ============================================================================= |
422 // ----------------------------------------------------------------------------- |
422 // ----------------------------------------------------------------------------- |
423 static void doRotate (const short l, const short m, const short n) |
423 static void doRotate (const short l, const short m, const short n) |
424 { List<LDObject*> sel = g_win->sel(); |
424 { QList<LDObject*> sel = g_win->sel(); |
425 List<vertex*> queue; |
425 QList<vertex*> queue; |
426 const vertex rotpoint = rotPoint (sel); |
426 const vertex rotpoint = rotPoint (sel); |
427 const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180, |
427 const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180, |
428 cosangle = cos (angle), |
428 cosangle = cos (angle), |
429 sinangle = sin (angle); |
429 sinangle = sin (angle); |
430 |
430 |
562 const double search = ui.search->value(), |
562 const double search = ui.search->value(), |
563 replacement = ui.replacement->value(); |
563 replacement = ui.replacement->value(); |
564 const bool any = ui.any->isChecked(), |
564 const bool any = ui.any->isChecked(), |
565 rel = ui.relative->isChecked(); |
565 rel = ui.relative->isChecked(); |
566 |
566 |
567 List<Axis> sel; |
567 QList<Axis> sel; |
568 int num = 0; |
568 int num = 0; |
569 |
569 |
570 if (ui.x->isChecked()) sel << X; |
570 if (ui.x->isChecked()) sel << X; |
571 |
571 |
572 if (ui.y->isChecked()) sel << Y; |
572 if (ui.y->isChecked()) sel << Y; |
628 } |
628 } |
629 |
629 |
630 // ============================================================================= |
630 // ============================================================================= |
631 // ----------------------------------------------------------------------------- |
631 // ----------------------------------------------------------------------------- |
632 DEFINE_ACTION (Demote, 0) |
632 DEFINE_ACTION (Demote, 0) |
633 { List<LDObject*> sel = g_win->sel(); |
633 { QList<LDObject*> sel = g_win->sel(); |
634 int num = 0; |
634 int num = 0; |
635 |
635 |
636 for (LDObject* obj : sel) |
636 for (LDObject* obj : sel) |
637 { if (obj->getType() != LDObject::CndLine) |
637 { if (obj->getType() != LDObject::CndLine) |
638 continue; |
638 continue; |