Sun, 03 Nov 2019 17:57:21 +0200
added dependency loading
3 | 1 | #include "polygon.h" |
2 | ||
3 | modelobjects::Triangle::Triangle( | |
4 | const Vertex& point_1, | |
5 | const Vertex& point_2, | |
6 | const Vertex& point_3, | |
7 | Color color_index) : | |
8 | ColoredBaseObject{color_index}, | |
9 | points{point_1, point_2, point_3} | |
10 | { | |
11 | } | |
12 | ||
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
13 | modelobjects::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) : |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
14 | ColoredBaseObject{color}, |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
15 | points{vertices[0], vertices[1], vertices[2]} |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
16 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
17 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
18 | |
3 | 19 | QVariant modelobjects::Triangle::getProperty(const Property id) const |
20 | { | |
21 | switch (id) | |
22 | { | |
23 | case Property::Point1: | |
24 | return points[0]; | |
25 | case Property::Point2: | |
26 | return points[1]; | |
27 | case Property::Point3: | |
28 | return points[2]; | |
29 | default: | |
30 | return ColoredBaseObject::getProperty(id); | |
31 | } | |
32 | } | |
33 | ||
34 | auto modelobjects::Triangle::setProperty(Property id, const QVariant& value) | |
35 | -> SetPropertyResult | |
36 | { | |
37 | switch (id) | |
38 | { | |
39 | case Property::Point1: | |
40 | points[0] = value.value<Vertex>(); | |
41 | return SetPropertyResult::Success; | |
42 | case Property::Point2: | |
43 | points[1] = value.value<Vertex>(); | |
44 | return SetPropertyResult::Success; | |
45 | case Property::Point3: | |
46 | points[2] = value.value<Vertex>(); | |
47 | return SetPropertyResult::Success; | |
48 | default: | |
49 | return ColoredBaseObject::setProperty(id, value); | |
50 | } | |
51 | } | |
52 | ||
6 | 53 | QString modelobjects::Triangle::textRepresentation() const |
54 | { | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
55 | return utility::format("%1 %2 %3", |
6 | 56 | vertexToStringParens(points[0]), |
57 | vertexToStringParens(points[1]), | |
58 | vertexToStringParens(points[2])); | |
59 | } | |
60 | ||
3 | 61 | modelobjects::Quadrilateral::Quadrilateral( |
62 | const Vertex& point_1, | |
63 | const Vertex& point_2, | |
64 | const Vertex& point_3, | |
65 | const Vertex& point_4, | |
66 | Color color_index) : | |
67 | ColoredBaseObject{color_index}, | |
68 | points{point_1, point_2, point_3, point_4} | |
69 | { | |
70 | } | |
71 | ||
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
72 | modelobjects::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) : |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
73 | ColoredBaseObject{color}, |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
74 | points{vertices[0], vertices[1], vertices[2], vertices[3]} |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
75 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
76 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
77 | |
3 | 78 | QVariant modelobjects::Quadrilateral::getProperty(const Property id) const |
79 | { | |
80 | switch (id) | |
81 | { | |
82 | case Property::Point1: | |
83 | return points[0]; | |
84 | case Property::Point2: | |
85 | return points[1]; | |
86 | case Property::Point3: | |
87 | return points[2]; | |
88 | case Property::Point4: | |
89 | return points[3]; | |
90 | default: | |
91 | return ColoredBaseObject::getProperty(id); | |
92 | } | |
93 | } | |
94 | ||
95 | auto modelobjects::Quadrilateral::setProperty( | |
96 | const Property id, | |
97 | const QVariant& value) | |
98 | -> SetPropertyResult | |
99 | { | |
100 | switch (id) | |
101 | { | |
102 | case Property::Point1: | |
103 | points[0] = value.value<Vertex>(); | |
104 | return SetPropertyResult::Success; | |
105 | case Property::Point2: | |
106 | points[1] = value.value<Vertex>(); | |
107 | return SetPropertyResult::Success; | |
108 | case Property::Point3: | |
109 | points[2] = value.value<Vertex>(); | |
110 | return SetPropertyResult::Success; | |
111 | case Property::Point4: | |
112 | points[3] = value.value<Vertex>(); | |
113 | return SetPropertyResult::Success; | |
114 | default: | |
115 | return ColoredBaseObject::setProperty(id, value); | |
116 | } | |
117 | } | |
6 | 118 | |
119 | QString modelobjects::Quadrilateral::textRepresentation() const | |
120 | { | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
121 | return utility::format("%1 %2 %3 %4", |
6 | 122 | vertexToStringParens(points[0]), |
123 | vertexToStringParens(points[1]), | |
124 | vertexToStringParens(points[2]), | |
125 | vertexToStringParens(points[3])); | |
126 | } |