122 } |
122 } |
123 |
123 |
124 // ============================================================================= |
124 // ============================================================================= |
125 // ----------------------------------------------------------------------------- |
125 // ----------------------------------------------------------------------------- |
126 DEFINE_ACTION (Save, CTRL (S)) |
126 DEFINE_ACTION (Save, CTRL (S)) |
127 { g_win->save (getCurrentDocument(), false); |
127 { save (getCurrentDocument(), false); |
128 } |
128 } |
129 |
129 |
130 // ============================================================================= |
130 // ============================================================================= |
131 // ----------------------------------------------------------------------------- |
131 // ----------------------------------------------------------------------------- |
132 DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) |
132 DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) |
133 { g_win->save (getCurrentDocument(), true); |
133 { save (getCurrentDocument(), true); |
134 } |
134 } |
135 |
135 |
136 // ============================================================================= |
136 // ============================================================================= |
137 // ----------------------------------------------------------------------------- |
137 // ----------------------------------------------------------------------------- |
138 DEFINE_ACTION (SaveAll, CTRL (L)) |
138 DEFINE_ACTION (SaveAll, CTRL (L)) |
139 { for (LDDocument* file : g_loadedFiles) |
139 { for (LDDocument* file : g_loadedFiles) |
140 { if (file->isImplicit()) |
140 { if (file->isImplicit()) |
141 continue; |
141 continue; |
142 |
142 |
143 g_win->save (file, false); |
143 save (file, false); |
144 } |
144 } |
145 } |
145 } |
146 |
146 |
147 // ============================================================================= |
147 // ============================================================================= |
148 // ----------------------------------------------------------------------------- |
148 // ----------------------------------------------------------------------------- |
260 // ----------------------------------------------------------------------------- |
260 // ----------------------------------------------------------------------------- |
261 DEFINE_ACTION (SelectAll, CTRL (A)) |
261 DEFINE_ACTION (SelectAll, CTRL (A)) |
262 { for (LDObject* obj : getCurrentDocument()->getObjects()) |
262 { for (LDObject* obj : getCurrentDocument()->getObjects()) |
263 obj->select(); |
263 obj->select(); |
264 |
264 |
265 g_win->updateSelection(); |
265 updateSelection(); |
266 } |
266 } |
267 |
267 |
268 // ============================================================================= |
268 // ============================================================================= |
269 // ----------------------------------------------------------------------------- |
269 // ----------------------------------------------------------------------------- |
270 DEFINE_ACTION (SelectByColor, CTRL_SHIFT (A)) |
270 DEFINE_ACTION (SelectByColor, CTRL_SHIFT (A)) |
271 { int colnum = g_win->getSelectedColor(); |
271 { int colnum = getSelectedColor(); |
272 |
272 |
273 if (colnum == -1) |
273 if (colnum == -1) |
274 return; // no consensus on color |
274 return; // no consensus on color |
275 |
275 |
276 getCurrentDocument()->clearSelection(); |
276 getCurrentDocument()->clearSelection(); |
277 |
277 |
278 for (LDObject* obj : getCurrentDocument()->getObjects()) |
278 for (LDObject* obj : getCurrentDocument()->getObjects()) |
279 if (obj->getColor() == colnum) |
279 if (obj->getColor() == colnum) |
280 obj->select(); |
280 obj->select(); |
281 |
281 |
282 g_win->updateSelection(); |
282 updateSelection(); |
283 } |
283 } |
284 |
284 |
285 // ============================================================================= |
285 // ============================================================================= |
286 // ----------------------------------------------------------------------------- |
286 // ----------------------------------------------------------------------------- |
287 DEFINE_ACTION (SelectByType, 0) |
287 DEFINE_ACTION (SelectByType, 0) |
288 { if (selection().isEmpty()) |
288 { if (selection().isEmpty()) |
289 return; |
289 return; |
290 |
290 |
291 LDObject::Type type = g_win->getUniformSelectedType(); |
291 LDObject::Type type = getUniformSelectedType(); |
292 |
292 |
293 if (type == LDObject::Unidentified) |
293 if (type == LDObject::Unidentified) |
294 return; |
294 return; |
295 |
295 |
296 // If we're selecting subfile references, the reference filename must also |
296 // If we're selecting subfile references, the reference filename must also |
315 continue; |
315 continue; |
316 |
316 |
317 obj->select(); |
317 obj->select(); |
318 } |
318 } |
319 |
319 |
320 g_win->updateSelection(); |
320 updateSelection(); |
321 } |
321 } |
322 |
322 |
323 // ============================================================================= |
323 // ============================================================================= |
324 // ----------------------------------------------------------------------------- |
324 // ----------------------------------------------------------------------------- |
325 DEFINE_ACTION (GridCoarse, 0) |
325 DEFINE_ACTION (GridCoarse, 0) |
326 { grid = Grid::Coarse; |
326 { grid = Grid::Coarse; |
327 g_win->updateGridToolBar(); |
327 updateGridToolBar(); |
328 } |
328 } |
329 |
329 |
330 DEFINE_ACTION (GridMedium, 0) |
330 DEFINE_ACTION (GridMedium, 0) |
331 { grid = Grid::Medium; |
331 { grid = Grid::Medium; |
332 g_win->updateGridToolBar(); |
332 updateGridToolBar(); |
333 } |
333 } |
334 |
334 |
335 DEFINE_ACTION (GridFine, 0) |
335 DEFINE_ACTION (GridFine, 0) |
336 { grid = Grid::Fine; |
336 { grid = Grid::Fine; |
337 g_win->updateGridToolBar(); |
337 updateGridToolBar(); |
338 } |
338 } |
339 |
339 |
340 // ============================================================================= |
340 // ============================================================================= |
341 // ----------------------------------------------------------------------------- |
341 // ----------------------------------------------------------------------------- |
342 DEFINE_ACTION (ResetView, CTRL (0)) |
342 DEFINE_ACTION (ResetView, CTRL (0)) |
343 { g_win->R()->resetAngles(); |
343 { R()->resetAngles(); |
344 g_win->R()->update(); |
344 R()->update(); |
345 } |
345 } |
346 |
346 |
347 // ============================================================================= |
347 // ============================================================================= |
348 // ----------------------------------------------------------------------------- |
348 // ----------------------------------------------------------------------------- |
349 DEFINE_ACTION (InsertFrom, 0) |
349 DEFINE_ACTION (InsertFrom, 0) |
350 { str fname = QFileDialog::getOpenFileName(); |
350 { str fname = QFileDialog::getOpenFileName(); |
351 int idx = g_win->getInsertionPoint(); |
351 int idx = getInsertionPoint(); |
352 |
352 |
353 if (!fname.length()) |
353 if (!fname.length()) |
354 return; |
354 return; |
355 |
355 |
356 File f (fname, File::Read); |
356 File f (fname, File::Read); |
464 // ============================================================================= |
464 // ============================================================================= |
465 // ----------------------------------------------------------------------------- |
465 // ----------------------------------------------------------------------------- |
466 extern_cfg (Bool, gl_axes); |
466 extern_cfg (Bool, gl_axes); |
467 DEFINE_ACTION (Axes, 0) |
467 DEFINE_ACTION (Axes, 0) |
468 { gl_axes = !gl_axes; |
468 { gl_axes = !gl_axes; |
469 g_win->updateActions(); |
469 updateActions(); |
470 g_win->R()->update(); |
470 R()->update(); |
471 } |
471 } |
472 |
472 |
473 // ============================================================================= |
473 // ============================================================================= |
474 // ----------------------------------------------------------------------------- |
474 // ----------------------------------------------------------------------------- |
475 DEFINE_ACTION (VisibilityToggle, 0) |
475 DEFINE_ACTION (VisibilityToggle, 0) |
476 { for (LDObject* obj : selection()) |
476 { for (LDObject* obj : selection()) |
477 obj->toggleHidden(); |
477 obj->toggleHidden(); |
478 |
478 |
479 g_win->refresh(); |
479 refresh(); |
480 } |
480 } |
481 |
481 |
482 // ============================================================================= |
482 // ============================================================================= |
483 // ----------------------------------------------------------------------------- |
483 // ----------------------------------------------------------------------------- |
484 DEFINE_ACTION (VisibilityHide, 0) |
484 DEFINE_ACTION (VisibilityHide, 0) |
485 { for (LDObject* obj : selection()) |
485 { for (LDObject* obj : selection()) |
486 obj->setHidden (true); |
486 obj->setHidden (true); |
487 |
487 |
488 g_win->refresh(); |
488 refresh(); |
489 } |
489 } |
490 |
490 |
491 // ============================================================================= |
491 // ============================================================================= |
492 // ----------------------------------------------------------------------------- |
492 // ----------------------------------------------------------------------------- |
493 DEFINE_ACTION (VisibilityReveal, 0) |
493 DEFINE_ACTION (VisibilityReveal, 0) |
494 { for (LDObject* obj : selection()) |
494 { for (LDObject* obj : selection()) |
495 obj->setHidden (false); |
495 obj->setHidden (false); |
496 g_win->refresh(); |
496 refresh(); |
497 } |
497 } |
498 |
498 |
499 // ============================================================================= |
499 // ============================================================================= |
500 // ----------------------------------------------------------------------------- |
500 // ----------------------------------------------------------------------------- |
501 DEFINE_ACTION (Wireframe, 0) |
501 DEFINE_ACTION (Wireframe, 0) |
502 { gl_wireframe = !gl_wireframe; |
502 { gl_wireframe = !gl_wireframe; |
503 g_win->R()->refresh(); |
503 R()->refresh(); |
504 } |
504 } |
505 |
505 |
506 // ============================================================================= |
506 // ============================================================================= |
507 // ----------------------------------------------------------------------------- |
507 // ----------------------------------------------------------------------------- |
508 DEFINE_ACTION (SetOverlay, 0) |
508 DEFINE_ACTION (SetOverlay, 0) |
509 { OverlayDialog dlg; |
509 { OverlayDialog dlg; |
510 |
510 |
511 if (!dlg.exec()) |
511 if (!dlg.exec()) |
512 return; |
512 return; |
513 |
513 |
514 g_win->R()->setupOverlay ((GL::EFixedCamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
514 R()->setupOverlay ((GL::EFixedCamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
515 dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
515 dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
516 } |
516 } |
517 |
517 |
518 // ============================================================================= |
518 // ============================================================================= |
519 // ----------------------------------------------------------------------------- |
519 // ----------------------------------------------------------------------------- |
520 DEFINE_ACTION (ClearOverlay, 0) |
520 DEFINE_ACTION (ClearOverlay, 0) |
521 { g_win->R()->clearOverlay(); |
521 { R()->clearOverlay(); |
522 } |
522 } |
523 |
523 |
524 // ============================================================================= |
524 // ============================================================================= |
525 // ----------------------------------------------------------------------------- |
525 // ----------------------------------------------------------------------------- |
526 DEFINE_ACTION (ModeSelect, CTRL (1)) |
526 DEFINE_ACTION (ModeSelect, CTRL (1)) |
527 { g_win->R()->setEditMode (ESelectMode); |
527 { R()->setEditMode (ESelectMode); |
528 } |
528 } |
529 |
529 |
530 // ============================================================================= |
530 // ============================================================================= |
531 // ----------------------------------------------------------------------------- |
531 // ----------------------------------------------------------------------------- |
532 DEFINE_ACTION (ModeDraw, CTRL (2)) |
532 DEFINE_ACTION (ModeDraw, CTRL (2)) |
533 { g_win->R()->setEditMode (EDrawMode); |
533 { R()->setEditMode (EDrawMode); |
534 } |
534 } |
535 |
535 |
536 // ============================================================================= |
536 // ============================================================================= |
537 // ----------------------------------------------------------------------------- |
537 // ----------------------------------------------------------------------------- |
538 DEFINE_ACTION (ModeCircle, CTRL (3)) |
538 DEFINE_ACTION (ModeCircle, CTRL (3)) |
539 { g_win->R()->setEditMode (ECircleMode); |
539 { R()->setEditMode (ECircleMode); |
540 } |
540 } |
541 |
541 |
542 // ============================================================================= |
542 // ============================================================================= |
543 // ----------------------------------------------------------------------------- |
543 // ----------------------------------------------------------------------------- |
544 DEFINE_ACTION (DrawAngles, 0) |
544 DEFINE_ACTION (DrawAngles, 0) |
545 { gl_drawangles = !gl_drawangles; |
545 { gl_drawangles = !gl_drawangles; |
546 g_win->R()->refresh(); |
546 R()->refresh(); |
547 } |
547 } |
548 |
548 |
549 // ============================================================================= |
549 // ============================================================================= |
550 // ----------------------------------------------------------------------------- |
550 // ----------------------------------------------------------------------------- |
551 DEFINE_ACTION (SetDrawDepth, 0) |
551 DEFINE_ACTION (SetDrawDepth, 0) |
552 { if (g_win->R()->camera() == GL::EFreeCamera) |
552 { if (R()->camera() == GL::EFreeCamera) |
553 return; |
553 return; |
554 |
554 |
555 bool ok; |
555 bool ok; |
556 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", |
556 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", |
557 fmt ("Depth value for %1 Camera:", g_win->R()->getCameraName()), |
557 fmt ("Depth value for %1 Camera:", R()->getCameraName()), |
558 g_win->R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
558 R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
559 |
559 |
560 if (ok) |
560 if (ok) |
561 g_win->R()->setDepthValue (depth); |
561 R()->setDepthValue (depth); |
562 } |
562 } |
563 |
563 |
564 #if 0 |
564 #if 0 |
565 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
565 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
566 // but I can't figure how to generate these pictures properly. Multi-threading |
566 // but I can't figure how to generate these pictures properly. Multi-threading |
767 { LDObject* obj = parseLine (line); |
767 { LDObject* obj = parseLine (line); |
768 doc->addObject (obj); |
768 doc->addObject (obj); |
769 } |
769 } |
770 |
770 |
771 // Try save it |
771 // Try save it |
772 if (g_win->save (doc, true)) |
772 if (save (doc, true)) |
773 { // Remove the selection now |
773 { // Remove the selection now |
774 for (LDObject* obj : selection()) |
774 for (LDObject* obj : selection()) |
775 obj->deleteSelf(); |
775 obj->deleteSelf(); |
776 |
776 |
777 // Compile all objects in the new subfile |
777 // Compile all objects in the new subfile |
778 for (LDObject* obj : doc->getObjects()) |
778 for (LDObject* obj : doc->getObjects()) |
779 g_win->R()->compileObject (obj); |
779 R()->compileObject (obj); |
780 |
780 |
781 g_loadedFiles << doc; |
781 g_loadedFiles << doc; |
782 |
782 |
783 // Add a reference to the new subfile to where the selection was |
783 // Add a reference to the new subfile to where the selection was |
784 LDSubfile* ref = new LDSubfile(); |
784 LDSubfile* ref = new LDSubfile(); |
785 ref->setColor (maincolor); |
785 ref->setColor (maincolor); |
786 ref->setFileInfo (doc); |
786 ref->setFileInfo (doc); |
787 ref->setPosition (g_origin); |
787 ref->setPosition (g_origin); |
788 ref->setTransform (g_identity); |
788 ref->setTransform (g_identity); |
789 getCurrentDocument()->insertObj (refidx, ref); |
789 getCurrentDocument()->insertObj (refidx, ref); |
790 g_win->R()->compileObject (ref); |
790 R()->compileObject (ref); |
791 |
791 |
792 // Refresh stuff |
792 // Refresh stuff |
793 g_win->updateDocumentList(); |
793 updateDocumentList(); |
794 g_win->doFullRefresh(); |
794 doFullRefresh(); |
795 } |
795 } |
796 else |
796 else |
797 { // Failed to save. |
797 { // Failed to save. |
798 delete doc; |
798 delete doc; |
799 } |
799 } |