Mon, 05 Mar 2018 22:42:54 +0200
Finally removed the cancer that is the LDObject::model pointer
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 | 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> |
1147
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1141
diff
changeset
|
21 | #include "../main.h" |
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1141
diff
changeset
|
22 | #include "../basics.h" |
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1141
diff
changeset
|
23 | #include "../glShared.h" |
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1141
diff
changeset
|
24 | #include "../colors.h" |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
25 | #include "../serializer.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
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
|
27 | class Model; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class LDDocument; |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
29 | class DocumentManager; |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
771
diff
changeset
|
30 | |
1138 | 31 | /* |
32 | * Object type codes. | |
33 | */ | |
1148
96cb15a7611f
Moved LDTriangle into its own source pair.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
34 | enum class LDObjectType |
786
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 |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1138
diff
changeset
|
37 | Quadrilateral, // Object represents a quadrilateral |
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
|
38 | Triangle, // Object represents a triangle |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1138
diff
changeset
|
39 | EdgeLine, // Object represents a line |
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1138
diff
changeset
|
40 | ConditionalEdge, // Object represents a conditional line |
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
|
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 | |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
49 | Q_DECLARE_METATYPE(LDObjectType) |
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
|
50 | 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
|
51 | |
1148
96cb15a7611f
Moved LDTriangle into its own source pair.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
52 | inline int qHash(LDObjectType type) |
96cb15a7611f
Moved LDTriangle into its own source pair.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
53 | { |
96cb15a7611f
Moved LDTriangle into its own source pair.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
54 | return qHash(static_cast<int>(type)); |
96cb15a7611f
Moved LDTriangle into its own source pair.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
55 | } |
96cb15a7611f
Moved LDTriangle into its own source pair.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
56 | |
1138 | 57 | /* |
58 | * Represents one line of code in an LDraw model file. | |
59 | */ | |
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
|
60 | class LDObject : public QObject |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | { |
1138 | 62 | Q_OBJECT |
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
|
63 | |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
785
diff
changeset
|
64 | public: |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
65 | LDObject(); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
66 | virtual ~LDObject(); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
67 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
68 | virtual QString asText() const = 0; // This object as LDraw code |
1138 | 69 | LDColor color() const; |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
70 | virtual LDColor defaultColor() const; // What color does the object default to? |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
71 | LDPolygon* getPolygon(); |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
72 | virtual void getVertices (DocumentManager *context, 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
|
73 | 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
|
74 | qint32 id() 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 isColored() const; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
76 | bool isHidden() const; |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
77 | 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
|
78 | void move (Vertex vect); |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
79 | virtual int numVertices() const; |
1251
e75cc5bff076
Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents:
1244
diff
changeset
|
80 | virtual int numPolygonVertices() 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 | QColor randomColor() const; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
83 | void setColor (LDColor color); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
84 | void setHidden (bool value); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
85 | void setVertex (int i, const Vertex& vert); |
1236
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1149
diff
changeset
|
86 | bool isInverted() const; |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1149
diff
changeset
|
87 | void setInverted(bool value); |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
88 | virtual int triangleCount(DocumentManager* context) const; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
89 | virtual LDObjectType type() const = 0; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
90 | virtual QString typeName() const = 0; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
91 | const Vertex& vertex (int i) const; |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
92 | virtual void serialize(class Serializer& serializer); |
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); |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
95 | static LDObject* newFromType(LDObjectType type); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | |
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
|
97 | signals: |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
98 | void codeChanged(const LDObjectState& before, const LDObjectState& 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
|
99 | |
956
2af18ba2665f
Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
100 | protected: |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
101 | template<typename T> |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
102 | 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
|
103 | |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
785
diff
changeset
|
104 | private: |
1236
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1149
diff
changeset
|
105 | bool m_hasInvertNext = false; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
106 | bool m_isHidden; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
107 | qint32 m_id; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
108 | LDColor m_color; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
109 | QColor m_randomColor; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
110 | Vertex m_coords[4]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | |
1244 | 113 | Q_DECLARE_METATYPE(LDObject*) |
114 | ||
1138 | 115 | /* |
116 | * Base class for objects with matrices. | |
117 | */ | |
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
|
118 | class LDMatrixObject : public LDObject |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
120 | public: |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
121 | LDMatrixObject() = default; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
122 | LDMatrixObject(const Matrix& transformationMatrix, const Vertex& pos); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
124 | const Vertex& position() const; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
125 | void setCoordinate (const Axis ax, double value); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
126 | void setPosition (const Vertex& a); |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
127 | void setTransformationMatrix (const Matrix& value); |
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
128 | const Matrix& transformationMatrix() const; |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
129 | void serialize(class Serializer& serializer) 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
|
130 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
131 | private: |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
132 | Vertex m_position; |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
133 | Matrix m_transformationMatrix; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | |
1138 | 136 | /* |
137 | * Represents a line in the LDraw file that could not be properly parsed. | |
138 | */ | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | class LDError : public LDObject |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | { |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
141 | public: |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
142 | LDError() = default; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
143 | LDError(QString contents, QString reason); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
145 | virtual LDObjectType type() const override |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
146 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
147 | return LDObjectType::Error; |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
148 | } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
149 | |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
150 | virtual QString asText() const override; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
151 | QString reason() const; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
152 | QString contents() const; |
1084
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
153 | QString objectListText() const override; |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
154 | bool isColored() const override { return false; } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
155 | QString typeName() const override { return "error"; } |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
156 | void serialize(class Serializer& serializer) 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
|
157 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
158 | private: |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
159 | QString m_contents; // The LDraw code that was being parsed |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
160 | QString m_reason; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
1138 | 163 | /* |
164 | * Represents a 0 BFC statement in the LDraw code. | |
165 | */ | |
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
|
166 | enum class BfcStatement |
847 | 167 | { |
168 | CertifyCCW, | |
169 | CCW, | |
170 | CertifyCW, | |
171 | CW, | |
172 | NoCertify, | |
173 | InvertNext, | |
174 | Clip, | |
175 | ClipCCW, | |
176 | ClipCW, | |
177 | 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
|
178 | _End |
1034 | 179 | }; |
847 | 180 | |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
181 | Q_DECLARE_METATYPE(BfcStatement) |
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
|
182 | MAKE_ITERABLE_ENUM(BfcStatement) |
847 | 183 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
184 | class LDBfc : public LDObject |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
186 | public: |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
187 | static const LDObjectType SubclassType = LDObjectType::Bfc; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
188 | |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
189 | LDBfc(BfcStatement type = BfcStatement::CertifyCCW); |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
190 | |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
191 | virtual LDObjectType type() const override |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
192 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
193 | return LDObjectType::Bfc; |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
194 | } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
195 | |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
196 | virtual QString asText() const override; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
198 | 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
|
199 | QString objectListText() const override; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
200 | BfcStatement statement() const; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
201 | void setStatement (BfcStatement value); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
202 | QString statementToString() const; |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
203 | bool isColored() const override { return false; } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
204 | QString typeName() const override { return "bfc"; } |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
205 | void serialize(class Serializer& serializer) override; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
206 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
207 | static QString statementToString (BfcStatement statement); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
208 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
209 | private: |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
210 | BfcStatement m_statement; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | |
1138 | 213 | /* |
214 | * Represents a single code-1 subfile reference. | |
215 | */ | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
216 | class LDSubfileReference : public LDMatrixObject |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | { |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
218 | public: |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
219 | static const LDObjectType SubclassType = LDObjectType::SubfileReference; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
220 | |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
221 | LDSubfileReference() = default; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
222 | LDSubfileReference(QString referenceName, const Matrix& transformationMatrix, const Vertex& position); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
224 | virtual LDObjectType type() const override |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
225 | { |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
226 | return SubclassType; |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
227 | } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
228 | |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
229 | virtual QString asText() const override; |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
230 | LDDocument* fileInfo(DocumentManager *context) const; |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
231 | virtual void getVertices(DocumentManager *context, QSet<Vertex>& verts) const override; |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
232 | void inlineContents(DocumentManager* context, Model& model, bool deep, bool render); |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
233 | QList<LDPolygon> inlinePolygons(DocumentManager* context); |
1084
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
234 | QString objectListText() const override; |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
235 | QString referenceName() const; |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
236 | int triangleCount(DocumentManager *context) const override; |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
237 | bool hasMatrix() const override { return true; } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
238 | QString typeName() const override { return "subfilereference"; } |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
239 | void serialize(class Serializer& serializer) 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
|
240 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
241 | private: |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
242 | QString m_referenceName; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | |
1138 | 245 | /* |
246 | * Models a Bézier curve. It is stored as a special comment in the LDraw code file and can be inlined down into line segments. | |
247 | */ | |
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
|
248 | 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
|
249 | { |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
250 | public: |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
251 | static const LDObjectType SubclassType = LDObjectType::BezierCurve; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
252 | |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
253 | LDBezierCurve() = default; |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
254 | LDBezierCurve(const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3); |
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
|
255 | |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
256 | virtual LDObjectType type() const override |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
257 | { |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
258 | return SubclassType; |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
259 | } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
260 | |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
261 | virtual QString asText() const 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
|
262 | 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
|
263 | 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
|
264 | QVector<LDPolygon> rasterizePolygons (int segments); |
1137
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
265 | int numVertices() const override { return 4; } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
266 | LDColor defaultColor() const override { return EdgeColor; } |
2b6488d11305
Inlined away the LDOBJ macros in ldobject.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
267 | QString typeName() const override { return "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
|
268 | }; |
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
|
269 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
270 | enum |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
271 | { |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
272 | LowResolution = 16, |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
273 | HighResolution = 48 |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
274 | }; |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
275 | |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
276 | /* |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
277 | * 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
|
278 | */ |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
279 | template<typename T> |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
280 | 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
|
281 | { |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
282 | if (*property != value) |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
283 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
284 | Serializer::Archive before = Serializer::store(this); |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
285 | *property = value; |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1266
diff
changeset
|
286 | emit codeChanged(before, Serializer::store(this)); |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
287 | } |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
288 | } |