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