src/linetypes/quadrilateral.cpp

changeset 86
4bec0525ef1b
parent 81
62373840e33a
child 87
93ec4d630346
--- a/src/linetypes/quadrilateral.cpp	Wed Mar 18 17:11:23 2020 +0200
+++ b/src/linetypes/quadrilateral.cpp	Thu Mar 19 21:06:06 2020 +0200
@@ -1,17 +1,23 @@
 #include "quadrilateral.h"
 
-ldraw::Quadrilateral::Quadrilateral(
+ldraw::Quadrilateral::Quadrilateral
+(
 	const glm::vec3& point_1,
 	const glm::vec3& point_2,
 	const glm::vec3& point_3,
 	const glm::vec3& point_4,
-	Color color_index) :
+	Color color_index
+) :
 	ColoredObject{color_index},
 	points{point_1, point_2, point_3, point_4}
 {
 }
 
-ldraw::Quadrilateral::Quadrilateral(const std::array<glm::vec3, 4>& vertices, const Color color) :
+ldraw::Quadrilateral::Quadrilateral
+(
+	const std::array<glm::vec3, 4>& vertices,
+	const Color color
+) :
 	ColoredObject{color},
 	points{vertices[0], vertices[1], vertices[2], vertices[3]}
 {
@@ -21,41 +27,26 @@
 {
 	switch (id)
 	{
-	case Property::Point1:
+	case Property::Point0:
 		return QVariant::fromValue(points[0]);
-	case Property::Point2:
+	case Property::Point1:
 		return QVariant::fromValue(points[1]);
-	case Property::Point3:
+	case Property::Point2:
 		return QVariant::fromValue(points[2]);
-	case Property::Point4:
+	case Property::Point3:
 		return QVariant::fromValue(points[3]);
 	default:
 		return ColoredObject::getProperty(id);
 	}
 }
 
-auto ldraw::Quadrilateral::setProperty(
-	const Property id,
-	const QVariant& value)
-	-> SetPropertyResult
+void ldraw::Quadrilateral::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
 {
-	switch (id)
-	{
-	case Property::Point1:
-		points[0] = value.value<glm::vec3>();
-		return SetPropertyResult::Success;
-	case Property::Point2:
-		points[1] = value.value<glm::vec3>();
-		return SetPropertyResult::Success;
-	case Property::Point3:
-		points[2] = value.value<glm::vec3>();
-		return SetPropertyResult::Success;
-	case Property::Point4:
-		points[3] = value.value<glm::vec3>();
-		return SetPropertyResult::Success;
-	default:
-		return ColoredObject::setProperty(id, value);
-	}
+	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point0, {points[0] = value;})
+	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point1, {points[1] = value;})
+	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point2, {points[2] = value;})
+	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point3, {points[3] = value;})
+	ColoredObject::setProperty(result, pair);
 }
 
 QString ldraw::Quadrilateral::textRepresentation() const

mercurial