Sun, 26 Jan 2020 01:06:27 +0200
fix default angle
6 | 1 | #include <QBrush> |
2 | #include <QFont> | |
14 | 3 | #include "object.h" |
3 | 4 | |
6 | 5 | static unsigned int getIdForNewObject() |
6 | { | |
7 | static unsigned int id = 0; | |
8 | id += 1; | |
9 | return id; | |
10 | } | |
3 | 11 | |
13 | 12 | linetypes::Object::Object() : |
6 | 13 | id {getIdForNewObject()} |
3 | 14 | { |
15 | } | |
16 | ||
13 | 17 | linetypes::Object::~Object() |
3 | 18 | { |
19 | } | |
20 | ||
13 | 21 | bool linetypes::Object::hasColor() const |
3 | 22 | { |
23 | return false; | |
24 | } | |
25 | ||
13 | 26 | QVariant linetypes::Object::getProperty(Property id) const |
3 | 27 | { |
28 | Q_UNUSED(id); | |
29 | return {}; | |
30 | } | |
31 | ||
13 | 32 | auto linetypes::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 | ||
13 | 40 | QBrush linetypes::Object::textRepresentationForeground() const |
6 | 41 | { |
42 | return {}; | |
43 | } | |
44 | ||
13 | 45 | QBrush linetypes::Object::textRepresentationBackground() const |
6 | 46 | { |
47 | return {}; | |
48 | } | |
49 | ||
13 | 50 | QFont linetypes::Object::textRepresentationFont() const |
6 | 51 | { |
52 | return {}; | |
53 | } | |
54 | ||
21 | 55 | void linetypes::Object::getPolygons(std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const |
56 | { | |
57 | Q_UNUSED(polygons) | |
58 | Q_UNUSED(context) | |
59 | } | |
60 | ||
13 | 61 | linetypes::ColoredObject::ColoredObject(const Color color_index) : |
62 | colorIndex{color_index} | |
3 | 63 | { |
64 | } | |
65 | ||
13 | 66 | bool linetypes::ColoredObject::hasColor() const |
3 | 67 | { |
68 | return true; | |
69 | } | |
70 | ||
13 | 71 | QVariant linetypes::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 | ||
13 | 82 | auto linetypes::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 | |
13 | 106 | QString linetypes::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 | } |