Moved LDQuadrilateral into its own source pair.

Tue, 14 Feb 2017 15:21:34 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 14 Feb 2017 15:21:34 +0200
changeset 1149
502c866b8512
parent 1148
96cb15a7611f
child 1150
262345e53050

Moved LDQuadrilateral into its own source pair.

CMakeLists.txt file | annotate | diff | comparison | revisions
src/editmodes/circleMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/drawMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/rectangleMode.cpp file | annotate | diff | comparison | revisions
src/linetypes/modelobject.cpp file | annotate | diff | comparison | revisions
src/linetypes/modelobject.h file | annotate | diff | comparison | revisions
src/linetypes/quadrilateral.cpp file | annotate | diff | comparison | revisions
src/linetypes/quadrilateral.h file | annotate | diff | comparison | revisions
src/model.cpp file | annotate | diff | comparison | revisions
src/primitives.cpp file | annotate | diff | comparison | revisions
src/toolsets/algorithmtoolset.cpp file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Tue Feb 14 15:11:33 2017 +0200
+++ b/CMakeLists.txt	Tue Feb 14 15:21:34 2017 +0200
@@ -76,6 +76,7 @@
 	src/linetypes/edgeline.cpp
 	src/linetypes/empty.cpp
 	src/linetypes/modelobject.cpp
+	src/linetypes/quadrilateral.cpp
 	src/linetypes/triangle.cpp
 	src/toolsets/algorithmtoolset.cpp
 	src/toolsets/basictoolset.cpp
@@ -141,6 +142,7 @@
 	src/linetypes/edgeline.h
 	src/linetypes/empty.h
 	src/linetypes/modelobject.h
+	src/linetypes/quadrilateral.h
 	src/linetypes/triangle.h
 	src/toolsets/algorithmtoolset.h
 	src/toolsets/basictoolset.h
--- a/src/editmodes/circleMode.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/editmodes/circleMode.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -19,7 +19,6 @@
 #include <QPainter>
 #include "circleMode.h"
 #include "../miscallenous.h"
-#include "../linetypes/modelobject.h"
 #include "../lddocument.h"
 #include "../ringFinder.h"
 #include "../primitives.h"
@@ -28,6 +27,8 @@
 #include "../mathfunctions.h"
 #include "../miscallenous.h"
 #include "../grid.h"
+#include "../linetypes/modelobject.h"
+#include "../linetypes/quadrilateral.h"
 
 CircleMode::CircleMode(Canvas* canvas) :
     Super {canvas} {}
--- a/src/editmodes/drawMode.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/editmodes/drawMode.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -22,6 +22,7 @@
 #include "../linetypes/modelobject.h"
 #include "../glrenderer.h"
 #include "../linetypes/edgeline.h"
+#include "../linetypes/quadrilateral.h"
 #include "../linetypes/triangle.h"
 
 DrawMode::DrawMode (Canvas* canvas) :
--- a/src/editmodes/rectangleMode.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/editmodes/rectangleMode.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -18,9 +18,10 @@
 
 #include <QPainter>
 #include <QMouseEvent>
+#include "../canvas.h"
 #include "rectangleMode.h"
 #include "../linetypes/modelobject.h"
-#include "../canvas.h"
+#include "../linetypes/quadrilateral.h"
 
 RectangleMode::RectangleMode (Canvas* canvas) :
     Super (canvas),
--- a/src/linetypes/modelobject.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/linetypes/modelobject.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -65,7 +65,6 @@
     LDMatrixObject (model) {}
 
 LDOBJ_DEFAULT_CTOR (LDError, LDObject)
-LDOBJ_DEFAULT_CTOR (LDQuadrilateral, LDObject)
 LDOBJ_DEFAULT_CTOR (LDBfc, LDObject)
 LDOBJ_DEFAULT_CTOR (LDBezierCurve, LDObject)
 
@@ -90,18 +89,6 @@
 	return val;
 }
 
-// =============================================================================
-//
-QString LDQuadrilateral::asText() const
-{
-	QString val = format ("4 %1", color());
-
-	for (int i = 0; i < 4; ++i)
-		val += format (" %1", vertex (i));
-
-	return val;
-}
-
 QString LDBezierCurve::asText() const
 {
 	QString result = format ("0 !LDFORGE BEZIER_CURVE %1", color());
@@ -147,11 +134,6 @@
 	return fileInfo()->triangleCount();
 }
 
-int LDQuadrilateral::triangleCount() const
-{
-	return 2;
-}
-
 int LDObject::numVertices() const
 {
 	return 0;
@@ -159,17 +141,6 @@
 
 // =============================================================================
 //
-LDQuadrilateral::LDQuadrilateral (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, Model* model) :
-    LDObject {model}
-{
-	setVertex (0, v1);
-	setVertex (1, v2);
-	setVertex (2, v3);
-	setVertex (3, v4);
-}
-
-// =============================================================================
-//
 LDBezierCurve::LDBezierCurve(const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, Model* model) :
     LDObject {model}
 {
@@ -411,18 +382,6 @@
 
 // =============================================================================
 //
-void LDQuadrilateral::invert()
-{
-	// Quad:     0 -> 1 -> 2 -> 3
-	// reversed: 0 -> 3 -> 2 -> 1
-	// Thus, we swap 1 and 3.
-	Vertex tmp = vertex (1);
-	setVertex (1, vertex (3));
-	setVertex (3, tmp);
-}
-
-// =============================================================================
-//
 void LDSubfileReference::invert()
 {
 	if (model() == nullptr)
--- a/src/linetypes/modelobject.h	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/linetypes/modelobject.h	Tue Feb 14 15:21:34 2017 +0200
@@ -258,31 +258,6 @@
 };
 
 /*
- * Represents a single code-4 quadrilateral.
- */
-class LDQuadrilateral : public LDObject
-{
-public:
-	static constexpr LDObjectType SubclassType = LDObjectType::Quadrilateral;
-
-	virtual LDObjectType type() const override
-	{
-		return SubclassType;
-	}
-
-	QString asText() const override;
-	void invert() override;
-	int triangleCount() const override;
-	int numVertices() const override { return 4; }
-	QString typeName() const override { return "quad"; }
-
-protected:
-	friend class Model;
-	LDQuadrilateral (Model* model);
-	LDQuadrilateral (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, Model* model = nullptr);
-};
-
-/*
  * Models a Bézier curve. It is stored as a special comment in the LDraw code file and can be inlined down into line segments.
  */
 class LDBezierCurve : public LDObject
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/linetypes/quadrilateral.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ *  LDForge: LDraw parts authoring CAD
+ *  Copyright (C) 2013 - 2017 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "quadrilateral.h"
+
+LDQuadrilateral::LDQuadrilateral(Model *model) :
+	LDObject {model} {}
+
+LDQuadrilateral::LDQuadrilateral(const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, Model* model) :
+	LDObject {model}
+{
+	setVertex(0, v1);
+	setVertex(1, v2);
+	setVertex(2, v3);
+	setVertex(3, v4);
+}
+
+int LDQuadrilateral::numVertices() const
+{
+	return 4;
+}
+
+QString LDQuadrilateral::typeName() const
+{
+	return "quad";
+}
+
+QString LDQuadrilateral::asText() const
+{
+	QString result = format("4 %1", color());
+
+	for (int i = 0; i < 4; ++i)
+		result += format(" %1", vertex(i));
+
+	return result;
+}
+
+int LDQuadrilateral::triangleCount() const
+{
+	return 2;
+}
+
+void LDQuadrilateral::invert()
+{
+	// Quad:     0 -> 1 -> 2 -> 3
+	// reversed: 0 -> 3 -> 2 -> 1
+	// Thus, we swap 1 and 3.
+	Vertex temp = vertex(1);
+	setVertex(1, vertex(3));
+	setVertex(3, temp);
+}
+
+LDObjectType LDQuadrilateral::type() const
+{
+	return SubclassType;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/linetypes/quadrilateral.h	Tue Feb 14 15:21:34 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ *  LDForge: LDraw parts authoring CAD
+ *  Copyright (C) 2013 - 2017 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#include "modelobject.h"
+
+/*
+ * Represents a single code-4 quadrilateral.
+ */
+class LDQuadrilateral : public LDObject
+{
+public:
+	static constexpr LDObjectType SubclassType = LDObjectType::Quadrilateral;
+
+	QString asText() const override;
+	void invert() override;
+	int numVertices() const override;
+	int triangleCount() const override;
+	LDObjectType type() const override;
+	QString typeName() const override;
+
+protected:
+	friend class Model;
+	LDQuadrilateral(Model* model);
+	LDQuadrilateral(const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, Model* model = nullptr);
+};
--- a/src/model.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/model.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -23,6 +23,7 @@
 #include "linetypes/conditionaledge.h"
 #include "linetypes/edgeline.h"
 #include "linetypes/empty.h"
+#include "linetypes/quadrilateral.h"
 #include "linetypes/triangle.h"
 
 Model::Model(DocumentManager* manager) :
--- a/src/primitives.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/primitives.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -28,6 +28,7 @@
 #include "linetypes/conditionaledge.h"
 #include "linetypes/edgeline.h"
 #include "linetypes/empty.h"
+#include "linetypes/quadrilateral.h"
 #include "linetypes/triangle.h"
 
 PrimitiveManager::PrimitiveManager(QObject* parent) :
--- a/src/toolsets/algorithmtoolset.cpp	Tue Feb 14 15:11:33 2017 +0200
+++ b/src/toolsets/algorithmtoolset.cpp	Tue Feb 14 15:21:34 2017 +0200
@@ -36,6 +36,7 @@
 #include "../linetypes/conditionaledge.h"
 #include "../linetypes/edgeline.h"
 #include "../linetypes/empty.h"
+#include "../linetypes/quadrilateral.h"
 #include "../linetypes/triangle.h"
 #include "ui_replcoords.h"
 #include "ui_editraw.h"

mercurial