| 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 |
|
| 9 namespace linetypes |
|
| 10 { |
|
| 11 enum class Property; |
|
| 12 class Object; |
|
| 13 class ColoredObject; |
|
| 14 class Empty; |
|
| 15 } |
|
| 16 |
|
| 17 /** |
|
| 18 * @brief Different properties that can be queried with getProperty |
|
| 19 */ |
|
| 20 enum class linetypes::Property |
|
| 21 { |
|
| 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 |
|
| 35 }; |
|
| 36 |
|
| 37 class linetypes::Object |
|
| 38 { |
|
| 39 public: |
|
| 40 enum class SetPropertyResult |
|
| 41 { |
|
| 42 Success = 0, |
|
| 43 PropertyNotHandled, |
|
| 44 InvalidValue |
|
| 45 }; |
|
| 46 Object(); |
|
| 47 Object(const Object&) = delete; |
|
| 48 virtual ~Object(); |
|
| 49 const unsigned int id; |
|
| 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); |
|
| 54 virtual QString textRepresentation() const = 0; |
|
| 55 virtual QBrush textRepresentationForeground() const; |
|
| 56 virtual QBrush textRepresentationBackground() const; |
|
| 57 virtual QFont textRepresentationFont() const; |
|
| 58 }; |
|
| 59 |
|
| 60 class linetypes::ColoredObject : public Object |
|
| 61 { |
|
| 62 public: |
|
| 63 ColoredObject(const Color colorIndex = colors::main); |
|
| 64 bool hasColor() const override final; |
|
| 65 QVariant getProperty(Property id) const override; |
|
| 66 SetPropertyResult setProperty(Property id, const QVariant& value) override; |
|
| 67 private: |
|
| 68 Color colorIndex = colors::main; |
|
| 69 }; |
|
| 70 |
|
| 71 /** |
|
| 72 * @brief Represents an empty line. |
|
| 73 */ |
|
| 74 class linetypes::Empty : public Object |
|
| 75 { |
|
| 76 QString textRepresentation() const override; |
|
| 77 }; |
|
| 78 |
|
| 79 namespace linetypes |
|
| 80 { |
|
| 81 using Id = std::decay_t<decltype(Object::id)>; |
|
| 82 } |
|