# HG changeset patch # User Teemu Piippo # Date 1409654041 -10800 # Node ID ba75c789667e2316a23bc307b41c66af9c098ae3 # Parent 20108369330022ac9ec40853e58583713507eac1 - added line loop mode (doesn't actually create anything yet) diff -r 201083693300 -r ba75c789667e CMakeLists.txt --- a/CMakeLists.txt Mon Sep 01 10:37:42 2014 +0300 +++ b/CMakeLists.txt Tue Sep 02 13:34:01 2014 +0300 @@ -67,6 +67,7 @@ src/editmodes/abstractEditMode.cc src/editmodes/circleMode.cc src/editmodes/drawMode.cc + src/editmodes/lineLoopMode.cpp src/editmodes/magicWandMode.cc src/editmodes/rectangleMode.cc src/editmodes/selectMode.cc @@ -102,6 +103,7 @@ src/editmodes/abstractEditMode.h src/editmodes/circleMode.h src/editmodes/drawMode.h + src/editmodes/lineLoopMode.h src/editmodes/magicWandMode.h src/editmodes/rectangleMode.h src/editmodes/selectMode.h diff -r 201083693300 -r ba75c789667e src/actions.cc --- a/src/actions.cc Mon Sep 01 10:37:42 2014 +0300 +++ b/src/actions.cc Tue Sep 02 13:34:01 2014 +0300 @@ -595,6 +595,11 @@ R()->setEditMode (EditModeType::MagicWand); } +void MainWindow::slot_actionModeLineLoop() +{ + R()->setEditMode (EditModeType::LineLoop); +} + // ============================================================================= // void MainWindow::slot_actionDrawAngles() diff -r 201083693300 -r ba75c789667e src/editmodes/abstractEditMode.cc --- a/src/editmodes/abstractEditMode.cc Mon Sep 01 10:37:42 2014 +0300 +++ b/src/editmodes/abstractEditMode.cc Tue Sep 02 13:34:01 2014 +0300 @@ -24,6 +24,7 @@ #include "rectangleMode.h" #include "circleMode.h" #include "magicWandMode.h" +#include "lineLoopMode.h" #include "../mainWindow.h" #include "../glRenderer.h" @@ -44,6 +45,7 @@ case EditModeType::Rectangle: return new RectangleMode (renderer); case EditModeType::Circle: return new CircleMode (renderer); case EditModeType::MagicWand: return new MagicWandMode (renderer); + case EditModeType::LineLoop: return new LineLoopMode (renderer); } throw std::logic_error ("bad type given to AbstractEditMode::createByType"); diff -r 201083693300 -r ba75c789667e src/editmodes/abstractEditMode.h --- a/src/editmodes/abstractEditMode.h Mon Sep 01 10:37:42 2014 +0300 +++ b/src/editmodes/abstractEditMode.h Tue Sep 02 13:34:01 2014 +0300 @@ -30,6 +30,7 @@ Rectangle, Circle, MagicWand, + LineLoop, }; class AbstractEditMode diff -r 201083693300 -r ba75c789667e src/editmodes/lineLoopMode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/editmodes/lineLoopMode.cpp Tue Sep 02 13:34:01 2014 +0300 @@ -0,0 +1,36 @@ +#include "lineLoopMode.h" +#include "../glRenderer.h" + +LineLoopMode::LineLoopMode (GLRenderer *renderer) : + Super (renderer) {} + +void LineLoopMode::render (QPainter& painter) const +{ + renderer()->drawBlip (painter, renderer()->coordconv3_2 (renderer()->position3D())); + QVector points; + + for (Vertex const& vrt : m_drawedVerts) + points << renderer()->coordconv3_2 (vrt); + + painter.setPen (renderer()->textPen()); + + for (int i = 0; i < points.size() - 1; ++i) + painter.drawLine (QLineF (points[i], points[i + 1])); + + for (QPointF const& point : points) + renderer()->drawBlip (painter, point); +} + +bool LineLoopMode::mouseReleased (MouseEventData const& data) +{ + if (Super::mouseReleased (data)) + return true; + + if (data.releasedButtons & Qt::LeftButton) + { + addDrawnVertex (renderer()->position3D()); + return true; + } + + return false; +} diff -r 201083693300 -r ba75c789667e src/editmodes/lineLoopMode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/editmodes/lineLoopMode.h Tue Sep 02 13:34:01 2014 +0300 @@ -0,0 +1,15 @@ +#pragma once +#include "abstractEditMode.h" + +class LineLoopMode : public AbstractDrawMode +{ + DEFINE_CLASS (LineLoopMode, AbstractDrawMode) + +public: + LineLoopMode (GLRenderer* renderer); + + void render (QPainter& painter) const override; + EditModeType type() const override { return EditModeType::LineLoop; } + bool mouseReleased (MouseEventData const& data) override; +}; + diff -r 201083693300 -r ba75c789667e src/mainWindow.cc --- a/src/mainWindow.cc Mon Sep 01 10:37:42 2014 +0300 +++ b/src/mainWindow.cc Tue Sep 02 13:34:01 2014 +0300 @@ -707,6 +707,7 @@ ui->actionModeRectangle->setChecked (mode == EditModeType::Rectangle); ui->actionModeCircle->setChecked (mode == EditModeType::Circle); ui->actionModeMagicWand->setChecked (mode == EditModeType::MagicWand); + ui->actionModeLineLoop->setChecked (mode == EditModeType::LineLoop); } // ============================================================================= diff -r 201083693300 -r ba75c789667e src/mainWindow.h --- a/src/mainWindow.h Mon Sep 01 10:37:42 2014 +0300 +++ b/src/mainWindow.h Tue Sep 02 13:34:01 2014 +0300 @@ -227,6 +227,7 @@ void slot_actionModeRectangle(); void slot_actionModeCircle(); void slot_actionModeMagicWand(); + void slot_actionModeLineLoop(); void slot_actionSetDrawDepth(); void slot_actionSetColor(); void slot_actionAutocolor(); diff -r 201083693300 -r ba75c789667e ui/ldforge.ui --- a/ui/ldforge.ui Mon Sep 01 10:37:42 2014 +0300 +++ b/ui/ldforge.ui Tue Sep 02 13:34:01 2014 +0300 @@ -47,8 +47,8 @@ 0 0 - 237 - 434 + 233 + 399 @@ -75,8 +75,8 @@ 0 0 - 237 - 434 + 256 + 121 @@ -157,8 +157,8 @@ 0 0 - 94 - 94 + 101 + 101 @@ -194,7 +194,7 @@ 0 0 1010 - 22 + 27 @@ -535,6 +535,7 @@ + @@ -1699,6 +1700,21 @@ Ctrl+3 + + + true + + + + :/icons/line.png:/icons/line.png + + + Line Loop Mode + + + Ctrl+6 + +