Sat, 05 Oct 2019 23:47:03 +0300
added the settings editor
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 | ||
13 | QVariant modelobjects::Triangle::getProperty(const Property id) const | |
14 | { | |
15 | switch (id) | |
16 | { | |
17 | case Property::Point1: | |
18 | return points[0]; | |
19 | case Property::Point2: | |
20 | return points[1]; | |
21 | case Property::Point3: | |
22 | return points[2]; | |
23 | default: | |
24 | return ColoredBaseObject::getProperty(id); | |
25 | } | |
26 | } | |
27 | ||
28 | auto modelobjects::Triangle::setProperty(Property id, const QVariant& value) | |
29 | -> SetPropertyResult | |
30 | { | |
31 | switch (id) | |
32 | { | |
33 | case Property::Point1: | |
34 | points[0] = value.value<Vertex>(); | |
35 | return SetPropertyResult::Success; | |
36 | case Property::Point2: | |
37 | points[1] = value.value<Vertex>(); | |
38 | return SetPropertyResult::Success; | |
39 | case Property::Point3: | |
40 | points[2] = value.value<Vertex>(); | |
41 | return SetPropertyResult::Success; | |
42 | default: | |
43 | return ColoredBaseObject::setProperty(id, value); | |
44 | } | |
45 | } | |
46 | ||
6 | 47 | QString modelobjects::Triangle::textRepresentation() const |
48 | { | |
49 | return format("%1 %2 %3", | |
50 | vertexToStringParens(points[0]), | |
51 | vertexToStringParens(points[1]), | |
52 | vertexToStringParens(points[2])); | |
53 | } | |
54 | ||
3 | 55 | modelobjects::Quadrilateral::Quadrilateral( |
56 | const Vertex& point_1, | |
57 | const Vertex& point_2, | |
58 | const Vertex& point_3, | |
59 | const Vertex& point_4, | |
60 | Color color_index) : | |
61 | ColoredBaseObject{color_index}, | |
62 | points{point_1, point_2, point_3, point_4} | |
63 | { | |
64 | } | |
65 | ||
66 | QVariant modelobjects::Quadrilateral::getProperty(const Property id) const | |
67 | { | |
68 | switch (id) | |
69 | { | |
70 | case Property::Point1: | |
71 | return points[0]; | |
72 | case Property::Point2: | |
73 | return points[1]; | |
74 | case Property::Point3: | |
75 | return points[2]; | |
76 | case Property::Point4: | |
77 | return points[3]; | |
78 | default: | |
79 | return ColoredBaseObject::getProperty(id); | |
80 | } | |
81 | } | |
82 | ||
83 | auto modelobjects::Quadrilateral::setProperty( | |
84 | const Property id, | |
85 | const QVariant& value) | |
86 | -> SetPropertyResult | |
87 | { | |
88 | switch (id) | |
89 | { | |
90 | case Property::Point1: | |
91 | points[0] = value.value<Vertex>(); | |
92 | return SetPropertyResult::Success; | |
93 | case Property::Point2: | |
94 | points[1] = value.value<Vertex>(); | |
95 | return SetPropertyResult::Success; | |
96 | case Property::Point3: | |
97 | points[2] = value.value<Vertex>(); | |
98 | return SetPropertyResult::Success; | |
99 | case Property::Point4: | |
100 | points[3] = value.value<Vertex>(); | |
101 | return SetPropertyResult::Success; | |
102 | default: | |
103 | return ColoredBaseObject::setProperty(id, value); | |
104 | } | |
105 | } | |
6 | 106 | |
107 | QString modelobjects::Quadrilateral::textRepresentation() const | |
108 | { | |
109 | return format("%1 %2 %3 %4", | |
110 | vertexToStringParens(points[0]), | |
111 | vertexToStringParens(points[1]), | |
112 | vertexToStringParens(points[2]), | |
113 | vertexToStringParens(points[3])); | |
114 | } |