Fri, 09 Aug 2013 04:29:37 +0300
Picking now works with the VAO setup
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> |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
24 | #include <QToolTip> |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
25 | #include <QTimer> |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include <GL/glu.h> |
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 "colors.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "gui.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "misc.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | #include "history.h" |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
35 | #include "dialogs.h" |
285
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
36 | #include "addObjectDialog.h" |
351 | 37 | #include "messagelog.h" |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
38 | #include "gldata.h" |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
39 | #include "build/moc_gldraw.cpp" |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | static const struct staticCameraMeta { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | const char glrotate[3]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | const Axis axisX, axisY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | const bool negX, negY; |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
45 | } g_staticCameras[6] = { |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
46 | {{ 1, 0, 0 }, X, Z, false, false }, |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
47 | {{ 0, 0, 0 }, X, Y, false, true }, |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
48 | {{ 0, 1, 0 }, Z, Y, true, true }, |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
49 | {{ -1, 0, 0 }, X, Z, false, true }, |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
50 | {{ 0, 0, 0 }, X, Y, true, true }, |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
51 | {{ 0, -1, 0 }, Z, Y, false, true }, |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | 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
|
60 | cfg (bool, gl_axes, false); |
193
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
61 | 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
|
62 | |
321
48e429bfd58c
Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
63 | // argh |
48e429bfd58c
Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
64 | const char* g_CameraNames[7] = { |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
65 | QT_TRANSLATE_NOOP ("GLRenderer", "Top"), |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
66 | QT_TRANSLATE_NOOP ("GLRenderer", "Front"), |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
67 | QT_TRANSLATE_NOOP ("GLRenderer", "Left"), |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
68 | QT_TRANSLATE_NOOP ("GLRenderer", "Bottom"), |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
69 | QT_TRANSLATE_NOOP ("GLRenderer", "Back"), |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
70 | QT_TRANSLATE_NOOP ("GLRenderer", "Right"), |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
71 | QT_TRANSLATE_NOOP ("GLRenderer", "Free") |
321
48e429bfd58c
Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
72 | }; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
74 | const GL::Camera g_Cameras[7] = { |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
75 | GL::Top, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
76 | GL::Front, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
77 | GL::Left, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
78 | GL::Bottom, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
79 | GL::Back, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
80 | GL::Right, |
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
81 | GL::Free |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | }; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | const struct GLAxis { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | const QColor col; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | const vertex vert; |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
87 | } g_GLAxes[3] = { |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
88 | { QColor (255, 0, 0), vertex (10000, 0, 0) }, |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
89 | { QColor (80, 192, 0), vertex (0, 10000, 0) }, |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
90 | { QColor (0, 160, 192), vertex (0, 0, 10000) }, |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | }; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
92 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
93 | #warning this should be a member |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
94 | static VertexCompiler g_vertexCompiler; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
95 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | // ============================================================================= |
412 | 99 | GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) { |
100 | m_picking = m_rangepick = false; | |
101 | m_camera = (GL::Camera) gl_camera.value; | |
102 | m_drawToolTip = false; | |
103 | m_editMode = Select; | |
104 | m_rectdraw = false; | |
105 | m_panning = false; | |
106 | setFile (null); | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
107 | setDrawOnly (false); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
108 | resetAngles(); |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
109 | setMessageLog (null); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | |
412 | 111 | m_toolTipTimer = new QTimer (this); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | m_toolTipTimer->setSingleShot (true); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
113 | connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | |
412 | 115 | m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
116 | m_thinBorderPen = m_thickBorderPen; | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | m_thinBorderPen.setWidth (1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | // Init camera icons |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
120 | for (const GL::Camera cam : g_Cameras) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
121 | str iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
123 | CameraIcon* info = &m_cameraIcons[cam]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | 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
|
125 | info->cam = cam; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | } |
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
|
132 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
133 | calcCameraIcons(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
137 | GLRenderer::~GLRenderer() { |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
138 | 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
|
139 | delete m_overlays[i].img; |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
140 | |
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
141 | for (CameraIcon& info : m_cameraIcons) |
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
142 | delete info.img; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | } |
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 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
148 | void GLRenderer::calcCameraIcons() { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | ushort i = 0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
151 | for (CameraIcon& info : m_cameraIcons) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | 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
|
153 | 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
|
154 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | 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
|
156 | info.destRect = QRect (x1, y1, 16, 16); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
157 | info.selRect = QRect (info.destRect.x(), info.destRect.y(), |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
158 | info.destRect.width() + 1, info.destRect.height() + 1); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | ++i; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
163 | void GLRenderer::initGLData() { |
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
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | |
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 | 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
|
170 | 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
|
171 | 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
|
172 | |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
173 | 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
|
174 | 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
|
175 | } |
43d722c255d3
Added support for overpaint-less mode since I'm having serious trouble with that
Santeri Piippo <crimsondusk64@gmail.com>
parents:
223
diff
changeset
|
176 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
178 | void GLRenderer::resetAngles() { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | m_rotX = 30.0f; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | m_rotY = 325.f; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | m_panX = m_panY = m_rotZ = 0.0f; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
182 | zoomToFit(); |
183
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 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
188 | void GLRenderer::initializeGL() { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
189 | setBackground(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | glLineWidth (gl_linethickness); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | setAutoFillBackground (false); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | setMouseTracking (true); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | setFocusPolicy (Qt::WheelFocus); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
196 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
197 | g_vertexCompiler.compileFile(); |
183
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 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
203 | QColor GLRenderer::getMainColor() { |
286
7a562bf3d829
Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
285
diff
changeset
|
204 | QColor col (gl_maincolor); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
206 | if (!col.isValid()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | 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
|
208 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | 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
|
210 | return col; |
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | // ----------------------------------------------------------------------------- |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
214 | void GLRenderer::setBackground() { |
286
7a562bf3d829
Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
285
diff
changeset
|
215 | QColor col (gl_bgcolor); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
217 | if (!col.isValid()) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | return; |
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 | col.setAlpha (255); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
222 | m_darkbg = luma (col) < 80; |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
223 | m_bgcolor = col; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | qglClearColor (col); |
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 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
230 | void GLRenderer::refresh() { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
231 | update(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
232 | swapBuffers(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
236 | void GLRenderer::hardRefresh() { |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
237 | g_vertexCompiler.compileFile(); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
238 | refresh(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | glLineWidth (gl_linethickness); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | 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
|
247 | m_width = w; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | m_height = h; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
250 | calcCameraIcons(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | 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
|
253 | glMatrixMode (GL_PROJECTION); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
254 | glLoadIdentity(); |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
255 | 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
|
256 | glMatrixMode (GL_MODELVIEW); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
259 | void GLRenderer::drawGLScene() { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
260 | if (file() == null) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
263 | if (gl_wireframe && !picking()) |
193
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
264 | glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
265 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | 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
|
267 | glEnable (GL_DEPTH_TEST); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | 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
|
270 | glMatrixMode (GL_PROJECTION); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
271 | glPushMatrix(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
273 | glLoadIdentity(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | 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
|
275 | glTranslatef (m_panX, m_panY, 0.0f); |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
276 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | 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
|
278 | 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
|
279 | 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
|
280 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | // 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
|
282 | 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
|
283 | 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
|
284 | 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
|
285 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | } else { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | glMatrixMode (GL_MODELVIEW); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
288 | glPushMatrix(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
289 | glLoadIdentity(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | glTranslatef (0.0f, 0.0f, -2.0f); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
292 | 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
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
298 | // Draw the polygons |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
299 | glEnableClientState (GL_VERTEX_ARRAY); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
300 | glEnableClientState (GL_COLOR_ARRAY); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
301 | glDisableClientState (GL_NORMAL_ARRAY); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
302 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
303 | if (gl_colorbfc) { |
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 | glEnable (GL_CULL_FACE); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
305 | glCullFace (GL_CCW); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
306 | } 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
|
307 | glDisable (GL_CULL_FACE); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
309 | VertexCompiler::Array* array = g_vertexCompiler.getMergedBuffer ( |
442
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
310 | (m_picking) ? VertexCompiler::PickArray : |
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
311 | (gl_colorbfc) ? VertexCompiler::BFCArray : |
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
312 | VertexCompiler::MainArray); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
313 | glVertexPointer (3, GL_FLOAT, sizeof (VertexCompiler::Vertex), &array->data()[0].x); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
314 | glColorPointer (4, GL_UNSIGNED_BYTE, sizeof (VertexCompiler::Vertex), &array->data()[0].color); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
315 | glDrawArrays (GL_TRIANGLES, 0, array->writtenSize() / sizeof (VertexCompiler::Vertex)); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
316 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
317 | // Draw edge lines |
442
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
318 | array = g_vertexCompiler.getMergedBuffer ( |
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
319 | (m_picking) ? VertexCompiler::EdgePickArray : |
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
320 | VertexCompiler::EdgeArray); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
321 | glVertexPointer (3, GL_FLOAT, sizeof (VertexCompiler::Vertex), &array->data()[0].x); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
322 | glColorPointer (4, GL_UNSIGNED_BYTE, sizeof (VertexCompiler::Vertex), &array->data()[0].color); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
323 | glDrawArrays (GL_LINES, 0, array->writtenSize() / sizeof (VertexCompiler::Vertex)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
325 | glPopMatrix(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | glMatrixMode (GL_MODELVIEW); |
193
ce8e25ccbaf6
Added wireframe mode
Santeri Piippo <crimsondusk64@gmail.com>
parents:
192
diff
changeset
|
327 | 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
|
328 | } |
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 | // ============================================================================= |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
331 | // This converts a 2D point on the screen to a 3D point in the model. If 'snap' |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
332 | // is true, the 3D point will snap to the current grid. |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
333 | // ============================================================================= |
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
|
334 | vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
335 | assert (camera() != Free); |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
336 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | vertex pos3d; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | 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
|
339 | 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
|
340 | 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
|
341 | 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
|
342 | 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
|
343 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | // Calculate cx and cy - these are the LDraw unit coords the cursor is at. |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
345 | double cx = (-m_virtWidth + ((2 * pos2d.x() * m_virtWidth) / m_width) - m_panX); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
346 | 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
|
347 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | if (snap) { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | 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
|
350 | 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
|
351 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | cx *= negXFac; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | cy *= negYFac; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | |
286
7a562bf3d829
Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
285
diff
changeset
|
356 | str tmp; |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
357 | // Create the vertex from the coordinates |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
358 | pos3d[axisX] = tmp.sprintf ("%.3f", cx).toDouble(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
359 | pos3d[axisY] = tmp.sprintf ("%.3f", cy).toDouble(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
360 | 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
|
361 | return pos3d; |
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | // ============================================================================= |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
365 | // Inverse operation for the above - convert a 3D position to a 2D screen |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
366 | // position |
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
367 | // ============================================================================= |
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
|
368 | 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
|
369 | GLfloat m[16]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | 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
|
374 | 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
|
375 | |
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
|
376 | 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
|
377 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
378 | const double x = pos3d.x(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
379 | const double y = pos3d.y(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
380 | 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
|
381 | |
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
|
382 | 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
|
383 | 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
|
384 | 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
|
385 | 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
|
386 | |
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
|
387 | 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
|
388 | 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
|
389 | |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
390 | 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
|
391 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | 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
|
397 | Q_UNUSED (ev) |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
398 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
399 | makeCurrent(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
400 | m_virtWidth = zoom(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | 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
|
402 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
403 | initGLData(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
404 | 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
|
405 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | QPainter paint (this); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
407 | 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
|
408 | 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
|
409 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
410 | // If we wish to only draw the brick, stop here |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
411 | if (drawOnly()) |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
412 | return; |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
413 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
414 | if (m_camera != Free && !picking()) { |
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
|
415 | // 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
|
416 | 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
|
417 | 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
|
418 | 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
|
419 | 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
|
420 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
421 | QRect targRect (v0.x(), v0.y(), abs (v1.x() - v0.x()), abs (v1.y() - v0.y())), |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
422 | srcRect (0, 0, overlay.img->width(), overlay.img->height()); |
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
|
423 | 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
|
424 | } |
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
|
425 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | // Paint the coordinates onto the screen. |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
427 | str text = fmt (tr ("X: %1, Y: %2, Z: %3"), m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z]); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
429 | QFontMetrics metrics = QFontMetrics (font()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | 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
|
431 | |
260
a3bab31c7e27
Fixed: Coordinates weren't drawn properly on a bright background (was always drawn in bright colors..). Note that previous commits were left dangling in their own head, the string class changes broke too many things.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
255
diff
changeset
|
432 | paint.setPen (m_darkbg ? Qt::white : Qt::black); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
433 | paint.drawText (m_width - textSize.width(), m_height - 16, textSize.width(), |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
434 | textSize.height(), Qt::AlignCenter, text); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | |
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
|
436 | // If we're drawing, draw the vertices onto the screen. |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
437 | if (editMode() == Draw) { |
282
c890f42c8054
Minor tweak to drawing rectangle selection (don't draw it if it was to be an additive pick)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
281
diff
changeset
|
438 | const short blipsize = 8; |
c890f42c8054
Minor tweak to drawing rectangle selection (don't draw it if it was to be an additive pick)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
281
diff
changeset
|
439 | int numverts = 4; |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
440 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
441 | if (!m_rectdraw) |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
442 | numverts = 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
|
443 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | if (numverts > 0) { |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
445 | QPoint poly[4]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
446 | vertex polyverts[4]; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
448 | if (!m_rectdraw) { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
449 | uchar i = 0; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
450 | 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
|
451 | poly[i] = coordconv3_2 (vert); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
452 | polyverts[i] = vert; |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
453 | ++i; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
454 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
455 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
456 | // Draw the cursor vertex as the last one in the list. |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
457 | if (numverts <= 4) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
458 | poly[i] = coordconv3_2 (m_hoverpos); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
459 | polyverts[i] = m_hoverpos; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
460 | } else { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
461 | numverts = 4; |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
462 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
463 | } else { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
464 | if (m_drawedVerts.size() > 0) { |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
465 | // Get vertex information from m_rectverts |
282
c890f42c8054
Minor tweak to drawing rectangle selection (don't draw it if it was to be an additive pick)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
281
diff
changeset
|
466 | for (int i = 0; i < numverts; ++i) { |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
467 | polyverts[i] = m_rectverts[i]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
468 | poly[i] = coordconv3_2 (polyverts[i]); |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
469 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
470 | } else { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
471 | poly[0] = coordconv3_2 (m_hoverpos); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
472 | polyverts[0] = m_hoverpos; |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
473 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
474 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
476 | // Draw the polygon-to-be |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
477 | QPen pen = m_thinBorderPen; |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
478 | pen.setWidth (2); |
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
479 | 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
|
480 | paint.setPen (pen); |
296
d544de09c93b
Use a more greenish green rather than yellowish lime, added some constraints to when double-clicking in the viewport should edit the given object to prevent unwanted popups
Santeri Piippo <crimsondusk64@gmail.com>
parents:
291
diff
changeset
|
481 | paint.setBrush (QColor (64, 192, 0, 128)); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | paint.drawPolygon (poly, numverts); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
483 | |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
484 | // Draw vertex blips |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
485 | pen = m_thinBorderPen; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
486 | pen.setWidth (1); |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
487 | paint.setPen (pen); |
296
d544de09c93b
Use a more greenish green rather than yellowish lime, added some constraints to when double-clicking in the viewport should edit the given object to prevent unwanted popups
Santeri Piippo <crimsondusk64@gmail.com>
parents:
291
diff
changeset
|
488 | paint.setBrush (QColor (64, 192, 0)); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
489 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
490 | for (ushort i = 0; i < numverts; ++i) { |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
491 | QPoint& blip = poly[i]; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
492 | paint.drawEllipse (blip.x() - blipsize / 2, blip.y() - blipsize / 2, |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
493 | blipsize, blipsize); |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
494 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
495 | // Draw their coordinates |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
496 | paint.drawText (blip.x(), blip.y() - 8, polyverts[i].stringRep (true)); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
497 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
502 | // Camera icons |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
503 | if (!m_picking) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | // 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
|
505 | paint.setPen (m_thinBorderPen); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | paint.setBrush (QBrush (QColor (0, 128, 160, 128))); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
507 | paint.drawRect (m_cameraIcons[camera()].selRect); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | // Draw the actual icons |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
510 | for (CameraIcon& info : m_cameraIcons) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
511 | // Don't draw the free camera icon when in draw mode |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
512 | if (&info == &m_cameraIcons[GL::Free] && editMode() != Select) |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
513 | continue; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
514 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
515 | 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
|
516 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
517 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
518 | str fmtstr = tr ("%1 Camera"); |
321
48e429bfd58c
Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents:
319
diff
changeset
|
519 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
520 | // 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
|
521 | { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
522 | const ushort margin = 4; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
524 | str label; |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
525 | label = fmt (fmtstr, tr (g_CameraNames[camera()])); |
210
58a3cbb49374
Better support for dark backgrounds..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
209
diff
changeset
|
526 | paint.setPen (m_darkbg ? Qt::white : Qt::black); |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
527 | paint.drawText (QPoint (margin, height() - (margin + metrics.descent())), label); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
528 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
529 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
530 | // Tool tips |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
531 | if (m_drawToolTip) { |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
532 | if (m_cameraIcons[m_toolTipCamera].destRect.contains (m_pos) == false) |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
533 | m_drawToolTip = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | else { |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
535 | str label = fmt (fmtstr, tr (g_CameraNames[m_toolTipCamera])); |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
536 | QToolTip::showText (m_globalpos, label); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | |
322
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
541 | // Message log |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
542 | if (msglog()) { |
322
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
543 | int y = 0; |
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
544 | const int margin = 2; |
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
545 | QColor col = Qt::black; |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
546 | paint.setPen (QPen()); |
322
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
547 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
548 | for (const MessageManager::Line& line : *msglog()) { |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
549 | col.setAlphaF (line.alpha); |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
550 | paint.setPen (QPen (col)); |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
551 | paint.drawText (QPoint (margin, y + margin + metrics.ascent()), line.text); |
322
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
552 | y += metrics.height(); |
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
553 | } |
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
554 | } |
5e701c3c3d8e
Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
321
diff
changeset
|
555 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
556 | // If we're range-picking, draw a rectangle encompassing the selection area. |
282
c890f42c8054
Minor tweak to drawing rectangle selection (don't draw it if it was to be an additive pick)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
281
diff
changeset
|
557 | if (m_rangepick && !m_picking && m_totalmove >= 10) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
558 | const short x0 = m_rangeStart.x(), |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
559 | y0 = m_rangeStart.y(), |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
560 | x1 = m_pos.x(), |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
561 | y1 = m_pos.y(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
563 | QRect rect (x0, y0, x1 - x0, y1 - y0); |
296
d544de09c93b
Use a more greenish green rather than yellowish lime, added some constraints to when double-clicking in the viewport should edit the given object to prevent unwanted popups
Santeri Piippo <crimsondusk64@gmail.com>
parents:
291
diff
changeset
|
564 | QColor fillColor = (m_addpick ? "#40FF00" : "#00CCFF"); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | fillColor.setAlphaF (0.2f); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
567 | paint.setPen (m_thickBorderPen); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | paint.setBrush (QBrush (fillColor)); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | paint.drawRect (rect); |
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 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
574 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
576 | void GLRenderer::compileAllObjects() { |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
577 | g_vertexCompiler.compileFile(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
578 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
579 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
581 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | // ============================================================================= |
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
|
583 | 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
|
584 | while (angle < 0) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | angle += 360.0; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
586 | while (angle > 360.0) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | angle -= 360.0; |
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 | |
262
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
590 | void GLRenderer::addDrawnVertex (vertex pos) { |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
591 | // If we picked an already-existing vertex, stop drawing |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
592 | for (vertex& vert : m_drawedVerts) { |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
593 | if (vert == pos) { |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
594 | endDraw (true); |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
595 | return; |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
596 | } |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
597 | } |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
598 | |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
599 | m_drawedVerts << pos; |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
600 | } |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
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 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
603 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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 | void GLRenderer::mouseReleaseEvent (QMouseEvent* ev) { |
419
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
606 | const bool wasLeft = (m_lastButtons & Qt::LeftButton) && !(ev->buttons() & Qt::LeftButton), |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
607 | wasRight = (m_lastButtons & Qt::RightButton) && !(ev->buttons() & Qt::RightButton), |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
608 | wasMid = (m_lastButtons & Qt::MidButton) && !(ev->buttons() & Qt::MidButton); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
609 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
610 | if (m_panning) |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
611 | m_panning = false; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
612 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
613 | if (wasLeft) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
614 | // 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
|
615 | if (!m_rangepick) { |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
616 | for (CameraIcon& info : m_cameraIcons) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
617 | if (info.destRect.contains (ev->pos())) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
618 | setCamera (info.cam); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
619 | goto end; |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
620 | } |
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
|
621 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
622 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
623 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
624 | switch (editMode()) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
625 | case Draw: |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
626 | if (m_rectdraw) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
627 | 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
|
628 | endDraw (true); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | return; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | } |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
631 | } else { |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
632 | // If we have 4 verts, stop drawing. |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
633 | if (m_drawedVerts.size() >= 4) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
634 | endDraw (true); |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
635 | return; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
636 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
637 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
638 | if (m_drawedVerts.size() == 0 && ev->modifiers() & Qt::ShiftModifier) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
639 | m_rectdraw = true; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
640 | updateRectVerts(); |
281
7904abfbdcef
Update the rect vertices right after rect draw mode is entered so that the old values don't remain to spook around
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
641 | } |
183
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 | |
262
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
644 | addDrawnVertex (m_hoverpos); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
645 | break; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
646 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
647 | case Select: |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
648 | if (!drawOnly()) { |
270
f5f2353af0d9
fixed: subfiles and radials couldn't be moved, made add-picking with control work again despite its double-use as range picking, changed 'Name' to 'Title' in new part dialog and widened it a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
268
diff
changeset
|
649 | if (m_totalmove < 10) |
f5f2353af0d9
fixed: subfiles and radials couldn't be moved, made add-picking with control work again despite its double-use as range picking, changed 'Name' to 'Title' in new part dialog and widened it a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
268
diff
changeset
|
650 | m_rangepick = false; |
f5f2353af0d9
fixed: subfiles and radials couldn't be moved, made add-picking with control work again despite its double-use as range picking, changed 'Name' to 'Title' in new part dialog and widened it a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
268
diff
changeset
|
651 | |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
652 | if (!m_rangepick) |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
653 | m_addpick = (m_keymods & Qt::ControlModifier); |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
654 | |
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
655 | if (m_totalmove < 10 || m_rangepick) |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
656 | pick (ev->x(), ev->y()); |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
657 | } |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
658 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
659 | break; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
660 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
661 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
662 | m_rangepick = false; |
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 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
665 | if (wasMid && editMode() == Draw && m_drawedVerts.size() < 4 && m_totalmove < 10) { |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
666 | // Find the closest vertex to our cursor |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
667 | double mindist = 1024.0f; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
668 | vertex closest; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
669 | bool valid = false; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
670 | |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
671 | QPoint curspos = coordconv3_2 (m_hoverpos); |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
672 | |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
673 | for (const vertex& pos3d: m_knownVerts) { |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
674 | QPoint pos2d = coordconv3_2 (pos3d); |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
675 | |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
676 | // Measure squared distance |
419
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
677 | const double dx = abs (pos2d.x() - curspos.x()), |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
678 | dy = abs (pos2d.y() - curspos.y()), |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
679 | distsq = (dx * dx) + (dy * dy); |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
680 | |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
681 | if (distsq >= 1024.0f) // 32.0f ** 2 |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
682 | continue; // too far away |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
683 | |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
684 | if (distsq < mindist) { |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
685 | mindist = distsq; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
686 | closest = pos3d; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
687 | valid = true; |
419
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
688 | |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
689 | /* If it's only 4 pixels away, I think we found our vertex now. */ |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
690 | if (distsq <= 16.0f) // 4.0f ** 2 |
d21b0a61d3b7
If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
418
diff
changeset
|
691 | break; |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
692 | } |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
693 | } |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
694 | |
262
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
695 | if (valid) |
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
696 | addDrawnVertex (closest); |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
697 | } |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
698 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
699 | if (wasRight && m_drawedVerts.size() > 0) { |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
700 | // Remove the last vertex |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
701 | 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
|
702 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
703 | if (m_drawedVerts.size() == 0) |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
704 | m_rectdraw = false; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
705 | } |
262
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
706 | |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
707 | end: |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
708 | update(); |
262
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
709 | m_totalmove = 0; |
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 | |
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 | void GLRenderer::mousePressEvent (QMouseEvent* ev) { |
262
56f8987f4c7c
Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents:
261
diff
changeset
|
716 | m_totalmove = 0; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
717 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
718 | if (ev->modifiers() & Qt::ControlModifier) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | m_rangepick = true; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
720 | m_rangeStart.setX (ev->x()); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
721 | m_rangeStart.setY (ev->y()); |
264
4299b818a816
Made range selection be done with Ctrl+Left rather than Shift+Left, additive is Ctrl+Alt+Left. Shift+Left is now an aliasing for panning alongside Mid.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
263
diff
changeset
|
722 | m_addpick = (m_keymods & Qt::AltModifier); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
723 | ev->accept(); |
183
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 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
726 | m_lastButtons = ev->buttons(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
727 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
728 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
729 | // ============================================================================= |
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 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
732 | void GLRenderer::mouseMoveEvent (QMouseEvent* ev) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
733 | int dx = ev->x() - m_pos.x(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
734 | int dy = ev->y() - m_pos.y(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
735 | 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
|
736 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
737 | const bool left = ev->buttons() & Qt::LeftButton, |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
738 | mid = ev->buttons() & Qt::MidButton, |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
739 | shift = ev->modifiers() & Qt::ShiftModifier; |
264
4299b818a816
Made range selection be done with Ctrl+Left rather than Shift+Left, additive is Ctrl+Alt+Left. Shift+Left is now an aliasing for panning alongside Mid.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
263
diff
changeset
|
740 | |
4299b818a816
Made range selection be done with Ctrl+Left rather than Shift+Left, additive is Ctrl+Alt+Left. Shift+Left is now an aliasing for panning alongside Mid.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
263
diff
changeset
|
741 | if (mid || (left && shift)) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
742 | m_panX += 0.03f * dx * (zoom() / 7.5f); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
743 | m_panY -= 0.03f * dy * (zoom() / 7.5f); |
264
4299b818a816
Made range selection be done with Ctrl+Left rather than Shift+Left, additive is Ctrl+Alt+Left. Shift+Left is now an aliasing for panning alongside Mid.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
263
diff
changeset
|
744 | m_panning = true; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
745 | } elif (left && !m_rangepick && camera() == Free) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
746 | 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
|
747 | 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
|
748 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
749 | clampAngle (m_rotX); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
750 | clampAngle (m_rotY); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
751 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
752 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
753 | // 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
|
754 | if (!m_drawToolTip) |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
755 | m_toolTipTimer->start (500); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
756 | |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
757 | // Update 2d position |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
758 | m_pos = ev->pos(); |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
759 | m_globalpos = ev->globalPos(); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
760 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
761 | // Calculate 3d position of the cursor |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
762 | m_hoverpos = (camera() != Free) ? coordconv2_3 (m_pos, true) : g_origin; |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
763 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
764 | // Update rect vertices since m_hoverpos may have changed |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
765 | updateRectVerts(); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
766 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
767 | update(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
768 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
769 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
770 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
771 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
772 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
773 | void GLRenderer::keyPressEvent (QKeyEvent* ev) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
774 | m_keymods = ev->modifiers(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
775 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
776 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
777 | void GLRenderer::keyReleaseEvent (QKeyEvent* ev) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
778 | m_keymods = ev->modifiers(); |
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 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
781 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
782 | void GLRenderer::wheelEvent (QWheelEvent* ev) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
783 | makeCurrent(); |
253
0737c217a54d
Added ability to have multiple GLRenderers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
252
diff
changeset
|
784 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
785 | zoomNotch (ev->delta() > 0); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
786 | 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
|
787 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
788 | update(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
789 | ev->accept(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
790 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
791 | |
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 | void GLRenderer::leaveEvent (QEvent* ev) { |
440
ce2009d50c61
camera icons now draw real tooltips instead of faking them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
794 | (void) ev; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
795 | m_drawToolTip = false; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
796 | m_toolTipTimer->stop(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
797 | update(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
798 | } |
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 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
801 | void GLRenderer::contextMenuEvent (QContextMenuEvent* ev) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
802 | g_win->spawnContextMenu (ev->globalPos()); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
803 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
804 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
805 | // ============================================================================= |
198
f246725199dc
Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
197
diff
changeset
|
806 | 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
|
807 | m_camera = cam; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
808 | gl_camera = (int) cam; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
809 | g_win->updateEditModeActions(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
810 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
811 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
812 | // ============================================================================= |
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 | 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
|
816 | GLint viewport[4]; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
817 | makeCurrent(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
818 | |
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
|
819 | // 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
|
820 | 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
|
821 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
822 | // 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
|
823 | if (!m_addpick) { |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
401
diff
changeset
|
824 | List<LDObject*> oldsel = g_win->sel(); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
825 | g_win->sel().clear(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
826 | |
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
|
827 | 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
|
828 | 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
|
829 | 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
|
830 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
831 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
832 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
833 | m_picking = true; |
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 | // Paint the picking scene |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
836 | glDisable (GL_DITHER); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
837 | 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
|
838 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
839 | drawGLScene(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
840 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
841 | glGetIntegerv (GL_VIEWPORT, viewport); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
842 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
843 | short x0 = mouseX, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
844 | y0 = mouseY; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
845 | short x1, y1; |
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 | // 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
|
848 | // 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
|
849 | if (m_rangepick) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
850 | x1 = m_rangeStart.x(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
851 | y1 = m_rangeStart.y(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
852 | } else { |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
853 | x1 = x0 + 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
854 | y1 = y0 + 1; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
855 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
856 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
857 | // 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
|
858 | if (x0 > x1) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
859 | dataswap (x0, x1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
860 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
861 | if (y0 > y1) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
862 | dataswap (y0, y1); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
863 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
864 | // 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
|
865 | 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
|
866 | 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
|
867 | 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
|
868 | 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
|
869 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
870 | 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
|
871 | 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
|
872 | 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
|
873 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
874 | // 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
|
875 | 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
|
876 | uchar* pixelptr = &pixeldata[0]; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
877 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
878 | 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
|
879 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
880 | // 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
|
881 | 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
|
882 | |
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
|
883 | 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
|
884 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
885 | // 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
|
886 | for (long i = 0; i < numpixels; ++i) { |
307
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
296
diff
changeset
|
887 | long idx = |
c731a22899a3
Use unique IDs instead of file indices in picking lists, this is much less prone to error
Santeri Piippo <crimsondusk64@gmail.com>
parents:
296
diff
changeset
|
888 | (*(pixelptr + 0) * 0x10000) + |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
889 | (*(pixelptr + 1) * 0x00100) + |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
890 | (*(pixelptr + 2) * 0x00001); |
442
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
891 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
892 | pixelptr += 4; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
893 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
894 | if (idx == 0xFFFFFF) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
895 | 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
|
896 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
897 | LDObject* obj = LDObject::fromID (idx); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
898 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
899 | // 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
|
900 | // 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
|
901 | 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
|
902 | bool removed = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
903 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
904 | for (ulong i = 0; i < g_win->sel().size(); ++i) { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
905 | if (g_win->sel()[i] == obj) { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
906 | 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
|
907 | obj->setSelected (false); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
908 | 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
|
909 | removedObj = obj; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
910 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
911 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
912 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
913 | if (removed) |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
914 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
915 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
916 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
917 | 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
|
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 | delete[] pixeldata; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
921 | |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
922 | // Remove duplicated entries |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
923 | g_win->sel().makeUnique(); |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
924 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
925 | // Update everything now. |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
926 | g_win->updateSelection(); |
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
|
927 | |
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
|
928 | // Recompile the objects now to update their color |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
929 | for (LDObject* obj : g_win->sel()) |
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
|
930 | compileObject (obj); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
931 | |
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
|
932 | 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
|
933 | 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
|
934 | |
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
|
935 | // 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
|
936 | 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
|
937 | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
938 | m_picking = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
939 | m_rangepick = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
940 | glEnable (GL_DITHER); |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
941 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
942 | setBackground(); |
401
89a9235b47d3
Use repaint() instead of update() when redrawing the scene after a pick so that the new scene is repainted immediately.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
392
diff
changeset
|
943 | repaint(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
944 | } |
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 | // ============================================================================= |
274
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
947 | READ_ACCESSOR (EditMode, GLRenderer::editMode) { |
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
948 | return m_editMode; |
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
949 | } |
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
950 | |
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
951 | SET_ACCESSOR (EditMode, GLRenderer::setEditMode) { |
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
952 | m_editMode = val; |
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
953 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
954 | 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
|
955 | case Select: |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
956 | unsetCursor(); |
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
|
957 | 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
|
958 | break; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
959 | |
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
|
960 | case Draw: |
392
629e3142d02d
change camera to top if switching to draw mode in free camera
Santeri Piippo <crimsondusk64@gmail.com>
parents:
384
diff
changeset
|
961 | // Cannot draw into the free camera - use top instead. |
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
|
962 | if (m_camera == Free) |
392
629e3142d02d
change camera to top if switching to draw mode in free camera
Santeri Piippo <crimsondusk64@gmail.com>
parents:
384
diff
changeset
|
963 | setCamera (Top); |
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
|
964 | |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
965 | // 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
|
966 | // 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
|
967 | 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
|
968 | |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
969 | // 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
|
970 | 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
|
971 | |
e8c47e51e03d
Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents:
200
diff
changeset
|
972 | // 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
|
973 | // 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
|
974 | // here! This code doesn't update the GL lists. |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
975 | g_win->sel().clear(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
976 | g_win->updateSelection(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
977 | m_drawedVerts.clear(); |
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
|
978 | 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
|
979 | } |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
980 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
981 | g_win->updateEditModeActions(); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
982 | update(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
983 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
984 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
985 | READ_ACCESSOR (LDFile*, GLRenderer::file) { |
318 | 986 | return m_file; |
987 | } | |
988 | ||
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
989 | SET_ACCESSOR (LDFile*, GLRenderer::setFile) { |
318 | 990 | m_file = val; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
991 | g_vertexCompiler.setFile (val); |
318 | 992 | |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
419
diff
changeset
|
993 | if (val != null) |
318 | 994 | overlaysFromObjects(); |
995 | } | |
996 | ||
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
997 | // ============================================================================= |
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
|
998 | 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
|
999 | (void) accept; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1000 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1001 | // Clean the selection and create the object |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
401
diff
changeset
|
1002 | List<vertex>& verts = m_drawedVerts; |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1003 | LDObject* obj = null; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1004 | |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1005 | if (m_rectdraw) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1006 | LDQuadObject* quad = new LDQuadObject; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1007 | |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1008 | // Copy the vertices from m_rectverts |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1009 | updateRectVerts(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
1010 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1011 | for (int i = 0; i < quad->vertices(); ++i) |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
1012 | quad->setVertex (i, m_rectverts[i]); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1013 | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
1014 | quad->setColor (maincolor); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1015 | obj = quad; |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1016 | } else { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1017 | switch (verts.size()) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1018 | case 1: |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1019 | // 1 vertex - add a vertex object |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1020 | obj = new LDVertexObject; |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1021 | static_cast<LDVertexObject*> (obj)->pos = verts[0]; |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
1022 | obj->setColor (maincolor); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1023 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1024 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1025 | case 2: |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1026 | // 2 verts - make a line |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1027 | obj = new LDLineObject (verts[0], verts[1]); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
1028 | obj->setColor (edgecolor); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1029 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1030 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1031 | case 3: |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1032 | case 4: |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1033 | obj = (verts.size() == 3) ? |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1034 | static_cast<LDObject*> (new LDTriangleObject) : |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1035 | static_cast<LDObject*> (new LDQuadObject); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1036 | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
1037 | obj->setColor (maincolor); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1038 | for (ushort i = 0; i < obj->vertices(); ++i) |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
1039 | obj->setVertex (i, verts[i]); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1040 | break; |
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 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1043 | |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1044 | if (obj) { |
384
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
382
diff
changeset
|
1045 | g_win->beginAction (null); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1046 | 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
|
1047 | compileObject (obj); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1048 | g_win->fullRefresh(); |
384
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
382
diff
changeset
|
1049 | g_win->endAction(); |
208
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1050 | } |
0bb57b81c92a
Allow rectangle drawing by pressing shift when inserting the first vertex.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
207
diff
changeset
|
1051 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1052 | 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
|
1053 | m_rectdraw = false; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1054 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1055 | |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
401
diff
changeset
|
1056 | static List<vertex> getVertices (LDObject* obj) { |
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
401
diff
changeset
|
1057 | List<vertex> verts; |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1058 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1059 | if (obj->vertices() >= 2) { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1060 | for (int i = 0; i < obj->vertices(); ++i) |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
1061 | verts << obj->getVertex (i); |
378 | 1062 | } elif (obj->getType() == LDObject::Subfile) { |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
401
diff
changeset
|
1063 | List<LDObject*> objs = static_cast<LDSubfileObject*> (obj)->inlineContents (true, true); |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1064 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1065 | for(LDObject* obj : objs) { |
261
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1066 | verts << getVertices (obj); |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1067 | delete obj; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1068 | } |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1069 | } |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1070 | |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1071 | return verts; |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1072 | } |
c4ad4e3c6839
Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
260
diff
changeset
|
1073 | |
183
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 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1076 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1077 | void GLRenderer::compileObject (LDObject* obj) { |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
1078 | g_vertexCompiler.compileObject (obj); |
216
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1079 | 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
|
1080 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1081 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1082 | // ============================================================================= |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1083 | 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
|
1084 | w = m_width; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1085 | h = m_height; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1086 | 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
|
1087 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1088 | m_screencap = true; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1089 | update(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1090 | m_screencap = false; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1091 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1092 | // Capture the pixels |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1093 | 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
|
1094 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1095 | return cap; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1096 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1097 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1098 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1099 | void GLRenderer::slot_toolTipTimer() { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1100 | // 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
|
1101 | // 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
|
1102 | // a tooltip. |
291
c8547f780861
Make camera icons a member of GLRenderer so multiple renderers won't conflict about them
Santeri Piippo <crimsondusk64@gmail.com>
parents:
286
diff
changeset
|
1103 | for (CameraIcon& icon : m_cameraIcons) { |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1104 | 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
|
1105 | m_toolTipCamera = icon.cam; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1106 | m_drawToolTip = true; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1107 | update(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1108 | break; |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1109 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1110 | } |
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
|
1111 | } |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1112 | |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1113 | // ============================================================================= |
cfe9ae5f1124
Fixed coordconv3_2 algorithm, plane drawing works on any of the fixed cameras now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
193
diff
changeset
|
1114 | 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
|
1115 | // 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
|
1116 | 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
|
1117 | return; |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1118 | |
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
|
1119 | 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
|
1120 | 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
|
1121 | |
c8882ff62d61
Hopefully fixed the problem regarding objects not getting drawn at first
Santeri Piippo <crimsondusk64@gmail.com>
parents:
212
diff
changeset
|
1122 | 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
|
1123 | } |
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
|
1124 | |
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
|
1125 | // ============================================================================= |
336
9dd47cc12ab8
fixed: overlays coudln't be defined for other cameras than the one used currently
Santeri Piippo <crimsondusk64@gmail.com>
parents:
324
diff
changeset
|
1126 | Axis GLRenderer::cameraAxis (bool y, GL::Camera camid) { |
378 | 1127 | if (camid == (GL::Camera) -1) |
336
9dd47cc12ab8
fixed: overlays coudln't be defined for other cameras than the one used currently
Santeri Piippo <crimsondusk64@gmail.com>
parents:
324
diff
changeset
|
1128 | camid = m_camera; |
9dd47cc12ab8
fixed: overlays coudln't be defined for other cameras than the one used currently
Santeri Piippo <crimsondusk64@gmail.com>
parents:
324
diff
changeset
|
1129 | |
9dd47cc12ab8
fixed: overlays coudln't be defined for other cameras than the one used currently
Santeri Piippo <crimsondusk64@gmail.com>
parents:
324
diff
changeset
|
1130 | const staticCameraMeta* cam = &g_staticCameras[camid]; |
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
|
1131 | 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
|
1132 | } |
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
|
1133 | |
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
|
1134 | // ============================================================================= |
378 | 1135 | bool GLRenderer::setupOverlay (GL::Camera cam, str file, int x, int y, int w, int h) { |
1136 | QImage* img = new QImage (file); | |
1137 | overlayMeta& info = getOverlay (cam); | |
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
|
1138 | |
378 | 1139 | if (img->isNull()) { |
1140 | critical (tr ("Failed to load overlay image!")); | |
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
|
1141 | delete img; |
317
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1142 | return 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
|
1143 | } |
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
|
1144 | |
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
|
1145 | 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
|
1146 | |
317
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1147 | info.fname = file; |
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1148 | info.lw = w; |
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1149 | info.lh = h; |
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1150 | info.ox = x; |
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1151 | info.oy = y; |
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
|
1152 | 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
|
1153 | |
378 | 1154 | if (info.lw == 0) |
1155 | info.lw = (info.lh * img->width()) / img->height(); | |
1156 | elif (info.lh == 0) | |
1157 | info.lh = (info.lw * img->height()) / img->width(); | |
196
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1158 | |
378 | 1159 | const Axis x2d = cameraAxis (false, cam), |
1160 | y2d = cameraAxis (true, cam); | |
1161 | ||
336
9dd47cc12ab8
fixed: overlays coudln't be defined for other cameras than the one used currently
Santeri Piippo <crimsondusk64@gmail.com>
parents:
324
diff
changeset
|
1162 | double negXFac = g_staticCameras[cam].negX ? -1 : 1, |
9dd47cc12ab8
fixed: overlays coudln't be defined for other cameras than the one used currently
Santeri Piippo <crimsondusk64@gmail.com>
parents:
324
diff
changeset
|
1163 | negYFac = g_staticCameras[cam].negY ? -1 : 1; |
378 | 1164 | |
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
|
1165 | info.v0 = info.v1 = g_origin; |
378 | 1166 | info.v0[x2d] = - (info.ox * info.lw * negXFac) / img->width(); |
1167 | info.v0[y2d] = (info.oy * info.lh * negYFac) / img->height(); | |
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
|
1168 | 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
|
1169 | info.v1[y2d] = info.v0[y2d] + info.lh; |
378 | 1170 | |
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
|
1171 | // Set alpha of all pixels to 0.5 |
378 | 1172 | for (long i = 0; i < img->width(); ++i) |
1173 | for (long j = 0; j < img->height(); ++j) { | |
1174 | uint32 pixel = img->pixel (i, j); | |
1175 | img->setPixel (i, j, 0x80000000 | (pixel & 0x00FFFFFF)); | |
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
|
1176 | } |
378 | 1177 | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1178 | updateOverlayObjects(); |
317
e41ab239ed28
Added ability to load the overlay meta
Santeri Piippo <crimsondusk64@gmail.com>
parents:
316
diff
changeset
|
1179 | return true; |
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
|
1180 | } |
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
|
1181 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1182 | void GLRenderer::clearOverlay() { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1183 | if (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
|
1184 | 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
|
1185 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1186 | 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
|
1187 | delete info.img; |
196
47f4f4543152
Allow one of the dimensions be filled via aspect ratio
Santeri Piippo <crimsondusk64@gmail.com>
parents:
195
diff
changeset
|
1188 | info.img = null; |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1189 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1190 | updateOverlayObjects(); |
219
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1191 | } |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1192 | |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1193 | void GLRenderer::setDepthValue (double depth) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1194 | assert (camera() < Free); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1195 | 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
|
1196 | } |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1197 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1198 | double GLRenderer::depthValue() const { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1199 | assert (camera() < Free); |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1200 | 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
|
1201 | } |
70eb948a2b02
Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
216
diff
changeset
|
1202 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1203 | const char* GLRenderer::cameraName() const { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1204 | 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
|
1205 | } |
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
|
1206 | |
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
|
1207 | 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
|
1208 | return m_overlays[newcam]; |
254
434c9844e45d
Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents:
253
diff
changeset
|
1209 | } |
434c9844e45d
Further work on image generation experiment
Santeri Piippo <crimsondusk64@gmail.com>
parents:
253
diff
changeset
|
1210 | |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1211 | void GLRenderer::zoomNotch (bool inward) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1212 | if (zoom() > 15) |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1213 | setZoom (zoom() * (inward ? 0.833f : 1.2f)); |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1214 | else |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1215 | setZoom (zoom() + (inward ? -1.2f : 1.2f)); |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1216 | } |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1217 | |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1218 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1219 | void GLRenderer::zoomToFit() { |
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1220 | if (file() == null) { |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1221 | setZoom (30.0f); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1222 | return; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1223 | } |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1224 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1225 | bool lastfilled = false; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1226 | bool firstrun = true; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1227 | const uint32 white = 0xFFFFFFFF; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1228 | bool inward = true; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1229 | ulong run = 0; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1230 | const ushort w = m_width, h = m_height; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1231 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1232 | glClearColor (1.0, 1.0, 1.0, 1.0); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1233 | glDisable (GL_DITHER); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1234 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1235 | // Use the pick list while drawing the scene, this way we can tell whether borders |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1236 | // are background or not. |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1237 | m_picking = true; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1238 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1239 | for (;;) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1240 | if (zoom() > 10000.0f || zoom() < 0.0f) { |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1241 | // Obviously, there's nothing to draw if we get here. |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1242 | // Default to 30.0f and break out. |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1243 | setZoom (30.0f); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1244 | break; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1245 | } |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1246 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1247 | zoomNotch (inward); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1248 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1249 | uchar* cap = new uchar[4 * w * h]; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1250 | drawGLScene(); |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1251 | glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1252 | uint32* imgdata = reinterpret_cast<uint32*> (cap); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1253 | bool filled = false; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1254 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1255 | // Check the top and bottom rows |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1256 | for (ushort i = 0; i < w && !filled; ++i) |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1257 | if (imgdata[i] != white || imgdata[((h - 1) * w) + i] != white) |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1258 | filled = true; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1259 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1260 | // Left and right edges |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1261 | for (ushort i = 0; i < h && !filled; ++i) |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1262 | if (imgdata[i * w] != white || imgdata[(i * w) + (w - 1)] != white) |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1263 | filled = true; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1264 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1265 | if (firstrun) { |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1266 | // If this is the first run, we don't know enough to determine |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1267 | // whether the zoom was to fit, so we mark in our knowledge so |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1268 | // far and start over. |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1269 | inward = !filled; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1270 | firstrun = false; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1271 | } else { |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1272 | // If this run filled the screen and the last one did not, the |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1273 | // last run had ideal zoom - zoom a bit back and we should reach it. |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1274 | if (filled && !lastfilled) { |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1275 | zoomNotch (false); |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1276 | break; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1277 | } |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1278 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1279 | // If this run did not fill the screen and the last one did, we've |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1280 | // now reached ideal zoom so we're done here. |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1281 | if (!filled && lastfilled) |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1282 | break; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1283 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1284 | inward = !filled; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1285 | } |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1286 | |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1287 | delete[] cap; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1288 | lastfilled = filled; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1289 | ++run; |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1290 | } |
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1291 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1292 | setBackground(); |
255
67d4aedf1041
Added method for zooming to fit, fixed zoom being inappropriate when parts are first loaded
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
1293 | m_picking = false; |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1294 | } |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1295 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1296 | // ============================================================================= |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1297 | void GLRenderer::updateRectVerts() { |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1298 | if (!m_rectdraw) |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1299 | return; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1300 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1301 | if (m_drawedVerts.size() == 0) { |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1302 | for (int i = 0; i < 4; ++i) |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1303 | m_rectverts[i] = m_hoverpos; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1304 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1305 | return; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1306 | } |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1307 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1308 | vertex v0 = m_drawedVerts[0], |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1309 | v1 = (m_drawedVerts.size() >= 2) ? m_drawedVerts[1] : m_hoverpos; |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1310 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1311 | const Axis ax = cameraAxis (false), |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1312 | ay = cameraAxis (true), |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1313 | az = (Axis) (3 - ax - ay); |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1314 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1315 | for (int i = 0; i < 4; ++i) |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1316 | m_rectverts[i][az] = depthValue(); |
263
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1317 | |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1318 | m_rectverts[0][ax] = v0[ax]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1319 | m_rectverts[0][ay] = v0[ay]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1320 | m_rectverts[1][ax] = v1[ax]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1321 | m_rectverts[1][ay] = v0[ay]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1322 | m_rectverts[2][ax] = v1[ax]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1323 | m_rectverts[2][ay] = v1[ay]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1324 | m_rectverts[3][ax] = v0[ax]; |
d7b534057d61
Make drawn vertices display a label containing coordinate informations, round down calculated coordinates
Santeri Piippo <crimsondusk64@gmail.com>
parents:
262
diff
changeset
|
1325 | m_rectverts[3][ay] = v1[ay]; |
285
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
1326 | } |
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
1327 | |
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
1328 | void GLRenderer::mouseDoubleClickEvent (QMouseEvent* ev) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1329 | if (!(ev->buttons() & Qt::LeftButton) || editMode() != Select) |
296
d544de09c93b
Use a more greenish green rather than yellowish lime, added some constraints to when double-clicking in the viewport should edit the given object to prevent unwanted popups
Santeri Piippo <crimsondusk64@gmail.com>
parents:
291
diff
changeset
|
1330 | return; |
d544de09c93b
Use a more greenish green rather than yellowish lime, added some constraints to when double-clicking in the viewport should edit the given object to prevent unwanted popups
Santeri Piippo <crimsondusk64@gmail.com>
parents:
291
diff
changeset
|
1331 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1332 | pick (ev->x(), ev->y()); |
285
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
1333 | |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1334 | if (g_win->sel().size() == 0) |
285
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
1335 | return; |
836e77323ab0
Also allow objects to be edited by double-click in the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
282
diff
changeset
|
1336 | |
384
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
382
diff
changeset
|
1337 | g_win->beginAction (null); |
361
f4c029f2a75b
fixed: double-clicking an object and editing it that way would not register to history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
351
diff
changeset
|
1338 | LDObject* obj = g_win->sel()[0]; |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1339 | AddObjectDialog::staticDialog (obj->getType(), obj); |
384
f4622b79133d
updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
382
diff
changeset
|
1340 | g_win->endAction(); |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1341 | ev->accept(); |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1342 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1343 | |
378 | 1344 | LDOverlayObject* GLRenderer::findOverlayObject (GLRenderer::Camera cam) { |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1345 | LDOverlayObject* ovlobj = null; |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1346 | |
378 | 1347 | for (LDObject * obj : *file()) { |
1348 | if (obj->getType() == LDObject::Overlay && static_cast<LDOverlayObject*> (obj)->camera() == cam) { | |
1349 | ovlobj = static_cast<LDOverlayObject*> (obj); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1350 | break; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1351 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1352 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1353 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1354 | return ovlobj; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1355 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1356 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1357 | // ============================================================================= |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1358 | // ----------------------------------------------------------------------------- |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1359 | // Read in overlays from the current file and update overlay info accordingly. |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1360 | // ============================================================================= |
382
c1642530ea35
Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
1361 | void GLRenderer::overlaysFromObjects() { |
378 | 1362 | for (Camera cam : g_Cameras) { |
1363 | if (cam == Free) | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1364 | continue; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1365 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1366 | overlayMeta& meta = m_overlays[cam]; |
378 | 1367 | LDOverlayObject* ovlobj = findOverlayObject (cam); |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1368 | |
378 | 1369 | if (!ovlobj && meta.img) { |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1370 | delete meta.img; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1371 | meta.img = null; |
378 | 1372 | } elif (ovlobj && (!meta.img || meta.fname != ovlobj->filename())) |
1373 | setupOverlay (cam, ovlobj->filename(), ovlobj->x(), ovlobj->y(), ovlobj->width(), ovlobj->height()); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1374 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1375 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1376 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1377 | // ============================================================================= |
378 | 1378 | void GLRenderer::updateOverlayObjects() { |
1379 | for (Camera cam : g_Cameras) { | |
1380 | if (cam == Free) | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1381 | continue; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1382 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1383 | overlayMeta& meta = m_overlays[cam]; |
378 | 1384 | LDOverlayObject* ovlobj = findOverlayObject (cam); |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1385 | |
378 | 1386 | if (!meta.img && ovlobj) { |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1387 | // If this is the last overlay image, we need to remove the empty space after it as well. |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1388 | LDObject* nextobj = ovlobj->next(); |
378 | 1389 | |
1390 | if (nextobj && nextobj->getType() == LDObject::Empty) { | |
1391 | m_file->forgetObject (nextobj); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1392 | delete nextobj; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1393 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1394 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1395 | // If the overlay object was there and the overlay itself is |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1396 | // not, remove the object. |
378 | 1397 | m_file->forgetObject (ovlobj); |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1398 | delete ovlobj; |
378 | 1399 | } elif (meta.img && !ovlobj) { |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1400 | // Inverse case: image is there but the overlay object is |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1401 | // not, thus create the object. |
377
271d1da66b7e
Appended 'Object' to the names of all LDObject derivatives so even though the LD prefix isn't reserved for just LDObjects anymore, these classes remain distinct
Santeri Piippo <crimsondusk64@gmail.com>
parents:
364
diff
changeset
|
1402 | ovlobj = new LDOverlayObject; |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1403 | |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1404 | // Find a suitable position to place this object. We want to place |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1405 | // this into the header, which is everything up to the first scemantic |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1406 | // object. If we find another overlay object, place this object after |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1407 | // the last one found. Otherwise, place it before the first schemantic |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1408 | // object and put an empty object after it (though don't do this if |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1409 | // there was no schemantic elements at all) |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1410 | ulong i, lastOverlay = -1u; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1411 | bool found = false; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1412 | |
378 | 1413 | for (i = 0; i < file()->numObjs(); ++i) { |
1414 | LDObject* obj = file()->obj (i); | |
1415 | ||
1416 | if (obj->isScemantic()) { | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1417 | found = true; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1418 | break; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1419 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1420 | |
378 | 1421 | if (obj->getType() == LDObject::Overlay) |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1422 | lastOverlay = i; |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1423 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1424 | |
378 | 1425 | if (lastOverlay != -1u) |
1426 | file()->insertObj (lastOverlay + 1, ovlobj); | |
1427 | else { | |
1428 | file()->insertObj (i, ovlobj); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1429 | |
378 | 1430 | if (found) |
1431 | file()->insertObj (i + 1, new LDEmptyObject); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1432 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1433 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1434 | |
378 | 1435 | if (meta.img && ovlobj) { |
1436 | ovlobj->setCamera (cam); | |
1437 | ovlobj->setFilename (meta.fname); | |
1438 | ovlobj->setX (meta.ox); | |
1439 | ovlobj->setY (meta.oy); | |
1440 | ovlobj->setWidth (meta.lw); | |
1441 | ovlobj->setHeight (meta.lh); | |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1442 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1443 | } |
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1444 | |
378 | 1445 | if (g_win->R() == this) |
316
b4fefda58f43
Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents:
312
diff
changeset
|
1446 | g_win->refresh(); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
440
diff
changeset
|
1447 | } |