split quadrilateral and triangle into their own source files

Sun, 03 Nov 2019 18:17:08 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 03 Nov 2019 18:17:08 +0200
changeset 15
9e18ec63eec3
parent 14
20d2ed3af73d
child 16
aeb5f203b3eb

split quadrilateral and triangle into their own source files

CMakeLists.txt file | annotate | diff | comparison | revisions
src/linetypes/polygon.cpp file | annotate | diff | comparison | revisions
src/linetypes/polygon.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/linetypes/triangle.cpp file | annotate | diff | comparison | revisions
src/linetypes/triangle.h file | annotate | diff | comparison | revisions
src/parser.cpp file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Sun Nov 03 18:13:38 2019 +0200
+++ b/CMakeLists.txt	Sun Nov 03 18:17:08 2019 +0200
@@ -32,8 +32,9 @@
 	src/linetypes/errorline.cpp
 	src/linetypes/metacommand.cpp
 	src/linetypes/object.cpp
-	src/linetypes/polygon.cpp
+	src/linetypes/quadrilateral.cpp
 	src/linetypes/subfilereference.cpp
+	src/linetypes/triangle.cpp
 	src/settingseditor/librarieseditor.cpp
 	src/settingseditor/settingseditor.cpp
 )
@@ -58,8 +59,9 @@
 	src/linetypes/errorline.h
 	src/linetypes/metacommand.h
 	src/linetypes/object.h
-	src/linetypes/polygon.h
+	src/linetypes/quadrilateral.h
 	src/linetypes/subfilereference.h
+	src/linetypes/triangle.h
 	src/settingseditor/librarieseditor.h
 	src/settingseditor/settingseditor.h
 )
--- a/src/linetypes/polygon.cpp	Sun Nov 03 18:13:38 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-#include "polygon.h"
-
-linetypes::Triangle::Triangle(
-	const Vertex& point_1,
-	const Vertex& point_2,
-	const Vertex& point_3,
-	Color color_index) :
-	ColoredObject{color_index},
-	points{point_1, point_2, point_3}
-{
-}
-
-linetypes::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) :
-	ColoredObject{color},
-	points{vertices[0], vertices[1], vertices[2]}
-{
-}
-
-QVariant linetypes::Triangle::getProperty(const Property id) const
-{
-	switch (id)
-	{
-	case Property::Point1:
-		return points[0];
-	case Property::Point2:
-		return points[1];
-	case Property::Point3:
-		return points[2];
-	default:
-		return ColoredObject::getProperty(id);
-	}
-}
-
-auto linetypes::Triangle::setProperty(Property id, const QVariant& value)
-	-> SetPropertyResult
-{
-	switch (id)
-	{
-	case Property::Point1:
-		points[0] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	case Property::Point2:
-		points[1] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	case Property::Point3:
-		points[2] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	default:
-		return ColoredObject::setProperty(id, value);
-	}
-}
-
-QString linetypes::Triangle::textRepresentation() const
-{
-	return utility::format("%1 %2 %3",
-		vertexToStringParens(points[0]),
-		vertexToStringParens(points[1]),
-		vertexToStringParens(points[2]));
-}
-
-linetypes::Quadrilateral::Quadrilateral(
-	const Vertex& point_1,
-	const Vertex& point_2,
-	const Vertex& point_3,
-	const Vertex& point_4,
-	Color color_index) :
-	ColoredObject{color_index},
-	points{point_1, point_2, point_3, point_4}
-{
-}
-
-linetypes::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) :
-	ColoredObject{color},
-	points{vertices[0], vertices[1], vertices[2], vertices[3]}
-{
-}
-
-QVariant linetypes::Quadrilateral::getProperty(const Property id) const
-{
-	switch (id)
-	{
-	case Property::Point1:
-		return points[0];
-	case Property::Point2:
-		return points[1];
-	case Property::Point3:
-		return points[2];
-	case Property::Point4:
-		return points[3];
-	default:
-		return ColoredObject::getProperty(id);
-	}
-}
-
-auto linetypes::Quadrilateral::setProperty(
-	const Property id,
-	const QVariant& value)
-	-> SetPropertyResult
-{
-	switch (id)
-	{
-	case Property::Point1:
-		points[0] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	case Property::Point2:
-		points[1] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	case Property::Point3:
-		points[2] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	case Property::Point4:
-		points[3] = value.value<Vertex>();
-		return SetPropertyResult::Success;
-	default:
-		return ColoredObject::setProperty(id, value);
-	}
-}
-
-QString linetypes::Quadrilateral::textRepresentation() const
-{
-	return utility::format("%1 %2 %3 %4",
-		vertexToStringParens(points[0]),
-		vertexToStringParens(points[1]),
-		vertexToStringParens(points[2]),
-		vertexToStringParens(points[3]));
-}
--- a/src/linetypes/polygon.h	Sun Nov 03 18:13:38 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-#include <array>
-#include "object.h"
-
-namespace linetypes
-{
-	class Triangle;
-	class Quadrilateral;
-}
-
-class linetypes::Triangle : public ColoredObject
-{
-public:
-	Triangle() = default;
-	Triangle(
-		const Vertex &point_1,
-		const Vertex &point_2,
-		const Vertex &point_3,
-		Color colorIndex = colors::main);
-	Triangle(const QVector<Vertex>& vertices, const Color color);
-	QVariant getProperty(Property id) const override;
-	SetPropertyResult setProperty(Property id, const QVariant& value) override;
-	QString textRepresentation() const override;
-private:
-	Vertex points[3] = {{}};
-};
-
-class linetypes::Quadrilateral : public ColoredObject
-{
-public:
-	Quadrilateral() = default;
-	Quadrilateral(
-		const Vertex &point_1,
-		const Vertex &point_2,
-		const Vertex &point_3,
-		const Vertex &point_4,
-		Color colorIndex = colors::main);
-	Quadrilateral(const QVector<Vertex>& vertices, const Color color);
-	QVariant getProperty(Property id) const override;
-	SetPropertyResult setProperty(Property id, const QVariant& value) override;
-	QString textRepresentation() const override;
-private:
-	Vertex points[4] = {{}};
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/linetypes/quadrilateral.cpp	Sun Nov 03 18:17:08 2019 +0200
@@ -0,0 +1,68 @@
+#include "quadrilateral.h"
+
+linetypes::Quadrilateral::Quadrilateral(
+	const Vertex& point_1,
+	const Vertex& point_2,
+	const Vertex& point_3,
+	const Vertex& point_4,
+	Color color_index) :
+	ColoredObject{color_index},
+	points{point_1, point_2, point_3, point_4}
+{
+}
+
+linetypes::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) :
+	ColoredObject{color},
+	points{vertices[0], vertices[1], vertices[2], vertices[3]}
+{
+}
+
+QVariant linetypes::Quadrilateral::getProperty(const Property id) const
+{
+	switch (id)
+	{
+	case Property::Point1:
+		return points[0];
+	case Property::Point2:
+		return points[1];
+	case Property::Point3:
+		return points[2];
+	case Property::Point4:
+		return points[3];
+	default:
+		return ColoredObject::getProperty(id);
+	}
+}
+
+auto linetypes::Quadrilateral::setProperty(
+	const Property id,
+	const QVariant& value)
+	-> SetPropertyResult
+{
+	switch (id)
+	{
+	case Property::Point1:
+		points[0] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	case Property::Point2:
+		points[1] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	case Property::Point3:
+		points[2] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	case Property::Point4:
+		points[3] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	default:
+		return ColoredObject::setProperty(id, value);
+	}
+}
+
+QString linetypes::Quadrilateral::textRepresentation() const
+{
+	return utility::format("%1 %2 %3 %4",
+		vertexToStringParens(points[0]),
+		vertexToStringParens(points[1]),
+		vertexToStringParens(points[2]),
+		vertexToStringParens(points[3]));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/linetypes/quadrilateral.h	Sun Nov 03 18:17:08 2019 +0200
@@ -0,0 +1,25 @@
+#pragma once
+#include "object.h"
+
+namespace linetypes
+{
+	class Quadrilateral;
+}
+
+class linetypes::Quadrilateral : public ColoredObject
+{
+public:
+	Quadrilateral() = default;
+	Quadrilateral(
+	const Vertex &point_1,
+	const Vertex &point_2,
+	const Vertex &point_3,
+	const Vertex &point_4,
+	Color colorIndex = colors::main);
+	Quadrilateral(const QVector<Vertex>& vertices, const Color color);
+	QVariant getProperty(Property id) const override;
+	SetPropertyResult setProperty(Property id, const QVariant& value) override;
+	QString textRepresentation() const override;
+private:
+	Vertex points[4] = {{}};
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/linetypes/triangle.cpp	Sun Nov 03 18:17:08 2019 +0200
@@ -0,0 +1,59 @@
+#include "triangle.h"
+
+linetypes::Triangle::Triangle(
+	const Vertex& point_1,
+	const Vertex& point_2,
+	const Vertex& point_3,
+	Color color_index) :
+	ColoredObject{color_index},
+	points{point_1, point_2, point_3}
+{
+}
+
+linetypes::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) :
+	ColoredObject{color},
+	points{vertices[0], vertices[1], vertices[2]}
+{
+}
+
+QVariant linetypes::Triangle::getProperty(const Property id) const
+{
+	switch (id)
+	{
+	case Property::Point1:
+		return points[0];
+	case Property::Point2:
+		return points[1];
+	case Property::Point3:
+		return points[2];
+	default:
+		return ColoredObject::getProperty(id);
+	}
+}
+
+auto linetypes::Triangle::setProperty(Property id, const QVariant& value)
+	-> SetPropertyResult
+{
+	switch (id)
+	{
+	case Property::Point1:
+		points[0] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	case Property::Point2:
+		points[1] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	case Property::Point3:
+		points[2] = value.value<Vertex>();
+		return SetPropertyResult::Success;
+	default:
+		return ColoredObject::setProperty(id, value);
+	}
+}
+
+QString linetypes::Triangle::textRepresentation() const
+{
+	return utility::format("%1 %2 %3",
+		vertexToStringParens(points[0]),
+		vertexToStringParens(points[1]),
+		vertexToStringParens(points[2]));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/linetypes/triangle.h	Sun Nov 03 18:17:08 2019 +0200
@@ -0,0 +1,24 @@
+#include "object.h"
+
+namespace linetypes
+{
+	class Triangle;
+}
+
+class linetypes::Triangle : public ColoredObject
+{
+public:
+	Triangle() = default;
+	Triangle(
+		const Vertex &point_1,
+		const Vertex &point_2,
+		const Vertex &point_3,
+		Color colorIndex = colors::main);
+	Triangle(const QVector<Vertex>& vertices, const Color color);
+	QVariant getProperty(Property id) const override;
+	SetPropertyResult setProperty(Property id, const QVariant& value) override;
+	QString textRepresentation() const override;
+private:
+	Vertex points[3] = {{}};
+};
+
--- a/src/parser.cpp	Sun Nov 03 18:13:38 2019 +0200
+++ b/src/parser.cpp	Sun Nov 03 18:17:08 2019 +0200
@@ -24,8 +24,9 @@
 #include "linetypes/errorline.h"
 #include "linetypes/metacommand.h"
 #include "linetypes/object.h"
-#include "linetypes/polygon.h"
+#include "linetypes/quadrilateral.h"
 #include "linetypes/subfilereference.h"
+#include "linetypes/triangle.h"
 
 struct BodyParseError
 {

mercurial