Mon, 04 Jun 2018 23:12:40 +0300
added work done on cylinders
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 | 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" |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
34 | #include "cylinder.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | // List of all LDObjects |
1135
8e0691be0b6f
Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
37 | QMap<qint32, LDObject*> g_allObjects; |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
38 | |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
39 | enum { MAX_LDOBJECT_IDS = (1 << 24) }; |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
40 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | // LDObject constructors |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | // |
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
|
44 | LDObject::LDObject() : |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1268
diff
changeset
|
45 | m_isHidden {false} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
47 | 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
|
48 | } |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
49 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | // |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1008
diff
changeset
|
52 | QString LDSubfileReference::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
54 | QString val = format ("1 %1 %2 ", color(), position()); |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
55 | val += transformationMatrix().toString(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | val += ' '; |
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
|
57 | val += m_referenceName; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
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
|
61 | 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
|
62 | { |
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
|
63 | 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
|
64 | |
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
|
65 | // 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
|
66 | 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
|
67 | 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
|
68 | |
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
|
69 | 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
|
70 | } |
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
|
71 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
74 | QString LDError::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | return contents(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | |
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
|
79 | 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
|
80 | { |
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
81 | return 0; |
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
82 | } |
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
83 | |
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
|
84 | 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
|
85 | { |
1290 | 86 | LDDocument* file = fileInfo(context); |
87 | if (file) | |
88 | return file->triangleCount(); | |
89 | else | |
90 | return 0; | |
1015
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
91 | } |
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
92 | |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
93 | int LDObject::numVertices() const |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
94 | { |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
95 | return 0; |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
96 | } |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
97 | |
1251
e75cc5bff076
Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents:
1236
diff
changeset
|
98 | int LDObject::numPolygonVertices() const |
e75cc5bff076
Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents:
1236
diff
changeset
|
99 | { |
e75cc5bff076
Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents:
1236
diff
changeset
|
100 | return this->numVertices(); |
e75cc5bff076
Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents:
1236
diff
changeset
|
101 | } |
e75cc5bff076
Converted magic wand mode and other selection stuff to mvc
Santeri Piippo
parents:
1236
diff
changeset
|
102 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | // |
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
|
105 | 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
|
106 | { |
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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | } |
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
|
112 | |
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
|
113 | // ============================================================================= |
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
|
114 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
115 | static void TransformObject (LDObject* obj, Matrix transform, Vertex pos, LDColor parentcolor) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | switch (obj->type()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | { |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
119 | case LDObjectType::EdgeLine: |
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
120 | case LDObjectType::ConditionalEdge: |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1117
diff
changeset
|
121 | case LDObjectType::Triangle: |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
122 | case LDObjectType::Quadrilateral: |
944 | 123 | for (int i = 0; i < obj->numVertices(); ++i) |
124 | { | |
125 | Vertex v = obj->vertex (i); | |
126 | v.transform (transform, pos); | |
127 | obj->setVertex (i, v); | |
128 | } | |
129 | break; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1117
diff
changeset
|
131 | case LDObjectType::SubfileReference: |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | { |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1008
diff
changeset
|
133 | LDSubfileReference* ref = static_cast<LDSubfileReference*> (obj); |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
134 | Matrix newMatrix = transform * ref->transformationMatrix(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | Vertex newpos = ref->position(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | newpos.transform (transform, pos); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | ref->setPosition (newpos); |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
138 | ref->setTransformationMatrix (newMatrix); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | } |
944 | 140 | break; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | |
944 | 142 | default: |
143 | break; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | |
946 | 146 | if (obj->color() == MainColor) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | obj->setColor (parentcolor); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | |
1391
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 | * 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
|
152 | */ |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
153 | 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
|
154 | { |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
155 | bool result = false; |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
156 | result ^= (isInverted()); |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
157 | result ^= (transformationMatrix().determinant() < 0); |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
158 | result ^= (nativeWinding(context) != winding); |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
159 | return result; |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
160 | } |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
161 | |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
162 | /* |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
163 | * 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
|
164 | * a subfile reference may use CW geometry. |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
165 | * |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
166 | * 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
|
167 | * determining the winding requires the libraries for reference. |
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 | Winding LDObject::nativeWinding(DocumentManager* /*context*/) const |
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 | return CounterClockwise; |
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 | |
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 | * Reimplementation of LDObject::nativeWinding for subfile references |
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 | Winding LDSubfileReference::nativeWinding(DocumentManager* context) const |
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 | return fileInfo(context)->winding(); |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
180 | } |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
181 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | // ============================================================================= |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
183 | // ----------------------------------------------------------------------------- |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
184 | void LDSubfileReference::rasterize( |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
185 | DocumentManager* context, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
186 | Winding parentWinding, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
187 | Model& model, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
188 | bool deep, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
189 | bool render |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
190 | ) { |
1367 | 191 | LDDocument* subfile = this->fileInfo(context); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | |
1367 | 193 | if (subfile != nullptr) |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
194 | { |
1367 | 195 | Model inlined {context}; |
196 | subfile->inlineContents(inlined, deep, render); | |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
197 | |
1367 | 198 | // Transform the objects |
199 | for (LDObject* object : inlined) | |
200 | { | |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
201 | if (shouldInvert(parentWinding, context)) |
1367 | 202 | ::invert(object, context); |
203 | ||
204 | TransformObject(object, transformationMatrix(), position(), color()); | |
205 | } | |
206 | ||
207 | model.merge(inlined); | |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
208 | } |
655
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 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | // |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
213 | LDPolygon* LDObject::getPolygon() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
214 | { |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
215 | LDObjectType ot = type(); |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
216 | int num = (ot == LDObjectType::EdgeLine) ? 2 |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1117
diff
changeset
|
217 | : (ot == LDObjectType::Triangle) ? 3 |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
218 | : (ot == LDObjectType::Quadrilateral) ? 4 |
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
219 | : (ot == LDObjectType::ConditionalEdge) ? 5 |
847 | 220 | : 0; |
221 | ||
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
222 | if (num == 0) |
984 | 223 | return nullptr; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
224 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
225 | LDPolygon* data = new LDPolygon; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
226 | data->num = num; |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
805
diff
changeset
|
227 | data->color = color().index(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
228 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
229 | for (int i = 0; i < data->numVertices(); ++i) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
230 | data->vertices[i] = vertex (i); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
231 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
232 | return data; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
233 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
234 | |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
235 | LDColor LDObject::defaultColor() const |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
236 | { |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
237 | return MainColor; |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
238 | } |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
239 | |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
240 | bool LDObject::isColored() const |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
241 | { |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
242 | return true; |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
243 | } |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
244 | |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
245 | bool LDObject::isScemantic() const |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
246 | { |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
247 | return true; |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
248 | } |
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 | bool LDObject::hasMatrix() const |
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 | return false; |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
253 | } |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
254 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
255 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
256 | // |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
257 | QVector<LDPolygon> LDSubfileReference::rasterizePolygons(DocumentManager* context, Winding parentWinding) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
258 | { |
1290 | 259 | LDDocument* file = fileInfo(context); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
260 | |
1290 | 261 | if (file) |
847 | 262 | { |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
263 | QVector<LDPolygon> data = fileInfo(context)->inlinePolygons(); |
1290 | 264 | |
265 | for (LDPolygon& entry : data) | |
266 | { | |
267 | for (int i = 0; i < entry.numVertices(); ++i) | |
268 | entry.vertices[i].transform (transformationMatrix(), position()); | |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
269 | |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
270 | if (shouldInvert(parentWinding, context)) |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1299
diff
changeset
|
271 | ::invertPolygon(entry); |
1290 | 272 | } |
273 | ||
274 | return data; | |
847 | 275 | } |
1290 | 276 | else |
277 | { | |
278 | return {}; | |
279 | } | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
280 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
281 | |
1297
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1290
diff
changeset
|
282 | void LDSubfileReference::setReferenceName(const QString& newReferenceName) |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1290
diff
changeset
|
283 | { |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1290
diff
changeset
|
284 | changeProperty(&this->m_referenceName, newReferenceName); |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1290
diff
changeset
|
285 | } |
389516787a4c
added subfile reference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1290
diff
changeset
|
286 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
287 | // ============================================================================= |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
288 | // |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
289 | // Moves this object using the given vector |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
290 | // |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
291 | void LDObject::move (const QVector3D vector) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
292 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | if (hasMatrix()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
295 | LDMatrixObject* mo = static_cast<LDMatrixObject*> (this); |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
296 | mo->setPosition (mo->position() + vector); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | { |
767
44f0d5322628
- slight refactor in ldobject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
764
diff
changeset
|
300 | 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
|
301 | setVertex (i, vertex (i) + vector); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
305 | bool LDObject::isHidden() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
306 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
307 | return m_isHidden; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
308 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
309 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
310 | void LDObject::setHidden (bool value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
311 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
312 | m_isHidden = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
313 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
314 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
315 | LDColor LDObject::color() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
316 | { |
1299 | 317 | if (this->m_color.isValid()) |
318 | return this->m_color; | |
319 | else | |
320 | return this->defaultColor(); | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
321 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
322 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
323 | QColor LDObject::randomColor() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
324 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
325 | return m_randomColor; |
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 | |
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
|
328 | 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
|
329 | { |
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
|
330 | 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
|
331 | { |
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
|
332 | 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
|
333 | 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
|
334 | |
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
|
335 | 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
|
336 | 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
|
337 | |
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
|
338 | 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
|
339 | 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
|
340 | |
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
|
341 | 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
|
342 | 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
|
343 | |
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
|
344 | 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
|
345 | 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
|
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 | 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
|
348 | 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
|
349 | |
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 | 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
|
351 | 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
|
352 | |
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 | 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
|
354 | 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
|
355 | |
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 | 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
|
357 | 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
|
358 | |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
359 | case LDObjectType::Cylinder: |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
360 | return new LDCylinder {}; |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
361 | |
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
|
362 | 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
|
363 | 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
|
364 | } |
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 | |
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 | 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
|
367 | } |
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 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
371 | void LDObject::setColor (LDColor color) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | { |
1299 | 373 | if (color == this->defaultColor()) |
374 | color = LDColor::nullColor; | |
375 | ||
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
376 | changeProperty(&m_color, color); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
381 | // Get a vertex by index |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
382 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | const Vertex& LDObject::vertex (int i) const |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | { |
805
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
385 | return m_coords[i]; |
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 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
390 | // Set a vertex to the given value |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
391 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | void LDObject::setVertex (int i, const Vertex& vert) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | { |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
394 | changeProperty(&m_coords[i], vert); |
655
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 | |
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
|
397 | LDMatrixObject::LDMatrixObject (const Matrix& transform, const Vertex& pos) : |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
398 | m_position (pos), |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
399 | m_transformationMatrix (transform) {} |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
400 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
401 | void LDMatrixObject::setCoordinate (const Axis axis, double value) |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
402 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
403 | Vertex position = this->position(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
404 | position.setCoordinate(axis, value); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
405 | this->setPosition(position); |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
406 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
407 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
408 | const Vertex& LDMatrixObject::position() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
409 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
410 | return m_position; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
411 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
412 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | void LDMatrixObject::setPosition (const Vertex& a) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | { |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
417 | changeProperty(&m_position, a); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | // |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
422 | const Matrix& LDMatrixObject::transformationMatrix() const |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
423 | { |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
424 | return m_transformationMatrix; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
425 | } |
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 | void LDMatrixObject::setTransformationMatrix (const Matrix& val) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | { |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
429 | changeProperty(&m_transformationMatrix, val); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | |
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
|
432 | LDError::LDError (QString contents, QString reason) : |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
433 | m_contents (contents), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
434 | m_reason (reason) {} |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
435 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
436 | QString LDError::reason() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
437 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
438 | return m_reason; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
439 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
440 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
441 | QString LDError::contents() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
442 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
443 | return m_contents; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
444 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
445 | |
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
|
446 | 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
|
447 | { |
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
|
448 | 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
|
449 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
450 | 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
|
451 | 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
|
452 | 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
|
453 | 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
|
454 | 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
|
455 | } |
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 | 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
|
457 | 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
|
458 | } |
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 | |
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
|
460 | void LDBezierCurve::rasterize(Model& model, int 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
|
461 | { |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
462 | QVector<LDPolygon> polygons = rasterizePolygons(segments); |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
463 | |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
464 | for (LDPolygon& poly : polygons) |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
465 | { |
1139
51303023d651
LDObject subclass renaming:
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
466 | LDEdgeLine* line = model.emplace<LDEdgeLine>(poly.vertices[0], poly.vertices[1]); |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
467 | line->setColor (poly.color); |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
468 | } |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
469 | } |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
470 | |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
471 | QVector<LDPolygon> LDBezierCurve::rasterizePolygons(int segments) |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
472 | { |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | |
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
|
477 | for (int i = 1; i < segments; ++i) |
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
|
478 | parms.append (pointAt (double (i) / segments)); |
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
|
479 | |
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
|
480 | parms.append (pointAt (1.0)); |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
481 | LDPolygon poly; |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
482 | poly.color = color().index(); |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
483 | poly.num = 2; |
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
|
484 | |
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
|
485 | for (int i = 0; i < segments; ++i) |
1003
31873c3cbdbc
Bézier curves are now parsed correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
486 | { |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
487 | poly.vertices[0] = parms[i]; |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
488 | poly.vertices[1] = parms[i + 1]; |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1003
diff
changeset
|
489 | result << poly; |
1003
31873c3cbdbc
Bézier curves are now parsed correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
490 | } |
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
|
491 | |
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
|
492 | 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
|
493 | } |
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 | |
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
|
495 | 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
|
496 | QString referenceName, |
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
|
497 | const Matrix& transformationMatrix, |
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
|
498 | const Vertex& position |
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
|
499 | ) : |
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
|
500 | LDMatrixObject {transformationMatrix, position}, |
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
|
501 | 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
|
502 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
503 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
504 | // |
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
|
505 | LDDocument* LDSubfileReference::fileInfo(DocumentManager* context) const |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
506 | { |
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
|
507 | return context->getDocumentByName(m_referenceName); |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
508 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
509 | |
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
|
510 | QString LDSubfileReference::referenceName() const |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
511 | { |
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
|
512 | return m_referenceName; |
1084
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
513 | } |
725
37b71daf4cb5
- added ability to draw with random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
724
diff
changeset
|
514 | |
1268 | 515 | 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
|
516 | { |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
517 | 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
|
518 | 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
|
519 | } |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
520 | |
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
|
521 | 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
|
522 | { |
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
|
523 | verts.unite(fileInfo(context)->inlineVertices()); |
1045
f726f8f49c7e
Unabbreviate "transform" to "transformationMatrix"
Teemu Piippo <teemu@hecknology.net>
parents:
1031
diff
changeset
|
524 | } |
1084
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
525 | |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
526 | QString LDObject::objectListText() const |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
527 | { |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
528 | if (numVertices() > 0) |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
529 | { |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
530 | QString result; |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
531 | |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
532 | for (int i = 0; i < numVertices(); ++i) |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
533 | { |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
534 | if (i != 0) |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
535 | result += ", "; |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
536 | |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
537 | result += vertex(i).toString (true); |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
538 | } |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
539 | |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
540 | return result; |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
541 | } |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
542 | else |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
543 | { |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
544 | return typeName(); |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
545 | } |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
546 | } |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
547 | |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
548 | QVector<LDPolygon> LDObject::rasterizePolygons(DocumentManager*, Winding) |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
549 | { |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
550 | return {}; |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
551 | } |
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1367
diff
changeset
|
552 | |
1084
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
553 | QString LDError::objectListText() const |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
554 | { |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
555 | return "ERROR: " + asText(); |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
556 | } |
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 | QString LDSubfileReference::objectListText() const |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
559 | { |
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
|
560 | 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
|
561 | |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
562 | for (int i = 0; i < 9; ++i) |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
563 | result += format("%1%2", transformationMatrix().value(i), (i != 8) ? " " : ""); |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
564 | |
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 | return result; |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
567 | } |
63daaf652454
Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
568 | |
1236
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
569 | bool LDObject::isInverted() const |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
570 | { |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
571 | return m_hasInvertNext; |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
572 | } |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
573 | |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
574 | void LDObject::setInverted(bool value) |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
575 | { |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
576 | changeProperty(&m_hasInvertNext, value); |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1161
diff
changeset
|
577 | } |
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
|
578 | |
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
|
579 | 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
|
580 | { |
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
|
581 | 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
|
582 | 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
|
583 | 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
|
584 | 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
|
585 | 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
|
586 | 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
|
587 | 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
|
588 | 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
|
589 | } |
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
|
590 | |
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
|
591 | 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
|
592 | { |
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
|
593 | 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
|
594 | serializer << m_position; |
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
|
595 | 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
|
596 | } |
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
|
597 | |
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
|
598 | 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
|
599 | { |
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
|
600 | 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
|
601 | 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
|
602 | 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
|
603 | } |
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
|
604 | |
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
|
605 | 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
|
606 | { |
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
|
607 | 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
|
608 | 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
|
609 | } |