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