src/linetypes/quadrilateral.cpp

changeset 35
98906a94732f
parent 33
4c41bfe2ec6e
child 77
028798a72591
equal deleted inserted replaced
34:1de2b8d64e9f 35:98906a94732f
1 #include "quadrilateral.h" 1 #include "quadrilateral.h"
2 2
3 linetypes::Quadrilateral::Quadrilateral( 3 ldraw::Quadrilateral::Quadrilateral(
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 const glm::vec3& 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<glm::vec3>& vertices, const Color color) : 14 ldraw::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 ldraw::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 QVariant::fromValue(points[0]); 25 return QVariant::fromValue(points[0]);
32 default: 32 default:
33 return ColoredObject::getProperty(id); 33 return ColoredObject::getProperty(id);
34 } 34 }
35 } 35 }
36 36
37 auto linetypes::Quadrilateral::setProperty( 37 auto ldraw::Quadrilateral::setProperty(
38 const Property id, 38 const Property id,
39 const QVariant& value) 39 const QVariant& value)
40 -> SetPropertyResult 40 -> SetPropertyResult
41 { 41 {
42 switch (id) 42 switch (id)
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 ldraw::Quadrilateral::textRepresentation() const
62 { 62 {
63 return utility::format("%1 %2 %3 %4", 63 return utility::format("%1 %2 %3 %4",
64 utility::vertexToStringParens(points[0]), 64 utility::vertexToStringParens(points[0]),
65 utility::vertexToStringParens(points[1]), 65 utility::vertexToStringParens(points[1]),
66 utility::vertexToStringParens(points[2]), 66 utility::vertexToStringParens(points[2]),
67 utility::vertexToStringParens(points[3])); 67 utility::vertexToStringParens(points[3]));
68 } 68 }
69 69
70 void linetypes::Quadrilateral::getPolygons( 70 void ldraw::Quadrilateral::getPolygons(
71 std::vector<gl::Polygon>& polygons, 71 std::vector<gl::Polygon>& polygons,
72 GetPolygonsContext* context) const 72 GetPolygonsContext* context) const
73 { 73 {
74 Q_UNUSED(context) 74 Q_UNUSED(context)
75 polygons.push_back(gl::quadrilateral( 75 polygons.push_back(gl::quadrilateral(
79 this->points[3], 79 this->points[3],
80 this->colorIndex, 80 this->colorIndex,
81 this->id)); 81 this->id));
82 } 82 }
83 83
84 void linetypes::Quadrilateral::invert() 84 void ldraw::Quadrilateral::invert()
85 { 85 {
86 // 0 1 2 3 86 // 0 1 2 3
87 // -> 2 1 0 3 87 // -> 2 1 0 3
88 std::swap(this->points[0], this->points[2]); 88 std::swap(this->points[0], this->points[2]);
89 } 89 }

mercurial