Sun, 25 Jul 2021 20:39:21 +0300
use QT_NO_KEYWORDS
6 | 1 | #include <QBrush> |
2 | #include <QFont> | |
14 | 3 | #include "object.h" |
89 | 4 | #include "widgets/vec3editor.h" |
5 | #include "modeleditcontext.h" | |
3 | 6 | |
46 | 7 | static std::int32_t getIdForNewObject() |
6 | 8 | { |
46 | 9 | static std::int32_t id = 0; |
6 | 10 | id += 1; |
11 | return id; | |
12 | } | |
3 | 13 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
14 | ldraw::Object::Object() : |
6 | 15 | id {getIdForNewObject()} |
3 | 16 | { |
17 | } | |
18 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
19 | ldraw::Object::~Object() |
3 | 20 | { |
21 | } | |
22 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
23 | bool ldraw::Object::hasColor() const |
3 | 24 | { |
25 | return false; | |
26 | } | |
27 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
28 | QVariant ldraw::Object::getProperty(Property id) const |
3 | 29 | { |
30 | Q_UNUSED(id); | |
31 | return {}; | |
32 | } | |
33 | ||
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
34 | void ldraw::Object::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) |
3 | 35 | { |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
36 | Q_UNUSED(result) |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
37 | Q_UNUSED(pair) |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
38 | } |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
39 | |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
40 | /** |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
41 | * @brief public interface to setProperty |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
42 | */ |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
43 | ldraw::Object::SetPropertyResult ldraw::Object::setProperty(const PropertyKeyValue& pair) |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
44 | { |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
45 | SetPropertyResult result; |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
46 | this->setProperty(&result, pair); |
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
47 | return result; |
3 | 48 | } |
49 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
50 | QBrush ldraw::Object::textRepresentationForeground() const |
6 | 51 | { |
52 | return {}; | |
53 | } | |
54 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
55 | QBrush ldraw::Object::textRepresentationBackground() const |
6 | 56 | { |
57 | return {}; | |
58 | } | |
59 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
60 | QFont ldraw::Object::textRepresentationFont() const |
6 | 61 | { |
62 | return {}; | |
63 | } | |
64 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
65 | void ldraw::Object::getPolygons(std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const |
21 | 66 | { |
67 | Q_UNUSED(polygons) | |
68 | Q_UNUSED(context) | |
69 | } | |
70 | ||
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
46
diff
changeset
|
71 | const glm::vec3& ldraw::Object::getPoint(int index) const |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
46
diff
changeset
|
72 | { |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
73 | Q_UNUSED(index); |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
46
diff
changeset
|
74 | throw BadPointIndex{}; |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
46
diff
changeset
|
75 | } |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
46
diff
changeset
|
76 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
77 | ldraw::ColoredObject::ColoredObject(const Color color_index) : |
13 | 78 | colorIndex{color_index} |
3 | 79 | { |
80 | } | |
81 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
82 | bool ldraw::ColoredObject::hasColor() const |
3 | 83 | { |
84 | return true; | |
85 | } | |
86 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
87 | QVariant ldraw::ColoredObject::getProperty(Property id) const |
3 | 88 | { |
89 | switch (id) | |
90 | { | |
91 | case Property::Color: | |
89 | 92 | return QVariant::fromValue<Color>(colorIndex); |
3 | 93 | default: |
13 | 94 | return Object::getProperty(id); |
3 | 95 | } |
96 | } | |
97 | ||
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
98 | void ldraw::ColoredObject::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) |
3 | 99 | { |
89 | 100 | LDRAW_OBJECT_HANDLE_SET_PROPERTY(Color, {colorIndex = value;}); |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
101 | Object::setProperty(result, pair); |
3 | 102 | } |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
103 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
104 | QString ldraw::Empty::textRepresentation() const |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
105 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
106 | return ""; |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
107 | } |