Wed, 22 Jun 2022 16:13:01 +0300
Fix invertnext not working with circular primitives
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*, | |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
15 | ldraw::Color, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
16 | const CircularFraction*>; |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | |
200 | 18 | enum PropertyKey |
180
5b7a8f2270ff
Handle properties in a generic manner in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
178
diff
changeset
|
19 | { |
200 | 20 | Point1, |
21 | Point2, | |
22 | Point3, | |
23 | Point4, | |
24 | Control1, | |
25 | Control2, | |
26 | Color, | |
27 | Transformation, | |
28 | Name, | |
29 | Text, | |
30 | Code, | |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
31 | Fraction, |
200 | 32 | }; |
180
5b7a8f2270ff
Handle properties in a generic manner in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
178
diff
changeset
|
33 | |
200 | 34 | 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
|
35 | { |
200 | 36 | std::map<PropertyKey, PropertyValue> result; |
37 | std::visit<void>(overloaded{ | |
38 | [&](const Colored<LineSegment>& edge) { | |
39 | result[Point1] = &edge.p1; | |
40 | result[Point2] = &edge.p2; | |
41 | result[Color] = edge.color; | |
42 | }, | |
43 | [&](const Colored<Triangle>& tri) { | |
44 | result[Point1] = &tri.p1; | |
45 | result[Point2] = &tri.p2; | |
46 | result[Point3] = &tri.p3; | |
47 | result[Color] = tri.color; | |
48 | }, | |
49 | [&](const Colored<Quadrilateral>& quad) { | |
50 | result[Point1] = &quad.p1; | |
51 | result[Point2] = &quad.p2; | |
52 | result[Point3] = &quad.p3; | |
53 | result[Point4] = &quad.p4; | |
54 | result[Color] = quad.color; | |
55 | }, | |
56 | [&](const Colored<ConditionalEdge>& cedge) { | |
57 | result[Point1] = &cedge.p1; | |
58 | result[Point2] = &cedge.p2; | |
59 | result[Control1] = &cedge.c1; | |
60 | result[Control2] = &cedge.c2; | |
61 | result[Color] = cedge.color; | |
62 | }, | |
63 | [&](const Colored<SubfileReference>& ref) { | |
64 | result[Transformation] = &ref.transformation; | |
65 | result[Name] = &ref.name; | |
66 | result[Color] = ref.color; | |
67 | }, | |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
68 | [&](const Colored<CircularPrimitive>& circ) { |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
69 | result[Transformation] = &circ.transformation; |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
70 | result[Fraction] = &circ.fraction; |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
71 | result[Color] = circ.color; |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
200
diff
changeset
|
72 | }, |
200 | 73 | [&](Empty) {}, |
74 | [&](const Comment& comment) { | |
75 | result[Text] = &comment.text; | |
76 | }, | |
77 | [&](const ParseError& parseError) { | |
78 | result[Code] = &parseError.code; | |
79 | }, | |
80 | }, element); | |
81 | return result; | |
183
97b591813c8b
- Add editors for string and bool properties
Teemu Piippo <teemu@hecknology.net>
parents:
182
diff
changeset
|
82 | } |