Fri, 20 Dec 2013 17:06:06 +0200
- added visible line angles when drawing
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QGLWidget> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QWheelEvent> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QMouseEvent> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QContextMenuEvent> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QInputDialog> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QToolTip> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QTimer> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include <GL/glu.h> |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "main.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "config.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "document.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "gldraw.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "colors.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "gui.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | #include "misc.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | #include "history.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | #include "dialogs.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | #include "addObjectDialog.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | #include "messagelog.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | #include "primitives.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | #include "moc_gldraw.cpp" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | static const LDFixedCameraInfo g_FixedCameras[6] = |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { {{ 1, 0, 0 }, X, Z, false, false }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | {{ 0, 0, 0 }, X, Y, false, true }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | {{ 0, 1, 0 }, Z, Y, true, true }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | {{ -1, 0, 0 }, X, Z, false, true }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | {{ 0, 0, 0 }, X, Y, true, true }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | {{ 0, -1, 0 }, Z, Y, false, true }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | }; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
51 | // Matrix templates for circle drawing. 2 is substituted with |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
52 | // the scale value, 1 is inverted to -1 if needed. |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | static const matrix g_circleDrawTransforms[3] = |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { { 2, 0, 0, 0, 1, 0, 0, 0, 2 }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | { 2, 0, 0, 0, 0, 2, 0, 1, 0 }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | { 0, 1, 0, 2, 0, 0, 0, 0, 2 }, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | }; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
59 | cfg (String, gl_bgcolor, "#CCCCD9"); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
60 | cfg (String, gl_maincolor, "#707078"); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
61 | cfg (Float, gl_maincolor_alpha, 1.0); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
62 | cfg (Int, gl_linethickness, 2); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
63 | cfg (Bool, gl_colorbfc, false); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
64 | cfg (Int, gl_camera, GLRenderer::EFreeCamera); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
65 | cfg (Bool, gl_blackedges, false); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
66 | cfg (Bool, gl_axes, false); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
67 | cfg (Bool, gl_wireframe, false); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
68 | cfg (Bool, gl_logostuds, false); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
69 | cfg (Bool, gl_aa, true); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
70 | cfg (Bool, gl_linelengths, true); |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
71 | cfg (Bool, gl_drawangles, false); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // argh |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | const char* g_CameraNames[7] = |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | { QT_TRANSLATE_NOOP ("GLRenderer", "Top"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | QT_TRANSLATE_NOOP ("GLRenderer", "Front"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | QT_TRANSLATE_NOOP ("GLRenderer", "Left"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | QT_TRANSLATE_NOOP ("GLRenderer", "Bottom"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | QT_TRANSLATE_NOOP ("GLRenderer", "Back"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | QT_TRANSLATE_NOOP ("GLRenderer", "Right"), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | QT_TRANSLATE_NOOP ("GLRenderer", "Free") |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | }; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | const GL::EFixedCamera g_Cameras[7] = |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | { GL::ETopCamera, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | GL::EFrontCamera, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | GL::ELeftCamera, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | GL::EBottomCamera, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | GL::EBackCamera, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | GL::ERightCamera, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | GL::EFreeCamera |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | }; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
94 | // Definitions for visual axes, drawn on the screen |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | const struct LDGLAxis |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | { const QColor col; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | const vertex vert; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | } g_GLAxes[3] = |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
99 | { { QColor (255, 0, 0), vertex (10000, 0, 0) }, // X |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
100 | { QColor (80, 192, 0), vertex (0, 10000, 0) }, // Y |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
101 | { QColor (0, 160, 192), vertex (0, 0, 10000) }, // Z |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | }; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | static bool g_glInvert = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | static QList<int> g_warnedColors; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | { m_Picking = m_rangepick = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | m_camera = (GL::EFixedCamera) gl_camera.value; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | m_drawToolTip = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | m_EditMode = ESelectMode; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | m_rectdraw = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | m_panning = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | setFile (null); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | setDrawOnly (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | setMessageLog (null); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | m_width = m_height = -1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | m_hoverpos = g_origin; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | m_toolTipTimer = new QTimer (this); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | m_toolTipTimer->setSingleShot (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | m_thinBorderPen = m_thickBorderPen; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | m_thinBorderPen.setWidth (1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | // Init camera icons |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | for (const GL::EFixedCamera cam : g_Cameras) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | { str iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | CameraIcon* info = &m_cameraIcons[cam]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | info->img = new QPixmap (getIcon (iconname)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | info->cam = cam; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | for (int i = 0; i < 6; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | { m_overlays[i].img = null; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | m_depthValues[i] = 0.0f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | calcCameraIcons(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | GLRenderer::~GLRenderer() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | { for (int i = 0; i < 6; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | delete m_overlays[i].img; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | for (CameraIcon& info : m_cameraIcons) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | delete info.img; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | // Calculates the "hitboxes" of the camera icons so that we can tell when the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | // cursor is pointing at the camera icon. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | void GLRenderer::calcCameraIcons() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | { int i = 0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | for (CameraIcon& info : m_cameraIcons) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | { // MATH |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | const long x1 = (m_width - (info.cam != EFreeCamera ? 48 : 16)) + ((i % 3) * 16) - 1, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | y1 = ((i / 3) * 16) + 1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | info.srcRect = QRect (0, 0, 16, 16); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | info.destRect = QRect (x1, y1, 16, 16); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | info.selRect = QRect ( |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | info.destRect.x(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | info.destRect.y(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | info.destRect.width() + 1, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | info.destRect.height() + 1 |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | ); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | ++i; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | void GLRenderer::initGLData() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | { glEnable (GL_BLEND); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | glEnable (GL_POLYGON_OFFSET_FILL); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | glPolygonOffset (1.0f, 1.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | glEnable (GL_DEPTH_TEST); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | glShadeModel (GL_SMOOTH); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | glEnable (GL_MULTISAMPLE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | if (gl_aa) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | { glEnable (GL_LINE_SMOOTH); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | glEnable (GL_POLYGON_SMOOTH); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | } else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | { glDisable (GL_LINE_SMOOTH); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | glDisable (GL_POLYGON_SMOOTH); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | void GLRenderer::resetAngles() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | { rot (X) = 30.0f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | rot (Y) = 325.f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | pan (X) = pan (Y) = rot (Z) = 0.0f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | zoomToFit(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | void GLRenderer::resetAllAngles() |
564
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
217 | { /* |
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
218 | EFixedCamera oldcam = camera(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | for (int i = 0; i < 7; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | { setCamera ((EFixedCamera) i); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | resetAngles(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | setCamera (oldcam); |
564
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
226 | */ |
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
227 | resetAngles(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | void GLRenderer::initializeGL() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | { setBackground(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | glLineWidth (gl_linethickness); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | setAutoFillBackground (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | setMouseTracking (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | setFocusPolicy (Qt::WheelFocus); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | compileAllObjects(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | QColor GLRenderer::getMainColor() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | { QColor col (gl_maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | if (!col.isValid()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | return QColor (0, 0, 0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | col.setAlpha (gl_maincolor_alpha * 255.f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | return col; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | void GLRenderer::setBackground() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | { QColor col (gl_bgcolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | if (!col.isValid()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | col.setAlpha (255); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | m_darkbg = luma (col) < 80; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | m_bgcolor = col; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | qglClearColor (col); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | void GLRenderer::setObjectColor (LDObject* obj, const ListType list) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | { QColor qcol; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | if (!obj->isColored()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | if (list == GL::PickList) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | { // Make the color by the object's ID if we're picking, so we can make the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | // ID again from the color we get from the picking results. Be sure to use |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | // the top level parent's index since we want a subfile's children point |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | // to the subfile itself. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | long i = obj->topLevelParent()->getID(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | // Calculate a color based from this index. This method caters for |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | // 16777216 objects. I don't think that'll be exceeded anytime soon. :) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | // ATM biggest is 53588.dat with 12600 lines. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | double r = (i / (256 * 256)) % 256, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | g = (i / 256) % 256, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | b = i % 256; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
292 | qglColor (QColor (r, g, b)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | if ((list == BFCFrontList || list == BFCBackList) && |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | obj->getType() != LDObject::Line && |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | obj->getType() != LDObject::CondLine) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | { if (list == GL::BFCFrontList) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | qcol = QColor (40, 192, 0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | qcol = QColor (224, 0, 0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | { if (obj->getColor() == maincolor) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | qcol = getMainColor(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | { LDColor* col = getColor (obj->getColor()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | if (col) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | qcol = col->faceColor; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | if (obj->getColor() == edgecolor) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | { qcol = luma (m_bgcolor) < 40 ? QColor (64, 64, 64) : Qt::black; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | LDColor* col; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | if (!gl_blackedges && obj->getParent() && (col = getColor (obj->getParent()->getColor()))) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | qcol = col->edgeColor; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
321 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | if (qcol.isValid() == false) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | { // The color was unknown. Use main color to make the object at least |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | // not appear pitch-black. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | if (obj->getColor() != edgecolor) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | qcol = getMainColor(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | // Warn about the unknown colors, but only once. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | for (int i : g_warnedColors) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | if (obj->getColor() == i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | log ("%1: Unknown color %2!\n", __func__, obj->getColor()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | g_warnedColors << obj->getColor(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | long r = qcol.red(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | g = qcol.green(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | b = qcol.blue(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | a = qcol.alpha(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | if (obj->topLevelParent()->isSelected()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | { // Brighten it up for the select list. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | const uchar add = 51; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | r = min (r + add, 255l); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | g = min (g + add, 255l); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | b = min (b + add, 255l); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | glColor4f ( |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | ((double) r) / 255.0f, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | ((double) g) / 255.0f, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | ((double) b) / 255.0f, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | ((double) a) / 255.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
362 | void GLRenderer::refresh() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | { update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | swapBuffers(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | void GLRenderer::hardRefresh() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | { compileAllObjects(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | refresh(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | glLineWidth (gl_linethickness); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
376 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | void GLRenderer::resizeGL (int w, int h) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | { m_width = w; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | m_height = h; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | calcCameraIcons(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | glViewport (0, 0, w, h); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | glMatrixMode (GL_PROJECTION); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
386 | glLoadIdentity(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
387 | gluPerspective (45.0f, (double) w / (double) h, 1.0f, 10000.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | glMatrixMode (GL_MODELVIEW); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | void GLRenderer::drawGLScene() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | { if (getFile() == null) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | if (gl_wireframe && !isPicking()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | glEnable (GL_DEPTH_TEST); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | if (m_camera != EFreeCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | { glMatrixMode (GL_PROJECTION); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
405 | glPushMatrix(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
407 | glLoadIdentity(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
408 | glOrtho (-m_virtWidth, m_virtWidth, -m_virtHeight, m_virtHeight, -100.0f, 100.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | glTranslatef (pan (X), pan (Y), 0.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | if (m_camera != EFrontCamera && m_camera != EBackCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | { glRotatef (90.0f, g_FixedCameras[camera()].glrotate[0], |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | g_FixedCameras[camera()].glrotate[1], |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | g_FixedCameras[camera()].glrotate[2]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | // Back camera needs to be handled differently |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | if (m_camera == GLRenderer::EBackCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | { glRotatef (180.0f, 1.0f, 0.0f, 0.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | glRotatef (180.0f, 0.0f, 0.0f, 1.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | { glMatrixMode (GL_MODELVIEW); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | glPushMatrix(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | glLoadIdentity(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | glTranslatef (0.0f, 0.0f, -2.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | glTranslatef (pan (X), pan (Y), -zoom()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | glRotatef (rot (X), 1.0f, 0.0f, 0.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | glRotatef (rot (Y), 0.0f, 1.0f, 0.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | glRotatef (rot (Z), 0.0f, 0.0f, 1.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
433 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | const GL::ListType list = (!isDrawOnly() && isPicking()) ? PickList : NormalList; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | if (gl_colorbfc && !isPicking() && !isDrawOnly()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | { glEnable (GL_CULL_FACE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | for (LDObject* obj : getFile()->getObjects()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | { if (obj->isHidden()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
443 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | glCullFace (GL_BACK); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | glCallList (obj->glLists[BFCFrontList]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | glCullFace (GL_FRONT); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | glCallList (obj->glLists[BFCBackList]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
449 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | glDisable (GL_CULL_FACE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
452 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
453 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | { for (LDObject* obj : getFile()->getObjects()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | { if (obj->isHidden()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
456 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
457 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
458 | glCallList (obj->glLists[list]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
460 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
461 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | if (gl_axes && !isPicking() && !isDrawOnly()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | glCallList (m_axeslist); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
464 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
465 | glPopMatrix(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
466 | glMatrixMode (GL_MODELVIEW); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
467 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
468 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
469 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
470 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
471 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
472 | // This converts a 2D point on the screen to a 3D point in the model. If 'snap' |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
473 | // is true, the 3D point will snap to the current grid. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
474 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | { assert (camera() != EFreeCamera); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | vertex pos3d; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
480 | const Axis axisX = cam->axisX; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | const Axis axisY = cam->axisY; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | const int negXFac = cam->negX ? -1 : 1, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
483 | negYFac = cam->negY ? -1 : 1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
484 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | // Calculate cx and cy - these are the LDraw unit coords the cursor is at. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
486 | double cx = (-m_virtWidth + ((2 * pos2d.x() * m_virtWidth) / m_width) - pan (X)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
487 | double cy = (m_virtHeight - ((2 * pos2d.y() * m_virtHeight) / m_height) - pan (Y)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
488 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
489 | if (snap) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
490 | { cx = Grid::snap (cx, (Grid::Config) axisX); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | cy = Grid::snap (cy, (Grid::Config) axisY); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
492 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
493 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | cx *= negXFac; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
495 | cy *= negYFac; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
496 | |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
497 | roundToDecimals (cx, 4); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
498 | roundToDecimals (cy, 4); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
499 | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | // Create the vertex from the coordinates |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
501 | pos3d[axisX] = cx; |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
502 | pos3d[axisY] = cy; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | pos3d[3 - axisX - axisY] = getDepthValue(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | return pos3d; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | // Inverse operation for the above - convert a 3D position to a 2D screen |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
510 | // position. Don't ask me how this code manages to work, I don't even know. |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
511 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
512 | QPoint GLRenderer::coordconv3_2 (const vertex& pos3d) const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
513 | { GLfloat m[16]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
514 | const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
515 | const Axis axisX = cam->axisX; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
516 | const Axis axisY = cam->axisY; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
517 | const int negXFac = cam->negX ? -1 : 1, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
518 | negYFac = cam->negY ? -1 : 1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
519 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
520 | glGetFloatv (GL_MODELVIEW_MATRIX, m); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
521 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
522 | const double x = pos3d.x(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | const double y = pos3d.y(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
524 | const double z = pos3d.z(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
525 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
526 | vertex transformed; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
527 | transformed[X] = (m[0] * x) + (m[1] * y) + (m[2] * z) + m[3]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
528 | transformed[Y] = (m[4] * x) + (m[5] * y) + (m[6] * z) + m[7]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
529 | transformed[Z] = (m[8] * x) + (m[9] * y) + (m[10] * z) + m[11]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
530 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
531 | double rx = (((transformed[axisX] * negXFac) + m_virtWidth + pan (X)) * m_width) / (2 * m_virtWidth); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
532 | double ry = (((transformed[axisY] * negYFac) - m_virtHeight + pan (Y)) * m_height) / (2 * m_virtHeight); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
533 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | return QPoint (rx, -ry); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
536 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | void GLRenderer::paintEvent (QPaintEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | { Q_UNUSED (ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | makeCurrent(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | m_virtWidth = zoom(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | m_virtHeight = (m_height * m_virtWidth) / m_width; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
545 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | initGLData(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | drawGLScene(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
548 | |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
549 | const QPen textpen (m_darkbg ? Qt::white : Qt::black); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
550 | const QBrush polybrush (QColor (64, 192, 0, 128)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
551 | QPainter paint (this); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | QFontMetrics metrics = QFontMetrics (QFont()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
553 | paint.setRenderHint (QPainter::HighQualityAntialiasing); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
555 | // If we wish to only draw the brick, stop here |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
556 | if (isDrawOnly()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
559 | if (m_camera != EFreeCamera && !isPicking()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
560 | { // Paint the overlay image if we have one |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
561 | const LDGLOverlay& overlay = m_overlays[m_camera]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
563 | if (overlay.img != null) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | { QPoint v0 = coordconv3_2 (m_overlays[m_camera].v0), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | v1 = coordconv3_2 (m_overlays[m_camera].v1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
567 | QRect targRect (v0.x(), v0.y(), abs (v1.x() - v0.x()), abs (v1.y() - v0.y())), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | srcRect (0, 0, overlay.img->width(), overlay.img->height()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | paint.drawImage (targRect, *overlay.img, srcRect); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
570 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | // Paint the coordinates onto the screen. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | str text = fmt (tr ("X: %1, Y: %2, Z: %3"), m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
574 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | QFontMetrics metrics = QFontMetrics (font()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
577 | |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
578 | paint.setPen (textpen); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
579 | paint.drawText (m_width - textSize.width(), m_height - 16, textSize.width(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | textSize.height(), Qt::AlignCenter, text); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
581 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | QPen linepen = m_thinBorderPen; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
583 | linepen.setWidth (2); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
584 | linepen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
586 | // Mode-specific rendering |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | if (getEditMode() == EDrawMode) |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
588 | { QPoint poly[4]; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
589 | vertex poly3d[4]; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
590 | int numverts = 4; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
591 | |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
592 | // Calculate polygon data |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
593 | if (!m_rectdraw) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
594 | { numverts = m_drawedVerts.size() + 1; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
595 | int i = 0; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
596 | |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
597 | for (vertex& vert : m_drawedVerts) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
598 | poly3d[i++] = vert; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
599 | |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
600 | // Draw the cursor vertex as the last one in the list. |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
601 | if (numverts <= 4) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
602 | poly3d[i] = m_hoverpos; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
603 | else |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
604 | numverts = 4; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
605 | } |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
606 | else |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
607 | { // Get vertex information from m_rectverts |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
608 | if (m_drawedVerts.size() > 0) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
609 | for (int i = 0; i < numverts; ++i) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
610 | poly3d[i] = m_rectverts[i]; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
611 | else |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
612 | poly3d[0] = m_hoverpos; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
613 | } |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
614 | |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
615 | // Convert to 2D |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
616 | for (int i = 0; i < numverts; ++i) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
617 | poly[i] = coordconv3_2 (poly3d[i]); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
619 | if (numverts > 0) |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
620 | { // Draw the polygon-to-be |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
621 | paint.setPen (linepen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
622 | paint.setBrush (polybrush); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | paint.drawPolygon (poly, numverts); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | // Draw vertex blips |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | for (int i = 0; i < numverts; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | { QPoint& blip = poly[i]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
628 | drawBlip (paint, blip); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | // Draw their coordinates |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
631 | paint.drawText (blip.x(), blip.y() - 8, poly3d[i].stringRep (true)); |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
632 | } |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
633 | |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
634 | // Draw line lenghts and angle info if appropriate |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
635 | if (numverts >= 2) |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
636 | { int numlines = (m_drawedVerts.size() == 1) ? 1 : m_drawedVerts.size() + 1; |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
637 | paint.setPen (textpen); |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
638 | |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
639 | for (int i = 0; i < numlines; ++i) |
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
640 | { const int j = (i + 1 < numverts) ? i + 1 : 0; |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
641 | const int h = (i - 1 >= 0) ? i - 1 : numverts - 1; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
642 | |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
643 | if (gl_linelengths) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
644 | { const str label = str::number (poly3d[i].distanceTo (poly3d[j])); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
645 | QPoint origin = QLineF (poly[i], poly[j]).pointAt (0.5).toPoint(); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
646 | paint.drawText (origin, label); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
647 | } |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
648 | |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
649 | if (gl_drawangles) |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
650 | { QLineF l0 (poly[h], poly[i]), |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
651 | l1 (poly[i], poly[j]); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
652 | double angle = l0.angleTo (l1); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
653 | str label = str::number (angle) + str::fromUtf8 (QByteArray ("\302\260")); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
654 | QPoint pos = poly[i]; |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
655 | pos.setY (pos.y() + metrics.height()); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
656 | paint.drawText (pos, label); |
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
657 | } |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
658 | } |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
660 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
661 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
662 | elif (getEditMode() == ECircleMode) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
663 | { // If we have not specified the center point of the circle yet, preview it on the screen. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
664 | if (m_drawedVerts.isEmpty()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | drawBlip (paint, coordconv3_2 (m_hoverpos)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | { QVector<vertex> verts, verts2; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
668 | const double dist0 = getCircleDrawDist (0), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | dist1 = (m_drawedVerts.size() >= 2) ? getCircleDrawDist (1) : -1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
670 | const int segs = lores; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
671 | const double angleUnit = (2 * pi) / segs; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
672 | Axis relX, relY; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | QVector<QPoint> ringpoints, circlepoints, circle2points; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
674 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | getRelativeAxes (relX, relY); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
676 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
677 | // Calculate the preview positions of vertices |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
678 | for (int i = 0; i < segs; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | { vertex v = g_origin; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | v[relX] = m_drawedVerts[0][relX] + (cos (i * angleUnit) * dist0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
681 | v[relY] = m_drawedVerts[0][relY] + (sin (i * angleUnit) * dist0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | verts << v; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | if (dist1 != -1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
685 | { v[relX] = m_drawedVerts[0][relX] + (cos (i * angleUnit) * dist1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | v[relY] = m_drawedVerts[0][relY] + (sin (i * angleUnit) * dist1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
687 | verts2 << v; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
688 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | int i = 0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | for (const vertex& v : verts + verts2) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
693 | { // Calculate the 2D point of the vertex |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | QPoint point = coordconv3_2 (v); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
695 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | // Draw a green blip at where it is |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | drawBlip (paint, point); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
698 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | // Add it to the list of points for the green ring fill. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | ringpoints << point; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
701 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | // Also add the circle points to separate lists |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
703 | if (i < verts.size()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
704 | circlepoints << point; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
705 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
706 | circle2points << point; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
707 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
708 | ++i; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
709 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
710 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
711 | // Insert the first point as the seventeenth one so that |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
712 | // the ring polygon is closed properly. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
713 | if (ringpoints.size() >= 16) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
714 | ringpoints.insert (16, ringpoints[0]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
715 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
716 | // Same for the outer ring. Note that the indices are offset by 1 |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
717 | // because of the insertion done above bumps the values. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
718 | if (ringpoints.size() >= 33) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | ringpoints.insert (33, ringpoints[17]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
721 | // Draw the ring |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
722 | paint.setBrush ((m_drawedVerts.size() >= 2) ? polybrush : Qt::NoBrush); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | paint.setPen (Qt::NoPen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
724 | paint.drawPolygon (QPolygon (ringpoints)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | // Draw the circles |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
727 | paint.setBrush (Qt::NoBrush); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
728 | paint.setPen (linepen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
729 | paint.drawPolygon (QPolygon (circlepoints)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
730 | paint.drawPolygon (QPolygon (circle2points)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
731 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
732 | { // Draw the current radius in the middle of the circle. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
733 | QPoint origin = coordconv3_2 (m_drawedVerts[0]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
734 | str label = str::number (dist0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
735 | paint.setPen (textpen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
736 | paint.drawText (origin.x() - (metrics.width (label) / 2), origin.y(), label); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
738 | if (m_drawedVerts.size() >= 2) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
739 | { label = str::number (dist1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
740 | paint.drawText (origin.x() - (metrics.width (label) / 2), origin.y() + metrics.height(), label); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
741 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
742 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
743 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
744 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
745 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
746 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
747 | // Camera icons |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
748 | if (!isPicking()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
749 | { // Draw a background for the selected camera |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
750 | paint.setPen (m_thinBorderPen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
751 | paint.setBrush (QBrush (QColor (0, 128, 160, 128))); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
752 | paint.drawRect (m_cameraIcons[camera()].selRect); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
753 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
754 | // Draw the actual icons |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
755 | for (CameraIcon& info : m_cameraIcons) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
756 | { // Don't draw the free camera icon when in draw mode |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
757 | if (&info == &m_cameraIcons[GL::EFreeCamera] && getEditMode() != ESelectMode) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
758 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
759 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
760 | paint.drawPixmap (info.destRect, *info.img, info.srcRect); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
761 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
762 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
763 | str fmtstr = tr ("%1 Camera"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
764 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
765 | // Draw a label for the current camera in the bottom left corner |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
766 | { const int margin = 4; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
767 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
768 | str label; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
769 | label = fmt (fmtstr, tr (g_CameraNames[camera()])); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
770 | paint.setPen (textpen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
771 | paint.drawText (QPoint (margin, height() - (margin + metrics.descent())), label); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
772 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
773 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
774 | // Tool tips |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
775 | if (m_drawToolTip) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
776 | { if (m_cameraIcons[m_toolTipCamera].destRect.contains (m_pos) == false) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
777 | m_drawToolTip = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
778 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
779 | { str label = fmt (fmtstr, tr (g_CameraNames[m_toolTipCamera])); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
780 | QToolTip::showText (m_globalpos, label); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
781 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
782 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
783 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
784 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
785 | // Message log |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
786 | if (getMessageLog()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
787 | { int y = 0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
788 | const int margin = 2; |
574
10874674fe30
- line lengths are now displayed when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
568
diff
changeset
|
789 | QColor penColor = textpen.color(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
790 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
791 | for (const MessageManager::Line& line : getMessageLog()->getLines()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
792 | { penColor.setAlphaF (line.alpha); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
793 | paint.setPen (penColor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
794 | paint.drawText (QPoint (margin, y + margin + metrics.ascent()), line.text); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
795 | y += metrics.height(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
796 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
797 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
798 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
799 | // If we're range-picking, draw a rectangle encompassing the selection area. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
800 | if (m_rangepick && !isPicking() && m_totalmove >= 10) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
801 | { int x0 = m_rangeStart.x(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
802 | y0 = m_rangeStart.y(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
803 | x1 = m_pos.x(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
804 | y1 = m_pos.y(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
805 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
806 | QRect rect (x0, y0, x1 - x0, y1 - y0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
807 | QColor fillColor = (m_addpick ? "#40FF00" : "#00CCFF"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
808 | fillColor.setAlphaF (0.2f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
809 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
810 | paint.setPen (m_thickBorderPen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
811 | paint.setBrush (QBrush (fillColor)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
812 | paint.drawRect (rect); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
813 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
814 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
815 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
816 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
817 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
818 | void GLRenderer::drawBlip (QPainter& paint, QPoint pos) const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
819 | { QPen pen = m_thinBorderPen; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
820 | const int blipsize = 8; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
821 | pen.setWidth (1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
822 | paint.setPen (pen); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
823 | paint.setBrush (QColor (64, 192, 0)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
824 | paint.drawEllipse (pos.x() - blipsize / 2, pos.y() - blipsize / 2, blipsize, blipsize); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
825 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
826 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
827 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
828 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
829 | void GLRenderer::compileAllObjects() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
830 | { if (!getFile()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
831 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
832 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
833 | // Compiling all is a big job, use a busy cursor |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
834 | setCursor (Qt::BusyCursor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
835 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
836 | m_knownVerts.clear(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
837 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
838 | for (LDObject* obj : getFile()->getObjects()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
839 | compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
840 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
841 | // Compile axes |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
842 | glDeleteLists (m_axeslist, 1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
843 | m_axeslist = glGenLists (1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
844 | glNewList (m_axeslist, GL_COMPILE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
845 | glBegin (GL_LINES); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
846 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
847 | for (const LDGLAxis& ax : g_GLAxes) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
848 | { qglColor (ax.col); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
849 | compileVertex (ax.vert); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
850 | compileVertex (-ax.vert); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
851 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
852 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
853 | glEnd(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
854 | glEndList(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
855 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
856 | setCursor (Qt::ArrowCursor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
857 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
858 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
859 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
860 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
861 | void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
862 | { glBegin (gltype); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
863 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
864 | const int numverts = (obj->getType() != LDObject::CondLine) ? obj->vertices() : 2; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
865 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
866 | if (g_glInvert == false) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
867 | for (int i = 0; i < numverts; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
868 | compileVertex (obj->getVertex (i)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
869 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
870 | for (int i = numverts - 1; i >= 0; --i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
871 | compileVertex (obj->getVertex (i)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
872 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
873 | glEnd(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
874 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
875 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
876 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
877 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
878 | void GLRenderer::compileList (LDObject* obj, const GLRenderer::ListType list) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
879 | { setObjectColor (obj, list); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
880 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
881 | switch (obj->getType()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
882 | { case LDObject::Line: |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
883 | { compileSubObject (obj, GL_LINES); |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
884 | } break; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
885 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
886 | case LDObject::CondLine: |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
887 | { // Draw conditional lines with a dash pattern - however, use a full |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
888 | // line when drawing a pick list to make selecting them easier. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
889 | if (list != GL::PickList) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
890 | { glLineStipple (1, 0x6666); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
891 | glEnable (GL_LINE_STIPPLE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
892 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
893 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
894 | compileSubObject (obj, GL_LINES); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
895 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
896 | glDisable (GL_LINE_STIPPLE); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
897 | } break; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
898 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
899 | case LDObject::Triangle: |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
900 | { compileSubObject (obj, GL_TRIANGLES); |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
901 | } break; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
902 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
903 | case LDObject::Quad: |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
904 | { compileSubObject (obj, GL_QUADS); |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
905 | } break; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
906 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
907 | case LDObject::Subfile: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
908 | { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
909 | QList<LDObject*> objs; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
910 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
911 | objs = ref->inlineContents ( |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
912 | LDSubfile::DeepInline | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
913 | LDSubfile::CacheInline | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
914 | LDSubfile::RendererInline); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
915 | bool oldinvert = g_glInvert; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
916 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
917 | if (ref->getTransform().getDeterminant() < 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
918 | g_glInvert = !g_glInvert; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
919 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
920 | LDObject* prev = ref->prev(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
921 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
922 | if (prev && prev->getType() == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
923 | g_glInvert = !g_glInvert; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
924 | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
925 | for (LDObject* obj : objs) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
926 | { compileList (obj, list); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
927 | obj->deleteSelf(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
928 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
929 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
930 | g_glInvert = oldinvert; |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
931 | } break; |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
932 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
933 | default: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
934 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
935 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
936 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
937 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
938 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
939 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
940 | void GLRenderer::compileVertex (const vertex& vrt) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
941 | { glVertex3d (vrt[X], -vrt[Y], -vrt[Z]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
942 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
943 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
944 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
945 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
946 | void GLRenderer::clampAngle (double& angle) const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
947 | { while (angle < 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
948 | angle += 360.0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
949 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
950 | while (angle > 360.0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
951 | angle -= 360.0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
952 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
953 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
954 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
955 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
956 | void GLRenderer::addDrawnVertex (vertex pos) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
957 | { // If we picked an already-existing vertex, stop drawing |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
958 | if (getEditMode() == EDrawMode) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
959 | { for (vertex& vert : m_drawedVerts) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
960 | { if (vert == pos) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
961 | { endDraw (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
962 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
963 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
964 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
965 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
966 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
967 | m_drawedVerts << pos; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
968 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
969 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
970 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
971 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
972 | void GLRenderer::mouseReleaseEvent (QMouseEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
973 | { const bool wasLeft = (m_lastButtons & Qt::LeftButton) && ! (ev->buttons() & Qt::LeftButton), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
974 | wasRight = (m_lastButtons & Qt::RightButton) && ! (ev->buttons() & Qt::RightButton), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
975 | wasMid = (m_lastButtons & Qt::MidButton) && ! (ev->buttons() & Qt::MidButton); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
976 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
977 | if (m_panning) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
978 | m_panning = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
979 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
980 | if (wasLeft) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
981 | { // Check if we selected a camera icon |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
982 | if (!m_rangepick) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
983 | { for (CameraIcon & info : m_cameraIcons) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
984 | { if (info.destRect.contains (ev->pos())) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
985 | { setCamera (info.cam); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
986 | goto end; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
987 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
988 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
989 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
990 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
991 | switch (getEditMode()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
992 | { case EDrawMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
993 | { if (m_rectdraw) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
994 | { if (m_drawedVerts.size() == 2) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
995 | { endDraw (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
996 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
997 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
998 | } else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
999 | { // If we have 4 verts, stop drawing. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1000 | if (m_drawedVerts.size() >= 4) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1001 | { endDraw (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1002 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1003 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1004 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1005 | if (m_drawedVerts.isEmpty() && ev->modifiers() & Qt::ShiftModifier) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1006 | { m_rectdraw = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1007 | updateRectVerts(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1008 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1009 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1010 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1011 | addDrawnVertex (m_hoverpos); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1012 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1013 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1014 | case ECircleMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1015 | { if (m_drawedVerts.size() == 3) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1016 | { endDraw (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1017 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1018 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1019 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1020 | addDrawnVertex (m_hoverpos); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1021 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1022 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1023 | case ESelectMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1024 | { if (!isDrawOnly()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1025 | { if (m_totalmove < 10) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1026 | m_rangepick = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1027 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1028 | if (!m_rangepick) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1029 | m_addpick = (m_keymods & Qt::ControlModifier); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1030 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1031 | if (m_totalmove < 10 || m_rangepick) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1032 | pick (ev->x(), ev->y()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1033 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1034 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1035 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1036 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1037 | m_rangepick = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1038 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1039 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1040 | if (wasMid && getEditMode() != ESelectMode && m_drawedVerts.size() < 4 && m_totalmove < 10) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1041 | { // Find the closest vertex to our cursor |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1042 | double mindist = 1024.0f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1043 | vertex closest; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1044 | bool valid = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1045 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1046 | QPoint curspos = coordconv3_2 (m_hoverpos); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1047 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1048 | for (const vertex& pos3d: m_knownVerts) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1049 | { QPoint pos2d = coordconv3_2 (pos3d); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1050 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1051 | // Measure squared distance |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1052 | const double dx = abs (pos2d.x() - curspos.x()), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1053 | dy = abs (pos2d.y() - curspos.y()), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1054 | distsq = (dx * dx) + (dy * dy); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1055 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1056 | if (distsq >= 1024.0f) // 32.0f ** 2 |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1057 | continue; // too far away |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1058 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1059 | if (distsq < mindist) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1060 | { mindist = distsq; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1061 | closest = pos3d; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1062 | valid = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1063 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1064 | // If it's only 4 pixels away, I think we found our vertex now. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1065 | if (distsq <= 16.0f) // 4.0f ** 2 |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1066 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1067 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1068 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1069 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1070 | if (valid) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1071 | addDrawnVertex (closest); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1072 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1073 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1074 | if (wasRight && !m_drawedVerts.isEmpty()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1075 | { // Remove the last vertex |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1076 | m_drawedVerts.removeLast(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1077 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1078 | if (m_drawedVerts.isEmpty()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1079 | m_rectdraw = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1080 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1081 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1082 | end: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1083 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1084 | m_totalmove = 0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1085 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1086 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1087 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1088 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1089 | void GLRenderer::mousePressEvent (QMouseEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1090 | { m_totalmove = 0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1091 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1092 | if (ev->modifiers() & Qt::ControlModifier) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1093 | { m_rangepick = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1094 | m_rangeStart.setX (ev->x()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1095 | m_rangeStart.setY (ev->y()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1096 | m_addpick = (m_keymods & Qt::AltModifier); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1097 | ev->accept(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1098 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1099 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1100 | m_lastButtons = ev->buttons(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1101 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1102 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1103 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1104 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1105 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1106 | void GLRenderer::mouseMoveEvent (QMouseEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1107 | { int dx = ev->x() - m_pos.x(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1108 | int dy = ev->y() - m_pos.y(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1109 | m_totalmove += abs (dx) + abs (dy); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1110 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1111 | const bool left = ev->buttons() & Qt::LeftButton, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1112 | mid = ev->buttons() & Qt::MidButton, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1113 | shift = ev->modifiers() & Qt::ShiftModifier; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1114 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1115 | if (mid || (left && shift)) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1116 | { pan (X) += 0.03f * dx * (zoom() / 7.5f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1117 | pan (Y) -= 0.03f * dy * (zoom() / 7.5f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1118 | m_panning = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1119 | } elif (left && !m_rangepick && camera() == EFreeCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1120 | { rot (X) = rot (X) + dy; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1121 | rot (Y) = rot (Y) + dx; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1122 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1123 | clampAngle (rot (X)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1124 | clampAngle (rot (Y)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1125 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1126 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1127 | // Start the tool tip timer |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1128 | if (!m_drawToolTip) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1129 | m_toolTipTimer->start (500); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1130 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1131 | // Update 2d position |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1132 | m_pos = ev->pos(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1133 | m_globalpos = ev->globalPos(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1134 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1135 | // Calculate 3d position of the cursor |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1136 | m_hoverpos = (camera() != EFreeCamera) ? coordconv2_3 (m_pos, true) : g_origin; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1137 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1138 | // Update rect vertices since m_hoverpos may have changed |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1139 | updateRectVerts(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1140 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1141 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1142 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1143 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1144 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1145 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1146 | void GLRenderer::keyPressEvent (QKeyEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1147 | { m_keymods = ev->modifiers(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1148 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1149 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1150 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1151 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1152 | void GLRenderer::keyReleaseEvent (QKeyEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1153 | { m_keymods = ev->modifiers(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1154 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1155 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1156 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1157 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1158 | void GLRenderer::wheelEvent (QWheelEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1159 | { makeCurrent(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1160 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1161 | zoomNotch (ev->delta() > 0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1162 | zoom() = clamp (zoom(), 0.01, 10000.0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1163 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1164 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1165 | ev->accept(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1166 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1167 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1168 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1169 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1170 | void GLRenderer::leaveEvent (QEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1171 | { (void) ev; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1172 | m_drawToolTip = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1173 | m_toolTipTimer->stop(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1174 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1175 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1176 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1177 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1178 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1179 | void GLRenderer::contextMenuEvent (QContextMenuEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1180 | { g_win->spawnContextMenu (ev->globalPos()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1181 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1182 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1183 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1184 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1185 | void GLRenderer::setCamera (const GLRenderer::EFixedCamera cam) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1186 | { m_camera = cam; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1187 | gl_camera = (int) cam; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1188 | g_win->updateEditModeActions(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1189 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1190 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1191 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1192 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1193 | void GLRenderer::pick (int mouseX, int mouseY) |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
1194 | { makeCurrent(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1195 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1196 | // Use particularly thick lines while picking ease up selecting lines. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1197 | glLineWidth (max<double> (gl_linethickness, 6.5f)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1198 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1199 | // Clear the selection if we do not wish to add to it. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1200 | if (!m_addpick) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1201 | { QList<LDObject*> oldsel = selection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1202 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1203 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1204 | for (LDObject* obj : oldsel) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1205 | compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1206 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1207 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1208 | setPicking (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1209 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1210 | // Paint the picking scene |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1211 | glDisable (GL_DITHER); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1212 | glClearColor (1.0f, 1.0f, 1.0f, 1.0f); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1213 | drawGLScene(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1214 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1215 | int x0 = mouseX, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1216 | y0 = mouseY; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1217 | int x1, y1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1218 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1219 | // Determine how big an area to read - with range picking, we pick by |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1220 | // the area given, with single pixel picking, we use an 1 x 1 area. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1221 | if (m_rangepick) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1222 | { x1 = m_rangeStart.x(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1223 | y1 = m_rangeStart.y(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1224 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1225 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1226 | { x1 = x0 + 1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1227 | y1 = y0 + 1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1228 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1229 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1230 | // x0 and y0 must be less than x1 and y1, respectively. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1231 | if (x0 > x1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1232 | qSwap (x0, x1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1233 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1234 | if (y0 > y1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1235 | qSwap (y0, y1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1236 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1237 | // Clamp the values to ensure they're within bounds |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1238 | x0 = max (0, x0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1239 | y0 = max (0, y0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1240 | x1 = min (x1, m_width); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1241 | y1 = min (y1, m_height); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1242 | const int areawidth = (x1 - x0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1243 | const int areaheight = (y1 - y0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1244 | const qint32 numpixels = areawidth * areaheight; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1245 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1246 | // Allocate space for the pixel data. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1247 | uchar* const pixeldata = new uchar[4 * numpixels]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1248 | uchar* pixelptr = &pixeldata[0]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1249 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1250 | // Read pixels from the color buffer. |
578
a86ae85a277c
- added visible line angles when drawing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
577
diff
changeset
|
1251 | glReadPixels (x0, m_height - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1252 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1253 | LDObject* removedObj = null; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1254 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1255 | // Go through each pixel read and add them to the selection. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1256 | for (qint32 i = 0; i < numpixels; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1257 | { qint32 idx = |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1258 | (*(pixelptr + 0) * 0x10000) + |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1259 | (*(pixelptr + 1) * 0x00100) + |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1260 | (*(pixelptr + 2) * 0x00001); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1261 | pixelptr += 4; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1262 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1263 | if (idx == 0xFFFFFF) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1264 | continue; // White is background; skip |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1265 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1266 | LDObject* obj = LDObject::fromID (idx); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1267 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1268 | // If this is an additive single pick and the object is currently selected, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1269 | // we remove it from selection instead. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1270 | if (!m_rangepick && m_addpick) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1271 | { if (obj->isSelected()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1272 | { obj->unselect(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1273 | removedObj = obj; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1274 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1275 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1276 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1277 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1278 | obj->select(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1279 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1280 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1281 | delete[] pixeldata; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1282 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1283 | // Update everything now. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1284 | g_win->updateSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1285 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1286 | // Recompile the objects now to update their color |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1287 | for (LDObject* obj : selection()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1288 | compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1289 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1290 | if (removedObj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1291 | compileObject (removedObj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1292 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1293 | // Restore line thickness |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1294 | glLineWidth (gl_linethickness); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1295 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1296 | setPicking (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1297 | m_rangepick = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1298 | glEnable (GL_DITHER); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1299 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1300 | setBackground(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1301 | repaint(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1302 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1303 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1304 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1305 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1306 | void GLRenderer::setEditMode (EditMode const& a) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1307 | { m_EditMode = a; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1308 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1309 | switch (a) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1310 | { case ESelectMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1311 | { unsetCursor(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1312 | setContextMenuPolicy (Qt::DefaultContextMenu); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1313 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1314 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1315 | case EDrawMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1316 | case ECircleMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1317 | { // Cannot draw into the free camera - use top instead. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1318 | if (m_camera == EFreeCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1319 | setCamera (ETopCamera); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1320 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1321 | // Disable the context menu - we need the right mouse button |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1322 | // for removing vertices. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1323 | setContextMenuPolicy (Qt::NoContextMenu); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1324 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1325 | // Use the crosshair cursor when drawing. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1326 | setCursor (Qt::CrossCursor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1327 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1328 | // Clear the selection when beginning to draw. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1329 | QList<LDObject*> priorsel = selection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1330 | getCurrentDocument()->clearSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1331 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1332 | for (LDObject* obj : priorsel) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1333 | compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1334 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1335 | g_win->updateSelection(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1336 | m_drawedVerts.clear(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1337 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1338 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1339 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1340 | g_win->updateEditModeActions(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1341 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1342 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1343 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1344 | void GLRenderer::setFile (LDDocument* const& a) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1345 | { m_File = a; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1346 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1347 | if (a != null) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1348 | initOverlaysFromObjects(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1349 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1350 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1351 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1352 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1353 | matrix GLRenderer::getCircleDrawMatrix (double scale) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1354 | { matrix transform = g_circleDrawTransforms[camera() % 3]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1355 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1356 | for (int i = 0; i < 9; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1357 | { if (transform[i] == 2) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1358 | transform[i] = scale; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1359 | elif (transform[i] == 1 && camera() >= 3) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1360 | transform[i] = -1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1361 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1362 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1363 | return transform; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1364 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1365 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1366 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1367 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1368 | void GLRenderer::endDraw (bool accept) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1369 | { (void) accept; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1370 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1371 | // Clean the selection and create the object |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1372 | QList<vertex>& verts = m_drawedVerts; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1373 | QList<LDObject*> objs; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1374 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1375 | switch (getEditMode()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1376 | { case EDrawMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1377 | { if (m_rectdraw) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1378 | { LDQuad* quad = new LDQuad; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1379 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1380 | // Copy the vertices from m_rectverts |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1381 | updateRectVerts(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1382 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1383 | for (int i = 0; i < quad->vertices(); ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1384 | quad->setVertex (i, m_rectverts[i]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1385 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1386 | quad->setColor (maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1387 | objs << quad; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1388 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1389 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1390 | { switch (verts.size()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1391 | { case 1: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1392 | { // 1 vertex - add a vertex object |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1393 | LDVertex* obj = new LDVertex; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1394 | obj->pos = verts[0]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1395 | obj->setColor (maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1396 | objs << obj; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1397 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1398 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1399 | case 2: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1400 | { // 2 verts - make a line |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1401 | LDLine* obj = new LDLine (verts[0], verts[1]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1402 | obj->setColor (edgecolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1403 | objs << obj; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1404 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1405 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1406 | case 3: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1407 | case 4: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1408 | { LDObject* obj = (verts.size() == 3) ? |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1409 | static_cast<LDObject*> (new LDTriangle) : |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1410 | static_cast<LDObject*> (new LDQuad); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1411 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1412 | obj->setColor (maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1413 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1414 | for (int i = 0; i < obj->vertices(); ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1415 | obj->setVertex (i, verts[i]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1416 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1417 | objs << obj; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1418 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1419 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1420 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1421 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1422 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1423 | case ECircleMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1424 | { const int segs = lores, divs = lores; // TODO: make customizable |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1425 | double dist0 = getCircleDrawDist (0), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1426 | dist1 = getCircleDrawDist (1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1427 | LDDocument* refFile = null; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1428 | matrix transform; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1429 | bool circleOrDisc = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1430 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1431 | if (dist1 < dist0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1432 | std::swap<double> (dist0, dist1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1433 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1434 | if (dist0 == dist1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1435 | { // If the radii are the same, there's no ring space to fill. Use a circle. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1436 | refFile = ::getDocument ("4-4edge.dat"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1437 | transform = getCircleDrawMatrix (dist0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1438 | circleOrDisc = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1439 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1440 | elif (dist0 == 0 || dist1 == 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1441 | { // If either radii is 0, use a disc. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1442 | refFile = ::getDocument ("4-4disc.dat"); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1443 | transform = getCircleDrawMatrix ((dist0 != 0) ? dist0 : dist1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1444 | circleOrDisc = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1445 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1446 | elif (g_RingFinder (dist0, dist1)) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1447 | { // The ring finder found a solution, use that. Add the component rings to the file. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1448 | for (const RingFinder::Component& cmp : g_RingFinder.bestSolution()->getComponents()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1449 | { // Get a ref file for this primitive. If we cannot find it in the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1450 | // LDraw library, generate it. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1451 | if ((refFile = ::getDocument (radialFileName (::Ring, lores, lores, cmp.num))) == null) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1452 | { refFile = generatePrimitive (::Ring, lores, lores, cmp.num); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1453 | refFile->setImplicit (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1454 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1455 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1456 | LDSubfile* ref = new LDSubfile; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1457 | ref->setFileInfo (refFile); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1458 | ref->setTransform (getCircleDrawMatrix (cmp.scale)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1459 | ref->setPosition (m_drawedVerts[0]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1460 | ref->setColor (maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1461 | objs << ref; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1462 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1463 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1464 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1465 | { // Ring finder failed, last resort: draw the ring with quads |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1466 | QList<QLineF> c0, c1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1467 | Axis relX, relY, relZ; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1468 | getRelativeAxes (relX, relY); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1469 | relZ = (Axis) (3 - relX - relY); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1470 | double x0 = m_drawedVerts[0][relX], |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1471 | y0 = m_drawedVerts[0][relY]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1472 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1473 | vertex templ; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1474 | templ[relX] = x0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1475 | templ[relY] = y0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1476 | templ[relZ] = getDepthValue(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1477 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1478 | // Calculate circle coords |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1479 | makeCircle (segs, divs, dist0, c0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1480 | makeCircle (segs, divs, dist1, c1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1481 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1482 | for (int i = 0; i < segs; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1483 | { vertex v0, v1, v2, v3; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1484 | v0 = v1 = v2 = v3 = templ; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1485 | v0[relX] += c0[i].x1(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1486 | v0[relY] += c0[i].y1(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1487 | v1[relX] += c0[i].x2(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1488 | v1[relY] += c0[i].y2(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1489 | v2[relX] += c1[i].x2(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1490 | v2[relY] += c1[i].y2(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1491 | v3[relX] += c1[i].x1(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1492 | v3[relY] += c1[i].y1(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1493 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1494 | LDQuad* q = new LDQuad (v0, v1, v2, v3); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1495 | q->setColor (maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1496 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1497 | // Ensure the quads always are BFC-front towards the camera |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1498 | if (camera() % 3 <= 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1499 | q->invert(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1500 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1501 | objs << q; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1502 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1503 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1504 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1505 | if (circleOrDisc) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1506 | { LDSubfile* ref = new LDSubfile; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1507 | ref->setFileInfo (refFile); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1508 | ref->setTransform (transform); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1509 | ref->setPosition (m_drawedVerts[0]); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1510 | ref->setColor (maincolor); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1511 | objs << ref; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1512 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1513 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1514 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1515 | case ESelectMode: |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1516 | { // this shouldn't happen |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1517 | assert (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1518 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1519 | } break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1520 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1521 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1522 | if (objs.size() > 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1523 | { g_win->beginAction (null); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1524 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1525 | for (LDObject* obj : objs) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1526 | { getFile()->addObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1527 | compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1528 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1529 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1530 | g_win->refresh(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1531 | g_win->endAction(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1532 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1533 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1534 | m_drawedVerts.clear(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1535 | m_rectdraw = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1536 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1537 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1538 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1539 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1540 | double GLRenderer::getCircleDrawDist (int pos) const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1541 | { assert (m_drawedVerts.size() >= pos + 1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1542 | const vertex& v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : m_hoverpos; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1543 | Axis relX, relY; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1544 | getRelativeAxes (relX, relY); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1545 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1546 | const double dx = m_drawedVerts[0][relX] - v1[relX]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1547 | const double dy = m_drawedVerts[0][relY] - v1[relY]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1548 | return sqrt ((dx * dx) + (dy * dy)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1549 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1550 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1551 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1552 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1553 | void GLRenderer::getRelativeAxes (Axis& relX, Axis& relY) const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1554 | { const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1555 | relX = cam->axisX; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1556 | relY = cam->axisY; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1557 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1558 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1559 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1560 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1561 | static QList<vertex> getVertices (LDObject* obj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1562 | { QList<vertex> verts; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1563 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1564 | if (obj->vertices() >= 2) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1565 | { for (int i = 0; i < obj->vertices(); ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1566 | verts << obj->getVertex (i); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1567 | } elif (obj->getType() == LDObject::Subfile) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1568 | { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1569 | QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1570 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1571 | for (LDObject* obj : objs) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1572 | { verts << getVertices (obj); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1573 | obj->deleteSelf(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1574 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1575 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1576 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1577 | return verts; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1578 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1579 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1580 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1581 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1582 | void GLRenderer::compileObject (LDObject* obj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1583 | { deleteLists (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1584 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1585 | for (const GL::ListType listType : g_glListTypes) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1586 | { if (isDrawOnly() && listType != GL::NormalList) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1587 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1588 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1589 | GLuint list = glGenLists (1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1590 | glNewList (list, GL_COMPILE); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1591 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1592 | obj->glLists[listType] = list; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1593 | compileList (obj, listType); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1594 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1595 | glEndList(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1596 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1597 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1598 | // Mark in known vertices of this object |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1599 | QList<vertex> verts = getVertices (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1600 | m_knownVerts << verts; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1601 | removeDuplicates (m_knownVerts); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1602 | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1603 | obj->setGLInit (true); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1604 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1605 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1606 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1607 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1608 | uchar* GLRenderer::getScreencap (int& w, int& h) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1609 | { w = m_width; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1610 | h = m_height; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1611 | uchar* cap = new uchar[4 * w * h]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1612 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1613 | m_screencap = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1614 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1615 | m_screencap = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1616 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1617 | // Capture the pixels |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1618 | glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1619 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1620 | return cap; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1621 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1622 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1623 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1624 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1625 | void GLRenderer::slot_toolTipTimer() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1626 | { // We come here if the cursor has stayed in one place for longer than a |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1627 | // a second. Check if we're holding it over a camera icon - if so, draw |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1628 | // a tooltip. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1629 | for (CameraIcon & icon : m_cameraIcons) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1630 | { if (icon.destRect.contains (m_pos)) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1631 | { m_toolTipCamera = icon.cam; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1632 | m_drawToolTip = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1633 | update(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1634 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1635 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1636 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1637 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1638 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1639 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1640 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1641 | void GLRenderer::deleteLists (LDObject* obj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1642 | { // Delete the lists but only if they have been initialized |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1643 | if (!obj->isGLInit()) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1644 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1645 | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1646 | for (const GL::ListType listType : g_glListTypes) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1647 | glDeleteLists (obj->glLists[listType], 1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1648 | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1649 | obj->setGLInit (false); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1650 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1651 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1652 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1653 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1654 | Axis GLRenderer::getCameraAxis (bool y, GLRenderer::EFixedCamera camid) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1655 | { if (camid == (GL::EFixedCamera) - 1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1656 | camid = m_camera; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1657 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1658 | const LDFixedCameraInfo* cam = &g_FixedCameras[camid]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1659 | return (y) ? cam->axisY : cam->axisX; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1660 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1661 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1662 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1663 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1664 | bool GLRenderer::setupOverlay (EFixedCamera cam, str file, int x, int y, int w, int h) |
568
2fb6c500ff9e
- convert overlay images explicitly to ARGB32 format, otherwise they might not be able to be made translucent properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
564
diff
changeset
|
1665 | { QImage* img = new QImage (QImage (file).convertToFormat (QImage::Format_ARGB32)); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1666 | LDGLOverlay& info = getOverlay (cam); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1667 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1668 | if (img->isNull()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1669 | { critical (tr ("Failed to load overlay image!")); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1670 | delete img; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1671 | return false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1672 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1673 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1674 | delete info.img; // delete the old image |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1675 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1676 | info.fname = file; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1677 | info.lw = w; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1678 | info.lh = h; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1679 | info.ox = x; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1680 | info.oy = y; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1681 | info.img = img; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1682 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1683 | if (info.lw == 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1684 | info.lw = (info.lh * img->width()) / img->height(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1685 | elif (info.lh == 0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1686 | info.lh = (info.lw * img->height()) / img->width(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1687 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1688 | const Axis x2d = getCameraAxis (false, cam), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1689 | y2d = getCameraAxis (true, cam); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1690 | const double negXFac = g_FixedCameras[cam].negX ? -1 : 1, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1691 | negYFac = g_FixedCameras[cam].negY ? -1 : 1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1692 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1693 | info.v0 = info.v1 = g_origin; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1694 | info.v0[x2d] = - (info.ox * info.lw * negXFac) / img->width(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1695 | info.v0[y2d] = (info.oy * info.lh * negYFac) / img->height(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1696 | info.v1[x2d] = info.v0[x2d] + info.lw; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1697 | info.v1[y2d] = info.v0[y2d] + info.lh; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1698 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1699 | // Set alpha of all pixels to 0.5 |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1700 | for (long i = 0; i < img->width(); ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1701 | for (long j = 0; j < img->height(); ++j) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1702 | { uint32 pixel = img->pixel (i, j); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1703 | img->setPixel (i, j, 0x80000000 | (pixel & 0x00FFFFFF)); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1704 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1705 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1706 | updateOverlayObjects(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1707 | return true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1708 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1709 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1710 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1711 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1712 | void GLRenderer::clearOverlay() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1713 | { if (camera() == EFreeCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1714 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1715 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1716 | LDGLOverlay& info = m_overlays[camera()]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1717 | delete info.img; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1718 | info.img = null; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1719 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1720 | updateOverlayObjects(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1721 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1722 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1723 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1724 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1725 | void GLRenderer::setDepthValue (double depth) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1726 | { assert (camera() < EFreeCamera); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1727 | m_depthValues[camera()] = depth; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1728 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1729 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1730 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1731 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1732 | double GLRenderer::getDepthValue() const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1733 | { assert (camera() < EFreeCamera); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1734 | return m_depthValues[camera()]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1735 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1736 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1737 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1738 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1739 | const char* GLRenderer::getCameraName() const |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1740 | { return g_CameraNames[camera()]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1741 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1742 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1743 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1744 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1745 | LDGLOverlay& GLRenderer::getOverlay (int newcam) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1746 | { return m_overlays[newcam]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1747 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1748 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1749 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1750 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1751 | void GLRenderer::zoomNotch (bool inward) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1752 | { if (zoom() > 15) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1753 | zoom() *= inward ? 0.833f : 1.2f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1754 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1755 | zoom() += inward ? -1.2f : 1.2f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1756 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1757 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1758 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1759 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1760 | void GLRenderer::zoomToFit() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1761 | { if (getFile() == null || m_width == -1 || m_height == -1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1762 | { zoom() = 30.0f; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1763 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1764 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1765 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1766 | bool lastfilled = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1767 | bool firstrun = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1768 | const uint32 white = 0xFFFFFFFF; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1769 | bool inward = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1770 | const int w = m_width, h = m_height; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1771 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1772 | glClearColor (1.0, 1.0, 1.0, 1.0); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1773 | glDisable (GL_DITHER); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1774 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1775 | // Use the pick list while drawing the scene, this way we can tell whether borders |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1776 | // are background or not. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1777 | setPicking (true); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1778 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1779 | for (;;) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1780 | { if (zoom() > 10000.0 || zoom() < 0.0) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1781 | { // Obviously, there's nothing to draw if we get here. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1782 | // Default to 30.0f and break out. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1783 | zoom() = 30.0; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1784 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1785 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1786 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1787 | zoomNotch (inward); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1788 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1789 | uchar* cap = new uchar[4 * w * h]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1790 | drawGLScene(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1791 | glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1792 | uint32* imgdata = reinterpret_cast<uint32*> (cap); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1793 | bool filled = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1794 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1795 | // Check the top and bottom rows |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1796 | for (int i = 0; i < w && !filled; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1797 | if (imgdata[i] != white || imgdata[((h - 1) * w) + i] != white) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1798 | filled = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1799 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1800 | // Left and right edges |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1801 | for (int i = 0; i < h && !filled; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1802 | if (imgdata[i * w] != white || imgdata[(i * w) + w - 1] != white) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1803 | filled = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1804 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1805 | delete[] cap; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1806 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1807 | if (firstrun) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1808 | { // If this is the first run, we don't know enough to determine |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1809 | // whether the zoom was to fit, so we mark in our knowledge so |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1810 | // far and start over. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1811 | inward = !filled; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1812 | firstrun = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1813 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1814 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1815 | { // If this run filled the screen and the last one did not, the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1816 | // last run had ideal zoom - zoom a bit back and we should reach it. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1817 | if (filled && !lastfilled) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1818 | { zoomNotch (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1819 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1820 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1821 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1822 | // If this run did not fill the screen and the last one did, we've |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1823 | // now reached ideal zoom so we're done here. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1824 | if (!filled && lastfilled) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1825 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1826 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1827 | inward = !filled; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1828 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1829 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1830 | lastfilled = filled; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1831 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1832 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1833 | setBackground(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1834 | setPicking (false); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1835 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1836 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1837 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1838 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1839 | void GLRenderer::zoomAllToFit() |
564
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
1840 | { /* |
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
1841 | EFixedCamera oldcam = camera(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1842 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1843 | for (int i = 0; i < 7; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1844 | { setCamera ((EFixedCamera) i); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1845 | zoomToFit(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1846 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1847 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1848 | setCamera (oldcam); |
564
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
1849 | */ |
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
1850 | |
79b23e02dcf1
- implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
1851 | zoomToFit(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1852 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1853 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1854 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1855 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1856 | void GLRenderer::updateRectVerts() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1857 | { if (!m_rectdraw) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1858 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1859 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1860 | if (m_drawedVerts.isEmpty()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1861 | { for (int i = 0; i < 4; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1862 | m_rectverts[i] = m_hoverpos; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1863 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1864 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1865 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1866 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1867 | vertex v0 = m_drawedVerts[0], |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1868 | v1 = (m_drawedVerts.size() >= 2) ? m_drawedVerts[1] : m_hoverpos; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1869 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1870 | const Axis ax = getCameraAxis (false), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1871 | ay = getCameraAxis (true), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1872 | az = (Axis) (3 - ax - ay); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1873 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1874 | for (int i = 0; i < 4; ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1875 | m_rectverts[i][az] = getDepthValue(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1876 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1877 | m_rectverts[0][ax] = v0[ax]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1878 | m_rectverts[0][ay] = v0[ay]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1879 | m_rectverts[1][ax] = v1[ax]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1880 | m_rectverts[1][ay] = v0[ay]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1881 | m_rectverts[2][ax] = v1[ax]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1882 | m_rectverts[2][ay] = v1[ay]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1883 | m_rectverts[3][ax] = v0[ax]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1884 | m_rectverts[3][ay] = v1[ay]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1885 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1886 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1887 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1888 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1889 | void GLRenderer::mouseDoubleClickEvent (QMouseEvent* ev) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1890 | { if (!(ev->buttons() & Qt::LeftButton) || getEditMode() != ESelectMode) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1891 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1892 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1893 | pick (ev->x(), ev->y()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1894 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1895 | if (selection().isEmpty()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1896 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1897 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1898 | g_win->beginAction (null); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1899 | LDObject* obj = selection().first(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1900 | AddObjectDialog::staticDialog (obj->getType(), obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1901 | g_win->endAction(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1902 | ev->accept(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1903 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1904 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1905 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1906 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1907 | LDOverlay* GLRenderer::findOverlayObject (EFixedCamera cam) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1908 | { LDOverlay* ovlobj = null; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1909 | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1910 | for (LDObject* obj : getFile()->getObjects()) |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1911 | { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1912 | { ovlobj = static_cast<LDOverlay*> (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1913 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1914 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1915 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1916 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1917 | return ovlobj; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1918 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1919 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1920 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1921 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1922 | // Read in overlays from the current file and update overlay info accordingly. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1923 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1924 | void GLRenderer::initOverlaysFromObjects() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1925 | { for (EFixedCamera cam : g_Cameras) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1926 | { if (cam == EFreeCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1927 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1928 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1929 | LDGLOverlay& meta = m_overlays[cam]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1930 | LDOverlay* ovlobj = findOverlayObject (cam); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1931 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1932 | if (!ovlobj && meta.img) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1933 | { delete meta.img; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1934 | meta.img = null; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1935 | } elif (ovlobj && (!meta.img || meta.fname != ovlobj->getFileName())) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1936 | setupOverlay (cam, ovlobj->getFileName(), ovlobj->getX(), |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1937 | ovlobj->getY(), ovlobj->getWidth(), ovlobj->getHeight()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1938 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1939 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1940 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1941 | // ============================================================================= |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1942 | // ----------------------------------------------------------------------------- |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1943 | void GLRenderer::updateOverlayObjects() |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1944 | { for (EFixedCamera cam : g_Cameras) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1945 | { if (cam == EFreeCamera) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1946 | continue; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1947 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1948 | LDGLOverlay& meta = m_overlays[cam]; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1949 | LDOverlay* ovlobj = findOverlayObject (cam); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1950 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1951 | if (!meta.img && ovlobj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1952 | { // If this is the last overlay image, we need to remove the empty space after it as well. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1953 | LDObject* nextobj = ovlobj->next(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1954 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1955 | if (nextobj && nextobj->getType() == LDObject::Empty) |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1956 | nextobj->deleteSelf(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1957 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1958 | // If the overlay object was there and the overlay itself is |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1959 | // not, remove the object. |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
1960 | ovlobj->deleteSelf(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1961 | } elif (meta.img && !ovlobj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1962 | { // Inverse case: image is there but the overlay object is |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1963 | // not, thus create the object. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1964 | ovlobj = new LDOverlay; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1965 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1966 | // Find a suitable position to place this object. We want to place |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1967 | // this into the header, which is everything up to the first scemantic |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1968 | // object. If we find another overlay object, place this object after |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1969 | // the last one found. Otherwise, place it before the first schemantic |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1970 | // object and put an empty object after it (though don't do this if |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1971 | // there was no schemantic elements at all) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1972 | int i, lastOverlay = -1; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1973 | bool found = false; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1974 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1975 | for (i = 0; i < getFile()->getObjectCount(); ++i) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1976 | { LDObject* obj = getFile()->getObject (i); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1977 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1978 | if (obj->isScemantic()) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1979 | { found = true; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1980 | break; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1981 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1982 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1983 | if (obj->getType() == LDObject::Overlay) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1984 | lastOverlay = i; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1985 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1986 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1987 | if (lastOverlay != -1) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1988 | getFile()->insertObj (lastOverlay + 1, ovlobj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1989 | else |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1990 | { getFile()->insertObj (i, ovlobj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1991 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1992 | if (found) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1993 | getFile()->insertObj (i + 1, new LDEmpty); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1994 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1995 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1996 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1997 | if (meta.img && ovlobj) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1998 | { ovlobj->setCamera (cam); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1999 | ovlobj->setFileName (meta.fname); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2000 | ovlobj->setX (meta.ox); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2001 | ovlobj->setY (meta.oy); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2002 | ovlobj->setWidth (meta.lw); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2003 | ovlobj->setHeight (meta.lh); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2004 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2005 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2006 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2007 | if (g_win->R() == this) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2008 | g_win->refresh(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2009 | } |