|
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 |
|
47 modelobjects::Quadrilateral::Quadrilateral( |
|
48 const Vertex& point_1, |
|
49 const Vertex& point_2, |
|
50 const Vertex& point_3, |
|
51 const Vertex& point_4, |
|
52 Color color_index) : |
|
53 ColoredBaseObject{color_index}, |
|
54 points{point_1, point_2, point_3, point_4} |
|
55 { |
|
56 } |
|
57 |
|
58 QVariant modelobjects::Quadrilateral::getProperty(const Property id) const |
|
59 { |
|
60 switch (id) |
|
61 { |
|
62 case Property::Point1: |
|
63 return points[0]; |
|
64 case Property::Point2: |
|
65 return points[1]; |
|
66 case Property::Point3: |
|
67 return points[2]; |
|
68 case Property::Point4: |
|
69 return points[3]; |
|
70 default: |
|
71 return ColoredBaseObject::getProperty(id); |
|
72 } |
|
73 } |
|
74 |
|
75 auto modelobjects::Quadrilateral::setProperty( |
|
76 const Property id, |
|
77 const QVariant& value) |
|
78 -> SetPropertyResult |
|
79 { |
|
80 switch (id) |
|
81 { |
|
82 case Property::Point1: |
|
83 points[0] = value.value<Vertex>(); |
|
84 return SetPropertyResult::Success; |
|
85 case Property::Point2: |
|
86 points[1] = value.value<Vertex>(); |
|
87 return SetPropertyResult::Success; |
|
88 case Property::Point3: |
|
89 points[2] = value.value<Vertex>(); |
|
90 return SetPropertyResult::Success; |
|
91 case Property::Point4: |
|
92 points[3] = value.value<Vertex>(); |
|
93 return SetPropertyResult::Success; |
|
94 default: |
|
95 return ColoredBaseObject::setProperty(id, value); |
|
96 } |
|
97 } |