src/ldtypes.cpp

Wed, 23 Oct 2013 12:46:10 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 23 Oct 2013 12:46:10 +0300
changeset 665
4355e72ffd47
parent 489
0b32138fedcc
parent 528
e38d199ef9aa
permissions
-rw-r--r--

Merge branch 'master' into gl

Conflicts:
src/file.cpp
src/gldraw.cpp
src/gldraw.h
src/gui.cpp
src/ldtypes.cpp
src/src.pro
src/types.h

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"
489
0b32138fedcc Further work on VAO rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
27 #include "gldata.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
464
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
29 cfg (String, ld_defaultname, "");
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
30 cfg (String, ld_defaultuser, "");
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
31 cfg (Int, ld_defaultlicense, 0);
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
32
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
33 // List of all LDObjects
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
34 QList<LDObject*> g_LDObjects;
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
35
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 // LDObject constructors
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
38 // -----------------------------------------------------------------------------
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 418
diff changeset
39 LDObject::LDObject() :
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
40 m_hidden (false),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
41 m_selected (false),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
42 m_parent (null),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
43 m_file (null),
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
44 qObjListEntry (null),
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
45 m_glinit (false)
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
46 {
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
47 memset (m_coords, 0, sizeof m_coords);
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
48
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
49 // Determine ID
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 418
diff changeset
50 int32 id = 1; // 0 is invalid
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
51
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
52 for (LDObject* obj : g_LDObjects)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
53 if (obj->id() >= id)
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
54 id = obj->id() + 1;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
55
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
56 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
57 g_LDObjects << this;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
60 // =============================================================================
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
61 // Default implementations for LDObject's virtual methods. These should never be
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
62 // actually called, for a subclass-less LDObject should never come into existance.
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
63 // These exist only to satisfy the linker.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
64 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
65 LDObject::Type LDObject::getType() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
66 { return LDObject::Unidentified;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
67 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
68
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
69 bool LDObject::hasMatrix() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
70 { return false;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
71 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
72
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
73 bool LDObject::isColored() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
74 { return false;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
75 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
76
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
77 bool LDObject::isScemantic() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
78 { return false;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
79 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
80
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
81 str LDObject::typeName() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
82 { return "";
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
83 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
84
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
85 short LDObject::vertices() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
86 { return 0;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
87 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
88
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
89 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
90 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
91 void LDObject::setVertexCoord (int i, Axis ax, double value)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
92 { vertex v = getVertex (i);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
93 v[ax] = value;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
94 setVertex (i, v);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
95 }
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
96
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
97 LDError::LDError() {}
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
100 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
101 str LDComment::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
102 { 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
103 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
105 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
106 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
107 str LDSubfile::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
108 { str val = fmt ("1 %1 %2 ", color(), position());
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
109 val += transform().stringRep();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 val += ' ';
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
111 val += fileInfo()->name();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
115 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
116 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
117 str LDLine::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
118 { str val = fmt ("2 %1", color());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
119
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
120 for (int i = 0; i < 2; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
121 val += fmt (" %1", getVertex (i));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
122
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
126 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
127 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
128 str LDTriangle::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
129 { str val = fmt ("3 %1", color());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
130
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
131 for (int i = 0; i < 3; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
132 val += fmt (" %1", getVertex (i));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
133
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
137 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
138 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
139 str LDQuad::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
140 { str val = fmt ("4 %1", color());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
141
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
142 for (int i = 0; i < 4; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
143 val += fmt (" %1", getVertex (i));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
144
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 return val;
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
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
148 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
149 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
150 str LDCndLine::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
151 { str val = fmt ("5 %1", color());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
152
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 // Add the coordinates
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
154 for (int i = 0; i < 4; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
155 val += fmt (" %1", getVertex (i));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
156
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 return val;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
160 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
161 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
162 str LDError::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
163 { return contents;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
166 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
167 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
168 str LDVertex::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
169 { 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
170 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
172 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
173 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
174 str LDEmpty::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
175 { return "";
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
179 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
180 const char* LDBFC::statements[] =
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
181 { "CERTIFY CCW",
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 "CCW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 "CERTIFY CW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 "CW",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 "NOCERTIFY",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 "INVERTNEXT",
418
c435027ee5cd added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
187 "CLIP",
c435027ee5cd added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
188 "CLIP CCW",
c435027ee5cd added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
189 "CLIP CW",
c435027ee5cd added support for BFC CLIP/NOCLIP
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
190 "NOCLIP",
183
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
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
193 str LDBFC::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
194 { return fmt ("0 BFC %1", LDBFC::statements[type]);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
198 // -----------------------------------------------------------------------------
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
199 QList<LDTriangle*> LDQuad::splitToTriangles()
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
200 { // Create the two triangles based on this quadrilateral:
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
201 // 0---3 0---3 3
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
202 // | | | / /|
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
203 // | | ==> | / / |
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
204 // | | |/ / |
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
205 // 1---2 1 1---2
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
206 LDTriangle* tri1 = new LDTriangle (getVertex (0), getVertex (1), getVertex (3));
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
207 LDTriangle* tri2 = new LDTriangle (getVertex (1), getVertex (2), getVertex (3));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
208
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 // The triangles also inherit the quad's color
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
210 tri1->setColor (color());
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
211 tri2->setColor (color());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
212
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
213 QList<LDTriangle*> triangles;
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
214 triangles << tri1;
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
215 triangles << tri2;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 return triangles;
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
220 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
221 void LDObject::replace (LDObject* other)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
222 { long idx = getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
223 assert (idx != -1);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
224
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
225 // Replace the instance of the old object with the new object
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
226 file()->setObject (idx, other);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
227
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // Remove the old object
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 delete this;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
233 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
234 void LDObject::swap (LDObject* other)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
235 { int i = 0;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
236
500
cad8cdc42a64 Finally got the ringfinder working! Working on integrating it to ring drawing...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
237 for (LDObject* obj : file()->objects())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
238 { if (obj == this)
484
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 464
diff changeset
239 file()->setObject (i, other);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
240 elif (obj == other)
500
cad8cdc42a64 Finally got the ringfinder working! Working on integrating it to ring drawing...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
241 file()->setObject (i, this);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
242
484
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 464
diff changeset
243 ++i;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 }
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
245
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
246 file()->addToHistory (new SwapHistory (id(), other->id()));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
248
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
249 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
250 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
251 LDLine::LDLine (vertex v1, vertex v2)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
252 { setVertex (0, v1);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
253 setVertex (1, v2);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
256 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
257 // -----------------------------------------------------------------------------
506
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
258 LDQuad::LDQuad (const vertex& v0, const vertex& v1, const vertex& v2, const vertex& v3)
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
259 { setVertex (0, v0);
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
260 setVertex (1, v1);
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
261 setVertex (2, v2);
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
262 setVertex (3, v3);
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
263 }
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
264
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
265 // =============================================================================
525f6c48db83 Added last-resort ring draw with quads
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
266 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
267 LDObject::~LDObject()
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
268 { // If this object was selected, unselect it now
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
269 if (selected())
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
270 unselect();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
271
528
e38d199ef9aa fixed: deleting objects would trigger a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 527
diff changeset
272 // If this object was associated to a file, remove it off it now
e38d199ef9aa fixed: deleting objects would trigger a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 527
diff changeset
273 if (file())
e38d199ef9aa fixed: deleting objects would trigger a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 527
diff changeset
274 file()->forgetObject (this);
e38d199ef9aa fixed: deleting objects would trigger a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 527
diff changeset
275
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
276 // Delete the GL lists
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
277 GL::deleteLists (this);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
278
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
279 // Remove this object from the list of LDObjects
503
bebe09014dd6 removed the List class in favor of QList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 500
diff changeset
280 g_LDObjects.removeOne (this);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
284 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
285 static void transformObject (LDObject* obj, matrix transform, vertex pos, short parentcolor)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
286 { switch (obj->getType())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
287 { case LDObject::Line:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
288 case LDObject::CndLine:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
289 case LDObject::Triangle:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
290 case LDObject::Quad:
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
291
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
292 for (short i = 0; i < obj->vertices(); ++i)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
293 { vertex v = obj->getVertex (i);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
294 v.transform (transform, pos);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
295 obj->setVertex (i, v);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
296 }
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
297
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
298 break;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
299
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
300 case LDObject::Subfile:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
301 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
302 matrix newMatrix = transform * ref->transform();
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
303 vertex newpos = ref->position();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
304
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
305 newpos.transform (transform, pos);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
306 ref->setPosition (newpos);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
307 ref->setTransform (newMatrix);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 break;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
310
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
311 default:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
312 break;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
314
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
315 if (obj->color() == maincolor)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
316 obj->setColor (parentcolor);
183
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
320 // -----------------------------------------------------------------------------
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
321 QList<LDObject*> LDSubfile::inlineContents (InlineFlags flags)
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
322 { QList<LDObject*> objs = fileInfo()->inlineContents (flags);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
323
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324 // Transform the objects
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
325 for (LDObject * obj : objs)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
326 { // Set the parent now so we know what inlined this.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
327 obj->setParent (this);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
328 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
329 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
330
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 return objs;
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 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
335 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
336 long LDObject::getIndex() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
337 {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
338 #ifndef RELEASE
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
339 assert (file() != null);
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
340 #endif
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
341
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
342 for (int i = 0; i < file()->numObjs(); ++i)
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
343 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
344 return i;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
345
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 return -1;
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 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
350 // -----------------------------------------------------------------------------
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
351 void LDObject::moveObjects (QList<LDObject*> objs, const bool up)
527
47c068f2e7e3 more minor changes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
352 { if (objs.isEmpty())
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
353 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
354
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 // 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
356 const long start = up ? 0 : (objs.size() - 1);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
357 const long end = up ? objs.size() : -1;
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
358 const long incr = up ? 1 : -1;
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
359 QList<LDObject*> objsToCompile;
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
360 LDFile* file = objs[0]->file();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
361
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
362 for (long i = start; i != end; i += incr)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
363 { LDObject* obj = objs[i];
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
364
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
365 const long idx = obj->getIndex(),
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
366 target = idx + (up ? -1 : 1);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
367
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
368 if ( (up && idx == 0) || (!up && idx == (long) (file->objects().size() - 1)))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
369 { // One of the objects hit the extrema. If this happens, this should be the first
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 // 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
371 // abort the entire operation.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
372 assert (i == start);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
375
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
376 objsToCompile << obj;
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
377 objsToCompile << file->obj (target);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
378
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
379 obj->swap (file->obj (target));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
381
503
bebe09014dd6 removed the List class in favor of QList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 500
diff changeset
382 removeDuplicates (objsToCompile);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
383
217
cad8c046f27a Fixed: moving objects up/down the object list messed up selection
Santeri Piippo <crimsondusk64@gmail.com>
parents: 216
diff changeset
384 // 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
385 // the wrong index colors which messes up selection.
503
bebe09014dd6 removed the List class in favor of QList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 500
diff changeset
386 for (LDObject* obj : objsToCompile)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
387 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
388 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
390 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
391 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
392 str LDObject::typeName (LDObject::Type type)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
393 { 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
394 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
395 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
396 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
397 }
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
398
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
400 // -----------------------------------------------------------------------------
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 503
diff changeset
401 str LDObject::objectListContents (const QList<LDObject*>& objs)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
402 { bool firstDetails = true;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 str text = "";
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
404
527
47c068f2e7e3 more minor changes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
405 if (objs.isEmpty())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406 return "nothing"; // :)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
407
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
408 for (long i = 0; i < LDObject::NumTypes; ++i)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
409 { LDObject::Type objType = (LDObject::Type) i;
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
410 int count = 0;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
411
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
412 for (LDObject * obj : objs)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
413 if (obj->getType() == objType)
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
414 count++;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
415
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
416 if (count == 0)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
418
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
419 if (!firstDetails)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420 text += ", ";
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
421
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
422 str noun = fmt ("%1%2", typeName (objType), plural (count));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
423
527
47c068f2e7e3 more minor changes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
424 // Plural of "vertex" is "vertices", correct that
47c068f2e7e3 more minor changes
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
425
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
426 if (objType == LDObject::Vertex && count != 1)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427 noun = "vertices";
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
428
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
429 text += fmt ("%1 %2", count, noun);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 firstDetails = false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
432
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433 return text;
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
437 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
438 LDObject* LDObject::topLevelParent()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
439 { 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
440 return this;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
441
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 LDObject* it = this;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
443
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
444 while (it->parent())
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
445 it = it->parent();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
446
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 return it;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449
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
450 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
451 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
452 LDObject* LDObject::next() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
453 { long idx = getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
454 assert (idx != -1);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
455
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
456 if (idx == (long) file()->numObjs() - 1)
191
9bb6a17305ad Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
457 return null;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
458
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
459 return file()->obj (idx + 1);
191
9bb6a17305ad Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
460 }
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
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
462 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
463 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
464 LDObject* LDObject::prev() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
465 { long idx = getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
466 assert (idx != -1);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
467
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
468 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
469 return null;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
470
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
471 return file()->obj (idx - 1);
191
9bb6a17305ad Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
472 }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
475 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
476 void LDObject::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
477 { (void) vect;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
478 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
479 void LDEmpty::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
480 { (void) vect;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
481 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
482 void LDBFC::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
483 { (void) vect;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
484 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
485 void LDComment::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
486 { (void) vect;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
487 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
488 void LDError::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
489 { (void) 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
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
492 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
493 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
494 void LDVertex::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
495 { pos += vect;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
497
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
498 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
499 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
500 void LDSubfile::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
501 { setPosition (position() + vect);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
502 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
503
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
504 // =============================================================================
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
505 // -----------------------------------------------------------------------------
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
506 void LDLine::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
507 { for (short i = 0; i < 2; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
508 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
509 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
511 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
512 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
513 void LDTriangle::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
514 { for (short i = 0; i < 3; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
515 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
516 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
517
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
518 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
519 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
520 void LDQuad::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
521 { for (short i = 0; i < 4; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
522 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
523 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
524
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
525 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
526 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
527 void LDCndLine::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
528 { for (short i = 0; i < 4; ++i)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
529 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
530 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
531
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
532 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
533 // -----------------------------------------------------------------------------
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
534 #define CHECK_FOR_OBJ(N) \
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 418
diff changeset
535 if (type == LDObject::N) \
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
536 return new LD##N;
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
537
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
538 LDObject* LDObject::getDefault (const LDObject::Type type)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
539 { CHECK_FOR_OBJ (Comment)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
540 CHECK_FOR_OBJ (BFC)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
541 CHECK_FOR_OBJ (Line)
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
542 CHECK_FOR_OBJ (CndLine)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
543 CHECK_FOR_OBJ (Subfile)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
544 CHECK_FOR_OBJ (Triangle)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
545 CHECK_FOR_OBJ (Quad)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
546 CHECK_FOR_OBJ (Empty)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
547 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
548 CHECK_FOR_OBJ (Error)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
549 CHECK_FOR_OBJ (Vertex)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
550 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
551 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
552 }
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
553
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
554 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
555 // -----------------------------------------------------------------------------
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
556 void LDObject::invert() {}
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
557 void LDBFC::invert() {}
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
558 void LDEmpty::invert() {}
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
559 void LDComment::invert() {}
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
560 void LDError::invert() {}
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
561
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
562 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
563 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
564 void LDTriangle::invert()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
565 { // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1.
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
566 // Thus, we swap 1 and 2.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
567 vertex tmp = getVertex (1);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
568 setVertex (1, getVertex (2));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
569 setVertex (2, tmp);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
570
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
571 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
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
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
574 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
575 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
576 void LDQuad::invert()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
577 { // Quad: 0 -> 1 -> 2 -> 3
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
578 // 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
579 // Thus, we swap 1 and 3.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
580 vertex tmp = getVertex (1);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
581 setVertex (1, getVertex (3));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
582 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
583 }
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
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
585 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
586 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
587 void LDSubfile::invert()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
588 { // 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
589 // 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
590 // 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
591 // 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
592 // Food for thought...
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
593
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
594 int idx = getIndex();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
595
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
596 if (idx > 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
597 { LDBFC* bfc = dynamic_cast<LDBFC*> (prev());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
598
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
599 if (bfc && bfc->type == LDBFC::InvertNext)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
600 { // This is prefixed with an invertnext, thus remove it.
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
601 file()->forgetObject (bfc);
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
602 delete bfc;
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
603 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
604 }
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
605 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
606
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
607 // Not inverted, thus prefix it with a new invertnext.
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
608 LDBFC* bfc = new LDBFC (LDBFC::InvertNext);
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
609 file()->insertObj (idx, bfc);
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
610 }
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
611
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
612 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
613 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
614 static void invertLine (LDObject* line)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
615 { // For lines, we swap the vertices. I don't think that a
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
616 // cond-line's control points need to be swapped, do they?
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
617 vertex tmp = line->getVertex (0);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
618 line->setVertex (0, line->getVertex (1));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
619 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
620 }
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
621
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
622 void LDLine::invert()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
623 { 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
624 }
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
625
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
626 void LDCndLine::invert()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
627 { 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
628 }
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
629
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
630 void LDVertex::invert() {}
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
631
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
632 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
633 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
634 LDLine* LDCndLine::demote()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
635 { LDLine* repl = new LDLine;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
636
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
637 for (int i = 0; i < repl->vertices(); ++i)
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
638 repl->setVertex (i, getVertex (i));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
639
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
640 repl->setColor (color());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
641
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
642 replace (repl);
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
643 return repl;
275
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
644 }
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
645
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
646 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
647 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
648 LDObject* LDObject::fromID (int id)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
649 { for (LDObject * obj : g_LDObjects)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
650 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
651 return obj;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
652
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
653 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
654 }
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
655
316
b4fefda58f43 Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
656 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
657 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
658 str LDOverlay::raw()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
659 { return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6",
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
660 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
661 }
b4fefda58f43 Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
662
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
663 void LDOverlay::move (vertex vect)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
664 { Q_UNUSED (vect)
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
665 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
666
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 459
diff changeset
667 void LDOverlay::invert() {}
307
c731a22899a3 Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 306
diff changeset
668
276
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 // Hook the set accessors of certain properties to this changeProperty function.
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 362
diff changeset
671 // 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
672 // makes history stuff work out of the box.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
673 // -----------------------------------------------------------------------------
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
674 template<class T> static void changeProperty (LDObject* obj, T* ptr, const T& val)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
675 { long idx;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
676
521
b85554206155 changeProperty(): don't change the property if the value would not change, this should save some procecssing..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 516
diff changeset
677 if (*ptr == val)
b85554206155 changeProperty(): don't change the property if the value would not change, this should save some procecssing..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 516
diff changeset
678 return;
b85554206155 changeProperty(): don't change the property if the value would not change, this should save some procecssing..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 516
diff changeset
679
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
680 if (obj->file() && (idx = obj->getIndex()) != -1)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
681 { str before = obj->raw();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
682 *ptr = val;
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
683 str after = obj->raw();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
684
445
15c3af0b5cb7 fixed: LDObject's various methods still assumed that the current file wouldn't change
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
685 obj->file()->addToHistory (new EditHistory (idx, before, after));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
686 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
687 else
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
688 *ptr = val;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
689 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
690
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
691 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
692 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
693 READ_ACCESSOR (short, LDObject::color)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
694 { return m_color;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
695 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
696
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
697 SET_ACCESSOR (short, LDObject::setColor)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
698 { changeProperty (this, &m_color, val);
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
699 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
700
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
701 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
702 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
703 const vertex& LDObject::getVertex (int i) const
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
704 { return m_coords[i]->data();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
705 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
706
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
707 void LDObject::setVertex (int i, const vertex& vert)
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
708 { changeProperty (this, &m_coords[i], LDSharedVertex::getSharedVertex (vert));
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
709 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
710
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
711 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
712 // -----------------------------------------------------------------------------
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
713 void LDMatrixObject::setPosition (const vertex& a)
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
714 { changeProperty (linkPointer(), &m_position, LDSharedVertex::getSharedVertex (a));
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
715 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
716
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
717 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 447
diff changeset
718 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
719 READ_ACCESSOR (matrix, LDMatrixObject::transform)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
720 { return m_transform;
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
721 }
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
722
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
723 SET_ACCESSOR (matrix, LDMatrixObject::setTransform)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
724 { changeProperty (linkPointer(), &m_transform, val);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 486
diff changeset
725 }
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
726
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
727 // =============================================================================
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
728 // -----------------------------------------------------------------------------
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
729 static QMap<vertex, LDSharedVertex*> g_sharedVerts;
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
730
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
731 LDSharedVertex* LDSharedVertex::getSharedVertex (const vertex& a)
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
732 { auto it = g_sharedVerts.find (a);
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
733
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
734 if (it == g_sharedVerts.end())
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
735 { LDSharedVertex* v = new LDSharedVertex (a);
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
736 g_sharedVerts[a] = v;
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
737 return v;
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
738 }
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
739
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
740 return *it;
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
741 }
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
742
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
743 // =============================================================================
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
744 // -----------------------------------------------------------------------------
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
745 void LDSharedVertex::addRef (LDObject* a)
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
746 { m_refs << a;
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
747 }
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
748
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
749 // =============================================================================
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
750 // -----------------------------------------------------------------------------
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
751 void LDSharedVertex::delRef (LDObject* a)
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
752 { m_refs.removeOne (a);
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
753
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
754 if (m_refs.empty())
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
755 { g_sharedVerts.remove (m_data);
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
756 delete this;
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
757 }
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
758 }
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
759
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
760 // =============================================================================
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
761 // -----------------------------------------------------------------------------
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
762 void LDObject::select()
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
763 { if (!file())
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
764 { log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", id());
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
765 return;
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
766 }
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
767
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
768 file()->addToSelection (this);
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
769 }
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
770
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
771 void LDObject::unselect()
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
772 { if (!file())
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
773 { log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", id());
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
774 return;
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
775 }
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
776
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 521
diff changeset
777 file()->removeFromSelection (this);
516
d3373bc7ca3b - added LDSharedVertex class for holding copy-on-write vertices. Will need this for future features..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 506
diff changeset
778 }

mercurial