Sat, 14 Dec 2019 22:36:06 +0200
added missing files
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
1 | #include "quadrilateral.h" |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
2 | |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
3 | linetypes::Quadrilateral::Quadrilateral( |
18 | 4 | const Point3D& point_1, |
5 | const Point3D& point_2, | |
6 | const Point3D& point_3, | |
7 | const Point3D& point_4, | |
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
8 | Color color_index) : |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
9 | ColoredObject{color_index}, |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | points{point_1, point_2, point_3, point_4} |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
11 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
12 | } |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
13 | |
18 | 14 | linetypes::Quadrilateral::Quadrilateral(const QVector<Point3D>& vertices, const Color color) : |
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
15 | ColoredObject{color}, |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
16 | points{vertices[0], vertices[1], vertices[2], vertices[3]} |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
18 | } |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | QVariant linetypes::Quadrilateral::getProperty(const Property id) const |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | switch (id) |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
24 | case Property::Point1: |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
25 | return points[0]; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | case Property::Point2: |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | return points[1]; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
28 | case Property::Point3: |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | return points[2]; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | case Property::Point4: |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | return points[3]; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
32 | default: |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | return ColoredObject::getProperty(id); |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
34 | } |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
35 | } |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
36 | |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
37 | auto linetypes::Quadrilateral::setProperty( |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
38 | const Property id, |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
39 | const QVariant& value) |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
40 | -> SetPropertyResult |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
41 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
42 | switch (id) |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
43 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
44 | case Property::Point1: |
18 | 45 | points[0] = value.value<Point3D>(); |
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
46 | return SetPropertyResult::Success; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
47 | case Property::Point2: |
18 | 48 | points[1] = value.value<Point3D>(); |
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
49 | return SetPropertyResult::Success; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
50 | case Property::Point3: |
18 | 51 | points[2] = value.value<Point3D>(); |
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
52 | return SetPropertyResult::Success; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
53 | case Property::Point4: |
18 | 54 | points[3] = value.value<Point3D>(); |
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
55 | return SetPropertyResult::Success; |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
56 | default: |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
57 | return ColoredObject::setProperty(id, value); |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
58 | } |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
59 | } |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
60 | |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
61 | QString linetypes::Quadrilateral::textRepresentation() const |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
62 | { |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
63 | return utility::format("%1 %2 %3 %4", |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
64 | vertexToStringParens(points[0]), |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
65 | vertexToStringParens(points[1]), |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
66 | vertexToStringParens(points[2]), |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
67 | vertexToStringParens(points[3])); |
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
68 | } |