Fri, 08 Nov 2019 19:05:07 +0200
things
3 | 1 | #pragma once |
2 | #include <QPointF> | |
3 | #include <QString> | |
4 | #include <QStringView> | |
5 | #include "main.h" | |
6 | #include "colors.h" | |
7 | #include "vertex.h" | |
8 | ||
13 | 9 | namespace linetypes |
3 | 10 | { |
11 | enum class Property; | |
13 | 12 | class Object; |
13 | class ColoredObject; | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
14 | class Empty; |
3 | 15 | } |
16 | ||
13 | 17 | /** |
18 | * @brief Different properties that can be queried with getProperty | |
19 | */ | |
20 | enum class linetypes::Property | |
3 | 21 | { |
13 | 22 | Color, // Color of the object |
23 | Text, // Text contained in a comment | |
24 | Point1, // First vertex in a polygon or edge line | |
25 | Point2, // Second vertex in a polygon or edge line | |
26 | Point3, // Third vertex in a polygon | |
27 | Point4, // Fourth vertex in a quadrilateral | |
28 | ControlPoint1, // First control point in a conditional edge line | |
29 | ControlPoint2, // Second control point in a conditional edge line | |
30 | Position, // Position of a subfile reference | |
31 | Transformation, // Transformation matrix of a subfile reference | |
32 | ReferenceName, // Subfile reference name | |
33 | IsInverted, // Whether or not the object has been inverted with BFC INVERTNEXT | |
34 | ErrorMessage // For error lines, why parsing failed | |
3 | 35 | }; |
36 | ||
13 | 37 | class linetypes::Object |
3 | 38 | { |
39 | public: | |
40 | enum class SetPropertyResult | |
41 | { | |
42 | Success = 0, | |
43 | PropertyNotHandled, | |
44 | InvalidValue | |
45 | }; | |
13 | 46 | Object(); |
47 | Object(const Object&) = delete; | |
48 | virtual ~Object(); | |
6 | 49 | const unsigned int id; |
3 | 50 | //virtual void toString(QTextStream &out) = 0; |
51 | virtual bool hasColor() const; | |
52 | virtual QVariant getProperty(Property id) const; | |
53 | virtual SetPropertyResult setProperty(Property id, const QVariant& value); | |
6 | 54 | virtual QString textRepresentation() const = 0; |
55 | virtual QBrush textRepresentationForeground() const; | |
56 | virtual QBrush textRepresentationBackground() const; | |
57 | virtual QFont textRepresentationFont() const; | |
3 | 58 | }; |
59 | ||
13 | 60 | class linetypes::ColoredObject : public Object |
3 | 61 | { |
62 | public: | |
13 | 63 | ColoredObject(const Color colorIndex = colors::main); |
3 | 64 | bool hasColor() const override final; |
65 | QVariant getProperty(Property id) const override; | |
66 | SetPropertyResult setProperty(Property id, const QVariant& value) override; | |
67 | private: | |
13 | 68 | Color colorIndex = colors::main; |
3 | 69 | }; |
6 | 70 | |
13 | 71 | /** |
72 | * @brief Represents an empty line. | |
73 | */ | |
74 | class linetypes::Empty : public Object | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
75 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
76 | QString textRepresentation() const override; |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
77 | }; |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
78 | |
13 | 79 | namespace linetypes |
6 | 80 | { |
13 | 81 | using Id = std::decay_t<decltype(Object::id)>; |
6 | 82 | } |