Sat, 07 Dec 2013 01:08:52 +0200
renamed LDCndLine to LDCondLine
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 | 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 | 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 | 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" |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
540
diff
changeset
|
25 | #include "main.h" |
183
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 | |
461
fbcc91ae1dd2
- added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
460
diff
changeset
|
38 | cfg (Bool, edit_schemanticinline, false); |
464
3779a14d597c
added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
461
diff
changeset
|
39 | extern_cfg (String, ld_defaultuser); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | // ============================================================================= |
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
|
42 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
43 | static int copyToClipboard() |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
44 | { QList<LDObject*> objs = selection(); |
344
55fcf67230fd
Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents:
330
diff
changeset
|
45 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
46 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | // Clear the clipboard first. |
368
436ceec98c4f
Use system clipboard rather than an internal one
Santeri Piippo <crimsondusk64@gmail.com>
parents:
360
diff
changeset
|
48 | qApp->clipboard()->clear(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
49 | |
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
|
50 | // 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
|
51 | str data; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
52 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
53 | for (LDObject* obj : objs) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
54 | { if (data.length() > 0) |
369
0060d11e4991
handle empty lines better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
368
diff
changeset
|
55 | data += "\n"; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
56 | |
376 | 57 | 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
|
58 | ++num; |
55fcf67230fd
Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents:
330
diff
changeset
|
59 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
60 | |
376 | 61 | 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
|
62 | return num; |
183
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | // ============================================================================= |
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
|
66 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
67 | DEFINE_ACTION (Cut, CTRL (X)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
68 | { int num = copyToClipboard(); |
376 | 69 | g_win->deleteSelection(); |
70 | 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
|
71 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // ============================================================================= |
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
|
74 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
75 | DEFINE_ACTION (Copy, CTRL (C)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
76 | { int num = copyToClipboard(); |
376 | 77 | 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
|
78 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | // ============================================================================= |
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
|
81 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
82 | DEFINE_ACTION (Paste, CTRL (V)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
83 | { const str clipboardText = qApp->clipboard()->text(); |
498
791c831c8020
further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
84 | int idx = g_win->getInsertionPoint(); |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
85 | LDFile::current()->clearSelection(); |
344
55fcf67230fd
Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents:
330
diff
changeset
|
86 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
87 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
88 | for (str line : clipboardText.split ("\n")) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
89 | { LDObject* pasted = parseLine (line); |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
90 | LDFile::current()->insertObj (idx++, pasted); |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
91 | pasted->select(); |
376 | 92 | 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
|
93 | ++num; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
95 | |
376 | 96 | log (ForgeWindow::tr ("%1 objects pasted"), num); |
97 | g_win->refresh(); | |
98 | g_win->scrollToSelection(); | |
183
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
444
diff
changeset
|
102 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
103 | DEFINE_ACTION (Delete, KEY (Delete)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
104 | { int num = g_win->deleteSelection(); |
376 | 105 | 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
|
106 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | // ============================================================================= |
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
|
109 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
110 | static void doInline (bool deep) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
111 | { QList<LDObject*> sel = selection(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
112 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
113 | for (LDObject* obj : sel) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
114 | { // Get the index of the subfile so we know where to insert the |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | // inlined contents. |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
387
diff
changeset
|
116 | long idx = obj->getIndex(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
117 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | if (idx == -1) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
120 | |
504
6a1fa662bfc1
Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
498
diff
changeset
|
121 | QList<LDObject*> objs; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
122 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | if (obj->getType() == LDObject::Subfile) |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
124 | objs = static_cast<LDSubfile*> (obj)->inlineContents ( |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
125 | (LDSubfile::InlineFlags) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
126 | ( (deep) ? LDSubfile::DeepInline : 0) | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
127 | LDSubfile::CacheInline |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
128 | ); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | else |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
131 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | // Merge in the inlined objects |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
133 | for (LDObject * inlineobj : objs) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
134 | { str line = inlineobj->raw(); |
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
|
135 | delete inlineobj; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
136 | |
376 | 137 | LDObject* newobj = parseLine (line); |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
138 | LDFile::current()->insertObj (idx++, newobj); |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
139 | newobj->select(); |
439
c3421d3f01a2
fixed crashing with inlining
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
140 | 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
|
141 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
142 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | // Delete the subfile now as it's been inlined. |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
144 | 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
|
145 | delete obj; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
147 | |
414
0f40c56fde23
some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
148 | g_win->refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
151 | DEFINE_ACTION (Inline, CTRL (I)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
152 | { doInline (false); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
155 | DEFINE_ACTION (InlineDeep, CTRL_SHIFT (I)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
156 | { doInline (true); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | |
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
|
159 | // ============================================================================= |
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
|
160 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
161 | DEFINE_ACTION (SplitQuads, 0) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
162 | { QList<LDObject*> objs = selection(); |
344
55fcf67230fd
Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents:
330
diff
changeset
|
163 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
164 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
165 | for (LDObject* obj : objs) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
166 | { if (obj->getType() != LDObject::Quad) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
168 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | // Find the index of this quad |
388
7ff483614aa1
Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
387
diff
changeset
|
170 | long index = obj->getIndex(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
171 | |
265
955c0aabfebf
Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
172 | if (index == -1) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
174 | |
504
6a1fa662bfc1
Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
498
diff
changeset
|
175 | QList<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
176 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | // 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
|
178 | // after the first one. |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
179 | LDFile::current()->setObject (index, triangles[0]); |
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
180 | LDFile::current()->insertObj (index + 1, triangles[1]); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
181 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
182 | for (LDTriangle* t : triangles) |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
414
diff
changeset
|
183 | g_win->R()->compileObject (t); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
184 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | // 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
|
186 | delete obj; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
187 | |
344
55fcf67230fd
Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents:
330
diff
changeset
|
188 | num++; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
190 | |
376 | 191 | log ("%1 quadrilaterals split", num); |
414
0f40c56fde23
some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
192 | g_win->refresh(); |
183
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | // ============================================================================= |
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
|
196 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
197 | DEFINE_ACTION (EditRaw, KEY (F9)) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
198 | { if (selection().size() != 1) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
200 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
201 | LDObject* obj = selection()[0]; |
330
76505a9c7b56
converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents:
329
diff
changeset
|
202 | QDialog* dlg = new QDialog; |
76505a9c7b56
converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents:
329
diff
changeset
|
203 | Ui::EditRawUI ui; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
204 | |
376 | 205 | ui.setupUi (dlg); |
206 | ui.code->setText (obj->raw()); | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
207 | |
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
|
208 | if (obj->getType() == LDObject::Error) |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
209 | ui.errorDescription->setText (static_cast<LDError*> (obj)->reason); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
210 | else |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
211 | { ui.errorDescription->hide(); |
330
76505a9c7b56
converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents:
329
diff
changeset
|
212 | ui.errorIcon->hide(); |
76505a9c7b56
converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents:
329
diff
changeset
|
213 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
214 | |
376 | 215 | 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
|
216 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
217 | |
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
|
218 | LDObject* oldobj = obj; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
219 | |
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
|
220 | // Reinterpret it from the text of the input field |
376 | 221 | obj = parseLine (ui.code->text()); |
222 | oldobj->replace (obj); | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
223 | |
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
|
224 | // Refresh |
376 | 225 | g_win->R()->compileObject (obj); |
330
76505a9c7b56
converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents:
329
diff
changeset
|
226 | g_win->refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
444
diff
changeset
|
230 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
231 | DEFINE_ACTION (SetColor, KEY (C)) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
232 | { if (selection().isEmpty()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
234 | |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
235 | int colnum; |
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
236 | int defcol = -1; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
237 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
238 | QList<LDObject*> objs = selection(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
239 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | // 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
|
241 | // value to the color selection dialog. |
376 | 242 | defcol = g_win->getSelectedColor(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
243 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // Show the dialog to the user now and ask for a color. |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
245 | if (ColorSelector::selectColor (colnum, defcol, g_win)) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
246 | { for (LDObject* obj : objs) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
247 | { if (obj->isColored() == false) |
221
1dd18eea7c84
Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
220
diff
changeset
|
248 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
249 | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
250 | obj->setColor (colnum); |
376 | 251 | 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
|
252 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
253 | |
376 | 254 | g_win->refresh(); |
183
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | // ============================================================================= |
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
|
259 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
260 | DEFINE_ACTION (Borders, CTRL_SHIFT (B)) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
261 | { QList<LDObject*> objs = selection(); |
326
469bf1fe26e8
applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
262 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
263 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
264 | for (LDObject* obj : objs) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
265 | { const LDObject::Type type = obj->getType(); |
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
266 | if (type != LDObject::Quad && type != LDObject::Triangle) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
268 | |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
269 | int numLines; |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
270 | LDLine* lines[4]; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
271 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
272 | if (type == LDObject::Quad) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
273 | { numLines = 4; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
274 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
275 | LDQuad* quad = static_cast<LDQuad*> (obj); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
276 | lines[0] = new LDLine (quad->getVertex (0), quad->getVertex (1)); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
277 | lines[1] = new LDLine (quad->getVertex (1), quad->getVertex (2)); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
278 | lines[2] = new LDLine (quad->getVertex (2), quad->getVertex (3)); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
279 | lines[3] = new LDLine (quad->getVertex (3), quad->getVertex (0)); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
280 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
281 | else |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
282 | { numLines = 3; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
283 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
284 | LDTriangle* tri = static_cast<LDTriangle*> (obj); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
285 | lines[0] = new LDLine (tri->getVertex (0), tri->getVertex (1)); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
286 | lines[1] = new LDLine (tri->getVertex (1), tri->getVertex (2)); |
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
287 | lines[2] = new LDLine (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
|
288 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
289 | |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
290 | for (int i = 0; i < numLines; ++i) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
291 | { long idx = obj->getIndex() + i + 1; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
292 | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
293 | lines[i]->setColor (edgecolor); |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
294 | LDFile::current()->insertObj (idx, lines[i]); |
376 | 295 | 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
|
296 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
297 | |
326
469bf1fe26e8
applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
298 | num += numLines; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
300 | |
376 | 301 | log (ForgeWindow::tr ("Added %1 border lines"), num); |
302 | g_win->refresh(); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | // ============================================================================= |
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
|
306 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
307 | DEFINE_ACTION (CornerVerts, 0) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
308 | { int num = 0; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
309 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
310 | for (LDObject* obj : selection()) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
311 | { 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
|
312 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
313 | |
498
791c831c8020
further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
314 | int idx = obj->getIndex(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
315 | |
498
791c831c8020
further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
316 | for (int i = 0; i < obj->vertices(); ++i) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
317 | { LDVertex* vert = new LDVertex; |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
318 | vert->pos = obj->getVertex (i); |
539
72ad83a67165
- upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
538
diff
changeset
|
319 | vert->setColor (obj->getColor()); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
320 | |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
321 | LDFile::current()->insertObj (++idx, vert); |
376 | 322 | g_win->R()->compileObject (vert); |
326
469bf1fe26e8
applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
323 | ++num; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
326 | |
376 | 327 | log (ForgeWindow::tr ("Added %1 vertices"), num); |
328 | g_win->refresh(); | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | // ============================================================================= |
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
|
332 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
333 | static void doMoveSelection (const bool up) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
334 | { QList<LDObject*> objs = selection(); |
265
955c0aabfebf
Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
335 | LDObject::moveObjects (objs, up); |
376 | 336 | g_win->buildObjList(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | |
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
|
339 | // ============================================================================= |
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
|
340 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
341 | DEFINE_ACTION (MoveUp, KEY (PageUp)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
342 | { doMoveSelection (true); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
345 | DEFINE_ACTION (MoveDown, KEY (PageDown)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
346 | { doMoveSelection (false); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
444
diff
changeset
|
350 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
351 | DEFINE_ACTION (Undo, CTRL (Z)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
352 | { LDFile::current()->undo(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
355 | DEFINE_ACTION (Redo, CTRL_SHIFT (Z)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
356 | { LDFile::current()->redo(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | // ============================================================================= |
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
|
360 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
361 | void doMoveObjects (vertex vect) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
362 | { // Apply the grid values |
376 | 363 | vect[X] *= currentGrid().confs[Grid::X]->value; |
364 | vect[Y] *= currentGrid().confs[Grid::Y]->value; | |
365 | vect[Z] *= currentGrid().confs[Grid::Z]->value; | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
366 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
367 | for (LDObject* obj : selection()) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
368 | { obj->move (vect); |
376 | 369 | 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
|
370 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
371 | |
376 | 372 | g_win->refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | |
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 | // ============================================================================= |
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
|
376 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
377 | DEFINE_ACTION (MoveXNeg, KEY (Left)) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
378 | { 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
|
379 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
381 | DEFINE_ACTION (MoveYNeg, KEY (Home)) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
382 | { 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
|
383 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
385 | DEFINE_ACTION (MoveZNeg, KEY (Down)) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
386 | { 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
|
387 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
389 | DEFINE_ACTION (MoveXPos, KEY (Right)) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
390 | { 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
|
391 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
393 | DEFINE_ACTION (MoveYPos, KEY (End)) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
394 | { 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
|
395 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
397 | DEFINE_ACTION (MoveZPos, KEY (Up)) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
398 | { 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
|
399 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | // ============================================================================= |
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
|
402 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
403 | DEFINE_ACTION (Invert, CTRL_SHIFT (W)) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
404 | { QList<LDObject*> sel = selection(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
405 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
406 | for (LDObject* obj : sel) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
407 | { obj->invert(); |
376 | 408 | 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
|
409 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
410 | |
376 | 411 | g_win->refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | // ============================================================================= |
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
|
415 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
416 | static void rotateVertex (vertex& v, const vertex& rotpoint, const matrix& transform) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
417 | { v.move (-rotpoint); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
418 | v.transform (transform, g_origin); |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
419 | v.move (rotpoint); |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
420 | } |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
421 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
444
diff
changeset
|
422 | // ============================================================================= |
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
|
423 | // ----------------------------------------------------------------------------- |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
424 | static void doRotate (const int l, const int m, const int n) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
425 | { QList<LDObject*> sel = selection(); |
504
6a1fa662bfc1
Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
498
diff
changeset
|
426 | QList<vertex*> queue; |
268
778eed342ee4
Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
427 | const vertex rotpoint = rotPoint (sel); |
456 | 428 | const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180, |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
429 | cosangle = cos (angle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
430 | sinangle = sin (angle); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
431 | |
456 | 432 | // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
433 | matrix transform ( |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
434 | { (l* l * (1 - cosangle)) + cosangle, |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
435 | (m* l * (1 - cosangle)) - (n* sinangle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
436 | (n* l * (1 - cosangle)) + (m* sinangle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
437 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
438 | (l* m * (1 - cosangle)) + (n* sinangle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
439 | (m* m * (1 - cosangle)) + cosangle, |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
440 | (n* m * (1 - cosangle)) - (l* sinangle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
441 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
442 | (l* n * (1 - cosangle)) - (m* sinangle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
443 | (m* n * (1 - cosangle)) + (l* sinangle), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
444 | (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
|
445 | }); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
446 | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
447 | // Apply the above matrix to everything |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
448 | for (LDObject* obj : sel) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
449 | { if (obj->vertices()) |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
450 | { for (int i = 0; i < obj->vertices(); ++i) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
451 | { vertex v = obj->getVertex (i); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
452 | rotateVertex (v, rotpoint, transform); |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
453 | obj->setVertex (i, v); |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
454 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
455 | } elif (obj->hasMatrix()) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
456 | { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
457 | |
456 | 458 | // Transform the position |
540
0334789cb4d7
- Changed the callback parm of PROPERTY to a stock/custom write method argument.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
539
diff
changeset
|
459 | vertex v = mo->getPosition(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
460 | rotateVertex (v, rotpoint, transform); |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
461 | mo->setPosition (v); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
462 | |
456 | 463 | // Transform the matrix |
539
72ad83a67165
- upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
538
diff
changeset
|
464 | mo->setTransform (mo->getTransform() * transform); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
465 | } elif (obj->getType() == LDObject::Vertex) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
466 | { LDVertex* vert = static_cast<LDVertex*> (obj); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
467 | vertex v = vert->pos; |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
468 | rotateVertex (v, rotpoint, transform); |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
469 | vert->pos = v; |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
470 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
471 | |
376 | 472 | 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
|
473 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
474 | |
376 | 475 | g_win->refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | |
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
|
478 | // ============================================================================= |
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
|
479 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
480 | DEFINE_ACTION (RotateXPos, CTRL (Right)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
481 | { doRotate (1, 0, 0); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
482 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
483 | DEFINE_ACTION (RotateYPos, CTRL (End)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
484 | { doRotate (0, 1, 0); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
485 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
486 | DEFINE_ACTION (RotateZPos, CTRL (Up)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
487 | { doRotate (0, 0, 1); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
488 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
489 | DEFINE_ACTION (RotateXNeg, CTRL (Left)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
490 | { doRotate (-1, 0, 0); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
491 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
492 | DEFINE_ACTION (RotateYNeg, CTRL (Home)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
493 | { doRotate (0, -1, 0); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
494 | } |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
495 | DEFINE_ACTION (RotateZNeg, CTRL (Down)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
496 | { doRotate (0, 0, -1); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
497 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
499 | DEFINE_ACTION (RotationPoint, (0)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
500 | { configRotationPoint(); |
211
8d35e631bef3
Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents:
205
diff
changeset
|
501 | } |
8d35e631bef3
Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents:
205
diff
changeset
|
502 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | // ============================================================================= |
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
|
504 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
505 | DEFINE_ACTION (RoundCoordinates, 0) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
506 | { setlocale (LC_ALL, "C"); |
326
469bf1fe26e8
applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
507 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
508 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
509 | for (LDObject* obj : selection()) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
510 | { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
511 | |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
512 | if (mo != null) |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
513 | { vertex v = mo->getPosition(); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
514 | matrix t = mo->getTransform(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
515 | |
508
7ace3537a560
removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents:
504
diff
changeset
|
516 | for (const Axis ax : g_Axes) |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
517 | roundToDecimals (v[ax], 3); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
518 | |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
519 | // Let matrix values be rounded to 4 decimals, |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
520 | // they need that extra precision |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
521 | for (int i = 0; i < 9; ++i) |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
522 | roundToDecimals (t[i], 4); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
523 | |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
524 | mo->setPosition (v); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
525 | mo->setTransform (t); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
526 | num += 10; |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
527 | } |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
528 | else |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
529 | { for (int i = 0; i < obj->vertices(); ++i) |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
530 | { vertex v = obj->getVertex (i); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
531 | |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
532 | for (const Axis ax : g_Axes) |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
533 | roundToDecimals (v[ax], 3); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
534 | |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
535 | obj->setVertex (i, v); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
536 | g_win->R()->compileObject (obj); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
537 | num += 3; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
538 | } |
286
7a562bf3d829
Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
283
diff
changeset
|
539 | } |
508
7ace3537a560
removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents:
504
diff
changeset
|
540 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
541 | |
542
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
542 | log (ForgeWindow::tr ("Rounded %1 values"), num); |
46a33bdc0b36
- Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
543 | g_win->refreshObjectList(); |
414
0f40c56fde23
some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
544 | g_win->refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
545 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | // ============================================================================= |
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
|
548 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
549 | DEFINE_ACTION (Uncolorize, 0) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
550 | { int num = 0; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
551 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
552 | for (LDObject* obj : selection()) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
553 | { 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
|
554 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
555 | |
344
55fcf67230fd
Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents:
330
diff
changeset
|
556 | int col = maincolor; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
557 | |
551
0efe5dbcef07
renamed LDCndLine to LDCondLine
Santeri Piippo <crimsondusk64@gmail.com>
parents:
542
diff
changeset
|
558 | 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
|
559 | col = edgecolor; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
560 | |
376 | 561 | obj->setColor (col); |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
414
diff
changeset
|
562 | 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
|
563 | num++; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
565 | |
376 | 566 | log (ForgeWindow::tr ("%1 objects uncolored"), num); |
414
0f40c56fde23
some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
567 | 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
|
568 | } |
fae3bc9ce319
Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
569 | |
fae3bc9ce319
Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
570 | // ============================================================================= |
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
|
571 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
572 | DEFINE_ACTION (ReplaceCoords, CTRL (R)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
573 | { QDialog* dlg = new QDialog (g_win); |
329
76db02dc7f60
Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
327
diff
changeset
|
574 | Ui::ReplaceCoordsUI ui; |
376 | 575 | ui.setupUi (dlg); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
576 | |
376 | 577 | if (!dlg->exec()) |
190
82f784cf2ce5
Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
578 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
579 | |
329
76db02dc7f60
Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
327
diff
changeset
|
580 | const double search = ui.search->value(), |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
581 | replacement = ui.replacement->value(); |
329
76db02dc7f60
Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
327
diff
changeset
|
582 | const bool any = ui.any->isChecked(), |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
583 | rel = ui.relative->isChecked(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
584 | |
504
6a1fa662bfc1
Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
498
diff
changeset
|
585 | QList<Axis> sel; |
329
76db02dc7f60
Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
327
diff
changeset
|
586 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
587 | |
376 | 588 | if (ui.x->isChecked()) sel << X; |
589 | if (ui.y->isChecked()) sel << Y; | |
590 | if (ui.z->isChecked()) sel << Z; | |
591 | ||
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
592 | for (LDObject* obj : selection()) |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
593 | { for (int i = 0; i < obj->vertices(); ++i) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
594 | { vertex v = obj->getVertex (i); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
595 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
596 | for (Axis ax : sel) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
597 | { double& coord = v[ax]; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
598 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
599 | if (any || coord == search) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
600 | { if (!rel) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
601 | coord = 0; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
602 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
603 | coord += replacement; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
604 | num++; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
605 | } |
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
|
606 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
607 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
608 | obj->setVertex (i, v); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
609 | g_win->R()->compileObject (obj); |
190
82f784cf2ce5
Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
610 | } |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
611 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
612 | |
376 | 613 | log (ForgeWindow::tr ("Altered %1 values"), num); |
414
0f40c56fde23
some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents:
409
diff
changeset
|
614 | 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
|
615 | } |
c414924a647c
Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
191
diff
changeset
|
616 | |
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
|
617 | // ============================================================================= |
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
|
618 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
619 | DEFINE_ACTION (Flip, CTRL_SHIFT (F)) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
620 | { QDialog* dlg = new QDialog; |
346
ba2db5e22f8b
Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents:
344
diff
changeset
|
621 | Ui::FlipUI ui; |
376 | 622 | ui.setupUi (dlg); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
623 | |
376 | 624 | if (!dlg->exec()) |
346
ba2db5e22f8b
Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents:
344
diff
changeset
|
625 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
626 | |
504
6a1fa662bfc1
Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
498
diff
changeset
|
627 | QList<Axis> sel; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
628 | |
376 | 629 | if (ui.x->isChecked()) sel << X; |
630 | if (ui.y->isChecked()) sel << Y; | |
631 | if (ui.z->isChecked()) sel << Z; | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
632 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
633 | for (LDObject* obj : selection()) |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
634 | { for (int i = 0; i < obj->vertices(); ++i) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
635 | { vertex v = obj->getVertex (i); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
636 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
637 | for (Axis ax : sel) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
638 | v[ax] *= -1; |
376 | 639 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
640 | obj->setVertex (i, v); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
641 | g_win->R()->compileObject (obj); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
642 | } |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
643 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
644 | |
346
ba2db5e22f8b
Converted flip prompt to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents:
344
diff
changeset
|
645 | g_win->refresh(); |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
646 | } |
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
647 | |
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
|
648 | // ============================================================================= |
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
|
649 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
650 | DEFINE_ACTION (Demote, 0) |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
651 | { QList<LDObject*> sel = selection(); |
326
469bf1fe26e8
applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
652 | int num = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
653 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
654 | for (LDObject* obj : sel) |
551
0efe5dbcef07
renamed LDCndLine to LDCondLine
Santeri Piippo <crimsondusk64@gmail.com>
parents:
542
diff
changeset
|
655 | { 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
|
656 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
657 | |
551
0efe5dbcef07
renamed LDCndLine to LDCondLine
Santeri Piippo <crimsondusk64@gmail.com>
parents:
542
diff
changeset
|
658 | LDLine* repl = static_cast<LDCondLine*> (obj)->demote(); |
376 | 659 | g_win->R()->compileObject (repl); |
326
469bf1fe26e8
applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
660 | ++num; |
214
28e0b37156be
Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
661 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
662 | |
376 | 663 | log (ForgeWindow::tr ("Demoted %1 conditional lines"), num); |
664 | 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
|
665 | } |
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
666 | |
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
|
667 | // ============================================================================= |
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
|
668 | // ----------------------------------------------------------------------------- |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
669 | static bool isColorUsed (int colnum) |
539
72ad83a67165
- upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
538
diff
changeset
|
670 | { for (LDObject* obj : LDFile::current()->getObjects()) |
72ad83a67165
- upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
538
diff
changeset
|
671 | if (obj->isColored() && obj->getColor() == colnum) |
220
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
672 | return true; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
673 | |
220
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
674 | return false; |
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
675 | } |
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
676 | |
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
|
677 | // ============================================================================= |
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
|
678 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
679 | DEFINE_ACTION (Autocolor, 0) |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
680 | { int colnum = 0; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
681 | |
382
c1642530ea35
Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
682 | 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
|
683 | colnum++; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
684 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
685 | if (colnum >= MAX_COLORS) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
686 | { log (ForgeWindow::tr ("Cannot auto-color: all colors are in use!")); |
220
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
687 | return; |
1f368f0a323b
Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
215
diff
changeset
|
688 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
689 | |
522
afa691788bdb
- migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
508
diff
changeset
|
690 | for (LDObject* obj : selection()) |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
691 | { 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
|
692 | continue; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
693 | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
694 | obj->setColor (colnum); |
376 | 695 | 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
|
696 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
697 | |
376 | 698 | log (ForgeWindow::tr ("Auto-colored: new color is [%1] %2"), colnum, getColor (colnum)->name); |
699 | g_win->refresh(); | |
444
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 | |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
702 | // ============================================================================= |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
703 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
704 | DEFINE_ACTION (AddHistoryLine, 0) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
705 | { LDObject* obj; |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
706 | bool ishistory = false, |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
707 | prevIsHistory = false; |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
708 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
709 | QDialog* dlg = new QDialog; |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
710 | 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
|
711 | ui->setupUi (dlg); |
464
3779a14d597c
added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
461
diff
changeset
|
712 | ui->m_username->setText (ld_defaultuser); |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
713 | 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
|
714 | ui->m_comment->setFocus(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
715 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
716 | if (!dlg->exec()) |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
717 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
718 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
719 | // 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
|
720 | str commentText = fmt ("!HISTORY %1 [%2] %3", |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
721 | ui->m_date->date().toString ("yyyy-MM-dd"), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
722 | ui->m_username->text(), |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
723 | ui->m_comment->text()); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
724 | |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
725 | LDComment* comm = new LDComment (commentText); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
726 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
727 | // 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
|
728 | for ( |
538
2f85d4d286e5
- ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents:
522
diff
changeset
|
729 | obj = LDFile::current()->getObject (0); |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
730 | 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
|
731 | obj = obj->next() |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
732 | ) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
733 | { LDComment* comm = dynamic_cast<LDComment*> (obj); |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
734 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
735 | 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
|
736 | ishistory = true; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
737 | |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
738 | if (prevIsHistory && !ishistory) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
739 | { // Last line was history, this isn't, thus insert the new history |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
740 | // line here. |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
741 | break; |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
742 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
743 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
744 | prevIsHistory = ishistory; |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
745 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
746 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
747 | 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
|
748 | LDFile::current()->insertObj (idx++, comm); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
749 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
750 | // 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
|
751 | // an empty line |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
752 | if (obj && obj->next() && obj->next()->isScemantic()) |
460
b230ae09c8e5
Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents:
458
diff
changeset
|
753 | LDFile::current()->insertObj (idx, new LDEmpty); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
754 | |
444
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
755 | g_win->buildObjList(); |
df1b5b902eb7
Added action "add history line" for adding new history entries
Santeri Piippo <crimsondusk64@gmail.com>
parents:
439
diff
changeset
|
756 | delete ui; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
484
diff
changeset
|
757 | } |