54 qApp->clipboard()->clear(); |
54 qApp->clipboard()->clear(); |
55 |
55 |
56 // Now, copy the contents into the clipboard. |
56 // Now, copy the contents into the clipboard. |
57 QString data; |
57 QString data; |
58 |
58 |
59 for (LDObjectPtr obj : objs) |
59 for (LDObject* obj : objs) |
60 { |
60 { |
61 if (not data.isEmpty()) |
61 if (not data.isEmpty()) |
62 data += "\n"; |
62 data += "\n"; |
63 |
63 |
64 data += obj->asText(); |
64 data += obj->asText(); |
130 |
130 |
131 assert (idx != -1); |
131 assert (idx != -1); |
132 LDObjectList objs = ref->inlineContents (deep, false); |
132 LDObjectList objs = ref->inlineContents (deep, false); |
133 |
133 |
134 // Merge in the inlined objects |
134 // Merge in the inlined objects |
135 for (LDObjectPtr inlineobj : objs) |
135 for (LDObject* inlineobj : objs) |
136 { |
136 { |
137 QString line = inlineobj->asText(); |
137 QString line = inlineobj->asText(); |
138 inlineobj->destroy(); |
138 inlineobj->destroy(); |
139 LDObjectPtr newobj = ParseLine (line); |
139 LDObject* newobj = ParseLine (line); |
140 CurrentDocument()->insertObj (idx++, newobj); |
140 CurrentDocument()->insertObj (idx++, newobj); |
141 newobj->select(); |
141 newobj->select(); |
142 } |
142 } |
143 |
143 |
144 // Delete the subfile now as it's been inlined. |
144 // Delete the subfile now as it's been inlined. |
190 void MainWindow::slot_actionEditRaw() |
190 void MainWindow::slot_actionEditRaw() |
191 { |
191 { |
192 if (Selection().size() != 1) |
192 if (Selection().size() != 1) |
193 return; |
193 return; |
194 |
194 |
195 LDObjectPtr obj = Selection()[0]; |
195 LDObject* obj = Selection()[0]; |
196 QDialog* dlg = new QDialog; |
196 QDialog* dlg = new QDialog; |
197 Ui::EditRawUI ui; |
197 Ui::EditRawUI ui; |
198 |
198 |
199 ui.setupUi (dlg); |
199 ui.setupUi (dlg); |
200 ui.code->setText (obj->asText()); |
200 ui.code->setText (obj->asText()); |
201 |
201 |
202 if (obj->type() == OBJ_Error) |
202 if (obj->type() == OBJ_Error) |
203 ui.errorDescription->setText (obj.staticCast<LDError>()->reason()); |
203 ui.errorDescription->setText (static_cast<LDError*> (obj)->reason()); |
204 else |
204 else |
205 { |
205 { |
206 ui.errorDescription->hide(); |
206 ui.errorDescription->hide(); |
207 ui.errorIcon->hide(); |
207 ui.errorIcon->hide(); |
208 } |
208 } |
209 |
209 |
210 if (dlg->exec() == QDialog::Rejected) |
210 if (dlg->exec() == QDialog::Rejected) |
211 return; |
211 return; |
212 |
212 |
213 // Reinterpret it from the text of the input field |
213 // Reinterpret it from the text of the input field |
214 LDObjectPtr newobj = ParseLine (ui.code->text()); |
214 LDObject* newobj = ParseLine (ui.code->text()); |
215 obj->replace (newobj); |
215 obj->replace (newobj); |
216 refresh(); |
216 refresh(); |
217 } |
217 } |
218 |
218 |
219 // ============================================================================= |
219 // ============================================================================= |
231 LDColor defaultcol = getSelectedColor(); |
231 LDColor defaultcol = getSelectedColor(); |
232 |
232 |
233 // Show the dialog to the user now and ask for a color. |
233 // Show the dialog to the user now and ask for a color. |
234 if (ColorSelector::selectColor (color, defaultcol, g_win)) |
234 if (ColorSelector::selectColor (color, defaultcol, g_win)) |
235 { |
235 { |
236 for (LDObjectPtr obj : objs) |
236 for (LDObject* obj : objs) |
237 { |
237 { |
238 if (obj->isColored()) |
238 if (obj->isColored()) |
239 obj->setColor (color); |
239 obj->setColor (color); |
240 } |
240 } |
241 |
241 |
248 void MainWindow::slot_actionBorders() |
248 void MainWindow::slot_actionBorders() |
249 { |
249 { |
250 LDObjectList objs = Selection(); |
250 LDObjectList objs = Selection(); |
251 int num = 0; |
251 int num = 0; |
252 |
252 |
253 for (LDObjectPtr obj : objs) |
253 for (LDObject* obj : objs) |
254 { |
254 { |
255 const LDObjectType type = obj->type(); |
255 const LDObjectType type = obj->type(); |
256 |
256 |
257 if (type != OBJ_Quad and type != OBJ_Triangle) |
257 if (type != OBJ_Quad and type != OBJ_Triangle) |
258 continue; |
258 continue; |
259 |
259 |
260 LDLinePtr lines[4]; |
260 LDLinePtr lines[4]; |
261 |
261 |
262 if (type == OBJ_Quad) |
262 if (type == OBJ_Quad) |
263 { |
263 { |
264 LDQuadPtr quad = obj.staticCast<LDQuad>(); |
264 LDQuadPtr quad = static_cast<LDQuad*> (obj); |
265 lines[0] = LDSpawn<LDLine> (quad->vertex (0), quad->vertex (1)); |
265 lines[0] = LDSpawn<LDLine> (quad->vertex (0), quad->vertex (1)); |
266 lines[1] = LDSpawn<LDLine> (quad->vertex (1), quad->vertex (2)); |
266 lines[1] = LDSpawn<LDLine> (quad->vertex (1), quad->vertex (2)); |
267 lines[2] = LDSpawn<LDLine> (quad->vertex (2), quad->vertex (3)); |
267 lines[2] = LDSpawn<LDLine> (quad->vertex (2), quad->vertex (3)); |
268 lines[3] = LDSpawn<LDLine> (quad->vertex (3), quad->vertex (0)); |
268 lines[3] = LDSpawn<LDLine> (quad->vertex (3), quad->vertex (0)); |
269 } |
269 } |
270 else |
270 else |
271 { |
271 { |
272 LDTrianglePtr tri = obj.staticCast<LDTriangle>(); |
272 LDTrianglePtr tri = static_cast<LDTriangle*> (obj); |
273 lines[0] = LDSpawn<LDLine> (tri->vertex (0), tri->vertex (1)); |
273 lines[0] = LDSpawn<LDLine> (tri->vertex (0), tri->vertex (1)); |
274 lines[1] = LDSpawn<LDLine> (tri->vertex (1), tri->vertex (2)); |
274 lines[1] = LDSpawn<LDLine> (tri->vertex (1), tri->vertex (2)); |
275 lines[2] = LDSpawn<LDLine> (tri->vertex (2), tri->vertex (0)); |
275 lines[2] = LDSpawn<LDLine> (tri->vertex (2), tri->vertex (0)); |
276 } |
276 } |
277 |
277 |
448 void MainWindow::slot_actionRoundCoordinates() |
448 void MainWindow::slot_actionRoundCoordinates() |
449 { |
449 { |
450 setlocale (LC_ALL, "C"); |
450 setlocale (LC_ALL, "C"); |
451 int num = 0; |
451 int num = 0; |
452 |
452 |
453 for (LDObjectPtr obj : Selection()) |
453 for (LDObject* obj : Selection()) |
454 { |
454 { |
455 LDMatrixObjectPtr mo = obj.dynamicCast<LDMatrixObject>(); |
455 LDMatrixObjectPtr mo = dynamic_cast<LDMatrixObject*> (obj); |
456 |
456 |
457 if (mo != null) |
457 if (mo != null) |
458 { |
458 { |
459 Vertex v = mo->position(); |
459 Vertex v = mo->position(); |
460 Matrix t = mo->transform(); |
460 Matrix t = mo->transform(); |
524 |
524 |
525 if (ui.x->isChecked()) sel << X; |
525 if (ui.x->isChecked()) sel << X; |
526 if (ui.y->isChecked()) sel << Y; |
526 if (ui.y->isChecked()) sel << Y; |
527 if (ui.z->isChecked()) sel << Z; |
527 if (ui.z->isChecked()) sel << Z; |
528 |
528 |
529 for (LDObjectPtr obj : Selection()) |
529 for (LDObject* obj : Selection()) |
530 { |
530 { |
531 for (int i = 0; i < obj->numVertices(); ++i) |
531 for (int i = 0; i < obj->numVertices(); ++i) |
532 { |
532 { |
533 Vertex v = obj->vertex (i); |
533 Vertex v = obj->vertex (i); |
534 |
534 |
570 |
570 |
571 if (ui.x->isChecked()) sel << X; |
571 if (ui.x->isChecked()) sel << X; |
572 if (ui.y->isChecked()) sel << Y; |
572 if (ui.y->isChecked()) sel << Y; |
573 if (ui.z->isChecked()) sel << Z; |
573 if (ui.z->isChecked()) sel << Z; |
574 |
574 |
575 for (LDObjectPtr obj : Selection()) |
575 for (LDObject* obj : Selection()) |
576 { |
576 { |
577 for (int i = 0; i < obj->numVertices(); ++i) |
577 for (int i = 0; i < obj->numVertices(); ++i) |
578 { |
578 { |
579 Vertex v = obj->vertex (i); |
579 Vertex v = obj->vertex (i); |
580 |
580 |
653 |
653 |
654 // ============================================================================= |
654 // ============================================================================= |
655 // |
655 // |
656 void MainWindow::slot_actionAddHistoryLine() |
656 void MainWindow::slot_actionAddHistoryLine() |
657 { |
657 { |
658 LDObjectPtr obj; |
658 LDObject* obj; |
659 bool ishistory = false, |
659 bool ishistory = false, |
660 prevIsHistory = false; |
660 prevIsHistory = false; |
661 |
661 |
662 QDialog* dlg = new QDialog; |
662 QDialog* dlg = new QDialog; |
663 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; |
663 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; |
680 // Find a spot to place the new comment |
680 // Find a spot to place the new comment |
681 for (obj = CurrentDocument()->getObject (0); |
681 for (obj = CurrentDocument()->getObject (0); |
682 obj != null and obj->next() != null and not obj->next()->isScemantic(); |
682 obj != null and obj->next() != null and not obj->next()->isScemantic(); |
683 obj = obj->next()) |
683 obj = obj->next()) |
684 { |
684 { |
685 LDCommentPtr comm = obj.dynamicCast<LDComment>(); |
685 LDCommentPtr comm = dynamic_cast<LDComment*> (obj); |
686 |
686 |
687 if (comm != null and comm->text().startsWith ("!HISTORY ")) |
687 if (comm != null and comm->text().startsWith ("!HISTORY ")) |
688 ishistory = true; |
688 ishistory = true; |
689 |
689 |
690 if (prevIsHistory and not ishistory) |
690 if (prevIsHistory and not ishistory) |
718 if (not ok) |
718 if (not ok) |
719 return; |
719 return; |
720 |
720 |
721 cfg::SplitLinesSegments = segments; |
721 cfg::SplitLinesSegments = segments; |
722 |
722 |
723 for (LDObjectPtr obj : Selection()) |
723 for (LDObject* obj : Selection()) |
724 { |
724 { |
725 if (not Eq (obj->type(), OBJ_Line, OBJ_CondLine)) |
725 if (not Eq (obj->type(), OBJ_Line, OBJ_CondLine)) |
726 continue; |
726 continue; |
727 |
727 |
728 QVector<LDObjectPtr> newsegs; |
728 QVector<LDObject*> newsegs; |
729 |
729 |
730 for (int i = 0; i < segments; ++i) |
730 for (int i = 0; i < segments; ++i) |
731 { |
731 { |
732 LDObjectPtr segment; |
732 LDObject* segment; |
733 Vertex v0, v1; |
733 Vertex v0, v1; |
734 |
734 |
735 v0.apply ([&](Axis ax, double& a) |
735 v0.apply ([&](Axis ax, double& a) |
736 { |
736 { |
737 double len = obj->vertex (1)[ax] - obj->vertex (0)[ax]; |
737 double len = obj->vertex (1)[ax] - obj->vertex (0)[ax]; |