| 241 grid = Grid::Fine; |
241 grid = Grid::Fine; |
| 242 g_ForgeWindow->updateGridToolBar (); |
242 g_ForgeWindow->updateGridToolBar (); |
| 243 } |
243 } |
| 244 |
244 |
| 245 // ============================================================================= |
245 // ============================================================================= |
| |
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| |
247 // ============================================================================= |
| 246 MAKE_ACTION (resetView, "Reset View", "reset-view", "Reset view angles, pan and zoom", CTRL (0)) { |
248 MAKE_ACTION (resetView, "Reset View", "reset-view", "Reset view angles, pan and zoom", CTRL (0)) { |
| 247 g_ForgeWindow->R->resetAngles (); |
249 g_ForgeWindow->R->resetAngles (); |
| 248 g_ForgeWindow->R->updateGL (); |
250 g_ForgeWindow->R->updateGL (); |
| 249 } |
251 } |
| 250 |
252 |
| |
253 // ============================================================================= |
| |
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 251 // ============================================================================= |
255 // ============================================================================= |
| 252 MAKE_ACTION (insertFrom, "Insert from File", "insert-from", "Insert LDraw data from a file.", (0)) { |
256 MAKE_ACTION (insertFrom, "Insert from File", "insert-from", "Insert LDraw data from a file.", (0)) { |
| 253 str fname = QFileDialog::getOpenFileName (); |
257 str fname = QFileDialog::getOpenFileName (); |
| 254 ulong idx = g_ForgeWindow->getInsertionPoint (); |
258 ulong idx = g_ForgeWindow->getInsertionPoint (); |
| 255 |
259 |
| 276 |
280 |
| 277 idx++; |
281 idx++; |
| 278 } |
282 } |
| 279 |
283 |
| 280 if (historyCopies.size() > 0) { |
284 if (historyCopies.size() > 0) { |
| |
285 History::addEntry (new AddHistory (historyIndices, historyCopies)); |
| |
286 g_ForgeWindow->refresh (); |
| |
287 g_ForgeWindow->scrollToSelection (); |
| |
288 } |
| |
289 } |
| |
290 |
| |
291 // ============================================================================= |
| |
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| |
293 // ============================================================================= |
| |
294 MAKE_ACTION (insertRaw, "Insert Raw", "insert-raw", "Type in LDraw code to insert.", (0)) { |
| |
295 ulong idx = g_ForgeWindow->getInsertionPoint (); |
| |
296 |
| |
297 QDialog* const dlg = new QDialog; |
| |
298 QVBoxLayout* const layout = new QVBoxLayout; |
| |
299 QTextEdit* const te_edit = new QTextEdit; |
| |
300 QDialogButtonBox* const bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| |
301 std::vector<LDObject*> historyCopies; |
| |
302 std::vector<ulong> historyIndices; |
| |
303 |
| |
304 layout->addWidget (te_edit); |
| |
305 layout->addWidget (bbx_buttons); |
| |
306 dlg->setLayout (layout); |
| |
307 dlg->connect (bbx_buttons, SIGNAL (accepted ()), dlg, SLOT (accept ())); |
| |
308 dlg->connect (bbx_buttons, SIGNAL (rejected ()), dlg, SLOT (reject ())); |
| |
309 |
| |
310 if (dlg->exec () == false) |
| |
311 return; |
| |
312 |
| |
313 g_ForgeWindow->sel.clear (); |
| |
314 |
| |
315 for (str line : str (te_edit->toPlainText ()).split ("\n")) { |
| |
316 LDObject* obj = parseLine (line); |
| |
317 |
| |
318 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin () + idx, obj); |
| |
319 historyIndices.push_back (idx); |
| |
320 historyCopies.push_back (obj->clone ()); |
| |
321 g_ForgeWindow->sel.push_back (obj); |
| |
322 idx++; |
| |
323 } |
| |
324 |
| |
325 if (historyCopies.size () > 0) { |
| 281 History::addEntry (new AddHistory (historyIndices, historyCopies)); |
326 History::addEntry (new AddHistory (historyIndices, historyCopies)); |
| 282 g_ForgeWindow->refresh (); |
327 g_ForgeWindow->refresh (); |
| 283 g_ForgeWindow->scrollToSelection (); |
328 g_ForgeWindow->scrollToSelection (); |
| 284 } |
329 } |
| 285 } |
330 } |