src/linetypes/quadrilateral.cpp

changeset 15
9e18ec63eec3
child 18
918b6c0f8b5b
equal deleted inserted replaced
14:20d2ed3af73d 15:9e18ec63eec3
1 #include "quadrilateral.h"
2
3 linetypes::Quadrilateral::Quadrilateral(
4 const Vertex& point_1,
5 const Vertex& point_2,
6 const Vertex& point_3,
7 const Vertex& point_4,
8 Color color_index) :
9 ColoredObject{color_index},
10 points{point_1, point_2, point_3, point_4}
11 {
12 }
13
14 linetypes::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) :
15 ColoredObject{color},
16 points{vertices[0], vertices[1], vertices[2], vertices[3]}
17 {
18 }
19
20 QVariant linetypes::Quadrilateral::getProperty(const Property id) const
21 {
22 switch (id)
23 {
24 case Property::Point1:
25 return points[0];
26 case Property::Point2:
27 return points[1];
28 case Property::Point3:
29 return points[2];
30 case Property::Point4:
31 return points[3];
32 default:
33 return ColoredObject::getProperty(id);
34 }
35 }
36
37 auto linetypes::Quadrilateral::setProperty(
38 const Property id,
39 const QVariant& value)
40 -> SetPropertyResult
41 {
42 switch (id)
43 {
44 case Property::Point1:
45 points[0] = value.value<Vertex>();
46 return SetPropertyResult::Success;
47 case Property::Point2:
48 points[1] = value.value<Vertex>();
49 return SetPropertyResult::Success;
50 case Property::Point3:
51 points[2] = value.value<Vertex>();
52 return SetPropertyResult::Success;
53 case Property::Point4:
54 points[3] = value.value<Vertex>();
55 return SetPropertyResult::Success;
56 default:
57 return ColoredObject::setProperty(id, value);
58 }
59 }
60
61 QString linetypes::Quadrilateral::textRepresentation() const
62 {
63 return utility::format("%1 %2 %3 %4",
64 vertexToStringParens(points[0]),
65 vertexToStringParens(points[1]),
66 vertexToStringParens(points[2]),
67 vertexToStringParens(points[3]));
68 }

mercurial