Fri, 31 Jan 2020 00:25:35 +0200
added render style storage
3 | 1 | #include "edge.h" |
2 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
3 | ldraw::Edge::Edge( |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
4 | const glm::vec3& point_1, |
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
5 | const glm::vec3& point_2, |
3 | 6 | const Color color_index) : |
13 | 7 | ColoredObject{color_index}, |
3 | 8 | point_1{point_1}, |
9 | point_2{point_2} {} | |
10 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
11 | ldraw::Edge::Edge(const QVector<glm::vec3>& vertices, const Color color) : |
13 | 12 | ColoredObject{color}, |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
13 | point_1{vertices[0]}, |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
14 | point_2{vertices[1]} |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
15 | { |
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 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
18 | QVariant ldraw::Edge::getProperty(Property property) const |
3 | 19 | { |
20 | switch (property) | |
21 | { | |
22 | case Property::Point1: | |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
23 | return QVariant::fromValue(point_1); |
3 | 24 | case Property::Point2: |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
25 | return QVariant::fromValue(point_2); |
3 | 26 | default: |
27 | return BaseClass::getProperty(property); | |
28 | } | |
29 | } | |
30 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
31 | auto ldraw::Edge::setProperty(Property property, const QVariant& value) |
3 | 32 | -> SetPropertyResult |
33 | { | |
34 | switch (property) | |
35 | { | |
36 | case Property::Point1: | |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
37 | point_1 = value.value<glm::vec3>(); |
3 | 38 | return SetPropertyResult::Success; |
39 | case Property::Point2: | |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
40 | point_2 = value.value<glm::vec3>(); |
3 | 41 | return SetPropertyResult::Success; |
42 | default: | |
43 | return BaseClass::setProperty(property, value); | |
44 | } | |
45 | } | |
6 | 46 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
47 | QString ldraw::Edge::textRepresentation() const |
6 | 48 | { |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
49 | return utility::format("%1 %2", utility::vertexToStringParens(point_1), utility::vertexToStringParens(point_2)); |
6 | 50 | } |
21 | 51 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
52 | void ldraw::Edge::getPolygons( |
21 | 53 | std::vector<gl::Polygon>& polygons, |
54 | GetPolygonsContext* context) const | |
55 | { | |
56 | Q_UNUSED(context) | |
57 | polygons.push_back(gl::edgeLine(this->point_1, this->point_2, this->colorIndex, this->id)); | |
58 | } |