1 #include "quadrilateral.h" |
1 #include "quadrilateral.h" |
2 |
|
3 ldraw::Quadrilateral::Quadrilateral |
|
4 ( |
|
5 const glm::vec3& point_1, |
|
6 const glm::vec3& point_2, |
|
7 const glm::vec3& point_3, |
|
8 const glm::vec3& point_4, |
|
9 Color color_index |
|
10 ) : |
|
11 ColoredObject{color_index}, |
|
12 points{point_1, point_2, point_3, point_4} |
|
13 { |
|
14 } |
|
15 |
|
16 ldraw::Quadrilateral::Quadrilateral |
|
17 ( |
|
18 const std::array<glm::vec3, 4>& vertices, |
|
19 const Color color |
|
20 ) : |
|
21 ColoredObject{color}, |
|
22 points{vertices[0], vertices[1], vertices[2], vertices[3]} |
|
23 { |
|
24 } |
|
25 |
|
26 QVariant ldraw::Quadrilateral::getProperty(const Property id) const |
|
27 { |
|
28 switch (id) |
|
29 { |
|
30 case Property::Point0: |
|
31 return QVariant::fromValue(points[0]); |
|
32 case Property::Point1: |
|
33 return QVariant::fromValue(points[1]); |
|
34 case Property::Point2: |
|
35 return QVariant::fromValue(points[2]); |
|
36 case Property::Point3: |
|
37 return QVariant::fromValue(points[3]); |
|
38 default: |
|
39 return ColoredObject::getProperty(id); |
|
40 } |
|
41 } |
|
42 |
|
43 void ldraw::Quadrilateral::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) |
|
44 { |
|
45 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point0, {points[0] = value;}) |
|
46 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point1, {points[1] = value;}) |
|
47 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point2, {points[2] = value;}) |
|
48 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point3, {points[3] = value;}) |
|
49 ColoredObject::setProperty(result, pair); |
|
50 } |
|
51 |
2 |
52 QString ldraw::Quadrilateral::textRepresentation() const |
3 QString ldraw::Quadrilateral::textRepresentation() const |
53 { |
4 { |
54 return utility::format("%1 %2 %3 %4", |
5 return utility::format("%1 %2 %3 %4", |
55 utility::vertexToStringParens(points[0]), |
6 utility::vertexToStringParens(this->points[0]), |
56 utility::vertexToStringParens(points[1]), |
7 utility::vertexToStringParens(this->points[1]), |
57 utility::vertexToStringParens(points[2]), |
8 utility::vertexToStringParens(this->points[2]), |
58 utility::vertexToStringParens(points[3])); |
9 utility::vertexToStringParens(this->points[3])); |
59 } |
10 } |
60 |
11 |
61 void ldraw::Quadrilateral::getPolygons( |
12 void ldraw::Quadrilateral::getPolygons( |
62 std::vector<gl::Polygon>& polygons, |
13 std::vector<gl::Polygon>& polygons, |
63 GetPolygonsContext* context) const |
14 GetPolygonsContext* context) const |