src/objecttypes/polygon.cpp

changeset 13
6e838748867b
parent 8
44679e468ba9
equal deleted inserted replaced
12:fe67489523b5 13:6e838748867b
1 #include "polygon.h" 1 #include "polygon.h"
2 2
3 modelobjects::Triangle::Triangle( 3 linetypes::Triangle::Triangle(
4 const Vertex& point_1, 4 const Vertex& point_1,
5 const Vertex& point_2, 5 const Vertex& point_2,
6 const Vertex& point_3, 6 const Vertex& point_3,
7 Color color_index) : 7 Color color_index) :
8 ColoredBaseObject{color_index}, 8 ColoredObject{color_index},
9 points{point_1, point_2, point_3} 9 points{point_1, point_2, point_3}
10 { 10 {
11 } 11 }
12 12
13 modelobjects::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) : 13 linetypes::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) :
14 ColoredBaseObject{color}, 14 ColoredObject{color},
15 points{vertices[0], vertices[1], vertices[2]} 15 points{vertices[0], vertices[1], vertices[2]}
16 { 16 {
17 } 17 }
18 18
19 QVariant modelobjects::Triangle::getProperty(const Property id) const 19 QVariant linetypes::Triangle::getProperty(const Property id) const
20 { 20 {
21 switch (id) 21 switch (id)
22 { 22 {
23 case Property::Point1: 23 case Property::Point1:
24 return points[0]; 24 return points[0];
25 case Property::Point2: 25 case Property::Point2:
26 return points[1]; 26 return points[1];
27 case Property::Point3: 27 case Property::Point3:
28 return points[2]; 28 return points[2];
29 default: 29 default:
30 return ColoredBaseObject::getProperty(id); 30 return ColoredObject::getProperty(id);
31 } 31 }
32 } 32 }
33 33
34 auto modelobjects::Triangle::setProperty(Property id, const QVariant& value) 34 auto linetypes::Triangle::setProperty(Property id, const QVariant& value)
35 -> SetPropertyResult 35 -> SetPropertyResult
36 { 36 {
37 switch (id) 37 switch (id)
38 { 38 {
39 case Property::Point1: 39 case Property::Point1:
44 return SetPropertyResult::Success; 44 return SetPropertyResult::Success;
45 case Property::Point3: 45 case Property::Point3:
46 points[2] = value.value<Vertex>(); 46 points[2] = value.value<Vertex>();
47 return SetPropertyResult::Success; 47 return SetPropertyResult::Success;
48 default: 48 default:
49 return ColoredBaseObject::setProperty(id, value); 49 return ColoredObject::setProperty(id, value);
50 } 50 }
51 } 51 }
52 52
53 QString modelobjects::Triangle::textRepresentation() const 53 QString linetypes::Triangle::textRepresentation() const
54 { 54 {
55 return utility::format("%1 %2 %3", 55 return utility::format("%1 %2 %3",
56 vertexToStringParens(points[0]), 56 vertexToStringParens(points[0]),
57 vertexToStringParens(points[1]), 57 vertexToStringParens(points[1]),
58 vertexToStringParens(points[2])); 58 vertexToStringParens(points[2]));
59 } 59 }
60 60
61 modelobjects::Quadrilateral::Quadrilateral( 61 linetypes::Quadrilateral::Quadrilateral(
62 const Vertex& point_1, 62 const Vertex& point_1,
63 const Vertex& point_2, 63 const Vertex& point_2,
64 const Vertex& point_3, 64 const Vertex& point_3,
65 const Vertex& point_4, 65 const Vertex& point_4,
66 Color color_index) : 66 Color color_index) :
67 ColoredBaseObject{color_index}, 67 ColoredObject{color_index},
68 points{point_1, point_2, point_3, point_4} 68 points{point_1, point_2, point_3, point_4}
69 { 69 {
70 } 70 }
71 71
72 modelobjects::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) : 72 linetypes::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) :
73 ColoredBaseObject{color}, 73 ColoredObject{color},
74 points{vertices[0], vertices[1], vertices[2], vertices[3]} 74 points{vertices[0], vertices[1], vertices[2], vertices[3]}
75 { 75 {
76 } 76 }
77 77
78 QVariant modelobjects::Quadrilateral::getProperty(const Property id) const 78 QVariant linetypes::Quadrilateral::getProperty(const Property id) const
79 { 79 {
80 switch (id) 80 switch (id)
81 { 81 {
82 case Property::Point1: 82 case Property::Point1:
83 return points[0]; 83 return points[0];
86 case Property::Point3: 86 case Property::Point3:
87 return points[2]; 87 return points[2];
88 case Property::Point4: 88 case Property::Point4:
89 return points[3]; 89 return points[3];
90 default: 90 default:
91 return ColoredBaseObject::getProperty(id); 91 return ColoredObject::getProperty(id);
92 } 92 }
93 } 93 }
94 94
95 auto modelobjects::Quadrilateral::setProperty( 95 auto linetypes::Quadrilateral::setProperty(
96 const Property id, 96 const Property id,
97 const QVariant& value) 97 const QVariant& value)
98 -> SetPropertyResult 98 -> SetPropertyResult
99 { 99 {
100 switch (id) 100 switch (id)
110 return SetPropertyResult::Success; 110 return SetPropertyResult::Success;
111 case Property::Point4: 111 case Property::Point4:
112 points[3] = value.value<Vertex>(); 112 points[3] = value.value<Vertex>();
113 return SetPropertyResult::Success; 113 return SetPropertyResult::Success;
114 default: 114 default:
115 return ColoredBaseObject::setProperty(id, value); 115 return ColoredObject::setProperty(id, value);
116 } 116 }
117 } 117 }
118 118
119 QString modelobjects::Quadrilateral::textRepresentation() const 119 QString linetypes::Quadrilateral::textRepresentation() const
120 { 120 {
121 return utility::format("%1 %2 %3 %4", 121 return utility::format("%1 %2 %3 %4",
122 vertexToStringParens(points[0]), 122 vertexToStringParens(points[0]),
123 vertexToStringParens(points[1]), 123 vertexToStringParens(points[1]),
124 vertexToStringParens(points[2]), 124 vertexToStringParens(points[2]),

mercurial