Tue, 19 Jun 2018 21:57:39 +0300
fixed chord triangle count formula
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1326 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QFileDialog> |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QInputDialog> |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
21 | #include <QMessageBox> |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "../mainwindow.h" |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
23 | #include "../lddocument.h" |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
24 | #include "../canvas.h" |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "../primitives.h" |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "../colors.h" |
1146
bb728c124d47
Renamed glCompiler.cpp → glcompiler.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
27 | #include "../glcompiler.h" |
1012 | 28 | #include "../documentmanager.h" |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
29 | #include "../linetypes/quadrilateral.h" |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "viewtoolset.h" |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | ViewToolset::ViewToolset (MainWindow *parent) : |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | Toolset (parent) {} |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | void ViewToolset::selectAll() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | { |
1257 | 37 | if (currentDocument()->size() >= 1) |
38 | { | |
39 | QModelIndex top = currentDocument()->index(0); | |
40 | QModelIndex bottom = currentDocument()->index(currentDocument()->size() - 1); | |
41 | QItemSelection selection {top, bottom}; | |
42 | mainWindow()->replaceSelection(selection); | |
43 | } | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | void ViewToolset::selectByColor() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
48 | if (selectedObjects().isEmpty()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | return; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
51 | QSet<LDColor> colors; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
53 | for (LDObject* obj : selectedObjects()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | if (obj->isColored()) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | colors << obj->color(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
1257 | 59 | QItemSelection selection; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
1257 | 61 | for (QModelIndex index : currentDocument()->indices()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | { |
1257 | 63 | if (colors.contains(currentDocument()->lookup(index)->color())) |
64 | selection.select(index, index); | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | } |
1257 | 66 | |
67 | mainWindow()->replaceSelection(selection); | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | void ViewToolset::selectByType() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
72 | if (selectedObjects().isEmpty()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | return; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
75 | QSet<LDObjectType> types; |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
76 | QSet<QString> subfilenames; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
78 | for (LDObject* obj : selectedObjects()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | types << obj->type(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1119
diff
changeset
|
82 | if (obj->type() == LDObjectType::SubfileReference) |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1258
diff
changeset
|
83 | subfilenames << static_cast<LDSubfileReference*>(obj)->fileInfo(m_documents)->name(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | |
1257 | 86 | QItemSelection selection; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | |
1257 | 88 | for (QModelIndex index : currentDocument()->indices()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | { |
1257 | 90 | LDObject* obj = currentDocument()->lookup(index); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | LDObjectType type = obj->type(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | if (not types.contains (type)) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | continue; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | // For subfiles, type check is not enough, we check the name of the document as well. |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1119
diff
changeset
|
97 | if (type == LDObjectType::SubfileReference |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1258
diff
changeset
|
98 | and not subfilenames.contains(static_cast<LDSubfileReference*>(obj)->fileInfo(m_documents)->name())) |
1016
3b279b5e57d3
Fixed line length warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
99 | { |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | continue; |
1016
3b279b5e57d3
Fixed line length warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
101 | } |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | |
1257 | 103 | selection.select(index, index); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | } |
1257 | 105 | |
106 | mainWindow()->replaceSelection(selection); | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | void ViewToolset::resetView() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | { |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
111 | m_window->renderer()->resetAngles(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
112 | m_window->renderer()->update(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | void ViewToolset::screenshot() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | { |
1171
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
117 | const char* imageFormats = "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;" |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
118 | "PPM images (*.ppm);;X11 Bitmaps (*.xbm);;X11 Pixmaps (*.xpm);;All Files (*.*)"; |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
119 | QImage image = m_window->renderer()->screenCapture(); |
1332
1fffb24d4ffe
replaced remaining DIRSLASH, Dirname and Basename uses with Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
120 | QString root = QFileInfo {currentDocument()->name()}.fileName(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | if (root.right (4) == ".dat") |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | root.chop (4); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | |
1064
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
125 | QString defaultname = (not root.isEmpty()) ? format ("%1.png", root) : ""; |
1171
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
126 | QString filename = QFileDialog::getSaveFileName (m_window, "Save Screencap", defaultname, imageFormats); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
128 | if (not filename.isEmpty() and not image.save (filename)) |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
129 | { |
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
130 | QString message = format(tr("Couldn't open %1 for writing to save screen capture: %2"), filename, strerror(errno)); |
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
131 | QMessageBox::critical(m_window, tr("Error"), message); |
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
132 | } |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | void ViewToolset::axes() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
137 | config::toggleDrawAxes(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | m_window->updateActions(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
139 | m_window->renderer()->update(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | void ViewToolset::visibilityToggle() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
144 | for (LDObject* obj : selectedObjects()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | obj->setHidden (not obj->isHidden()); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | void ViewToolset::visibilityHide() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
150 | for (LDObject* obj : selectedObjects()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | obj->setHidden (true); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | void ViewToolset::visibilityReveal() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
156 | for (LDObject* obj : selectedObjects()) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | obj->setHidden (false); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | void ViewToolset::wireframe() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
162 | config::toggleDrawWireframe(); |
1168
0b450b4559b8
Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
163 | m_window->renderer()->update(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | void ViewToolset::drawAngles() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
168 | config::toggleDrawAngles(); |
1168
0b450b4559b8
Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
169 | m_window->renderer()->update(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
172 | /* |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
173 | * If the given object is within a single plane, returns that plane. |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
174 | * Should probably be smarter than this. |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
175 | */ |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
176 | static Plane drawPlaneFromObject(LDObject* object) |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | { |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
178 | switch (object->type()) |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
179 | { |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
180 | case LDObjectType::Quadrilateral: |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
181 | if (not static_cast<LDQuadrilateral*>(object)->isCoPlanar()) |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
182 | return {}; |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
183 | case LDObjectType::Triangle: |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
184 | return Plane::fromPoints(object->vertex(0), object->vertex(1), object->vertex(2)); |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
185 | |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
186 | default: |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
187 | return {}; |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
188 | } |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
189 | } |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
190 | |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
191 | void ViewToolset::setDrawPlane() |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
192 | { |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
193 | QSet<LDObject*> objects = selectedObjects(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
195 | if (objects.size() == 1) |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
196 | { |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
197 | LDObject* object = *objects.begin(); |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
198 | Plane plane = drawPlaneFromObject(object); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
200 | if (plane.isValid()) |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
201 | { |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
202 | m_window->renderer()->setDrawPlane(plane); |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
203 | } |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
204 | else |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
205 | { |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
206 | QMessageBox::critical( |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
207 | m_window, |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
208 | tr("Error"), |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
209 | tr("This object does not define a single plane"), |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
210 | QMessageBox::Ok, |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
211 | QMessageBox::Ok); |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
212 | } |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
213 | } |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
214 | } |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
215 | |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
216 | void ViewToolset::clearDrawPlane() |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
217 | { |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
218 | m_window->renderer()->setDrawPlane({}); |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
219 | } |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
220 | |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
221 | void ViewToolset::setCullDepth() |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
222 | { |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
223 | if (m_window->renderer()->camera() == Camera::Free) |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
224 | return; |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
225 | |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
226 | bool ok; |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
227 | double depth = QInputDialog::getDouble( |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
228 | m_window, |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
229 | tr("Set cull value"), |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
230 | format( |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
231 | tr("Cull depth for %1:\nPolygons closer than at this depth are not shown."), |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
232 | m_window->renderer()->currentCamera().name() |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
233 | ), |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
234 | m_window->renderer()->currentCullValue(), |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
235 | -GLRenderer::far, |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
236 | GLRenderer::far, |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
237 | 4, |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
238 | &ok |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
239 | ); |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
240 | |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
241 | if (ok) |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
242 | m_window->renderer()->setCullValue(depth); |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
243 | } |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
244 | |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
245 | void ViewToolset::clearCullDepth() |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
246 | { |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1332
diff
changeset
|
247 | m_window->renderer()->clearCurrentCullValue(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | #if 0 |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | // but I can't figure how to generate these pictures properly. Multi-threading |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | // these is an immense pain. |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | void ViewToolset::testpic() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | LDDocument* file = getFile ("axle.dat"); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | setlocale (LC_ALL, "C"); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | if (not file) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | critical ("couldn't load axle.dat"); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | return; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | int w, h; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | GLRenderer* rend = new GLRenderer; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | rend->resize (64, 64); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | rend->setAttribute (Qt::WA_DontShowOnScreen); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | rend->show(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | rend->setFile (file); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | rend->setDrawOnly (true); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | rend->compileAllObjects(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | rend->initGLData(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | rend->drawGLScene(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | uchar* imgdata = rend->screencap (w, h); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | QImage img = imageFromScreencap (imgdata, w, h); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | if (img.isNull()) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | critical ("Failed to create the image!\n"); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | else |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | QLabel* label = new QLabel; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | QDialog* dlg = new QDialog; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | label->setPixmap (QPixmap::fromImage (img)); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | QVBoxLayout* layout = new QVBoxLayout (dlg); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | layout->addWidget (label); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | dlg->exec(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
292 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | delete[] imgdata; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | rend->deleteLater(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | #endif |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | void ViewToolset::bfcView() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
301 | config::toggleBfcRedGreenView(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
303 | if (config::bfcRedGreenView()) |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
304 | config::setRandomColors (false); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | m_window->updateActions(); |
1168
0b450b4559b8
Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
307 | m_window->renderer()->update(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | void ViewToolset::jumpTo() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | bool ok; |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
313 | int defaultValue = 0; |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
314 | |
1258 | 315 | if (countof(m_window->selectedIndexes()) == 1) |
316 | defaultValue = (*m_window->selectedIndexes().begin()).row(); | |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
317 | |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
318 | int row = QInputDialog::getInt( |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
319 | nullptr, /* parent */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
320 | tr("Go to line"), /* title */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
321 | tr("Go to line:"), /* caption */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
322 | defaultValue, /* default value */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
323 | 1, /* minimum value */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
324 | currentDocument()->size(), /* maximum value */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
325 | 1, /* step value */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
326 | &ok /* success pointer */ |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
327 | ); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | |
1063
1f15c52c11f6
Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
329 | if (ok) |
1f15c52c11f6
Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
330 | { |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
331 | QModelIndex object = currentDocument()->index(row - 1); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
333 | if (object.isValid() and object.row() < currentDocument()->size()) |
1063
1f15c52c11f6
Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
334 | { |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
335 | mainWindow()->clearSelection(); |
1257 | 336 | mainWindow()->select(object); |
1063
1f15c52c11f6
Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
337 | } |
1f15c52c11f6
Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents:
1034
diff
changeset
|
338 | } |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | void ViewToolset::randomColors() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
343 | config::toggleRandomColors(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
345 | if (config::randomColors()) |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
346 | config::setBfcRedGreenView (false); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | m_window->updateActions(); |
1168
0b450b4559b8
Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
349 | m_window->renderer()->update(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | void ViewToolset::drawSurfaces() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
354 | config::toggleDrawSurfaces(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | m_window->updateActions(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | void ViewToolset::drawEdgeLines() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
360 | config::toggleDrawEdgeLines(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | m_window->updateActions(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
362 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | void ViewToolset::drawConditionalLines() |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
366 | config::toggleDrawConditionalLines(); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | m_window->updateActions(); |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
368 | } |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
369 | |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
370 | void ViewToolset::lighting() |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
371 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
372 | config::toggleLighting(); |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
373 | m_window->updateActions(); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
374 | } |