Fri, 24 May 2013 16:43:56 +0300
Added ability to have multiple GLRenderers
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QGLWidget> |
200
5583af82087e
Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
198
diff
changeset
|
20 | #include <QWheelEvent> |
5583af82087e
Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
198
diff
changeset
|
21 | #include <QMouseEvent> |
5583af82087e
Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
198
diff
changeset
|
22 | #include <QContextMenuEvent> |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
23 | #include <QInputDialog> |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
24 | #include <QTimer> |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <GL/glu.h> |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
26 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "common.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "config.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "file.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "gldraw.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "bbox.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "colors.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "gui.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | #include "misc.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | #include "history.h" |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
36 | #include "dialogs.h" |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | static const struct staticCameraMeta { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | const char glrotate[3]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | const Axis axisX, axisY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | const bool negX, negY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | } g_staticCameras[6] = { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { { 1, 0, 0 }, X, Z, false, false }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | { { 0, 0, 0 }, X, Y, false, true }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | { { 0, 1, 0 }, Z, Y, true, true }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | { { -1, 0, 0 }, X, Z, false, true }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | { { 0, 0, 0 }, X, Y, true, true }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | { { 0, -1, 0 }, Z, Y, false, true }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | cfg (str, gl_bgcolor, "#CCCCD9"); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | cfg (str, gl_maincolor, "#707078"); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | cfg (float, gl_maincolor_alpha, 1.0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | cfg (int, gl_linethickness, 2); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | cfg (bool, gl_colorbfc, true); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | cfg (int, gl_camera, GLRenderer::Free); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | cfg (bool, gl_blackedges, true); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | cfg (bool, gl_axes, false); |
193
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
59 | cfg (bool, gl_wireframe, false); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | // CameraIcon::img is a heap-allocated QPixmap because otherwise it gets |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | // initialized before program gets to main() and constructs a QApplication |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | // and Qt doesn't like that. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | struct CameraIcon { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | QPixmap* img; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | QRect srcRect, destRect, selRect; |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
67 | GL::Camera cam; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | } g_CameraIcons[7]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | const char* g_CameraNames[7] = { "Top", "Front", "Left", "Bottom", "Back", "Right", "Free" }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
72 | const GL::Camera g_Cameras[7] = { |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
73 | GL::Top, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
74 | GL::Front, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
75 | GL::Left, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
76 | GL::Bottom, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
77 | GL::Back, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
78 | GL::Right, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
79 | GL::Free |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | const struct GLAxis { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | const QColor col; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | const vertex vert; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | } g_GLAxes[3] = { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | { QColor (255, 0, 0), vertex (10000, 0, 0) }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | { QColor (128, 192, 0), vertex (0, 10000, 0) }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | { QColor (0, 160, 192), vertex (0, 0, 10000) }, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | resetAngles (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | m_picking = m_rangepick = false; |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
97 | m_camera = (GL::Camera) gl_camera.value; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | m_drawToolTip = false; |
223
4f95d7f2e9ef
Added PROPERTY macro for easier exposed member variable management
Santeri Piippo <crimsondusk64@gmail.com>
parents:
222
diff
changeset
|
99 | m_editMode = Select; |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
100 | m_rectdraw = false; |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
101 | setFile (null); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
102 | setDrawOnly (false); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | m_toolTipTimer = new QTimer (this); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | m_toolTipTimer->setSingleShot (true); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | connect (m_toolTipTimer, SIGNAL (timeout ()), this, SLOT (slot_toolTipTimer ())); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | m_thinBorderPen = m_thickBorderPen; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | m_thinBorderPen.setWidth (1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | // Init camera icons |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
113 | for (const GL::Camera cam : g_Cameras) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | str iconname; |
189
ac2d3e8dd110
Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
188
diff
changeset
|
115 | iconname.format ("camera-%s", str (g_CameraNames[cam]).lower ().c ()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | CameraIcon* info = &g_CameraIcons[cam]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | info->img = new QPixmap (getIcon (iconname)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | info->cam = cam; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
122 | for (int i = 0; i < 6; ++i) { |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
123 | m_overlays[i].img = null; |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
124 | m_depthValues[i] = 0.0f; |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
125 | } |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
126 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
127 | calcCameraIcons (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | // ============================================================================= |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
131 | GLRenderer::~GLRenderer () { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | for (CameraIcon& info : g_CameraIcons) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | delete info.img; |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
134 | |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
135 | for (int i = 0; i < 6; ++i) |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
136 | delete m_overlays[i].img; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | // ============================================================================= |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
142 | void GLRenderer::calcCameraIcons () { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | ushort i = 0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | for (CameraIcon& info : g_CameraIcons) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | const long x1 = (m_width - (info.cam != Free ? 48 : 16)) + ((i % 3) * 16) - 1, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | y1 = ((i / 3) * 16) + 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | info.srcRect = QRect (0, 0, 16, 16); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | info.destRect = QRect (x1, y1, 16, 16); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | info.selRect = QRect (info.destRect.x (), info.destRect.y (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | info.destRect.width () + 1, info.destRect.height () + 1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | ++i; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | |
230
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
157 | void GLRenderer::initGLData () { |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
158 | glEnable (GL_BLEND); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
159 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
160 | glEnable (GL_POLYGON_OFFSET_FILL); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
161 | glPolygonOffset (1.0f, 1.0f); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
162 | |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
163 | glEnable (GL_DEPTH_TEST); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
164 | glShadeModel (GL_SMOOTH); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
165 | glEnable (GL_MULTISAMPLE); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
166 | |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
167 | glEnable (GL_LINE_SMOOTH); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
168 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
169 | } |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
170 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | void GLRenderer::resetAngles () { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | m_rotX = 30.0f; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | m_rotY = 325.f; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | m_panX = m_panY = m_rotZ = 0.0f; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | // Set the default zoom based on the bounding box |
211
8d35e631bef3
Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents:
210
diff
changeset
|
178 | if (g_BBox.empty () == false) |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
179 | setZoom (g_BBox.size () * 6); |
211
8d35e631bef3
Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents:
210
diff
changeset
|
180 | else |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
181 | setZoom (30.0f); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | void GLRenderer::initializeGL () { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | setBackground (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | glLineWidth (gl_linethickness); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | setAutoFillBackground (false); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | setMouseTracking (true); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | setFocusPolicy (Qt::WheelFocus); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
195 | compileAllObjects (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | QColor GLRenderer::getMainColor () { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | QColor col (gl_maincolor.value.chars()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | if (!col.isValid ()) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | return QColor (0, 0, 0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | col.setAlpha (gl_maincolor_alpha * 255.f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | return col; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | // ----------------------------------------------------------------------------- |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | void GLRenderer::setBackground () { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | QColor col (gl_bgcolor.value.chars()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | if (!col.isValid ()) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
218 | col.setAlpha (255); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
220 | m_darkbg = luma (col) < 80; |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
221 | m_bgcolor = col; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | qglClearColor (col); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | // ============================================================================= |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
228 | static vector<short> g_warnedColors; |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
229 | void GLRenderer::setObjectColor (LDObject* obj, const ListType list) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | QColor qcol; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
232 | if (!obj->isColored ()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
235 | if (list == GL::PickList) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | // Make the color by the object's index color if we're picking, so we can |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
237 | // make the index from the color we get from the picking results. Be sure |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
238 | // to use the top level parent's index since inlinees don't have an index. |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
239 | long i = obj->topLevelParent ()->getIndex (file ()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | // We should have the index now. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | assert (i != -1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // Calculate a color based from this index. This method caters for |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | // 16777216 objects. I don't think that'll be exceeded anytime soon. :) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | // ATM biggest is 53588.dat with 12600 lines. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | double r = (i / (256 * 256)) % 256, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | g = (i / 256) % 256, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | b = i % 256; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
251 | qglColor (QColor (r, g, b)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
255 | if ((list == BFCFrontList || list == BFCBackList) && |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | obj->getType () != LDObject::Line && |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | obj->getType () != LDObject::CondLine) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
259 | if (list == GL::BFCFrontList) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
260 | qcol = QColor (80, 192, 0); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | else |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
262 | qcol = QColor (224, 0, 0); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
263 | } else { |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
264 | if (obj->color == maincolor) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
265 | qcol = getMainColor (); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
266 | else { |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
267 | color* col = getColor (obj->color); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
268 | qcol = col->faceColor; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
269 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
271 | if (obj->color == edgecolor) { |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
272 | qcol = luma (m_bgcolor) < 40 ? QColor (64, 64, 64) : Qt::black; |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
273 | color* col; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
274 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
275 | if (!gl_blackedges && obj->parent != null && (col = getColor (obj->parent->color)) != null) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
276 | qcol = col->edgeColor; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
277 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
279 | if (qcol.isValid () == false) { |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
280 | // The color was unknown. Use main color to make the object at least |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
281 | // not appear pitch-black. |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
282 | if (obj->color != edgecolor) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
283 | qcol = getMainColor (); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
284 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
285 | // Warn about the unknown colors, but only once. |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
286 | for (short i : g_warnedColors) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
287 | if (obj->color == i) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
288 | return; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
289 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
290 | printf ("%s: Unknown color %d!\n", __func__, obj->color); |
252
3f9067022d74
Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents:
251
diff
changeset
|
291 | g_warnedColors << obj->color; |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
292 | return; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
293 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | long r = qcol.red (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | g = qcol.green (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | b = qcol.blue (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | a = qcol.alpha (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
301 | if (obj->topLevelParent ()->selected ()) { |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
302 | // Brighten it up for the select list. |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
303 | const uchar add = 51; |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
304 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | r = min (r + add, 255l); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | g = min (g + add, 255l); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | b = min (b + add, 255l); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | glColor4f ( |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | ((double) r) / 255.0f, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | ((double) g) / 255.0f, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | ((double) b) / 255.0f, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | ((double) a) / 255.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | void GLRenderer::refresh () { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
321 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | swapBuffers (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | void GLRenderer::hardRefresh () { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
327 | compileAllObjects (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | refresh (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | glLineWidth (gl_linethickness); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | void GLRenderer::resizeGL (int w, int h) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | m_width = w; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | m_height = h; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
340 | calcCameraIcons (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | glViewport (0, 0, w, h); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | glMatrixMode (GL_PROJECTION); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | glLoadIdentity (); |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
345 | gluPerspective (45.0f, (double) w / (double) h, 1.0f, 10000.0f); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | glMatrixMode (GL_MODELVIEW); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
349 | void GLRenderer::drawGLScene () { |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
350 | if (file () == null) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | |
193
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
353 | if (gl_wireframe && !picking ()) |
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
354 | glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
355 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | glEnable (GL_DEPTH_TEST); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | if (m_camera != GLRenderer::Free) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | glMatrixMode (GL_PROJECTION); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | glPushMatrix (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
362 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | glLoadIdentity (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | glOrtho (-m_virtWidth, m_virtWidth, -m_virtHeight, m_virtHeight, -100.0f, 100.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | glTranslatef (m_panX, m_panY, 0.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | glRotatef (90.0f, g_staticCameras[m_camera].glrotate[0], |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | g_staticCameras[m_camera].glrotate[1], |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | g_staticCameras[m_camera].glrotate[2]); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | // Back camera needs to be handled differently |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | if (m_camera == GLRenderer::Back) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | glRotatef (180.0f, 1.0f, 0.0f, 0.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | glRotatef (180.0f, 0.0f, 0.0f, 1.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | } else { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
376 | glMatrixMode (GL_MODELVIEW); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | glPushMatrix (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | glLoadIdentity (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | glTranslatef (0.0f, 0.0f, -2.0f); |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
381 | glTranslatef (m_panX, m_panY, -zoom ()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | glRotatef (m_rotX, 1.0f, 0.0f, 0.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | glRotatef (m_rotY, 0.0f, 1.0f, 0.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | glRotatef (m_rotZ, 0.0f, 0.0f, 1.0f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
386 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
387 | const GL::ListType list = (!drawOnly () && m_picking) ? PickList : NormalList; |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
388 | |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
389 | if (gl_colorbfc && !m_picking && !drawOnly ()) { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
390 | glEnable (GL_CULL_FACE); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
392 | for (LDObject* obj : file ()->objs ()) { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
393 | if (obj->hidden ()) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
394 | continue; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
395 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
396 | glCullFace (GL_BACK); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
397 | glCallList (obj->glLists[BFCFrontList]); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
398 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
399 | glCullFace (GL_FRONT); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
400 | glCallList (obj->glLists[BFCBackList]); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
401 | } |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
402 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
403 | glDisable (GL_CULL_FACE); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
404 | } else { |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
405 | for (LDObject* obj : file ()->objs ()) { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
406 | if (obj->hidden ()) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
407 | continue; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
408 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
409 | glCallList (obj->glLists[list]); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
410 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
413 | if (gl_axes && !m_picking && !drawOnly ()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | glCallList (m_axeslist); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | glPopMatrix (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | glMatrixMode (GL_MODELVIEW); |
193
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
418 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | // ============================================================================= |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
422 | vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const { |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
423 | assert (camera () != Free); |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
424 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | vertex pos3d; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | const staticCameraMeta* cam = &g_staticCameras[m_camera]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | const Axis axisX = cam->axisX; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | const Axis axisY = cam->axisY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | const short negXFac = cam->negX ? -1 : 1, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | negYFac = cam->negY ? -1 : 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | // Calculate cx and cy - these are the LDraw unit coords the cursor is at. |
209
d3bdd13bce4d
Don't do any object offsetting, instead use origin as the rotation point for the free camera.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
208
diff
changeset
|
433 | double cx = (-m_virtWidth + ((2 * pos2d.x () * m_virtWidth) / m_width) - m_panX); |
d3bdd13bce4d
Don't do any object offsetting, instead use origin as the rotation point for the free camera.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
208
diff
changeset
|
434 | double cy = (m_virtHeight - ((2 * pos2d.y () * m_virtHeight) / m_height) - m_panY); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | if (snap) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | cx = Grid::snap (cx, (Grid::Config) axisX); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | cy = Grid::snap (cy, (Grid::Config) axisY); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | cx *= negXFac; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | cy *= negYFac; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
443 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | pos3d = g_origin; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | pos3d[axisX] = cx; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | pos3d[axisY] = cy; |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
447 | pos3d[3 - axisX - axisY] = depthValue (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | return pos3d; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
449 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | // ============================================================================= |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
452 | QPoint GLRenderer::coordconv3_2 (const vertex& pos3d) const { |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
453 | GLfloat m[16]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | const staticCameraMeta* cam = &g_staticCameras[m_camera]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | const Axis axisX = cam->axisX; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
456 | const Axis axisY = cam->axisY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
457 | const short negXFac = cam->negX ? -1 : 1, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
458 | negYFac = cam->negY ? -1 : 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
460 | glGetFloatv (GL_MODELVIEW_MATRIX, m); |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
461 | |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
462 | const double x = pos3d.x (); |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
463 | const double y = pos3d.y (); |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
464 | const double z = pos3d.z (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
465 | |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
466 | vertex transformed; |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
467 | transformed[X] = (m[0] * x) + (m[1] * y) + (m[2] * z) + m[3]; |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
468 | transformed[Y] = (m[4] * x) + (m[5] * y) + (m[6] * z) + m[7]; |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
469 | transformed[Z] = (m[8] * x) + (m[9] * y) + (m[10] * z) + m[11]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
470 | |
209
d3bdd13bce4d
Don't do any object offsetting, instead use origin as the rotation point for the free camera.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
208
diff
changeset
|
471 | double rx = (((transformed[axisX] * negXFac) + m_virtWidth + m_panX) * m_width) / (2 * m_virtWidth); |
d3bdd13bce4d
Don't do any object offsetting, instead use origin as the rotation point for the free camera.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
208
diff
changeset
|
472 | double ry = (((transformed[axisY] * negYFac) - m_virtHeight + m_panY) * m_height) / (2 * m_virtHeight); |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
473 | |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
474 | return QPoint (rx, -ry); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
480 | void GLRenderer::paintEvent (QPaintEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | Q_UNUSED (ev) |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
482 | |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
483 | makeCurrent (); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
484 | m_virtWidth = zoom (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | m_virtHeight = (m_height * m_virtWidth) / m_width; |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
486 | |
230
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
487 | initGLData (); |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
488 | drawGLScene (); |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
489 | |
230
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
490 | m_hoverpos = g_origin; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
492 | QPainter paint (this); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
493 | QFontMetrics metrics = QFontMetrics (QFont ()); |
209
d3bdd13bce4d
Don't do any object offsetting, instead use origin as the rotation point for the free camera.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
208
diff
changeset
|
494 | paint.setRenderHint (QPainter::HighQualityAntialiasing); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
495 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
496 | // If we wish to only draw the brick, stop here |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
497 | if (drawOnly ()) |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
498 | return; |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
499 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | if (m_camera != Free) { |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
501 | // Paint the overlay image if we have one |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
502 | const overlayMeta& overlay = m_overlays[m_camera]; |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
503 | if (overlay.img != null) { |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
504 | QPoint v0 = coordconv3_2 (m_overlays[m_camera].v0), |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
505 | v1 = coordconv3_2 (m_overlays[m_camera].v1); |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
506 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
507 | QRect targRect (v0.x (), v0.y (), abs (v1.x () - v0.x ()), abs (v1.y () - v0.y ())), |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
508 | srcRect (0, 0, overlay.img->width (), overlay.img->height ()); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
509 | paint.drawImage (targRect, *overlay.img, srcRect); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
510 | } |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
511 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
512 | // Calculate 3d position of the cursor |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
513 | m_hoverpos = coordconv2_3 (m_pos, true); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
514 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
515 | // Paint the coordinates onto the screen. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
516 | str text; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
517 | text.format ("X: %s, Y: %s, Z: %s", ftoa (m_hoverpos[X]).chars (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
518 | ftoa (m_hoverpos[Y]).chars (), ftoa (m_hoverpos[Z]).chars ()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
519 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
520 | QFontMetrics metrics = QFontMetrics (font ()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
521 | QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
522 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | paint.drawText (m_width - textSize.width (), m_height - 16, textSize.width (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
524 | textSize.height (), Qt::AlignCenter, text); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
525 | |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
526 | // If we're drawing, draw the vertices onto the screen. |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
527 | if (editMode () == Draw) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
528 | ushort numverts; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
529 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
530 | if (!m_rectdraw) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
531 | numverts = m_drawedVerts.size () + 1; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
532 | else |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
533 | numverts = (m_drawedVerts.size () > 0) ? 4 : 1; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
534 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | const short blipsize = 8; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
536 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | if (numverts > 0) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | QPoint* poly = new QPoint[numverts]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
540 | if (!m_rectdraw) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
541 | uchar i = 0; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
542 | for (vertex& vert : m_drawedVerts) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
543 | poly[i] = coordconv3_2 (vert); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
544 | ++i; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
545 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
546 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
547 | // Draw the cursor vertex as the last one in the list. |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
548 | if (numverts < 5) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
549 | poly[i] = coordconv3_2 (m_hoverpos); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
550 | else |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
551 | numverts = 4; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
552 | } else { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
553 | if (m_drawedVerts.size () > 0) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
554 | QPoint v0 = coordconv3_2 (m_drawedVerts[0]), |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
555 | v1 = coordconv3_2 ((m_drawedVerts.size () >= 2) ? m_drawedVerts[1] : m_hoverpos); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
556 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
557 | poly[0] = QPoint (v0.x (), v0.y ()); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
558 | poly[1] = QPoint (v0.x (), v1.y ()); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
559 | poly[2] = QPoint (v1.x (), v1.y ()); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
560 | poly[3] = QPoint (v1.x (), v0.y ()); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
561 | } else { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
562 | poly[0] = coordconv3_2 (m_hoverpos); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
563 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
566 | QPen pen = m_thinBorderPen; |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
567 | pen.setWidth (1); |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
568 | paint.setPen (pen); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | paint.setBrush (QColor (128, 192, 0)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
570 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | // Draw vertex blips |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | for (ushort i = 0; i < numverts; ++i) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | QPoint& blip = poly[i]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
574 | paint.drawEllipse (blip.x () - blipsize / 2, blip.y () - blipsize / 2, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | blipsize, blipsize); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
577 | |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
578 | pen.setWidth (2); |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
579 | pen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black); |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
580 | paint.setPen (pen); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
581 | paint.setBrush (QColor (128, 192, 0, 128)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | paint.drawPolygon (poly, numverts); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
583 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
584 | delete[] poly; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
586 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
589 | // Camera icons |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
590 | if (!m_picking) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
591 | // Draw a background for the selected camera |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
592 | paint.setPen (m_thinBorderPen); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
593 | paint.setBrush (QBrush (QColor (0, 128, 160, 128))); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
594 | paint.drawRect (g_CameraIcons[camera ()].selRect); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
595 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
596 | // Draw the actual icons |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
597 | for (CameraIcon& info : g_CameraIcons) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
598 | // Don't draw the free camera icon when in draw mode |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
599 | if (&info == &g_CameraIcons[GL::Free] && editMode () != Select) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
600 | continue; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
601 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
602 | paint.drawPixmap (info.destRect, *info.img, info.srcRect); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
603 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
604 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
605 | // Draw a label for the current camera in the top left corner |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
606 | { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
607 | const ushort margin = 4; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
608 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
609 | str label; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
610 | label.format ("%s Camera", g_CameraNames[camera ()]); |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
611 | paint.setPen (m_darkbg ? Qt::white : Qt::black); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
612 | paint.drawText (QPoint (margin, margin + metrics.ascent ()), label); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
613 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
614 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
615 | // Tool tips |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
616 | if (m_drawToolTip) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | if (g_CameraIcons[m_toolTipCamera].destRect.contains (m_pos) == false) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | m_drawToolTip = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
619 | else { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
620 | QPen bord = m_thinBorderPen; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
621 | bord.setBrush (Qt::black); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
622 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | const ushort margin = 2; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | ushort x0 = m_pos.x (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | y0 = m_pos.y (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | str label; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
628 | label.format ("%s Camera", g_CameraNames[m_toolTipCamera]); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | const ushort textWidth = metrics.width (label), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | textHeight = metrics.height (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | fullWidth = textWidth + (2 * margin), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
633 | fullHeight = textHeight + (2 * margin); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
634 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
635 | QRect area (m_pos.x (), m_pos.y (), fullWidth, fullHeight); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
636 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
637 | if (x0 + fullWidth > m_width) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
638 | x0 -= fullWidth; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
639 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
640 | if (y0 + fullHeight > m_height) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
641 | y0 -= fullHeight; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
642 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
643 | paint.setBrush (QColor (0, 128, 255, 208)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | paint.setPen (bord); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
645 | paint.drawRect (x0, y0, fullWidth, fullHeight); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | paint.setBrush (Qt::black); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
648 | paint.drawText (QPoint (x0 + margin, y0 + margin + metrics.ascent ()), label); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
649 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
650 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
652 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
653 | // If we're range-picking, draw a rectangle encompassing the selection area. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
654 | if (m_rangepick && !m_picking) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
655 | const short x0 = m_rangeStart.x (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
656 | y0 = m_rangeStart.y (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | x1 = m_pos.x (), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | y1 = m_pos.y (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
660 | QRect rect (x0, y0, x1 - x0, y1 - y0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
661 | QColor fillColor = (m_addpick ? "#80FF00" : "#00CCFF"); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
662 | fillColor.setAlphaF (0.2f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
663 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
664 | paint.setPen (m_thickBorderPen); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | paint.setBrush (QBrush (fillColor)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | paint.drawRect (rect); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
668 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
670 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
671 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
672 | // ============================================================================= |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
673 | void GLRenderer::compileAllObjects () { |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
674 | if (!file ()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
676 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
677 | for (LDObject* obj : file ()->objs ()) |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
678 | compileObject (obj); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | // Compile axes |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
681 | glDeleteLists (m_axeslist, 1); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | m_axeslist = glGenLists (1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | glNewList (m_axeslist, GL_COMPILE); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | glBegin (GL_LINES); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
685 | for (const GLAxis& ax : g_GLAxes) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | qglColor (ax.col); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
687 | compileVertex (ax.vert); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
688 | compileVertex (-ax.vert); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | glEnd (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | glEndList (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
693 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
695 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | // ============================================================================= |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
697 | static bool g_glInvert = false; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
698 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | glBegin (gltype); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
701 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | const short numverts = (obj->getType () != LDObject::CondLine) ? obj->vertices () : 2; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
703 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
704 | if (g_glInvert == false) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
705 | for (short i = 0; i < numverts; ++i) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
706 | compileVertex (obj->coords[i]); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
707 | else |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
708 | for (short i = numverts - 1; i >= 0; --i) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
709 | compileVertex (obj->coords[i]); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
710 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
711 | glEnd (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
712 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
713 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
714 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
715 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
716 | // ============================================================================= |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
717 | void GLRenderer::compileList (LDObject* obj, const GLRenderer::ListType list) { |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
718 | setObjectColor (obj, list); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | switch (obj->getType ()) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
721 | case LDObject::Line: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
722 | compileSubObject (obj, GL_LINES); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
724 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | case LDObject::CondLine: |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
726 | if (list != GL::PickList) { |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
727 | glLineStipple (1, 0x6666); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
728 | glEnable (GL_LINE_STIPPLE); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
729 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
730 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
731 | compileSubObject (obj, GL_LINES); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
732 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
733 | glDisable (GL_LINE_STIPPLE); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
734 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
735 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
736 | case LDObject::Triangle: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | compileSubObject (obj, GL_TRIANGLES); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
738 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
739 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
740 | case LDObject::Quad: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
741 | compileSubObject (obj, GL_QUADS); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
742 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
743 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
744 | case LDObject::Subfile: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
745 | { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
746 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
747 | vector<LDObject*> objs = ref->inlineContents (true, true); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
748 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
749 | bool oldinvert = g_glInvert; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
750 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
751 | if (ref->transform.determinant () < 0) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
752 | g_glInvert = !g_glInvert; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
753 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
754 | LDObject* prev = ref->prev (); |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
755 | if (prev && prev->getType () == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
756 | g_glInvert = !g_glInvert; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
757 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
758 | for (LDObject* obj : objs) { |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
759 | compileList (obj, list); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
760 | delete obj; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
761 | } |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
762 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
763 | g_glInvert = oldinvert; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
764 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
765 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
766 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
767 | case LDObject::Radial: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
768 | { |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
769 | LDRadial* rad = static_cast<LDRadial*> (obj); |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
770 | vector<LDObject*> objs = rad->decompose (true); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
771 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
772 | bool oldinvert = g_glInvert; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
773 | if (rad->transform.determinant () < 0) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
774 | g_glInvert = !g_glInvert; |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
775 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
776 | LDObject* prev = rad->prev (); |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
777 | if (prev && prev->getType () == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
778 | g_glInvert = !g_glInvert; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
779 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
780 | for (LDObject* obj : objs) { |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
781 | compileList (obj, list); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
782 | delete obj; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
783 | } |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
784 | |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
785 | g_glInvert = oldinvert; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
786 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
787 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
788 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
789 | #if 0 |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
790 | TODO: find a proper way to draw vertices without having them be affected by zoom. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
791 | case LDObject::Vertex: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
792 | { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
793 | LDVertex* pVert = static_cast<LDVertex*> (obj); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
794 | LDTriangle* pPoly; |
188
4e686b771996
Further removal of hungarian notation
Santeri Piippo <crimsondusk64@gmail.com>
parents:
186
diff
changeset
|
795 | vertex* vPos = &(pVert->pos); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
796 | const double fPolyScale = max (fZoom, 1.0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
797 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
798 | #define BIPYRAMID_COORD(N) ((((i + N) % 4) >= 2 ? 1 : -1) * 0.3f * fPolyScale) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
799 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
800 | for (int i = 0; i < 8; ++i) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
801 | pPoly = new LDTriangle; |
188
4e686b771996
Further removal of hungarian notation
Santeri Piippo <crimsondusk64@gmail.com>
parents:
186
diff
changeset
|
802 | pPoly->coords[0] = {vPos->x, vPos->y + ((i >= 4 ? 1 : -1) * 0.4f * fPolyScale), vPos->z}; |
4e686b771996
Further removal of hungarian notation
Santeri Piippo <crimsondusk64@gmail.com>
parents:
186
diff
changeset
|
803 | pPoly->coords[1] = { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
804 | vPos->x + BIPYRAMID_COORD (0), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
805 | vPos->y, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
806 | vPos->z + BIPYRAMID_COORD (1) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
807 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
808 | |
188
4e686b771996
Further removal of hungarian notation
Santeri Piippo <crimsondusk64@gmail.com>
parents:
186
diff
changeset
|
809 | pPoly->coords[2] = { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
810 | vPos->x + BIPYRAMID_COORD (1), |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
811 | vPos->y, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
812 | vPos->z + BIPYRAMID_COORD (2) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
813 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
814 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
815 | pPoly->dColor = pVert->dColor; |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
816 | compileOneObject (pPoly, list); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
817 | delete pPoly; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
818 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
819 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
820 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
821 | #endif // 0 |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
822 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
823 | default: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
824 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
825 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
826 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
827 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
828 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
829 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
830 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
831 | void GLRenderer::compileVertex (const vertex& vrt) { |
209
d3bdd13bce4d
Don't do any object offsetting, instead use origin as the rotation point for the free camera.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
208
diff
changeset
|
832 | glVertex3d (vrt[X], -vrt[Y], -vrt[Z]); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
833 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
834 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
835 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
836 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
837 | // ============================================================================= |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
838 | void GLRenderer::clampAngle (double& angle) const { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
839 | while (angle < 0) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
840 | angle += 360.0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
841 | while (angle > 360.0) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
842 | angle -= 360.0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
843 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
844 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
845 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
846 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
847 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
848 | void GLRenderer::mouseReleaseEvent (QMouseEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
849 | const bool wasLeft = (m_lastButtons & Qt::LeftButton) && !(ev->buttons() & Qt::LeftButton); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
850 | const bool wasRight = (m_lastButtons & Qt::RightButton) && !(ev->buttons() & Qt::RightButton); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
851 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
852 | if (wasLeft) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
853 | // Check if we selected a camera icon |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
854 | if (!m_rangepick) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
855 | for (CameraIcon& info : g_CameraIcons) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
856 | if (info.destRect.contains (ev->pos ())) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
857 | setCamera (info.cam); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
858 | update (); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
859 | return; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
860 | } |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
861 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
862 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
863 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
864 | switch (editMode ()) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
865 | case Draw: |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
866 | if (m_rectdraw) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
867 | if (m_drawedVerts.size () == 2) { |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
868 | endDraw (true); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
869 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
870 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
871 | } else { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
872 | // If we have 4 verts, stop drawing. |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
873 | if (m_drawedVerts.size () >= 4) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
874 | endDraw (true); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
875 | return; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
876 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
877 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
878 | if (m_drawedVerts.size () == 0 && ev->modifiers () & Qt::ShiftModifier) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
879 | m_rectdraw = true; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
880 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
881 | // If we picked an already-existing vertex, stop drawing |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
882 | for (vertex& vert : m_drawedVerts) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
883 | if (vert == m_hoverpos) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
884 | endDraw (true); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
885 | return; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
886 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
887 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
888 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
889 | |
252
3f9067022d74
Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents:
251
diff
changeset
|
890 | m_drawedVerts << m_hoverpos; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
891 | update (); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
892 | break; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
893 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
894 | case Select: |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
895 | if (!drawOnly ()) { |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
896 | if (!m_rangepick) |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
897 | m_addpick = (m_keymods & Qt::ControlModifier); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
898 | |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
899 | if (m_totalmove < 10 || m_rangepick) |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
900 | pick (ev->x (), ev->y ()); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
901 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
902 | break; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
903 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
904 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
905 | m_rangepick = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
906 | m_totalmove = 0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
907 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
908 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
909 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
910 | if (wasRight && m_drawedVerts.size () > 0) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
911 | // Remove the last vertex |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
912 | m_drawedVerts.erase (m_drawedVerts.size () - 1); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
913 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
914 | if (m_drawedVerts.size () == 0) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
915 | m_rectdraw = false; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
916 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
917 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
918 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
919 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
920 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
921 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
922 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
923 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
924 | void GLRenderer::mousePressEvent (QMouseEvent* ev) { |
223
4f95d7f2e9ef
Added PROPERTY macro for easier exposed member variable management
Santeri Piippo <crimsondusk64@gmail.com>
parents:
222
diff
changeset
|
925 | if (ev->buttons () & Qt::LeftButton) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
926 | m_totalmove = 0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
927 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
928 | if (ev->modifiers () & Qt::ShiftModifier) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
929 | m_rangepick = true; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
930 | m_rangeStart.setX (ev->x ()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
931 | m_rangeStart.setY (ev->y ()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
932 | m_addpick = (m_keymods & Qt::ControlModifier); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
933 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
934 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
935 | m_lastButtons = ev->buttons (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
936 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
937 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
938 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
939 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
940 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
941 | void GLRenderer::mouseMoveEvent (QMouseEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
942 | int dx = ev->x () - m_pos.x (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
943 | int dy = ev->y () - m_pos.y (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
944 | m_totalmove += abs (dx) + abs (dy); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
945 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
946 | if (ev->buttons () & Qt::LeftButton && !m_rangepick) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
947 | m_rotX = m_rotX + (dy); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
948 | m_rotY = m_rotY + (dx); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
949 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
950 | clampAngle (m_rotX); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
951 | clampAngle (m_rotY); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
952 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
953 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
954 | if (ev->buttons () & Qt::MidButton) { |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
955 | m_panX += 0.03f * dx * (zoom () / 7.5f); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
956 | m_panY -= 0.03f * dy * (zoom () / 7.5f); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
957 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
958 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
959 | // Start the tool tip timer |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
960 | if (!m_drawToolTip) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
961 | m_toolTipTimer->start (1000); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
962 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
963 | m_pos = ev->pos (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
964 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
965 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
966 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
967 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
968 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
969 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
970 | void GLRenderer::keyPressEvent (QKeyEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
971 | m_keymods = ev->modifiers (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
972 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
973 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
974 | void GLRenderer::keyReleaseEvent (QKeyEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
975 | m_keymods = ev->modifiers (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
976 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
977 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
978 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
979 | void GLRenderer::wheelEvent (QWheelEvent* ev) { |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
980 | makeCurrent (); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
981 | |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
982 | if (zoom () > 15) |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
983 | setZoom (zoom () * (ev->delta () < 0 ? 1.2f : 0.833f)); |
222
fddd36a6526c
Make zooming more intuitive - use incremental zooming after crossing the 15.0f mark
Santeri Piippo <crimsondusk64@gmail.com>
parents:
219
diff
changeset
|
984 | else |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
985 | setZoom (zoom () + ((double) ev->delta () / -100.0f)); |
222
fddd36a6526c
Make zooming more intuitive - use incremental zooming after crossing the 15.0f mark
Santeri Piippo <crimsondusk64@gmail.com>
parents:
219
diff
changeset
|
986 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
987 | setZoom (clamp<double> (zoom (), 0.01f, 10000.0f)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
988 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
989 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
990 | ev->accept (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
991 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
992 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
993 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
994 | void GLRenderer::leaveEvent (QEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
995 | Q_UNUSED (ev); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
996 | m_drawToolTip = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
997 | m_toolTipTimer->stop (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
998 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
999 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1000 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1001 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1002 | void GLRenderer::contextMenuEvent (QContextMenuEvent* ev) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1003 | g_win->spawnContextMenu (ev->globalPos ()); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1004 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1005 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1006 | // ============================================================================= |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
1007 | void GLRenderer::setCamera (const GL::Camera cam) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1008 | m_camera = cam; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1009 | gl_camera = (int) cam; |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1010 | g_win->updateEditModeActions (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1011 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1012 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1013 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1014 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1015 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1016 | void GLRenderer::pick (uint mouseX, uint mouseY) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1017 | GLint viewport[4]; |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1018 | makeCurrent (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1019 | |
212
79c5205b807c
Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
1020 | // Use particularly thick lines while picking ease up selecting lines. |
79c5205b807c
Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
1021 | glLineWidth (max<double> (gl_linethickness, 6.5f)); |
79c5205b807c
Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
1022 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1023 | // Clear the selection if we do not wish to add to it. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1024 | if (!m_addpick) { |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1025 | vector<LDObject*> oldsel = g_win->sel (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1026 | g_win->sel ().clear (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1027 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1028 | for (LDObject* obj : oldsel) { |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1029 | obj->setSelected (false); |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1030 | compileObject (obj); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1031 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1032 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1033 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1034 | m_picking = true; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1035 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1036 | // Paint the picking scene |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1037 | glDisable (GL_DITHER); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1038 | glClearColor (1.0f, 1.0f, 1.0f, 1.0f); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1039 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1040 | drawGLScene (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1041 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1042 | glGetIntegerv (GL_VIEWPORT, viewport); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1043 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1044 | short x0 = mouseX, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1045 | y0 = mouseY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1046 | short x1, y1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1047 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1048 | // Determine how big an area to read - with range picking, we pick by |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1049 | // the area given, with single pixel picking, we use an 1 x 1 area. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1050 | if (m_rangepick) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1051 | x1 = m_rangeStart.x (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1052 | y1 = m_rangeStart.y (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1053 | } else { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1054 | x1 = x0 + 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1055 | y1 = y0 + 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1056 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1057 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1058 | // x0 and y0 must be less than x1 and y1, respectively. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1059 | if (x0 > x1) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1060 | dataswap (x0, x1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1061 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1062 | if (y0 > y1) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1063 | dataswap (y0, y1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1064 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1065 | // Clamp the values to ensure they're within bounds |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1066 | x0 = max<short> (0, x0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1067 | y0 = max<short> (0, y0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1068 | x1 = min<short> (x1, m_width); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1069 | y1 = min<short> (y1, m_height); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1070 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1071 | const short areawidth = (x1 - x0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1072 | const short areaheight = (y1 - y0); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1073 | const long numpixels = areawidth * areaheight; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1074 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1075 | // Allocate space for the pixel data. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1076 | uchar* const pixeldata = new uchar[4 * numpixels]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1077 | uchar* pixelptr = &pixeldata[0]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1078 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1079 | assert (viewport[3] == m_height); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1080 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1081 | // Read pixels from the color buffer. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1082 | glReadPixels (x0, viewport[3] - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1083 | |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1084 | LDObject* removedObj = null; |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1085 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1086 | // Go through each pixel read and add them to the selection. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1087 | for (long i = 0; i < numpixels; ++i) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1088 | uint32 idx = |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1089 | (*(pixelptr) * 0x10000) + |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1090 | (*(pixelptr + 1) * 0x00100) + |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1091 | (*(pixelptr + 2) * 0x00001); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1092 | pixelptr += 4; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1093 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1094 | if (idx == 0xFFFFFF) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1095 | continue; // White is background; skip |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1096 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1097 | LDObject* obj = file ()->obj (idx); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1098 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1099 | // If this is an additive single pick and the object is currently selected, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1100 | // we remove it from selection instead. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1101 | if (!m_rangepick && m_addpick) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1102 | bool removed = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1103 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1104 | for (ulong i = 0; i < g_win->sel ().size(); ++i) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1105 | if (g_win->sel ()[i] == obj) { |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1106 | g_win->sel ().erase (i); |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1107 | obj->setSelected (false); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1108 | removed = true; |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1109 | removedObj = obj; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1110 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1111 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1112 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1113 | if (removed) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1114 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1115 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1116 | |
252
3f9067022d74
Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents:
251
diff
changeset
|
1117 | g_win->sel () << obj; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1118 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1119 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1120 | delete[] pixeldata; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1121 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1122 | // Remove duplicate entries. For this to be effective, the vector must be |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1123 | // sorted first. |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1124 | vector<LDObject*>& sel = g_win->sel (); |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1125 | std::sort (sel.begin (), sel.end ()); |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1126 | vector<LDObject*>::it pos = std::unique (sel.begin (), sel.end ()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1127 | sel.resize (std::distance (sel.begin (), pos)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1128 | // Update everything now. |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1129 | g_win->updateSelection (); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1130 | |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1131 | // Recompile the objects now to update their color |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1132 | for (LDObject* obj : sel) |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1133 | compileObject (obj); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1134 | |
191
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1135 | if (removedObj) |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1136 | compileObject (removedObj); |
9bb6a17305ad
Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
189
diff
changeset
|
1137 | |
212
79c5205b807c
Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
1138 | // Restore line thickness |
79c5205b807c
Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
1139 | glLineWidth (gl_linethickness); |
79c5205b807c
Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents:
211
diff
changeset
|
1140 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1141 | m_picking = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1142 | m_rangepick = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1143 | glEnable (GL_DITHER); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1144 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1145 | setBackground (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1146 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1147 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1148 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1149 | // ============================================================================= |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1150 | void GLRenderer::callback_setEditMode () { |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1151 | switch (editMode ()) { |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1152 | case Select: |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1153 | unsetCursor (); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1154 | setContextMenuPolicy (Qt::DefaultContextMenu); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1155 | break; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1156 | |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1157 | case Draw: |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1158 | if (m_camera == Free) |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1159 | return; // Cannot draw with the free camera |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1160 | |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1161 | // Disable the context menu - we need the right mouse button |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1162 | // for removing vertices. |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1163 | setContextMenuPolicy (Qt::NoContextMenu); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1164 | |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1165 | // Use the crosshair cursor when drawing. |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1166 | setCursor (Qt::CrossCursor); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1167 | |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1168 | // Clear the selection when beginning to draw. |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1169 | // FIXME: make the selection clearing stuff in ::pick a method and use it |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1170 | // here! This code doesn't update the GL lists. |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1171 | g_win->sel ().clear (); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1172 | g_win->updateSelection (); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1173 | m_drawedVerts.clear (); |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1174 | break; |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1175 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1176 | |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1177 | g_win->updateEditModeActions (); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1178 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1179 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1180 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1181 | // ============================================================================= |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1182 | void GLRenderer::endDraw (bool accept) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1183 | (void) accept; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1184 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1185 | // Clean the selection and create the object |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1186 | vector<vertex>& verts = m_drawedVerts; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1187 | LDObject* obj = null; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1188 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1189 | if (m_rectdraw) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1190 | LDQuad* quad = new LDQuad; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1191 | vertex v0 = m_drawedVerts[0], |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1192 | v1 = m_drawedVerts[1]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1193 | const Axis axisX = cameraAxis (false), |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1194 | axisY = cameraAxis (true); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1195 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1196 | memset (quad->coords, 0, sizeof quad->coords); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1197 | quad->coords[0][axisX] = v0[axisX]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1198 | quad->coords[0][axisY] = v0[axisY]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1199 | quad->coords[1][axisX] = v1[axisX]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1200 | quad->coords[1][axisY] = v0[axisY]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1201 | quad->coords[2][axisX] = v1[axisX]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1202 | quad->coords[2][axisY] = v1[axisY]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1203 | quad->coords[3][axisX] = v0[axisX]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1204 | quad->coords[3][axisY] = v1[axisY]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1205 | quad->color = maincolor; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1206 | obj = quad; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1207 | } else { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1208 | switch (verts.size ()) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1209 | case 1: |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1210 | // 1 vertex - add a vertex object |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1211 | obj = new LDVertex; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1212 | static_cast<LDVertex*> (obj)->pos = verts[0]; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1213 | obj->color = maincolor; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1214 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1215 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1216 | case 2: |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1217 | // 2 verts - make a line |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1218 | obj = new LDLine; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1219 | obj->color = edgecolor; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1220 | for (ushort i = 0; i < 2; ++i) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1221 | obj->coords[i] = verts[i]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1222 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1223 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1224 | case 3: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1225 | case 4: |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1226 | obj = (verts.size () == 3) ? |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1227 | static_cast<LDObject*> (new LDTriangle) : |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1228 | static_cast<LDObject*> (new LDQuad); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1229 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1230 | obj->color = maincolor; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1231 | for (ushort i = 0; i < obj->vertices (); ++i) |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1232 | obj->coords[i] = verts[i]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1233 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1234 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1235 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1236 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1237 | if (obj) { |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1238 | file ()->addObject (obj); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1239 | compileObject (obj); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1240 | g_win->fullRefresh (); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1241 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1242 | History::addEntry (new AddHistory ({(ulong) obj->getIndex (file ())}, {obj->clone ()})); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1243 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1244 | |
207
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
1245 | m_drawedVerts.clear (); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1246 | m_rectdraw = false; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1247 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1248 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1249 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1250 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1251 | // ============================================================================= |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1252 | void GLRenderer::compileObject (LDObject* obj) { |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1253 | deleteLists (obj); |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1254 | |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1255 | for (const GL::ListType listType : g_glListTypes) { |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1256 | if (drawOnly () && listType != GL::NormalList) |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1257 | continue; |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
1258 | |
185
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1259 | GLuint list = glGenLists (1); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1260 | glNewList (list, GL_COMPILE); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1261 | |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1262 | obj->glLists[listType] = list; |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1263 | compileList (obj, listType); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1264 | |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1265 | glEndList (); |
6fea53f1ffc2
Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
183
diff
changeset
|
1266 | } |
216
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1267 | |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1268 | obj->m_glinit = true; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1269 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1270 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1271 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1272 | uchar* GLRenderer::screencap (ushort& w, ushort& h) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1273 | w = m_width; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1274 | h = m_height; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1275 | uchar* cap = new uchar[4 * w * h]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1276 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1277 | m_screencap = true; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1278 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1279 | m_screencap = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1280 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1281 | // Capture the pixels |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1282 | glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1283 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1284 | // Restore the background |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1285 | setBackground (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1286 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1287 | return cap; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1288 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1289 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1290 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1291 | void GLRenderer::slot_toolTipTimer () { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1292 | // We come here if the cursor has stayed in one place for longer than a |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1293 | // a second. Check if we're holding it over a camera icon - if so, draw |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1294 | // a tooltip. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1295 | for (CameraIcon& icon : g_CameraIcons) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1296 | if (icon.destRect.contains (m_pos)) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1297 | m_toolTipCamera = icon.cam; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1298 | m_drawToolTip = true; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1299 | update (); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1300 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1301 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1302 | } |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1303 | } |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1304 | |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1305 | // ============================================================================= |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1306 | void GLRenderer::deleteLists (LDObject* obj) { |
216
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1307 | // Delete the lists but only if they have been initialized |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1308 | if (!obj->m_glinit) |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1309 | return; |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1310 | |
194
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1311 | for (const GL::ListType listType : g_glListTypes) |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1312 | glDeleteLists (obj->glLists[listType], 1); |
216
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1313 | |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1314 | obj->m_glinit = false; |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1315 | } |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1316 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1317 | // ============================================================================= |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1318 | Axis GLRenderer::cameraAxis (bool y) { |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1319 | const staticCameraMeta* cam = &g_staticCameras[m_camera]; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1320 | return (y) ? cam->axisY : cam->axisX; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1321 | } |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1322 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1323 | // ============================================================================= |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1324 | void GLRenderer::setupOverlay () { |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1325 | if (camera () == Free) |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1326 | return; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1327 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1328 | OverlayDialog dlg; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1329 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1330 | if (!dlg.exec ()) |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1331 | return; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1332 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1333 | QImage* img = new QImage (dlg.fpath ().chars ()); |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1334 | overlayMeta& info = getOverlay (camera ()); |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1335 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1336 | if (img->isNull ()) { |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1337 | critical ("Failed to load overlay image!"); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1338 | delete img; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1339 | return; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1340 | } |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1341 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1342 | delete info.img; // delete the old image |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1343 | |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1344 | info.fname = dlg.fpath (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1345 | info.lw = dlg.lwidth (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1346 | info.lh = dlg.lheight (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1347 | info.ox = dlg.ofsx (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1348 | info.oy = dlg.ofsy (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1349 | info.img = img; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1350 | |
196
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1351 | if (info.lw == 0) |
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1352 | info.lw = (info.lh * img->width ()) / img->height (); |
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1353 | else if (info.lh == 0) |
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1354 | info.lh = (info.lw * img->height ()) / img->width (); |
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1355 | |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1356 | const Axis x2d = cameraAxis (false), |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1357 | y2d = cameraAxis (true); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1358 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1359 | double negXFac = g_staticCameras[m_camera].negX ? -1 : 1, |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1360 | negYFac = g_staticCameras[m_camera].negY ? -1 : 1; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1361 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1362 | info.v0 = info.v1 = g_origin; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1363 | info.v0[x2d] = -(info.ox * info.lw * negXFac) / img->width (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1364 | info.v0[y2d] = (info.oy * info.lh * negYFac) / img->height (); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1365 | info.v1[x2d] = info.v0[x2d] + info.lw; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1366 | info.v1[y2d] = info.v0[y2d] + info.lh; |
197
82a868e9e929
Allow changing of existing overlay values
Santeri Piippo <crimsondusk64@gmail.com>
parents:
196
diff
changeset
|
1367 | info.fname = dlg.fpath (); |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1368 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1369 | // Set alpha of all pixels to 0.5 |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1370 | for (long i = 0; i < img->width (); ++i) |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1371 | for (long j = 0; j < img->height (); ++j) { |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1372 | uint32 pixel = img->pixel (i, j); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1373 | img->setPixel (i, j, 0x80000000 | (pixel & 0x00FFFFFF)); |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1374 | } |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1375 | } |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1376 | |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1377 | void GLRenderer::clearOverlay () { |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1378 | if (camera () == Free) |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1379 | return; |
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1380 | |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1381 | overlayMeta& info = m_overlays[camera ()]; |
195
7a776f6b0d2a
Added image overlays, these are offset and scaled photos drawn on top of the part model to help getting part data from pictures.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
194
diff
changeset
|
1382 | delete info.img; |
196
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1383 | info.img = null; |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1384 | } |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1385 | |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1386 | void GLRenderer::setDepthValue (double depth) { |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1387 | assert (camera () < Free); |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1388 | m_depthValues[camera ()] = depth; |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1389 | } |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1390 | |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1391 | double GLRenderer::depthValue () const { |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1392 | assert (camera () < Free); |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1393 | return m_depthValues[camera ()]; |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1394 | } |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1395 | |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1396 | const char* GLRenderer::cameraName () const { |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1397 | return g_CameraNames[camera ()]; |
251
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1398 | } |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1399 | |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1400 | overlayMeta& GLRenderer::getOverlay (int newcam) { |
c4b96bc41298
Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
250
diff
changeset
|
1401 | return m_overlays[newcam]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1402 | } |