27 class LDDocument; |
27 class LDDocument; |
28 |
28 |
29 /* |
29 /* |
30 * Object type codes. |
30 * Object type codes. |
31 */ |
31 */ |
32 enum LDObjectType |
32 enum class LDObjectType |
33 { |
33 { |
34 SubfileReference, // Object represents a sub-file reference |
34 SubfileReference, // Object represents a sub-file reference |
35 Quadrilateral, // Object represents a quadrilateral |
35 Quadrilateral, // Object represents a quadrilateral |
36 Triangle, // Object represents a triangle |
36 Triangle, // Object represents a triangle |
37 EdgeLine, // Object represents a line |
37 EdgeLine, // Object represents a line |
43 BezierCurve, // Object represents a Bézier curve |
43 BezierCurve, // Object represents a Bézier curve |
44 _End |
44 _End |
45 }; |
45 }; |
46 |
46 |
47 MAKE_ITERABLE_ENUM(LDObjectType) |
47 MAKE_ITERABLE_ENUM(LDObjectType) |
|
48 |
|
49 inline int qHash(LDObjectType type) |
|
50 { |
|
51 return qHash(static_cast<int>(type)); |
|
52 } |
48 |
53 |
49 /* |
54 /* |
50 * Represents one line of code in an LDraw model file. |
55 * Represents one line of code in an LDraw model file. |
51 */ |
56 */ |
52 class LDObject : public QObject |
57 class LDObject : public QObject |
251 private: |
256 private: |
252 LDDocument* m_fileInfo; |
257 LDDocument* m_fileInfo; |
253 }; |
258 }; |
254 |
259 |
255 /* |
260 /* |
256 * Represents a single code-3 triangle in the LDraw code file. |
|
257 */ |
|
258 class LDTriangle : public LDObject |
|
259 { |
|
260 public: |
|
261 static constexpr LDObjectType SubclassType = LDObjectType::Triangle; |
|
262 |
|
263 virtual LDObjectType type() const override |
|
264 { |
|
265 return SubclassType; |
|
266 } |
|
267 |
|
268 virtual QString asText() const override; |
|
269 virtual void invert() override; |
|
270 int triangleCount() const override; |
|
271 int numVertices() const override { return 3; } |
|
272 QString typeName() const override { return "triangle"; } |
|
273 |
|
274 protected: |
|
275 friend class Model; |
|
276 LDTriangle (Model* model); |
|
277 LDTriangle (Vertex const& v1, Vertex const& v2, Vertex const& v3, Model* model = nullptr); |
|
278 }; |
|
279 |
|
280 /* |
|
281 * Represents a single code-4 quadrilateral. |
261 * Represents a single code-4 quadrilateral. |
282 */ |
262 */ |
283 class LDQuadrilateral : public LDObject |
263 class LDQuadrilateral : public LDObject |
284 { |
264 { |
285 public: |
265 public: |