MathFunctions is now a namespace.

Mon, 06 Mar 2017 00:43:43 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 06 Mar 2017 00:43:43 +0200
changeset 1198
f7151e4cd90f
parent 1197
e22cba39230a
child 1199
613a981223a6

MathFunctions is now a namespace.

src/hierarchyelement.cpp file | annotate | diff | comparison | revisions
src/hierarchyelement.h file | annotate | diff | comparison | revisions
src/mainwindow.cpp file | annotate | diff | comparison | revisions
src/mainwindow.h file | annotate | diff | comparison | revisions
src/mathfunctions.cpp file | annotate | diff | comparison | revisions
src/mathfunctions.h file | annotate | diff | comparison | revisions
src/toolsets/movetoolset.cpp file | annotate | diff | comparison | revisions
--- a/src/hierarchyelement.cpp	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/hierarchyelement.cpp	Mon Mar 06 00:43:43 2017 +0200
@@ -67,9 +67,3 @@
 {
 	return m_window->grid();
 }
-
-
-MathFunctions* HierarchyElement::math() const
-{
-	return m_window->mathFunctions();
-}
--- a/src/hierarchyelement.h	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/hierarchyelement.h	Mon Mar 06 00:43:43 2017 +0200
@@ -27,7 +27,6 @@
 class DocumentManager;
 class PrimitiveManager;
 class Grid;
-class MathFunctions;
 class MainWindow;
 
 //
@@ -43,7 +42,6 @@
 	LDDocument* currentDocument();
 	PrimitiveManager* primitives();
 	Grid* grid() const;
-	MathFunctions* math() const;
 
 	// Format and print the given args to the message log.
 	template<typename... Args>
--- a/src/mainwindow.cpp	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/mainwindow.cpp	Mon Mar 06 00:43:43 2017 +0200
@@ -53,7 +53,6 @@
     QMainWindow (parent, flags),
 	m_primitives(new PrimitiveManager(this)),
     m_grid(new Grid),
-	m_mathFunctions(new MathFunctions(this)),
 	ui (*new Ui_MainWindow),
 	m_externalPrograms (nullptr),
     m_settings (makeSettings (this)),
@@ -169,7 +168,6 @@
 {
 	delete m_primitives;
 	delete m_grid;
-	delete m_mathFunctions;
 	delete &ui;
 	delete m_settings;
 
@@ -1224,11 +1222,6 @@
 	return m_grid;
 }
 
-MathFunctions* MainWindow::mathFunctions() const
-{
-	return m_mathFunctions;
-}
-
 // ---------------------------------------------------------------------------------------------------------------------
 //
 ColorToolbarItem::ColorToolbarItem (LDColor color, QToolButton* toolButton) :
--- a/src/mainwindow.h	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/mainwindow.h	Mon Mar 06 00:43:43 2017 +0200
@@ -36,7 +36,6 @@
 class Configuration;
 class PrimitiveManager;
 class Grid;
-class MathFunctions;
 class DocumentManager;
 class LDDocument;
 
@@ -88,7 +87,6 @@
 	Canvas* getRendererForDocument(LDDocument* document);
 	Grid* grid();
 	void loadShortcuts();
-	MathFunctions* mathFunctions() const;
 	MessageManager* messageLog() const;
 	LDDocument* newDocument (bool cache = false);
 	void openDocumentForEditing(LDDocument* document);
@@ -149,7 +147,6 @@
 	QMap<LDDocument*, Canvas*> m_renderers;
 	PrimitiveManager* m_primitives;
 	Grid* m_grid;
-	MathFunctions* m_mathFunctions;
 	QVector<LDObject*> m_sel;
 	QVector<ColorToolbarItem>	m_quickColors;
 	QList<QToolButton*>	m_colorButtons;
--- a/src/mathfunctions.cpp	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/mathfunctions.cpp	Mon Mar 06 00:43:43 2017 +0200
@@ -21,11 +21,7 @@
 #include "miscallenous.h"
 
 
-MathFunctions::MathFunctions(QObject* parent) :
-	HierarchyElement(parent) {}
-
-
-void MathFunctions::rotateVertex(Vertex& vertex, const Vertex& rotationPoint, const Matrix& transformationMatrix) const
+void MathFunctions::rotateVertex(Vertex& vertex, const Vertex& rotationPoint, const Matrix& transformationMatrix)
 {
 	vertex -= rotationPoint;
 	vertex.transform (transformationMatrix, {0, 0, 0});
@@ -33,7 +29,7 @@
 }
 
 
-void MathFunctions::rotateObjects(int l, int m, int n, double angle, const QVector<LDObject*>& objects) const
+void MathFunctions::rotateObjects(int l, int m, int n, double angle, const QVector<LDObject*>& objects)
 {
 	Vertex rotationPoint = getRotationPoint (objects);
 	double cosAngle = cos(angle);
@@ -83,7 +79,7 @@
 }
 
 
-Vertex MathFunctions::getRotationPoint(const QVector<LDObject*>& objs) const
+Vertex MathFunctions::getRotationPoint(const QVector<LDObject*>& objs)
 {
 	switch (RotationPoint (configuration().rotationPointType()))
 	{
--- a/src/mathfunctions.h	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/mathfunctions.h	Mon Mar 06 00:43:43 2017 +0200
@@ -18,8 +18,6 @@
 
 #pragma once
 #include "main.h"
-#include "hierarchyelement.h"
-
 
 enum RotationPoint
 {
@@ -28,16 +26,9 @@
 	CustomPoint,
 };
 
-
-class MathFunctions : public HierarchyElement
+namespace MathFunctions
 {
-public:
-	MathFunctions(QObject* parent);
-
-	void rotateObjects(int l, int m, int n, double angle, const QVector<LDObject*>& objects) const;
-	Vertex getRotationPoint(const QVector<LDObject*>& objs) const;
-
-private:
-	void rotateVertex(Vertex& vertex, const Vertex& rotationPoint, const Matrix& transformationMatrix) const;
-};
-
+    void rotateObjects(int l, int m, int n, double angle, const QVector<LDObject*>& objects);
+	void rotateVertex(Vertex& vertex, const Vertex& rotationPoint, const Matrix& transformationMatrix);
+	Vertex getRotationPoint(const QVector<LDObject*>& objs);
+}
--- a/src/toolsets/movetoolset.cpp	Mon Mar 06 00:41:13 2017 +0200
+++ b/src/toolsets/movetoolset.cpp	Mon Mar 06 00:43:43 2017 +0200
@@ -146,32 +146,32 @@
 
 void MoveToolset::rotateXPos()
 {
-	math()->rotateObjects (1, 0, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
+	MathFunctions::rotateObjects (1, 0, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
 }
 
 void MoveToolset::rotateYPos()
 {
-	math()->rotateObjects (0, 1, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
+	MathFunctions::rotateObjects (0, 1, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
 }
 
 void MoveToolset::rotateZPos()
 {
-	math()->rotateObjects (0, 0, 1, getRotateActionAngle(), selectedObjects().toList().toVector());
+	MathFunctions::rotateObjects (0, 0, 1, getRotateActionAngle(), selectedObjects().toList().toVector());
 }
 
 void MoveToolset::rotateXNeg()
 {
-	math()->rotateObjects (-1, 0, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
+	MathFunctions::rotateObjects (-1, 0, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
 }
 
 void MoveToolset::rotateYNeg()
 {
-	math()->rotateObjects (0, -1, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
+	MathFunctions::rotateObjects (0, -1, 0, getRotateActionAngle(), selectedObjects().toList().toVector());
 }
 
 void MoveToolset::rotateZNeg()
 {
-	math()->rotateObjects (0, 0, -1, getRotateActionAngle(), selectedObjects().toList().toVector());
+	MathFunctions::rotateObjects (0, 0, -1, getRotateActionAngle(), selectedObjects().toList().toVector());
 }
 
 void MoveToolset::configureRotationPoint()

mercurial