# HG changeset patch # User Teemu Piippo # Date 1529439538 -10800 # Node ID f5eb947a2e7f7e4795e6e0c6012efe19989fab87 # Parent b48f3fd2664b8510172873a7bdd1d5f526950d09 added support for inverting circular primitives diff -r b48f3fd2664b -r f5eb947a2e7f src/algorithms/invert.cpp --- a/src/algorithms/invert.cpp Tue Jun 19 22:45:10 2018 +0300 +++ b/src/algorithms/invert.cpp Tue Jun 19 23:18:58 2018 +0300 @@ -17,6 +17,7 @@ */ #include "../linetypes/modelobject.h" +#include "../linetypes/circularprimitive.h" #include "../lddocument.h" #include "../glShared.h" @@ -128,6 +129,15 @@ reference->setInverted(not reference->isInverted()); } } + else if (obj->type() == LDObjectType::CircularPrimitive) + { + auto primitive = static_cast(obj); + + if (primitive->isFlat()) + primitive->setTransformationMatrix(primitive->transformationMatrix() * ::flipmatrix(Y)); + else + primitive->setInverted(not primitive->isInverted()); + } } /* diff -r b48f3fd2664b -r f5eb947a2e7f src/dialogs/circularprimitiveeditor.cpp --- a/src/dialogs/circularprimitiveeditor.cpp Tue Jun 19 22:45:10 2018 +0300 +++ b/src/dialogs/circularprimitiveeditor.cpp Tue Jun 19 23:18:58 2018 +0300 @@ -120,6 +120,11 @@ this->primitive->setTransformationMatrix(newMatrix); } ); + connect(ui.inverted, &QCheckBox::clicked, [&](bool checked) + { + if (this->primitive) + this->primitive->setInverted(checked); + }); // Connect the reset button, "reset button" here meaning any button with the reset role. connect( ui.buttonBox, @@ -176,6 +181,7 @@ }); withSignalsBlocked(ui.color, [&](){ ui.color->setColor(primitive->color()); }); withSignalsBlocked(ui.matrix, [&](){ ui.matrix->setMatrix(primitive->transformationMatrix()); }); + withSignalsBlocked(ui.inverted, [&](){ ui.inverted->setChecked(primitive->isInverted()); }); } } diff -r b48f3fd2664b -r f5eb947a2e7f src/dialogs/circularprimitiveeditor.ui --- a/src/dialogs/circularprimitiveeditor.ui Tue Jun 19 22:45:10 2018 +0300 +++ b/src/dialogs/circularprimitiveeditor.ui Tue Jun 19 23:18:58 2018 +0300 @@ -66,6 +66,13 @@ + + + + Inverted + + + diff -r b48f3fd2664b -r f5eb947a2e7f src/linetypes/circularprimitive.cpp --- a/src/linetypes/circularprimitive.cpp Tue Jun 19 22:45:10 2018 +0300 +++ b/src/linetypes/circularprimitive.cpp Tue Jun 19 23:18:58 2018 +0300 @@ -68,6 +68,20 @@ return true; } +bool LDCircularPrimitive::isFlat() const +{ + switch (m_type) + { + case PrimitiveModel::Cylinder: + case PrimitiveModel::CylinderClosed: + case PrimitiveModel::CylinderOpen: + return false; + + default: + return true; + } +} + void LDCircularPrimitive::rasterize( DocumentManager* context, Winding /* parentWinding */, diff -r b48f3fd2664b -r f5eb947a2e7f src/linetypes/circularprimitive.h --- a/src/linetypes/circularprimitive.h Tue Jun 19 22:45:10 2018 +0300 +++ b/src/linetypes/circularprimitive.h Tue Jun 19 23:18:58 2018 +0300 @@ -19,6 +19,7 @@ QString asText() const override; void getVertices(DocumentManager *context, QSet& verts) const override; bool isRasterizable() const override; + bool isFlat() const; void rasterize( DocumentManager* context, Winding parentWinding,