src/gui_editactions.cpp

Thu, 04 Jul 2013 18:56:34 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 04 Jul 2013 18:56:34 +0300
changeset 330
76505a9c7b56
parent 329
76db02dc7f60
child 344
55fcf67230fd
permissions
-rw-r--r--

converted the raw edit prompt

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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
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.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
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.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
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>
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
22
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "gui.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "common.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "file.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include "colorSelectDialog.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include "historyDialog.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"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "extprogs.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 194
diff changeset
31 #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
32 #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
33 #include "colors.h"
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
34 #include "ui_replcoords.h"
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
35 #include "ui_editraw.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
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
37 vector<str> g_Clipboard;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 cfg (bool, edit_schemanticinline, false);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // =============================================================================
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
44 static void copyToClipboard () {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 vector<LDObject*> objs = g_win->sel ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46
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.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 g_Clipboard.clear ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
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.
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
51 for (LDObject* obj : objs)
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
52 g_Clipboard << obj->raw ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) {
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
59 copyToClipboard ();
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
60 g_win->deleteSelection ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 copyToClipboard ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 ulong idx = g_win->getInsertionPoint ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 g_win->sel ().clear ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
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
77 for (str line : g_Clipboard) {
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
78 LDObject* pasted = parseLine (line);
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
79 g_curfile->insertObj (idx++, pasted);
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
80 g_win->sel () << pasted;
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
81 g_win->R ()->compileObject (pasted);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
84 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 g_win->scrollToSelection ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 MAKE_ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) {
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
92 g_win->deleteSelection ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 // =============================================================================
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
98 static void doInline (bool deep) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 vector<LDObject*> sel = g_win->sel ();
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 for (LDObject* obj : sel) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 // Get the index of the subfile so we know where to insert the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 // inlined contents.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 long idx = obj->getIndex (g_curfile);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 if (idx == -1)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 continue;
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 vector<LDObject*> objs;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 if (obj->getType() == LDObject::Subfile)
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
111 objs = static_cast<LDSubfile*> (obj)->inlineContents (deep, true);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 else
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 // Merge in the inlined objects
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 for (LDObject* inlineobj : objs) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 // This object is now inlined so it has no parent anymore.
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
118 inlineobj->setParent (null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 g_curfile->insertObj (idx++, inlineobj);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 // Delete the subfile now as it's been inlined.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 g_curfile->forgetObject (obj);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 delete obj;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126
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
127 g_win->fullRefresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 MAKE_ACTION (inlineContents, "Inline", "inline", "Inline selected subfiles.", CTRL (I)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 doInline (false);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 MAKE_ACTION (deepInline, "Deep Inline", "inline-deep", "Recursively inline selected subfiles "
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 "down to polygons only.", CTRL_SHIFT (I))
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 doInline (true);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
140 // ===============================================================================================
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
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 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 vector<LDObject*> objs = g_win->sel ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 for (LDObject* obj : objs) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 if (obj->getType() != LDObject::Quad)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 continue;
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 // Find the index of this quad
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
151 long index = obj->getIndex (g_curfile);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
153 if (index == -1)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
156 vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles ();
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 // 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
159 // after the first one.
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
160 g_curfile->setObject (index, triangles[0]);
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
161 g_curfile->insertObj (index + 1, triangles[1]);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 // 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
164 delete obj;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166
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
167 g_win->fullRefresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 // =============================================================================
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
173 MAKE_ACTION( setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY( F9 ))
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
174 {
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
175 if( g_win->sel().size() != 1 )
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
178 LDObject* obj = g_win->sel()[0];
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
179 QDialog* dlg = new QDialog;
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
180 Ui::EditRawUI ui;
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
181
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
182 ui.setupUi( dlg );
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
183 ui.code->setText( obj->raw() );
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
184
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
185 if( obj->getType() == LDObject::Gibberish )
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
186 ui.errorDescription->setText( static_cast<LDGibberish*>( obj )->reason );
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
187 else
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
188 {
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
189 ui.errorDescription->hide();
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
190 ui.errorIcon->hide();
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
191 }
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
192
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
193 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
194 return;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
195
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
196 LDObject* oldobj = obj;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
197
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
198 // Reinterpret it from the text of the input field
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
199 obj = parseLine( ui.code->text() );
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
200 oldobj->replace( obj );
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
201
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
202 // Refresh
330
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
203 g_win->R()->compileObject( obj );
76505a9c7b56 converted the raw edit prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 329
diff changeset
204 g_win->refresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 // =============================================================================
243
a7c72c847634 Changed shortcut of Set Color to C, like MLCAD
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
210 MAKE_ACTION (setColor, "Set Color", "palette", "Set the color on given objects.", KEY (C)) {
a7c72c847634 Changed shortcut of Set Color to C, like MLCAD
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
211 if (g_win->sel ().size () <= 0)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
214 short colnum;
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
215 short defcol = -1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
217 vector<LDObject*> objs = g_win->sel ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 // 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
220 // value to the color selection dialog.
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
221 defcol = g_win->getSelectedColor ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 // Show the dialog to the user now and ask for a color.
327
9ea604af1319 Largely reworked the color selector. Still not perfect but is better
Santeri Piippo <crimsondusk64@gmail.com>
parents: 326
diff changeset
224 if (ColorSelector::getColor (colnum, defcol, g_win)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 for (LDObject* obj : objs) {
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
226 if (obj->isColored () == false)
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
227 continue;
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
228
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
229 obj->setColor (colnum);
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
230 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
231 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
233 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 // =============================================================================
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
240 MAKE_ACTION (makeBorders, "Make Borders", "make-borders", "Add borders around given polygons.", CTRL_SHIFT (B)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 vector<LDObject*> objs = g_win->sel ();
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
242 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 for (LDObject* obj : objs) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 if (obj->getType() != LDObject::Quad && obj->getType() != LDObject::Triangle)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
248 short numLines;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 LDLine* lines[4];
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 if (obj->getType() == LDObject::Quad) {
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
252 numLines = 4;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 LDQuad* quad = static_cast<LDQuad*> (obj);
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
255 lines[0] = new LDLine (quad->getVertex (0), quad->getVertex (1));
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
256 lines[1] = new LDLine (quad->getVertex (1), quad->getVertex (2));
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
257 lines[2] = new LDLine (quad->getVertex (2), quad->getVertex (3));
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
258 lines[3] = new LDLine (quad->getVertex (3), quad->getVertex (0));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 } else {
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
260 numLines = 3;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 LDTriangle* tri = static_cast<LDTriangle*> (obj);
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
263 lines[0] = new LDLine (tri->getVertex (0), tri->getVertex (1));
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
264 lines[1] = new LDLine (tri->getVertex (1), tri->getVertex (2));
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
265 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
266 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
268 for (short i = 0; i < numLines; ++i) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 ulong idx = obj->getIndex (g_curfile) + i + 1;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
271 lines[i]->setColor (edgecolor);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 g_curfile->insertObj (idx, lines[i]);
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
273 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
274 }
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
275
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
276 num += numLines;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
279 log( ForgeWindow::tr( "Added %1 border lines" ), num );
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
280 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 MAKE_ACTION (makeCornerVerts, "Make Corner Vertices", "corner-verts",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 "Adds vertex objects to the corners of the given polygons", (0))
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 {
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
289 int num = 0;
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
290
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 for (LDObject* obj : g_win->sel ()) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 if (obj->vertices () < 2)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295 ulong idx = obj->getIndex (g_curfile);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 for (short i = 0; i < obj->vertices(); ++i) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 LDVertex* vert = new LDVertex;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
298 vert->pos = obj->getVertex (i);
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
299 vert->setColor (obj->color ());
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 g_curfile->insertObj (++idx, vert);
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
302 g_win->R ()->compileObject (vert);
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
303 ++num;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
307 log( ForgeWindow::tr( "Added %1 vertices" ), num );
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
308 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 // =============================================================================
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
314 static void doMoveSelection (const bool up) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 vector<LDObject*> objs = g_win->sel ();
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
316 LDObject::moveObjects (objs, up);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 g_win->buildObjList ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 279
diff changeset
320 MAKE_ACTION (moveUp, "Move Up", "arrow-up", "Move the current selection up.", KEY (PageUp)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 doMoveSelection (true);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 279
diff changeset
324 MAKE_ACTION (moveDown, "Move Down", "arrow-down", "Move the current selection down.", KEY (PageDown)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325 doMoveSelection (false);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 // =============================================================================
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 MAKE_ACTION (undo, "Undo", "undo", "Undo a step.", CTRL (Z)) {
274
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
332 g_curfile->undo ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 MAKE_ACTION (redo, "Redo", "redo", "Redo a step.", CTRL_SHIFT (Z)) {
274
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
336 g_curfile->redo ();
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 MAKE_ACTION (showHistory, "Edit History", "history", "Show the history dialog.", (0)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340 HistoryDialog dlg;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 dlg.exec ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
342 }
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 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 // =============================================================================
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
347 void doMoveObjects (vertex vect) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 // Apply the grid values
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
349 vect[X] *= currentGrid ().confs[Grid::X]->value;
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
350 vect[Y] *= currentGrid ().confs[Grid::Y]->value;
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
351 vect[Z] *= currentGrid ().confs[Grid::Z]->value;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 for (LDObject* obj : g_win->sel ()) {
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
354 obj->move (vect);
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
355 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
356 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
358 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 MAKE_ACTION (moveXNeg, "Move -X", "move-x-neg", "Move selected objects negative on the X axis.", KEY (Left)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 doMoveObjects ({-1, 0, 0});
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 279
diff changeset
365 MAKE_ACTION (moveYNeg, "Move -Y", "move-y-neg", "Move selected objects negative on the Y axis.", KEY (Home)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 doMoveObjects ({0, -1, 0});
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 MAKE_ACTION (moveZNeg, "Move -Z", "move-z-neg", "Move selected objects negative on the Z axis.", KEY (Down)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 doMoveObjects ({0, 0, -1});
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 MAKE_ACTION (moveXPos, "Move +X", "move-x-pos", "Move selected objects positive on the X axis.", KEY (Right)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 doMoveObjects ({1, 0, 0});
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 279
diff changeset
377 MAKE_ACTION (moveYPos, "Move +Y", "move-y-pos", "Move selected objects positive on the Y axis.", KEY (End)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 doMoveObjects ({0, 1, 0});
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381 MAKE_ACTION (moveZPos, "Move +Z", "move-z-pos", "Move selected objects positive on the Z axis.", KEY (Up)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 doMoveObjects ({0, 0, 1});
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 MAKE_ACTION (invert, "Invert", "invert", "Reverse the winding of given objects.", CTRL_SHIFT (W)) {
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
387 vector<LDObject*> sel = g_win->sel ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388
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
389 for (LDObject* obj : sel) {
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
390 obj->invert ();
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
391 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
392 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
394 g_win->refresh ();
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 // =============================================================================
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
398 static void rotateVertex (vertex& v, const vertex& rotpoint, const matrix& transform) {
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
399 v.move (-rotpoint);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
400 v.transform (transform, g_origin);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
401 v.move (rotpoint);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
402 }
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
403
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404 static void doRotate (const short l, const short m, const short n) {
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
405 vector<LDObject*> sel = g_win->sel ();
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
406 vector<vertex*> queue;
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
407 const vertex rotpoint = rotPoint (sel);
212
79c5205b807c Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
408 const double angle = (pi * currentGrid ().confs[Grid::Angle]->value) / 180;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
411 const double cosangle = cos (angle),
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
412 sinangle = sin (angle);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
413
191
9bb6a17305ad Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 190
diff changeset
414 matrix transform ({
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
415 (l * l * (1 - cosangle)) + cosangle,
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
416 (m * l * (1 - cosangle)) - (n * sinangle),
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
417 (n * l * (1 - cosangle)) + (m * sinangle),
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
419 (l * m * (1 - cosangle)) + (n * sinangle),
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
420 (m * m * (1 - cosangle)) + cosangle,
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
421 (n * m * (1 - cosangle)) - (l * sinangle),
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
423 (l * n * (1 - cosangle)) - (m * sinangle),
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
424 (m * n * (1 - cosangle)) + (l * sinangle),
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
425 (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
426 });
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
428 // Apply the above matrix to everything
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 for (LDObject* obj : sel) {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
430 if (obj->vertices ()) {
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
431 for (short i = 0; i < obj->vertices (); ++i) {
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
432 vertex v = obj->getVertex (i);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
433 rotateVertex (v, rotpoint, transform);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
434 obj->setVertex (i, v);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
435 }
319
d0f41342ef51 Show values in file opening prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
436 } elif (obj->hasMatrix ()) {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
437 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
438 vertex v = mo->position ();
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
439 rotateVertex (v, rotpoint, transform);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
440 mo->setPosition (v);
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
441 mo->setTransform (mo->transform () * transform);
319
d0f41342ef51 Show values in file opening prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
442 } elif (obj->getType () == LDObject::Vertex) {
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
443 LDVertex* vert = static_cast<LDVertex*> (obj);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
444 vertex v = vert->pos;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
445 rotateVertex (v, rotpoint, transform);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
446 vert->pos = v;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
447 }
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
448
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
449 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
450 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451
194
cfe9ae5f1124 Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
452 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
455 MAKE_ACTION (rotateXPos, "Rotate +X", "rotate-x-pos", "Rotate objects around X axis", CTRL (Right)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
456 doRotate (1, 0, 0);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
458
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 279
diff changeset
459 MAKE_ACTION (rotateYPos, "Rotate +Y", "rotate-y-pos", "Rotate objects around Y axis", CTRL (End)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460 doRotate (0, 1, 0);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463 MAKE_ACTION (rotateZPos, "Rotate +Z", "rotate-z-pos", "Rotate objects around Z axis", CTRL (Up)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464 doRotate (0, 0, 1);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 MAKE_ACTION (rotateXNeg, "Rotate -X", "rotate-x-neg", "Rotate objects around X axis", CTRL (Left)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
468 doRotate (-1, 0, 0);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 279
diff changeset
471 MAKE_ACTION (rotateYNeg, "Rotate -Y", "rotate-y-neg", "Rotate objects around Y axis", CTRL (Home)) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 doRotate (0, -1, 0);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 MAKE_ACTION (rotateZNeg, "Rotate -Z", "rotate-z-neg", "Rotate objects around Z axis", CTRL (Down)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 doRotate (0, 0, -1);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
479 // =========================================================================================================================================
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
480 MAKE_ACTION (rotpoint, "Set Rotation Point", "rotpoint", "Configure the rotation point.", (0)) {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
481 configRotationPoint ();
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
482 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
483
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
485 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
486 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
487 MAKE_ACTION (roundCoords, "Round Coordinates", "round-coords", "Round coordinates down to 3/4 decimals", (0)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488 setlocale (LC_ALL, "C");
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
489 int num = 0;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
490
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 for (LDObject* obj : g_win->sel ())
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
492 for (short i = 0; i < obj->vertices (); ++i) {
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
493 vertex v = obj->getVertex (i);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
494
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
495 for (const Axis ax : g_Axes) {
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
496 // HACK: :p
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
497 char valstr[64];
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
498 sprintf (valstr, "%.3f", v[ax]);
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
499 v[ax] = atof (valstr);
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
500 }
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
501
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
502 obj->setVertex (i, v);
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
503 num += 3;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
504 }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
506 log( ForgeWindow::tr( "Rounded %1 coordinates" ), num );
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
507 g_win->fullRefresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
508 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513 MAKE_ACTION (uncolorize, "Uncolorize", "uncolorize", "Reduce colors of everything selected to main and edge colors", (0)) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514 for (LDObject* obj : g_win->sel ()) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
515 if (obj->isColored () == false)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
516 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
517
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
518 obj->setColor ((obj->getType () == LDObject::Line || obj->getType () == LDObject::CondLine) ? edgecolor : maincolor);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
519 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
520
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
521 g_win->fullRefresh ();
184
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
522 }
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
523
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
524 // =============================================================================
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
525 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
526 // =============================================================================
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
527 MAKE_ACTION (ytruder, "Ytruder", "ytruder", "Extrude selected lines to a given plane", (0)) {
184
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
528 runYtruder ();
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
529 }
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
530
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
531 MAKE_ACTION (rectifier, "Rectifier", "rectifier", "Optimizes quads into rect primitives.", (0)) {
184
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
532 runRectifier ();
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
533 }
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
534
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
535 MAKE_ACTION (intersector, "Intersector", "intersector", "Perform clipping between two input groups.", (0)) {
184
fae3bc9ce319 Move external prog actions into gui_actions.cpp because linking order changed
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
536 runIntersector ();
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 188
diff changeset
537 }
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 188
diff changeset
538
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
539 MAKE_ACTION (coverer, "Coverer", "coverer", "Fill the space between two line shapes", (0)) {
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
540 runCoverer ();
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
541 }
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
542
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
543 MAKE_ACTION (isecalc, "Isecalc", "isecalc", "Compute intersection between objects", (0)) {
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
544 runIsecalc ();
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
545 }
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
546
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
547 // =============================================================================
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
548 MAKE_ACTION( replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL( R ))
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
549 {
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
550 QDialog* dlg = new QDialog( g_win );
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
551 Ui::ReplaceCoordsUI ui;
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
552 ui.setupUi( dlg );
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
553
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
554 if( !dlg->exec() )
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
555 return;
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
556
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
557 const double search = ui.search->value(),
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
558 replacement = ui.replacement->value();
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
559 const bool any = ui.any->isChecked(),
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
560 rel = ui.relative->isChecked();
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
561
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
562 vector<Axis> sel;
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
563 int num = 0;
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
564
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
565 if( ui.x->isChecked() ) sel << X;
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
566 if( ui.y->isChecked() ) sel << Y;
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
567 if( ui.z->isChecked() ) sel << Z;
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
568
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
569 for( LDObject * obj : g_win->sel() )
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
570 for( short i = 0; i < obj->vertices(); ++i )
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
571 {
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
572 vertex v = obj->getVertex( i );
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
573
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
574 for( Axis ax : sel )
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
575 {
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
576 double& coord = v[ax];
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
577
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
578 if( any || coord == search )
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
579 {
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
580 if( !rel )
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
581 coord = 0;
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
582
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
583 coord += replacement;
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
584 num++;
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
585 }
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
586 }
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
587
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
588 obj->setVertex( i, v );
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
589 }
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
590
329
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
591 log( ForgeWindow::tr( "Altered %1 values" ), num );
76db02dc7f60 Designerified the replace coordinates action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 327
diff changeset
592 g_win->fullRefresh();
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
593 }
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
594
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
595 // =================================================================================================
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
596 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
597 // =================================================================================================
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
598 class FlipDialog : public QDialog {
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
599 public:
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
600 explicit FlipDialog (QWidget* parent = 0, Qt::WindowFlags f = 0) : QDialog (parent, f) {
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
601 cbg_axes = makeAxesBox ();
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
602
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
603 QVBoxLayout* layout = new QVBoxLayout;
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
604 layout->addWidget (cbg_axes);
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
605 layout->addWidget (makeButtonBox (*this));
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
606 setLayout (layout);
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
607 }
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
608
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
609 vector<int> axes () { return cbg_axes->checkedValues (); }
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
610
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
611 private:
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
612 CheckBoxGroup* cbg_axes;
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
613 };
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
614
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
615 // ================================================================================================
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
616 MAKE_ACTION (flip, "Flip", "flip", "Flip coordinates", CTRL_SHIFT (F)) {
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
617 FlipDialog dlg;
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
618
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
619 if (!dlg.exec ())
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
620 return;
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
621
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
622 vector<int> sel = dlg.axes ();
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
623
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
624 for (LDObject* obj : g_win->sel ())
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
625 for (short i = 0; i < obj->vertices (); ++i) {
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
626 vertex v = obj->getVertex (i);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
627
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
628 for (int ax : sel)
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
629 v[(Axis) ax] *= -1;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
630
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
631 obj->setVertex (i, v);
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
632 }
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
633
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
634 g_win->fullRefresh ();
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
635 }
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
636
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
637 // ================================================================================================
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
638 MAKE_ACTION (demote, "Demote conditional lines", "demote", "Demote conditional lines down to normal lines.", (0)) {
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
639 vector<LDObject*> sel = g_win->sel ();
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
640 int num = 0;
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
641
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
642 for (LDObject* obj : sel) {
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
643 if (obj->getType () != LDObject::CondLine)
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
644 continue;
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
645
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
646 LDLine* repl = static_cast<LDCondLine*> (obj)->demote ();
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
647 g_win->R ()->compileObject (repl);
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
648 ++num;
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
649 }
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
650
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
651 log( ForgeWindow::tr( "Demoted %1 conditional lines" ), num );
214
28e0b37156be Added demote function for making conditional lines normal lines
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
652 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
653 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
654
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 262
diff changeset
655 // =================================================================================================
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
656 static bool isColorUsed (short colnum) {
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 243
diff changeset
657 for (LDObject* obj : g_curfile->objs ())
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
658 if (obj->isColored () && obj->color () == colnum)
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
659 return true;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
660
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
661 return false;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
662 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
663
221
1dd18eea7c84 Add some missing icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 220
diff changeset
664 MAKE_ACTION (autoColor, "Autocolor", "autocolor", "Set the color of the given object to the first found unused color.", (0)) {
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
665 short colnum = 0;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
666
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
667 while (colnum < 512 && (getColor (colnum) == null || isColorUsed (colnum)))
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
668 colnum++;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
669
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
670 if (colnum >= 512) {
321
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 319
diff changeset
671 //: Auto-colorer error message
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
672 critical( ForgeWindow::tr( "Out of unused colors! What are you doing?!" ));
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
673 return;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
674 }
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 for (LDObject* obj : g_win->sel ()) {
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
677 if (obj->isColored () == false)
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
678 continue;
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
679
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
680 obj->setColor (colnum);
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
681 g_win->R ()->compileObject (obj);
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
682 }
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
683
326
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
684 log( ForgeWindow::tr( "Auto-colored: new color is [%1] %2" ), colnum, getColor( colnum )->name );
469bf1fe26e8 applied message log to some actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
685
220
1f368f0a323b Added auto-coloring, this colors objects with the first found unused color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 215
diff changeset
686 g_win->refresh ();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
687 }

mercurial