src/linetypes/triangle.cpp

changeset 15
9e18ec63eec3
parent 14
20d2ed3af73d
child 18
918b6c0f8b5b
equal deleted inserted replaced
14:20d2ed3af73d 15:9e18ec63eec3
1 #include "triangle.h"
2
3 linetypes::Triangle::Triangle(
4 const Vertex& point_1,
5 const Vertex& point_2,
6 const Vertex& point_3,
7 Color color_index) :
8 ColoredObject{color_index},
9 points{point_1, point_2, point_3}
10 {
11 }
12
13 linetypes::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) :
14 ColoredObject{color},
15 points{vertices[0], vertices[1], vertices[2]}
16 {
17 }
18
19 QVariant linetypes::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 ColoredObject::getProperty(id);
31 }
32 }
33
34 auto linetypes::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 ColoredObject::setProperty(id, value);
50 }
51 }
52
53 QString linetypes::Triangle::textRepresentation() const
54 {
55 return utility::format("%1 %2 %3",
56 vertexToStringParens(points[0]),
57 vertexToStringParens(points[1]),
58 vertexToStringParens(points[2]));
59 }

mercurial