src/ldtypes.cpp

Tue, 30 Jul 2013 07:38:08 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 30 Jul 2013 07:38:08 +0300
changeset 402
ec95fc95e5f3
parent 388
7ff483614aa1
child 409
8da2563c645a
permissions
-rw-r--r--

Renamed vector to List, changed it to wrap around std::deque.

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
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
28 // 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
29 List<LDObject*> g_LDObjects;
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
30
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 // LDObject constructors
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
35 LDObject::LDObject () :
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
36 m_hidden (false),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
37 m_selected (false),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
38 m_parent (null),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
39 m_file (null),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
40 qObjListEntry (null),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
41 m_glinit (false)
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
42 {
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
43 // Determine ID
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
44 qint32 id = 1; // 0 is invalid
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
45
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
46 for (LDObject* obj : g_LDObjects)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
47 if (obj->id() >= id)
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
48 id = obj->id() + 1;
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
49
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
50 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
51 g_LDObjects << this;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
54 // Default implementations for LDObject's virtual methods. These should never be
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
55 // actually called, for a subclass-less LDObject should never come into existance.
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
56 // These exist only to satisfy the linker.
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
57 LDObject::Type LDObject::getType() const {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
58 return LDObject::Unidentified;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
59 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
60
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
61 bool LDObject::hasMatrix() const {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
62 return false;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
63 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
64
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
65 bool LDObject::isColored() const {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
66 return false;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
67 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
68
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
69 bool LDObject::isScemantic() const {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
70 return false;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
71 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
72
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
73 str LDObject::typeName() const {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
74 return "";
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
75 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
76
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
77 short LDObject::vertices() const {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
78 return 0;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
79 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
80
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
81 // =============================================================================
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
82 void LDObject::setVertexCoord (int i, Axis ax, double value) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
83 vertex v = getVertex (i);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
84 v[ax] = value;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
85 setVertex (i, v);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
86 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
87
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
88 LDErrorObject::LDErrorObject() {}
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 // =============================================================================
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
91 str LDCommentObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
92 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
93 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
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
95 str LDSubfileObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
96 str val = fmt ("1 %1 %2 ", color(), position());
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
97 val += transform().stringRep();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 val += ' ';
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
99 val += fileInfo()->name();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102
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
103 str LDLineObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
104 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
105
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
106 for (ushort i = 0; i < 2; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
107 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
108
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
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
112 str LDTriangleObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
113 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
114
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
115 for (ushort i = 0; i < 3; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
116 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
117
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 return val;
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
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
121 str LDQuadObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
122 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
123
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
124 for (ushort i = 0; i < 4; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
125 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
126
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129
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
130 str LDCondLineObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
131 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
132
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 // Add the coordinates
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
134 for (ushort i = 0; i < 4; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
135 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
136
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139
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
140 str LDErrorObject::raw() {
188
4e686b771996 Further removal of hungarian notation
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
141 return contents;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
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
144 str LDVertexObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
145 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
146 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147
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
148 str LDEmptyObject::raw() {
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
149 return "";
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 // =============================================================================
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 // =============================================================================
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
155 const char* LDBFCObject::statements[] = {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 "CERTIFY CCW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 "CCW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 "CERTIFY CW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 "CW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 "NOCERTIFY",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 "INVERTNEXT",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163
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
164 str LDBFCObject::raw() {
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
165 return fmt ("0 BFC %1", LDBFCObject::statements[type]);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 }
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 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 // =============================================================================
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
171 List<LDTriangleObject*> LDQuadObject::splitToTriangles() {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 // Create the two triangles based on this quadrilateral:
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
173 // 0---3 0---3 3
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
174 // | | | / /|
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
175 // | | ==> | / / |
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
176 // | | |/ / |
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
177 // 1---2 1 1---2
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
178 LDTriangleObject* tri1 = new LDTriangleObject (getVertex (0), getVertex (1), getVertex (3));
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
179 LDTriangleObject* tri2 = new LDTriangleObject (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
180
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 // The triangles also inherit the quad's color
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
182 tri1->setColor (color());
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
183 tri2->setColor (color());
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
185 List<LDTriangleObject*> triangles;
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
186 triangles << tri1;
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
187 triangles << tri2;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 return triangles;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 // =============================================================================
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 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
194 void LDObject::replace (LDObject* other) {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
195 long idx = getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
196 assert (idx != -1);
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
197
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
198 // Replace the instance of the old object with the new object
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
199 LDOpenFile::current()->setObject (idx, other);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 // Remove the old object
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 delete this;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
208 void LDObject::swap (LDObject* other) {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
209 for (LDObject*& obj : *LDOpenFile::current()) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
210 if (obj == this)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 obj = other;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
212 elif (obj == other)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 obj = this;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 }
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
215
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
216 LDOpenFile::current()->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
217 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218
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
219 LDLineObject::LDLineObject (vertex v1, vertex v2) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
220 setVertex (0, v1);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
221 setVertex (1, v2);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
224 LDObject::~LDObject() {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 // Remove this object from the selection array if it is there.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
226 for (ulong i = 0; i < g_win->sel().size(); ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
227 if (g_win->sel() [i] == this)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
228 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
229
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
230 // Delete the GL lists
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
231 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
232
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
233 // Remove this object from the list of LDObjects
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
234 ulong pos = g_LDObjects.find (this);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
235
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
236 if (pos < g_LDObjects.size())
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
237 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
238 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
243 static void transformObject (LDObject* obj, matrix transform, vertex pos, short parentcolor) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
244 switch (obj->getType()) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 case LDObject::Line:
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 case LDObject::CondLine:
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 case LDObject::Triangle:
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
248 case LDObject::Quad:
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
249 for (short i = 0; i < obj->vertices(); ++i) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
250 vertex v = obj->getVertex (i);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
251 v.transform (transform, pos);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
252 obj->setVertex (i, v);
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
253 }
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
254
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 break;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
256
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 case LDObject::Subfile:
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 {
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
259 LDSubfileObject* ref = static_cast<LDSubfileObject*> (obj);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
260 matrix newMatrix = transform * ref->transform();
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
261 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
262
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
263 newpos.transform (transform, pos);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
264 ref->setPosition (newpos);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
265 ref->setTransform (newMatrix);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 break;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
268
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 default:
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 break;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
273 if (obj->color() == maincolor)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
274 obj->setColor (parentcolor);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 // =============================================================================
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
280 List<LDObject*> LDSubfileObject::inlineContents (bool deep, bool cache) {
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
281 List<LDObject*> objs, objcache;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
282
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 // If we have this cached, just clone that
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
284 if (deep && fileInfo()->cache().size()) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
285 for (LDObject* obj : fileInfo()->cache())
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
286 objs << obj->clone();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
287 } else {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
288 if (!deep)
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
289 cache = false;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
290
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
291 for (LDObject* obj : *fileInfo()) {
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
292 // Skip those without scemantic meaning
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
293 if (!obj->isScemantic())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 continue;
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 // Got another sub-file reference, inline it if we're deep-inlining. If not,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 // just add it into the objects normally. Also, we only cache immediate
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298 // subfiles and this is not one. Yay, recursion!
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
299 if (deep && obj->getType() == LDObject::Subfile) {
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
300 LDSubfileObject* ref = static_cast<LDSubfileObject*> (obj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
302 List<LDObject*> otherobjs = ref->inlineContents (true, false);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
304 for (LDObject* otherobj : otherobjs) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 // Cache this object, if desired
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
306 if (cache)
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
307 objcache << otherobj->clone();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
309 objs << otherobj;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 }
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
311 } else {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
312 if (cache)
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
313 objcache << obj->clone();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
315 objs << obj->clone();
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
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
319 if (cache)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
320 fileInfo()->setCache (objcache);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323 // Transform the objects
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
324 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
325 // Set the parent now so we know what inlined this.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
326 obj->setParent (this);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
327 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
328 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 return objs;
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
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 // =============================================================================
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
336 long LDObject::getIndex() const {
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
337 #ifndef RELEASE
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
338 assert (file() != null);
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
339 #endif
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
340
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
341 for (ulong i = 0; i < file()->numObjs(); ++i)
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
342 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
343 return i;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 return -1;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 // =============================================================================
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
351 void LDObject::moveObjects (List<LDObject*> objs, const bool up) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 // If we move down, we need to iterate the array in reverse order.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
353 const long start = up ? 0 : (objs.size() - 1);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
354 const long end = up ? objs.size() : -1;
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
355 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
356 List<LDObject*> objsToCompile;
217
cad8c046f27a Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents: 216
diff changeset
357
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
358 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
359 LDObject* obj = objs[i];
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
361 const long idx = obj->getIndex(),
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
362 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
363
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
364 if ((up && idx == 0) || (!up && idx == (long) (LDOpenFile::current()->objs().size() - 1))) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 // 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
366 // 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
367 // abort the entire operation.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
368 assert (i == start);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
372 objsToCompile << obj;
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
373 objsToCompile << LDOpenFile::current()->obj (target);
217
cad8c046f27a Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents: 216
diff changeset
374
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
375 obj->swap (LDOpenFile::current()->obj (target));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 }
217
cad8c046f27a Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents: 216
diff changeset
377
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
378 objsToCompile.makeUnique();
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
379
217
cad8c046f27a Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents: 216
diff changeset
380 // 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
381 // the wrong index colors which messes up selection.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
382 for (LDObject* obj : objsToCompile)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
383 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
384 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
386 str LDObject::typeName (LDObject::Type type) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
387 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
388 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
389 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
390 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
391 }
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
392
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 // =============================================================================
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
396 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
397 bool firstDetails = true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 str text = "";
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
400 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
401 return "nothing"; // :)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
403 for (long i = 0; i < LDObject::NumTypes; ++i) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
404 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
405 ulong objCount = 0;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
407 for (LDObject* obj : objs)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
408 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
409 objCount++;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
411 if (objCount == 0)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
414 if (!firstDetails)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 text += ", ";
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
417 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
418
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 // Plural of "vertex" is "vertices". Stupid English.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
420 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
421 noun = "vertices";
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
423 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
424 firstDetails = false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425 }
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 return text;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
431 LDObject* LDObject::topLevelParent() {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
432 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
433 return this;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435 LDObject* it = this;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
436
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
437 while (it->parent())
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
438 it = it->parent();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
439
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 return it;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442
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
443 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
444 LDObject* LDObject::next() const {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
445 long idx = getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
446 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
447
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
448 if (idx == (long) LDOpenFile::current()->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
449 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
450
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
451 return LDOpenFile::current()->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
452 }
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
453
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 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
455 LDObject* LDObject::prev() const {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
456 long idx = getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
457 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
458
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
459 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
460 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
461
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
462 return LDOpenFile::current()->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
463 }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
468 void LDObject::move (vertex vect) { (void) vect; }
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
469 void LDEmptyObject::move (vertex vect) { (void) vect; }
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
470 void LDBFCObject::move (vertex vect) { (void) vect; }
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
471 void LDCommentObject::move (vertex vect) { (void) vect; }
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
472 void LDErrorObject::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
473
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
474 void LDVertexObject::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
475 pos += vect;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477
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
478 void LDSubfileObject::move (vertex vect) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
479 setPosition (position() + vect);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
481
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
482 void LDLineObject::move (vertex vect) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
483 for (short i = 0; i < 2; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
484 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
485 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
486
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
487 void LDTriangleObject::move (vertex vect) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
488 for (short i = 0; i < 3; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
489 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
490 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491
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
492 void LDQuadObject::move (vertex vect) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
493 for (short i = 0; i < 4; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
494 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
495 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496
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
497 void LDCondLineObject::move (vertex vect) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
498 for (short i = 0; i < 4; ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
499 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
500 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
502 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
503 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505 #define CHECK_FOR_OBJ(N) \
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
506 if( type == LDObject::N ) \
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
507 return new LD##N##Object;
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
508
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
509 LDObject* LDObject::getDefault (const LDObject::Type type) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
510 CHECK_FOR_OBJ (Comment)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
511 CHECK_FOR_OBJ (BFC)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
512 CHECK_FOR_OBJ (Line)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
513 CHECK_FOR_OBJ (CondLine)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
514 CHECK_FOR_OBJ (Subfile)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
515 CHECK_FOR_OBJ (Triangle)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
516 CHECK_FOR_OBJ (Quad)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
517 CHECK_FOR_OBJ (Empty)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
518 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
519 CHECK_FOR_OBJ (Error)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
520 CHECK_FOR_OBJ (Vertex)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
521 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
522 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
523 }
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
524
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
525 // =============================================================================
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
526 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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 // =============================================================================
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
528 void LDObject::invert() {}
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
529 void LDBFCObject::invert() {}
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
530 void LDEmptyObject::invert() {}
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
531 void LDCommentObject::invert() {}
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
532 void LDErrorObject::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
533
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
534 void LDTriangleObject::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
535 // 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
536 // Thus, we swap 1 and 2.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
537 vertex tmp = getVertex (1);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
538 setVertex (1, getVertex (2));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
539 setVertex (2, tmp);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
540
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
541 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
542 }
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
543
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
544 void LDQuadObject::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
545 // 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
546 // 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
547 // Thus, we swap 1 and 3.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
548 vertex tmp = getVertex (1);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
549 setVertex (1, getVertex (3));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
550 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
551 }
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
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
553 void LDSubfileObject::invert() {
312
97620579d86c Nuked the obsolete radial type now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 311
diff changeset
554 // 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
555 // 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
556 // 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
557 // 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
558 // 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
559
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
560 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
561
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
562 if (idx > 0) {
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
563 LDBFCObject* bfc = dynamic_cast<LDBFCObject*> (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
564
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
565 if (bfc && bfc->type == LDBFCObject::InvertNext) {
312
97620579d86c Nuked the obsolete radial type now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 311
diff changeset
566 // This is prefixed with an invertnext, thus remove it.
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
567 LDOpenFile::current()->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
568 delete bfc;
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
569 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
570 }
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
571 }
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
572
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 // Not inverted, thus prefix it with a new invertnext.
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
574 LDBFCObject* bfc = new LDBFCObject (LDBFCObject::InvertNext);
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
575 LDOpenFile::current()->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
576 }
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
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
578 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
579 // 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
580 // cond-line's control points need to be swapped, do they?
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
581 vertex tmp = line->getVertex (0);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
582 line->setVertex (0, line->getVertex (1));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
583 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
584 }
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
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
586 void LDLineObject::invert() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
587 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
588 }
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
589
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
590 void LDCondLineObject::invert() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
591 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
592 }
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
593
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
594 void LDVertexObject::invert() {}
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
595
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
596 // =============================================================================
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
597 LDLineObject* LDCondLineObject::demote() {
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
598 LDLineObject* repl = new LDLineObject;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
599
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
600 for (int i = 0; i < repl->vertices(); ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
601 repl->setVertex (i, getVertex (i));
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
602
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
603 repl->setColor (color());
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
604
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
605 replace (repl);
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
606 return repl;
275
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
607 }
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
608
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
609 LDObject* LDObject::fromID (int id) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
610 for (LDObject* obj : g_LDObjects)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
611 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
612 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
613
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
614 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
615 }
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
616
316
b4fefda58f43 Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
617 // =============================================================================
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
618 str LDOverlayObject::raw() {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
619 return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6",
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
620 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
621 }
b4fefda58f43 Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
622
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
623 void LDOverlayObject::move (vertex vect) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
624 Q_UNUSED (vect)
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
625 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
626
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
627 void LDOverlayObject::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
628
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
629 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
630 // Hook the set accessors of certain properties to this changeProperty function.
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
631 // It takes care of history management so we can capture low-level changes, this
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
632 // makes history stuff work out of the box.
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
633 template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) {
275
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
634 long idx;
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
635
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
636 if (obj->file() && (idx = obj->getIndex()) != -1) {
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
637 str before = obj->raw();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
638 *ptr = val;
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
639 str after = obj->raw();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
640
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
641 LDOpenFile::current()->addToHistory (new EditHistory (idx, before, after));
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
642 } else
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
643 *ptr = val;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
644 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
645
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
646 READ_ACCESSOR (short, LDObject::color) {
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
647 return m_color;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
648 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
649
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
650 SET_ACCESSOR (short, LDObject::setColor) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
651 changeProperty (this, &m_color, val);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
652 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
653
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
654 const vertex& LDObject::getVertex (int i) const {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
655 return m_coords[i];
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
656 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
657
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
658 void LDObject::setVertex (int i, const vertex& vert) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
659 changeProperty (this, &m_coords[i], vert);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
660 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
661
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
662 READ_ACCESSOR (vertex, LDMatrixObject::position) {
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
663 return m_position;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
664 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
665
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
666 SET_ACCESSOR (vertex, LDMatrixObject::setPosition) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
667 changeProperty (linkPointer(), &m_position, val);
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
668 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
669
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
670 READ_ACCESSOR (matrix, LDMatrixObject::transform) {
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
671 return m_transform;
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
672 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
673
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
674 SET_ACCESSOR (matrix, LDMatrixObject::setTransform) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
675 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
676 }

mercurial