src/ldObject.h

Tue, 14 Feb 2017 12:43:10 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 14 Feb 2017 12:43:10 +0200
changeset 1137
2b6488d11305
parent 1135
8e0691be0b6f
child 1138
0dfdef50b0ee
permissions
-rw-r--r--

Inlined away the LDOBJ macros in ldobject.h.

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1072
9ce9496427f2 Happy new year 2017!
Teemu Piippo <teemu@hecknology.net>
parents: 1045
diff changeset
3 * Copyright (C) 2013 - 2017 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
768
29e6c5552388 - initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 767
diff changeset
20 #include <type_traits>
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "main.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "basics.h"
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
23 #include "glShared.h"
795
195fa1fff9c3 - changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
24 #include "colors.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
26 class Model;
1011
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1006
diff changeset
27 class LDSubfileReference;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 class LDDocument;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
29 class LDBfc;
776
624131d0163d - selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents: 771
diff changeset
30
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
31 //
786
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
32 // Object type codes.
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
33 //
786
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
34 enum LDObjectType
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
35 {
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
36 SubfileReference, // Object represents a sub-file reference
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
37 Quad, // Object represents a quadrilateral
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
38 Triangle, // Object represents a triangle
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
39 Line, // Object represents a line
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
40 CondLine, // Object represents a conditional line
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
41 Bfc, // Object represents a BFC statement
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
42 Comment, // Object represents a comment
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
43 Error, // Object is the result of failed parsing
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
44 Empty, // Object represents an empty line
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
45 BezierCurve, // Object represents a Bézier curve
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
46 _End
786
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
47 };
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
48
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
49 MAKE_ITERABLE_ENUM(LDObjectType)
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
50
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
51 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 // LDObject
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 // Base class object for all object types. Each LDObject represents a single line
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 // in the LDraw code file. The virtual method getType returns an enumerator
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // which is a token of the object's type. The object can be casted into
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 // sub-classes based on this enumerator.
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
58 //
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
59 class LDObject : public QObject
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 {
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
61 Q_OBJECT
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
62
786
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
63 public:
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
64 virtual QString asText() const = 0; // This object as LDraw code
1079
67c6e5d32e68 More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents: 1078
diff changeset
65 LDColor color() const;
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
66 virtual LDColor defaultColor() const; // What color does the object default to?
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
67 Model* model() const;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
68 LDPolygon* getPolygon();
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1028
diff changeset
69 virtual void getVertices (QSet<Vertex>& verts) const;
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
70 virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject)
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
71 qint32 id() const;
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
72 virtual void invert(); // Inverts this object (winding is reversed)
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
73 virtual bool isColored() const;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
74 bool isHidden() const;
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
75 virtual bool isScemantic() const; // Does this object have meaning in the part model?
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
76 bool isSelected() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
77 int lineNumber() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
78 void move (Vertex vect);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
79 LDObject* next() const;
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
80 virtual int numVertices() const;
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
81 virtual QString objectListText() const;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
82 LDObject* previous() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
83 bool previousIsInvertnext (LDBfc*& ptr);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
84 QColor randomColor() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
85 void setColor (LDColor color);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
86 void setHidden (bool value);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
87 void setVertex (int i, const Vertex& vert);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
88 void swap (LDObject* other);
1015
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
89 virtual int triangleCount() const;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
90 virtual LDObjectType type() const = 0;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
91 virtual QString typeName() const = 0;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
92 const Vertex& vertex (int i) const;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93
1135
8e0691be0b6f Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
94 static LDObject* fromID(qint32 id);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
96 signals:
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
97 void codeChanged(QString before, QString after);
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
98
956
2af18ba2665f Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
99 protected:
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
100 friend class Model;
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
101 LDObject (Model* model = nullptr);
956
2af18ba2665f Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
102 virtual ~LDObject();
1082
1738bdaf36d6 The "all objects have valid models" invariant seems to be holding up now. At least basic drawing works again.
Teemu Piippo <teemu@hecknology.net>
parents: 1081
diff changeset
103 void setDocument(Model* model);
956
2af18ba2665f Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
104
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
105 template<typename T>
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
106 void changeProperty(T* property, const T& value);
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
107
786
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 785
diff changeset
108 private:
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
109 bool m_isHidden;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
110 bool m_isSelected;
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
111 Model* _model;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
112 qint32 m_id;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
113 LDColor m_color;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
114 QColor m_randomColor;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
115 Vertex m_coords[4];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 // Common code for objects with matrices. This class is multiple-derived in
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 // and thus not used directly other than as a common storage point for matrices
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 // and vertices.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 // In 0.1-alpha, there was a separate 'radial' type which had a position and
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 // matrix as well. Even though right now only LDSubfile uses this, I'm keeping
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 // this class distinct in case I get new extension ideas. :)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 //
843
9ac9060877cc - moved LDMatrixObject to be an abstract class deriving from LDObject. LDSubfile only inherits from LDMatrixObject.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 835
diff changeset
127 class LDMatrixObject : public LDObject
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 {
843
9ac9060877cc - moved LDMatrixObject to be an abstract class deriving from LDObject. LDSubfile only inherits from LDMatrixObject.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 835
diff changeset
129 Vertex m_position;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
131 public:
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
132 const Vertex& position() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
133 void setCoordinate (const Axis ax, double value);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
134 void setPosition (const Vertex& a);
1045
f726f8f49c7e Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
135 void setTransformationMatrix (const Matrix& value);
f726f8f49c7e Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
136 const Matrix& transformationMatrix() const;
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
137
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
138 protected:
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
139 LDMatrixObject (Model* model = nullptr);
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
140 LDMatrixObject (const Matrix& transformationMatrix, const Vertex& pos, Model* model = nullptr);
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
141
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
142 private:
1045
f726f8f49c7e Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
143 Matrix m_transformationMatrix;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
146 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 // Represents a line in the LDraw file that could not be properly parsed. It is
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 // represented by a (!) ERROR in the code view. It exists for the purpose of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 // allowing garbage lines be debugged and corrected within LDForge.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 class LDError : public LDObject
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
154 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
155 static constexpr LDObjectType SubclassType = LDObjectType::Error;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
157 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
158 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
159 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
160 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
161
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
162 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
163 virtual void invert() override;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
164 QString reason() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
165 QString contents() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
166 QString fileReferenced() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
167 void setFileReferenced (QString value);
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
168 QString objectListText() const override;
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
169 bool isColored() const override { return false; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
170 QString typeName() const override { return "error"; }
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
171
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
172 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
173 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
174 LDError (Model* model);
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
175 LDError (QString contents, QString reason, Model* model = nullptr);
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
176
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
177 private:
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
178 QString m_fileReferenced; // If this error was caused by inability to open a file, what file was that?
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
179 QString m_contents; // The LDraw code that was being parsed
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
180 QString m_reason;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
183 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 //
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
185 // Represents a 0 BFC statement in the LDraw code.
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 //
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
187 enum class BfcStatement
847
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
188 {
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
189 CertifyCCW,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
190 CCW,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
191 CertifyCW,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
192 CW,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
193 NoCertify,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
194 InvertNext,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
195 Clip,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
196 ClipCCW,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
197 ClipCW,
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
198 NoClip,
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
199 _End
1034
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
200 };
847
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
201
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
202 MAKE_ITERABLE_ENUM(BfcStatement)
847
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
203
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
204 class LDBfc : public LDObject
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
206 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
207 static constexpr LDObjectType SubclassType = LDObjectType::Bfc;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
208
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
209 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
210 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
211 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
212 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
213
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
214 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
215 virtual void invert() override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
216 protected:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
217 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
218 LDBfc (Model* model);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
220 public:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
221 bool isScemantic() const override { return statement() == BfcStatement::InvertNext; }
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
222 QString objectListText() const override;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
223 BfcStatement statement() const;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
224 void setStatement (BfcStatement value);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
225 QString statementToString() const;
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
226 bool isColored() const override { return false; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
227 QString typeName() const override { return "bfc"; }
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
228
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
229 static QString statementToString (BfcStatement statement);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
230
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
231 protected:
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
232 LDBfc (const BfcStatement type, Model* model = nullptr);
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
233
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
234 private:
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
235 BfcStatement m_statement;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
238 //
1011
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1006
diff changeset
239 // LDReference
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 // Represents a single code-1 subfile reference.
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
242 //
1011
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1006
diff changeset
243 class LDSubfileReference : public LDMatrixObject
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
245 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
246 static constexpr LDObjectType SubclassType = LDObjectType::SubfileReference;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
248 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
249 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
250 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
251 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
252
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
253 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
254 virtual void invert() override;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
255 LDDocument* fileInfo() const;
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1028
diff changeset
256 virtual void getVertices (QSet<Vertex>& verts) const override;
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
257 void inlineContents(Model& model, bool deep, bool render);
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
258 QList<LDPolygon> inlinePolygons();
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
259 QString objectListText() const override;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
260 void setFileInfo (LDDocument* fileInfo);
1015
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
261 int triangleCount() const override;
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
262 bool hasMatrix() const override { return true; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
263 QString typeName() const override { return "subfilereference"; }
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
264
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
265 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
266 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
267 LDSubfileReference (Model* model);
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
268 LDSubfileReference(LDDocument* reference, const Matrix& transformationMatrix, const Vertex& position, Model* model = nullptr);
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
269
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
270 private:
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
271 LDDocument* m_fileInfo;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
274 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 // LDLine
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 //
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
277 // Represents a single code-2 line in the LDraw code file.
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
278 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 class LDLine : public LDObject
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
281 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
282 static constexpr LDObjectType SubclassType = LDObjectType::Line;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
283
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
284 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
285 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
286 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
287 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
288
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
289 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
290 virtual void invert() override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
291 int numVertices() const override { return 2; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
292 LDColor defaultColor() const override { return EdgeColor; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
293 QString typeName() const override { return "line"; }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
295 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
296 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
297 LDLine (Model* model);
1077
952d6b3e7d11 Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents: 1076
diff changeset
298 LDLine (Vertex v1, Vertex v2, Model* model = nullptr);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
301 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 // LDCondLine
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 //
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
304 // Represents a single code-5 conditional line.
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
305 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 class LDCondLine : public LDLine
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
308 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
309 static constexpr LDObjectType SubclassType = LDObjectType::CondLine;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
311 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
312 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
313 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
314 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
315
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
316 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
317 virtual void invert() override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
318 int numVertices() const override { return 4; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
319 LDColor defaultColor() const override { return EdgeColor; }
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
320 LDLine* becomeEdgeLine();
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
321 QString typeName() const override { return "condline"; }
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
322
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
323 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
324 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
325 LDCondLine (Model* model);
1077
952d6b3e7d11 Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents: 1076
diff changeset
326 LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, Model* model = nullptr);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
329 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 // LDTriangle
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 // Represents a single code-3 triangle in the LDraw code file. Vertices v0, v1
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 // and v2 contain the end-points of this triangle. dColor is the color the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334 // triangle is colored with.
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
335 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 class LDTriangle : public LDObject
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
338 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
339 static constexpr LDObjectType SubclassType = LDObjectType::Triangle;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
341 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
342 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
343 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
344 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
345
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
346 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
347 virtual void invert() override;
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
348 int triangleCount() const override;
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
349 int numVertices() const override { return 3; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
350 QString typeName() const override { return "triangle"; }
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
351
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
352 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
353 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
354 LDTriangle (Model* model);
1074
a62f810ca26f Made the quad→triangles use emplacement. However, now it crashes because of problems in the underlying system (the LDObject constructor shouldn't do anything in regard to the model!)
Teemu Piippo <teemu@hecknology.net>
parents: 1073
diff changeset
355 LDTriangle (Vertex const& v1, Vertex const& v2, Vertex const& v3, Model* model = nullptr);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
358 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 // LDQuad
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 // Represents a single code-4 quadrilateral. v0, v1, v2 and v3 are the end points
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 // of the quad, dColor is the color used for the quad.
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
363 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364 class LDQuad : public LDObject
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
366 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
367 static constexpr LDObjectType SubclassType = LDObjectType::Quad;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
369 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
370 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
371 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
372 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
373
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
374 QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
375 void invert() override;
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
376 int triangleCount() const override;
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
377 int numVertices() const override { return 4; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
378 QString typeName() const override { return "quad"; }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
380 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
381 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
382 LDQuad (Model* model);
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
383 LDQuad (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, Model* model = nullptr);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385
1000
c064cc048f14 Begin work on Bézier curve support. They can be drawn but don't render in 3D and they load as comments.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 995
diff changeset
386 class LDBezierCurve : public LDObject
c064cc048f14 Begin work on Bézier curve support. They can be drawn but don't render in 3D and they load as comments.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 995
diff changeset
387 {
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
388 public:
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
389 static constexpr LDObjectType SubclassType = LDObjectType::BezierCurve;
1000
c064cc048f14 Begin work on Bézier curve support. They can be drawn but don't render in 3D and they load as comments.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 995
diff changeset
390
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
391 virtual LDObjectType type() const override
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
392 {
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
393 return SubclassType;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
394 }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
395
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
396 virtual QString asText() const override;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
397 virtual void invert() override;
1002
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1000
diff changeset
398 Vertex pointAt (qreal t) const;
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
399 void rasterize(Model& model, int segments);
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1015
diff changeset
400 QVector<LDPolygon> rasterizePolygons (int segments);
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
401 int numVertices() const override { return 4; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
402 LDColor defaultColor() const override { return EdgeColor; }
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
403 QString typeName() const override { return "beziercurve"; }
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
404
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
405 protected:
1137
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
406 friend class Model;
2b6488d11305 Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
407 LDBezierCurve (Model* model);
1081
47cde4087cc5 Made all LDObject constructors protected. Emplacement is now the only way to create objects.
Teemu Piippo <teemu@hecknology.net>
parents: 1080
diff changeset
408 LDBezierCurve (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, Model* model = nullptr);
1000
c064cc048f14 Begin work on Bézier curve support. They can be drawn but don't render in 3D and they load as comments.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 995
diff changeset
409 };
c064cc048f14 Begin work on Bézier curve support. They can be drawn but don't render in 3D and they load as comments.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 995
diff changeset
410
861
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
411 enum
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
412 {
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
413 LowResolution = 16,
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
414 HighResolution = 48
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
415 };
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
416
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
417 /*
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
418 * Changes a property in a manner that emits the appropriate signal to notify that the object changed.
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
419 */
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
420 template<typename T>
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
421 void LDObject::changeProperty(T* property, const T& value)
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
422 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
423 if (*property != value)
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
424 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
425 QString before = asText();
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
426 *property = value;
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
427 emit codeChanged(before, asText());
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
428 }
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1100
diff changeset
429 }

mercurial