Tue, 19 Jun 2018 23:56:07 +0300
added buttons to rotate circular primitives
--- a/src/dialogs/circularprimitiveeditor.cpp Tue Jun 19 23:18:58 2018 +0300 +++ b/src/dialogs/circularprimitiveeditor.cpp Tue Jun 19 23:56:07 2018 +0300 @@ -125,6 +125,8 @@ if (this->primitive) this->primitive->setInverted(checked); }); + connect(ui.rotateCcw, &QPushButton::clicked, [&](){ rotate(-1); }); + connect(ui.rotateCw, &QPushButton::clicked, [&](){ rotate(1); }); // Connect the reset button, "reset button" here meaning any button with the reset role. connect( ui.buttonBox, @@ -193,3 +195,16 @@ if (primitive) primitive->restore(originalState); // Restoring does not change 'originalState' } + +void CircularPrimitiveEditor::rotate(double factor) +{ + if (primitive) + { + double angle = factor * 360.0 / primitive->divisions(); + + QQuaternion rotation = QQuaternion::fromAxisAndAngle({0.0f, 1.0f, 0.0f}, angle); + QMatrix4x4 matrix = primitive->transformationMatrix(); + matrix.rotate(rotation); + primitive->setTransformationMatrix(matrix); + } +}
--- a/src/dialogs/circularprimitiveeditor.h Tue Jun 19 23:18:58 2018 +0300 +++ b/src/dialogs/circularprimitiveeditor.h Tue Jun 19 23:56:07 2018 +0300 @@ -31,6 +31,7 @@ private: Q_SLOT void updateWidgets(); Q_SLOT void reset(); + void rotate(double factor); class Ui_CircularPrimitiveEditor& ui; LDCircularPrimitive* primitive;
--- a/src/dialogs/circularprimitiveeditor.ui Tue Jun 19 23:18:58 2018 +0300 +++ b/src/dialogs/circularprimitiveeditor.ui Tue Jun 19 23:56:07 2018 +0300 @@ -138,10 +138,28 @@ <property name="title"> <string>Transformation</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0"> <item> <widget class="MatrixEditor" name="matrix" native="true"/> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="rotateCcw"> + <property name="text"> + <string>↺</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="rotateCw"> + <property name="text"> + <string>↻</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item>