src/toolsets/algorithmtoolset.cpp

changeset 970
c8aae45afd85
parent 969
b1742ee91d5b
child 971
c00f9665a9f8
--- a/src/toolsets/algorithmtoolset.cpp	Sun Aug 30 17:20:55 2015 +0300
+++ b/src/toolsets/algorithmtoolset.cpp	Mon Aug 31 04:57:16 2015 +0300
@@ -38,14 +38,9 @@
 #include "ui_addhistoryline.h"
 #include "algorithmtoolset.h"
 
-EXTERN_CFGENTRY (String, DefaultUser)
-
-CFGENTRY (Int, RoundPosition, 3)
-CFGENTRY (Int, RoundMatrix, 4)
-CFGENTRY (Int, SplitLinesSegments, 5)
-EXTERN_CFGENTRY (String, DefaultName)
-EXTERN_CFGENTRY (String, DefaultUser)
-EXTERN_CFGENTRY (Bool, UseCALicense)
+ConfigOption (int roundPositionPrecision = 3)
+ConfigOption (int roundMatrixPrecision = 4)
+ConfigOption (int splitLinesSegments = 5)
 
 AlgorithmToolset::AlgorithmToolset (MainWindow* parent) :
 	Toolset (parent)
@@ -163,9 +158,15 @@
 			Vertex v = mo->position();
 			Matrix t = mo->transform();
 
-			// Note: matrix values are to be rounded to 4 decimals.
-			v.apply ([](Axis, double& a) { RoundToDecimals (a, cfg::RoundPosition); });
-			ApplyToMatrix (t, [](int, double& a) { RoundToDecimals (a, cfg::RoundMatrix); });
+			v.apply ([](Axis, double& a)
+			{
+				RoundToDecimals (a, m_config->roundPositionPrecision);
+			});
+
+			ApplyToMatrix (t, [](int, double& a)
+			{
+				RoundToDecimals (a, m_config->roundMatrixPrecision);
+			});
 
 			mo->setPosition (v);
 			mo->setTransform (t);
@@ -176,7 +177,10 @@
 			for (int i = 0; i < obj->numVertices(); ++i)
 			{
 				Vertex v = obj->vertex (i);
-				v.apply ([](Axis, double& a) { RoundToDecimals (a, cfg::RoundPosition); });
+				v.apply ([](Axis, double& a)
+				{
+					RoundToDecimals (a, m_config->roundPositionPrecision);
+				});
 				obj->setVertex (i, v);
 				num += 3;
 			}
@@ -328,7 +332,7 @@
 	QDialog* dlg = new QDialog;
 	Ui_AddHistoryLine* ui = new Ui_AddHistoryLine;
 	ui->setupUi (dlg);
-	ui->m_username->setText (cfg::DefaultUser);
+	ui->m_username->setText (m_config->defaultUser);
 	ui->m_date->setDate (QDate::currentDate());
 	ui->m_comment->setFocus();
 
@@ -372,13 +376,14 @@
 void AlgorithmToolset::splitLines()
 {
 	bool ok;
-	int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:", cfg::SplitLinesSegments, 0,
+	int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:",
+		m_window->config (m_config->splitLinesSegments), 0,
 		std::numeric_limits<int>::max(), 1, &ok);
 
 	if (not ok)
 		return;
 
-	cfg::SplitLinesSegments = segments;
+	m_config->splitLinesSegments = segments;
 
 	for (LDObject* obj : Selection())
 	{
@@ -539,7 +544,7 @@
 	LDObjectList objs;
 	objs << LDSpawn<LDComment> (subtitle);
 	objs << LDSpawn<LDComment> ("Name: "); // This gets filled in when the subfile is saved
-	objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", cfg::DefaultName, cfg::DefaultUser));
+	objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", m_config->defaultName, m_config->defaultUser));
 	objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart");
 
 	if (not license.isEmpty())

mercurial