53 Ui::NewPartUI ui; |
53 Ui::NewPartUI ui; |
54 ui.setupUi (dlg); |
54 ui.setupUi (dlg); |
55 |
55 |
56 QString authortext = ld_defaultname; |
56 QString authortext = ld_defaultname; |
57 |
57 |
58 if (!ld_defaultuser.isEmpty()) |
58 if (not ld_defaultuser.isEmpty()) |
59 authortext.append (format (" [%1]", ld_defaultuser)); |
59 authortext.append (format (" [%1]", ld_defaultuser)); |
60 |
60 |
61 ui.le_author->setText (authortext); |
61 ui.le_author->setText (authortext); |
62 |
62 |
63 switch (ld_defaultlicense) |
63 switch (ld_defaultlicense) |
78 QMessageBox::warning (null, "Warning", |
78 QMessageBox::warning (null, "Warning", |
79 format ("Unknown ld_defaultlicense value %1!", ld_defaultlicense)); |
79 format ("Unknown ld_defaultlicense value %1!", ld_defaultlicense)); |
80 break; |
80 break; |
81 } |
81 } |
82 |
82 |
83 if (dlg->exec() == false) |
83 if (dlg->exec() == QDialog::Rejected) |
84 return; |
84 return; |
85 |
85 |
86 newFile(); |
86 newFile(); |
87 |
87 |
88 const LDBFC::Statement BFCType = |
88 const LDBFC::Statement BFCType = |
156 |
156 |
157 // ============================================================================= |
157 // ============================================================================= |
158 // |
158 // |
159 DEFINE_ACTION (Close, CTRL (W)) |
159 DEFINE_ACTION (Close, CTRL (W)) |
160 { |
160 { |
161 if (!getCurrentDocument()->isSafeToClose()) |
161 if (not getCurrentDocument()->isSafeToClose()) |
162 return; |
162 return; |
163 |
163 |
164 delete getCurrentDocument(); |
164 delete getCurrentDocument(); |
165 } |
165 } |
166 |
166 |
167 // ============================================================================= |
167 // ============================================================================= |
168 // |
168 // |
169 DEFINE_ACTION (CloseAll, 0) |
169 DEFINE_ACTION (CloseAll, 0) |
170 { |
170 { |
171 if (!safeToCloseAll()) |
171 if (not safeToCloseAll()) |
172 return; |
172 return; |
173 |
173 |
174 closeAll(); |
174 closeAll(); |
175 } |
175 } |
176 |
176 |
384 DEFINE_ACTION (InsertFrom, 0) |
384 DEFINE_ACTION (InsertFrom, 0) |
385 { |
385 { |
386 QString fname = QFileDialog::getOpenFileName(); |
386 QString fname = QFileDialog::getOpenFileName(); |
387 int idx = getInsertionPoint(); |
387 int idx = getInsertionPoint(); |
388 |
388 |
389 if (!fname.length()) |
389 if (not fname.length()) |
390 return; |
390 return; |
391 |
391 |
392 QFile f (fname); |
392 QFile f (fname); |
393 |
393 |
394 if (!f.open (QIODevice::ReadOnly)) |
394 if (not f.open (QIODevice::ReadOnly)) |
395 { |
395 { |
396 critical (format ("Couldn't open %1 (%2)", fname, f.errorString())); |
396 critical (format ("Couldn't open %1 (%2)", fname, f.errorString())); |
397 return; |
397 return; |
398 } |
398 } |
399 |
399 |
455 QDialogButtonBox* const bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
455 QDialogButtonBox* const bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
456 |
456 |
457 layout->addWidget (te_edit); |
457 layout->addWidget (te_edit); |
458 layout->addWidget (bbx_buttons); |
458 layout->addWidget (bbx_buttons); |
459 dlg->setLayout (layout); |
459 dlg->setLayout (layout); |
460 dlg->setWindowTitle (APPNAME ": Insert Raw"); |
460 dlg->setWindowTitle (APPNAME " - Insert Raw"); |
461 dlg->connect (bbx_buttons, SIGNAL (accepted()), dlg, SLOT (accept())); |
461 dlg->connect (bbx_buttons, SIGNAL (accepted()), dlg, SLOT (accept())); |
462 dlg->connect (bbx_buttons, SIGNAL (rejected()), dlg, SLOT (reject())); |
462 dlg->connect (bbx_buttons, SIGNAL (rejected()), dlg, SLOT (reject())); |
463 |
463 |
464 if (dlg->exec() == false) |
464 if (dlg->exec() == QDialog::Rejected) |
465 return; |
465 return; |
466 |
466 |
467 getCurrentDocument()->clearSelection(); |
467 getCurrentDocument()->clearSelection(); |
468 |
468 |
469 for (QString line : QString (te_edit->toPlainText()).split ("\n")) |
469 for (QString line : QString (te_edit->toPlainText()).split ("\n")) |
496 |
496 |
497 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; |
497 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; |
498 QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
498 QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
499 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
499 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
500 |
500 |
501 if (fname.length() > 0 && !img.save (fname)) |
501 if (not fname.isEmpty() && not img.save (fname)) |
502 critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); |
502 critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); |
503 |
503 |
504 delete[] imgdata; |
504 delete[] imgdata; |
505 } |
505 } |
506 |
506 |
507 // ============================================================================= |
507 // ============================================================================= |
508 // |
508 // |
509 extern_cfg (Bool, gl_axes); |
509 extern_cfg (Bool, gl_axes); |
510 DEFINE_ACTION (Axes, 0) |
510 DEFINE_ACTION (Axes, 0) |
511 { |
511 { |
512 gl_axes = !gl_axes; |
512 gl_axes = not gl_axes; |
513 updateActions(); |
513 updateActions(); |
514 R()->update(); |
514 R()->update(); |
515 } |
515 } |
516 |
516 |
517 // ============================================================================= |
517 // ============================================================================= |
518 // |
518 // |
519 DEFINE_ACTION (VisibilityToggle, 0) |
519 DEFINE_ACTION (VisibilityToggle, 0) |
520 { |
520 { |
521 for (LDObject* obj : selection()) |
521 for (LDObject* obj : selection()) |
522 obj->setHidden (!obj->isHidden()); |
522 obj->setHidden (not obj->isHidden()); |
523 |
523 |
524 refresh(); |
524 refresh(); |
525 } |
525 } |
526 |
526 |
527 // ============================================================================= |
527 // ============================================================================= |
545 |
545 |
546 // ============================================================================= |
546 // ============================================================================= |
547 // |
547 // |
548 DEFINE_ACTION (Wireframe, 0) |
548 DEFINE_ACTION (Wireframe, 0) |
549 { |
549 { |
550 gl_wireframe = !gl_wireframe; |
550 gl_wireframe = not gl_wireframe; |
551 R()->refresh(); |
551 R()->refresh(); |
552 } |
552 } |
553 |
553 |
554 // ============================================================================= |
554 // ============================================================================= |
555 // |
555 // |
556 DEFINE_ACTION (SetOverlay, 0) |
556 DEFINE_ACTION (SetOverlay, 0) |
557 { |
557 { |
558 OverlayDialog dlg; |
558 OverlayDialog dlg; |
559 |
559 |
560 if (!dlg.exec()) |
560 if (not dlg.exec()) |
561 return; |
561 return; |
562 |
562 |
563 R()->setupOverlay ((GL::EFixedCamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
563 R()->setupOverlay ((GL::EFixedCamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
564 dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
564 dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
565 } |
565 } |
594 |
594 |
595 // ============================================================================= |
595 // ============================================================================= |
596 // |
596 // |
597 DEFINE_ACTION (DrawAngles, 0) |
597 DEFINE_ACTION (DrawAngles, 0) |
598 { |
598 { |
599 gl_drawangles = !gl_drawangles; |
599 gl_drawangles = not gl_drawangles; |
600 R()->refresh(); |
600 R()->refresh(); |
601 } |
601 } |
602 |
602 |
603 // ============================================================================= |
603 // ============================================================================= |
604 // |
604 // |
623 DEFINE_ACTION (testpic, "Test picture", "", "", (0)) |
623 DEFINE_ACTION (testpic, "Test picture", "", "", (0)) |
624 { |
624 { |
625 LDDocument* file = getFile ("axle.dat"); |
625 LDDocument* file = getFile ("axle.dat"); |
626 setlocale (LC_ALL, "C"); |
626 setlocale (LC_ALL, "C"); |
627 |
627 |
628 if (!file) |
628 if (not file) |
629 { |
629 { |
630 critical ("couldn't load axle.dat"); |
630 critical ("couldn't load axle.dat"); |
631 return; |
631 return; |
632 } |
632 } |
633 |
633 |
674 |
674 |
675 // ============================================================================= |
675 // ============================================================================= |
676 // |
676 // |
677 DEFINE_ACTION (BFCView, SHIFT (B)) |
677 DEFINE_ACTION (BFCView, SHIFT (B)) |
678 { |
678 { |
679 gl_colorbfc = !gl_colorbfc; |
679 gl_colorbfc = not gl_colorbfc; |
680 updateActions(); |
680 updateActions(); |
681 R()->refresh(); |
681 R()->refresh(); |
682 } |
682 } |
683 |
683 |
684 // ============================================================================= |
684 // ============================================================================= |
693 defval = selection()[0]->lineNumber(); |
693 defval = selection()[0]->lineNumber(); |
694 |
694 |
695 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, |
695 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, |
696 1, getCurrentDocument()->getObjectCount(), 1, &ok); |
696 1, getCurrentDocument()->getObjectCount(), 1, &ok); |
697 |
697 |
698 if (!ok || (obj = getCurrentDocument()->getObject (idx - 1)) == null) |
698 if (not ok || (obj = getCurrentDocument()->getObject (idx - 1)) == null) |
699 return; |
699 return; |
700 |
700 |
701 getCurrentDocument()->clearSelection(); |
701 getCurrentDocument()->clearSelection(); |
702 obj->select(); |
702 obj->select(); |
703 updateSelection(); |
703 updateSelection(); |
763 QDir().mkpath (subdirname); |
763 QDir().mkpath (subdirname); |
764 } |
764 } |
765 } |
765 } |
766 |
766 |
767 // Determine the body of the name of the subfile |
767 // Determine the body of the name of the subfile |
768 if (!parentpath.isEmpty()) |
768 if (not parentpath.isEmpty()) |
769 { |
769 { |
770 if (parentpath.endsWith (".dat")) |
770 if (parentpath.endsWith (".dat")) |
771 parentpath.chop (4); |
771 parentpath.chop (4); |
772 |
772 |
773 // Remove the s?? suffix if it's there, otherwise we'll get filenames |
773 // Remove the s?? suffix if it's there, otherwise we'll get filenames |
797 // be carried over to the subfile. |
797 // be carried over to the subfile. |
798 for (LDObject* obj : getCurrentDocument()->objects()) |
798 for (LDObject* obj : getCurrentDocument()->objects()) |
799 { |
799 { |
800 LDBFC* bfc = dynamic_cast<LDBFC*> (obj); |
800 LDBFC* bfc = dynamic_cast<LDBFC*> (obj); |
801 |
801 |
802 if (!bfc) |
802 if (not bfc) |
803 continue; |
803 continue; |
804 |
804 |
805 LDBFC::Statement a = bfc->statement(); |
805 LDBFC::Statement a = bfc->statement(); |
806 |
806 |
807 if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) |
807 if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) |