Sun, 03 Nov 2019 17:57:21 +0200
added dependency loading
| 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 | ||
| 9 | namespace modelobjects | |
| 10 | { | |
| 11 | enum class Property; | |
| 12 | class BaseObject; | |
| 13 | class ColoredBaseObject; | |
|
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
14 | class Empty; |
| 3 | 15 | } |
| 16 | ||
| 17 | enum class modelobjects::Property | |
| 18 | { | |
| 19 | Color, | |
| 20 | Text, | |
| 21 | Point1, | |
| 22 | Point2, | |
| 23 | Point3, | |
| 24 | Point4, | |
| 25 | ControlPoint1, | |
| 26 | ControlPoint2, | |
| 27 | Position, | |
| 28 | Transformation, | |
| 29 | ReferenceName, | |
| 30 | IsInverted, | |
|
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
31 | ErrorMessage |
| 3 | 32 | }; |
| 33 | ||
| 34 | class modelobjects::BaseObject | |
| 35 | { | |
| 36 | public: | |
| 37 | enum class SetPropertyResult | |
| 38 | { | |
| 39 | Success = 0, | |
| 40 | PropertyNotHandled, | |
| 41 | InvalidValue | |
| 42 | }; | |
| 43 | BaseObject(); | |
| 44 | BaseObject(const BaseObject&) = delete; | |
| 45 | virtual ~BaseObject(); | |
| 6 | 46 | const unsigned int id; |
| 3 | 47 | //virtual void toString(QTextStream &out) = 0; |
| 48 | virtual bool hasColor() const; | |
| 49 | virtual QVariant getProperty(Property id) const; | |
| 50 | virtual SetPropertyResult setProperty(Property id, const QVariant& value); | |
| 6 | 51 | virtual QString textRepresentation() const = 0; |
| 52 | virtual QBrush textRepresentationForeground() const; | |
| 53 | virtual QBrush textRepresentationBackground() const; | |
| 54 | virtual QFont textRepresentationFont() const; | |
| 3 | 55 | }; |
| 56 | ||
| 57 | class modelobjects::ColoredBaseObject : public BaseObject | |
| 58 | { | |
| 59 | public: | |
| 60 | ColoredBaseObject(const Color color_index = colors::main); | |
| 61 | bool hasColor() const override final; | |
| 62 | QVariant getProperty(Property id) const override; | |
| 63 | SetPropertyResult setProperty(Property id, const QVariant& value) override; | |
| 64 | private: | |
| 65 | Color color_index = colors::main; | |
| 66 | }; | |
| 6 | 67 | |
|
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
68 | class modelobjects::Empty : public BaseObject |
|
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
69 | { |
|
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
70 | QString textRepresentation() const override; |
|
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
71 | }; |
|
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
72 | |
| 6 | 73 | namespace modelobjects |
| 74 | { | |
| 75 | using Id = std::remove_const_t<decltype(BaseObject::id)>; | |
| 76 | } |