Sat, 11 Jun 2022 14:30:30 +0300
Rewrite dependency loading
183
97b591813c8b
- Add editors for string and bool properties
Teemu Piippo <teemu@hecknology.net>
parents:
182
diff
changeset
|
1 | #include <QCheckBox> |
97b591813c8b
- Add editors for string and bool properties
Teemu Piippo <teemu@hecknology.net>
parents:
182
diff
changeset
|
2 | #include <QLineEdit> |
178 | 3 | #include <QFormLayout> |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
4 | #include "objecteditor.h" |
152 | 5 | #include "document.h" |
178 | 6 | #include "widgets/colorbutton.h" |
7 | #include "widgets/colorindexinput.h" | |
181 | 8 | #include "widgets/vec3editor.h" |
182
27fb1c3c9fbb
add ui file to object editor
Teemu Piippo <teemu@hecknology.net>
parents:
181
diff
changeset
|
9 | #include "ui_objecteditor.h" |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | |
200 | 11 | using PropertyValue = std::variant< |
12 | const glm::vec3*, | |
13 | const glm::mat4*, | |
14 | const QString*, | |
15 | ldraw::Color>; | |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
16 | |
200 | 17 | enum PropertyKey |
180
5b7a8f2270ff
Handle properties in a generic manner in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
178
diff
changeset
|
18 | { |
200 | 19 | Point1, |
20 | Point2, | |
21 | Point3, | |
22 | Point4, | |
23 | Control1, | |
24 | Control2, | |
25 | Color, | |
26 | Transformation, | |
27 | Name, | |
28 | Text, | |
29 | Code, | |
30 | }; | |
180
5b7a8f2270ff
Handle properties in a generic manner in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
178
diff
changeset
|
31 | |
200 | 32 | std::map<PropertyKey, PropertyValue> getProperties(const ModelElement& element) |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | { |
200 | 34 | std::map<PropertyKey, PropertyValue> result; |
35 | std::visit<void>(overloaded{ | |
36 | [&](const Colored<LineSegment>& edge) { | |
37 | result[Point1] = &edge.p1; | |
38 | result[Point2] = &edge.p2; | |
39 | result[Color] = edge.color; | |
40 | }, | |
41 | [&](const Colored<Triangle>& tri) { | |
42 | result[Point1] = &tri.p1; | |
43 | result[Point2] = &tri.p2; | |
44 | result[Point3] = &tri.p3; | |
45 | result[Color] = tri.color; | |
46 | }, | |
47 | [&](const Colored<Quadrilateral>& quad) { | |
48 | result[Point1] = &quad.p1; | |
49 | result[Point2] = &quad.p2; | |
50 | result[Point3] = &quad.p3; | |
51 | result[Point4] = &quad.p4; | |
52 | result[Color] = quad.color; | |
53 | }, | |
54 | [&](const Colored<ConditionalEdge>& cedge) { | |
55 | result[Point1] = &cedge.p1; | |
56 | result[Point2] = &cedge.p2; | |
57 | result[Control1] = &cedge.c1; | |
58 | result[Control2] = &cedge.c2; | |
59 | result[Color] = cedge.color; | |
60 | }, | |
61 | [&](const Colored<SubfileReference>& ref) { | |
62 | result[Transformation] = &ref.transformation; | |
63 | result[Name] = &ref.name; | |
64 | result[Color] = ref.color; | |
65 | }, | |
66 | [&](Empty) {}, | |
67 | [&](const Comment& comment) { | |
68 | result[Text] = &comment.text; | |
69 | }, | |
70 | [&](const ParseError& parseError) { | |
71 | result[Code] = &parseError.code; | |
72 | }, | |
73 | }, element); | |
74 | return result; | |
183
97b591813c8b
- Add editors for string and bool properties
Teemu Piippo <teemu@hecknology.net>
parents:
182
diff
changeset
|
75 | } |