Moved the identity matrix constant into Matrix's namespace

Sat, 28 Jan 2017 17:23:04 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 28 Jan 2017 17:23:04 +0200
changeset 1070
292c64cb2a75
parent 1069
220cde0fa2d9
child 1071
ff4639b672ae

Moved the identity matrix constant into Matrix's namespace

src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/basics.h file | annotate | diff | comparison | revisions
src/glRenderer.cpp file | annotate | diff | comparison | revisions
src/ldObject.cpp file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
src/toolsets/algorithmtoolset.cpp file | annotate | diff | comparison | revisions
src/types/matrix.cpp file | annotate | diff | comparison | revisions
src/types/matrix.h file | annotate | diff | comparison | revisions
--- a/src/addObjectDialog.cpp	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/addObjectDialog.cpp	Sat Jan 28 17:23:04 2017 +0200
@@ -193,7 +193,7 @@
 		QLabel* lb_matrix = new QLabel ("Matrix:");
 		le_matrix = new QLineEdit;
 		// le_matrix->setValidator (new QDoubleValidator);
-		Matrix defaultMatrix = IdentityMatrix;
+		Matrix defaultMatrix = Matrix::identity;
 
 		if (mo)
 		{
@@ -299,7 +299,7 @@
 		return; // Nothing to edit with empties
 
 	const bool newObject = (obj == nullptr);
-	Matrix transform = IdentityMatrix;
+	Matrix transform = Matrix::identity;
 	AddObjectDialog dlg (type, obj);
 
 	if (obj and obj->type() != type)
--- a/src/basics.h	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/basics.h	Sat Jan 28 17:23:04 2017 +0200
@@ -125,7 +125,6 @@
 };
 
 extern const Vertex Origin;
-extern const Matrix IdentityMatrix;
 
 static const double pi = 3.14159265358979323846;
 
--- a/src/glRenderer.cpp	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/glRenderer.cpp	Sat Jan 28 17:23:04 2017 +0200
@@ -1567,7 +1567,7 @@
 		ref->setColor (MainColor);
 		ref->setFileInfo (m_documents->getDocumentByName (primitiveName));
 		ref->setPosition (Origin);
-		ref->setTransformationMatrix (IdentityMatrix);
+		ref->setTransformationMatrix (Matrix::identity);
 		currentDocument()->insertObject (m_window->suggestInsertPoint(), ref);
 		ref->select();
 		m_window->buildObjectList();
--- a/src/ldObject.cpp	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/ldObject.cpp	Sat Jan 28 17:23:04 2017 +0200
@@ -699,7 +699,7 @@
 	{
 		// Subfile has all vertices zero on one specific plane, so it is flat.
 		// Let's flip it.
-		Matrix matrixModifier = IdentityMatrix;
+		Matrix matrixModifier = Matrix::identity;
 
 		if (axisSet & (1 << X))
 			matrixModifier(0, 0) = -1;
--- a/src/main.cpp	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/main.cpp	Sat Jan 28 17:23:04 2017 +0200
@@ -26,7 +26,6 @@
 
 MainWindow* g_win = nullptr;
 const Vertex Origin (0.0f, 0.0f, 0.0f);
-const Matrix IdentityMatrix ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
 
 ConfigOption (bool FirstStart = true)
 
--- a/src/toolsets/algorithmtoolset.cpp	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/toolsets/algorithmtoolset.cpp	Sat Jan 28 17:23:04 2017 +0200
@@ -576,7 +576,7 @@
 		ref->setColor (MainColor);
 		ref->setFileInfo (doc);
 		ref->setPosition (Origin);
-		ref->setTransformationMatrix (IdentityMatrix);
+		ref->setTransformationMatrix (Matrix::identity);
 		currentDocument()->insertObject (refidx, ref);
 
 		// Refresh stuff
--- a/src/types/matrix.cpp	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/types/matrix.cpp	Sat Jan 28 17:23:04 2017 +0200
@@ -20,6 +20,8 @@
 #include "../format.h"
 #include "matrix.h"
 
+const Matrix Matrix::identity {1, 0, 0, 0, 1, 0, 0, 0, 1};
+
 /*
  * Default-constructor for a matrix
  */
--- a/src/types/matrix.h	Sat Jan 28 17:20:16 2017 +0200
+++ b/src/types/matrix.h	Sat Jan 28 17:23:04 2017 +0200
@@ -52,6 +52,8 @@
 	double& operator()(int row, int column);
 	const double& operator()(int row, int column) const;
 
+	static const Matrix identity;
+
 private:
 	double m_values[9];
 };

mercurial