Fixed circle mode not building the circle anymore

Wed, 17 Feb 2016 03:24:07 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Wed, 17 Feb 2016 03:24:07 +0200
changeset 1030
d931a7547578
parent 1029
9fc4c7d7c859
child 1031
55c0d3beea0d

Fixed circle mode not building the circle anymore

src/editmodes/circleMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/circleMode.h file | annotate | diff | comparison | revisions
--- a/src/editmodes/circleMode.cpp	Wed Feb 17 03:15:10 2016 +0200
+++ b/src/editmodes/circleMode.cpp	Wed Feb 17 03:24:07 2016 +0200
@@ -31,11 +31,13 @@
 CircleMode::CircleMode (GLRenderer* renderer) :
 	Super (renderer) {}
 
+
 EditModeType CircleMode::type() const
 {
 	return EditModeType::Circle;
 }
 
+
 double CircleMode::getCircleDrawDist (int pos) const
 {
 	if (m_drawedVerts.size() >= pos + 1)
@@ -57,6 +59,7 @@
 	return 0.0;
 }
 
+
 Matrix CircleMode::getCircleDrawMatrix (double scale)
 {
 	// Matrix templates. 2 is substituted with the scale value, 1 is inverted to -1 if needed.
@@ -80,7 +83,8 @@
 	return transform;
 }
 
-void CircleMode::buildCircle()
+
+void CircleMode::endDraw()
 {
 	LDObjectList objs;
 	PrimitiveSpec spec;
@@ -194,6 +198,7 @@
 	finishDraw (objs);
 }
 
+
 double CircleMode::getAngleOffset() const
 {
 	if (m_drawedVerts.isEmpty())
@@ -211,6 +216,7 @@
 	return angleoffset;
 }
 
+
 void CircleMode::render (QPainter& painter) const
 {
 	QFontMetrics metrics = QFontMetrics (QFont());
@@ -309,26 +315,15 @@
 	}
 }
 
-bool CircleMode::mouseReleased (MouseEventData const& data)
-{
-	if (Super::mouseReleased (data))
-		return true;
-
-	if (data.releasedButtons & Qt::LeftButton)
-	{
-		if (m_drawedVerts.size() < 3)
-			addDrawnVertex (renderer()->position3D());
-		else
-			buildCircle();
-
-		return true;
-	}
-
-	return false;
-}
 
 bool CircleMode::preAddVertex (const Vertex&)
 {
 	m_angleOffset = getAngleOffset();
 	return false;
 }
+
+
+int CircleMode::maxVertices() const
+{
+	return 3;
+}
\ No newline at end of file
--- a/src/editmodes/circleMode.h	Wed Feb 17 03:15:10 2016 +0200
+++ b/src/editmodes/circleMode.h	Wed Feb 17 03:24:07 2016 +0200
@@ -22,20 +22,21 @@
 class CircleMode : public AbstractDrawMode
 {
 	DEFINE_CLASS (CircleMode, AbstractDrawMode)
-	double m_angleOffset;
 
 public:
 	CircleMode (GLRenderer* renderer);
 
-	virtual void render (QPainter& painter) const override;
-	virtual EditModeType type() const override;
-
+	void endDraw() override;
 	double getCircleDrawDist (int pos) const;
 	Matrix getCircleDrawMatrix (double scale);
-	bool mouseReleased (const AbstractEditMode::MouseEventData& data) override;
+	int maxVertices() const override;
 	bool preAddVertex (Vertex const&) override;
+	void render (QPainter& painter) const override;
+	EditModeType type() const override;
 
 private:
+	double m_angleOffset;
+
 	void buildCircle();
 	double getAngleOffset() const;
 };

mercurial