# HG changeset patch # User Teemu Piippo # Date 1409697891 -10800 # Node ID f040f0fb37957cc2a4460bc73c97ac640833bb18 # Parent ce8e9b37d44f34eb5ca3cb366d89cd8e627142e8 - renamed line loop to line path, updated changelog diff -r ce8e9b37d44f -r f040f0fb3795 CMakeLists.txt --- a/CMakeLists.txt Wed Sep 03 01:28:58 2014 +0300 +++ b/CMakeLists.txt Wed Sep 03 01:44:51 2014 +0300 @@ -67,7 +67,7 @@ src/editmodes/abstractEditMode.cc src/editmodes/circleMode.cc src/editmodes/drawMode.cc - src/editmodes/lineLoopMode.cpp + src/editmodes/linePathMode.cpp src/editmodes/magicWandMode.cc src/editmodes/rectangleMode.cc src/editmodes/selectMode.cc @@ -103,7 +103,7 @@ src/editmodes/abstractEditMode.h src/editmodes/circleMode.h src/editmodes/drawMode.h - src/editmodes/lineLoopMode.h + src/editmodes/linePathMode.h src/editmodes/magicWandMode.h src/editmodes/rectangleMode.h src/editmodes/selectMode.h diff -r ce8e9b37d44f -r f040f0fb3795 changelog.txt --- a/changelog.txt Wed Sep 03 01:28:58 2014 +0300 +++ b/changelog.txt Wed Sep 03 01:44:51 2014 +0300 @@ -44,6 +44,7 @@ + - Added three togglable actions for filtering what's drawn (Draw surfaces/Draw edgelines/Draw conditional lines) + - Added the magic wand tool. + - Can now attempt to download missing subfiles from ldraw.org like LDView. ++ - Added the line path tool. - - The camera is now changed to the top one if switching to draw mode while using the free camera instead of disabling the draw mode. - - The color selector now uses the color's edge color for the borders instead of black. diff -r ce8e9b37d44f -r f040f0fb3795 src/actions.cc --- a/src/actions.cc Wed Sep 03 01:28:58 2014 +0300 +++ b/src/actions.cc Wed Sep 03 01:44:51 2014 +0300 @@ -595,9 +595,9 @@ R()->setEditMode (EditModeType::MagicWand); } -void MainWindow::slot_actionModeLineLoop() +void MainWindow::slot_actionModeLinePath() { - R()->setEditMode (EditModeType::LineLoop); + R()->setEditMode (EditModeType::LinePath); } // ============================================================================= diff -r ce8e9b37d44f -r f040f0fb3795 src/editmodes/abstractEditMode.cc --- a/src/editmodes/abstractEditMode.cc Wed Sep 03 01:28:58 2014 +0300 +++ b/src/editmodes/abstractEditMode.cc Wed Sep 03 01:44:51 2014 +0300 @@ -24,7 +24,7 @@ #include "rectangleMode.h" #include "circleMode.h" #include "magicWandMode.h" -#include "lineLoopMode.h" +#include "linePathMode.h" #include "../mainWindow.h" #include "../glRenderer.h" @@ -45,7 +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); + case EditModeType::LinePath: return new LinePathMode (renderer); } throw std::logic_error ("bad type given to AbstractEditMode::createByType"); diff -r ce8e9b37d44f -r f040f0fb3795 src/editmodes/abstractEditMode.h --- a/src/editmodes/abstractEditMode.h Wed Sep 03 01:28:58 2014 +0300 +++ b/src/editmodes/abstractEditMode.h Wed Sep 03 01:44:51 2014 +0300 @@ -31,7 +31,7 @@ Rectangle, Circle, MagicWand, - LineLoop, + LinePath, }; class AbstractEditMode diff -r ce8e9b37d44f -r f040f0fb3795 src/editmodes/lineLoopMode.cpp --- a/src/editmodes/lineLoopMode.cpp Wed Sep 03 01:28:58 2014 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -#include "lineLoopMode.h" -#include "../glRenderer.h" -#include "../mainWindow.h" -#include - -LineLoopMode::LineLoopMode (GLRenderer *renderer) : - Super (renderer) {} - -void LineLoopMode::render (QPainter& painter) const -{ - QVector points; - QList points3d (m_drawedVerts); - points3d << renderer()->position3D(); - - for (Vertex const& vrt : points3d) - points << renderer()->coordconv3_2 (vrt); - - painter.setPen (renderer()->textPen()); - assert (points.size() == points3d.size()); - - for (int i = 0; i < points.size() - 1; ++i) - { - painter.drawLine (QLineF (points[i], points[i + 1])); - drawLength (painter, points3d[i], points3d[i + 1], 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; -} - -bool LineLoopMode::preAddVertex (Vertex const& pos) -{ - // If we picked an the last vertex, stop drawing - if (not m_drawedVerts.isEmpty() and pos == m_drawedVerts.last()) - { - endDraw(); - return true; - } - - return false; -} - -void LineLoopMode::endDraw() -{ - LDObjectList objs; - - for (int i = 0; i < m_drawedVerts.size() - 1; ++i) - { - LDLinePtr line = LDSpawn(); - line->setVertex (0, m_drawedVerts[i]); - line->setVertex (1, m_drawedVerts[i + 1]); - objs << line; - } - - finishDraw (objs); -} - -bool LineLoopMode::keyReleased (QKeyEvent* ev) -{ - if (Super::keyReleased (ev)) - return true; - - if (ev->key() == Qt::Key_Enter or ev->key() == Qt::Key_Return) - { - endDraw(); - return true; - } - - return false; -} diff -r ce8e9b37d44f -r f040f0fb3795 src/editmodes/lineLoopMode.h --- a/src/editmodes/lineLoopMode.h Wed Sep 03 01:28:58 2014 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#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; - bool preAddVertex (Vertex const& pos) override; - bool keyReleased (QKeyEvent*) override; - void endDraw(); -}; - diff -r ce8e9b37d44f -r f040f0fb3795 src/editmodes/linePathMode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/editmodes/linePathMode.cpp Wed Sep 03 01:44:51 2014 +0300 @@ -0,0 +1,84 @@ +#include "linePathMode.h" +#include "../glRenderer.h" +#include "../mainWindow.h" +#include + +LinePathMode::LinePathMode (GLRenderer *renderer) : + Super (renderer) {} + +void LinePathMode::render (QPainter& painter) const +{ + QVector points; + QList points3d (m_drawedVerts); + points3d << renderer()->position3D(); + + for (Vertex const& vrt : points3d) + points << renderer()->coordconv3_2 (vrt); + + painter.setPen (renderer()->textPen()); + assert (points.size() == points3d.size()); + + for (int i = 0; i < points.size() - 1; ++i) + { + painter.drawLine (QLineF (points[i], points[i + 1])); + drawLength (painter, points3d[i], points3d[i + 1], points[i], points[i + 1]); + } + + for (QPointF const& point : points) + renderer()->drawBlip (painter, point); +} + +bool LinePathMode::mouseReleased (MouseEventData const& data) +{ + if (Super::mouseReleased (data)) + return true; + + if (data.releasedButtons & Qt::LeftButton) + { + addDrawnVertex (renderer()->position3D()); + return true; + } + + return false; +} + +bool LinePathMode::preAddVertex (Vertex const& pos) +{ + // If we picked an the last vertex, stop drawing + if (not m_drawedVerts.isEmpty() and pos == m_drawedVerts.last()) + { + endDraw(); + return true; + } + + return false; +} + +void LinePathMode::endDraw() +{ + LDObjectList objs; + + for (int i = 0; i < m_drawedVerts.size() - 1; ++i) + { + LDLinePtr line = LDSpawn(); + line->setVertex (0, m_drawedVerts[i]); + line->setVertex (1, m_drawedVerts[i + 1]); + objs << line; + } + + finishDraw (objs); +} + +bool LinePathMode::keyReleased (QKeyEvent* ev) +{ + if (Super::keyReleased (ev)) + return true; + + if (ev->key() == Qt::Key_Enter or ev->key() == Qt::Key_Return) + { + endDraw(); + return true; + } + + return false; +} diff -r ce8e9b37d44f -r f040f0fb3795 src/editmodes/linePathMode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/editmodes/linePathMode.h Wed Sep 03 01:44:51 2014 +0300 @@ -0,0 +1,18 @@ +#pragma once +#include "abstractEditMode.h" + +class LinePathMode : public AbstractDrawMode +{ + DEFINE_CLASS (LinePathMode, AbstractDrawMode) + +public: + LinePathMode (GLRenderer* renderer); + + void render (QPainter& painter) const override; + EditModeType type() const override { return EditModeType::LinePath; } + bool mouseReleased (MouseEventData const& data) override; + bool preAddVertex (Vertex const& pos) override; + bool keyReleased (QKeyEvent*) override; + void endDraw(); +}; + diff -r ce8e9b37d44f -r f040f0fb3795 src/mainWindow.cc --- a/src/mainWindow.cc Wed Sep 03 01:28:58 2014 +0300 +++ b/src/mainWindow.cc Wed Sep 03 01:44:51 2014 +0300 @@ -707,7 +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); + ui->actionModeLinePath->setChecked (mode == EditModeType::LinePath); } // ============================================================================= diff -r ce8e9b37d44f -r f040f0fb3795 src/mainWindow.h --- a/src/mainWindow.h Wed Sep 03 01:28:58 2014 +0300 +++ b/src/mainWindow.h Wed Sep 03 01:44:51 2014 +0300 @@ -227,7 +227,7 @@ void slot_actionModeRectangle(); void slot_actionModeCircle(); void slot_actionModeMagicWand(); - void slot_actionModeLineLoop(); + void slot_actionModeLinePath(); void slot_actionSetDrawDepth(); void slot_actionSetColor(); void slot_actionAutocolor(); diff -r ce8e9b37d44f -r f040f0fb3795 ui/ldforge.ui --- a/ui/ldforge.ui Wed Sep 03 01:28:58 2014 +0300 +++ b/ui/ldforge.ui Wed Sep 03 01:44:51 2014 +0300 @@ -535,7 +535,7 @@ - + @@ -1700,7 +1700,7 @@ Ctrl+3 - + true @@ -1709,7 +1709,7 @@ :/icons/line.png:/icons/line.png - Line Loop Mode + Line Path Mode Ctrl+6