Wed, 08 Jan 2014 21:43:46 +0200
- removed the File class in favor of QFile
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
600
209e3f1f7b2c
- updated copyright year. Best wishes for 2014!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
590
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QFileDialog> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QMessageBox> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QTextEdit> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QBoxLayout> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QDialogButtonBox> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QPushButton> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QInputDialog> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "gui.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "document.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "history.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "configDialog.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "addObjectDialog.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "misc.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "gldraw.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | #include "dialogs.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | #include "primitives.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | #include "ui_newpart.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | #include "widgets.h" |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
38 | #include "colors.h" |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
40 | extern_cfg (Bool, gl_wireframe); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
41 | extern_cfg (Bool, gl_colorbfc); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
42 | extern_cfg (String, ld_defaultname); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
43 | extern_cfg (String, ld_defaultuser); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
44 | extern_cfg (Int, ld_defaultlicense); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
45 | extern_cfg (Bool, gl_drawangles); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | DEFINE_ACTION (New, CTRL_SHIFT (N)) |
603 | 50 | { |
51 | QDialog* dlg = new QDialog (g_win); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | Ui::NewPartUI ui; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | ui.setupUi (dlg); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
55 | QString authortext = ld_defaultname; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
590
7aec744ce97b
- refactored config code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
587
diff
changeset
|
57 | if (!ld_defaultuser.isEmpty()) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | authortext.append (fmt (" [%1]", ld_defaultuser)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | ui.le_author->setText (authortext); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | switch (ld_defaultlicense) |
603 | 63 | { |
64 | case 0: | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | ui.rb_license_ca->setChecked (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | case 1: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | ui.rb_license_nonca->setChecked (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | case 2: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | ui.rb_license_none->setChecked (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | default: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | QMessageBox::warning (null, "Warning", |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | fmt ("Unknown ld_defaultlicense value %1!", ld_defaultlicense)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | if (dlg->exec() == false) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | newFile(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | const LDBFC::Type BFCType = |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW : |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
91 | const QString license = |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | ui.rb_license_ca->isChecked() ? CALicense : |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | ui.rb_license_nonca->isChecked() ? NonCALicense : ""; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | getCurrentDocument()->addObjects ( |
603 | 96 | { |
97 | new LDComment (ui.le_title->text()), | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | new LDComment ("Name: <untitled>.dat"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | new LDComment (fmt ("Author: %1", ui.le_author->text())), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | new LDComment (fmt ("!LDRAW_ORG Unofficial_Part")), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | (license != "" ? new LDComment (license) : null), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | new LDEmpty, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | new LDBFC (BFCType), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | new LDEmpty, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | }); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
107 | doFullRefresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | DEFINE_ACTION (NewFile, CTRL (N)) |
603 | 113 | { |
114 | newFile(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | DEFINE_ACTION (Open, CTRL (O)) |
603 | 120 | { |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
121 | QString name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)"); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | if (name.length() == 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | openMainFile (name); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | DEFINE_ACTION (Save, CTRL (S)) |
603 | 132 | { |
133 | save (getCurrentDocument(), false); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) |
603 | 139 | { |
140 | save (getCurrentDocument(), true); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | DEFINE_ACTION (SaveAll, CTRL (L)) |
603 | 146 | { |
147 | for (LDDocument* file : g_loadedFiles) | |
148 | { | |
149 | if (file->isImplicit()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
152 | save (file, false); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | DEFINE_ACTION (Close, CTRL (W)) |
603 | 159 | { |
160 | if (!getCurrentDocument()->isSafeToClose()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | delete getCurrentDocument(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | DEFINE_ACTION (CloseAll, 0) |
603 | 169 | { |
170 | if (!safeToCloseAll()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | closeAll(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | DEFINE_ACTION (Settings, 0) |
603 | 179 | { |
180 | (new ConfigDialog)->exec(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | DEFINE_ACTION (SetLDrawPath, 0) |
603 | 186 | { |
187 | (new LDrawPathDialog (true))->exec(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | DEFINE_ACTION (Exit, CTRL (Q)) |
603 | 193 | { |
194 | exit (0); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | DEFINE_ACTION (NewSubfile, 0) |
603 | 200 | { |
604 | 201 | AddObjectDialog::staticDialog (LDObject::ESubfile, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | DEFINE_ACTION (NewLine, 0) |
603 | 207 | { |
604 | 208 | AddObjectDialog::staticDialog (LDObject::ELine, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | DEFINE_ACTION (NewTriangle, 0) |
603 | 214 | { |
604 | 215 | AddObjectDialog::staticDialog (LDObject::ETriangle, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | DEFINE_ACTION (NewQuad, 0) |
603 | 221 | { |
604 | 222 | AddObjectDialog::staticDialog (LDObject::EQuad, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | DEFINE_ACTION (NewCLine, 0) |
603 | 228 | { |
604 | 229 | AddObjectDialog::staticDialog (LDObject::ECondLine, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | DEFINE_ACTION (NewComment, 0) |
603 | 235 | { |
604 | 236 | AddObjectDialog::staticDialog (LDObject::EComment, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | DEFINE_ACTION (NewBFC, 0) |
603 | 242 | { |
604 | 243 | AddObjectDialog::staticDialog (LDObject::EBFC, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | DEFINE_ACTION (NewVertex, 0) |
603 | 249 | { |
604 | 250 | AddObjectDialog::staticDialog (LDObject::EVertex, null); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | DEFINE_ACTION (Edit, 0) |
603 | 256 | { |
257 | if (selection().size() != 1) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | LDObject* obj = selection() [0]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | AddObjectDialog::staticDialog (obj->getType(), obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | DEFINE_ACTION (Help, KEY (F1)) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | { |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | DEFINE_ACTION (About, 0) |
603 | 273 | { |
274 | AboutDialog().exec(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | DEFINE_ACTION (AboutQt, 0) |
603 | 280 | { |
281 | QMessageBox::aboutQt (g_win); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | DEFINE_ACTION (SelectAll, CTRL (A)) |
603 | 287 | { |
288 | for (LDObject* obj : getCurrentDocument()->getObjects()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | obj->select(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
291 | updateSelection(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
292 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | DEFINE_ACTION (SelectByColor, CTRL_SHIFT (A)) |
603 | 297 | { |
298 | int colnum = getSelectedColor(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | if (colnum == -1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | return; // no consensus on color |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | for (LDObject* obj : getCurrentDocument()->getObjects()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | if (obj->getColor() == colnum) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | obj->select(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
309 | updateSelection(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | DEFINE_ACTION (SelectByType, 0) |
603 | 315 | { |
316 | if (selection().isEmpty()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
319 | LDObject::Type type = getUniformSelectedType(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | |
604 | 321 | if (type == LDObject::EUnidentified) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | // If we're selecting subfile references, the reference filename must also |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | // be uniform. |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
326 | QString refName; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | |
604 | 328 | if (type == LDObject::ESubfile) |
603 | 329 | { |
330 | refName = static_cast<LDSubfile*> (selection()[0])->getFileInfo()->getName(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | for (LDObject* obj : selection()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | if (static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | for (LDObject* obj : getCurrentDocument()->getObjects()) |
603 | 340 | { |
341 | if (obj->getType() != type) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | |
604 | 344 | if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | obj->select(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
350 | updateSelection(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | DEFINE_ACTION (GridCoarse, 0) |
603 | 356 | { |
357 | grid = Grid::Coarse; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
358 | updateGridToolBar(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | DEFINE_ACTION (GridMedium, 0) |
603 | 362 | { |
363 | grid = Grid::Medium; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
364 | updateGridToolBar(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | DEFINE_ACTION (GridFine, 0) |
603 | 368 | { |
369 | grid = Grid::Fine; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
370 | updateGridToolBar(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | DEFINE_ACTION (ResetView, CTRL (0)) |
603 | 376 | { |
377 | R()->resetAngles(); | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
378 | R()->update(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | DEFINE_ACTION (InsertFrom, 0) |
603 | 384 | { |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
385 | QString fname = QFileDialog::getOpenFileName(); |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
386 | int idx = getInsertionPoint(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
387 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | if (!fname.length()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | |
609
a8dc74a809c6
- removed the File class in favor of QFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
606
diff
changeset
|
391 | QFile f (fname); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | |
609
a8dc74a809c6
- removed the File class in favor of QFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
606
diff
changeset
|
393 | if (!f.open (QIODevice::ReadOnly)) |
603 | 394 | { |
609
a8dc74a809c6
- removed the File class in favor of QFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
606
diff
changeset
|
395 | critical (fmt ("Couldn't open %1 (%2)", fname, f.errorString())); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | QList<LDObject*> objs = loadFileContents (&f, null); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | for (LDObject* obj : objs) |
603 | 404 | { |
405 | getCurrentDocument()->insertObj (idx, obj); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | obj->select(); |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
407 | R()->compileObject (obj); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
408 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | idx++; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
412 | refresh(); |
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
413 | scrollToSelection(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | DEFINE_ACTION (ExportTo, 0) |
603 | 419 | { |
420 | if (selection().isEmpty()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
423 | QString fname = QFileDialog::getSaveFileName(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | if (fname.length() == 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | QFile file (fname); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | if (!file.open (QIODevice::WriteOnly | QIODevice::Text)) |
603 | 431 | { |
609
a8dc74a809c6
- removed the File class in favor of QFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
606
diff
changeset
|
432 | critical (fmt ("Unable to open %1 for writing (%2)", fname, file.errorString())); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
433 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | for (LDObject* obj : selection()) |
603 | 437 | { |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
438 | QString contents = obj->raw(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | QByteArray data = contents.toUtf8(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | file.write (data, data.size()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | file.write ("\r\n", 2); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
443 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | DEFINE_ACTION (InsertRaw, 0) |
603 | 448 | { |
449 | int idx = getInsertionPoint(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | QDialog* const dlg = new QDialog; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
452 | QVBoxLayout* const layout = new QVBoxLayout; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
453 | QTextEdit* const te_edit = new QTextEdit; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | QDialogButtonBox* const bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
456 | layout->addWidget (te_edit); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
457 | layout->addWidget (bbx_buttons); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
458 | dlg->setLayout (layout); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | dlg->setWindowTitle (APPNAME ": Insert Raw"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
460 | dlg->connect (bbx_buttons, SIGNAL (accepted()), dlg, SLOT (accept())); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
461 | dlg->connect (bbx_buttons, SIGNAL (rejected()), dlg, SLOT (reject())); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | if (dlg->exec() == false) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
464 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
465 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
466 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
467 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
468 | for (QString line : QString (te_edit->toPlainText()).split ("\n")) |
603 | 469 | { |
470 | LDObject* obj = parseLine (line); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
471 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
472 | getCurrentDocument()->insertObj (idx, obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
473 | obj->select(); |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
474 | R()->compileObject (obj); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | idx++; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
478 | refresh(); |
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
479 | scrollToSelection(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
480 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
483 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
484 | DEFINE_ACTION (Screenshot, 0) |
603 | 485 | { |
486 | setlocale (LC_ALL, "C"); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
487 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
488 | int w, h; |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
489 | uchar* imgdata = R()->getScreencap (w, h); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
490 | QImage img = imageFromScreencap (imgdata, w, h); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
492 | QString root = basename (getCurrentDocument()->getName()); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
493 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | if (root.right (4) == ".dat") |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
495 | root.chop (4); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
496 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
497 | QString defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; |
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
498 | QString fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | if (fname.length() > 0 && !img.save (fname)) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
502 | critical (fmt ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | delete[] imgdata; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | extern_cfg (Bool, gl_axes); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
510 | DEFINE_ACTION (Axes, 0) |
603 | 511 | { |
512 | gl_axes = !gl_axes; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
513 | updateActions(); |
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
514 | R()->update(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
515 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
516 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
517 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
518 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
519 | DEFINE_ACTION (VisibilityToggle, 0) |
603 | 520 | { |
521 | for (LDObject* obj : selection()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
522 | obj->toggleHidden(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
524 | refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
525 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
526 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
527 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
528 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
529 | DEFINE_ACTION (VisibilityHide, 0) |
603 | 530 | { |
531 | for (LDObject* obj : selection()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
532 | obj->setHidden (true); |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
533 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
534 | refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
536 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | DEFINE_ACTION (VisibilityReveal, 0) |
603 | 540 | { |
541 | for (LDObject* obj : selection()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | obj->setHidden (false); |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
543 | refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
545 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
548 | DEFINE_ACTION (Wireframe, 0) |
603 | 549 | { |
550 | gl_wireframe = !gl_wireframe; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
551 | R()->refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
553 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
555 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
556 | DEFINE_ACTION (SetOverlay, 0) |
603 | 557 | { |
558 | OverlayDialog dlg; | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
559 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
560 | if (!dlg.exec()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
561 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
563 | R()->setupOverlay ((GL::EFixedCamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
567 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | DEFINE_ACTION (ClearOverlay, 0) |
603 | 570 | { |
571 | R()->clearOverlay(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
574 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | DEFINE_ACTION (ModeSelect, CTRL (1)) |
603 | 577 | { |
578 | R()->setEditMode (ESelectMode); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
579 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
581 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
583 | DEFINE_ACTION (ModeDraw, CTRL (2)) |
603 | 584 | { |
585 | R()->setEditMode (EDrawMode); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
586 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
589 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
590 | DEFINE_ACTION (ModeCircle, CTRL (3)) |
603 | 591 | { |
592 | R()->setEditMode (ECircleMode); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
593 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
594 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
595 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
596 | // ----------------------------------------------------------------------------- |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
597 | DEFINE_ACTION (DrawAngles, 0) |
603 | 598 | { |
599 | gl_drawangles = !gl_drawangles; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
600 | R()->refresh(); |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
601 | } |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
602 | |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
603 | // ============================================================================= |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
604 | // ----------------------------------------------------------------------------- |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
605 | DEFINE_ACTION (SetDrawDepth, 0) |
603 | 606 | { |
607 | if (R()->camera() == GL::EFreeCamera) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
608 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
609 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
610 | bool ok; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
611 | double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
612 | fmt ("Depth value for %1 Camera:", R()->getCameraName()), |
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
613 | R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
614 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
615 | if (ok) |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
616 | R()->setDepthValue (depth); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
619 | #if 0 |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
620 | // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
621 | // but I can't figure how to generate these pictures properly. Multi-threading |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
622 | // these is an immense pain. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | DEFINE_ACTION (testpic, "Test picture", "", "", (0)) |
603 | 624 | { |
625 | LDDocument* file = getFile ("axle.dat"); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | setlocale (LC_ALL, "C"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
628 | if (!file) |
603 | 629 | { |
630 | critical ("couldn't load axle.dat"); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
633 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
634 | int w, h; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
635 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
636 | GLRenderer* rend = new GLRenderer; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
637 | rend->resize (64, 64); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
638 | rend->setAttribute (Qt::WA_DontShowOnScreen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
639 | rend->show(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
640 | rend->setFile (file); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
641 | rend->setDrawOnly (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
642 | rend->compileAllObjects(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
643 | rend->initGLData(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | rend->drawGLScene(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
645 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | uchar* imgdata = rend->screencap (w, h); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | QImage img = imageFromScreencap (imgdata, w, h); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
648 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
649 | if (img.isNull()) |
603 | 650 | { |
651 | critical ("Failed to create the image!\n"); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
652 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
653 | else |
603 | 654 | { |
655 | QLabel* label = new QLabel; | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
656 | QDialog* dlg = new QDialog; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | label->setPixmap (QPixmap::fromImage (img)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | QVBoxLayout* layout = new QVBoxLayout (dlg); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | layout->addWidget (label); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
660 | dlg->exec(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
661 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
662 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
663 | delete[] imgdata; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
664 | rend->deleteLater(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | #endif |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
668 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
670 | DEFINE_ACTION (ScanPrimitives, 0) |
603 | 671 | { |
672 | PrimitiveLister::start(); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
674 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
676 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
677 | DEFINE_ACTION (BFCView, SHIFT (B)) |
603 | 678 | { |
679 | gl_colorbfc = !gl_colorbfc; | |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
680 | updateActions(); |
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
681 | R()->refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
685 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | DEFINE_ACTION (JumpTo, CTRL (G)) |
603 | 687 | { |
688 | bool ok; | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | int defval = 0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | LDObject* obj; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | if (selection().size() == 1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
693 | defval = selection()[0]->getIndex(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
695 | int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | 1, getCurrentDocument()->getObjectCount(), 1, &ok); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
698 | if (!ok || (obj = getCurrentDocument()->getObject (idx - 1)) == null) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
701 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | obj->select(); |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
703 | updateSelection(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
704 | } |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
705 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
706 | // ============================================================================= |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
707 | // ----------------------------------------------------------------------------- |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
708 | DEFINE_ACTION (SubfileSelection, 0) |
603 | 709 | { |
710 | if (selection().size() == 0) | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
711 | return; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
712 | |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
713 | QString parentpath = getCurrentDocument()->getFullPath(); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
714 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
715 | // BFC type of the new subfile - it shall inherit the BFC type of the parent document |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
716 | LDBFC::Type bfctype = LDBFC::NoCertify; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
717 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
718 | // Dirname of the new subfile |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
719 | QString subdirname = dirname (parentpath); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
720 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
721 | // Title of the new subfile |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
722 | QString subtitle; |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
723 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
724 | // Comment containing the title of the parent document |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
725 | LDComment* titleobj = dynamic_cast<LDComment*> (getCurrentDocument()->getObject (0)); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
726 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
727 | // License text for the subfile |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
728 | QString license = getLicenseText (ld_defaultlicense); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
729 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
730 | // LDraw code body of the new subfile (i.e. code of the selection) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
731 | QStringList code; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
732 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
733 | // Full path of the subfile to be |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
734 | QString fullsubname; |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
735 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
736 | // Where to insert the subfile reference? |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
737 | int refidx = selection()[0]->getIndex(); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
738 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
739 | // Determine title of subfile |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
740 | if (titleobj != null) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
741 | subtitle = "~" + titleobj->text; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
742 | else |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
743 | subtitle = "~subfile"; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
744 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
745 | // Remove duplicate tildes |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
746 | while (subtitle[0] == '~' && subtitle[1] == '~') |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
747 | subtitle.remove (0, 1); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
748 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
749 | // If this the parent document isn't already in s/, we need to stuff it into |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
750 | // a subdirectory named s/. Ensure it exists! |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
751 | QString topdirname = basename (dirname (getCurrentDocument()->getFullPath())); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
752 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
753 | if (topdirname != "s") |
603 | 754 | { |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
755 | QString desiredPath = subdirname + "/s"; |
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
756 | QString title = tr ("Create subfile directory?"); |
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
757 | QString text = fmt (tr ("The directory <b>%1</b> is suggested for " |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
758 | "subfiles. This directory does not exist, create it?"), desiredPath); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
759 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
760 | if (QDir (desiredPath).exists() || confirm (title, text)) |
603 | 761 | { |
762 | subdirname = desiredPath; | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
763 | QDir().mkpath (subdirname); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
764 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
765 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
766 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
767 | // Determine the body of the name of the subfile |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
768 | if (!parentpath.isEmpty()) |
603 | 769 | { |
770 | if (parentpath.endsWith (".dat")) | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
771 | parentpath.chop (4); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
772 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
773 | // Remove the s?? suffix if it's there, otherwise we'll get filenames |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
774 | // like s01s01.dat when subfiling subfiles. |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
775 | QRegExp subfilesuffix ("s[0-9][0-9]$"); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
776 | if (subfilesuffix.indexIn (parentpath) != -1) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
777 | parentpath.chop (subfilesuffix.matchedLength()); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
778 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
779 | int subidx = 1; |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
780 | QString digits; |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
781 | QFile f; |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
782 | QString testfname; |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
783 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
784 | do |
603 | 785 | { |
786 | digits.setNum (subidx++); | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
787 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
788 | // pad it with a zero |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
789 | if (digits.length() == 1) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
790 | digits.prepend ("0"); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
791 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
792 | fullsubname = subdirname + "/" + basename (parentpath) + "s" + digits + ".dat"; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
793 | } while (findDocument ("s\\" + basename (fullsubname)) != null || QFile (fullsubname).exists()); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
794 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
795 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
796 | // Determine the BFC winding type used in the main document - it is to |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
797 | // be carried over to the subfile. |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
798 | for (LDObject* obj : getCurrentDocument()->getObjects()) |
603 | 799 | { |
800 | LDBFC* bfc = dynamic_cast<LDBFC*> (obj); | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
801 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
802 | if (!bfc) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
803 | continue; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
804 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
805 | LDBFC::Type a = bfc->type; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
806 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
807 | if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) |
603 | 808 | { |
809 | bfctype = a; | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
810 | break; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
811 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
812 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
813 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
814 | // Get the body of the document in LDraw code |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
815 | for (LDObject* obj : selection()) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
816 | code << obj->raw(); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
817 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
818 | // Create the new subfile document |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
819 | LDDocument* doc = new LDDocument; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
820 | doc->setImplicit (false); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
821 | doc->setFullPath (fullsubname); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
822 | doc->setName (LDDocument::shortenName (fullsubname)); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
823 | doc->addObjects ( |
603 | 824 | { |
825 | new LDComment (subtitle), | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
826 | new LDComment ("Name: "), |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
827 | new LDComment (fmt ("Author: %1 [%2]", ld_defaultname, ld_defaultuser)), |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
828 | new LDComment (fmt ("!LDRAW_ORG Unofficial_Subpart")), |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
829 | (license != "" ? new LDComment (license) : null), |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
830 | new LDEmpty, |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
831 | new LDBFC (bfctype), |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
832 | new LDEmpty, |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
833 | }); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
834 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
835 | // Add the actual subfile code to the new document |
606
3dd6f343ec06
- removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
604
diff
changeset
|
836 | for (QString line : code) |
603 | 837 | { |
838 | LDObject* obj = parseLine (line); | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
839 | doc->addObject (obj); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
840 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
841 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
842 | // Try save it |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
843 | if (save (doc, true)) |
603 | 844 | { |
845 | // Remove the selection now | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
846 | for (LDObject* obj : selection()) |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
847 | obj->deleteSelf(); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
848 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
849 | // Compile all objects in the new subfile |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
850 | for (LDObject* obj : doc->getObjects()) |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
851 | R()->compileObject (obj); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
852 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
853 | g_loadedFiles << doc; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
854 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
855 | // Add a reference to the new subfile to where the selection was |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
856 | LDSubfile* ref = new LDSubfile(); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
857 | ref->setColor (maincolor); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
858 | ref->setFileInfo (doc); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
859 | ref->setPosition (g_origin); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
860 | ref->setTransform (g_identity); |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
861 | getCurrentDocument()->insertObj (refidx, ref); |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
862 | R()->compileObject (ref); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
863 | |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
864 | // Refresh stuff |
587
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
865 | updateDocumentList(); |
507e5d5c348c
- removed the horrible actions.h hack in favor of usage of Qt's meta object system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
578
diff
changeset
|
866 | doFullRefresh(); |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
867 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
868 | else |
603 | 869 | { |
870 | // Failed to save. | |
575
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
871 | delete doc; |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
872 | } |
59c0b57e843b
- added selection auto-subfiling(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
873 | } |