src/linetypes/triangle.cpp

changeset 35
98906a94732f
parent 33
4c41bfe2ec6e
child 77
028798a72591
equal deleted inserted replaced
34:1de2b8d64e9f 35:98906a94732f
1 #include "triangle.h" 1 #include "triangle.h"
2 2
3 linetypes::Triangle::Triangle( 3 ldraw::Triangle::Triangle(
4 const glm::vec3& point_1, 4 const glm::vec3& point_1,
5 const glm::vec3& point_2, 5 const glm::vec3& point_2,
6 const glm::vec3& 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<glm::vec3>& vertices, const Color color) : 13 ldraw::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 ldraw::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 QVariant::fromValue(points[0]); 24 return QVariant::fromValue(points[0]);
29 default: 29 default:
30 return ColoredObject::getProperty(id); 30 return ColoredObject::getProperty(id);
31 } 31 }
32 } 32 }
33 33
34 auto linetypes::Triangle::setProperty(Property id, const QVariant& value) 34 auto ldraw::Triangle::setProperty(Property id, const QVariant& value)
35 -> SetPropertyResult 35 -> SetPropertyResult
36 { 36 {
37 switch (id) 37 switch (id)
38 { 38 {
39 case Property::Point1: 39 case Property::Point1:
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 ldraw::Triangle::textRepresentation() const
54 { 54 {
55 return utility::format("%1 %2 %3", 55 return utility::format("%1 %2 %3",
56 utility::vertexToStringParens(points[0]), 56 utility::vertexToStringParens(points[0]),
57 utility::vertexToStringParens(points[1]), 57 utility::vertexToStringParens(points[1]),
58 utility::vertexToStringParens(points[2])); 58 utility::vertexToStringParens(points[2]));
59 } 59 }
60 60
61 void linetypes::Triangle::getPolygons( 61 void ldraw::Triangle::getPolygons(
62 std::vector<gl::Polygon>& polygons, 62 std::vector<gl::Polygon>& polygons,
63 GetPolygonsContext* context) const 63 GetPolygonsContext* context) const
64 { 64 {
65 Q_UNUSED(context) 65 Q_UNUSED(context)
66 polygons.push_back(gl::triangle( 66 polygons.push_back(gl::triangle(
69 this->points[2], 69 this->points[2],
70 this->colorIndex, 70 this->colorIndex,
71 this->id)); 71 this->id));
72 } 72 }
73 73
74 void linetypes::Triangle::invert() 74 void ldraw::Triangle::invert()
75 { 75 {
76 // 0 1 2 76 // 0 1 2
77 // -> 1 0 2 77 // -> 1 0 2
78 std::swap(this->points[0], this->points[1]); 78 std::swap(this->points[0], this->points[1]);
79 } 79 }

mercurial