Fri, 07 Feb 2020 23:59:06 +0200
selection works now
6 | 1 | #include <QBrush> |
2 | #include <QFont> | |
14 | 3 | #include "object.h" |
3 | 4 | |
46 | 5 | static std::int32_t getIdForNewObject() |
6 | 6 | { |
46 | 7 | static std::int32_t id = 0; |
6 | 8 | id += 1; |
9 | return id; | |
10 | } | |
3 | 11 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
12 | ldraw::Object::Object() : |
6 | 13 | id {getIdForNewObject()} |
3 | 14 | { |
15 | } | |
16 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
17 | ldraw::Object::~Object() |
3 | 18 | { |
19 | } | |
20 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
21 | bool ldraw::Object::hasColor() const |
3 | 22 | { |
23 | return false; | |
24 | } | |
25 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
26 | QVariant ldraw::Object::getProperty(Property id) const |
3 | 27 | { |
28 | Q_UNUSED(id); | |
29 | return {}; | |
30 | } | |
31 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
32 | auto ldraw::Object::setProperty(Property id, const QVariant& value) |
3 | 33 | -> SetPropertyResult |
34 | { | |
35 | Q_UNUSED(id) | |
36 | Q_UNUSED(value) | |
37 | return SetPropertyResult::PropertyNotHandled; | |
38 | } | |
39 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
40 | QBrush ldraw::Object::textRepresentationForeground() const |
6 | 41 | { |
42 | return {}; | |
43 | } | |
44 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
45 | QBrush ldraw::Object::textRepresentationBackground() const |
6 | 46 | { |
47 | return {}; | |
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 | QFont ldraw::Object::textRepresentationFont() 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 | void ldraw::Object::getPolygons(std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const |
21 | 56 | { |
57 | Q_UNUSED(polygons) | |
58 | Q_UNUSED(context) | |
59 | } | |
60 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
61 | ldraw::ColoredObject::ColoredObject(const Color color_index) : |
13 | 62 | colorIndex{color_index} |
3 | 63 | { |
64 | } | |
65 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
66 | bool ldraw::ColoredObject::hasColor() const |
3 | 67 | { |
68 | return true; | |
69 | } | |
70 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
71 | QVariant ldraw::ColoredObject::getProperty(Property id) const |
3 | 72 | { |
73 | switch (id) | |
74 | { | |
75 | case Property::Color: | |
13 | 76 | return colorIndex.index; |
3 | 77 | default: |
13 | 78 | return Object::getProperty(id); |
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 | auto ldraw::ColoredObject::setProperty(Property id, const QVariant& value) |
3 | 83 | -> SetPropertyResult |
84 | { | |
85 | switch (id) | |
86 | { | |
87 | case Property::Color: | |
88 | { | |
89 | bool ok; | |
90 | const int value_int = value.toInt(&ok); | |
91 | if (ok) | |
92 | { | |
13 | 93 | colorIndex.index = value_int; |
3 | 94 | return SetPropertyResult::Success; |
95 | } | |
96 | else | |
97 | { | |
98 | return SetPropertyResult::InvalidValue; | |
99 | } | |
100 | } | |
101 | default: | |
13 | 102 | return Object::setProperty(id, value); |
3 | 103 | } |
104 | } | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
105 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
106 | QString ldraw::Empty::textRepresentation() const |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
107 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
108 | return ""; |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
109 | } |