src/gui_editactions.cpp

Sun, 18 Aug 2013 17:30:58 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 18 Aug 2013 17:30:58 +0300
changeset 458
cb360f4d8979
parent 456
ae4fea87d6a1
child 460
b230ae09c8e5
permissions
-rw-r--r--

Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.

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
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
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.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
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.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
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
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
19 #include <QSpinBox>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
20 #include <QCheckBox>
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
21 #include <QBoxLayout>
368
436ceec98c4f Use system clipboard rather than an internal one
Santeri Piippo <crimsondusk64@gmail.com>
parents: 360
diff changeset
22 #include <QClipboard>
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
23
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "gui.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "common.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include "file.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include "colorSelectDialog.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 #include "misc.h"
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
29 #include "widgets.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 194
diff changeset
30 #include "gldraw.h"
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
31 #include "dialogs.h"
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
32 #include "colors.h"
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
33 #include "ui_replcoords.h"
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
34 #include "ui_editraw.h"
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
35 #include "ui_flip.h"
444
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
36 #include "ui_addhistoryline.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 cfg (bool, edit_schemanticinline, false);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 // =============================================================================
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: 444
diff changeset
41 // -----------------------------------------------------------------------------
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
42 static int copyToClipboard() {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
43 List<LDObject*> objs = g_win->sel();
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
44 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 // Clear the clipboard first.
368
436ceec98c4f Use system clipboard rather than an internal one
Santeri Piippo <crimsondusk64@gmail.com>
parents: 360
diff changeset
47 qApp->clipboard()->clear();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
277
246ca26620ce Clipboard now stores LDraw code rather than object clones, this seems much less prone to problems
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
49 // Now, copy the contents into the clipboard.
368
436ceec98c4f Use system clipboard rather than an internal one
Santeri Piippo <crimsondusk64@gmail.com>
parents: 360
diff changeset
50 str data;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
51
368
436ceec98c4f Use system clipboard rather than an internal one
Santeri Piippo <crimsondusk64@gmail.com>
parents: 360
diff changeset
52 for (LDObject* obj : objs) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
53 if (data.length() > 0)
369
0060d11e4991 handle empty lines better
Santeri Piippo <crimsondusk64@gmail.com>
parents: 368
diff changeset
54 data += "\n";
0060d11e4991 handle empty lines better
Santeri Piippo <crimsondusk64@gmail.com>
parents: 368
diff changeset
55
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
56 data += obj->raw();
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
57 ++num;
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
58 }
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
59
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
60 qApp->clipboard()->setText (data);
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
61 return num;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 // =============================================================================
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: 444
diff changeset
65 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
66 DEFINE_ACTION (Cut, CTRL (X)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
67 int num = copyToClipboard();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
68 g_win->deleteSelection();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
69 log (ForgeWindow::tr ("%1 objects cut"), num);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // =============================================================================
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: 444
diff changeset
73 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
74 DEFINE_ACTION (Copy, CTRL (C)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
75 int num = copyToClipboard();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
76 log (ForgeWindow::tr ("%1 objects copied"), num);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 // =============================================================================
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: 444
diff changeset
80 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
81 DEFINE_ACTION (Paste, CTRL (V)) {
368
436ceec98c4f Use system clipboard rather than an internal one
Santeri Piippo <crimsondusk64@gmail.com>
parents: 360
diff changeset
82 const str clipboardText = qApp->clipboard()->text();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
83 ulong idx = g_win->getInsertionPoint();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
84 g_win->sel().clear();
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
85 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
87 for (str line : clipboardText.split ("\n")) {
277
246ca26620ce Clipboard now stores LDraw code rather than object clones, this seems much less prone to problems
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
88 LDObject* pasted = parseLine (line);
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
89 LDFile::current()->insertObj (idx++, pasted);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
90 g_win->sel() << pasted;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
91 g_win->R()->compileObject (pasted);
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
92 ++num;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
95 log (ForgeWindow::tr ("%1 objects pasted"), num);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
96 g_win->refresh();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
97 g_win->scrollToSelection();
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 // =============================================================================
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: 444
diff changeset
101 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
102 DEFINE_ACTION (Delete, KEY (Delete)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
103 int num = g_win->deleteSelection();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
104 log (ForgeWindow::tr ("%1 objects deleted"), num);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 // =============================================================================
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: 444
diff changeset
108 // -----------------------------------------------------------------------------
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
109 static void doInline (bool deep) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
110 List<LDObject*> sel = g_win->sel();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 for (LDObject* obj : sel) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 // Get the index of the subfile so we know where to insert the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 // inlined contents.
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 387
diff changeset
115 long idx = obj->getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
116
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 if (idx == -1)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
120 List<LDObject*> objs;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 if (obj->getType() == LDObject::Subfile)
458
cb360f4d8979 Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 456
diff changeset
123 objs = static_cast<LDSubfileObject*> (obj)->inlineContents (
cb360f4d8979 Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 456
diff changeset
124 (LDSubfileObject::InlineFlags)
cb360f4d8979 Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 456
diff changeset
125 ((deep) ? LDSubfileObject::DeepInline : 0) |
cb360f4d8979 Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 456
diff changeset
126 LDSubfileObject::CacheInline
cb360f4d8979 Rewrote stud logo support, restructuring inlining stuff in the process. Logoed studs must only be used for rendering scenes, otherwise they will for instance get inlined in and that's not desired, or the vertex snapper will catch onto the logo's coordinates.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 456
diff changeset
127 );
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 else
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 // Merge in the inlined objects
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 for (LDObject* inlineobj : objs) {
360
77f08db90249 when inlining (as an action), reinterpret the inlinees so that there's not any pointer mess-ups
Santeri Piippo <crimsondusk64@gmail.com>
parents: 355
diff changeset
133 str line = inlineobj->raw();
77f08db90249 when inlining (as an action), reinterpret the inlinees so that there's not any pointer mess-ups
Santeri Piippo <crimsondusk64@gmail.com>
parents: 355
diff changeset
134 delete inlineobj;
439
c3421d3f01a2 fixed crashing with inlining
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
135
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
136 LDObject* newobj = parseLine (line);
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
137 LDFile::current()->insertObj (idx++, newobj);
360
77f08db90249 when inlining (as an action), reinterpret the inlinees so that there's not any pointer mess-ups
Santeri Piippo <crimsondusk64@gmail.com>
parents: 355
diff changeset
138 g_win->sel() << newobj;
439
c3421d3f01a2 fixed crashing with inlining
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
139 g_win->R()->compileObject (newobj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 // Delete the subfile now as it's been inlined.
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
143 LDFile::current()->forgetObject (obj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 delete obj;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
147 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
150 DEFINE_ACTION (Inline, CTRL (I)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 doInline (false);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
154 DEFINE_ACTION (InlineDeep, CTRL_SHIFT (I)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 doInline (true);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157
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: 444
diff changeset
158 // =============================================================================
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: 444
diff changeset
159 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
160 DEFINE_ACTION (SplitQuads, 0) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
161 List<LDObject*> objs = g_win->sel();
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
162 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 for (LDObject* obj : objs) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 if (obj->getType() != LDObject::Quad)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 // Find the index of this quad
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 387
diff changeset
169 long index = obj->getIndex();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
171 if (index == -1)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
174 List<LDTriangleObject*> triangles = static_cast<LDQuadObject*> (obj)->splitToTriangles();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 // Replace the quad with the first triangle and add the second triangle
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 // after the first one.
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
178 LDFile::current()->setObject (index, triangles[0]);
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
179 LDFile::current()->insertObj (index + 1, triangles[1]);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 414
diff changeset
181 for (LDTriangleObject * t : triangles)
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 414
diff changeset
182 g_win->R()->compileObject (t);
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
183
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 // Delete this quad now, it has been split.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 delete obj;
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
186
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
187 num++;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
190 log ("%1 quadrilaterals split", num);
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
191 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 444
diff changeset
195 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
196 DEFINE_ACTION (EditRaw, KEY (F9)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
197 if (g_win->sel().size() != 1)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
200 LDObject* obj = g_win->sel() [0];
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
201 QDialog* dlg = new QDialog;
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
202 Ui::EditRawUI ui;
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
203
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
204 ui.setupUi (dlg);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
205 ui.code->setText (obj->raw());
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
206
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
207 if (obj->getType() == LDObject::Error)
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
208 ui.errorDescription->setText (static_cast<LDErrorObject*> (obj)->reason);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
209 else {
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
210 ui.errorDescription->hide();
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
211 ui.errorIcon->hide();
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
212 }
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
213
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
214 if (!dlg->exec())
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
215 return;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
216
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
217 LDObject* oldobj = obj;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
218
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
219 // Reinterpret it from the text of the input field
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
220 obj = parseLine (ui.code->text());
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
221 oldobj->replace (obj);
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
222
279
86a325a6b7c7 Renamed Set Contents into Edit LDraw Code; made the add object dialog's comment line box wider
Santeri Piippo <crimsondusk64@gmail.com>
parents: 277
diff changeset
223 // Refresh
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
224 g_win->R()->compileObject (obj);
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
225 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // =============================================================================
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: 444
diff changeset
229 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
230 DEFINE_ACTION (SetColor, KEY (C)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
231 if (g_win->sel().size() <= 0)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
234 short colnum;
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
235 short defcol = -1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
237 List<LDObject*> objs = g_win->sel();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 // If all selected objects have the same color, said color is our default
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 // value to the color selection dialog.
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
241 defcol = g_win->getSelectedColor();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 // Show the dialog to the user now and ask for a color.
327
9ea604af1319 Largely reworked the color selector. Still not perfect but is better
Santeri Piippo <crimsondusk64@gmail.com>
parents: 326
diff changeset
244 if (ColorSelector::getColor (colnum, defcol, g_win)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 for (LDObject* obj : objs) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
246 if (obj->isColored() == false)
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
247 continue;
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
248
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
249 obj->setColor (colnum);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
250 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
251 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
253 g_win->refresh();
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 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 // =============================================================================
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: 444
diff changeset
258 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
259 DEFINE_ACTION (Borders, CTRL_SHIFT (B)) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
260 List<LDObject*> objs = g_win->sel();
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
261 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 for (LDObject* obj : objs) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 if (obj->getType() != LDObject::Quad && obj->getType() != LDObject::Triangle)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266
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
267 short numLines;
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
268 LDLineObject* lines[4];
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 if (obj->getType() == LDObject::Quad) {
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
271 numLines = 4;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272
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
273 LDQuadObject* quad = static_cast<LDQuadObject*> (obj);
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
274 lines[0] = new LDLineObject (quad->getVertex (0), quad->getVertex (1));
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
275 lines[1] = new LDLineObject (quad->getVertex (1), quad->getVertex (2));
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
276 lines[2] = new LDLineObject (quad->getVertex (2), quad->getVertex (3));
271d1da66b7e Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents: 376
diff changeset
277 lines[3] = new LDLineObject (quad->getVertex (3), quad->getVertex (0));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 } else {
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
279 numLines = 3;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280
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
281 LDTriangleObject* tri = static_cast<LDTriangleObject*> (obj);
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
282 lines[0] = new LDLineObject (tri->getVertex (0), tri->getVertex (1));
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
283 lines[1] = new LDLineObject (tri->getVertex (1), tri->getVertex (2));
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
284 lines[2] = new LDLineObject (tri->getVertex (2), tri->getVertex (0));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286
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
287 for (short i = 0; i < numLines; ++i) {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 387
diff changeset
288 ulong idx = obj->getIndex() + i + 1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
290 lines[i]->setColor (edgecolor);
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
291 LDFile::current()->insertObj (idx, lines[i]);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
292 g_win->R()->compileObject (lines[i]);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 }
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
294
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
295 num += numLines;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
298 log (ForgeWindow::tr ("Added %1 border lines"), num);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
299 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 // =============================================================================
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: 444
diff changeset
303 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
304 DEFINE_ACTION (CornerVerts, 0) {
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
305 int num = 0;
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
306
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
307 for (LDObject* obj : g_win->sel()) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
308 if (obj->vertices() < 2)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 387
diff changeset
311 ulong idx = obj->getIndex();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
312
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 for (short i = 0; i < obj->vertices(); ++i) {
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
314 LDVertexObject* vert = new LDVertexObject;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
315 vert->pos = obj->getVertex (i);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
316 vert->setColor (obj->color());
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
318 LDFile::current()->insertObj (++idx, vert);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
319 g_win->R()->compileObject (vert);
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
320 ++num;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
324 log (ForgeWindow::tr ("Added %1 vertices"), num);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
325 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 // =============================================================================
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: 444
diff changeset
329 // -----------------------------------------------------------------------------
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
330 static void doMoveSelection (const bool up) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
331 List<LDObject*> objs = g_win->sel();
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
332 LDObject::moveObjects (objs, up);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
333 g_win->buildObjList();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 444
diff changeset
336 // =============================================================================
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: 444
diff changeset
337 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
338 DEFINE_ACTION (MoveUp, KEY (PageUp)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 doMoveSelection (true);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
342 DEFINE_ACTION (MoveDown, KEY (PageDown)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 doMoveSelection (false);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 // =============================================================================
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: 444
diff changeset
347 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
348 DEFINE_ACTION (Undo, CTRL (Z)) {
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
349 LDFile::current()->undo();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
351
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
352 DEFINE_ACTION (Redo, CTRL_SHIFT (Z)) {
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
353 LDFile::current()->redo();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 // =============================================================================
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: 444
diff changeset
357 // -----------------------------------------------------------------------------
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
358 void doMoveObjects (vertex vect) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 // Apply the grid values
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
360 vect[X] *= currentGrid().confs[Grid::X]->value;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
361 vect[Y] *= currentGrid().confs[Grid::Y]->value;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
362 vect[Z] *= currentGrid().confs[Grid::Z]->value;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
364 for (LDObject* obj : g_win->sel()) {
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
365 obj->move (vect);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
366 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
367 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
369 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371
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: 444
diff changeset
372 // =============================================================================
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: 444
diff changeset
373 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
374 DEFINE_ACTION (MoveXNeg, KEY (Left)) {
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: 444
diff changeset
375 doMoveObjects ({-1, 0, 0});
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
378 DEFINE_ACTION (MoveYNeg, KEY (Home)) {
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
379 doMoveObjects ({0, -1, 0});
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
382 DEFINE_ACTION (MoveZNeg, KEY (Down)) {
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
383 doMoveObjects ({0, 0, -1});
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
386 DEFINE_ACTION (MoveXPos, KEY (Right)) {
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
387 doMoveObjects ({1, 0, 0});
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
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
390 DEFINE_ACTION (MoveYPos, KEY (End)) {
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
391 doMoveObjects ({0, 1, 0});
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
394 DEFINE_ACTION (MoveZPos, KEY (Up)) {
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
395 doMoveObjects ({0, 0, 1});
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 // =============================================================================
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: 444
diff changeset
399 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
400 DEFINE_ACTION (Invert, CTRL_SHIFT (W)) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
401 List<LDObject*> sel = g_win->sel();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402
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
403 for (LDObject* obj : sel) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
404 obj->invert();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
405 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
406 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
408 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411 // =============================================================================
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: 444
diff changeset
412 // -----------------------------------------------------------------------------
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
413 static void rotateVertex (vertex& v, const vertex& rotpoint, const matrix& transform) {
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
414 v.move (-rotpoint);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
415 v.transform (transform, g_origin);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
416 v.move (rotpoint);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
417 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
418
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: 444
diff changeset
419 // =============================================================================
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: 444
diff changeset
420 // -----------------------------------------------------------------------------
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421 static void doRotate (const short l, const short m, const short n) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
422 List<LDObject*> sel = g_win->sel();
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
423 List<vertex*> queue;
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
424 const vertex rotpoint = rotPoint (sel);
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
425 const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180,
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
426 cosangle = cos (angle),
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
427 sinangle = sin (angle);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
428
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
429 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 414
diff changeset
430 matrix transform ({
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
431 (l * l * (1 - cosangle)) + cosangle,
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
432 (m * l * (1 - cosangle)) - (n * sinangle),
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
433 (n * l * (1 - cosangle)) + (m * sinangle),
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
435 (l * m * (1 - cosangle)) + (n * sinangle),
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
436 (m * m * (1 - cosangle)) + cosangle,
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
437 (n * m * (1 - cosangle)) - (l * sinangle),
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
439 (l * n * (1 - cosangle)) - (m * sinangle),
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
440 (m * n * (1 - cosangle)) + (l * sinangle),
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
441 (n * n * (1 - cosangle)) + cosangle
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 });
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
444 // Apply the above matrix to everything
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445 for (LDObject* obj : sel) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
446 if (obj->vertices()) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
447 for (short i = 0; i < obj->vertices(); ++i) {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
448 vertex v = obj->getVertex (i);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
449 rotateVertex (v, rotpoint, transform);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
450 obj->setVertex (i, v);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
451 }
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
452 } elif (obj->hasMatrix()) {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
453 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj);
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
454
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
455 // Transform the position
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
456 vertex v = mo->position();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
457 rotateVertex (v, rotpoint, transform);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
458 mo->setPosition (v);
456
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
459
ae4fea87d6a1 more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
460 // Transform the matrix
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
461 mo->setTransform (mo->transform() * transform);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
462 } elif (obj->getType() == LDObject::Vertex) {
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
463 LDVertexObject* vert = static_cast<LDVertexObject*> (obj);
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
464 vertex v = vert->pos;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
465 rotateVertex (v, rotpoint, transform);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
466 vert->pos = v;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
467 }
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
468
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
469 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
470 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
471
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
472 g_win->refresh();
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: 444
diff changeset
475 // =============================================================================
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: 444
diff changeset
476 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
477 DEFINE_ACTION (RotateXPos, CTRL (Right)) { doRotate (1, 0, 0); }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
478 DEFINE_ACTION (RotateYPos, CTRL (End)) { doRotate (0, 1, 0); }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
479 DEFINE_ACTION (RotateZPos, CTRL (Up)) { doRotate (0, 0, 1); }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
480 DEFINE_ACTION (RotateXNeg, CTRL (Left)) { doRotate (-1, 0, 0); }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
481 DEFINE_ACTION (RotateYNeg, CTRL (Home)) { doRotate (0, -1, 0); }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
482 DEFINE_ACTION (RotateZNeg, CTRL (Down)) { doRotate (0, 0, -1); }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
484 DEFINE_ACTION (RotationPoint, (0)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
485 configRotationPoint();
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
486 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
487
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488 // =============================================================================
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: 444
diff changeset
489 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
490 DEFINE_ACTION (RoundCoordinates, 0) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 setlocale (LC_ALL, "C");
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
492 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
493
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
494 for (LDObject* obj : g_win->sel())
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
495 for (short i = 0; i < obj->vertices(); ++i) {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
496 vertex v = obj->getVertex (i);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
497
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
498 for (const Axis ax : g_Axes) {
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
499 // HACK: .. should find a better way to do this
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
500 char valstr[64];
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
501 sprintf (valstr, "%.3f", v[ax]);
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
502 v[ax] = atof (valstr);
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
503 }
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
504
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
505 obj->setVertex (i, v);
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 414
diff changeset
506 g_win->R()->compileObject (obj);
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
507 num += 3;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
508 }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
510 log (ForgeWindow::tr ("Rounded %1 coordinates"), num);
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
511 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514 // =============================================================================
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: 444
diff changeset
515 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
516 DEFINE_ACTION (Uncolorize, 0) {
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
517 int num = 0;
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
518
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
519 for (LDObject* obj : g_win->sel()) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
520 if (obj->isColored() == false)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
521 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
522
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
523 int col = maincolor;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
524
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
525 if (obj->getType() == LDObject::Line || obj->getType() == LDObject::CondLine)
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
526 col = edgecolor;
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
527
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
528 obj->setColor (col);
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 414
diff changeset
529 g_win->R()->compileObject (obj);
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 330
diff changeset
530 num++;
183
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
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
533 log (ForgeWindow::tr ("%1 objects uncolored"), num);
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
534 g_win->refresh();
184
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
535 }
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
536
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
537 // =============================================================================
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: 444
diff changeset
538 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
539 DEFINE_ACTION (ReplaceCoords, CTRL (R)) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
540 QDialog* dlg = new QDialog (g_win);
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
541 Ui::ReplaceCoordsUI ui;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
542 ui.setupUi (dlg);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
543
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
544 if (!dlg->exec())
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
545 return;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
546
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
547 const double search = ui.search->value(),
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
548 replacement = ui.replacement->value();
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
549 const bool any = ui.any->isChecked(),
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
550 rel = ui.relative->isChecked();
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
551
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
552 List<Axis> sel;
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
553 int num = 0;
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
554
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
555 if (ui.x->isChecked()) sel << X;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
556 if (ui.y->isChecked()) sel << Y;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
557 if (ui.z->isChecked()) sel << Z;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
558
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
559 for (LDObject* obj : g_win->sel())
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
560 for (short i = 0; i < obj->vertices(); ++i) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
561 vertex v = obj->getVertex (i);
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
562
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
563 for (Axis ax : sel) {
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
564 double& coord = v[ax];
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
565
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
566 if (any || coord == search) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
567 if (!rel)
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
568 coord = 0;
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
569
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
570 coord += replacement;
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
571 num++;
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
572 }
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
573 }
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
574
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
575 obj->setVertex (i, v);
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 414
diff changeset
576 g_win->R()->compileObject (obj);
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
577 }
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
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
579 log (ForgeWindow::tr ("Altered %1 values"), num);
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
580 g_win->refresh();
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
581 }
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
582
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: 444
diff changeset
583 // =============================================================================
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: 444
diff changeset
584 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
585 DEFINE_ACTION (Flip, CTRL_SHIFT (F)) {
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
586 QDialog* dlg = new QDialog;
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
587 Ui::FlipUI ui;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
588 ui.setupUi (dlg);
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
589
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
590 if (!dlg->exec())
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
591 return;
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
592
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
593 List<Axis> sel;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
594 if (ui.x->isChecked()) sel << X;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
595 if (ui.y->isChecked()) sel << Y;
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
596 if (ui.z->isChecked()) sel << Z;
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
597
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
598 for (LDObject* obj : g_win->sel())
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
599 for (short i = 0; i < obj->vertices(); ++i) {
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
600 vertex v = obj->getVertex (i);
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
601
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
602 for (Axis ax : sel)
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
603 v[ax] *= -1;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
604
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
605 obj->setVertex (i, v);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
606 g_win->R()->compileObject (obj);
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 }
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
608
346
ba2db5e22f8b Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
609 g_win->refresh();
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
610 }
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
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: 444
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: 444
diff changeset
613 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
614 DEFINE_ACTION (Demote, 0) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
615 List<LDObject*> sel = g_win->sel();
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
616 int num = 0;
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
617
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
618 for (LDObject* obj : sel) {
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
619 if (obj->getType() != LDObject::CondLine)
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
620 continue;
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
621
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
622 LDLineObject* repl = static_cast<LDCondLineObject*> (obj)->demote();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
623 g_win->R()->compileObject (repl);
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
624 ++num;
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
625 }
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
626
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
627 log (ForgeWindow::tr ("Demoted %1 conditional lines"), num);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
628 g_win->refresh();
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
629 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
630
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: 444
diff changeset
631 // =============================================================================
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: 444
diff changeset
632 // -----------------------------------------------------------------------------
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
633 static bool isColorUsed (short colnum) {
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
634 for (LDObject* obj : LDFile::current()->objs())
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
635 if (obj->isColored() && obj->color() == colnum)
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
636 return true;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
637
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
638 return false;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
639 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
640
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: 444
diff changeset
641 // =============================================================================
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: 444
diff changeset
642 // -----------------------------------------------------------------------------
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
643 DEFINE_ACTION (Autocolor, 0) {
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
644 short colnum = 0;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
645
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
646 while (colnum < MAX_COLORS && (getColor (colnum) == null || isColorUsed (colnum)))
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
647 colnum++;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
648
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
649 if (colnum >= MAX_COLORS) {
321
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 319
diff changeset
650 //: Auto-colorer error message
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
651 critical (ForgeWindow::tr ("Out of unused colors! What are you doing?!"));
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
652 return;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
653 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
654
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
655 for (LDObject* obj : g_win->sel()) {
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
656 if (obj->isColored() == false)
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
657 continue;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
658
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
659 obj->setColor (colnum);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
660 g_win->R()->compileObject (obj);
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
661 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
662
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
663 log (ForgeWindow::tr ("Auto-colored: new color is [%1] %2"), colnum, getColor (colnum)->name);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 369
diff changeset
664 g_win->refresh();
444
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
665 }
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
666
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
667 // =============================================================================
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
668 // -----------------------------------------------------------------------------
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
669 DEFINE_ACTION (AddHistoryLine, 0) {
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
670 LDObject* obj;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
671 bool ishistory = false,
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
672 prevIsHistory = false;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
673
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
674 QDialog* dlg = new QDialog;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
675 Ui_AddHistoryLine* ui = new Ui_AddHistoryLine;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
676 ui->setupUi (dlg);
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
677 ui->m_date->setDate (QDate::currentDate());
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
678 ui->m_comment->setFocus();
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
679
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
680 if (!dlg->exec())
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
681 return;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
682
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
683 // Create the comment object based on input
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
684 str commentText = fmt ("!HISTORY %1 [%2] %3",
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
685 ui->m_date->date().toString("yyyy-MM-dd"),
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
686 ui->m_username->text(),
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
687 ui->m_comment->text());
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
688
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
689 LDCommentObject* comm = new LDCommentObject (commentText);
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
690
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
691 // Find a spot to place the new comment
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
692 for (
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
693 obj = LDFile::current()->object (0);
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
694 obj && obj->next() && !obj->next()->isScemantic();
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
695 obj = obj->next()
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
696 ) {
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
697 LDCommentObject* comm = dynamic_cast<LDCommentObject*> (obj);
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
698 if (comm && comm->text.startsWith ("!HISTORY "))
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
699 ishistory = true;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
700
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
701 if (prevIsHistory && !ishistory) {
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
702 // Last line was history, this isn't, thus insert the new history
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
703 // line here.
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
704 break;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
705 }
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
706
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
707 prevIsHistory = ishistory;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
708 }
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
709
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
710 int idx = obj ? obj->getIndex() : 0;
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
711 LDFile::current()->insertObj (idx++, comm);
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
712
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
713 // If we're adding a history line right before a scemantic object, pad it
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
714 // an empty line
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
715 if (obj && obj->next() && obj->next()->isScemantic())
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
716 LDFile::current()->insertObj (idx, new LDEmptyObject);
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
717
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
718 g_win->buildObjList();
df1b5b902eb7 Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents: 439
diff changeset
719 delete ui;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
720 }

mercurial