Tue, 09 Apr 2013 18:23:07 +0300
Added a button to clear a keyboard shortcut.
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
3 | * Copyright (C) 2013 Santeri `arezey` Piippo |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
18 | |
0 | 19 | #include <QtGui> |
20 | ||
21 | #include "common.h" | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
22 | #include "gldraw.h" |
0 | 23 | #include "gui.h" |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
24 | #include "file.h" |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
25 | #include "config.h" |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
26 | #include "misc.h" |
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
27 | #include "colors.h" |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
28 | #include "config.h" |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
29 | |
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:
78
diff
changeset
|
30 | EXTERN_ACTION (newFile) |
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:
78
diff
changeset
|
31 | EXTERN_ACTION (open) |
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:
78
diff
changeset
|
32 | EXTERN_ACTION (save) |
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:
78
diff
changeset
|
33 | EXTERN_ACTION (saveAs) |
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:
78
diff
changeset
|
34 | EXTERN_ACTION (settings) |
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:
78
diff
changeset
|
35 | EXTERN_ACTION (exit) |
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:
78
diff
changeset
|
36 | EXTERN_ACTION (cut) |
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:
78
diff
changeset
|
37 | EXTERN_ACTION (copy) |
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:
78
diff
changeset
|
38 | EXTERN_ACTION (paste) |
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:
78
diff
changeset
|
39 | EXTERN_ACTION (del) |
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:
78
diff
changeset
|
40 | EXTERN_ACTION (setColor) |
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:
78
diff
changeset
|
41 | EXTERN_ACTION (inlineContents) |
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:
78
diff
changeset
|
42 | EXTERN_ACTION (deepInline) |
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:
78
diff
changeset
|
43 | EXTERN_ACTION (splitQuads) |
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:
78
diff
changeset
|
44 | EXTERN_ACTION (setContents) |
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:
78
diff
changeset
|
45 | EXTERN_ACTION (makeBorders) |
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:
78
diff
changeset
|
46 | EXTERN_ACTION (newSubfile) |
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:
78
diff
changeset
|
47 | EXTERN_ACTION (newLine) |
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:
78
diff
changeset
|
48 | EXTERN_ACTION (newCondLine) |
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:
78
diff
changeset
|
49 | EXTERN_ACTION (newTriangle) |
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:
78
diff
changeset
|
50 | EXTERN_ACTION (newQuad) |
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:
78
diff
changeset
|
51 | EXTERN_ACTION (newVertex) |
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:
78
diff
changeset
|
52 | EXTERN_ACTION (newComment) |
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:
78
diff
changeset
|
53 | EXTERN_ACTION (help) |
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:
78
diff
changeset
|
54 | EXTERN_ACTION (about) |
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:
78
diff
changeset
|
55 | EXTERN_ACTION (aboutQt) |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
56 | |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
57 | vector<actionmeta> g_ActionMeta; |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
58 | cfg (bool, lv_colorize, true); |
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
59 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
60 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
61 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
62 | // ============================================================================= |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
63 | ForgeWindow::ForgeWindow () { |
0 | 64 | R = new renderer; |
65 | ||
66 | qObjList = new QTreeWidget; | |
67 | qObjList->setHeaderHidden (true); | |
68 | qObjList->setMaximumWidth (256); | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
69 | qObjList->setSelectionMode (QTreeWidget::MultiSelection); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
70 | connect (qObjList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ())); |
0 | 71 | |
72 | qMessageLog = new QTextEdit; | |
73 | qMessageLog->setReadOnly (true); | |
74 | qMessageLog->setMaximumHeight (96); | |
75 | ||
76 | QWidget* w = new QWidget; | |
77 | QGridLayout* layout = new QGridLayout; | |
78 | layout->setColumnMinimumWidth (0, 192); | |
79 | layout->setColumnStretch (0, 1); | |
80 | layout->addWidget (R, 0, 0); | |
81 | layout->addWidget (qObjList, 0, 1); | |
82 | layout->addWidget (qMessageLog, 1, 0, 1, 2); | |
83 | w->setLayout (layout); | |
84 | setCentralWidget (w); | |
85 | ||
86 | createMenuActions (); | |
87 | createMenus (); | |
88 | createToolbars (); | |
89 | ||
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
90 | slot_selectionChanged (); |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
91 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
92 | setWindowIcon (QIcon ("icons/ldforge.png")); |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
93 | setTitle (); |
0 | 94 | setMinimumSize (320, 200); |
95 | resize (800, 600); | |
96 | } | |
97 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
98 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
99 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
100 | // ============================================================================= |
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:
78
diff
changeset
|
101 | void ForgeWindow::createMenuActions () { |
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:
78
diff
changeset
|
102 | // Create the actions based on stored meta. |
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:
78
diff
changeset
|
103 | for (actionmeta meta : g_ActionMeta) { |
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:
78
diff
changeset
|
104 | QAction*& qAct = *meta.qAct; |
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:
78
diff
changeset
|
105 | qAct = new QAction (getIcon (meta.sIconName), meta.sDisplayName, this); |
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:
78
diff
changeset
|
106 | qAct->setStatusTip (meta.sDescription); |
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:
78
diff
changeset
|
107 | qAct->setShortcut (*meta.conf); |
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:
78
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:
78
diff
changeset
|
109 | connect (qAct, SIGNAL (triggered ()), this, SLOT (slot_action ())); |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
110 | } |
0 | 111 | |
112 | // things not implemented yet | |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
113 | QAction* const qaDisabledActions[] = { |
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:
78
diff
changeset
|
114 | ACTION_NAME (newSubfile), |
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:
78
diff
changeset
|
115 | ACTION_NAME (about), |
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:
78
diff
changeset
|
116 | ACTION_NAME (help), |
0 | 117 | }; |
118 | ||
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
119 | for (QAction* act : qaDisabledActions) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
120 | act->setEnabled (false); |
0 | 121 | } |
122 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
123 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
124 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
125 | // ============================================================================= |
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:
78
diff
changeset
|
126 | #define ADD_MENU_ITEM(MENU, ACT) q##MENU##Menu->addAction (ACTION_NAME (ACT)); |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
127 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
128 | void ForgeWindow::createMenus () { |
0 | 129 | // File menu |
130 | qFileMenu = menuBar ()->addMenu (tr ("&File")); | |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
131 | ADD_MENU_ITEM (File, newFile) // New |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
132 | ADD_MENU_ITEM (File, open) // Open |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
133 | ADD_MENU_ITEM (File, save) // Save |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
134 | ADD_MENU_ITEM (File, saveAs) // Save As |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
135 | qFileMenu->addSeparator (); // ------- |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
136 | ADD_MENU_ITEM (File, settings) // Settings |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
137 | qFileMenu->addSeparator (); // ------- |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
138 | ADD_MENU_ITEM (File, exit) // Exit |
0 | 139 | |
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:
78
diff
changeset
|
140 | // Insert menu |
0 | 141 | qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
142 | ADD_MENU_ITEM (Insert, newSubfile) // New Subfile |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
143 | ADD_MENU_ITEM (Insert, newLine) // New Line |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
144 | ADD_MENU_ITEM (Insert, newTriangle) // New Triangle |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
145 | ADD_MENU_ITEM (Insert, newQuad) // New Quad |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
146 | ADD_MENU_ITEM (Insert, newCondLine) // New Conditional Line |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
147 | ADD_MENU_ITEM (Insert, newComment) // New Comment |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
148 | ADD_MENU_ITEM (Insert, newVertex) // New Vertex |
0 | 149 | |
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:
78
diff
changeset
|
150 | // Edit menu |
0 | 151 | qEditMenu = menuBar ()->addMenu (tr ("&Edit")); |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
152 | ADD_MENU_ITEM (Edit, cut) // Cut |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
153 | ADD_MENU_ITEM (Edit, copy) // Copy |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
154 | ADD_MENU_ITEM (Edit, paste) // Paste |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
155 | ADD_MENU_ITEM (Edit, del) // Delete |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
156 | qEditMenu->addSeparator (); // ----- |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
157 | ADD_MENU_ITEM (Edit, setColor) // Set Color |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
158 | qEditMenu->addSeparator (); // ----- |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
159 | ADD_MENU_ITEM (Edit, inlineContents) // Inline |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
160 | ADD_MENU_ITEM (Edit, deepInline) // Deep Inline |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
161 | ADD_MENU_ITEM (Edit, splitQuads) // Split Quads |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
162 | ADD_MENU_ITEM (Edit, setContents) // Set Contents |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
163 | ADD_MENU_ITEM (Edit, makeBorders) // Make Borders |
0 | 164 | |
165 | // Help menu | |
166 | qHelpMenu = menuBar ()->addMenu (tr ("&Help")); | |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
167 | ADD_MENU_ITEM (Help, help) // Help |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
168 | qHelpMenu->addSeparator (); // ----- |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
169 | ADD_MENU_ITEM (Help, about) // About |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
170 | ADD_MENU_ITEM (Help, aboutQt) // About Qt |
0 | 171 | } |
172 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
173 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
174 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
175 | // ============================================================================= |
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:
78
diff
changeset
|
176 | #define ADD_TOOLBAR_ITEM(BAR, ACT) q##BAR##ToolBar->addAction (ACTION_NAME (ACT)); |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
177 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
178 | void ForgeWindow::createToolbars () { |
0 | 179 | qFileToolBar = new QToolBar ("File"); |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
180 | ADD_TOOLBAR_ITEM (File, newFile) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
181 | ADD_TOOLBAR_ITEM (File, open) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
182 | ADD_TOOLBAR_ITEM (File, save) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
183 | ADD_TOOLBAR_ITEM (File, saveAs) |
0 | 184 | addToolBar (qFileToolBar); |
185 | ||
186 | qInsertToolBar = new QToolBar ("Insert"); | |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
187 | ADD_TOOLBAR_ITEM (Insert, newSubfile) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
188 | ADD_TOOLBAR_ITEM (Insert, newLine) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
189 | ADD_TOOLBAR_ITEM (Insert, newTriangle) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
190 | ADD_TOOLBAR_ITEM (Insert, newQuad) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
191 | ADD_TOOLBAR_ITEM (Insert, newCondLine) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
192 | ADD_TOOLBAR_ITEM (Insert, newComment) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
193 | ADD_TOOLBAR_ITEM (Insert, newVertex) |
0 | 194 | addToolBar (qInsertToolBar); |
195 | ||
196 | qEditToolBar = new QToolBar ("Edit"); | |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
197 | ADD_TOOLBAR_ITEM (Edit, cut) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
198 | ADD_TOOLBAR_ITEM (Edit, copy) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
199 | ADD_TOOLBAR_ITEM (Edit, paste) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
200 | ADD_TOOLBAR_ITEM (Edit, del) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
201 | ADD_TOOLBAR_ITEM (Edit, setColor) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
202 | ADD_TOOLBAR_ITEM (Edit, inlineContents) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
203 | ADD_TOOLBAR_ITEM (Edit, splitQuads) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
204 | ADD_TOOLBAR_ITEM (Edit, setContents) |
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
205 | ADD_TOOLBAR_ITEM (Edit, makeBorders) |
0 | 206 | addToolBar (qEditToolBar); |
207 | } | |
208 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
209 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
210 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
211 | // ============================================================================= |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
212 | void ForgeWindow::setTitle () { |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
213 | str zTitle = APPNAME_DISPLAY " v" VERSION_STRING; |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
214 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
215 | // Append our current file if we have one |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
216 | if (g_CurrentFile) { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
217 | zTitle.appendformat (": %s", basename (g_CurrentFile->zFileName.chars())); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
218 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
219 | if (g_CurrentFile->objects.size() > 0 && |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
220 | g_CurrentFile->objects[0]->getType() == OBJ_Comment) |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
221 | { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
222 | // Append title |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
223 | LDComment* comm = static_cast<LDComment*> (g_CurrentFile->objects[0]); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
224 | zTitle.appendformat (":%s", comm->zText.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
225 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
226 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
227 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
228 | setWindowTitle (zTitle.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
229 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
230 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
231 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
232 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
233 | // ============================================================================= |
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:
78
diff
changeset
|
234 | void ForgeWindow::slot_action () { |
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:
78
diff
changeset
|
235 | // Get the action that triggered this slot. |
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:
78
diff
changeset
|
236 | QAction* qAct = static_cast<QAction*> (sender ()); |
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:
78
diff
changeset
|
237 | |
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:
78
diff
changeset
|
238 | // Find the meta for the action. |
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:
78
diff
changeset
|
239 | actionmeta* pMeta = nullptr; |
0 | 240 | |
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:
78
diff
changeset
|
241 | for (actionmeta meta : g_ActionMeta) { |
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:
78
diff
changeset
|
242 | if (*meta.qAct == qAct) { |
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:
78
diff
changeset
|
243 | pMeta = &meta; |
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:
78
diff
changeset
|
244 | break; |
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:
78
diff
changeset
|
245 | } |
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:
78
diff
changeset
|
246 | } |
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:
78
diff
changeset
|
247 | |
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:
78
diff
changeset
|
248 | if (!pMeta) { |
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:
78
diff
changeset
|
249 | fprintf (stderr, "unknown signal sender %p!\n", qAct); |
42
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
250 | return; |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
251 | } |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
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:
78
diff
changeset
|
253 | // We have the meta, now call the handler. |
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:
78
diff
changeset
|
254 | (*pMeta->handler) (); |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
255 | } |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
256 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
257 | // ============================================================================= |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
258 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
259 | // ============================================================================= |
64
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
260 | void ForgeWindow::deleteSelection () { |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
261 | vector<LDObject*> objs = getSelectedObjects (); |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
262 | |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
263 | // Delete the objects that were being selected |
70
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
264 | for (LDObject* obj : objs) { |
64
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
265 | g_CurrentFile->forgetObject (obj); |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
266 | delete obj; |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
267 | } |
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:
78
diff
changeset
|
268 | |
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:
78
diff
changeset
|
269 | 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:
78
diff
changeset
|
270 | refresh (); |
64
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
271 | } |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
272 | |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
273 | // ============================================================================= |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
274 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
275 | // ============================================================================= |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
276 | void ForgeWindow::buildObjList () { |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
277 | if (!g_CurrentFile) |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
278 | return; |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
279 | |
0 | 280 | QList<QTreeWidgetItem*> qaItems; |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
281 | |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
282 | qObjList->clear (); |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
283 | |
70
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
284 | for (LDObject* obj : g_CurrentFile->objects) { |
0 | 285 | str zText; |
286 | switch (obj->getType ()) { | |
287 | case OBJ_Comment: | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
288 | zText = static_cast<LDComment*> (obj)->zText.chars(); |
10
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
289 | |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
290 | // Remove leading whitespace |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
291 | while (~zText && zText[0] == ' ') |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
292 | zText -= -1; |
0 | 293 | break; |
294 | ||
295 | case OBJ_Empty: | |
296 | break; // leave it empty | |
297 | ||
298 | case OBJ_Line: | |
299 | { | |
300 | LDLine* line = static_cast<LDLine*> (obj); | |
301 | zText.format ("%s, %s", | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
302 | line->vaCoords[0].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
303 | line->vaCoords[1].getStringRep (true).chars()); |
0 | 304 | } |
305 | break; | |
306 | ||
307 | case OBJ_Triangle: | |
308 | { | |
309 | LDTriangle* triangle = static_cast<LDTriangle*> (obj); | |
310 | zText.format ("%s, %s, %s", | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
311 | triangle->vaCoords[0].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
312 | triangle->vaCoords[1].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
313 | triangle->vaCoords[2].getStringRep (true).chars()); |
0 | 314 | } |
315 | break; | |
316 | ||
317 | case OBJ_Quad: | |
318 | { | |
319 | LDQuad* quad = static_cast<LDQuad*> (obj); | |
10
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
320 | zText.format ("%s, %s, %s, %s", |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
321 | quad->vaCoords[0].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
322 | quad->vaCoords[1].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
323 | quad->vaCoords[2].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
324 | quad->vaCoords[3].getStringRep (true).chars()); |
0 | 325 | } |
326 | break; | |
327 | ||
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
328 | case OBJ_CondLine: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
329 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
330 | LDCondLine* line = static_cast<LDCondLine*> (obj); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
331 | zText.format ("%s, %s, %s, %s", |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
332 | line->vaCoords[0].getStringRep (true).chars(), |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
333 | line->vaCoords[1].getStringRep (true).chars(), |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
334 | line->vaCoords[2].getStringRep (true).chars(), |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
335 | line->vaCoords[3].getStringRep (true).chars()); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
336 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
337 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
338 | |
0 | 339 | case OBJ_Gibberish: |
340 | zText.format ("ERROR: %s", | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
341 | static_cast<LDGibberish*> (obj)->zContents.chars()); |
0 | 342 | break; |
343 | ||
344 | case OBJ_Vertex: | |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
345 | zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep (true).chars()); |
0 | 346 | break; |
347 | ||
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
348 | case OBJ_Subfile: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
349 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
350 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
351 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
352 | zText.format ("%s %s, (", |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
353 | ref->zFileName.chars(), ref->vPosition.getStringRep (true).chars()); |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
354 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
355 | for (short i = 0; i < 9; ++i) |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
356 | zText.appendformat ("%s%s", |
64
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
357 | ftoa (ref->mMatrix[i]).chars(), |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
358 | (i != 8) ? " " : ""); |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
359 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
360 | zText += ')'; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
361 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
362 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
363 | |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
364 | case OBJ_BFC: |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
365 | { |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
366 | LDBFC* bfc = static_cast<LDBFC*> (obj); |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
367 | zText = LDBFC::saStatements[bfc->dStatement]; |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
368 | } |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
369 | break; |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
370 | |
0 | 371 | default: |
372 | zText = g_saObjTypeNames[obj->getType ()]; | |
373 | break; | |
374 | } | |
375 | ||
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
376 | QTreeWidgetItem* item = new QTreeWidgetItem ((QTreeWidget*) (nullptr), |
0 | 377 | QStringList (zText.chars()), 0); |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
378 | item->setIcon (0, QIcon (str::mkfmt ("icons/%s.png", g_saObjTypeIcons[obj->getType ()]).chars())); |
0 | 379 | |
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
380 | // Color gibberish red |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
381 | if (obj->getType() == OBJ_Gibberish) { |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
382 | item->setBackground (0, QColor ("#AA0000")); |
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
383 | item->setForeground (0, QColor ("#FFAA00")); |
52
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
384 | } else if (lv_colorize && |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
385 | obj->dColor != -1 && |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
386 | obj->dColor != dMainColor && |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
387 | obj->dColor != dEdgeColor) |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
388 | { |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
389 | // If the object isn't in the main or edge color, draw this |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
390 | // list entry in said color. |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
391 | color* col = getColor (obj->dColor); |
67
d523a370a17a
57181.dat (Philo's model of the XL-motor) showcased a new problem.. there was no handling of unknown colors which led into crashes. Added stdout warnings, also added mid and dark stone colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
392 | if (col) |
72
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
393 | item->setForeground (0, col->qColor); |
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
394 | } |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
395 | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
396 | obj->qObjListEntry = item; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
397 | |
0 | 398 | qaItems.append (item); |
399 | } | |
400 | ||
401 | qObjList->insertTopLevelItems (0, qaItems); | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
402 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
403 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
404 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
405 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
406 | // ============================================================================= |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
407 | void ForgeWindow::slot_selectionChanged () { |
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:
78
diff
changeset
|
408 | /* |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
409 | // If the selection isn't 1 exact, disable setting contents |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
410 | ACTION (setContents)->setEnabled (qObjList->selectedItems().size() == 1); |
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
411 | |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
412 | // If we have no selection, disable splitting quads |
77
7c2f500405fe
Systemized actions and added (for now no-op) key configurations for them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
413 | ACTION (splitQuads)->setEnabled (qObjList->selectedItems().size() > 0); |
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:
78
diff
changeset
|
414 | */ |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
415 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
416 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
417 | // ============================================================================= |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
418 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
419 | // ============================================================================= |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
420 | ulong ForgeWindow::getInsertionPoint () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
421 | ulong ulIndex; |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
422 | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
423 | if (qObjList->selectedItems().size() == 1) { |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
424 | // If we have a selection, put the item after it. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
425 | for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
426 | if (g_CurrentFile->objects[ulIndex]->qObjListEntry == qObjList->selectedItems()[0]) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
427 | break; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
428 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
429 | if (ulIndex >= g_CurrentFile->objects.size()) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
430 | return ulIndex + 1; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
431 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
432 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
433 | // Otherwise place the object at the end. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
434 | return g_CurrentFile->objects.size(); |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
435 | } |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
436 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
437 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
438 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
439 | // ============================================================================= |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
440 | void ForgeWindow::refresh () { |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
441 | buildObjList (); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
442 | R->hardRefresh (); |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
443 | } |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
444 | |
50
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
445 | // ============================================================================= |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
446 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
447 | // ============================================================================= |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
448 | std::vector<LDObject*> ForgeWindow::getSelectedObjects () { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
449 | std::vector<LDObject*> objs; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
450 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
451 | QList<QTreeWidgetItem*> const qaItems = qObjList->selectedItems(); |
70
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
452 | for (LDObject* obj : g_CurrentFile->objects) |
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
453 | for (QTreeWidgetItem* qItem : qaItems) { |
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
454 | if (qItem == obj->qObjListEntry) { |
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
455 | objs.push_back (obj); |
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
456 | break; |
50
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
457 | } |
49
242f6ea0f5e5
Finished with the color selection dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
458 | } |
50
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
459 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
460 | return 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:
78
diff
changeset
|
461 | } |
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:
78
diff
changeset
|
462 | |
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:
78
diff
changeset
|
463 | // ============================================================================= |
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:
78
diff
changeset
|
464 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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:
78
diff
changeset
|
465 | // ============================================================================= |
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:
78
diff
changeset
|
466 | QIcon getIcon (const char* sIconName) { |
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:
78
diff
changeset
|
467 | return (QIcon (str::mkfmt ("./icons/%s.png", sIconName))); |
0 | 468 | } |