62 |
62 |
63 QList<LDTriangle*> triangles = it->splitToTriangles(); |
63 QList<LDTriangle*> triangles = it->splitToTriangles(); |
64 |
64 |
65 // Replace the quad with the first triangle and add the second triangle |
65 // Replace the quad with the first triangle and add the second triangle |
66 // after the first one. |
66 // after the first one. |
67 currentDocument()->setObject (index, triangles[0]); |
67 currentDocument()->setObjectAt (index, triangles[0]); |
68 currentDocument()->insertObj (index + 1, triangles[1]); |
68 currentDocument()->insertObject (index + 1, triangles[1]); |
69 num++; |
69 num++; |
70 } |
70 } |
71 |
71 |
72 print ("%1 quadrilaterals split", num); |
72 print ("%1 quadrilaterals split", num); |
73 } |
73 } |
159 Vertex v = mo->position(); |
159 Vertex v = mo->position(); |
160 Matrix t = mo->transform(); |
160 Matrix t = mo->transform(); |
161 |
161 |
162 v.apply ([&](Axis, double& a) |
162 v.apply ([&](Axis, double& a) |
163 { |
163 { |
164 roundToDecimals (a, Config->roundPositionPrecision()); |
164 roundToDecimals (a, m_config->roundPositionPrecision()); |
165 }); |
165 }); |
166 |
166 |
167 applyToMatrix (t, [&](int, double& a) |
167 applyToMatrix (t, [&](int, double& a) |
168 { |
168 { |
169 roundToDecimals (a, Config->roundMatrixPrecision()); |
169 roundToDecimals (a, m_config->roundMatrixPrecision()); |
170 }); |
170 }); |
171 |
171 |
172 mo->setPosition (v); |
172 mo->setPosition (v); |
173 mo->setTransform (t); |
173 mo->setTransform (t); |
174 num += 12; |
174 num += 12; |
178 for (int i = 0; i < obj->numVertices(); ++i) |
178 for (int i = 0; i < obj->numVertices(); ++i) |
179 { |
179 { |
180 Vertex v = obj->vertex (i); |
180 Vertex v = obj->vertex (i); |
181 v.apply ([&](Axis, double& a) |
181 v.apply ([&](Axis, double& a) |
182 { |
182 { |
183 roundToDecimals (a, Config->roundPositionPrecision()); |
183 roundToDecimals (a, m_config->roundPositionPrecision()); |
184 }); |
184 }); |
185 obj->setVertex (i, v); |
185 obj->setVertex (i, v); |
186 num += 3; |
186 num += 3; |
187 } |
187 } |
188 } |
188 } |
331 bool prevIsHistory = false; |
331 bool prevIsHistory = false; |
332 |
332 |
333 QDialog* dlg = new QDialog; |
333 QDialog* dlg = new QDialog; |
334 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; |
334 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; |
335 ui->setupUi (dlg); |
335 ui->setupUi (dlg); |
336 ui->m_username->setText (Config->defaultUser()); |
336 ui->m_username->setText (m_config->defaultUser()); |
337 ui->m_date->setDate (QDate::currentDate()); |
337 ui->m_date->setDate (QDate::currentDate()); |
338 ui->m_comment->setFocus(); |
338 ui->m_comment->setFocus(); |
339 |
339 |
340 if (not dlg->exec()) |
340 if (not dlg->exec()) |
341 return; |
341 return; |
361 |
361 |
362 prevIsHistory = ishistory; |
362 prevIsHistory = ishistory; |
363 } |
363 } |
364 |
364 |
365 int idx = obj ? obj->lineNumber() : 0; |
365 int idx = obj ? obj->lineNumber() : 0; |
366 currentDocument()->insertObj (idx++, comment); |
366 currentDocument()->insertObject (idx++, comment); |
367 |
367 |
368 // If we're adding a history line right before a scemantic object, pad it |
368 // If we're adding a history line right before a scemantic object, pad it |
369 // an empty line |
369 // an empty line |
370 if (obj and obj->next() and obj->next()->isScemantic()) |
370 if (obj and obj->next() and obj->next()->isScemantic()) |
371 currentDocument()->insertObj (idx, new LDEmpty); |
371 currentDocument()->insertObject (idx, new LDEmpty); |
372 |
372 |
373 m_window->buildObjectList(); |
373 m_window->buildObjectList(); |
374 delete ui; |
374 delete ui; |
375 } |
375 } |
376 |
376 |
377 void AlgorithmToolset::splitLines() |
377 void AlgorithmToolset::splitLines() |
378 { |
378 { |
379 bool ok; |
379 bool ok; |
380 int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:", |
380 int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:", |
381 Config->splitLinesSegments(), 0, std::numeric_limits<int>::max(), 1, &ok); |
381 m_config->splitLinesSegments(), 0, std::numeric_limits<int>::max(), 1, &ok); |
382 |
382 |
383 if (not ok) |
383 if (not ok) |
384 return; |
384 return; |
385 |
385 |
386 Config->setSplitLinesSegments (segments); |
386 m_config->setSplitLinesSegments (segments); |
387 |
387 |
388 for (LDObject* obj : selectedObjects()) |
388 for (LDObject* obj : selectedObjects()) |
389 { |
389 { |
390 if (not isOneOf (obj->type(), OBJ_Line, OBJ_CondLine)) |
390 if (not isOneOf (obj->type(), OBJ_Line, OBJ_CondLine)) |
391 continue; |
391 continue; |
542 doc->setName (LDDocument::shortenName (fullsubname)); |
542 doc->setName (LDDocument::shortenName (fullsubname)); |
543 |
543 |
544 LDObjectList objs; |
544 LDObjectList objs; |
545 objs << LDSpawn<LDComment> (subtitle); |
545 objs << LDSpawn<LDComment> (subtitle); |
546 objs << LDSpawn<LDComment> ("Name: "); // This gets filled in when the subfile is saved |
546 objs << LDSpawn<LDComment> ("Name: "); // This gets filled in when the subfile is saved |
547 objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", Config->defaultName(), Config->defaultUser())); |
547 objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", m_config->defaultName(), m_config->defaultUser())); |
548 objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); |
548 objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); |
549 |
549 |
550 if (not license.isEmpty()) |
550 if (not license.isEmpty()) |
551 objs << LDSpawn<LDComment> (license); |
551 objs << LDSpawn<LDComment> (license); |
552 |
552 |
575 LDSubfileReference* ref = LDSpawn<LDSubfileReference>(); |
575 LDSubfileReference* ref = LDSpawn<LDSubfileReference>(); |
576 ref->setColor (MainColor); |
576 ref->setColor (MainColor); |
577 ref->setFileInfo (doc); |
577 ref->setFileInfo (doc); |
578 ref->setPosition (Origin); |
578 ref->setPosition (Origin); |
579 ref->setTransform (IdentityMatrix); |
579 ref->setTransform (IdentityMatrix); |
580 currentDocument()->insertObj (refidx, ref); |
580 currentDocument()->insertObject (refidx, ref); |
581 |
581 |
582 // Refresh stuff |
582 // Refresh stuff |
583 m_window->updateDocumentList(); |
583 m_window->updateDocumentList(); |
584 m_window->doFullRefresh(); |
584 m_window->doFullRefresh(); |
585 } |
585 } |