# HG changeset patch # User Teemu Piippo # Date 1455672247 -7200 # Node ID d931a7547578d9080111b2d8ce1b649768ccd45a # Parent 9fc4c7d7c859404c4c963f3869d4ac365d283e57 Fixed circle mode not building the circle anymore diff -r 9fc4c7d7c859 -r d931a7547578 src/editmodes/circleMode.cpp --- a/src/editmodes/circleMode.cpp Wed Feb 17 03:15:10 2016 +0200 +++ b/src/editmodes/circleMode.cpp Wed Feb 17 03:24:07 2016 +0200 @@ -31,11 +31,13 @@ CircleMode::CircleMode (GLRenderer* renderer) : Super (renderer) {} + EditModeType CircleMode::type() const { return EditModeType::Circle; } + double CircleMode::getCircleDrawDist (int pos) const { if (m_drawedVerts.size() >= pos + 1) @@ -57,6 +59,7 @@ return 0.0; } + Matrix CircleMode::getCircleDrawMatrix (double scale) { // Matrix templates. 2 is substituted with the scale value, 1 is inverted to -1 if needed. @@ -80,7 +83,8 @@ return transform; } -void CircleMode::buildCircle() + +void CircleMode::endDraw() { LDObjectList objs; PrimitiveSpec spec; @@ -194,6 +198,7 @@ finishDraw (objs); } + double CircleMode::getAngleOffset() const { if (m_drawedVerts.isEmpty()) @@ -211,6 +216,7 @@ return angleoffset; } + void CircleMode::render (QPainter& painter) const { QFontMetrics metrics = QFontMetrics (QFont()); @@ -309,26 +315,15 @@ } } -bool CircleMode::mouseReleased (MouseEventData const& data) -{ - if (Super::mouseReleased (data)) - return true; - - if (data.releasedButtons & Qt::LeftButton) - { - if (m_drawedVerts.size() < 3) - addDrawnVertex (renderer()->position3D()); - else - buildCircle(); - - return true; - } - - return false; -} bool CircleMode::preAddVertex (const Vertex&) { m_angleOffset = getAngleOffset(); return false; } + + +int CircleMode::maxVertices() const +{ + return 3; +} \ No newline at end of file diff -r 9fc4c7d7c859 -r d931a7547578 src/editmodes/circleMode.h --- a/src/editmodes/circleMode.h Wed Feb 17 03:15:10 2016 +0200 +++ b/src/editmodes/circleMode.h Wed Feb 17 03:24:07 2016 +0200 @@ -22,20 +22,21 @@ class CircleMode : public AbstractDrawMode { DEFINE_CLASS (CircleMode, AbstractDrawMode) - double m_angleOffset; public: CircleMode (GLRenderer* renderer); - virtual void render (QPainter& painter) const override; - virtual EditModeType type() const override; - + void endDraw() override; double getCircleDrawDist (int pos) const; Matrix getCircleDrawMatrix (double scale); - bool mouseReleased (const AbstractEditMode::MouseEventData& data) override; + int maxVertices() const override; bool preAddVertex (Vertex const&) override; + void render (QPainter& painter) const override; + EditModeType type() const override; private: + double m_angleOffset; + void buildCircle(); double getAngleOffset() const; };