Thu, 21 Mar 2013 03:20:02 +0200
Added polygon bordering function
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" |
0 | 25 | |
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
|
26 | #include "zz_setContentsDialog.h" |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
27 | #include "zz_configDialog.h" |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
28 | #include "zz_addObjectDialog.h" |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
29 | #include "misc.h" |
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
|
30 | #include "zz_colorSelectDialog.h" |
49
242f6ea0f5e5
Finished with the color selection dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
31 | #include "colors.h" |
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
|
32 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
33 | #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
34 | qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
35 | qAct_##OBJECT->setStatusTip (tr (DESCR)); \ |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
36 | connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
37 | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
38 | vector<LDObject*> g_Clipboard; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
39 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
40 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
41 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
42 | // ============================================================================= |
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
|
43 | ForgeWindow::ForgeWindow () { |
0 | 44 | R = new renderer; |
45 | ||
46 | qObjList = new QTreeWidget; | |
47 | qObjList->setHeaderHidden (true); | |
48 | 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
|
49 | qObjList->setSelectionMode (QTreeWidget::MultiSelection); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
50 | connect (qObjList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ())); |
0 | 51 | |
52 | qMessageLog = new QTextEdit; | |
53 | qMessageLog->setReadOnly (true); | |
54 | qMessageLog->setMaximumHeight (96); | |
55 | ||
56 | QWidget* w = new QWidget; | |
57 | QGridLayout* layout = new QGridLayout; | |
58 | layout->setColumnMinimumWidth (0, 192); | |
59 | layout->setColumnStretch (0, 1); | |
60 | layout->addWidget (R, 0, 0); | |
61 | layout->addWidget (qObjList, 0, 1); | |
62 | layout->addWidget (qMessageLog, 1, 0, 1, 2); | |
63 | w->setLayout (layout); | |
64 | setCentralWidget (w); | |
65 | ||
66 | createMenuActions (); | |
67 | createMenus (); | |
68 | createToolbars (); | |
69 | ||
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
|
70 | 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
|
71 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
72 | setWindowIcon (QIcon ("icons/ldforge.png")); |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
73 | setTitle (); |
0 | 74 | setMinimumSize (320, 200); |
75 | resize (800, 600); | |
76 | } | |
77 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
78 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
79 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
80 | // ============================================================================= |
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
|
81 | void ForgeWindow::createMenuActions () { |
0 | 82 | // Long menu names go here so my cool action definition table doesn't get out of proportions |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
83 | char const* sNewCdLineText = "New Conditional Line", |
0 | 84 | *sNewQuadText = "New Quadrilateral", |
85 | *sAboutText = "About " APPNAME_DISPLAY; | |
86 | ||
87 | MAKE_ACTION (new, "&New", "file-new", "Create a new part model.") | |
5
727e02d6b87a
rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
88 | MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.") |
727e02d6b87a
rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
89 | MAKE_ACTION (save, "&Save", "file-save", "Save the part model.") |
727e02d6b87a
rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
90 | MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part to a specific file.") |
0 | 91 | MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
92 | ||
93 | MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.") | |
94 | MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.") | |
95 | MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.") | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
96 | MAKE_ACTION (delete, "Delete", "delete", "Delete the selection") |
0 | 97 | |
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
|
98 | MAKE_ACTION (setColor, "Set Color", "palette", "Set the color on given objects.") |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
99 | MAKE_ACTION (inline, "Inline", "inline", "Inline selected subfiles.") |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
100 | MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.") |
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
|
101 | MAKE_ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.") |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
102 | MAKE_ACTION (makeBorders, "Make Borders", "make-borders", "Add borders around given polygons.") |
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
|
103 | |
0 | 104 | MAKE_ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.") |
105 | MAKE_ACTION (newLine, "New Line", "add-line", "Creates a new line.") | |
106 | MAKE_ACTION (newTriangle, "New Triangle", "add-triangle", "Creates a new triangle.") | |
107 | MAKE_ACTION (newQuad, sNewQuadText, "add-quad", "Creates a new quadrilateral.") | |
43
85b24285a8c7
Removed vectors. I realized that subfiles can actually perform their job just as well and that keeping them around would just imply extra work - for nothing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
108 | MAKE_ACTION (newCondLine, sNewCdLineText, "add-condline", "Creates a new conditional line.") |
85b24285a8c7
Removed vectors. I realized that subfiles can actually perform their job just as well and that keeping them around would just imply extra work - for nothing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
109 | MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment.") |
0 | 110 | MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.") |
111 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
112 | MAKE_ACTION (settings, "Settings", "settings", "Edit the settings of " APPNAME_DISPLAY ".") |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
113 | |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
114 | MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.") |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
115 | MAKE_ACTION (about, sAboutText, "ldforge", "Shows information about " APPNAME_DISPLAY ".") |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
116 | MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.") |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
117 | |
0 | 118 | // Keyboard shortcuts |
119 | qAct_new->setShortcut (Qt::CTRL | Qt::Key_N); | |
120 | qAct_open->setShortcut (Qt::CTRL | Qt::Key_O); | |
121 | qAct_save->setShortcut (Qt::CTRL | Qt::Key_S); | |
122 | qAct_saveAs->setShortcut (Qt::CTRL | Qt::SHIFT | Qt::Key_S); | |
123 | ||
124 | qAct_cut->setShortcut (Qt::CTRL | Qt::Key_X); | |
125 | qAct_copy->setShortcut (Qt::CTRL | Qt::Key_C); | |
126 | qAct_paste->setShortcut (Qt::CTRL | Qt::Key_V); | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
127 | qAct_delete->setShortcut (Qt::Key_Delete); |
0 | 128 | |
129 | // things not implemented yet | |
130 | QAction* qaDisabledActions[] = { | |
131 | qAct_newSubfile, | |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
132 | qAct_about, |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
133 | qAct_inline, |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
134 | qAct_help, |
0 | 135 | }; |
136 | ||
137 | for (ushort i = 0; i < sizeof qaDisabledActions / sizeof *qaDisabledActions; ++i) | |
138 | qaDisabledActions[i]->setEnabled (false); | |
139 | } | |
140 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
141 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
142 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
143 | // ============================================================================= |
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
|
144 | void ForgeWindow::createMenus () { |
0 | 145 | // File menu |
146 | qFileMenu = menuBar ()->addMenu (tr ("&File")); | |
147 | qFileMenu->addAction (qAct_new); // New | |
148 | qFileMenu->addAction (qAct_open); // Open | |
149 | qFileMenu->addAction (qAct_save); // Save | |
150 | qFileMenu->addAction (qAct_saveAs); // Save As | |
151 | qFileMenu->addSeparator (); // ------- | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
152 | qFileMenu->addAction (qAct_settings); // Settings |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
153 | qFileMenu->addSeparator (); // ------- |
0 | 154 | qFileMenu->addAction (qAct_exit); // Exit |
155 | ||
156 | // Edit menu | |
157 | qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); | |
158 | qInsertMenu->addAction (qAct_newSubfile); // New Subfile | |
159 | qInsertMenu->addAction (qAct_newLine); // New Line | |
160 | qInsertMenu->addAction (qAct_newTriangle); // New Triangle | |
161 | qInsertMenu->addAction (qAct_newQuad); // New Quad | |
162 | qInsertMenu->addAction (qAct_newCondLine); // New Conditional Line | |
163 | qInsertMenu->addAction (qAct_newComment); // New Comment | |
164 | qInsertMenu->addAction (qAct_newVertex); // New Vertex | |
165 | ||
166 | qEditMenu = menuBar ()->addMenu (tr ("&Edit")); | |
167 | qEditMenu->addAction (qAct_cut); // Cut | |
168 | qEditMenu->addAction (qAct_copy); // Copy | |
169 | qEditMenu->addAction (qAct_paste); // Paste | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
170 | qEditMenu->addAction (qAct_delete); // Delete |
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
|
171 | qEditMenu->addSeparator (); // ----- |
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
|
172 | qEditMenu->addAction (qAct_setColor); // Set Color |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
173 | qEditMenu->addSeparator (); // ----- |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
174 | qEditMenu->addAction (qAct_inline); // Inline |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
175 | qEditMenu->addAction (qAct_splitQuads); // Split Quads |
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
|
176 | qEditMenu->addAction (qAct_setContents); // Set Contents |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
177 | qEditMenu->addAction (qAct_makeBorders); // Make Borders |
0 | 178 | |
179 | // Help menu | |
180 | qHelpMenu = menuBar ()->addMenu (tr ("&Help")); | |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
181 | qHelpMenu->addAction (qAct_help); // Help |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
182 | qHelpMenu->addSeparator (); // ----- |
0 | 183 | qHelpMenu->addAction (qAct_about); // About |
184 | qHelpMenu->addAction (qAct_aboutQt); // About Qt | |
185 | } | |
186 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
187 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
188 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
189 | // ============================================================================= |
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
|
190 | void ForgeWindow::createToolbars () { |
0 | 191 | qFileToolBar = new QToolBar ("File"); |
192 | qFileToolBar->addAction (qAct_new); | |
193 | qFileToolBar->addAction (qAct_open); | |
194 | qFileToolBar->addAction (qAct_save); | |
195 | qFileToolBar->addAction (qAct_saveAs); | |
196 | addToolBar (qFileToolBar); | |
197 | ||
198 | qInsertToolBar = new QToolBar ("Insert"); | |
199 | qInsertToolBar->addAction (qAct_newSubfile); | |
200 | qInsertToolBar->addAction (qAct_newLine); | |
201 | qInsertToolBar->addAction (qAct_newTriangle); | |
202 | qInsertToolBar->addAction (qAct_newQuad); | |
203 | qInsertToolBar->addAction (qAct_newCondLine); | |
204 | qInsertToolBar->addAction (qAct_newComment); | |
205 | qInsertToolBar->addAction (qAct_newVertex); | |
206 | addToolBar (qInsertToolBar); | |
207 | ||
208 | qEditToolBar = new QToolBar ("Edit"); | |
209 | qEditToolBar->addAction (qAct_cut); | |
210 | qEditToolBar->addAction (qAct_copy); | |
211 | qEditToolBar->addAction (qAct_paste); | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
212 | qEditToolBar->addAction (qAct_delete); |
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
|
213 | qEditToolBar->addAction (qAct_setColor); |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
214 | qEditToolBar->addAction (qAct_inline); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
215 | qEditToolBar->addAction (qAct_splitQuads); |
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
|
216 | qEditToolBar->addAction (qAct_setContents); |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
217 | qEditToolBar->addAction (qAct_makeBorders); |
0 | 218 | addToolBar (qEditToolBar); |
219 | } | |
220 | ||
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
221 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
222 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
223 | // ============================================================================= |
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
|
224 | void ForgeWindow::setTitle () { |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
225 | str zTitle = APPNAME_DISPLAY " v" VERSION_STRING; |
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 | // 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
|
228 | if (g_CurrentFile) { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
229 | 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
|
230 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
231 | if (g_CurrentFile->objects.size() > 0 && |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
232 | g_CurrentFile->objects[0]->getType() == OBJ_Comment) |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
233 | { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
234 | // Append title |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
235 | 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
|
236 | zTitle.appendformat (":%s", comm->zText.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
237 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
238 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
239 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
240 | setWindowTitle (zTitle.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
241 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
242 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
243 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
244 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
245 | // ============================================================================= |
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
|
246 | void ForgeWindow::slot_new () { |
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
|
247 | newFile (); |
0 | 248 | } |
249 | ||
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
|
250 | void ForgeWindow::slot_open () { |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
251 | str zName; |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
252 | zName += QFileDialog::getOpenFileName (this, "Open File", |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
253 | "", "LDraw files (*.dat *.ldr)"); |
0 | 254 | |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
255 | if (~zName) |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
256 | openMainFile (zName); |
0 | 257 | } |
258 | ||
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
|
259 | void ForgeWindow::slot_save () { |
42
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
260 | if (!~g_CurrentFile->zFileName) { |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
261 | // If we don't have a file name, this is an anonymous file created |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
262 | // with the new file command. We cannot save without a name so ask |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
263 | // the user for one. |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
264 | slot_saveAs (); |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
265 | return; |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
266 | } |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
267 | |
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
|
268 | g_CurrentFile->save (); |
0 | 269 | } |
270 | ||
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
|
271 | void ForgeWindow::slot_saveAs () { |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
272 | str zName; |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
273 | zName += QFileDialog::getSaveFileName (this, "Save As", |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
274 | "", "LDraw files (*.dat *.ldr)"); |
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
|
275 | |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
276 | if (~zName && g_CurrentFile->save (zName)) |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
277 | g_CurrentFile->zFileName = zName; |
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
|
278 | } |
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
|
279 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
280 | void ForgeWindow::slot_settings () { |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
281 | ConfigDialog::staticDialog (this); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
282 | } |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
283 | |
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
|
284 | void ForgeWindow::slot_exit () { |
0 | 285 | exit (0); |
286 | } | |
287 | ||
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
|
288 | void ForgeWindow::slot_newSubfile () { |
0 | 289 | |
290 | } | |
291 | ||
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
|
292 | void ForgeWindow::slot_newLine () { |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
293 | AddObjectDialog::staticDialog (OBJ_Line, this); |
0 | 294 | } |
295 | ||
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
|
296 | void ForgeWindow::slot_newTriangle () { |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
297 | AddObjectDialog::staticDialog (OBJ_Triangle, this); |
0 | 298 | } |
299 | ||
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
|
300 | void ForgeWindow::slot_newQuad () { |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
301 | AddObjectDialog::staticDialog (OBJ_Quad, this); |
0 | 302 | } |
303 | ||
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
|
304 | void ForgeWindow::slot_newCondLine () { |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
305 | AddObjectDialog::staticDialog (OBJ_CondLine, this); |
0 | 306 | } |
307 | ||
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
|
308 | void ForgeWindow::slot_newComment () { |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
309 | AddObjectDialog::staticDialog (OBJ_Comment, this); |
0 | 310 | } |
311 | ||
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
312 | void ForgeWindow::slot_help () { |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
313 | |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
314 | } |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
315 | |
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
|
316 | void ForgeWindow::slot_about () { |
0 | 317 | |
318 | } | |
319 | ||
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
|
320 | void ForgeWindow::slot_aboutQt () { |
0 | 321 | QMessageBox::aboutQt (this); |
322 | } | |
323 | ||
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
324 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
325 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
326 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
327 | bool ForgeWindow::copyToClipboard () { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
328 | vector<LDObject*> objs = getSelectedObjects (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
329 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
330 | if (objs.size() == 0) |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
331 | return false; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
332 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
333 | // Clear the clipboard. However, its contents are dynamically allocated |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
334 | // clones of LDObjects (cannot use pointers to real objects because the |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
335 | // cut operation deletes them!), so we have to delete said objects first. |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
336 | for (std::size_t i = 0; i < g_Clipboard.size(); ++i) |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
337 | delete g_Clipboard[i]; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
338 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
339 | g_Clipboard.clear (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
340 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
341 | for (std::size_t i = 0; i < objs.size(); ++i) |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
342 | g_Clipboard.push_back (objs[i]->makeClone ()); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
343 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
344 | return true; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
345 | } |
0 | 346 | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
347 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
348 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
349 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
350 | void ForgeWindow::deleteSelection () { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
351 | vector<LDObject*> objs = getSelectedObjects (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
352 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
353 | // Delete the objects that were being selected |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
354 | for (ulong i = 0; i < (ulong)objs.size(); ++i) { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
355 | LDObject* obj = objs[i]; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
356 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
357 | g_CurrentFile->forgetObject (obj); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
358 | delete obj; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
359 | } |
0 | 360 | } |
361 | ||
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
362 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
363 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
364 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
365 | void ForgeWindow::slot_cut () { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
366 | if (!copyToClipboard ()) |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
367 | return; |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
368 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
369 | deleteSelection (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
370 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
371 | qAct_paste->setEnabled (true); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
372 | refresh (); |
0 | 373 | } |
374 | ||
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
375 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
376 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
377 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
378 | void ForgeWindow::slot_copy () { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
379 | if (copyToClipboard ()) |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
380 | qAct_paste->setEnabled (true); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
381 | } |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
382 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
383 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
384 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
385 | // ============================================================================= |
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
|
386 | void ForgeWindow::slot_paste () { |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
387 | for (std::size_t i = 0; i < g_Clipboard.size(); ++i) { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
388 | LDObject* copy = g_Clipboard[i]->makeClone (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
389 | g_CurrentFile->addObject (copy); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
390 | } |
0 | 391 | |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
392 | refresh (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
393 | } |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
394 | |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
395 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
396 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
397 | // ============================================================================= |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
398 | void ForgeWindow::slot_delete () { |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
399 | deleteSelection (); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
400 | refresh (); |
0 | 401 | } |
402 | ||
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
|
403 | void ForgeWindow::slot_newVertex () { |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
404 | AddObjectDialog::staticDialog (OBJ_Vertex, this); |
0 | 405 | } |
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_inline () { |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
408 | |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
409 | } |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
410 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
411 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
412 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
413 | // ============================================================================= |
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
|
414 | void ForgeWindow::slot_splitQuads () { |
56
64899ff3bcb3
Simplify ForgeWindow::slot_splitQuads with the new methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
55
diff
changeset
|
415 | vector<LDObject*> objs = getSelectedObjects (); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
416 | |
56
64899ff3bcb3
Simplify ForgeWindow::slot_splitQuads with the new methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
55
diff
changeset
|
417 | // Delete the objects that were being selected |
64899ff3bcb3
Simplify ForgeWindow::slot_splitQuads with the new methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
55
diff
changeset
|
418 | for (ulong i = 0; i < (ulong)objs.size(); ++i) { |
64899ff3bcb3
Simplify ForgeWindow::slot_splitQuads with the new methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
55
diff
changeset
|
419 | LDObject* obj = objs[i]; |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
420 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
421 | // Don't even consider non-quads |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
422 | if (obj->getType() != OBJ_Quad) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
423 | continue; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
424 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
425 | static_cast<LDQuad*> (obj)->splitToTriangles (); |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
426 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
427 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
428 | refresh (); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
429 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
430 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
431 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
432 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
433 | // ============================================================================= |
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
|
434 | void ForgeWindow::slot_setContents () { |
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
|
435 | if (qObjList->selectedItems().size() != 1) |
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
|
436 | return; |
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
|
437 | |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
438 | LDObject* obj = getSelectedObjects ()[0]; |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
439 | SetContentsDialog::staticDialog (obj, this); |
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
|
440 | } |
0 | 441 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
442 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
443 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
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 | void ForgeWindow::slot_setColor () { |
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 | if (qObjList->selectedItems().size() <= 0) |
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 | return; |
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 | |
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 | short dColor; |
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 | short dDefault = -1; |
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 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
452 | std::vector<LDObject*> objs = 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
|
453 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
454 | // Try to get a consensus on the color used for use as a default. |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
455 | for (ulong i = 0; i < objs.size(); ++i) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
456 | LDObject* obj = objs[i]; |
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 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
458 | if (obj->dColor == -1) |
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 | continue; // doesn't use colors |
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 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
461 | if (dDefault != -1 && obj->dColor != dDefault) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
462 | // No unanimosity in object color, therefore we don't have a |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
463 | // proper default value to use. |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
464 | dDefault = -1; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
465 | break; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
466 | } |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
467 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
468 | if (dDefault == -1) |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
469 | dDefault = obj->dColor; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
470 | } |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
471 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
472 | // Show the dialog to the user now and ask him for a color. |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
473 | if (ColorSelectDialog::staticDialog (dColor, dDefault, this)) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
474 | for (ulong i = 0; i < objs.size(); ++i) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
475 | LDObject* obj = objs[i]; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
476 | if (obj->dColor != -1) |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
477 | obj->dColor = dColor; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
478 | } |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
479 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
480 | refresh (); |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
481 | } |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
482 | } |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
483 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
484 | // ============================================================================= |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
485 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
486 | // ============================================================================= |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
487 | void ForgeWindow::slot_makeBorders () { |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
488 | vector<LDObject*> objs = getSelectedObjects (); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
489 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
490 | // Delete the objects that were being selected |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
491 | for (std::size_t i = 0; i < objs.size(); ++i) { |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
492 | LDObject* obj = objs[i]; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
493 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
494 | if (obj->getType() != OBJ_Quad && obj->getType() != OBJ_Triangle) |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
495 | continue; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
496 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
497 | short dNumLines; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
498 | LDLine* lines[4]; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
499 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
500 | if (obj->getType() == OBJ_Quad) { |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
501 | dNumLines = 4; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
502 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
503 | LDQuad* quad = static_cast<LDQuad*> (obj); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
504 | lines[0] = new LDLine (quad->vaCoords[0], quad->vaCoords[1]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
505 | lines[1] = new LDLine (quad->vaCoords[1], quad->vaCoords[2]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
506 | lines[2] = new LDLine (quad->vaCoords[2], quad->vaCoords[3]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
507 | lines[3] = new LDLine (quad->vaCoords[3], quad->vaCoords[0]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
508 | } else { |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
509 | dNumLines = 3; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
510 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
511 | LDTriangle* tri = static_cast<LDTriangle*> (obj); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
512 | lines[0] = new LDLine (tri->vaCoords[0], tri->vaCoords[1]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
513 | lines[1] = new LDLine (tri->vaCoords[1], tri->vaCoords[2]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
514 | lines[2] = new LDLine (tri->vaCoords[2], tri->vaCoords[0]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
515 | } |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
516 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
517 | for (short i = 0; i < dNumLines; ++i) { |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
518 | lines[i]->dColor = dEdgeColor; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
519 | g_CurrentFile->addObject (lines[i]); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
520 | } |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
521 | } |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
522 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
523 | refresh (); |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
524 | } |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
525 | |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
526 | // ============================================================================= |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
527 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
528 | // ============================================================================= |
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
|
529 | void ForgeWindow::buildObjList () { |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
530 | if (!g_CurrentFile) |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
531 | return; |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
532 | |
0 | 533 | QList<QTreeWidgetItem*> qaItems; |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
534 | |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
535 | qObjList->clear (); |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
536 | |
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
|
537 | for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
0 | 538 | LDObject* obj = g_CurrentFile->objects[i]; |
539 | ||
540 | str zText; | |
541 | switch (obj->getType ()) { | |
542 | 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
|
543 | 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
|
544 | |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
545 | // Remove leading whitespace |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
546 | 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
|
547 | zText -= -1; |
0 | 548 | break; |
549 | ||
550 | case OBJ_Empty: | |
551 | break; // leave it empty | |
552 | ||
553 | case OBJ_Line: | |
554 | { | |
555 | LDLine* line = static_cast<LDLine*> (obj); | |
556 | 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
|
557 | 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
|
558 | line->vaCoords[1].getStringRep (true).chars()); |
0 | 559 | } |
560 | break; | |
561 | ||
562 | case OBJ_Triangle: | |
563 | { | |
564 | LDTriangle* triangle = static_cast<LDTriangle*> (obj); | |
565 | 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
|
566 | 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
|
567 | 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
|
568 | triangle->vaCoords[2].getStringRep (true).chars()); |
0 | 569 | } |
570 | break; | |
571 | ||
572 | case OBJ_Quad: | |
573 | { | |
574 | 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
|
575 | 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
|
576 | 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
|
577 | 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
|
578 | 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
|
579 | quad->vaCoords[3].getStringRep (true).chars()); |
0 | 580 | } |
581 | break; | |
582 | ||
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
583 | case OBJ_CondLine: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
584 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
585 | 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
|
586 | 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
|
587 | 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
|
588 | 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
|
589 | 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
|
590 | 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
|
591 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
592 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
593 | |
0 | 594 | case OBJ_Gibberish: |
595 | 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
|
596 | static_cast<LDGibberish*> (obj)->zContents.chars()); |
0 | 597 | break; |
598 | ||
599 | case OBJ_Vertex: | |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
600 | zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep (true).chars()); |
0 | 601 | break; |
602 | ||
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
603 | case OBJ_Subfile: |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
604 | { |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
605 | 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
|
606 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
607 | zText.format ("%s %s, (", |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
608 | 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
|
609 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
610 | 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
|
611 | zText.appendformat ("%s%s", |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
612 | ftoa (ref->faMatrix[i]).chars(), |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
613 | (i != 8) ? " " : ""); |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
614 | |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
615 | zText += ')'; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
616 | } |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
617 | break; |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
618 | |
0 | 619 | default: |
620 | zText = g_saObjTypeNames[obj->getType ()]; | |
621 | break; | |
622 | } | |
623 | ||
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
|
624 | QTreeWidgetItem* item = new QTreeWidgetItem ((QTreeWidget*) (nullptr), |
0 | 625 | QStringList (zText.chars()), 0); |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
626 | item->setIcon (0, QIcon (str::mkfmt ("icons/%s.png", g_saObjTypeIcons[obj->getType ()]).chars())); |
0 | 627 | |
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
|
628 | // 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
|
629 | if (obj->getType() == OBJ_Gibberish) { |
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
|
630 | item->setBackgroundColor (0, "#AA0000"); |
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
|
631 | 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
|
632 | } 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
|
633 | 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
|
634 | 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
|
635 | 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
|
636 | { |
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
|
637 | // 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
|
638 | // list entry in said color. |
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
|
639 | item->setForeground (0, QColor (g_LDColors[obj->dColor]->zColor.chars())); |
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
|
640 | } |
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
|
641 | |
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
|
642 | 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
|
643 | |
0 | 644 | qaItems.append (item); |
645 | } | |
646 | ||
647 | 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
|
648 | } |
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
|
649 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
650 | // ============================================================================= |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
651 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
652 | // ============================================================================= |
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
|
653 | void ForgeWindow::slot_selectionChanged () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
654 | // If the selection isn't 1 exact, disable setting contents |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
655 | qAct_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
|
656 | |
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
|
657 | // If we have no selection, disable splitting quads |
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
|
658 | qAct_splitQuads->setEnabled (qObjList->selectedItems().size() > 0); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
659 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
660 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
661 | // ============================================================================= |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
662 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
663 | // ============================================================================= |
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
|
664 | ulong ForgeWindow::getInsertionPoint () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
665 | 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
|
666 | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
667 | if (qObjList->selectedItems().size() == 1) { |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
668 | // 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
|
669 | for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
670 | if (g_CurrentFile->objects[ulIndex]->qObjListEntry == qObjList->selectedItems()[0]) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
671 | break; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
672 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
673 | if (ulIndex >= g_CurrentFile->objects.size()) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
674 | return ulIndex + 1; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
675 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
676 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
677 | // Otherwise place the object at the end. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
678 | return g_CurrentFile->objects.size(); |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
679 | } |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
680 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
681 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
682 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
683 | // ============================================================================= |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
684 | void ForgeWindow::refresh () { |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
685 | buildObjList (); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
686 | 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
|
687 | } |
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
|
688 | |
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
|
689 | // ============================================================================= |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
690 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
691 | // ============================================================================= |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
692 | 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
|
693 | 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
|
694 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
695 | QList<QTreeWidgetItem*> const qaItems = qObjList->selectedItems(); |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
696 | for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
697 | LDObject* obj = g_CurrentFile->objects[i]; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
698 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
699 | for (long j = 0; j < qaItems.size(); ++j) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
700 | if (qaItems[j] == obj->qObjListEntry) { |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
701 | objs.push_back (obj); |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
702 | break; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
703 | } |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
704 | } |
49
242f6ea0f5e5
Finished with the color selection dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
705 | } |
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
|
706 | |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
49
diff
changeset
|
707 | return objs; |
0 | 708 | } |