gui_editactions.cpp

Sun, 21 Apr 2013 16:36:20 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 21 Apr 2013 16:36:20 +0300
changeset 121
7e87c85ad092
parent 120
607301744394
child 122
33c227d0fa1b
permissions
-rw-r--r--

Rotation improvements; allow radials be inlined

79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "gui.h"
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "common.h"
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
21 #include "file.h"
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
22 #include "history.h"
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
23 #include "zz_colorSelectDialog.h"
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
24 #include "zz_historyDialog.h"
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "zz_setContentsDialog.h"
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
26 #include "misc.h"
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
27 #include "bbox.h"
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 vector<LDObject*> g_Clipboard;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 static bool copyToClipboard () {
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
35 vector<LDObject*> objs = g_ForgeWindow->selection ();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 if (objs.size() == 0)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 return false;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 // Clear the clipboard first.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 for (LDObject* obj : g_Clipboard)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 delete obj;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 g_Clipboard.clear ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 // Now, copy the contents into the clipboard. The objects should be
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 // separate objects so that modifying the existing ones does not affect
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 // the clipboard. Thus, we add clones of the objects to the clipboard, not
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 // the objects themselves.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 for (ulong i = 0; i < objs.size(); ++i)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 g_Clipboard.push_back (objs[i]->clone ());
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 return true;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) {
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
60 vector<ulong> ulaIndices;
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
61 vector<LDObject*> copies;
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
62
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 if (!copyToClipboard ())
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 return;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
66 g_ForgeWindow->deleteSelection (&ulaIndices, &copies);
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
67 History::addEntry (new DelHistory (ulaIndices, copies, DelHistory::Cut));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 copyToClipboard ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) {
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
81 vector<ulong> ulaIndices;
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
82 vector<LDObject*> paCopies;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83
110
a62ab18d1b80 Added select by type. Selection is now preserved over operations.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
84 ulong idx = g_ForgeWindow->getInsertionPoint ();
a62ab18d1b80 Added select by type. Selection is now preserved over operations.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
85
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
86 for (LDObject* obj : g_Clipboard) {
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
87 ulaIndices.push_back (idx);
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
88 paCopies.push_back (obj->clone ());
110
a62ab18d1b80 Added select by type. Selection is now preserved over operations.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
89
a62ab18d1b80 Added select by type. Selection is now preserved over operations.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
90 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + idx++, obj->clone ());
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
91 }
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
92
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
93 History::addEntry (new AddHistory (ulaIndices, paCopies, AddHistory::Paste));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 g_ForgeWindow->refresh ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) {
85
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
101 vector<ulong> ulaIndices;
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
102 vector<LDObject*> copies;
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
103
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
104 g_ForgeWindow->deleteSelection (&ulaIndices, &copies);
85
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
105
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 93
diff changeset
106 if (copies.size ())
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
107 History::addEntry (new DelHistory (ulaIndices, copies));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 static void doInline (bool bDeep) {
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
114 vector<LDObject*> sel = g_ForgeWindow->selection ();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115
98
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
116 // History stuff
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
117 vector<LDSubfile*> paRefs;
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
118 vector<ulong> ulaRefIndices, ulaBitIndices;
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
119
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
120 for (LDObject* obj : sel) {
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
121 if (obj->getType() != OBJ_Subfile)
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
122 continue;
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
123
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
124 ulaRefIndices.push_back (obj->getIndex (g_CurrentFile));
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
125 paRefs.push_back (static_cast<LDSubfile*> (obj)->clone ());
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
126 }
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
127
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 for (LDObject* obj : sel) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 // Get the index of the subfile so we know where to insert the
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 // inlined contents.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 long idx = obj->getIndex (g_CurrentFile);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 if (idx == -1)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 continue;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
135 vector<LDObject*> objs;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
137 if (obj->getType() == OBJ_Subfile)
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
138 objs = static_cast<LDSubfile*> (obj)->inlineContents (bDeep, true);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
139 else if (obj->getType() == OBJ_Radial)
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
140 objs = static_cast<LDRadial*> (obj)->decompose (true);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
141 else
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
142 continue;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 // Merge in the inlined objects
98
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
145 for (LDObject* inlineobj : objs) {
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
146 ulaBitIndices.push_back (idx);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
147
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
148 // This object is now inlined so it has no parent anymore.
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
149 inlineobj->parent = null;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
150
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + idx++, inlineobj);
98
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
152 }
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 // Delete the subfile now as it's been inlined.
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
155 g_CurrentFile->forgetObject (obj);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
156 delete obj;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158
98
5dcc551f260a Added inlining history management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
159 History::addEntry (new InlineHistory (ulaBitIndices, ulaRefIndices, paRefs, bDeep));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 g_ForgeWindow->refresh ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 ACTION (inlineContents, "Inline", "inline", "Inline selected subfiles.", CTRL (I)) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 doInline (false);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 ACTION (deepInline, "Deep Inline", "inline-deep", "Recursively inline selected subfiles "
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 "down to polygons only.", CTRL_SHIFT (I))
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 doInline (true);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) {
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
177 vector<LDObject*> objs = g_ForgeWindow->selection ();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178
93
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
179 vector<ulong> ulaIndices;
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
180 vector<LDQuad*> paCopies;
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
181
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
182 // Store stuff first for history archival
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
183 for (LDObject* obj : objs) {
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
184 if (obj->getType() != OBJ_Quad)
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
185 continue;
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
186
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
187 ulaIndices.push_back (obj->getIndex (g_CurrentFile));
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
188 paCopies.push_back (static_cast<LDQuad*> (obj)->clone ());
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
189 }
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
190
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 for (LDObject* obj : objs) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 if (obj->getType() != OBJ_Quad)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 continue;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 // Find the index of this quad
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 long lIndex = obj->getIndex (g_CurrentFile);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197
93
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
198 if (lIndex == -1)
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 return;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 std::vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 // Replace the quad with the first triangle and add the second triangle
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 // after the first one.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 g_CurrentFile->objects[lIndex] = triangles[0];
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + lIndex + 1, triangles[1]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 // Delete this quad now, it has been split.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 delete obj;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211
93
92682e6369e9 Added history handling for quad splitting.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 92
diff changeset
212 History::addEntry (new QuadSplitHistory (ulaIndices, paCopies));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 g_ForgeWindow->refresh ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.", KEY (F9)) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 if (g_ForgeWindow->qObjList->selectedItems().size() != 1)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 return;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
223 LDObject* obj = g_ForgeWindow->selection ()[0];
90
03f718ed5b33 Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 89
diff changeset
224 SetContentsDialog::staticDialog (obj);
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 ACTION (setColor, "Set Color", "palette", "Set the color on given objects.", KEY (F10)) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 if (g_ForgeWindow->qObjList->selectedItems().size() <= 0)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 return;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 short dColor;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 short dDefault = -1;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
237 std::vector<LDObject*> objs = g_ForgeWindow->selection ();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 // If all selected objects have the same color, said color is our default
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 // value to the color selection dialog.
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
241 dDefault = g_ForgeWindow->getSelectedColor ();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 // Show the dialog to the user now and ask for a color.
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 if (ColorSelectDialog::staticDialog (dColor, dDefault, g_ForgeWindow)) {
89
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
245 std::vector<ulong> ulaIndices;
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
246 std::vector<short> daColors;
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
247
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
248 for (LDObject* obj : objs) {
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
249 if (obj->dColor != -1) {
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
250 ulaIndices.push_back (obj->getIndex (g_CurrentFile));
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
251 daColors.push_back (obj->dColor);
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
252
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 obj->dColor = dColor;
89
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
254 }
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
255 }
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256
89
5e6c08e98dbf Allow undo of set color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 85
diff changeset
257 History::addEntry (new SetColorHistory (ulaIndices, daColors, dColor));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 g_ForgeWindow->refresh ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 // =============================================================================
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265 ACTION (makeBorders, "Make Borders", "make-borders", "Add borders around given polygons.",
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 CTRL_SHIFT (B))
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 {
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
268 vector<LDObject*> objs = g_ForgeWindow->selection ();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269
92
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
270 vector<ulong> ulaIndices;
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
271 vector<LDObject*> paObjs;
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
272
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 for (LDObject* obj : objs) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 if (obj->getType() != OBJ_Quad && obj->getType() != OBJ_Triangle)
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 continue;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 short dNumLines;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 LDLine* lines[4];
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 if (obj->getType() == OBJ_Quad) {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 dNumLines = 4;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 LDQuad* quad = static_cast<LDQuad*> (obj);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 lines[0] = new LDLine (quad->vaCoords[0], quad->vaCoords[1]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 lines[1] = new LDLine (quad->vaCoords[1], quad->vaCoords[2]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 lines[2] = new LDLine (quad->vaCoords[2], quad->vaCoords[3]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 lines[3] = new LDLine (quad->vaCoords[3], quad->vaCoords[0]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 } else {
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 dNumLines = 3;
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 LDTriangle* tri = static_cast<LDTriangle*> (obj);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 lines[0] = new LDLine (tri->vaCoords[0], tri->vaCoords[1]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 lines[1] = new LDLine (tri->vaCoords[1], tri->vaCoords[2]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 lines[2] = new LDLine (tri->vaCoords[2], tri->vaCoords[0]);
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 for (short i = 0; i < dNumLines; ++i) {
92
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
298 ulong idx = obj->getIndex (g_CurrentFile) + i + 1;
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
299
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 lines[i]->dColor = dEdgeColor;
92
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
301 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + idx, lines[i]);
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
302
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
303 ulaIndices.push_back (idx);
586d294ca83f Added history management for auto-bordering (and mass-addition in general)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
304 paObjs.push_back (lines[i]->clone ());
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 }
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
308 History::addEntry (new AddHistory (ulaIndices, paObjs));
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 g_ForgeWindow->refresh ();
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 }
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
311
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
312 // =============================================================================
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
314 // =============================================================================
103
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
315 ACTION (makeCornerVerts, "Make Corner Vertices", "corner-verts",
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
316 "Adds vertex objects to the corners of the given polygons", (0))
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
317 {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
318 vector<ulong> ulaIndices;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
319 vector<LDObject*> paObjs;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
320
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
321 for (LDObject* obj : g_ForgeWindow->selection ()) {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
322 vertex* vaCoords = null;
103
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
323 ushort uNumCoords = 0;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
324
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
325 switch (obj->getType ()) {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
326 case OBJ_Quad:
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
327 uNumCoords = 4;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
328 vaCoords = static_cast<LDQuad*> (obj)->vaCoords;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
329 break;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
330
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
331 case OBJ_Triangle:
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
332 uNumCoords = 3;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
333 vaCoords = static_cast<LDTriangle*> (obj)->vaCoords;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
334 break;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
335
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
336 case OBJ_Line:
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
337 uNumCoords = 2;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
338 vaCoords = static_cast<LDLine*> (obj)->vaCoords;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
339 break;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
340
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
341 default:
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
342 break;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
343 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
344
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
345 ulong idx = obj->getIndex (g_CurrentFile);
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
346 for (ushort i = 0; i < uNumCoords; ++i) {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
347 LDVertex* pVert = new LDVertex;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
348 pVert->vPosition = vaCoords[i];
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
349 pVert->dColor = obj->dColor;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
350
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
351 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ++idx, pVert);
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
352 ulaIndices.push_back (idx);
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
353 paObjs.push_back (pVert->clone ());
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
354 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
355 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
356
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
357 if (ulaIndices.size() > 0) {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
358 History::addEntry (new AddHistory (ulaIndices, paObjs));
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
359 g_ForgeWindow->refresh ();
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
360 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
361 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
362
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
363 // =============================================================================
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
365 // =============================================================================
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
366 static void doMoveSelection (const bool bUp) {
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
367 vector<LDObject*> objs = g_ForgeWindow->selection ();
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
368
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
369 // Get the indices of the objects for history archival
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
370 vector<ulong> ulaIndices;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
371 for (LDObject* obj : objs)
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
372 ulaIndices.push_back (obj->getIndex (g_CurrentFile));
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
373
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
374 LDObject::moveObjects (objs, bUp);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
375 History::addEntry (new ListMoveHistory (ulaIndices, bUp));
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
376 g_ForgeWindow->buildObjList ();
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
377 }
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
378
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
379 ACTION (moveUp, "Move Up", "arrow-up", "Move the current selection up.", SHIFT (Up)) {
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
380 doMoveSelection (true);
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
381 }
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
382
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
383 ACTION (moveDown, "Move Down", "arrow-down", "Move the current selection down.", SHIFT (Down)) {
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
384 doMoveSelection (false);
85
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
385 }
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
386
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
387 // =============================================================================
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
389 // =============================================================================
85
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
390 ACTION (undo, "Undo", "undo", "Undo a step.", CTRL (Z)) {
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
391 History::undo ();
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
392 }
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
393
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
394 ACTION (redo, "Redo", "redo", "Redo a step.", CTRL_SHIFT (Z)) {
b1541b547c8c Added undo/redo foundations. Capable of undoing and redoing delete operations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
395 History::redo ();
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
396 }
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
397
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
398 ACTION (showHistory, "Show History", "history", "Show the history dialog.", (0)) {
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
399 HistoryDialog dlg;
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
400 dlg.exec ();
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
401 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
402
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
403 // =============================================================================
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
404 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
405 // =============================================================================
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
406 void doMoveObjects (const vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
407 vector<ulong> ulaIndices;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
408
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
409 for (LDObject* obj : g_ForgeWindow->selection ()) {
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
410 ulaIndices.push_back (obj->getIndex (g_CurrentFile));
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
411 obj->move (vVector);
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
412 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
413
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
414 History::addEntry (new MoveHistory (ulaIndices, vVector));
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
415 g_ForgeWindow->refresh ();
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
416 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
417
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
418 ACTION (moveXNeg, "Move -X", "move-x-neg", "Move selected objects negative on the X axis.", KEY (Left)) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
419 doMoveObjects ({-1, 0, 0});
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
420 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
421
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
422 ACTION (moveYNeg, "Move -Y", "move-y-neg", "Move selected objects negative on the Y axis.", KEY (PageUp)) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
423 doMoveObjects ({0, -1, 0});
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
424 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
425
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
426 ACTION (moveZNeg, "Move -Z", "move-z-neg", "Move selected objects negative on the Z axis.", KEY (Down)) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
427 doMoveObjects ({0, 0, -1});
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
428 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
429
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
430 ACTION (moveXPos, "Move +X", "move-x-pos", "Move selected objects positive on the X axis.", KEY (Right)) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
431 doMoveObjects ({1, 0, 0});
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
432 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
433
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
434 ACTION (moveYPos, "Move +Y", "move-y-pos", "Move selected objects positive on the Y axis.", KEY (PageDown)) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
435 doMoveObjects ({0, 1, 0});
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
436 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
437
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
438 ACTION (moveZPos, "Move +Z", "move-z-pos", "Move selected objects positive on the Z axis.", KEY (Up)) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
439 doMoveObjects ({0, 0, 1});
118
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
440 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
441
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
442 // =============================================================================
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
443 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
444 // invert - reverse winding
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
445 //
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
446 // NOTE: History management gets a little tricky here. For lines, cond-lines,
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
447 // triangles and quads, we edit the object, thus we record an EditHistory. For
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
448 // subfiles and radials we create or delete invertnext objects. Since we have
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
449 // multiple actions of different types, we store a history entry for each of
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
450 // them and wrap them into a ComboHistory, which allows storage of multiple
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
451 // simultaneous edits with different type. This is what we ultimately store into
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
452 // History.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
453 // =============================================================================
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
454 ACTION (invert, "Invert", "invert", "Reverse the winding of given objects.", CTRL_SHIFT (W)) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
455 std::vector<LDObject*> paSelection = g_ForgeWindow->selection ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
456 std::vector<HistoryEntry*> paHistory;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
457
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
458 for (LDObject* obj : paSelection) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
459 // For the objects we end up editing, we store information into these
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
460 // variables and we store them into an EditHistory after the switch
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
461 // block. Subfile and radial management is stored into the history
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
462 // list immediately.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
463 ulong ulHistoryIndex = obj->getIndex (g_CurrentFile);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
464 LDObject* pOldCopy, *pNewCopy;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
465 bool bEdited = false;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
466
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
467 switch (obj->getType ()) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
468 case OBJ_Line:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
469 case OBJ_CondLine:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
470 {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
471 // For lines, we swap the vertices. I don't think that a
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
472 // cond-line's control points need to be swapped, do they?
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
473 LDLine* pLine = static_cast<LDLine*> (obj);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
474 vertex vTemp = pLine->vaCoords[0];
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
475
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
476 pOldCopy = pLine->clone ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
477 pLine->vaCoords[0] = pLine->vaCoords[1];
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
478 pLine->vaCoords[1] = vTemp;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
479 pNewCopy = pLine->clone ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
480 bEdited = true;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
481 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
482 break;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
483
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
484 case OBJ_Triangle:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
485 {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
486 // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
487 // Thus, we swap 1 and 2.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
488 LDTriangle* pTri = static_cast<LDTriangle*> (obj);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
489 vertex vTemp = pTri->vaCoords[1];
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
490
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
491 pOldCopy = pTri->clone ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
492 pTri->vaCoords[1] = pTri->vaCoords[2];
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
493 pTri->vaCoords[2] = vTemp;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
494 pNewCopy = pTri->clone ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
495 bEdited = true;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
496 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
497 break;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
498
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
499 case OBJ_Quad:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
500 {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
501 // Quad: 0 -> 1 -> 2 -> 3
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
502 // rev: 0 -> 3 -> 2 -> 1
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
503 // Thus, we swap 1 and 3.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
504 LDQuad* pQuad = static_cast<LDQuad*> (obj);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
505 vertex vTemp = pQuad->vaCoords[1];
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
506
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
507 pOldCopy = pQuad->clone ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
508 pQuad->vaCoords[1] = pQuad->vaCoords[3];
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
509 pQuad->vaCoords[3] = vTemp;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
510 pNewCopy = pQuad->clone ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
511 bEdited = true;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
512 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
513 break;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
514
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
515 case OBJ_Subfile:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
516 case OBJ_Radial:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
517 {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
518 // Subfiles and radials are inverted when they're prefixed with
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
519 // a BFC INVERTNEXT statement. Thus we need to toggle this status.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
520 // For flat primitives it's sufficient that the determinant is
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
521 // flipped but I don't have a method for checking flatness yet.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
522 // Food for thought...
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
523
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
524 bool inverted = false;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
525 ulong idx = obj->getIndex (g_CurrentFile);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
526
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
527 if (idx > 0) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
528 LDObject* prev = g_CurrentFile->object (idx - 1);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
529 LDBFC* bfc = dynamic_cast<LDBFC*> (prev);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
530
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
531 if (bfc && bfc->eStatement == LDBFC::InvertNext) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
532 // Object is prefixed with an invertnext, thus remove it.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
533 paHistory.push_back (new DelHistory ({idx - 1}, {bfc->clone ()}));
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
534
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
535 inverted = true;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
536 g_CurrentFile->forgetObject (bfc);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
537 delete bfc;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
538 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
539 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
540
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
541 if (!inverted) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
542 // Not inverted, thus prefix it with a new invertnext.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
543 LDBFC* bfc = new LDBFC (LDBFC::InvertNext);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
544 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin () + idx, bfc);
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
545
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
546 paHistory.push_back (new AddHistory ({idx}, {bfc->clone ()}));
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
547 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
548 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
549 break;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
550
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
551 default:
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
552 break;
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
553 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
554
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
555 // If we edited this object, store the EditHistory based on collected
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
556 // information now.
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
557 if (bEdited == true)
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
558 paHistory.push_back (new EditHistory ({ulHistoryIndex}, {pOldCopy}, {pNewCopy}));
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
559 }
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
560
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
561 if (paHistory.size () > 0) {
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
562 History::addEntry (new ComboHistory (paHistory));
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
563 g_ForgeWindow->refresh ();
649110bb36a8 Added winding reversal, though undoing it isn't quite ready yet.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
564 }
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
565 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
566
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
567 // =============================================================================
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
568 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
569 // =============================================================================
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
570 static void doRotate (const short l, const short m, const short n) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
571 std::vector<LDObject*> sel = g_ForgeWindow->selection ();
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
572 bbox box;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
573 vertex origin;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
574 std::vector<vertex*> queue;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
575
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
576 // TODO: generalize the angle
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
577 const double angle = (pi * 22.5f) / 360;
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
578
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
579 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
580 matrix transform (
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
581 (l * l * (1 - cos (angle))) + cos (angle),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
582 (m * l * (1 - cos (angle))) - (n * sin (angle)),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
583 (n * l * (1 - cos (angle))) + (m * sin (angle)),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
584
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
585 (l * m * (1 - cos (angle))) + (n * sin (angle)),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
586 (m * m * (1 - cos (angle))) + cos (angle),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
587 (n * m * (1 - cos (angle))) - (l * sin (angle)),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
588
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
589 (l * n * (1 - cos (angle))) - (m * sin (angle)),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
590 (m * n * (1 - cos (angle))) + (l * sin (angle)),
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
591 (n * n * (1 - cos (angle))) + cos (angle)
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
592 );
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
593
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
594 // Calculate center vertex
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
595 for (LDObject* obj : sel)
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
596 box << obj;
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
597
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
598 origin = box.center ();
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
599 printf ("origin: %s\n", origin.getStringRep (true).chars ());
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
600
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
601 // Apply the above matrix to everything
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
602 for (LDObject* obj : sel) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
603 if (obj->vertices ())
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
604 for (short i = 0; i < obj->vertices (); ++i)
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
605 queue.push_back (&obj->vaCoords[i]);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
606 else if (obj->getType () == OBJ_Subfile) {
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
607 LDSubfile* ref = static_cast<LDSubfile*> (obj);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
608
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
609 queue.push_back (&ref->vPosition);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
610 ref->mMatrix = ref->mMatrix * transform;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
611 } else if (obj->getType () == OBJ_Radial) {
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
612 LDRadial* rad = static_cast<LDRadial*> (obj);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
613
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
614 queue.push_back (&rad->vPosition);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
615 // rad->mMatrix = rad->mMatrix * transform;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
616 } else if (obj->getType () == OBJ_Vertex)
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
617 queue.push_back (&static_cast<LDVertex*> (obj)->vPosition);
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
618 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
619
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
620 for (vertex* v : queue) {
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
621 v->move (-origin);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
622 v->transform (transform, g_Origin);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
623 v->move (origin);
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
624 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
625
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
626 g_ForgeWindow->refresh ();
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
627 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
628
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
629 ACTION (rotateXPos, "Rotate +X", "rotate-x-pos", "Rotate objects around X axis", CTRL (Right)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
630 doRotate (1, 0, 0);
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
631 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
632
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
633 ACTION (rotateYPos, "Rotate +Y", "rotate-y-pos", "Rotate objects around Y axis", CTRL (PageDown)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
634 doRotate (0, 1, 0);
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
635 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
636
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
637 ACTION (rotateZPos, "Rotate +Z", "rotate-z-pos", "Rotate objects around Z axis", CTRL (Up)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
638 doRotate (0, 0, 1);
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
639 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
640
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
641 ACTION (rotateXNeg, "Rotate -X", "rotate-x-neg", "Rotate objects around X axis", CTRL (Left)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
642 doRotate (-1, 0, 0);
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
643 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
644
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
645 ACTION (rotateYNeg, "Rotate -Y", "rotate-y-neg", "Rotate objects around Y axis", CTRL (PageUp)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
646 doRotate (0, -1, 0);
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
647 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
648
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
649 ACTION (rotateZNeg, "Rotate -Z", "rotate-z-neg", "Rotate objects around Z axis", CTRL (Down)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
650 doRotate (0, 0, -1);
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
651 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
652
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
653 // =============================================================================
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
654 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
655 // =============================================================================
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
656 ACTION (roundCoords, "Round Coordinates", "round-coords", "Round coordinates down to 3/4 decimals", (0)) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
657 setlocale (LC_ALL, "C");
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
658
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
659 for (LDObject* obj : g_ForgeWindow->selection ()) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
660 for (short i = 0; i < obj->vertices (); ++i) {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
661 double* coords[3] = {
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
662 &obj->vaCoords[i].x,
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
663 &obj->vaCoords[i].y,
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
664 &obj->vaCoords[i].z,
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
665 };
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
666
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
667 for (double* coord : coords)
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
668 *coord = atof (format ("%.3f", *coord));
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
669 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
670 }
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
671
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
672 g_ForgeWindow->refresh ();
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
673 }

mercurial