38 Transformation, // 4x4 transformation matrix of a subfile reference |
39 Transformation, // 4x4 transformation matrix of a subfile reference |
39 ReferenceName, // Subfile reference name |
40 ReferenceName, // Subfile reference name |
40 IsInverted, // Whether or not the object has been inverted with BFC INVERTNEXT |
41 IsInverted, // Whether or not the object has been inverted with BFC INVERTNEXT |
41 ErrorMessage // For error lines, why parsing failed |
42 ErrorMessage // For error lines, why parsing failed |
42 }; |
43 }; |
|
44 |
|
45 // Mapping of properties to types |
|
46 #define LDFORGE_DEFINE_PROPERTY_TYPE(PROPERTY, TYPE) \ |
|
47 namespace ldraw { \ |
|
48 template<> struct PropertyType<ldraw::Property::PROPERTY> { using type = TYPE; }; \ |
|
49 } |
|
50 |
|
51 namespace ldraw |
|
52 { |
|
53 template<ldraw::Property property> |
|
54 struct PropertyType |
|
55 { |
|
56 }; |
|
57 |
|
58 template<ldraw::Property property> |
|
59 using PropertyType_t = typename PropertyType<property>::type; |
|
60 } |
|
61 |
|
62 LDFORGE_DEFINE_PROPERTY_TYPE(Color, int) |
|
63 LDFORGE_DEFINE_PROPERTY_TYPE(Text, QString) |
|
64 LDFORGE_DEFINE_PROPERTY_TYPE(Point1, glm::vec3) |
|
65 LDFORGE_DEFINE_PROPERTY_TYPE(Point2, glm::vec3) |
|
66 LDFORGE_DEFINE_PROPERTY_TYPE(Point3, glm::vec3) |
|
67 LDFORGE_DEFINE_PROPERTY_TYPE(Point4, glm::vec3) |
|
68 LDFORGE_DEFINE_PROPERTY_TYPE(ControlPoint1, glm::vec3) |
|
69 LDFORGE_DEFINE_PROPERTY_TYPE(ControlPoint2, glm::vec3) |
|
70 LDFORGE_DEFINE_PROPERTY_TYPE(Transformation, glm::mat4) |
|
71 LDFORGE_DEFINE_PROPERTY_TYPE(ReferenceName, QString) |
|
72 LDFORGE_DEFINE_PROPERTY_TYPE(IsInverted, bool) |
|
73 LDFORGE_DEFINE_PROPERTY_TYPE(ErrorMessage, QString) |
43 |
74 |
44 class ldraw::Object |
75 class ldraw::Object |
45 { |
76 { |
46 public: |
77 public: |
47 enum class SetPropertyResult |
78 enum class SetPropertyResult |
71 public: |
102 public: |
72 ColoredObject(const Color colorIndex = ldraw::mainColor); |
103 ColoredObject(const Color colorIndex = ldraw::mainColor); |
73 bool hasColor() const override final; |
104 bool hasColor() const override final; |
74 QVariant getProperty(Property id) const override; |
105 QVariant getProperty(Property id) const override; |
75 SetPropertyResult setProperty(Property id, const QVariant& value) override; |
106 SetPropertyResult setProperty(Property id, const QVariant& value) override; |
76 protected: |
|
77 Color colorIndex = ldraw::mainColor; |
107 Color colorIndex = ldraw::mainColor; |
78 }; |
108 }; |
79 |
109 |
80 /** |
110 /** |
81 * @brief Represents an empty line. |
111 * @brief Represents an empty line. |