36 #include "ui_editraw.h" |
36 #include "ui_editraw.h" |
37 #include "ui_flip.h" |
37 #include "ui_flip.h" |
38 #include "ui_addhistoryline.h" |
38 #include "ui_addhistoryline.h" |
39 #include "algorithmtoolset.h" |
39 #include "algorithmtoolset.h" |
40 |
40 |
41 EXTERN_CFGENTRY (String, DefaultUser) |
41 ConfigOption (int roundPositionPrecision = 3) |
42 |
42 ConfigOption (int roundMatrixPrecision = 4) |
43 CFGENTRY (Int, RoundPosition, 3) |
43 ConfigOption (int splitLinesSegments = 5) |
44 CFGENTRY (Int, RoundMatrix, 4) |
|
45 CFGENTRY (Int, SplitLinesSegments, 5) |
|
46 EXTERN_CFGENTRY (String, DefaultName) |
|
47 EXTERN_CFGENTRY (String, DefaultUser) |
|
48 EXTERN_CFGENTRY (Bool, UseCALicense) |
|
49 |
44 |
50 AlgorithmToolset::AlgorithmToolset (MainWindow* parent) : |
45 AlgorithmToolset::AlgorithmToolset (MainWindow* parent) : |
51 Toolset (parent) |
46 Toolset (parent) |
52 { |
47 { |
53 } |
48 } |
161 if (mo != null) |
156 if (mo != null) |
162 { |
157 { |
163 Vertex v = mo->position(); |
158 Vertex v = mo->position(); |
164 Matrix t = mo->transform(); |
159 Matrix t = mo->transform(); |
165 |
160 |
166 // Note: matrix values are to be rounded to 4 decimals. |
161 v.apply ([](Axis, double& a) |
167 v.apply ([](Axis, double& a) { RoundToDecimals (a, cfg::RoundPosition); }); |
162 { |
168 ApplyToMatrix (t, [](int, double& a) { RoundToDecimals (a, cfg::RoundMatrix); }); |
163 RoundToDecimals (a, m_config->roundPositionPrecision); |
|
164 }); |
|
165 |
|
166 ApplyToMatrix (t, [](int, double& a) |
|
167 { |
|
168 RoundToDecimals (a, m_config->roundMatrixPrecision); |
|
169 }); |
169 |
170 |
170 mo->setPosition (v); |
171 mo->setPosition (v); |
171 mo->setTransform (t); |
172 mo->setTransform (t); |
172 num += 12; |
173 num += 12; |
173 } |
174 } |
174 else |
175 else |
175 { |
176 { |
176 for (int i = 0; i < obj->numVertices(); ++i) |
177 for (int i = 0; i < obj->numVertices(); ++i) |
177 { |
178 { |
178 Vertex v = obj->vertex (i); |
179 Vertex v = obj->vertex (i); |
179 v.apply ([](Axis, double& a) { RoundToDecimals (a, cfg::RoundPosition); }); |
180 v.apply ([](Axis, double& a) |
|
181 { |
|
182 RoundToDecimals (a, m_config->roundPositionPrecision); |
|
183 }); |
180 obj->setVertex (i, v); |
184 obj->setVertex (i, v); |
181 num += 3; |
185 num += 3; |
182 } |
186 } |
183 } |
187 } |
184 } |
188 } |
326 bool prevIsHistory = false; |
330 bool prevIsHistory = false; |
327 |
331 |
328 QDialog* dlg = new QDialog; |
332 QDialog* dlg = new QDialog; |
329 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; |
333 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; |
330 ui->setupUi (dlg); |
334 ui->setupUi (dlg); |
331 ui->m_username->setText (cfg::DefaultUser); |
335 ui->m_username->setText (m_config->defaultUser); |
332 ui->m_date->setDate (QDate::currentDate()); |
336 ui->m_date->setDate (QDate::currentDate()); |
333 ui->m_comment->setFocus(); |
337 ui->m_comment->setFocus(); |
334 |
338 |
335 if (not dlg->exec()) |
339 if (not dlg->exec()) |
336 return; |
340 return; |
370 } |
374 } |
371 |
375 |
372 void AlgorithmToolset::splitLines() |
376 void AlgorithmToolset::splitLines() |
373 { |
377 { |
374 bool ok; |
378 bool ok; |
375 int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:", cfg::SplitLinesSegments, 0, |
379 int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:", |
|
380 m_window->config (m_config->splitLinesSegments), 0, |
376 std::numeric_limits<int>::max(), 1, &ok); |
381 std::numeric_limits<int>::max(), 1, &ok); |
377 |
382 |
378 if (not ok) |
383 if (not ok) |
379 return; |
384 return; |
380 |
385 |
381 cfg::SplitLinesSegments = segments; |
386 m_config->splitLinesSegments = segments; |
382 |
387 |
383 for (LDObject* obj : Selection()) |
388 for (LDObject* obj : Selection()) |
384 { |
389 { |
385 if (not isOneOf (obj->type(), OBJ_Line, OBJ_CondLine)) |
390 if (not isOneOf (obj->type(), OBJ_Line, OBJ_CondLine)) |
386 continue; |
391 continue; |
537 doc->setName (LDDocument::shortenName (fullsubname)); |
542 doc->setName (LDDocument::shortenName (fullsubname)); |
538 |
543 |
539 LDObjectList objs; |
544 LDObjectList objs; |
540 objs << LDSpawn<LDComment> (subtitle); |
545 objs << LDSpawn<LDComment> (subtitle); |
541 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 |
542 objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", cfg::DefaultName, cfg::DefaultUser)); |
547 objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", m_config->defaultName, m_config->defaultUser)); |
543 objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); |
548 objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); |
544 |
549 |
545 if (not license.isEmpty()) |
550 if (not license.isEmpty()) |
546 objs << LDSpawn<LDComment> (license); |
551 objs << LDSpawn<LDComment> (license); |
547 |
552 |