Sun, 04 Oct 2015 16:55:26 +0300
Fix rectangle mode for real
Handle Bézier curves in external programs (rasterize them when passing them on)
--- a/src/editmodes/rectangleMode.cpp Sun Oct 04 16:45:30 2015 +0300 +++ b/src/editmodes/rectangleMode.cpp Sun Oct 04 16:55:26 2015 +0300 @@ -37,31 +37,19 @@ QVector<Vertex> ({renderer()->position3D()}), true, false); } -bool RectangleMode::mouseReleased (MouseEventData const& data) +void RectangleMode::endDraw() { - if (Super::mouseReleased (data)) - return true; - - if (data.releasedButtons & Qt::LeftButton) + if (m_drawedVerts.size() == 2) { - if (m_drawedVerts.size() == 2) - { - LDQuad* quad (LDSpawn<LDQuad>()); - updateRectVerts(); + LDQuad* quad = LDSpawn<LDQuad>(); + updateRectVerts(); - for (int i = 0; i < quad->numVertices(); ++i) - quad->setVertex (i, m_rectangleVerts[i]); + for (int i = 0; i < quad->numVertices(); ++i) + quad->setVertex (i, m_rectangleVerts[i]); - quad->setColor (MainColor); - finishDraw (LDObjectList ({quad})); - return true; - } - - addDrawnVertex (renderer()->position3D()); - return true; + quad->setColor (MainColor); + finishDraw (LDObjectList ({quad})); } - - return false; } //
--- a/src/editmodes/rectangleMode.h Sun Oct 04 16:45:30 2015 +0300 +++ b/src/editmodes/rectangleMode.h Sun Oct 04 16:55:26 2015 +0300 @@ -27,10 +27,11 @@ public: RectangleMode (GLRenderer* renderer); - virtual void render (QPainter& painter) const override; - virtual EditModeType type() const override; - virtual bool mouseReleased (MouseEventData const& data) override; - virtual bool mouseMoved (QMouseEvent*) override; + void render (QPainter& painter) const override; + EditModeType type() const override; + void endDraw() override; + bool mouseMoved (QMouseEvent*) override; + int maxVertices() const override { return 2; } private: void updateRectVerts();
--- a/src/toolsets/extprogramtoolset.cpp Sun Oct 04 16:45:30 2015 +0300 +++ b/src/toolsets/extprogramtoolset.cpp Sun Oct 04 16:55:26 2015 +0300 @@ -170,7 +170,15 @@ { LDSubfile* ref = static_cast<LDSubfile*> (obj); LDObjectList objs = ref->inlineContents (true, false); + writeObjects (objs, f); + for (LDObject* obj : objs) + obj->destroy(); + } + else if (obj->type() == OBJ_BezierCurve) + { + LDBezierCurve* curve = static_cast<LDBezierCurve*> (obj); + LDObjectList objs = curve->rasterize(); writeObjects (objs, f); for (LDObject* obj : objs)