src/gui_actions.cpp

Fri, 13 Dec 2013 00:39:49 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 13 Dec 2013 00:39:49 +0200
changeset 556
5f4395ec5db0
parent 554
2478a6b3106d
permissions
-rw-r--r--

- LDObject::move is no longer virtual

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
4 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
9 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
14 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
19 #include <QFileDialog>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
20 #include <QMessageBox>
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 195
diff changeset
21 #include <QTextEdit>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 195
diff changeset
22 #include <QBoxLayout>
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
23 #include <QDialogButtonBox>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
24 #include <QPushButton>
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
25 #include <QInputDialog>
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
26
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include "gui.h"
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
28 #include "document.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include "history.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "configDialog.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #include "addObjectDialog.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 #include "misc.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 195
diff changeset
33 #include "gldraw.h"
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
34 #include "dialogs.h"
292
4779ca562d5e Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 291
diff changeset
35 #include "primitives.h"
315
cb0c23f35e2b UI-ified the new part prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
36 #include "ui_newpart.h"
317
e41ab239ed28 Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents: 315
diff changeset
37 #include "widgets.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
39 extern_cfg (Bool, gl_wireframe);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
40 extern_cfg (Bool, gl_colorbfc);
464
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
41 extern_cfg (String, ld_defaultname);
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
42 extern_cfg (String, ld_defaultuser);
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
43 extern_cfg (Int, ld_defaultlicense);
193
ce8e25ccbaf6 Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
44
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
46 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
47 DEFINE_ACTION (New, CTRL_SHIFT (N))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
48 { QDialog* dlg = new QDialog (g_win);
315
cb0c23f35e2b UI-ified the new part prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
49 Ui::NewPartUI ui;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
50 ui.setupUi (dlg);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
51
464
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
52 str authortext = ld_defaultname;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
53
464
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
54 if (!ld_defaultuser.value.isEmpty())
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
55 authortext.append (fmt (" [%1]", ld_defaultuser));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
56
464
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
57 ui.le_author->setText (authortext);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
58
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
59 switch (ld_defaultlicense)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
60 { case 0:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
61 ui.rb_license_ca->setChecked (true);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
62 break;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
63
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
64 case 1:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
65 ui.rb_license_nonca->setChecked (true);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
66 break;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
67
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
68 case 2:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
69 ui.rb_license_none->setChecked (true);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
70 break;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
71
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
72 default:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
73 QMessageBox::warning (null, "Warning",
554
2478a6b3106d - Reworked primitive listing. No longer uses multi-threading.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 553
diff changeset
74 fmt ("Unknown ld_defaultlicense value %1!", ld_defaultlicense));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
75 break;
464
3779a14d597c added profile data auto-filling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
76 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
77
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
78 if (dlg->exec() == false)
315
cb0c23f35e2b UI-ified the new part prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
79 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
80
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
81 newFile();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
82
460
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
83 const LDBFC::Type BFCType =
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
84 ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW :
b230ae09c8e5 Cut the Object-suffix from LDObject types, it doesn't help things at all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 455
diff changeset
85 ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
86
315
cb0c23f35e2b UI-ified the new part prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
87 const str license =
cb0c23f35e2b UI-ified the new part prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
88 ui.rb_license_ca->isChecked() ? CALicense :
391
beef61ce962a Finalized multi-file behavior. The future is here! :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 389
diff changeset
89 ui.rb_license_nonca->isChecked() ? NonCALicense : "";
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
90
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
91 getCurrentDocument()->addObjects (
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
92 { new LDComment (ui.le_title->text()),
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
93 new LDComment ("Name: <untitled>.dat"),
484
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 472
diff changeset
94 new LDComment (fmt ("Author: %1", ui.le_author->text())),
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 472
diff changeset
95 new LDComment (fmt ("!LDRAW_ORG Unofficial_Part")),
554
2478a6b3106d - Reworked primitive listing. No longer uses multi-threading.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 553
diff changeset
96 (license != "" ? new LDComment (license) : null),
484
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 472
diff changeset
97 new LDEmpty,
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 472
diff changeset
98 new LDBFC (BFCType),
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 472
diff changeset
99 new LDEmpty,
5b5c77c7f3dd made LDFile interfacing a bit clearer
Santeri Piippo <crimsondusk64@gmail.com>
parents: 472
diff changeset
100 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
101
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
102 g_win->doFullRefresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
106 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
107 DEFINE_ACTION (NewFile, CTRL (N))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
108 { newFile();
416
be1824f53c48 Added an action for creating a new, blank file, improved multi-file stability
Santeri Piippo <crimsondusk64@gmail.com>
parents: 415
diff changeset
109 }
be1824f53c48 Added an action for creating a new, blank file, improved multi-file stability
Santeri Piippo <crimsondusk64@gmail.com>
parents: 415
diff changeset
110
be1824f53c48 Added an action for creating a new, blank file, improved multi-file stability
Santeri Piippo <crimsondusk64@gmail.com>
parents: 415
diff changeset
111 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
112 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
113 DEFINE_ACTION (Open, CTRL (O))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
114 { str name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
115
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
116 if (name.length() == 0)
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 224
diff changeset
117 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
118
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 224
diff changeset
119 openMainFile (name);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
123 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
124 DEFINE_ACTION (Save, CTRL (S))
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
125 { g_win->save (getCurrentDocument(), false);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
129 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
130 DEFINE_ACTION (SaveAs, CTRL_SHIFT (S))
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
131 { g_win->save (getCurrentDocument(), true);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
135 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
136 DEFINE_ACTION (SaveAll, CTRL (L))
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
137 { for (LDDocument* file : g_loadedFiles)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
138 { if (file->isImplicit())
389
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
139 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
140
389
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
141 g_win->save (file, false);
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
142 }
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
143 }
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
144
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
145 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
146 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
147 DEFINE_ACTION (Close, CTRL (W))
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
148 { if (!getCurrentDocument()->isSafeToClose())
389
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
149 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
150
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
151 delete getCurrentDocument();
389
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
152 }
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
153
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
154 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
155 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
156 DEFINE_ACTION (CloseAll, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
157 { if (!safeToCloseAll())
389
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
158 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
159
389
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
160 closeAll();
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
161 }
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
162
ccb763dbe98e Added actions for saving all files, closing and closing all files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
163 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
164 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
165 DEFINE_ACTION (Settings, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
166 { (new ConfigDialog)->exec();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
169 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
170 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
171 DEFINE_ACTION (SetLDrawPath, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
172 { (new LDrawPathDialog (true))->exec();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
176 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
177 DEFINE_ACTION (Exit, CTRL (Q))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
178 { exit (0);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
182 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
183 DEFINE_ACTION (NewSubfile, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
184 { AddObjectDialog::staticDialog (LDObject::Subfile, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
187 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
188 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
189 DEFINE_ACTION (NewLine, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
190 { AddObjectDialog::staticDialog (LDObject::Line, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
193 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
194 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
195 DEFINE_ACTION (NewTriangle, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
196 { AddObjectDialog::staticDialog (LDObject::Triangle, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
199 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
200 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
201 DEFINE_ACTION (NewQuad, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
202 { AddObjectDialog::staticDialog (LDObject::Quad, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
205 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
206 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
207 DEFINE_ACTION (NewCLine, 0)
551
0efe5dbcef07 renamed LDCndLine to LDCondLine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 550
diff changeset
208 { AddObjectDialog::staticDialog (LDObject::CondLine, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
211 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
212 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
213 DEFINE_ACTION (NewComment, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
214 { AddObjectDialog::staticDialog (LDObject::Comment, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
217 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
218 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
219 DEFINE_ACTION (NewBFC, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
220 { AddObjectDialog::staticDialog (LDObject::BFC, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
223 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
224 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
225 DEFINE_ACTION (NewVertex, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
226 { AddObjectDialog::staticDialog (LDObject::Vertex, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
229 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
230 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
231 DEFINE_ACTION (Edit, 0)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
232 { if (selection().size() != 1)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
234
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
235 LDObject* obj = selection() [0];
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
236 AddObjectDialog::staticDialog (obj->getType(), obj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
239 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
240 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
241 DEFINE_ACTION (Help, KEY (F1))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
242 {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
246 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
247 DEFINE_ACTION (About, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
248 { AboutDialog().exec();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
251 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
252 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
253 DEFINE_ACTION (AboutQt, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
254 { QMessageBox::aboutQt (g_win);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
258 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
259 DEFINE_ACTION (SelectAll, CTRL (A))
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
260 { for (LDObject* obj : getCurrentDocument()->getObjects())
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
261 obj->select();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
262
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
263 g_win->updateSelection();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
267 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
268 DEFINE_ACTION (SelectByColor, CTRL_SHIFT (A))
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
269 { int colnum = g_win->getSelectedColor();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
270
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
271 if (colnum == -1)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 return; // no consensus on color
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
273
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
274 getCurrentDocument()->clearSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
275
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
276 for (LDObject* obj : getCurrentDocument()->getObjects())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
277 if (obj->getColor() == colnum)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
278 obj->select();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
279
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
280 g_win->updateSelection();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
284 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
285 DEFINE_ACTION (SelectByType, 0)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
286 { if (selection().isEmpty())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
288
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
289 LDObject::Type type = g_win->getUniformSelectedType();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
290
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 240
diff changeset
291 if (type == LDObject::Unidentified)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
293
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 // If we're selecting subfile references, the reference filename must also
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295 // be uniform.
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 240
diff changeset
296 str refName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
297
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
298 if (type == LDObject::Subfile)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
299 { refName = static_cast<LDSubfile*> (selection()[0])->getFileInfo()->getName();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
300
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
301 for (LDObject* obj : selection())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
302 if (static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
305
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
306 getCurrentDocument()->clearSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
307
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
308 for (LDObject* obj : getCurrentDocument()->getObjects())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
309 { if (obj->getType() != type)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
311
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
312 if (type == LDObject::Subfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
314
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
315 obj->select();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
317
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
318 g_win->updateSelection();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
322 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
323 DEFINE_ACTION (GridCoarse, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
324 { grid = Grid::Coarse;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
325 g_win->updateGridToolBar();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
328 DEFINE_ACTION (GridMedium, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
329 { grid = Grid::Medium;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
330 g_win->updateGridToolBar();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
333 DEFINE_ACTION (GridFine, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
334 { grid = Grid::Fine;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
335 g_win->updateGridToolBar();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
339 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
340 DEFINE_ACTION (ResetView, CTRL (0))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
341 { g_win->R()->resetAngles();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
342 g_win->R()->update();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
346 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
347 DEFINE_ACTION (InsertFrom, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
348 { str fname = QFileDialog::getOpenFileName();
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
349 int idx = g_win->getInsertionPoint();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
350
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
351 if (!fname.length())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
353
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
354 File f (fname, File::Read);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
355
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
356 if (!f)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
357 { critical (fmt ("Couldn't open %1 (%2)", fname, strerror (errno)));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
360
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
361 QList<LDObject*> objs = loadFileContents (&f, null);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
362
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
363 getCurrentDocument()->clearSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
364
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
365 for (LDObject* obj : objs)
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
366 { getCurrentDocument()->insertObj (idx, obj);
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
367 obj->select();
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 416
diff changeset
368 g_win->R()->compileObject (obj);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
369
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 idx++;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
372
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
373 g_win->refresh();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
374 g_win->scrollToSelection();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
378 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
379 DEFINE_ACTION (ExportTo, 0)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
380 { if (selection().isEmpty())
257
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
381 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
382
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
383 str fname = QFileDialog::getSaveFileName();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
384
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
385 if (fname.length() == 0)
257
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
386 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
387
257
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
388 QFile file (fname);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
389
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
390 if (!file.open (QIODevice::WriteOnly | QIODevice::Text))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
391 { critical (fmt ("Unable to open %1 for writing (%2)", fname, strerror (errno)));
257
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
392 return;
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
393 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
394
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
395 for (LDObject* obj : selection())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
396 { str contents = obj->raw();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
397 QByteArray data = contents.toUtf8();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
398 file.write (data, data.size());
257
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
399 file.write ("\r\n", 2);
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
400 }
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
401 }
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
402
481566b60ecd Added Export To File action, moved it + insert from to File menu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 255
diff changeset
403 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
404 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
405 DEFINE_ACTION (InsertRaw, 0)
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
406 { int idx = g_win->getInsertionPoint();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
407
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408 QDialog* const dlg = new QDialog;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 QVBoxLayout* const layout = new QVBoxLayout;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 QTextEdit* const te_edit = new QTextEdit;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411 QDialogButtonBox* const bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
412
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413 layout->addWidget (te_edit);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414 layout->addWidget (bbx_buttons);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 dlg->setLayout (layout);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 dlg->setWindowTitle (APPNAME ": Insert Raw");
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
417 dlg->connect (bbx_buttons, SIGNAL (accepted()), dlg, SLOT (accept()));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
418 dlg->connect (bbx_buttons, SIGNAL (rejected()), dlg, SLOT (reject()));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
419
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
420 if (dlg->exec() == false)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
422
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
423 getCurrentDocument()->clearSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
424
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
425 for (str line : str (te_edit->toPlainText()).split ("\n"))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
426 { LDObject* obj = parseLine (line);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
427
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
428 getCurrentDocument()->insertObj (idx, obj);
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
429 obj->select();
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 416
diff changeset
430 g_win->R()->compileObject (obj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 idx++;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
433
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
434 g_win->refresh();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
435 g_win->scrollToSelection();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
438 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
439 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
440 DEFINE_ACTION (Screenshot, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
441 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
442
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
443 int w, h;
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
444 uchar* imgdata = g_win->R()->getScreencap (w, h);
255
67d4aedf1041 Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
445 QImage img = imageFromScreencap (imgdata, w, h);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
446
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
447 str root = basename (getCurrentDocument()->getName());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
448
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
449 if (root.right (4) == ".dat")
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
450 root.chop (4);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
451
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
452 str defaultname = (root.length() > 0) ? fmt ("%1.png", root) : "";
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname,
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
454 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
455
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
456 if (fname.length() > 0 && !img.save (fname))
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
457 critical (fmt ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno)));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
458
255
67d4aedf1041 Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
459 delete[] imgdata;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
462 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
463 // -----------------------------------------------------------------------------
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
464 extern_cfg (Bool, gl_axes);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
465 DEFINE_ACTION (Axes, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
466 { gl_axes = !gl_axes;
542
46a33bdc0b36 - Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents: 539
diff changeset
467 g_win->updateActions();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
468 g_win->R()->update();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
471 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
472 // -----------------------------------------------------------------------------
530
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
473 DEFINE_ACTION (VisibilityToggle, 0)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
474 { for (LDObject* obj : selection())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
475 obj->toggleHidden();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
476
414
0f40c56fde23 some further little optimization
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
477 g_win->refresh();
193
ce8e25ccbaf6 Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
478 }
ce8e25ccbaf6 Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents: 192
diff changeset
479
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
480 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
481 // -----------------------------------------------------------------------------
530
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
482 DEFINE_ACTION (VisibilityHide, 0)
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
483 { for (LDObject* obj : selection())
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
484 obj->setHidden (true);
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
485
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
486 g_win->refresh();
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
487 }
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
488
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
489 // =============================================================================
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
490 // -----------------------------------------------------------------------------
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
491 DEFINE_ACTION (VisibilityReveal, 0)
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
492 { for (LDObject* obj : selection())
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
493 obj->setHidden (false);
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
494
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
495 g_win->refresh();
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
496 }
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
497
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
498 // =============================================================================
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
499 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
500 DEFINE_ACTION (Wireframe, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
501 { gl_wireframe = !gl_wireframe;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
502 g_win->R()->refresh();
195
7a776f6b0d2a Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 193
diff changeset
503 }
7a776f6b0d2a Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 193
diff changeset
504
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
505 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
506 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
507 DEFINE_ACTION (SetOverlay, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
508 { OverlayDialog dlg;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
509
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
510 if (!dlg.exec())
317
e41ab239ed28 Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents: 315
diff changeset
511 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
512
550
d97594e3fc54 more stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 542
diff changeset
513 g_win->R()->setupOverlay ((GL::EFixedCamera) dlg.camera(), dlg.fpath(), dlg.ofsx(),
d97594e3fc54 more stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 542
diff changeset
514 dlg.ofsy(), dlg.lwidth(), dlg.lheight());
195
7a776f6b0d2a Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 193
diff changeset
515 }
7a776f6b0d2a Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 193
diff changeset
516
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
517 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
518 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
519 DEFINE_ACTION (ClearOverlay, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
520 { g_win->R()->clearOverlay();
207
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
521 }
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
522
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
523 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
524 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
525 DEFINE_ACTION (ModeSelect, CTRL (1))
550
d97594e3fc54 more stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 542
diff changeset
526 { g_win->R()->setEditMode (ESelectMode);
207
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
527 }
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
528
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
529 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
530 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
531 DEFINE_ACTION (ModeDraw, CTRL (2))
550
d97594e3fc54 more stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 542
diff changeset
532 { g_win->R()->setEditMode (EDrawMode);
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
533 }
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
534
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
535 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
536 // -----------------------------------------------------------------------------
492
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 485
diff changeset
537 DEFINE_ACTION (ModeCircle, CTRL (3))
550
d97594e3fc54 more stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 542
diff changeset
538 { g_win->R()->setEditMode (ECircleMode);
492
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 485
diff changeset
539 }
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 485
diff changeset
540
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 485
diff changeset
541 // =============================================================================
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 485
diff changeset
542 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
543 DEFINE_ACTION (SetDrawDepth, 0)
550
d97594e3fc54 more stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 542
diff changeset
544 { if (g_win->R()->camera() == GL::EFreeCamera)
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
545 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
546
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
547 bool ok;
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
548 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth",
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
549 fmt ("Depth value for %1 Camera:", g_win->R()->getCameraName()),
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
550 g_win->R()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
551
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
552 if (ok)
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
553 g_win->R()->setDepthValue (depth);
253
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
554 }
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
555
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
556 #if 0
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
557 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery,
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
558 // but I can't figure how to generate these pictures properly. Multi-threading
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
559 // these is an immense pain.
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
560 DEFINE_ACTION (testpic, "Test picture", "", "", (0))
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
561 { LDDocument* file = getFile ("axle.dat");
254
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
562 setlocale (LC_ALL, "C");
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
563
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
564 if (!file)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
565 { critical ("couldn't load axle.dat");
253
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
566 return;
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
567 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
568
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
569 int w, h;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
570
253
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
571 GLRenderer* rend = new GLRenderer;
291
c8547f780861 Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents: 290
diff changeset
572 rend->resize (64, 64);
254
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
573 rend->setAttribute (Qt::WA_DontShowOnScreen);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
574 rend->show();
253
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
575 rend->setFile (file);
0737c217a54d Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
576 rend->setDrawOnly (true);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
577 rend->compileAllObjects();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
578 rend->initGLData();
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
579 rend->drawGLScene();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
580
255
67d4aedf1041 Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
581 uchar* imgdata = rend->screencap (w, h);
67d4aedf1041 Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
582 QImage img = imageFromScreencap (imgdata, w, h);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
583
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
584 if (img.isNull())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
585 { critical ("Failed to create the image!\n");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
586 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
587 else
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
588 { QLabel* label = new QLabel;
254
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
589 QDialog* dlg = new QDialog;
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
590 label->setPixmap (QPixmap::fromImage (img));
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
591 QVBoxLayout* layout = new QVBoxLayout (dlg);
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
592 layout->addWidget (label);
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
593 dlg->exec();
254
434c9844e45d Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents: 253
diff changeset
594 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
595
255
67d4aedf1041 Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents: 254
diff changeset
596 delete[] imgdata;
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
597 rend->deleteLater();
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
598 }
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
599 #endif
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
600
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
601 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
602 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
603 DEFINE_ACTION (ScanPrimitives, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
604 { PrimitiveLister::start();
353
07b3753baedc dded an action to quickly toggle BFC red/green view.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
605 }
07b3753baedc dded an action to quickly toggle BFC red/green view.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 344
diff changeset
606
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
607 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
608 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
609 DEFINE_ACTION (BFCView, SHIFT (B))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
610 { gl_colorbfc = !gl_colorbfc;
542
46a33bdc0b36 - Improved coordinate rounding, replaced the hack with a proper implementation, now rounds properly and works on subfiles as well
Santeri Piippo <crimsondusk64@gmail.com>
parents: 539
diff changeset
611 g_win->updateActions();
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 353
diff changeset
612 g_win->R()->refresh();
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
613 }
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
614
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
615 // =============================================================================
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
616 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
617 DEFINE_ACTION (JumpTo, CTRL (G))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
618 { bool ok;
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
619 int defval = 0;
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
620 LDObject* obj;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
621
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
622 if (selection().size() == 1)
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
623 defval = selection()[0]->getIndex();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
624
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
625 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval,
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
626 1, getCurrentDocument()->getObjectCount(), 1, &ok);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
627
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
628 if (!ok || (obj = getCurrentDocument()->getObject (idx - 1)) == null)
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
629 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
630
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 551
diff changeset
631 getCurrentDocument()->clearSelection();
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
632 obj->select();
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
633 g_win->updateSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
634 }

mercurial