Wed, 04 Sep 2013 11:54:17 +0300
For some reason, of all changesets, 4fb5763 made compiling subfiles extremely slow. WTF? Reverted the change to restore compilation speed.
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
4 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
9 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
14 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "common.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "ldtypes.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "file.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "misc.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "gui.h" |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
24 | #include "history.h" |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
25 | #include "gldraw.h" |
381
241f65769a57
restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
26 | #include "colors.h" |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
464
3779a14d597c
added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
460
diff
changeset
|
28 | cfg (String, ld_defaultname, ""); |
3779a14d597c
added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
460
diff
changeset
|
29 | cfg (String, ld_defaultuser, ""); |
3779a14d597c
added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
460
diff
changeset
|
30 | cfg (Int, ld_defaultlicense, 0); |
3779a14d597c
added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
460
diff
changeset
|
31 | |
306
fef00a6cbff0
minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
32 | // List of all LDObjects |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
388
diff
changeset
|
33 | List<LDObject*> g_LDObjects; |
306
fef00a6cbff0
minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
34 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | // LDObject constructors |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
37 | // ----------------------------------------------------------------------------- |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
38 | LDObject::LDObject() : |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
39 | m_hidden (false), |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
40 | m_selected (false), |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
41 | m_parent (null), |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
42 | m_file (null), |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
43 | qObjListEntry (null), |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
44 | m_glinit (false) |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
45 | { |
306
fef00a6cbff0
minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
46 | // Determine ID |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
47 | int32 id = 1; // 0 is invalid |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
48 | |
376 | 49 | for (LDObject* obj : g_LDObjects) |
50 | if (obj->id() >= id) | |
306
fef00a6cbff0
minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
51 | id = obj->id() + 1; |
fef00a6cbff0
minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
52 | |
376 | 53 | setID (id); |
307
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
54 | g_LDObjects << this; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
57 | // ============================================================================= |
376 | 58 | // Default implementations for LDObject's virtual methods. These should never be |
59 | // actually called, for a subclass-less LDObject should never come into existance. | |
60 | // These exist only to satisfy the linker. | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
61 | // ----------------------------------------------------------------------------- |
376 | 62 | LDObject::Type LDObject::getType() const { |
63 | return LDObject::Unidentified; | |
64 | } | |
65 | ||
66 | bool LDObject::hasMatrix() const { | |
67 | return false; | |
68 | } | |
69 | ||
70 | bool LDObject::isColored() const { | |
71 | return false; | |
72 | } | |
73 | ||
74 | bool LDObject::isScemantic() const { | |
75 | return false; | |
76 | } | |
77 | ||
78 | str LDObject::typeName() const { | |
79 | return ""; | |
80 | } | |
81 | ||
82 | short LDObject::vertices() const { | |
83 | return 0; | |
84 | } | |
85 | ||
86 | // ============================================================================= | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
87 | // ----------------------------------------------------------------------------- |
376 | 88 | void LDObject::setVertexCoord (int i, Axis ax, double value) { |
89 | vertex v = getVertex (i); | |
90 | v[ax] = value; | |
91 | setVertex (i, v); | |
92 | } | |
93 | ||
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
94 | LDError::LDError() {} |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
97 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
98 | str LDComment::raw() { |
376 | 99 | return fmt ("0 %1", text); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
102 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
103 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
104 | str LDSubfile::raw() { |
376 | 105 | str val = fmt ("1 %1 %2 ", color(), position()); |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
106 | val += transform().stringRep(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | val += ' '; |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
108 | val += fileInfo()->name(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | return val; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
112 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
113 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
114 | str LDLine::raw() { |
376 | 115 | str val = fmt ("2 %1", color()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | |
376 | 117 | for (ushort i = 0; i < 2; ++i) |
118 | val += fmt (" %1", getVertex (i)); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | return val; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
123 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
124 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
125 | str LDTriangle::raw() { |
376 | 126 | str val = fmt ("3 %1", color()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
376 | 128 | for (ushort i = 0; i < 3; ++i) |
129 | val += fmt (" %1", getVertex (i)); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | return val; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
134 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
135 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
136 | str LDQuad::raw() { |
376 | 137 | str val = fmt ("4 %1", color()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
376 | 139 | for (ushort i = 0; i < 4; ++i) |
140 | val += fmt (" %1", getVertex (i)); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | return val; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
145 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
146 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
147 | str LDCndLine::raw() { |
376 | 148 | str val = fmt ("5 %1", color()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | // Add the coordinates |
376 | 151 | for (ushort i = 0; i < 4; ++i) |
152 | val += fmt (" %1", getVertex (i)); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | return val; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
157 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
158 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
159 | str LDError::raw() { |
188
4e686b771996
Further removal of hungarian notation
Santeri Piippo <crimsondusk64@gmail.com>
parents:
185
diff
changeset
|
160 | return contents; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
163 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
164 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
165 | str LDVertex::raw() { |
376 | 166 | return fmt ("0 !LDFORGE VERTEX %1 %2", color(), pos); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
169 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
170 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
171 | str LDEmpty::raw() { |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
172 | return ""; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
176 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
177 | const char* LDBFC::statements[] = { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | "CERTIFY CCW", |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | "CCW", |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | "CERTIFY CW", |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | "CW", |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | "NOCERTIFY", |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | "INVERTNEXT", |
418
c435027ee5cd
added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
184 | "CLIP", |
c435027ee5cd
added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
185 | "CLIP CCW", |
c435027ee5cd
added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
186 | "CLIP CW", |
c435027ee5cd
added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
187 | "NOCLIP", |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
190 | str LDBFC::raw() { |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
191 | return fmt ("0 BFC %1", LDBFC::statements[type]); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
195 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
196 | List<LDTriangle*> LDQuad::splitToTriangles() { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | // Create the two triangles based on this quadrilateral: |
376 | 198 | // 0---3 0---3 3 |
199 | // | | | / /| | |
200 | // | | ==> | / / | | |
201 | // | | |/ / | | |
202 | // 1---2 1 1---2 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
203 | LDTriangle* tri1 = new LDTriangle (getVertex (0), getVertex (1), getVertex (3)); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
204 | LDTriangle* tri2 = new LDTriangle (getVertex (1), getVertex (2), getVertex (3)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | // The triangles also inherit the quad's color |
376 | 207 | tri1->setColor (color()); |
208 | tri2->setColor (color()); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
210 | List<LDTriangle*> triangles; |
252
3f9067022d74
Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents:
251
diff
changeset
|
211 | triangles << tri1; |
3f9067022d74
Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents:
251
diff
changeset
|
212 | triangles << tri2; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | return triangles; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
217 | // ----------------------------------------------------------------------------- |
376 | 218 | void LDObject::replace (LDObject* other) { |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
219 | long idx = getIndex(); |
376 | 220 | assert (idx != -1); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
221 | |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
222 | // Replace the instance of the old object with the new object |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
223 | file()->setObject (idx, other); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | // Remove the old object |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | delete this; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
230 | // ----------------------------------------------------------------------------- |
376 | 231 | void LDObject::swap (LDObject* other) { |
484
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
232 | int i = 0; |
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
233 | for (LDObject* obj : file()->objects()) { |
376 | 234 | if (obj == this) |
484
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
235 | file()->setObject (i, other); |
376 | 236 | elif (obj == other) |
484
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
237 | file()->setObject (i, this); |
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
238 | |
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
239 | ++i; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | } |
376 | 241 | |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
242 | file()->addToHistory (new SwapHistory (id(), other->id())); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
245 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
246 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
247 | LDLine::LDLine (vertex v1, vertex v2) { |
376 | 248 | setVertex (0, v1); |
249 | setVertex (1, v2); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
252 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
253 | // ----------------------------------------------------------------------------- |
376 | 254 | LDObject::~LDObject() { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | // Remove this object from the selection array if it is there. |
376 | 256 | for (ulong i = 0; i < g_win->sel().size(); ++i) |
257 | if (g_win->sel() [i] == this) | |
258 | g_win->sel().erase (i); | |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
259 | |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
260 | // Delete the GL lists |
376 | 261 | GL::deleteLists (this); |
307
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
262 | |
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
263 | // Remove this object from the list of LDObjects |
376 | 264 | ulong pos = g_LDObjects.find (this); |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
265 | |
376 | 266 | if (pos < g_LDObjects.size()) |
267 | g_LDObjects.erase (pos); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
271 | // ----------------------------------------------------------------------------- |
376 | 272 | static void transformObject (LDObject* obj, matrix transform, vertex pos, short parentcolor) { |
273 | switch (obj->getType()) { | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | case LDObject::Line: |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
275 | case LDObject::CndLine: |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | case LDObject::Triangle: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | case LDObject::Quad: |
376 | 278 | for (short i = 0; i < obj->vertices(); ++i) { |
279 | vertex v = obj->getVertex (i); | |
280 | v.transform (transform, pos); | |
281 | obj->setVertex (i, v); | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
282 | } |
376 | 283 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | break; |
376 | 285 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | case LDObject::Subfile: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | { |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
288 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
289 | matrix newMatrix = transform * ref->transform(); |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
290 | vertex newpos = ref->position(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | |
376 | 292 | newpos.transform (transform, pos); |
293 | ref->setPosition (newpos); | |
294 | ref->setTransform (newMatrix); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | break; |
376 | 297 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | default: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | |
376 | 302 | if (obj->color() == maincolor) |
303 | obj->setColor (parentcolor); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
307 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
308 | List<LDObject*> LDSubfile::inlineContents (InlineFlags flags) { |
458
cb360f4d8979
Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
309 | List<LDObject*> objs = fileInfo()->inlineContents (flags); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | // Transform the objects |
376 | 312 | for (LDObject* obj : objs) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | // Set the parent now so we know what inlined this. |
376 | 314 | obj->setParent (this); |
315 | transformObject (obj, transform(), position(), color()); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | return objs; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
321 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
322 | // ----------------------------------------------------------------------------- |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
323 | long LDObject::getIndex() const { |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
324 | #ifndef RELEASE |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
325 | assert (file() != null); |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
326 | #endif |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
327 | |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
328 | for (ulong i = 0; i < file()->numObjs(); ++i) |
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
329 | if (file()->obj (i) == this) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | return i; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | return -1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
336 | // ----------------------------------------------------------------------------- |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
388
diff
changeset
|
337 | void LDObject::moveObjects (List<LDObject*> objs, const bool up) { |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
338 | if (objs.size() == 0) |
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
339 | return; |
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
340 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | // If we move down, we need to iterate the array in reverse order. |
376 | 342 | const long start = up ? 0 : (objs.size() - 1); |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
343 | const long end = up ? objs.size() : -1; |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
344 | const long incr = up ? 1 : -1; |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
388
diff
changeset
|
345 | List<LDObject*> objsToCompile; |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
346 | LDFile* file = objs[0]->file(); |
217
cad8c046f27a
Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
347 | |
376 | 348 | for (long i = start; i != end; i += incr) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | LDObject* obj = objs[i]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
351 | const long idx = obj->getIndex(), |
376 | 352 | target = idx + (up ? -1 : 1); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | |
484
5b5c77c7f3dd
made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents:
464
diff
changeset
|
354 | if ((up && idx == 0) || (!up && idx == (long) (file->objects().size() - 1))) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | // One of the objects hit the extrema. If this happens, this should be the first |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | // abort the entire operation. |
376 | 358 | assert (i == start); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | |
252
3f9067022d74
Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents:
251
diff
changeset
|
362 | objsToCompile << obj; |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
363 | objsToCompile << file->obj (target); |
217
cad8c046f27a
Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
364 | |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
365 | obj->swap (file->obj (target)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | } |
217
cad8c046f27a
Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
367 | |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
368 | objsToCompile.makeUnique(); |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
369 | |
217
cad8c046f27a
Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
370 | // The objects need to be recompiled, otherwise their pick lists are left with |
cad8c046f27a
Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
371 | // the wrong index colors which messes up selection. |
376 | 372 | for (LDObject* obj : objsToCompile) |
373 | g_win->R()->compileObject (obj); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
376 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
377 | // ----------------------------------------------------------------------------- |
376 | 378 | str LDObject::typeName (LDObject::Type type) { |
379 | LDObject* obj = LDObject::getDefault (type); | |
357
9c954c222996
Removed the two string arrays containing object types and icon names, moved these as LDObjects' virtual functions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
380 | str name = obj->typeName(); |
9c954c222996
Removed the two string arrays containing object types and icon names, moved these as LDObjects' virtual functions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
381 | delete obj; |
9c954c222996
Removed the two string arrays containing object types and icon names, moved these as LDObjects' virtual functions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
382 | return name; |
9c954c222996
Removed the two string arrays containing object types and icon names, moved these as LDObjects' virtual functions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
383 | } |
9c954c222996
Removed the two string arrays containing object types and icon names, moved these as LDObjects' virtual functions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
384 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
386 | // ----------------------------------------------------------------------------- |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
388
diff
changeset
|
387 | str LDObject::objectListContents (const List<LDObject*>& objs) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | bool firstDetails = true; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | str text = ""; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | |
376 | 391 | if (objs.size() == 0) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | return "nothing"; // :) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | |
376 | 394 | for (long i = 0; i < LDObject::NumTypes; ++i) { |
395 | LDObject::Type objType = (LDObject::Type) i; | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | ulong objCount = 0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | |
376 | 398 | for (LDObject* obj : objs) |
399 | if (obj->getType() == objType) | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | objCount++; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | |
376 | 402 | if (objCount == 0) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | continue; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | |
376 | 405 | if (!firstDetails) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | text += ", "; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
407 | |
376 | 408 | str noun = fmt ("%1%2", typeName (objType), plural (objCount)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | // Plural of "vertex" is "vertices". Stupid English. |
376 | 411 | if (objType == LDObject::Vertex && objCount != 1) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | noun = "vertices"; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | |
376 | 414 | text += fmt ("%1 %2", objCount, noun); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | firstDetails = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | return text; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
422 | // ----------------------------------------------------------------------------- |
376 | 423 | LDObject* LDObject::topLevelParent() { |
424 | if (!parent()) | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
425 | return this; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | LDObject* it = this; |
376 | 428 | |
429 | while (it->parent()) | |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
430 | it = it->parent(); |
376 | 431 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | return it; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
433 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
435 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
436 | // ----------------------------------------------------------------------------- |
376 | 437 | LDObject* LDObject::next() const { |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
438 | long idx = getIndex(); |
376 | 439 | assert (idx != -1); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
440 | |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
441 | if (idx == (long) file()->numObjs() - 1) |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
442 | return null; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
443 | |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
444 | return file()->obj (idx + 1); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
445 | } |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
446 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
447 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
448 | // ----------------------------------------------------------------------------- |
376 | 449 | LDObject* LDObject::prev() const { |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
450 | long idx = getIndex(); |
376 | 451 | assert (idx != -1); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
452 | |
376 | 453 | if (idx == 0) |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
454 | return null; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
455 | |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
456 | return file()->obj (idx - 1); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
457 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
458 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
460 | // ----------------------------------------------------------------------------- |
376 | 461 | void LDObject::move (vertex vect) { (void) vect; } |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
462 | void LDEmpty::move (vertex vect) { (void) vect; } |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
463 | void LDBFC::move (vertex vect) { (void) vect; } |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
464 | void LDComment::move (vertex vect) { (void) vect; } |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
465 | void LDError::move (vertex vect) { (void) vect; } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
466 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
467 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
468 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
469 | void LDVertex::move (vertex vect) { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
470 | pos += vect; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
471 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
472 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
473 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
474 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
475 | void LDSubfile::move (vertex vect) { |
376 | 476 | setPosition (position() + vect); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
479 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
480 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
481 | void LDLine::move (vertex vect) { |
376 | 482 | for (short i = 0; i < 2; ++i) |
483 | setVertex (i, getVertex (i) + vect); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
484 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
486 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
487 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
488 | void LDTriangle::move (vertex vect) { |
376 | 489 | for (short i = 0; i < 3; ++i) |
490 | setVertex (i, getVertex (i) + vect); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
492 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
493 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
494 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
495 | void LDQuad::move (vertex vect) { |
376 | 496 | for (short i = 0; i < 4; ++i) |
497 | setVertex (i, getVertex (i) + vect); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
500 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
501 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
502 | void LDCndLine::move (vertex vect) { |
376 | 503 | for (short i = 0; i < 4; ++i) |
504 | setVertex (i, getVertex (i) + vect); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
508 | // ----------------------------------------------------------------------------- |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | #define CHECK_FOR_OBJ(N) \ |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
510 | if (type == LDObject::N) \ |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
511 | return new LD##N; |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
512 | |
376 | 513 | LDObject* LDObject::getDefault (const LDObject::Type type) { |
514 | CHECK_FOR_OBJ (Comment) | |
515 | CHECK_FOR_OBJ (BFC) | |
516 | CHECK_FOR_OBJ (Line) | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
517 | CHECK_FOR_OBJ (CndLine) |
376 | 518 | CHECK_FOR_OBJ (Subfile) |
519 | CHECK_FOR_OBJ (Triangle) | |
520 | CHECK_FOR_OBJ (Quad) | |
521 | CHECK_FOR_OBJ (Empty) | |
522 | CHECK_FOR_OBJ (BFC) | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
523 | CHECK_FOR_OBJ (Error) |
376 | 524 | CHECK_FOR_OBJ (Vertex) |
525 | CHECK_FOR_OBJ (Overlay) | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
526 | return null; |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
527 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
528 | |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
529 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
530 | // ----------------------------------------------------------------------------- |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
531 | void LDObject::invert() {} |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
532 | void LDBFC::invert() {} |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
533 | void LDEmpty::invert() {} |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
534 | void LDComment::invert() {} |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
535 | void LDError::invert() {} |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
536 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
537 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
538 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
539 | void LDTriangle::invert() { |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
540 | // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1. |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
541 | // Thus, we swap 1 and 2. |
376 | 542 | vertex tmp = getVertex (1); |
543 | setVertex (1, getVertex (2)); | |
544 | setVertex (2, tmp); | |
545 | ||
265
955c0aabfebf
Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
546 | return; |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
547 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
548 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
549 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
550 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
551 | void LDQuad::invert() { |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
552 | // Quad: 0 -> 1 -> 2 -> 3 |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
553 | // rev: 0 -> 3 -> 2 -> 1 |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
554 | // Thus, we swap 1 and 3. |
376 | 555 | vertex tmp = getVertex (1); |
556 | setVertex (1, getVertex (3)); | |
557 | setVertex (3, tmp); | |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
558 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
559 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
560 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
561 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
562 | void LDSubfile::invert() { |
312
97620579d86c
Nuked the obsolete radial type now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
311
diff
changeset
|
563 | // Subfiles are inverted when they're prefixed with |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
564 | // a BFC INVERTNEXT statement. Thus we need to toggle this status. |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
565 | // For flat primitives it's sufficient that the determinant is |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
566 | // flipped but I don't have a method for checking flatness yet. |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
567 | // Food for thought... |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
568 | |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
569 | ulong idx = getIndex(); |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
570 | |
376 | 571 | if (idx > 0) { |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
572 | LDBFC* bfc = dynamic_cast<LDBFC*> (prev()); |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
573 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
574 | if (bfc && bfc->type == LDBFC::InvertNext) { |
312
97620579d86c
Nuked the obsolete radial type now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
311
diff
changeset
|
575 | // This is prefixed with an invertnext, thus remove it. |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
576 | file()->forgetObject (bfc); |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
577 | delete bfc; |
265
955c0aabfebf
Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
578 | return; |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
579 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
580 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
581 | |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
582 | // Not inverted, thus prefix it with a new invertnext. |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
583 | LDBFC* bfc = new LDBFC (LDBFC::InvertNext); |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
584 | file()->insertObj (idx, bfc); |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
585 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
586 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
587 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
588 | // ----------------------------------------------------------------------------- |
376 | 589 | static void invertLine (LDObject* line) { |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
590 | // For lines, we swap the vertices. I don't think that a |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
591 | // cond-line's control points need to be swapped, do they? |
376 | 592 | vertex tmp = line->getVertex (0); |
593 | line->setVertex (0, line->getVertex (1)); | |
594 | line->setVertex (1, tmp); | |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
595 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
596 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
597 | void LDLine::invert() { |
376 | 598 | invertLine (this); |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
599 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
600 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
601 | void LDCndLine::invert() { |
376 | 602 | invertLine (this); |
192
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
603 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
604 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
605 | void LDVertex::invert() {} |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
606 | |
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
607 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
608 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
609 | LDLine* LDCndLine::demote() { |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
610 | LDLine* repl = new LDLine; |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
611 | |
376 | 612 | for (int i = 0; i < repl->vertices(); ++i) |
613 | repl->setVertex (i, getVertex (i)); | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
614 | |
376 | 615 | repl->setColor (color()); |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
616 | |
376 | 617 | replace (repl); |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
618 | return repl; |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
619 | } |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
620 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
621 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
622 | // ----------------------------------------------------------------------------- |
376 | 623 | LDObject* LDObject::fromID (int id) { |
624 | for (LDObject* obj : g_LDObjects) | |
625 | if (obj->id() == id) | |
307
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
626 | return obj; |
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
627 | |
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
628 | return null; |
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
629 | } |
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
630 | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
631 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
632 | // ----------------------------------------------------------------------------- |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
633 | str LDOverlay::raw() { |
376 | 634 | return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", |
635 | filename(), camera(), x(), y(), width(), height()); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
636 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
637 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
638 | void LDOverlay::move (vertex vect) { |
376 | 639 | Q_UNUSED (vect) |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
640 | } |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
641 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
459
diff
changeset
|
642 | void LDOverlay::invert() {} |
307
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
306
diff
changeset
|
643 | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
644 | // ============================================================================= |
376 | 645 | // Hook the set accessors of certain properties to this changeProperty function. |
646 | // It takes care of history management so we can capture low-level changes, this | |
647 | // makes history stuff work out of the box. | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
648 | // ----------------------------------------------------------------------------- |
376 | 649 | template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) { |
486
25747c37c7be
For some reason, of all changesets, 4fb5763 made compiling subfiles extremely slow. WTF? Reverted the change to restore compilation speed.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
650 | long idx; |
25747c37c7be
For some reason, of all changesets, 4fb5763 made compiling subfiles extremely slow. WTF? Reverted the change to restore compilation speed.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
651 | |
25747c37c7be
For some reason, of all changesets, 4fb5763 made compiling subfiles extremely slow. WTF? Reverted the change to restore compilation speed.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
652 | if (obj->file() && (idx = obj->getIndex()) != -1) { |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
653 | str before = obj->raw(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
654 | *ptr = val; |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
655 | str after = obj->raw(); |
376 | 656 | |
445
15c3af0b5cb7
fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
657 | obj->file()->addToHistory (new EditHistory (idx, before, after)); |
376 | 658 | } else |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
659 | *ptr = val; |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
660 | } |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
661 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
662 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
663 | // ----------------------------------------------------------------------------- |
376 | 664 | READ_ACCESSOR (short, LDObject::color) { |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
665 | return m_color; |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
666 | } |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
667 | |
376 | 668 | SET_ACCESSOR (short, LDObject::setColor) { |
669 | changeProperty (this, &m_color, val); | |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
670 | } |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
671 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
672 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
673 | // ----------------------------------------------------------------------------- |
376 | 674 | const vertex& LDObject::getVertex (int i) const { |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
675 | return m_coords[i]; |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
676 | } |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
677 | |
376 | 678 | void LDObject::setVertex (int i, const vertex& vert) { |
679 | changeProperty (this, &m_coords[i], vert); | |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
680 | } |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
681 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
682 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
683 | // ----------------------------------------------------------------------------- |
376 | 684 | READ_ACCESSOR (vertex, LDMatrixObject::position) { |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
685 | return m_position; |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
686 | } |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
687 | |
376 | 688 | SET_ACCESSOR (vertex, LDMatrixObject::setPosition) { |
689 | changeProperty (linkPointer(), &m_position, val); | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
690 | } |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
691 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
692 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
447
diff
changeset
|
693 | // ----------------------------------------------------------------------------- |
376 | 694 | READ_ACCESSOR (matrix, LDMatrixObject::transform) { |
359
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
695 | return m_transform; |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
696 | } |
bcdfc801658b
more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
357
diff
changeset
|
697 | |
376 | 698 | SET_ACCESSOR (matrix, LDMatrixObject::setTransform) { |
699 | changeProperty (linkPointer(), &m_transform, val); | |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
700 | } |