src/linetypes/quadrilateral.cpp

Sat, 14 Dec 2019 23:00:01 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 14 Dec 2019 23:00:01 +0200
changeset 20
cef43609a374
parent 18
918b6c0f8b5b
child 21
0133e565e072
permissions
-rw-r--r--

fixed build

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
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
4 const Point3D& point_1,
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
5 const Point3D& point_2,
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
6 const Point3D& point_3,
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 15
diff changeset
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 }

mercurial