src/linetypes/quadrilateral.cpp

changeset 33
4c41bfe2ec6e
parent 26
3a9e761e4faa
child 35
98906a94732f
equal deleted inserted replaced
32:767592024ec5 33:4c41bfe2ec6e
1 #include "quadrilateral.h" 1 #include "quadrilateral.h"
2 2
3 linetypes::Quadrilateral::Quadrilateral( 3 linetypes::Quadrilateral::Quadrilateral(
4 const Point3D& point_1, 4 const glm::vec3& point_1,
5 const Point3D& point_2, 5 const glm::vec3& point_2,
6 const Point3D& point_3, 6 const glm::vec3& point_3,
7 const Point3D& point_4, 7 const glm::vec3& point_4,
8 Color color_index) : 8 Color color_index) :
9 ColoredObject{color_index}, 9 ColoredObject{color_index},
10 points{point_1, point_2, point_3, point_4} 10 points{point_1, point_2, point_3, point_4}
11 { 11 {
12 } 12 }
13 13
14 linetypes::Quadrilateral::Quadrilateral(const QVector<Point3D>& vertices, const Color color) : 14 linetypes::Quadrilateral::Quadrilateral(const QVector<glm::vec3>& vertices, const Color color) :
15 ColoredObject{color}, 15 ColoredObject{color},
16 points{vertices[0], vertices[1], vertices[2], vertices[3]} 16 points{vertices[0], vertices[1], vertices[2], vertices[3]}
17 { 17 {
18 } 18 }
19 19
20 QVariant linetypes::Quadrilateral::getProperty(const Property id) const 20 QVariant linetypes::Quadrilateral::getProperty(const Property id) const
21 { 21 {
22 switch (id) 22 switch (id)
23 { 23 {
24 case Property::Point1: 24 case Property::Point1:
25 return points[0]; 25 return QVariant::fromValue(points[0]);
26 case Property::Point2: 26 case Property::Point2:
27 return points[1]; 27 return QVariant::fromValue(points[1]);
28 case Property::Point3: 28 case Property::Point3:
29 return points[2]; 29 return QVariant::fromValue(points[2]);
30 case Property::Point4: 30 case Property::Point4:
31 return points[3]; 31 return QVariant::fromValue(points[3]);
32 default: 32 default:
33 return ColoredObject::getProperty(id); 33 return ColoredObject::getProperty(id);
34 } 34 }
35 } 35 }
36 36
40 -> SetPropertyResult 40 -> SetPropertyResult
41 { 41 {
42 switch (id) 42 switch (id)
43 { 43 {
44 case Property::Point1: 44 case Property::Point1:
45 points[0] = value.value<Point3D>(); 45 points[0] = value.value<glm::vec3>();
46 return SetPropertyResult::Success; 46 return SetPropertyResult::Success;
47 case Property::Point2: 47 case Property::Point2:
48 points[1] = value.value<Point3D>(); 48 points[1] = value.value<glm::vec3>();
49 return SetPropertyResult::Success; 49 return SetPropertyResult::Success;
50 case Property::Point3: 50 case Property::Point3:
51 points[2] = value.value<Point3D>(); 51 points[2] = value.value<glm::vec3>();
52 return SetPropertyResult::Success; 52 return SetPropertyResult::Success;
53 case Property::Point4: 53 case Property::Point4:
54 points[3] = value.value<Point3D>(); 54 points[3] = value.value<glm::vec3>();
55 return SetPropertyResult::Success; 55 return SetPropertyResult::Success;
56 default: 56 default:
57 return ColoredObject::setProperty(id, value); 57 return ColoredObject::setProperty(id, value);
58 } 58 }
59 } 59 }
60 60
61 QString linetypes::Quadrilateral::textRepresentation() const 61 QString linetypes::Quadrilateral::textRepresentation() const
62 { 62 {
63 return utility::format("%1 %2 %3 %4", 63 return utility::format("%1 %2 %3 %4",
64 vertexToStringParens(points[0]), 64 utility::vertexToStringParens(points[0]),
65 vertexToStringParens(points[1]), 65 utility::vertexToStringParens(points[1]),
66 vertexToStringParens(points[2]), 66 utility::vertexToStringParens(points[2]),
67 vertexToStringParens(points[3])); 67 utility::vertexToStringParens(points[3]));
68 } 68 }
69 69
70 void linetypes::Quadrilateral::getPolygons( 70 void linetypes::Quadrilateral::getPolygons(
71 std::vector<gl::Polygon>& polygons, 71 std::vector<gl::Polygon>& polygons,
72 GetPolygonsContext* context) const 72 GetPolygonsContext* context) const

mercurial