# HG changeset patch # User Teemu Piippo # Date 1488753823 -7200 # Node ID f7151e4cd90fb2eff4e85cc40199fa6996cd8f2d # Parent e22cba39230a4543c2e34738385cfd5561bb9ef5 MathFunctions is now a namespace. diff -r e22cba39230a -r f7151e4cd90f src/hierarchyelement.cpp --- 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(); -} diff -r e22cba39230a -r f7151e4cd90f src/hierarchyelement.h --- 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 diff -r e22cba39230a -r f7151e4cd90f src/mainwindow.cpp --- 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) : diff -r e22cba39230a -r f7151e4cd90f src/mainwindow.h --- 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 m_renderers; PrimitiveManager* m_primitives; Grid* m_grid; - MathFunctions* m_mathFunctions; QVector m_sel; QVector m_quickColors; QList m_colorButtons; diff -r e22cba39230a -r f7151e4cd90f src/mathfunctions.cpp --- 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& objects) const +void MathFunctions::rotateObjects(int l, int m, int n, double angle, const QVector& objects) { Vertex rotationPoint = getRotationPoint (objects); double cosAngle = cos(angle); @@ -83,7 +79,7 @@ } -Vertex MathFunctions::getRotationPoint(const QVector& objs) const +Vertex MathFunctions::getRotationPoint(const QVector& objs) { switch (RotationPoint (configuration().rotationPointType())) { diff -r e22cba39230a -r f7151e4cd90f src/mathfunctions.h --- 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& objects) const; - Vertex getRotationPoint(const QVector& 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& objects); + void rotateVertex(Vertex& vertex, const Vertex& rotationPoint, const Matrix& transformationMatrix); + Vertex getRotationPoint(const QVector& objs); +} diff -r e22cba39230a -r f7151e4cd90f src/toolsets/movetoolset.cpp --- 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()