src/toolsets/viewtoolset.cpp

Tue, 01 Jan 2019 22:30:10 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 01 Jan 2019 22:30:10 +0200
changeset 1437
1a77c6156db7
parent 1436
241d3e452b32
permissions
-rw-r--r--

commit work done on mdi

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
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1323
diff changeset
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
413ecd6b9801 It worx again!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
37 if (currentDocument()->size() >= 1)
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
38 {
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
39 QModelIndex top = currentDocument()->index(0);
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
40 QModelIndex bottom = currentDocument()->index(currentDocument()->size() - 1);
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
41 QItemSelection selection {top, bottom};
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
42 mainWindow()->replaceSelection(selection);
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
59 QItemSelection selection;
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
1257
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
63 if (colors.contains(currentDocument()->lookup(index)->color()))
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
66
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
86 QItemSelection selection;
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87
1257
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
105
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
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
1437
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
166 void ViewToolset::newTopCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
167 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
168 createNewCamera(gl::TopCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
169 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
170
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
171 void ViewToolset::newFrontCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
172 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
173 createNewCamera(gl::FrontCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
174 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
175
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
176 void ViewToolset::newLeftCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
177 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
178 createNewCamera(gl::LeftCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
179 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
180
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
181 void ViewToolset::newBottomCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
182 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
183 createNewCamera(gl::BottomCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
184 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
185
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
186 void ViewToolset::newBackCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
187 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
188 createNewCamera(gl::BackCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
189 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
190
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
191 void ViewToolset::newRightCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
192 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
193 createNewCamera(gl::RightCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
194 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
195
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
196 void ViewToolset::newFreeCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
197 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
198 createNewCamera(gl::FreeCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
199 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
200
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
201 void ViewToolset::selectTopCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
202 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
203 selectCamera(gl::TopCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
204 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
205
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
206 void ViewToolset::selectFrontCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
207 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
208 selectCamera(gl::FrontCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
209 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
210
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
211 void ViewToolset::selectLeftCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
212 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
213 selectCamera(gl::LeftCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
214 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
215
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
216 void ViewToolset::selectBottomCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
217 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
218 selectCamera(gl::BottomCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
219 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
220
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
221 void ViewToolset::selectBackCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
222 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
223 selectCamera(gl::BackCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
224 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
225
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
226 void ViewToolset::selectRightCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
227 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
228 selectCamera(gl::RightCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
229 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
230
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
231 void ViewToolset::selectFreeCamera()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
232 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
233 selectCamera(gl::FreeCamera);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
234 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
235
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
236 void ViewToolset::createNewCamera(gl::CameraType cameraType)
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
237 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
238 m_window->createCameraForDocument(currentDocument(), cameraType);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
239 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
240
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
241 void ViewToolset::selectCamera(gl::CameraType cameraType)
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
242 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
243 m_window->selectCameraForDocument(currentDocument(), cameraType);
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
244 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
245
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 void ViewToolset::drawAngles()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
248 config::toggleDrawAngles();
1168
0b450b4559b8 Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
249 m_window->renderer()->update();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251
1390
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
252 /*
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
253 * 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
254 * 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
255 */
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
256 static Plane drawPlaneFromObject(LDObject* object)
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 {
1390
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
258 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
259 {
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
260 case LDObjectType::Quadrilateral:
1437
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
261 case LDObjectType::Triangle:
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
262 if (
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
263 object->type() == LDObjectType::Quadrilateral
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
264 and not static_cast<LDQuadrilateral*>(object)->isCoPlanar()
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
265 ) {
1390
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
266 return {};
1437
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
267 }
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
268 else
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
269 {
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
270 return Plane::fromPoints(object->vertex(0), object->vertex(1), object->vertex(2));
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
271 }
1390
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
272
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
273 default:
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
274 return {};
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
275 }
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
276 }
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
277
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
278 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
279 {
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
280 QSet<LDObject*> objects = selectedObjects();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281
1390
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
282 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
283 {
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
284 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
285 Plane plane = drawPlaneFromObject(object);
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286
1390
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
287 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
288 {
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
289 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
290 }
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
291 else
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
292 {
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
293 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
294 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
295 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
296 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
297 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
298 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
299 }
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
300 }
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
301 }
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
302
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
303 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
304 {
3eace926af7f added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents: 1369
diff changeset
305 m_window->renderer()->setDrawPlane({});
1369
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
306 }
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
307
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
308 void ViewToolset::setCullDepth()
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
309 {
1437
1a77c6156db7 commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents: 1436
diff changeset
310 if (m_window->renderer()->currentCamera().isModelview())
1369
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
311 return;
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
312
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
313 bool ok;
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
314 double depth = QInputDialog::getDouble(
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
315 m_window,
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
316 tr("Set cull value"),
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
317 format(
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
318 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
319 m_window->renderer()->currentCamera().name()
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
320 ),
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
321 m_window->renderer()->currentCullValue(),
1436
241d3e452b32 moved GL stuff into a new gl namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1390
diff changeset
322 -gl::far,
241d3e452b32 moved GL stuff into a new gl namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1390
diff changeset
323 gl::far,
1369
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
324 4,
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
325 &ok
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
326 );
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
327
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
328 if (ok)
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
329 m_window->renderer()->setCullValue(depth);
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
330 }
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
331
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
332 void ViewToolset::clearCullDepth()
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
333 {
1e2391b78d17 added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents: 1332
diff changeset
334 m_window->renderer()->clearCurrentCullValue();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337 #if 0
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 // 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
339 // 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
340 // these is an immense pain.
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 void ViewToolset::testpic()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
342 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 LDDocument* file = getFile ("axle.dat");
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 setlocale (LC_ALL, "C");
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 if (not file)
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 critical ("couldn't load axle.dat");
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 return;
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 int w, h;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354 GLRenderer* rend = new GLRenderer;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 rend->resize (64, 64);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 rend->setAttribute (Qt::WA_DontShowOnScreen);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357 rend->show();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 rend->setFile (file);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 rend->setDrawOnly (true);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 rend->compileAllObjects();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 rend->initGLData();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 rend->drawGLScene();
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 uchar* imgdata = rend->screencap (w, h);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 QImage img = imageFromScreencap (imgdata, w, h);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 if (img.isNull())
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 critical ("Failed to create the image!\n");
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 else
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 QLabel* label = new QLabel;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 QDialog* dlg = new QDialog;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 label->setPixmap (QPixmap::fromImage (img));
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 QVBoxLayout* layout = new QVBoxLayout (dlg);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 layout->addWidget (label);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 dlg->exec();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381 delete[] imgdata;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 rend->deleteLater();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
383 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 #endif
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 void ViewToolset::bfcView()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
388 config::toggleBfcRedGreenView();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
390 if (config::bfcRedGreenView())
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
391 config::setRandomColors (false);
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393 m_window->updateActions();
1168
0b450b4559b8 Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
394 m_window->renderer()->update();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 void ViewToolset::jumpTo()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 bool ok;
1256
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
400 int defaultValue = 0;
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
401
1258
f5921a474d57 removed LDObject::lineNumber
Santeri Piippo
parents: 1257
diff changeset
402 if (countof(m_window->selectedIndexes()) == 1)
f5921a474d57 removed LDObject::lineNumber
Santeri Piippo
parents: 1257
diff changeset
403 defaultValue = (*m_window->selectedIndexes().begin()).row();
1256
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
404
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
405 int row = QInputDialog::getInt(
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
406 nullptr, /* parent */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
407 tr("Go to line"), /* title */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
408 tr("Go to line:"), /* caption */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
409 defaultValue, /* default value */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
410 1, /* minimum value */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
411 currentDocument()->size(), /* maximum value */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
412 1, /* step value */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
413 &ok /* success pointer */
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
414 );
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415
1063
1f15c52c11f6 Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
416 if (ok)
1f15c52c11f6 Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
417 {
1256
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
418 QModelIndex object = currentDocument()->index(row - 1);
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419
1256
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
420 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
421 {
1256
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1251
diff changeset
422 mainWindow()->clearSelection();
1257
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
423 mainWindow()->select(object);
1063
1f15c52c11f6 Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
424 }
1f15c52c11f6 Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
425 }
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 void ViewToolset::randomColors()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
430 config::toggleRandomColors();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
432 if (config::randomColors())
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
433 config::setBfcRedGreenView (false);
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435 m_window->updateActions();
1168
0b450b4559b8 Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
436 m_window->renderer()->update();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439 void ViewToolset::drawSurfaces()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
441 config::toggleDrawSurfaces();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 m_window->updateActions();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
444
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445 void ViewToolset::drawEdgeLines()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
447 config::toggleDrawEdgeLines();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 m_window->updateActions();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451 void ViewToolset::drawConditionalLines()
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
452 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
453 config::toggleDrawConditionalLines();
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454 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
455 }
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
456
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
457 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
458 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
459 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
460 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
461 }

mercurial