Wed, 03 Sep 2014 01:44:51 +0300
- renamed line loop to line path, updated changelog
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
changelog.txt | file | annotate | diff | comparison | revisions | |
src/actions.cc | file | annotate | diff | comparison | revisions | |
src/editmodes/abstractEditMode.cc | file | annotate | diff | comparison | revisions | |
src/editmodes/abstractEditMode.h | file | annotate | diff | comparison | revisions | |
src/editmodes/lineLoopMode.cpp | file | annotate | diff | comparison | revisions | |
src/editmodes/lineLoopMode.h | file | annotate | diff | comparison | revisions | |
src/editmodes/linePathMode.cpp | file | annotate | diff | comparison | revisions | |
src/editmodes/linePathMode.h | file | annotate | diff | comparison | revisions | |
src/mainWindow.cc | file | annotate | diff | comparison | revisions | |
src/mainWindow.h | file | annotate | diff | comparison | revisions | |
ui/ldforge.ui | file | annotate | diff | comparison | revisions |
--- 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
--- 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.
--- 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); } // =============================================================================
--- 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");
--- 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
--- 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 <QKeyEvent> - -LineLoopMode::LineLoopMode (GLRenderer *renderer) : - Super (renderer) {} - -void LineLoopMode::render (QPainter& painter) const -{ - QVector<QPointF> points; - QList<Vertex> 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<LDLine>(); - 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; -}
--- 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(); -}; -
--- /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 <QKeyEvent> + +LinePathMode::LinePathMode (GLRenderer *renderer) : + Super (renderer) {} + +void LinePathMode::render (QPainter& painter) const +{ + QVector<QPointF> points; + QList<Vertex> 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<LDLine>(); + 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; +}
--- /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(); +}; +
--- 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); } // =============================================================================
--- 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();
--- 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 @@ <addaction name="actionModeRectangle"/> <addaction name="actionModeCircle"/> <addaction name="actionModeMagicWand"/> - <addaction name="actionModeLineLoop"/> + <addaction name="actionModeLinePath"/> </widget> <widget class="QToolBar" name="colorToolbar"> <property name="windowTitle"> @@ -1700,7 +1700,7 @@ <string>Ctrl+3</string> </property> </action> - <action name="actionModeLineLoop"> + <action name="actionModeLinePath"> <property name="checkable"> <bool>true</bool> </property> @@ -1709,7 +1709,7 @@ <normaloff>:/icons/line.png</normaloff>:/icons/line.png</iconset> </property> <property name="text"> - <string>Line Loop Mode</string> + <string>Line Path Mode</string> </property> <property name="shortcut"> <string>Ctrl+6</string>