Mon, 18 Mar 2013 04:03:05 +0200
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
0 | 1 | #include <QtGui> |
2 | ||
3 | #include "common.h" | |
4 | #include "draw.h" | |
5 | #include "gui.h" | |
6 | #include "model.h" | |
7 | #include "io.h" | |
8 | ||
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
|
9 | #include "zz_setContentsDialog.h" |
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
|
10 | |
0 | 11 | LDForgeWindow::LDForgeWindow () { |
12 | R = new renderer; | |
13 | ||
14 | qObjList = new QTreeWidget; | |
15 | qObjList->setHeaderHidden (true); | |
16 | 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
|
17 | qObjList->setSelectionMode (QTreeWidget::MultiSelection); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
18 | connect (qObjList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ())); |
0 | 19 | |
20 | qMessageLog = new QTextEdit; | |
21 | qMessageLog->setReadOnly (true); | |
22 | qMessageLog->setMaximumHeight (96); | |
23 | ||
24 | QWidget* w = new QWidget; | |
25 | QGridLayout* layout = new QGridLayout; | |
26 | layout->setColumnMinimumWidth (0, 192); | |
27 | layout->setColumnStretch (0, 1); | |
28 | layout->addWidget (R, 0, 0); | |
29 | layout->addWidget (qObjList, 0, 1); | |
30 | layout->addWidget (qMessageLog, 1, 0, 1, 2); | |
31 | w->setLayout (layout); | |
32 | setCentralWidget (w); | |
33 | ||
34 | createMenuActions (); | |
35 | createMenus (); | |
36 | createToolbars (); | |
37 | ||
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
|
38 | 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
|
39 | |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
40 | setTitle (); |
0 | 41 | setMinimumSize (320, 200); |
42 | resize (800, 600); | |
43 | } | |
44 | ||
45 | #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ | |
46 | qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ | |
47 | qAct_##OBJECT->setStatusTip (tr (DESCR)); \ | |
48 | connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); | |
49 | ||
50 | void LDForgeWindow::createMenuActions () { | |
51 | // Long menu names go here so my cool action definition table doesn't get out of proportions | |
52 | const char* sNewCdLineText = "New Conditional Line", | |
53 | *sNewQuadText = "New Quadrilateral", | |
54 | *sAboutText = "About " APPNAME_DISPLAY; | |
55 | ||
56 | 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
|
57 | 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
|
58 | 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
|
59 | MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part to a specific file.") |
0 | 60 | MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
61 | ||
62 | MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.") | |
63 | MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.") | |
64 | MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.") | |
65 | MAKE_ACTION (about, sAboutText, "about", "Shows information about " APPNAME_DISPLAY ".") | |
66 | MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.") | |
67 | ||
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
|
68 | 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
|
69 | 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
|
70 | MAKE_ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.") |
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
|
71 | |
0 | 72 | MAKE_ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.") |
73 | MAKE_ACTION (newLine, "New Line", "add-line", "Creates a new line.") | |
74 | MAKE_ACTION (newTriangle, "New Triangle", "add-triangle", "Creates a new triangle.") | |
75 | MAKE_ACTION (newQuad, sNewQuadText, "add-quad", "Creates a new quadrilateral.") | |
76 | MAKE_ACTION (newCondLine, sNewCdLineText, "add-condline", "Creates a new conditional line."); | |
77 | MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment."); | |
78 | MAKE_ACTION (newVector, "New Vector", "add-vector", "Creates a new vector.") | |
79 | MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.") | |
80 | ||
81 | // Keyboard shortcuts | |
82 | qAct_new->setShortcut (Qt::CTRL | Qt::Key_N); | |
83 | qAct_open->setShortcut (Qt::CTRL | Qt::Key_O); | |
84 | qAct_save->setShortcut (Qt::CTRL | Qt::Key_S); | |
85 | qAct_saveAs->setShortcut (Qt::CTRL | Qt::SHIFT | Qt::Key_S); | |
86 | ||
87 | qAct_cut->setShortcut (Qt::CTRL | Qt::Key_X); | |
88 | qAct_copy->setShortcut (Qt::CTRL | Qt::Key_C); | |
89 | qAct_paste->setShortcut (Qt::CTRL | Qt::Key_V); | |
90 | ||
91 | // things not implemented yet | |
92 | QAction* qaDisabledActions[] = { | |
93 | qAct_saveAs, | |
94 | qAct_newSubfile, | |
95 | qAct_newTriangle, | |
96 | qAct_newQuad, | |
97 | qAct_newCondLine, | |
98 | qAct_newComment, | |
99 | qAct_newVector, | |
100 | qAct_newVertex, | |
101 | qAct_cut, | |
102 | qAct_copy, | |
103 | qAct_paste, | |
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
|
104 | 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
|
105 | qAct_inline, |
0 | 106 | }; |
107 | ||
108 | for (ushort i = 0; i < sizeof qaDisabledActions / sizeof *qaDisabledActions; ++i) | |
109 | qaDisabledActions[i]->setEnabled (false); | |
110 | } | |
111 | ||
112 | void LDForgeWindow::createMenus () { | |
113 | // File menu | |
114 | qFileMenu = menuBar ()->addMenu (tr ("&File")); | |
115 | qFileMenu->addAction (qAct_new); // New | |
116 | qFileMenu->addAction (qAct_open); // Open | |
117 | qFileMenu->addAction (qAct_save); // Save | |
118 | qFileMenu->addAction (qAct_saveAs); // Save As | |
119 | qFileMenu->addSeparator (); // ------- | |
120 | qFileMenu->addAction (qAct_exit); // Exit | |
121 | ||
122 | // Edit menu | |
123 | qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); | |
124 | qInsertMenu->addAction (qAct_newSubfile); // New Subfile | |
125 | qInsertMenu->addAction (qAct_newLine); // New Line | |
126 | qInsertMenu->addAction (qAct_newTriangle); // New Triangle | |
127 | qInsertMenu->addAction (qAct_newQuad); // New Quad | |
128 | qInsertMenu->addAction (qAct_newCondLine); // New Conditional Line | |
129 | qInsertMenu->addAction (qAct_newComment); // New Comment | |
130 | qInsertMenu->addAction (qAct_newVector); // New Vector | |
131 | qInsertMenu->addAction (qAct_newVertex); // New Vertex | |
132 | ||
133 | qEditMenu = menuBar ()->addMenu (tr ("&Edit")); | |
134 | qEditMenu->addAction (qAct_cut); // Cut | |
135 | qEditMenu->addAction (qAct_copy); // Copy | |
136 | qEditMenu->addAction (qAct_paste); // Paste | |
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
|
137 | 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
|
138 | qEditMenu->addAction (qAct_inline); // Inline |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
139 | 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
|
140 | qEditMenu->addAction (qAct_setContents); // Set Contents |
0 | 141 | |
142 | // Help menu | |
143 | qHelpMenu = menuBar ()->addMenu (tr ("&Help")); | |
144 | qHelpMenu->addAction (qAct_about); // About | |
145 | qHelpMenu->addAction (qAct_aboutQt); // About Qt | |
146 | } | |
147 | ||
148 | void LDForgeWindow::createToolbars () { | |
149 | qFileToolBar = new QToolBar ("File"); | |
150 | qFileToolBar->addAction (qAct_new); | |
151 | qFileToolBar->addAction (qAct_open); | |
152 | qFileToolBar->addAction (qAct_save); | |
153 | qFileToolBar->addAction (qAct_saveAs); | |
154 | addToolBar (qFileToolBar); | |
155 | ||
156 | qInsertToolBar = new QToolBar ("Insert"); | |
157 | qInsertToolBar->addAction (qAct_newSubfile); | |
158 | qInsertToolBar->addAction (qAct_newLine); | |
159 | qInsertToolBar->addAction (qAct_newTriangle); | |
160 | qInsertToolBar->addAction (qAct_newQuad); | |
161 | qInsertToolBar->addAction (qAct_newCondLine); | |
162 | qInsertToolBar->addAction (qAct_newComment); | |
163 | qInsertToolBar->addAction (qAct_newVector); | |
164 | qInsertToolBar->addAction (qAct_newVertex); | |
165 | addToolBar (qInsertToolBar); | |
166 | ||
167 | qEditToolBar = new QToolBar ("Edit"); | |
168 | qEditToolBar->addAction (qAct_cut); | |
169 | qEditToolBar->addAction (qAct_copy); | |
170 | qEditToolBar->addAction (qAct_paste); | |
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
|
171 | qEditToolBar->addAction (qAct_inline); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
172 | 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
|
173 | qEditToolBar->addAction (qAct_setContents); |
0 | 174 | addToolBar (qEditToolBar); |
175 | } | |
176 | ||
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
177 | void LDForgeWindow::setTitle () { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
178 | str zTitle = APPNAME_DISPLAY " v" VERSION_STRING; |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
179 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
180 | // 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
|
181 | if (g_CurrentFile) { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
182 | 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
|
183 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
184 | if (g_CurrentFile->objects.size() > 0 && |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
185 | g_CurrentFile->objects[0]->getType() == OBJ_Comment) |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
186 | { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
187 | // Append title |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
188 | 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
|
189 | zTitle.appendformat (":%s", comm->zText.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
190 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
191 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
192 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
193 | setWindowTitle (zTitle.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
194 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
195 | |
0 | 196 | void LDForgeWindow::slot_new () { |
197 | printf ("new file\n"); | |
198 | ||
199 | closeModel (); | |
200 | newModel (); | |
201 | } | |
202 | ||
203 | void LDForgeWindow::slot_open () { | |
4
758302636564
improve opening, don't auto-load 55966.dat (:P)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
204 | str name = QFileDialog::getOpenFileName (this, "Open File", |
0 | 205 | "", "LDraw files (*.dat *.ldr)").toStdString().c_str(); |
206 | ||
23
69a91c1ff583
begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents:
22
diff
changeset
|
207 | openModel (name); |
0 | 208 | } |
209 | ||
210 | void LDForgeWindow::slot_save () { | |
20
2ca638886082
Yay! This thing can save now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
211 | saveModel (); |
0 | 212 | } |
213 | ||
214 | void LDForgeWindow::slot_saveAs () { | |
215 | printf ("save as file\n"); | |
216 | } | |
217 | ||
218 | void LDForgeWindow::slot_exit () { | |
219 | printf ("exit\n"); | |
220 | exit (0); | |
221 | } | |
222 | ||
223 | void LDForgeWindow::slot_newSubfile () { | |
224 | ||
225 | } | |
226 | ||
227 | void LDForgeWindow::slot_newLine () { | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
228 | LDLine* line = new LDLine; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
229 | const ulong ulSpot = getInsertionPoint (); |
0 | 230 | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
231 | memset (line->vaCoords, 0, sizeof line->vaCoords); |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
232 | line->dColor = 24; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
233 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
234 | g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ulSpot, line); |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
235 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
236 | buildObjList (); |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
237 | R->hardRefresh (); |
0 | 238 | } |
239 | ||
240 | void LDForgeWindow::slot_newTriangle () { | |
241 | ||
242 | } | |
243 | ||
244 | void LDForgeWindow::slot_newQuad () { | |
245 | ||
246 | } | |
247 | ||
248 | void LDForgeWindow::slot_newCondLine () { | |
249 | ||
250 | } | |
251 | ||
252 | void LDForgeWindow::slot_newComment () { | |
253 | ||
254 | } | |
255 | ||
256 | void LDForgeWindow::slot_about () { | |
257 | ||
258 | } | |
259 | ||
260 | void LDForgeWindow::slot_aboutQt () { | |
261 | QMessageBox::aboutQt (this); | |
262 | } | |
263 | ||
264 | void LDForgeWindow::slot_cut () { | |
265 | ||
266 | } | |
267 | ||
268 | void LDForgeWindow::slot_copy () { | |
269 | ||
270 | } | |
271 | ||
272 | void LDForgeWindow::slot_paste () { | |
273 | ||
274 | } | |
275 | ||
276 | void LDForgeWindow::slot_newVector () { | |
277 | ||
278 | } | |
279 | ||
280 | void LDForgeWindow::slot_newVertex () { | |
281 | ||
282 | } | |
283 | ||
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
|
284 | void LDForgeWindow::slot_inline () { |
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
|
285 | |
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
|
286 | } |
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
|
287 | |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
288 | void LDForgeWindow::slot_splitQuads () { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
289 | if (qObjList->selectedItems().size() == 0) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
290 | return; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
291 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
292 | const QList<QTreeWidgetItem*> qaItems = qObjList->selectedItems(); |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
293 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
294 | for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
295 | LDObject* obj = g_CurrentFile->objects[i]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
296 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
297 | // Don't even consider non-quads |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
298 | if (obj->getType() != OBJ_Quad) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
299 | continue; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
300 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
301 | bool bIsSelected = false; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
302 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
303 | for (long j = 0; j < qaItems.size(); ++j) { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
304 | if (qaItems[j] == obj->qObjListEntry) { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
305 | bIsSelected = true; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
306 | break; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
307 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
308 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
309 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
310 | if (!bIsSelected) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
311 | continue; // Was not selected |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
312 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
313 | static_cast<LDQuad*> (obj)->splitToTriangles (); |
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
|
314 | i++;// Skip past the second triangle |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
315 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
316 | |
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
|
317 | printf ("build obj list\n"); |
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
|
318 | buildObjList (); |
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
|
319 | |
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
|
320 | printf ("refresh teh renderer\n"); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
321 | R->hardRefresh (); |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
322 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
323 | |
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
|
324 | void LDForgeWindow::slot_setContents () { |
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
|
325 | 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
|
326 | 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
|
327 | |
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
|
328 | ulong ulIndex; |
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
|
329 | LDObject* obj = nullptr; |
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
|
330 | |
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
|
331 | QTreeWidgetItem* item = qObjList->selectedItems()[0]; |
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
|
332 | for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) { |
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
|
333 | obj = g_CurrentFile->objects[ulIndex]; |
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
|
334 | |
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
|
335 | if (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
|
336 | break; |
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
|
337 | } |
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
|
338 | |
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
|
339 | if (ulIndex >= g_CurrentFile->objects.size()) |
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
|
340 | 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
|
341 | |
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
|
342 | Dialog_SetContents::staticDialog (obj, this); |
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
|
343 | } |
0 | 344 | |
345 | static QIcon IconForObjectType (LDObject* obj) { | |
346 | switch (obj->getType ()) { | |
347 | case OBJ_Empty: | |
348 | return QIcon ("icons/empty.png"); | |
349 | ||
350 | case OBJ_Line: | |
351 | return QIcon ("icons/line.png"); | |
352 | ||
353 | case OBJ_Quad: | |
354 | return QIcon ("icons/quad.png"); | |
355 | ||
356 | case OBJ_Subfile: | |
357 | return QIcon ("icons/subfile.png"); | |
358 | ||
359 | case OBJ_Triangle: | |
360 | return QIcon ("icons/triangle.png"); | |
361 | ||
362 | case OBJ_CondLine: | |
363 | return QIcon ("icons/condline.png"); | |
364 | ||
365 | case OBJ_Comment: | |
366 | return QIcon ("icons/comment.png"); | |
367 | ||
368 | case OBJ_Vector: | |
369 | return QIcon ("icons/vector.png"); | |
370 | ||
371 | case OBJ_Vertex: | |
372 | return QIcon ("icons/vertex.png"); | |
373 | ||
374 | case OBJ_Gibberish: | |
375 | case OBJ_Unidentified: | |
376 | return QIcon ("icons/error.png"); | |
377 | } | |
378 | ||
379 | return QIcon (); | |
380 | } | |
381 | ||
382 | void LDForgeWindow::buildObjList () { | |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
383 | if (!g_CurrentFile) |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
384 | return; |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
385 | |
0 | 386 | QList<QTreeWidgetItem*> qaItems; |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
387 | |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
388 | qObjList->clear (); |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
389 | |
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
|
390 | for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
0 | 391 | LDObject* obj = g_CurrentFile->objects[i]; |
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
|
392 | printf ("%lu: %p\n", i, obj); |
0 | 393 | |
394 | str zText; | |
395 | switch (obj->getType ()) { | |
396 | 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
|
397 | 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
|
398 | |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
399 | // Remove leading whitespace |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
400 | 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
|
401 | zText -= -1; |
0 | 402 | break; |
403 | ||
404 | case OBJ_Empty: | |
405 | break; // leave it empty | |
406 | ||
407 | case OBJ_Line: | |
408 | case OBJ_CondLine: | |
409 | { | |
410 | LDLine* line = static_cast<LDLine*> (obj); | |
411 | 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
|
412 | 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
|
413 | line->vaCoords[1].getStringRep (true).chars()); |
0 | 414 | } |
415 | break; | |
416 | ||
417 | case OBJ_Triangle: | |
418 | { | |
419 | LDTriangle* triangle = static_cast<LDTriangle*> (obj); | |
420 | 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
|
421 | 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
|
422 | 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
|
423 | triangle->vaCoords[2].getStringRep (true).chars()); |
0 | 424 | } |
425 | break; | |
426 | ||
427 | case OBJ_Quad: | |
428 | { | |
429 | 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
|
430 | 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
|
431 | 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
|
432 | 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
|
433 | 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
|
434 | quad->vaCoords[3].getStringRep (true).chars()); |
0 | 435 | } |
436 | break; | |
437 | ||
438 | case OBJ_Gibberish: | |
439 | 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
|
440 | static_cast<LDGibberish*> (obj)->zContents.chars()); |
0 | 441 | break; |
442 | ||
443 | case OBJ_Vector: | |
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
|
444 | zText.format ("%s", static_cast<LDVector*> (obj)->vPos.getStringRep(true).chars()); |
0 | 445 | break; |
446 | ||
447 | case OBJ_Vertex: | |
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
|
448 | zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep(true).chars()); |
0 | 449 | break; |
450 | ||
451 | default: | |
452 | zText = g_saObjTypeNames[obj->getType ()]; | |
453 | break; | |
454 | } | |
455 | ||
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
|
456 | QTreeWidgetItem* item = new QTreeWidgetItem ((QTreeWidget*) (nullptr), |
0 | 457 | QStringList (zText.chars()), 0); |
458 | item->setIcon (0, IconForObjectType (obj)); | |
459 | ||
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
|
460 | // 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
|
461 | 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
|
462 | 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
|
463 | item->setForeground (0, QColor ("#FFAA00")); |
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
|
464 | } |
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
|
465 | |
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
|
466 | 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
|
467 | |
0 | 468 | qaItems.append (item); |
469 | } | |
470 | ||
471 | 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
|
472 | } |
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
|
473 | |
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
|
474 | void LDForgeWindow::slot_selectionChanged () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
475 | // 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
|
476 | 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
|
477 | |
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
|
478 | // 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
|
479 | qAct_splitQuads->setEnabled (qObjList->selectedItems().size() > 0); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
480 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
481 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
482 | // ============================================================================= |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
483 | // ulong getInsertionPoint () |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
484 | // |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
485 | // Returns the index of where a new item should be placed at. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
486 | // ============================================================================= |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
487 | ulong LDForgeWindow::getInsertionPoint () { |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
488 | 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
|
489 | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
490 | if (qObjList->selectedItems().size() == 1) { |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
491 | // 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
|
492 | for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
493 | if (g_CurrentFile->objects[ulIndex]->qObjListEntry == qObjList->selectedItems()[0]) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
494 | break; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
495 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
496 | if (ulIndex >= g_CurrentFile->objects.size()) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
497 | return ulIndex + 1; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
498 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
499 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
500 | // Otherwise place the object at the end. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
501 | return g_CurrentFile->objects.size(); |
0 | 502 | } |