src/linetypes/modelobject.cpp

Thu, 20 Jun 2019 08:54:35 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 20 Jun 2019 08:54:35 +0300
changeset 1440
265b2e95a8e8
parent 1426
e5a2ddfe2ba5
permissions
-rw-r--r--

uuid things

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
1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
3 * Copyright (C) 2013 - 2018 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
1147
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
19 #include "../documentmanager.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
20 #include "../linetypes/modelobject.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
21 #include "../lddocument.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
22 #include "../mainwindow.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
23 #include "../editHistory.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
24 #include "../canvas.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
25 #include "../colors.h"
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
26 #include "../glcompiler.h"
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
27 #include "../algorithms/invert.h"
1147
a26568aa3cce Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
28 #include "edgeline.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: 1268
diff changeset
29 #include "triangle.h"
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: 1268
diff changeset
30 #include "quadrilateral.h"
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: 1268
diff changeset
31 #include "conditionaledge.h"
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: 1268
diff changeset
32 #include "comment.h"
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: 1268
diff changeset
33 #include "empty.h"
1398
1c70d3447d20 changed LDCylinder to LDCircularPrimitive and moved circles to it
Teemu Piippo <teemu@hecknology.net>
parents: 1397
diff changeset
34 #include "circularprimitive.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
1440
265b2e95a8e8 uuid things
Teemu Piippo <teemu@hecknology.net>
parents: 1426
diff changeset
36 static Uuid id_counter;
769
8bb3bed44570 - improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 768
diff changeset
37
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 // LDObject constructors
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 //
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: 1268
diff changeset
41 LDObject::LDObject() :
1440
265b2e95a8e8 uuid things
Teemu Piippo <teemu@hecknology.net>
parents: 1426
diff changeset
42 id {++id_counter},
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: 1268
diff changeset
43 m_isHidden {false}
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 {
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
45 m_randomColor = QColor::fromHsv (rand() % 360, rand() % 256, rand() % 96 + 128);
770
b04c1e6ca1fb - hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 769
diff changeset
46 }
769
8bb3bed44570 - improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 768
diff changeset
47
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 //
1011
4fdd74a04790 Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1008
diff changeset
50 QString LDSubfileReference::asText() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 {
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
52 auto cellString = [&](int row, int column) { return QString::number(transformationMatrix()(row, column)); };
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
53
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
54 return QStringList {
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
55 "1",
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
56 color().indexString(),
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
57 cellString(0, 3), // x
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
58 cellString(1, 3), // y
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
59 cellString(2, 3), // z
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
60 cellString(0, 0), // matrix start
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
61 cellString(0, 1), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
62 cellString(0, 2), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
63 cellString(1, 0), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
64 cellString(1, 1), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
65 cellString(1, 2), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
66 cellString(2, 0), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
67 cellString(2, 1), // ...
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
68 cellString(2, 2), // matrix end
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
69 referenceName()
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
70 }.join(" ");
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72
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: 998
diff changeset
73 QString LDBezierCurve::asText() const
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: 998
diff changeset
74 {
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: 998
diff changeset
75 QString result = format ("0 !LDFORGE BEZIER_CURVE %1", color());
1008
74cb432812d3 Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1006
diff changeset
76
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: 998
diff changeset
77 // Add the coordinates
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: 998
diff changeset
78 for (int i = 0; i < 4; ++i)
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: 998
diff changeset
79 result += format (" %1", vertex (i));
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: 998
diff changeset
80
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: 998
diff changeset
81 return result;
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: 998
diff changeset
82 }
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: 998
diff changeset
83
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 //
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
86 QString LDError::asText() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 return contents();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
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
91 int LDObject::triangleCount(DocumentManager*) const
1015
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
92 {
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
93 return 0;
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
94 }
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
95
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
96 int LDSubfileReference::triangleCount(DocumentManager* context) const
1015
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
97 {
1290
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
98 LDDocument* file = fileInfo(context);
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
99 if (file)
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
100 return file->triangleCount();
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
101 else
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
102 return 0;
1015
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
103 }
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
104
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
105 int LDObject::numVertices() const
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
106 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
107 return 0;
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
108 }
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
109
1251
e75cc5bff076 Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents: 1236
diff changeset
110 int LDObject::numPolygonVertices() const
e75cc5bff076 Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents: 1236
diff changeset
111 {
e75cc5bff076 Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents: 1236
diff changeset
112 return this->numVertices();
e75cc5bff076 Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents: 1236
diff changeset
113 }
e75cc5bff076 Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents: 1236
diff changeset
114
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 //
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: 1268
diff changeset
117 LDBezierCurve::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: 998
diff changeset
118 {
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: 1268
diff changeset
119 setVertex(0, v0);
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: 1268
diff changeset
120 setVertex(1, v1);
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: 1268
diff changeset
121 setVertex(2, v2);
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: 1268
diff changeset
122 setVertex(3, 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: 998
diff changeset
123 }
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: 998
diff changeset
124
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: 998
diff changeset
125 // =============================================================================
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: 998
diff changeset
126 //
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
127 static void TransformObject (LDObject* object, const QMatrix4x4& matrix, LDColor parentcolor)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 {
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
129 if (object->hasMatrix()) {
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
130 LDMatrixObject* reference = static_cast<LDMatrixObject*>(object);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
131 QMatrix4x4 newMatrix = matrix * reference->transformationMatrix();
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
132 reference->setTransformationMatrix(newMatrix);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
133 }
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
134 else
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 {
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
136 for (int i = 0; i < object->numVertices(); ++i)
944
1a6f1997fcbe Replace casts
Teemu Piippo <crimsondusk64@gmail.com>
parents: 943
diff changeset
137 {
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
138 Vertex vertex = object->vertex(i);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
139 vertex.transform(matrix);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
140 object->setVertex(i, vertex);
944
1a6f1997fcbe Replace casts
Teemu Piippo <crimsondusk64@gmail.com>
parents: 943
diff changeset
141 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
144 if (object->color() == MainColor)
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
145 object->setColor(parentcolor);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
148 /*
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
149 * Returns whether or not a compound object should be inverted.
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
150 */
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
151 bool LDMatrixObject::shouldInvert(Winding winding, DocumentManager* context)
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
152 {
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
153 bool result = false;
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
154 result ^= (isInverted());
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
155 result ^= (transformationMatrix().determinant() < 0);
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
156 result ^= (nativeWinding(context) != winding);
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
157 return result;
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
158 }
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
159
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
160 /*
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
161 * The winding used by the object's geometry. By default it's CCW but some documents referenced by
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
162 * a subfile reference may use CW geometry.
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
163 *
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
164 * Since the native winding of a subfile reference depends on the actual document it references,
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
165 * determining the winding requires the libraries for reference.
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
166 */
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
167 Winding LDObject::nativeWinding(DocumentManager* /*context*/) const
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
168 {
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
169 return CounterClockwise;
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
170 }
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
171
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
172 /*
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
173 * Reimplementation of LDObject::nativeWinding for subfile references
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
174 */
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
175 Winding LDSubfileReference::nativeWinding(DocumentManager* context) const
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
176 {
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
177 return fileInfo(context)->winding();
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
178 }
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
179
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 // =============================================================================
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
181 // -----------------------------------------------------------------------------
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
182 void LDSubfileReference::rasterize(
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
183 DocumentManager* context,
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
184 Winding parentWinding,
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
185 Model& model,
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
186 bool deep,
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
187 bool render
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
188 ) {
1367
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
189 LDDocument* subfile = this->fileInfo(context);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190
1367
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
191 if (subfile != nullptr)
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
192 {
1367
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
193 Model inlined {context};
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
194 subfile->inlineContents(inlined, deep, render);
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
195
1367
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
196 // Transform the objects
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
197 for (LDObject* object : inlined)
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
198 {
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
199 if (shouldInvert(parentWinding, context))
1367
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
200 ::invert(object, context);
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
201
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
202 TransformObject(object, transformationMatrix(), color());
1367
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
203 }
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
204
0aab8d972cf6 fixed some problems
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
205 model.merge(inlined);
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
206 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 //
1400
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
211 LDPolygon LDObject::getPolygon()
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
212 {
786
71d786ce0dcc - LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
213 LDObjectType ot = type();
1400
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
214 LDPolygon::Type polygonType;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
215
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
216 switch (ot)
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
217 {
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
218 case LDObjectType::EdgeLine:
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
219 polygonType = LDPolygon::Type::EdgeLine;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
220 break;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
221
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
222 case LDObjectType::Triangle:
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
223 polygonType = LDPolygon::Type::Triangle;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
224 break;
847
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 846
diff changeset
225
1400
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
226 case LDObjectType::Quadrilateral:
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
227 polygonType = LDPolygon::Type::Quadrilateral;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
228 break;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
229
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
230 case LDObjectType::ConditionalEdge:
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
231 polygonType = LDPolygon::Type::ConditionalEdge;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
232 break;
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
233
1400
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
234 default:
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
235 return {};
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
236 }
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
237
1400
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
238 LDPolygon data;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
239 data.type = polygonType;
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
240 data.color = color();
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
241
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
242 for (int i = 0; i < data.numVertices(); ++i)
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
243 data.vertices[i] = vertex(i);
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
244
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
245 return data;
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
246 }
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
247
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
248 LDColor LDObject::defaultColor() const
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
249 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
250 return MainColor;
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
251 }
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
252
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
253 bool LDObject::isColored() const
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
254 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
255 return true;
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
256 }
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
257
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
258 bool LDObject::isScemantic() const
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
259 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
260 return true;
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
261 }
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
262
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
263 bool LDObject::hasMatrix() const
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
264 {
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
265 return false;
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
266 }
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
267
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
268 // =============================================================================
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
269 //
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
270 QVector<LDPolygon> LDSubfileReference::rasterizePolygons(DocumentManager* context, Winding parentWinding)
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
271 {
1290
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
272 LDDocument* file = fileInfo(context);
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
273
1290
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
274 if (file)
847
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 846
diff changeset
275 {
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
276 QVector<LDPolygon> data = fileInfo(context)->inlinePolygons();
1290
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
277
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
278 for (LDPolygon& entry : data)
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
279 {
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
280 for (int i = 0; i < entry.numVertices(); ++i)
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
281 entry.vertices[i].transform(transformationMatrix());
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
282
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
283 if (shouldInvert(parentWinding, context))
1305
31627acdd4b5 Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents: 1299
diff changeset
284 ::invertPolygon(entry);
1290
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
285 }
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
286
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
287 return data;
847
274a7fac44fc - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 846
diff changeset
288 }
1290
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
289 else
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
290 {
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
291 return {};
8db26042f3d1 Fixed crashing
Teemu Piippo <teemu@hecknology.net>
parents: 1278
diff changeset
292 }
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
293 }
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
294
1297
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents: 1290
diff changeset
295 void LDSubfileReference::setReferenceName(const QString& newReferenceName)
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents: 1290
diff changeset
296 {
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents: 1290
diff changeset
297 changeProperty(&this->m_referenceName, newReferenceName);
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents: 1290
diff changeset
298 }
389516787a4c added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents: 1290
diff changeset
299
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
300 // =============================================================================
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
301 //
1313
4baed9f54de3 reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents: 1312
diff changeset
302 // Moves this object using the given vector
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
303 //
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
304 void LDObject::move(const QVector3D& vector)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 if (hasMatrix())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 {
943
af81220741d9 Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents: 920
diff changeset
308 LDMatrixObject* mo = static_cast<LDMatrixObject*> (this);
1426
e5a2ddfe2ba5 fix object moving
Teemu Piippo <teemu@hecknology.net>
parents: 1423
diff changeset
309 QMatrix4x4 matrix = mo->transformationMatrix();
e5a2ddfe2ba5 fix object moving
Teemu Piippo <teemu@hecknology.net>
parents: 1423
diff changeset
310 matrix(0, 3) += vector.x();
e5a2ddfe2ba5 fix object moving
Teemu Piippo <teemu@hecknology.net>
parents: 1423
diff changeset
311 matrix(1, 3) += vector.y();
e5a2ddfe2ba5 fix object moving
Teemu Piippo <teemu@hecknology.net>
parents: 1423
diff changeset
312 matrix(2, 3) += vector.z();
e5a2ddfe2ba5 fix object moving
Teemu Piippo <teemu@hecknology.net>
parents: 1423
diff changeset
313 mo->setTransformationMatrix(matrix);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 else
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 {
767
44f0d5322628 - slight refactor in ldobject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents: 764
diff changeset
317 for (int i = 0; i < numVertices(); ++i)
1313
4baed9f54de3 reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents: 1312
diff changeset
318 setVertex (i, vertex (i) + vector);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
322 bool LDObject::isHidden() const
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
323 {
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
324 return m_isHidden;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
325 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
326
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
327 void LDObject::setHidden (bool value)
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
328 {
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
329 m_isHidden = value;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
330 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
331
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
332 LDColor LDObject::color() const
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
333 {
1299
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
334 if (this->m_color.isValid())
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
335 return this->m_color;
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
336 else
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
337 return this->defaultColor();
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
338 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
339
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
340 QColor LDObject::randomColor() const
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
341 {
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
342 return m_randomColor;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
343 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
344
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: 1268
diff changeset
345 LDObject* LDObject::newFromType(LDObjectType type)
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: 1268
diff changeset
346 {
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: 1268
diff changeset
347 switch (type)
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: 1268
diff changeset
348 {
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: 1268
diff changeset
349 case 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: 1268
diff changeset
350 return new LDSubfileReference {};
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: 1268
diff changeset
351
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: 1268
diff changeset
352 case LDObjectType::Quadrilateral:
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: 1268
diff changeset
353 return new LDQuadrilateral {};
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: 1268
diff changeset
354
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: 1268
diff changeset
355 case LDObjectType::Triangle:
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: 1268
diff changeset
356 return new LDTriangle {};
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: 1268
diff changeset
357
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: 1268
diff changeset
358 case LDObjectType::EdgeLine:
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: 1268
diff changeset
359 return new LDEdgeLine {};
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: 1268
diff changeset
360
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: 1268
diff changeset
361 case LDObjectType::ConditionalEdge:
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: 1268
diff changeset
362 return new LDConditionalEdge {};
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: 1268
diff changeset
363
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: 1268
diff changeset
364 case LDObjectType::Comment:
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: 1268
diff changeset
365 return new LDComment {};
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: 1268
diff changeset
366
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: 1268
diff changeset
367 case LDObjectType::Error:
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: 1268
diff changeset
368 return new LDError {};
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: 1268
diff changeset
369
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: 1268
diff changeset
370 case LDObjectType::Empty:
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: 1268
diff changeset
371 return new LDEmpty {};
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: 1268
diff changeset
372
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: 1268
diff changeset
373 case 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: 1268
diff changeset
374 return new LDBezierCurve {};
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: 1268
diff changeset
375
1398
1c70d3447d20 changed LDCylinder to LDCircularPrimitive and moved circles to it
Teemu Piippo <teemu@hecknology.net>
parents: 1397
diff changeset
376 case LDObjectType::CircularPrimitive:
1c70d3447d20 changed LDCylinder to LDCircularPrimitive and moved circles to it
Teemu Piippo <teemu@hecknology.net>
parents: 1397
diff changeset
377 return new LDCircularPrimitive {};
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
378
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: 1268
diff changeset
379 case LDObjectType::_End:
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: 1268
diff changeset
380 break;
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: 1268
diff changeset
381 }
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: 1268
diff changeset
382
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: 1268
diff changeset
383 return nullptr;
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: 1268
diff changeset
384 }
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: 1268
diff changeset
385
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 //
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
388 void LDObject::setColor (LDColor color)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389 {
1299
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
390 if (color == this->defaultColor())
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
391 color = LDColor::nullColor;
b692088dc1a6 fixed color handling
Teemu Piippo <teemu@hecknology.net>
parents: 1297
diff changeset
392
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
393 changeProperty(&m_color, color);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 //
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
398 // Get a vertex by index
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
399 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 const Vertex& LDObject::vertex (int i) const
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401 {
805
d88c0354de97 - refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
402 return m_coords[i];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406 //
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
407 // Set a vertex to the given value
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
408 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 void LDObject::setVertex (int i, const Vertex& vert)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 {
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
411 changeProperty(&m_coords[i], vert);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
414 LDMatrixObject::LDMatrixObject(const QMatrix4x4& matrix) :
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
415 m_transformationMatrix {matrix} {}
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
416
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
417 Vertex LDMatrixObject::position() const
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
418 {
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
419 QVector4D column = m_transformationMatrix.column(3);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
420 return {column.x(), column.y(), column.z()};
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
421 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
422
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 //
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
425 const QMatrix4x4& LDMatrixObject::transformationMatrix() const
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
426 {
1045
f726f8f49c7e Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents: 1031
diff changeset
427 return m_transformationMatrix;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
428 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
429
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
430 void LDMatrixObject::translate(const QVector3D& offset)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 {
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
432 QMatrix4x4 matrix = transformationMatrix();
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
433 matrix.translate(offset);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
434 setTransformationMatrix(matrix);
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
435 }
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
436
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
437 void LDMatrixObject::setTransformationMatrix(const QMatrix4x4& newMatrix)
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
438 {
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
439 changeProperty(&m_transformationMatrix, newMatrix);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441
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: 1268
diff changeset
442 LDError::LDError (QString contents, QString reason) :
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
443 m_contents (contents),
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
444 m_reason (reason) {}
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
445
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
446 QString LDError::reason() const
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
447 {
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
448 return m_reason;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
449 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
450
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
451 QString LDError::contents() const
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
452 {
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
453 return m_contents;
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
454 }
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
455
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
456 Vertex LDBezierCurve::pointAt (qreal t) const
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
457 {
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
458 if (t >= 0.0 and t <= 1.0)
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
459 {
1313
4baed9f54de3 reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents: 1312
diff changeset
460 Vertex result = pow(1.0 - t, 3) * vertex(0);
4baed9f54de3 reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents: 1312
diff changeset
461 result += (3 * pow(1.0 - t, 2) * t) * vertex(2).toVector();
4baed9f54de3 reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents: 1312
diff changeset
462 result += (3 * (1.0 - t) * pow(t, 2)) * vertex(3).toVector();
4baed9f54de3 reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents: 1312
diff changeset
463 result += pow(t, 3) * vertex(1).toVector();
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
464 return result;
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
465 }
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
466 else
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
467 return Vertex();
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
468 }
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
469
1423
6608db56b047 fixed rendering of bézier curves
Teemu Piippo <teemu@hecknology.net>
parents: 1416
diff changeset
470 bool LDBezierCurve::isRasterizable() const
6608db56b047 fixed rendering of bézier curves
Teemu Piippo <teemu@hecknology.net>
parents: 1416
diff changeset
471 {
6608db56b047 fixed rendering of bézier curves
Teemu Piippo <teemu@hecknology.net>
parents: 1416
diff changeset
472 return true;
6608db56b047 fixed rendering of bézier curves
Teemu Piippo <teemu@hecknology.net>
parents: 1416
diff changeset
473 }
6608db56b047 fixed rendering of bézier curves
Teemu Piippo <teemu@hecknology.net>
parents: 1416
diff changeset
474
1416
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
475 void LDBezierCurve::rasterize(DocumentManager* context, Winding winding, Model& model, bool, bool)
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
476 {
1416
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
477 QVector<LDPolygon> polygons = rasterizePolygons(context, winding);
1004
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
478
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
479 for (LDPolygon& poly : polygons)
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
480 {
1139
51303023d651 LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
481 LDEdgeLine* line = model.emplace<LDEdgeLine>(poly.vertices[0], poly.vertices[1]);
1397
5d5c11af0268 cleaned up LDColor constructors
Teemu Piippo <teemu@hecknology.net>
parents: 1391
diff changeset
482 line->setColor(LDColor {poly.color});
1004
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
483 }
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
484 }
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
485
1416
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
486 QVector<LDPolygon> LDBezierCurve::rasterizePolygons(DocumentManager*, Winding)
1004
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
487 {
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
488 QVector<LDPolygon> result;
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
489 QVector<Vertex> parms;
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
490 parms.append (pointAt (0.0));
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
491
1416
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
492 for (int i = 1; i < m_segments; ++i)
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
493 parms.append (pointAt (double (i) / m_segments));
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
494
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
495 parms.append (pointAt (1.0));
1004
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
496 LDPolygon poly;
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
497 poly.color = color().index();
1400
ae83213bdd63 refactored LDPolygon
Teemu Piippo <teemu@hecknology.net>
parents: 1398
diff changeset
498 poly.type = LDPolygon::Type::EdgeLine;
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
499
1416
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
500 for (int i = 0; i < m_segments; ++i)
1003
31873c3cbdbc Bézier curves are now parsed correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
501 {
1004
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
502 poly.vertices[0] = parms[i];
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
503 poly.vertices[1] = parms[i + 1];
ba4200437179 Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1003
diff changeset
504 result << poly;
1003
31873c3cbdbc Bézier curves are now parsed correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
505 }
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
506
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
507 return result;
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
508 }
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
509
1416
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
510 void LDBezierCurve::serialize(Serializer& serializer)
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
511 {
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
512 LDObject::serialize(serializer);
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
513 serializer << m_segments;
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
514 }
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
515
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
516 int LDBezierCurve::segments() const
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
517 {
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
518 return m_segments;
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
519 }
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
520
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
521 void LDBezierCurve::setSegments(int newSegments)
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
522 {
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
523 changeProperty(&m_segments, newSegments);
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
524 }
ba63c7286767 fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1406
diff changeset
525
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
526 LDSubfileReference::LDSubfileReference(
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
527 QString referenceName,
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
528 const QMatrix4x4& matrix
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
529 ) :
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
530 LDMatrixObject {matrix},
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
531 m_referenceName {referenceName} {}
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
532
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
533 // =============================================================================
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
534 //
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
535 LDDocument* LDSubfileReference::fileInfo(DocumentManager* context) const
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
536 {
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
537 return context->getDocumentByName(m_referenceName);
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
538 }
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
539
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
540 QString LDSubfileReference::referenceName() const
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 987
diff changeset
541 {
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
542 return m_referenceName;
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
543 }
725
37b71daf4cb5 - added ability to draw with random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 724
diff changeset
544
1268
7cbdaefda950 fix warning
Santeri Piippo
parents: 1266
diff changeset
545 void LDObject::getVertices(DocumentManager*, QSet<Vertex>& verts) const
835
268413885cb1 - reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
546 {
268413885cb1 - reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
547 for (int i = 0; i < numVertices(); ++i)
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1028
diff changeset
548 verts.insert(vertex(i));
835
268413885cb1 - reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
549 }
268413885cb1 - reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
550
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
551 void LDSubfileReference::getVertices (DocumentManager* context, QSet<Vertex>& verts) const
835
268413885cb1 - reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
552 {
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
553 verts.unite(fileInfo(context)->inlineVertices());
1045
f726f8f49c7e Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents: 1031
diff changeset
554 }
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
555
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
556 QString LDObject::objectListText() const
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
557 {
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
558 if (numVertices() > 0)
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
559 {
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
560 QString result;
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
561
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
562 for (int i = 0; i < numVertices(); ++i)
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
563 {
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
564 if (i != 0)
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
565 result += ", ";
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
566
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
567 result += vertex(i).toString (true);
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
568 }
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
569
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
570 return result;
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
571 }
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
572 else
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
573 {
1402
8bbf2af8c3f5 some rework in description
Teemu Piippo <teemu@hecknology.net>
parents: 1400
diff changeset
574 return iconName();
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
575 }
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
576 }
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
577
1391
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
578 QVector<LDPolygon> LDObject::rasterizePolygons(DocumentManager*, Winding)
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
579 {
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
580 return {};
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
581 }
5fa4bf1fc781 added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents: 1367
diff changeset
582
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
583 QString LDError::objectListText() const
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
584 {
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
585 return "ERROR: " + asText();
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
586 }
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
587
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
588 QString LDSubfileReference::objectListText() const
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
589 {
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
590 QString result = format ("%1 %2, (", referenceName(), position().toString(true));
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
591
1403
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
592 for (int i = 0; i < 3; ++i)
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
593 for (int j = 0; j < 3; ++j)
7a2d84112983 replaced the Matrix class with QMatrix4x4
Teemu Piippo <teemu@hecknology.net>
parents: 1402
diff changeset
594 result += format("%1%2", transformationMatrix()(i, j), (i != 2 or j != 2) ? " " : "");
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
595
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
596 result += ')';
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
597 return result;
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
598 }
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1082
diff changeset
599
1236
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
600 bool LDObject::isInverted() const
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
601 {
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
602 return m_hasInvertNext;
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
603 }
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
604
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
605 void LDObject::setInverted(bool value)
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
606 {
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
607 changeProperty(&m_hasInvertNext, value);
861bf8ebb8ec BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents: 1161
diff changeset
608 }
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: 1268
diff changeset
609
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: 1268
diff changeset
610 void LDObject::serialize(Serializer& serializer)
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: 1268
diff changeset
611 {
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: 1268
diff changeset
612 serializer << m_hasInvertNext;
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: 1268
diff changeset
613 serializer << m_isHidden;
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: 1268
diff changeset
614 serializer << m_color;
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: 1268
diff changeset
615 serializer << m_randomColor;
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: 1268
diff changeset
616 serializer << m_coords[0];
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: 1268
diff changeset
617 serializer << m_coords[1];
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: 1268
diff changeset
618 serializer << m_coords[2];
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: 1268
diff changeset
619 serializer << m_coords[3];
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: 1268
diff changeset
620 }
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: 1268
diff changeset
621
1406
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
622 void LDObject::restore(LDObjectState& archive)
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
623 {
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
624 Serializer restorer {archive, Serializer::Restore};
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
625 Serializer::Archive before = Serializer::store(this);
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
626 serialize(restorer);
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
627 emit modified(before, Serializer::store(this));
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
628 }
37fffb682d2f Circular primitive editor complete
Teemu Piippo <teemu@hecknology.net>
parents: 1403
diff changeset
629
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: 1268
diff changeset
630 void LDMatrixObject::serialize(Serializer& serializer)
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: 1268
diff changeset
631 {
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: 1268
diff changeset
632 LDObject::serialize(serializer);
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: 1268
diff changeset
633 serializer << m_transformationMatrix;
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: 1268
diff changeset
634 }
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: 1268
diff changeset
635
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: 1268
diff changeset
636 void LDError::serialize(Serializer& serializer)
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: 1268
diff changeset
637 {
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: 1268
diff changeset
638 LDObject::serialize(serializer);
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: 1268
diff changeset
639 serializer << m_contents;
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: 1268
diff changeset
640 serializer << m_reason;
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: 1268
diff changeset
641 }
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: 1268
diff changeset
642
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: 1268
diff changeset
643 void LDSubfileReference::serialize(Serializer& serializer)
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: 1268
diff changeset
644 {
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: 1268
diff changeset
645 LDMatrixObject::serialize(serializer);
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: 1268
diff changeset
646 serializer << m_referenceName;
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: 1268
diff changeset
647 }

mercurial