- added line loop mode (doesn't actually create anything yet)

Tue, 02 Sep 2014 13:34:01 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Tue, 02 Sep 2014 13:34:01 +0300
changeset 874
ba75c789667e
parent 873
201083693300
child 875
ce8e9b37d44f

- added line loop mode (doesn't actually create anything yet)

CMakeLists.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/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	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
--- 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()
--- 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");
--- 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
--- /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<QPointF> 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;
+}
--- /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;
+};
+
--- 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);
 }
 
 // =============================================================================
--- 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();
--- 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 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>237</width>
-           <height>434</height>
+           <width>233</width>
+           <height>399</height>
           </rect>
          </property>
          <attribute name="label">
@@ -75,8 +75,8 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>237</width>
-           <height>434</height>
+           <width>256</width>
+           <height>121</height>
           </rect>
          </property>
          <attribute name="label">
@@ -157,8 +157,8 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>94</width>
-           <height>94</height>
+           <width>101</width>
+           <height>101</height>
           </rect>
          </property>
          <attribute name="label">
@@ -194,7 +194,7 @@
      <x>0</x>
      <y>0</y>
      <width>1010</width>
-     <height>22</height>
+     <height>27</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
@@ -535,6 +535,7 @@
    <addaction name="actionModeRectangle"/>
    <addaction name="actionModeCircle"/>
    <addaction name="actionModeMagicWand"/>
+   <addaction name="actionModeLineLoop"/>
   </widget>
   <widget class="QToolBar" name="colorToolbar">
    <property name="windowTitle">
@@ -1699,6 +1700,21 @@
     <string>Ctrl+3</string>
    </property>
   </action>
+  <action name="actionModeLineLoop">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="icon">
+    <iconset resource="../ldforge.qrc">
+     <normaloff>:/icons/line.png</normaloff>:/icons/line.png</iconset>
+   </property>
+   <property name="text">
+    <string>Line Loop Mode</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+6</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="../ldforge.qrc"/>

mercurial