src/linetypes/triangle.cpp

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

mercurial