38 |
38 |
39 // ============================================================================= |
39 // ============================================================================= |
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
41 // ============================================================================= |
41 // ============================================================================= |
42 static int copyToClipboard() { |
42 static int copyToClipboard() { |
43 vector<LDObject*> objs = g_win->sel(); |
43 List<LDObject*> objs = g_win->sel(); |
44 int num = 0; |
44 int num = 0; |
45 |
45 |
46 // Clear the clipboard first. |
46 // Clear the clipboard first. |
47 qApp->clipboard()->clear(); |
47 qApp->clipboard()->clear(); |
48 |
48 |
110 |
110 |
111 // ============================================================================= |
111 // ============================================================================= |
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
113 // ============================================================================= |
113 // ============================================================================= |
114 static void doInline (bool deep) { |
114 static void doInline (bool deep) { |
115 vector<LDObject*> sel = g_win->sel(); |
115 List<LDObject*> sel = g_win->sel(); |
116 |
116 |
117 for (LDObject* obj : sel) { |
117 for (LDObject* obj : sel) { |
118 // Get the index of the subfile so we know where to insert the |
118 // Get the index of the subfile so we know where to insert the |
119 // inlined contents. |
119 // inlined contents. |
120 long idx = obj->getIndex(); |
120 long idx = obj->getIndex(); |
121 |
121 |
122 if (idx == -1) |
122 if (idx == -1) |
123 continue; |
123 continue; |
124 |
124 |
125 vector<LDObject*> objs; |
125 List<LDObject*> objs; |
126 |
126 |
127 if (obj->getType() == LDObject::Subfile) |
127 if (obj->getType() == LDObject::Subfile) |
128 objs = static_cast<LDSubfileObject*> (obj)->inlineContents (deep, true); |
128 objs = static_cast<LDSubfileObject*> (obj)->inlineContents (deep, true); |
129 else |
129 else |
130 continue; |
130 continue; |
157 |
157 |
158 // =============================================================================================== |
158 // =============================================================================================== |
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
160 // =============================================================================================== |
160 // =============================================================================================== |
161 DEFINE_ACTION (SplitQuads, 0) { |
161 DEFINE_ACTION (SplitQuads, 0) { |
162 vector<LDObject*> objs = g_win->sel(); |
162 List<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 vector<LDTriangleObject*> triangles = static_cast<LDQuadObject*> (obj)->splitToTriangles(); |
175 List<LDTriangleObject*> triangles = static_cast<LDQuadObject*> (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 LDOpenFile::current()->setObject (index, triangles[0]); |
179 LDOpenFile::current()->setObject (index, triangles[0]); |
180 LDOpenFile::current()->insertObj (index + 1, triangles[1]); |
180 LDOpenFile::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 vector<LDObject*> objs = g_win->sel(); |
261 List<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; |
329 |
329 |
330 // ============================================================================= |
330 // ============================================================================= |
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
332 // ============================================================================= |
332 // ============================================================================= |
333 static void doMoveSelection (const bool up) { |
333 static void doMoveSelection (const bool up) { |
334 vector<LDObject*> objs = g_win->sel(); |
334 List<LDObject*> objs = g_win->sel(); |
335 LDObject::moveObjects (objs, up); |
335 LDObject::moveObjects (objs, up); |
336 g_win->buildObjList(); |
336 g_win->buildObjList(); |
337 } |
337 } |
338 |
338 |
339 DEFINE_ACTION (MoveUp, KEY (PageUp)) { |
339 DEFINE_ACTION (MoveUp, KEY (PageUp)) { |
396 doMoveObjects ({0, 0, 1}); |
396 doMoveObjects ({0, 0, 1}); |
397 } |
397 } |
398 |
398 |
399 // ============================================================================= |
399 // ============================================================================= |
400 DEFINE_ACTION (Invert, CTRL_SHIFT (W)) { |
400 DEFINE_ACTION (Invert, CTRL_SHIFT (W)) { |
401 vector<LDObject*> sel = g_win->sel(); |
401 List<LDObject*> sel = g_win->sel(); |
402 |
402 |
403 for (LDObject* obj : sel) { |
403 for (LDObject* obj : sel) { |
404 obj->invert(); |
404 obj->invert(); |
405 g_win->R()->compileObject (obj); |
405 g_win->R()->compileObject (obj); |
406 } |
406 } |
414 v.transform (transform, g_origin); |
414 v.transform (transform, g_origin); |
415 v.move (rotpoint); |
415 v.move (rotpoint); |
416 } |
416 } |
417 |
417 |
418 static void doRotate (const short l, const short m, const short n) { |
418 static void doRotate (const short l, const short m, const short n) { |
419 vector<LDObject*> sel = g_win->sel(); |
419 List<LDObject*> sel = g_win->sel(); |
420 vector<vertex*> queue; |
420 List<vertex*> queue; |
421 const vertex rotpoint = rotPoint (sel); |
421 const vertex rotpoint = rotPoint (sel); |
422 const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180; |
422 const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180; |
423 |
423 |
424 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 |
424 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 |
425 const double cosangle = cos (angle), |
425 const double cosangle = cos (angle), |
538 const double search = ui.search->value(), |
538 const double search = ui.search->value(), |
539 replacement = ui.replacement->value(); |
539 replacement = ui.replacement->value(); |
540 const bool any = ui.any->isChecked(), |
540 const bool any = ui.any->isChecked(), |
541 rel = ui.relative->isChecked(); |
541 rel = ui.relative->isChecked(); |
542 |
542 |
543 vector<Axis> sel; |
543 List<Axis> sel; |
544 int num = 0; |
544 int num = 0; |
545 |
545 |
546 if (ui.x->isChecked()) sel << X; |
546 if (ui.x->isChecked()) sel << X; |
547 if (ui.y->isChecked()) sel << Y; |
547 if (ui.y->isChecked()) sel << Y; |
548 if (ui.z->isChecked()) sel << Z; |
548 if (ui.z->isChecked()) sel << Z; |
598 g_win->refresh(); |
598 g_win->refresh(); |
599 } |
599 } |
600 |
600 |
601 // ================================================================================================ |
601 // ================================================================================================ |
602 DEFINE_ACTION (Demote, 0) { |
602 DEFINE_ACTION (Demote, 0) { |
603 vector<LDObject*> sel = g_win->sel(); |
603 List<LDObject*> sel = g_win->sel(); |
604 int num = 0; |
604 int num = 0; |
605 |
605 |
606 for (LDObject* obj : sel) { |
606 for (LDObject* obj : sel) { |
607 if (obj->getType() != LDObject::CondLine) |
607 if (obj->getType() != LDObject::CondLine) |
608 continue; |
608 continue; |