Fri, 13 Dec 2019 21:35:59 +0200
things
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
14
diff
changeset
|
1 | #include "triangle.h" |
3 | 2 | |
13 | 3 | linetypes::Triangle::Triangle( |
18 | 4 | const Point3D& point_1, |
5 | const Point3D& point_2, | |
6 | const Point3D& point_3, | |
3 | 7 | Color color_index) : |
13 | 8 | ColoredObject{color_index}, |
3 | 9 | points{point_1, point_2, point_3} |
10 | { | |
11 | } | |
12 | ||
18 | 13 | linetypes::Triangle::Triangle(const QVector<Point3D>& vertices, const Color color) : |
13 | 14 | ColoredObject{color}, |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
15 | points{vertices[0], vertices[1], vertices[2]} |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
16 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
17 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
18 | |
13 | 19 | QVariant linetypes::Triangle::getProperty(const Property id) const |
3 | 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: | |
13 | 30 | return ColoredObject::getProperty(id); |
3 | 31 | } |
32 | } | |
33 | ||
13 | 34 | auto linetypes::Triangle::setProperty(Property id, const QVariant& value) |
3 | 35 | -> SetPropertyResult |
36 | { | |
37 | switch (id) | |
38 | { | |
39 | case Property::Point1: | |
18 | 40 | points[0] = value.value<Point3D>(); |
3 | 41 | return SetPropertyResult::Success; |
42 | case Property::Point2: | |
18 | 43 | points[1] = value.value<Point3D>(); |
3 | 44 | return SetPropertyResult::Success; |
45 | case Property::Point3: | |
18 | 46 | points[2] = value.value<Point3D>(); |
3 | 47 | return SetPropertyResult::Success; |
48 | default: | |
13 | 49 | return ColoredObject::setProperty(id, value); |
3 | 50 | } |
51 | } | |
52 | ||
13 | 53 | QString linetypes::Triangle::textRepresentation() const |
6 | 54 | { |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
55 | return utility::format("%1 %2 %3", |
6 | 56 | vertexToStringParens(points[0]), |
57 | vertexToStringParens(points[1]), | |
58 | vertexToStringParens(points[2])); | |
59 | } |