Thu, 04 Jan 2018 22:52:04 +0200
undo config change
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1222 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
19 | #define GL_GLEXT_PROTOTYPES |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
20 | #include <GL/glu.h> |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
21 | #include <GL/glext.h> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QGLWidget> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QWheelEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QMouseEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QContextMenuEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include <QInputDialog> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include <QToolTip> |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
28 | #include <QTextDocument> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include <QTimer> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include <GL/glu.h> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "main.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "ldDocument.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "glRenderer.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | #include "colors.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
958
diff
changeset
|
35 | #include "mainwindow.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | #include "miscallenous.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | #include "editHistory.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | #include "dialogs.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | #include "addObjectDialog.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | #include "messageLog.h" |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
41 | #include "glCompiler.h" |
827 | 42 | #include "primitives.h" |
998 | 43 | #include "documentmanager.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
45 | const LDFixedCamera g_FixedCameras[6] = |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | { |
742
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
47 | {{ 1, 0, 0 }, X, Z, false, false, false }, // top |
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
48 | {{ 0, 0, 0 }, X, Y, false, true, false }, // front |
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
49 | {{ 0, 1, 0 }, Z, Y, true, true, false }, // left |
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
50 | {{ -1, 0, 0 }, X, Z, false, true, true }, // bottom |
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
51 | {{ 0, 0, 0 }, X, Y, true, true, true }, // back |
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
52 | {{ 0, -1, 0 }, Z, Y, false, true, true }, // right |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
1217 | 55 | ConfigOption(QColor BackgroundColor = "#FFFFFF") |
56 | ConfigOption(QColor MainColor = "#A0A0A0") | |
57 | ConfigOption(float MainColorAlpha = 1.0) | |
58 | ConfigOption(int LineThickness = 2) | |
59 | ConfigOption(bool BfcRedGreenView = false) | |
60 | ConfigOption(int Camera = 6) | |
61 | ConfigOption(bool BlackEdges = false) | |
62 | ConfigOption(bool DrawAxes = false) | |
63 | ConfigOption(bool DrawWireframe = false) | |
64 | ConfigOption(bool UseLogoStuds = false) | |
65 | ConfigOption(bool AntiAliasedLines = true) | |
66 | ConfigOption(bool RandomColors = false) | |
67 | ConfigOption(bool HighlightObjectBelowCursor = true) | |
68 | ConfigOption(bool DrawSurfaces = true) | |
69 | ConfigOption(bool DrawEdgeLines = true) | |
70 | ConfigOption(bool DrawConditionalLines = true) | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // |
1217 | 74 | GLRenderer::GLRenderer(QWidget* parent) : |
75 | QGLWidget(parent), | |
76 | HierarchyElement(parent), | |
77 | m_document(nullptr), | |
78 | m_initialized(false) | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | { |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
80 | m_isPicking = false; |
1224 | 81 | m_camera = (ECamera) config->camera(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | m_drawToolTip = false; |
1217 | 83 | m_currentEditMode = AbstractEditMode::createByType(this, EditModeType::Select); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | m_panning = false; |
1217 | 85 | m_compiler = new GLCompiler(this); |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
86 | m_objectAtCursor = nullptr; |
1217 | 87 | setDrawOnly(false); |
88 | m_messageLog = new MessageManager(this); | |
89 | m_messageLog->setRenderer(this); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | m_width = m_height = -1; |
1218
e0b59d183f96
replaced Origin with default-constructed Vertex
Santeri Piippo
parents:
1217
diff
changeset
|
91 | m_position3D = Vertex {}; |
1217 | 92 | m_toolTipTimer = new QTimer(this); |
93 | m_toolTipTimer->setSingleShot(true); | |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
94 | m_isCameraMoving = false; |
1217 | 95 | m_thinBorderPen = QPen(QColor(0, 0, 0, 208), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
96 | m_thinBorderPen.setWidth(1); | |
97 | setAcceptDrops(true); | |
98 | connect(m_toolTipTimer, SIGNAL(timeout()), this, SLOT(slot_toolTipTimer())); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | // Init camera icons |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
760
diff
changeset
|
101 | for (ECamera cam = EFirstCamera; cam < ENumCameras; ++cam) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
103 | const char* cameraIconNames[ENumCameras] = |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
104 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
105 | "camera-top", "camera-front", "camera-left", |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
106 | "camera-bottom", "camera-back", "camera-right", |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
107 | "camera-free" |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
108 | }; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
109 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | CameraIcon* info = &m_cameraIcons[cam]; |
1217 | 111 | info->image = new QPixmap(GetIcon(cameraIconNames[cam])); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | info->cam = cam; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | calcCameraIcons(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | GLRenderer::~GLRenderer() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | { |
1217 | 122 | for (int i = 0; i < countof(currentDocumentData().overlays); ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | delete currentDocumentData().overlays[i].img; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | for (CameraIcon& info : m_cameraIcons) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
126 | delete info.image; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
127 | |
857
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
856
diff
changeset
|
128 | if (messageLog()) |
1217 | 129 | messageLog()->setRenderer(nullptr); |
857
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
856
diff
changeset
|
130 | |
1217 | 131 | m_compiler->setRenderer(nullptr); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
132 | delete m_compiler; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
133 | delete m_currentEditMode; |
1217 | 134 | glDeleteBuffers(1, &m_axesVbo); |
135 | glDeleteBuffers(1, &m_axesColorVbo); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | // Calculates the "hitboxes" of the camera icons so that we can tell when the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | // cursor is pointing at the camera icon. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | void GLRenderer::calcCameraIcons() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | int i = 0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | for (CameraIcon& info : m_cameraIcons) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | // MATH |
1217 | 149 | int x1 = (m_width -(info.cam != EFreeCamera ? 48 : 16)) +((i % 3) * 16) - 1; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
150 | int y1 = ((i / 3) * 16) + 1; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | |
1217 | 152 | info.sourceRect = QRect(0, 0, 16, 16); |
153 | info.targetRect = QRect(x1, y1, 16, 16); | |
154 | info.selRect = QRect( | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
155 | info.targetRect.x(), |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
156 | info.targetRect.y(), |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
157 | info.targetRect.width() + 1, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
158 | info.targetRect.height() + 1 |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | ); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | ++i; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | void GLRenderer::initGLData() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | { |
1217 | 169 | glEnable(GL_BLEND); |
170 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
171 | glEnable(GL_POLYGON_OFFSET_FILL); | |
172 | glPolygonOffset(1.0f, 1.0f); | |
173 | glEnable(GL_DEPTH_TEST); | |
174 | glShadeModel(GL_SMOOTH); | |
175 | glEnable(GL_MULTISAMPLE); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | |
1224 | 177 | if (config->antiAliasedLines()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | { |
1217 | 179 | glEnable(GL_LINE_SMOOTH); |
180 | glEnable(GL_POLYGON_SMOOTH); | |
181 | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); | |
182 | glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
183 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
184 | else |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | { |
1217 | 186 | glDisable(GL_LINE_SMOOTH); |
187 | glDisable(GL_POLYGON_SMOOTH); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
191 | bool GLRenderer::isDrawOnly() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
192 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
193 | return m_isDrawOnly; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
194 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
195 | |
1217 | 196 | void GLRenderer::setDrawOnly(bool value) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
197 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
198 | m_isDrawOnly = value; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
199 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
200 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
201 | MessageManager* GLRenderer::messageLog() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
202 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
203 | return m_messageLog; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
204 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
205 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
206 | bool GLRenderer::isPicking() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
207 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
208 | return m_isPicking; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
209 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
210 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
211 | LDDocument* GLRenderer::document() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
212 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
213 | return m_document; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
214 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
215 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
216 | GLCompiler* GLRenderer::compiler() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
217 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
218 | return m_compiler; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
219 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
220 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
221 | LDObject* GLRenderer::objectAtCursor() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
222 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
223 | return m_objectAtCursor; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
224 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
225 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | // |
738
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
228 | void GLRenderer::needZoomToFit() |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
229 | { |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
230 | if (document()) |
738
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
231 | currentDocumentData().needZoomToFit = true; |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
232 | } |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
233 | |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
234 | // ============================================================================= |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
235 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | void GLRenderer::resetAngles() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | { |
1217 | 238 | rotation(X) = 30.0f; |
239 | rotation(Y) = 325.f; | |
240 | panning(X) = panning(Y) = rotation(Z) = 0.0f; | |
738
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
241 | needZoomToFit(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | void GLRenderer::resetAllAngles() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | { |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
760
diff
changeset
|
248 | ECamera oldcam = camera(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | for (int i = 0; i < 7; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | { |
1217 | 252 | setCamera((ECamera) i); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | resetAngles(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | |
1217 | 256 | setCamera(oldcam); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | void GLRenderer::initializeGL() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | { |
856
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
263 | #ifdef USE_QT5 |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
264 | initializeOpenGLFunctions(); |
856
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
265 | #endif |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | setBackground(); |
1224 | 267 | glLineWidth(config->lineThickness()); |
1217 | 268 | glLineStipple(1, 0x6666); |
269 | setAutoFillBackground(false); | |
270 | setMouseTracking(true); | |
271 | setFocusPolicy(Qt::WheelFocus); | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
272 | compiler()->initialize(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
273 | initializeAxes(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
274 | m_initialized = true; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
275 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
276 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
277 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
278 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
279 | void GLRenderer::initializeAxes() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
280 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
281 | // Definitions for visual axes, drawn on the screen |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
282 | struct AxisInfo |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
283 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
284 | QColor color; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
285 | Vertex extrema; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
286 | }; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
287 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
288 | static const AxisInfo axisinfo[3] = |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
289 | { |
1217 | 290 | { QColor(192, 96, 96), Vertex(10000, 0, 0) }, // X |
291 | { QColor(48, 192, 48), Vertex(0, 10000, 0) }, // Y | |
292 | { QColor(48, 112, 192), Vertex(0, 0, 10000) }, // Z | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
293 | }; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
294 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
295 | float axisdata[18]; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
296 | float colordata[18]; |
1217 | 297 | memset(axisdata, 0, sizeof axisdata); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
298 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
299 | for (int i = 0; i < 3; ++i) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
300 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
301 | const AxisInfo& data = axisinfo[i]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
302 | |
1217 | 303 | for_axes(ax) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
304 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
305 | axisdata[(i * 6) + ax] = data.extrema[ax]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
306 | axisdata[(i * 6) + 3 + ax] = -data.extrema[ax]; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
307 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
308 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
309 | int offset = i * 6; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
310 | colordata[offset + 0] = colordata[offset + 3] = data.color.red(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
311 | colordata[offset + 1] = colordata[offset + 4] = data.color.green(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
312 | colordata[offset + 2] = colordata[offset + 5] = data.color.blue(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
313 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
314 | |
1217 | 315 | glGenBuffers(1, &m_axesVbo); |
316 | glBindBuffer(GL_ARRAY_BUFFER, m_axesVbo); | |
317 | glBufferData(GL_ARRAY_BUFFER, sizeof axisdata, axisdata, GL_STATIC_DRAW); | |
318 | glGenBuffers(1, &m_axesColorVbo); | |
319 | glBindBuffer(GL_ARRAY_BUFFER, m_axesColorVbo); | |
320 | glBufferData(GL_ARRAY_BUFFER, sizeof colordata, colordata, GL_STATIC_DRAW); | |
321 | glBindBuffer(GL_ARRAY_BUFFER, 0); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | void GLRenderer::setBackground() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | { |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
328 | if (isPicking()) |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
329 | { |
1217 | 330 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
331 | return; |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
332 | } |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
333 | |
1224 | 334 | QColor color = config->backgroundColor(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | |
973
c1b60c7d5135
Change color config types into actual colors now that I can do that
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
336 | if (not color.isValid()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | |
1217 | 339 | color.setAlpha(255); |
340 | m_useDarkBackground = luma(color) < 80; | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
341 | m_backgroundColor = color; |
1217 | 342 | qglClearColor(color); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | void GLRenderer::refresh() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | update(); |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
350 | |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
351 | if (isVisible()) |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
352 | swapBuffers(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | void GLRenderer::hardRefresh() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
359 | if (m_initialized) |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
360 | { |
1217 | 361 | compiler()->compileDocument(currentDocument()); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
362 | refresh(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
363 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | // |
1217 | 368 | void GLRenderer::resizeGL(int w, int h) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | m_width = w; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | m_height = h; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | calcCameraIcons(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | |
1217 | 375 | glViewport(0, 0, w, h); |
376 | glMatrixMode(GL_PROJECTION); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | glLoadIdentity(); |
1217 | 378 | gluPerspective(45.0f,(double) w /(double) h, 1.0f, 40000.0f); |
379 | glMatrixMode(GL_MODELVIEW); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | void GLRenderer::drawGLScene() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | { |
984 | 386 | if (document() == nullptr) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
387 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | |
737
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
389 | if (currentDocumentData().needZoomToFit) |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
390 | { |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
391 | currentDocumentData().needZoomToFit = false; |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
392 | zoomAllToFit(); |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
393 | } |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
394 | |
1224 | 395 | if (config->drawWireframe() and not isPicking()) |
1217 | 396 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | |
1217 | 398 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
399 | glEnable(GL_DEPTH_TEST); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
401 | if (camera() != EFreeCamera) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | { |
1217 | 403 | glMatrixMode(GL_PROJECTION); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | glPushMatrix(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
405 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | glLoadIdentity(); |
1217 | 407 | glOrtho(-m_virtualWidth, m_virtualWidth, -m_virtualHeight, m_virtualHeight, -200.0f, 200.0f); |
408 | glTranslatef(panning(X), panning(Y), 0.0f); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
410 | if (camera() != EFrontCamera and camera() != EBackCamera) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | { |
1217 | 412 | glRotatef(90.0f, g_FixedCameras[camera()].glrotate[0], |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | g_FixedCameras[camera()].glrotate[1], |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | g_FixedCameras[camera()].glrotate[2]); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | // Back camera needs to be handled differently |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
418 | if (camera() == EBackCamera) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | { |
1217 | 420 | glRotatef(180.0f, 1.0f, 0.0f, 0.0f); |
421 | glRotatef(180.0f, 0.0f, 0.0f, 1.0f); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | { |
1217 | 426 | glMatrixMode(GL_MODELVIEW); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | glPushMatrix(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | glLoadIdentity(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | |
1217 | 430 | glTranslatef(0.0f, 0.0f, -2.0f); |
431 | glTranslatef(panning(X), panning(Y), -zoom()); | |
432 | glRotatef(rotation(X), 1.0f, 0.0f, 0.0f); | |
433 | glRotatef(rotation(Y), 0.0f, 1.0f, 0.0f); | |
434 | glRotatef(rotation(Z), 0.0f, 0.0f, 1.0f); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | |
1217 | 437 | glEnableClientState(GL_VERTEX_ARRAY); |
438 | glEnableClientState(GL_COLOR_ARRAY); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
440 | if (isPicking()) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
441 | { |
1217 | 442 | drawVbos(TrianglesVbo, PickColorsVboComplement, GL_TRIANGLES); |
443 | drawVbos(QuadsVbo, PickColorsVboComplement, GL_QUADS); | |
444 | drawVbos(LinesVbo, PickColorsVboComplement, GL_LINES); | |
445 | drawVbos(ConditionalLinesVbo, PickColorsVboComplement, GL_LINES); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | { |
1224 | 449 | if (config->bfcRedGreenView()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
450 | { |
1217 | 451 | glEnable(GL_CULL_FACE); |
452 | glCullFace(GL_BACK); | |
453 | drawVbos(TrianglesVbo, BfcFrontColorsVboComplement, GL_TRIANGLES); | |
454 | drawVbos(QuadsVbo, BfcFrontColorsVboComplement, GL_QUADS); | |
455 | glCullFace(GL_FRONT); | |
456 | drawVbos(TrianglesVbo, BfcBackColorsVboComplement, GL_TRIANGLES); | |
457 | drawVbos(QuadsVbo, BfcBackColorsVboComplement, GL_QUADS); | |
458 | glDisable(GL_CULL_FACE); | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
459 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
460 | else |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
461 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
462 | ComplementVboType colors; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
463 | |
1224 | 464 | if (config->randomColors()) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
465 | colors = RandomColorsVboComplement; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
466 | else |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
467 | colors = NormalColorsVboComplement; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
468 | |
1217 | 469 | drawVbos(TrianglesVbo, colors, GL_TRIANGLES); |
470 | drawVbos(QuadsVbo, colors, GL_QUADS); | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
471 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
472 | |
1217 | 473 | drawVbos(LinesVbo, NormalColorsVboComplement, GL_LINES); |
474 | glEnable(GL_LINE_STIPPLE); | |
475 | drawVbos(ConditionalLinesVbo, NormalColorsVboComplement, GL_LINES); | |
476 | glDisable(GL_LINE_STIPPLE); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | |
1224 | 478 | if (config->drawAxes()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
479 | { |
1217 | 480 | glBindBuffer(GL_ARRAY_BUFFER, m_axesVbo); |
481 | glVertexPointer(3, GL_FLOAT, 0, NULL); | |
482 | glBindBuffer(GL_ARRAY_BUFFER, m_axesVbo); | |
483 | glColorPointer(3, GL_FLOAT, 0, NULL); | |
484 | glDrawArrays(GL_LINES, 0, 6); | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
485 | CHECK_GL_ERROR(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
486 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
487 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
488 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
489 | glPopMatrix(); |
1217 | 490 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
491 | glDisableClientState(GL_VERTEX_ARRAY); | |
492 | glDisableClientState(GL_COLOR_ARRAY); | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
493 | CHECK_GL_ERROR(); |
1217 | 494 | glDisable(GL_CULL_FACE); |
495 | glMatrixMode(GL_MODELVIEW); | |
496 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
497 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | // |
1217 | 501 | void GLRenderer::drawVbos(SurfaceVboType surface, ComplementVboType colors, GLenum type) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
502 | { |
815
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
503 | // Filter this through some configuration options |
1224 | 504 | if ((isOneOf(surface, QuadsVbo, TrianglesVbo) and config->drawSurfaces() == false) |
505 | or(surface == LinesVbo and config->drawEdgeLines() == false) | |
506 | or(surface == ConditionalLinesVbo and config->drawConditionalLines() == false)) | |
815
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
507 | { |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
508 | return; |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
509 | } |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
510 | |
1217 | 511 | int surfacenum = m_compiler->vboNumber(surface, SurfacesVboComplement); |
512 | int colornum = m_compiler->vboNumber(surface, colors); | |
513 | m_compiler->prepareVBO(surfacenum); | |
514 | m_compiler->prepareVBO(colornum); | |
515 | GLuint surfacevbo = m_compiler->vbo(surfacenum); | |
516 | GLuint colorvbo = m_compiler->vbo(colornum); | |
517 | GLsizei count = m_compiler->vboSize(surfacenum) / 3; | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
518 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
519 | if (count > 0) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
520 | { |
1217 | 521 | glBindBuffer(GL_ARRAY_BUFFER, surfacevbo); |
522 | glVertexPointer(3, GL_FLOAT, 0, nullptr); | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
523 | CHECK_GL_ERROR(); |
1217 | 524 | glBindBuffer(GL_ARRAY_BUFFER, colorvbo); |
525 | glColorPointer(4, GL_FLOAT, 0, nullptr); | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
526 | CHECK_GL_ERROR(); |
1217 | 527 | glDrawArrays(type, 0, count); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
528 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
529 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
530 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
531 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
532 | // ============================================================================= |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
533 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | // This converts a 2D point on the screen to a 3D point in the model. If 'snap' |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | // is true, the 3D point will snap to the current grid. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
536 | // |
1217 | 537 | Vertex GLRenderer::convert2dTo3d(const QPoint& pos2d, bool snap) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
539 | if (camera() == EFreeCamera) |
1218
e0b59d183f96
replaced Origin with default-constructed Vertex
Santeri Piippo
parents:
1217
diff
changeset
|
540 | return {}; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | Vertex pos3d; |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
543 | const LDFixedCamera* cam = &g_FixedCameras[camera()]; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
544 | const Axis axisX = cam->localX; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
545 | const Axis axisY = cam->localY; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
546 | const int negXFac = cam->negatedX ? -1 : 1, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
547 | negYFac = cam->negatedY ? -1 : 1; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
548 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
549 | // Calculate cx and cy - these are the LDraw unit coords the cursor is at. |
1217 | 550 | double cx = (-m_virtualWidth +((2 * pos2d.x() * m_virtualWidth) / m_width) - panning(X)); |
551 | double cy = (m_virtualHeight -((2 * pos2d.y() * m_virtualHeight) / m_height) - panning(Y)); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
553 | if (snap) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | { |
1217 | 555 | cx = Grid::Snap(cx, Grid::Coordinate); |
556 | cy = Grid::Snap(cy, Grid::Coordinate); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
559 | cx *= negXFac; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
560 | cy *= negYFac; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
561 | |
1223 | 562 | cx = RoundToDecimals(cx, 4); |
563 | cy = RoundToDecimals(cy, 4); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | // Create the vertex from the coordinates |
1217 | 566 | pos3d.setCoordinate(axisX, cx); |
567 | pos3d.setCoordinate(axisY, cy); | |
568 | pos3d.setCoordinate((Axis)(3 - axisX - axisY), getDepthValue()); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | return pos3d; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
570 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | // |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
574 | // Inverse operation for the above - convert a 3D position to a 2D screen position. Don't ask me how this code manages |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
575 | // to work, I don't even know. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | // |
1217 | 577 | QPoint GLRenderer::convert3dTo2d(const Vertex& pos3d) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
578 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
579 | if (camera() == EFreeCamera) |
1217 | 580 | return QPoint(0, 0); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
581 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
582 | const LDFixedCamera* cam = &g_FixedCameras[camera()]; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
583 | const Axis axisX = cam->localX; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
584 | const Axis axisY = cam->localY; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
585 | const int negXFac = cam->negatedX ? -1 : 1; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
586 | const int negYFac = cam->negatedY ? -1 : 1; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
587 | GLfloat matrix[16]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | const double x = pos3d.x(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
589 | const double y = pos3d.y(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
590 | const double z = pos3d.z(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
591 | Vertex transformed; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
592 | |
1217 | 593 | glGetFloatv(GL_MODELVIEW_MATRIX, matrix); |
594 | transformed.setX((matrix[0] * x) +(matrix[1] * y) +(matrix[2] * z) + matrix[3]); | |
595 | transformed.setY((matrix[4] * x) +(matrix[5] * y) +(matrix[6] * z) + matrix[7]); | |
596 | transformed.setZ((matrix[8] * x) +(matrix[9] * y) +(matrix[10] * z) + matrix[11]); | |
597 | double rx = (((transformed[axisX] * negXFac) + m_virtualWidth + panning(X)) * m_width) /(2 * m_virtualWidth); | |
598 | double ry = (((transformed[axisY] * negYFac) - m_virtualHeight + panning(Y)) * m_height) /(2 * m_virtualHeight); | |
599 | return QPoint(rx, -ry); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
600 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
601 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
602 | QPen GLRenderer::textPen() const |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
603 | { |
1217 | 604 | return QPen(m_useDarkBackground ? Qt::white : Qt::black); |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
605 | } |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
606 | |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
607 | QPen GLRenderer::linePen() const |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
608 | { |
1217 | 609 | QPen linepen(m_thinBorderPen); |
610 | linepen.setWidth(2); | |
611 | linepen.setColor(luma(m_backgroundColor) < 40 ? Qt::white : Qt::black); | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
612 | return linepen; |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
613 | } |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
614 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
615 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
616 | // |
1217 | 617 | void GLRenderer::paintEvent(QPaintEvent*) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | { |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
619 | doMakeCurrent(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
620 | m_virtualWidth = zoom(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
621 | m_virtualHeight = (m_height * m_virtualWidth) / m_width; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
622 | initGLData(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | drawGLScene(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | |
1217 | 625 | QPainter paint(this); |
626 | QFontMetrics metrics = QFontMetrics(QFont()); | |
627 | paint.setRenderHint(QPainter::HighQualityAntialiasing); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
628 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | // If we wish to only draw the brick, stop here |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | if (isDrawOnly()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
633 | #ifndef RELEASE |
713
46377d340c23
- more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents:
708
diff
changeset
|
634 | if (not isPicking()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
635 | { |
1217 | 636 | QString text = format("Rotation:(%1°, %2°, %3°)\nPanning:(%4, %5), Zoom: %6", |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
637 | rotation(X), rotation(Y), rotation(Z), panning(X), panning(Y), zoom()); |
1217 | 638 | QRect textSize = metrics.boundingRect(0, 0, m_width, m_height, Qt::AlignCenter, text); |
639 | paint.setPen(textPen()); | |
640 | paint.drawText((width() - textSize.width()) / 2, height() - textSize.height(), textSize.width(), | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
641 | textSize.height(), Qt::AlignCenter, text); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
642 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
643 | #endif |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
644 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
645 | if (camera() != EFreeCamera and not isPicking()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | // Paint the overlay image if we have one |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
648 | const LDGLOverlay& overlay = currentDocumentData().overlays[camera()]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
649 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
650 | if (overlay.img) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | { |
1217 | 652 | QPoint v0 = convert3dTo2d(currentDocumentData().overlays[camera()].v0); |
653 | QPoint v1 = convert3dTo2d(currentDocumentData().overlays[camera()].v1); | |
654 | QRect targetRect(v0.x(), v0.y(), qAbs(v1.x() - v0.x()), qAbs(v1.y() - v0.y())); | |
655 | QRect sourceRect(0, 0, overlay.img->width(), overlay.img->height()); | |
656 | paint.drawImage(targetRect, *overlay.img, sourceRect); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | // Paint the coordinates onto the screen. |
1217 | 660 | QString text = format(tr("X: %1, Y: %2, Z: %3"), m_position3D[X], m_position3D[Y], m_position3D[Z]); |
661 | QFontMetrics metrics = QFontMetrics(font()); | |
662 | QRect textSize = metrics.boundingRect(0, 0, m_width, m_height, Qt::AlignCenter, text); | |
663 | paint.setPen(textPen()); | |
664 | paint.drawText(m_width - textSize.width(), m_height - 16, textSize.width(), | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | textSize.height(), Qt::AlignCenter, text); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
668 | if (not isPicking()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | { |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
670 | // Draw edit mode HUD |
1217 | 671 | m_currentEditMode->render(paint); |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
672 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | // Draw a background for the selected camera |
1217 | 674 | paint.setPen(m_thinBorderPen); |
675 | paint.setBrush(QBrush(QColor(0, 128, 160, 128))); | |
676 | paint.drawRect(m_cameraIcons[camera()].selRect); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
677 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
678 | // Draw the camera icons |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | for (CameraIcon& info : m_cameraIcons) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
681 | // Don't draw the free camera icon when we can't use the free camera |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
682 | if (&info == &m_cameraIcons[EFreeCamera] and not m_currentEditMode->allowFreeCamera()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | continue; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | |
1217 | 685 | paint.drawPixmap(info.targetRect, *info.image, info.sourceRect); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
687 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
688 | // Draw a label for the current camera in the bottom left corner |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | const int margin = 4; |
1217 | 691 | paint.setPen(textPen()); |
692 | paint.drawText(QPoint(margin, height() -(margin + metrics.descent())), currentCameraName()); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
693 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
695 | // Tool tips |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | if (m_drawToolTip) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | { |
1217 | 698 | if (not m_cameraIcons[m_toolTipCamera].targetRect.contains(m_mousePosition)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | m_drawToolTip = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | else |
1217 | 701 | QToolTip::showText(m_globalpos, currentCameraName()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
703 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
704 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
705 | // Message log |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
706 | if (messageLog()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
707 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
708 | int y = 0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
709 | const int margin = 2; |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
710 | QColor penColor = textPen().color(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
711 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
712 | for (const MessageManager::Line& line : messageLog()->getLines()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
713 | { |
1217 | 714 | penColor.setAlphaF(line.alpha); |
715 | paint.setPen(penColor); | |
716 | paint.drawText(QPoint(margin, y + margin + metrics.ascent()), line.text); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
717 | y += metrics.height(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
718 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
721 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
722 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | // |
1217 | 724 | void GLRenderer::drawBlip(QPainter& painter, QPointF pos, QColor color) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | QPen pen = m_thinBorderPen; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
727 | const int blipsize = 8; |
1217 | 728 | pen.setWidth(1); |
729 | painter.setPen(pen); | |
730 | painter.setBrush(color); | |
731 | painter.drawEllipse(pos.x() - blipsize / 2, pos.y() - blipsize / 2, blipsize, blipsize); | |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1000
diff
changeset
|
732 | } |
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1000
diff
changeset
|
733 | |
1217 | 734 | void GLRenderer::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d) |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1000
diff
changeset
|
735 | { |
1217 | 736 | drawBlipCoordinates(painter, pos3d, convert3dTo2d(pos3d)); |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1000
diff
changeset
|
737 | } |
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1000
diff
changeset
|
738 | |
1217 | 739 | void GLRenderer::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1000
diff
changeset
|
740 | { |
1217 | 741 | painter.setPen(textPen()); |
742 | painter.drawText(pos.x(), pos.y() - 8, pos3d.toString(true)); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
743 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
744 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
745 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
746 | // |
1217 | 747 | void GLRenderer::clampAngle(double& angle) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
748 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
749 | while (angle < 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
750 | angle += 360.0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
751 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
752 | while (angle > 360.0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
753 | angle -= 360.0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
754 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
755 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
756 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
757 | // |
1217 | 758 | void GLRenderer::mouseReleaseEvent(QMouseEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
759 | { |
1217 | 760 | bool wasLeft = (m_lastButtons & Qt::LeftButton) and not(ev->buttons() & Qt::LeftButton); |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
761 | Qt::MouseButtons releasedbuttons = m_lastButtons & ~ev->buttons(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
762 | m_panning = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
763 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
764 | if (wasLeft) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
765 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
766 | // Check if we selected a camera icon |
827 | 767 | if (not mouseHasMoved()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
768 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
769 | for (CameraIcon & info : m_cameraIcons) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
770 | { |
1217 | 771 | if (info.targetRect.contains(ev->pos())) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
772 | { |
1217 | 773 | setCamera(info.cam); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
774 | goto end; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
775 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
776 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
777 | } |
827 | 778 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
779 | |
827 | 780 | if (not isDrawOnly()) |
781 | { | |
782 | AbstractEditMode::MouseEventData data; | |
783 | data.ev = ev; | |
784 | data.mouseMoved = mouseHasMoved(); | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
785 | data.keymods = m_currentKeyboardModifiers; |
827 | 786 | data.releasedButtons = releasedbuttons; |
824
6add2126e7ff
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
823
diff
changeset
|
787 | |
1217 | 788 | if (m_currentEditMode->mouseReleased(data)) |
827 | 789 | goto end; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
790 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
791 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
792 | end: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
793 | update(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
794 | m_totalMouseMove = 0; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
795 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
796 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
797 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
798 | // |
1217 | 799 | void GLRenderer::mousePressEvent(QMouseEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
800 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
801 | m_totalMouseMove = 0; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
802 | m_lastButtons = ev->buttons(); |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
803 | |
1217 | 804 | if (m_currentEditMode->mousePressed(ev)) |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
805 | ev->accept(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
806 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
807 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
808 | // ============================================================================= |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
809 | // |
1217 | 810 | void GLRenderer::mouseMoveEvent(QMouseEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
811 | { |
828
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
812 | int dx = ev->x() - m_mousePosition.x(); |
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
813 | int dy = ev->y() - m_mousePosition.y(); |
1217 | 814 | m_totalMouseMove += qAbs(dx) + qAbs(dy); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
815 | m_isCameraMoving = false; |
828
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
816 | |
1217 | 817 | if (not m_currentEditMode->mouseMoved(ev)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
818 | { |
827 | 819 | const bool left = ev->buttons() & Qt::LeftButton, |
820 | mid = ev->buttons() & Qt::MidButton, | |
821 | shift = ev->modifiers() & Qt::ShiftModifier; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
822 | |
1217 | 823 | if (mid or(left and shift)) |
827 | 824 | { |
1217 | 825 | panning(X) += 0.03f * dx *(zoom() / 7.5f); |
826 | panning(Y) -= 0.03f * dy *(zoom() / 7.5f); | |
827 | 827 | m_panning = true; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
828 | m_isCameraMoving = true; |
827 | 829 | } |
967 | 830 | else if (left and camera() == EFreeCamera) |
827 | 831 | { |
1217 | 832 | rotation(X) = rotation(X) + dy; |
833 | rotation(Y) = rotation(Y) + dx; | |
834 | clampAngle(rotation(X)); | |
835 | clampAngle(rotation(Y)); | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
836 | m_isCameraMoving = true; |
827 | 837 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
838 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
839 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
840 | // Start the tool tip timer |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
841 | if (not m_drawToolTip) |
1217 | 842 | m_toolTipTimer->start(500); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
843 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
844 | // Update 2d position |
766
df2a48223e53
- renamed some renderer members
Santeri Piippo <crimsondusk64@gmail.com>
parents:
763
diff
changeset
|
845 | m_mousePosition = ev->pos(); |
882
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
846 | m_globalpos = ev->globalPos(); |
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
847 | |
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
848 | #ifndef USE_QT5 |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
849 | m_mousePositionF = ev->posF(); |
882
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
850 | #else |
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
851 | m_mousePositionF = ev->localPos(); |
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
852 | #endif |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
853 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
854 | // Calculate 3d position of the cursor |
1218
e0b59d183f96
replaced Origin with default-constructed Vertex
Santeri Piippo
parents:
1217
diff
changeset
|
855 | m_position3D = (camera() != EFreeCamera) ? convert2dTo3d(m_mousePosition, true) : Vertex {}; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
856 | |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
857 | highlightCursorObject(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
858 | update(); |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
859 | ev->accept(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
860 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
861 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
862 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
863 | // |
1217 | 864 | void GLRenderer::keyPressEvent(QKeyEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
865 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
866 | m_currentKeyboardModifiers = ev->modifiers(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
867 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
868 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
869 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
870 | // |
1217 | 871 | void GLRenderer::keyReleaseEvent(QKeyEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
872 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
873 | m_currentKeyboardModifiers = ev->modifiers(); |
1217 | 874 | m_currentEditMode->keyReleased(ev); |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
869
diff
changeset
|
875 | update(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
876 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
877 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
878 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
879 | // |
1217 | 880 | void GLRenderer::wheelEvent(QWheelEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
881 | { |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
882 | doMakeCurrent(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
883 | |
1217 | 884 | zoomNotch(ev->delta() > 0); |
885 | zoom() = qBound(0.01, zoom(), 10000.0); | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
886 | m_isCameraMoving = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
887 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
888 | ev->accept(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
889 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
890 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
891 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
892 | // |
1217 | 893 | void GLRenderer::leaveEvent(QEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
894 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
895 | (void) ev; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
896 | m_drawToolTip = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
897 | m_toolTipTimer->stop(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
898 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
899 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
900 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
901 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
902 | // |
1217 | 903 | void GLRenderer::contextMenuEvent(QContextMenuEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
904 | { |
1217 | 905 | m_window->spawnContextMenu(ev->globalPos()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
906 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
907 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
908 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
909 | // |
1217 | 910 | void GLRenderer::setCamera(const ECamera cam) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
911 | { |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
912 | // The edit mode may forbid the free camera. |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
913 | if (cam == EFreeCamera and not m_currentEditMode->allowFreeCamera()) |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
914 | return; |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
915 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
916 | m_camera = cam; |
1224 | 917 | config->setCamera((int) cam); |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
918 | m_window->updateEditModeActions(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
919 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
920 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
921 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
922 | // |
1217 | 923 | void GLRenderer::pick(int mouseX, int mouseY, bool additive) |
827 | 924 | { |
1217 | 925 | pick(QRect(mouseX, mouseY, mouseX + 1, mouseY + 1), additive); |
827 | 926 | } |
927 | ||
928 | // ============================================================================= | |
929 | // | |
1217 | 930 | void GLRenderer::pick(QRect const& range, bool additive) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
931 | { |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
932 | doMakeCurrent(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
933 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
934 | // Clear the selection if we do not wish to add to it. |
827 | 935 | if (not additive) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
936 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
937 | LDObjectList oldSelection = selectedObjects(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
938 | currentDocument()->clearSelection(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
939 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
940 | for (LDObject* obj : oldSelection) |
1217 | 941 | compileObject(obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
942 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
943 | |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
944 | // Paint the picking scene |
1217 | 945 | setPicking(true); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
946 | drawGLScene(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
947 | |
827 | 948 | int x0 = range.left(); |
949 | int y0 = range.top(); | |
828
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
950 | int x1 = x0 + range.width(); |
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
951 | int y1 = y0 + range.height(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
952 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
953 | // Clamp the values to ensure they're within bounds |
1217 | 954 | x0 = qMax(0, x0); |
955 | y0 = qMax(0, y0); | |
956 | x1 = qMin(x1, m_width); | |
957 | y1 = qMin(y1, m_height); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
958 | const int areawidth = (x1 - x0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
959 | const int areaheight = (y1 - y0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
960 | const qint32 numpixels = areawidth * areaheight; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
961 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
962 | // Allocate space for the pixel data. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
963 | uchar* const pixeldata = new uchar[4 * numpixels]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
964 | uchar* pixelptr = &pixeldata[0]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
965 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
966 | // Read pixels from the color buffer. |
1217 | 967 | glReadPixels(x0, m_height - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
968 | |
946 | 969 | LDObject* removedObj = nullptr; |
752
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
970 | QList<qint32> indices; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
971 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
972 | // Go through each pixel read and add them to the selection. |
753 | 973 | // Note: black is background, those indices are skipped. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
974 | for (qint32 i = 0; i < numpixels; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
975 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
976 | qint32 idx = |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
977 | (*(pixelptr + 0) * 0x10000) + |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
978 | (*(pixelptr + 1) * 0x100) + |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
979 | *(pixelptr + 2); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
980 | pixelptr += 4; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
981 | |
752
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
982 | if (idx != 0) |
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
983 | indices << idx; |
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
984 | } |
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
985 | |
1217 | 986 | removeDuplicates(indices); |
752
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
987 | |
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
988 | for (qint32 idx : indices) |
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
989 | { |
1217 | 990 | LDObject* obj = LDObject::fromID(idx); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
991 | |
984 | 992 | if (obj == nullptr) |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
993 | continue; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
994 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
995 | // If this is an additive single pick and the object is currently selected, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
996 | // we remove it from selection instead. |
828
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
997 | if (additive) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
998 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
999 | if (obj->isSelected()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1000 | { |
767
44f0d5322628
- slight refactor in ldobject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
766
diff
changeset
|
1001 | obj->deselect(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1002 | removedObj = obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1003 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1004 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1005 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1006 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1007 | obj->select(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1008 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1009 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1010 | delete[] pixeldata; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1011 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1012 | // Update everything now. |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
1013 | m_window->updateSelection(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1014 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1015 | // Recompile the objects now to update their color |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
1016 | for (LDObject* obj : selectedObjects()) |
1217 | 1017 | compileObject(obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1018 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1019 | if (removedObj) |
1217 | 1020 | compileObject(removedObj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1021 | |
1217 | 1022 | setPicking(false); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1023 | repaint(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1024 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1025 | |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1026 | // |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1027 | // Simpler version of GLRenderer::pick which simply picks whatever object on the screen |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1028 | // |
1217 | 1029 | LDObject* GLRenderer::pickOneObject(int mouseX, int mouseY) |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1030 | { |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1031 | uchar pixel[4]; |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1032 | doMakeCurrent(); |
1217 | 1033 | setPicking(true); |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1034 | drawGLScene(); |
1217 | 1035 | glReadPixels(mouseX, m_height - mouseY, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); |
1036 | LDObject* obj = LDObject::fromID((pixel[0] * 0x10000) +(pixel[1] * 0x100) + pixel[2]); | |
1037 | setPicking(false); | |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1038 | repaint(); |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1039 | return obj; |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1040 | } |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1041 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1042 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1043 | // |
1217 | 1044 | void GLRenderer::setEditMode(EditModeType a) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1045 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1046 | if (m_currentEditMode and m_currentEditMode->type() == a) |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1047 | return; |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
1048 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1049 | delete m_currentEditMode; |
1217 | 1050 | m_currentEditMode = AbstractEditMode::createByType(this, a); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1051 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1052 | // If we cannot use the free camera, use the top one instead. |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1053 | if (camera() == EFreeCamera and not m_currentEditMode->allowFreeCamera()) |
1217 | 1054 | setCamera(ETopCamera); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1055 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
1056 | m_window->updateEditModeActions(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1057 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1058 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1059 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1060 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1061 | // |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1062 | EditModeType GLRenderer::currentEditModeType() const |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1063 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1064 | return m_currentEditMode->type(); |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1065 | } |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1066 | |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1067 | // ============================================================================= |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1068 | // |
1217 | 1069 | void GLRenderer::setDocument(LDDocument* document) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1070 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1071 | m_document = document; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1072 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1073 | if (document) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1074 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1075 | initOverlaysFromObjects(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1076 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1077 | if (not currentDocumentData().init) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1078 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1079 | resetAllAngles(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1080 | currentDocumentData().init = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1081 | } |
737
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
1082 | |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
1083 | currentDocumentData().needZoomToFit = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1084 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1085 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1086 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1087 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1088 | // |
1217 | 1089 | void GLRenderer::setPicking(bool value) |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1090 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1091 | m_isPicking = value; |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1092 | setBackground(); |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1093 | |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1094 | if (isPicking()) |
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1095 | { |
1217 | 1096 | glDisable(GL_DITHER); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1097 | |
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1098 | // Use particularly thick lines while picking ease up selecting lines. |
1224 | 1099 | glLineWidth(qMax<double>(config->lineThickness(), 6.5)); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1100 | } |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1101 | else |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1102 | { |
1217 | 1103 | glEnable(GL_DITHER); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1104 | |
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1105 | // Restore line thickness |
1224 | 1106 | glLineWidth(config->lineThickness()); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
1107 | } |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1108 | } |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1109 | |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1110 | // ============================================================================= |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1111 | // |
1217 | 1112 | void GLRenderer::getRelativeAxes(Axis& relX, Axis& relY) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1113 | { |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1114 | const LDFixedCamera* cam = &g_FixedCameras[camera()]; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1115 | relX = cam->localX; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1116 | relY = cam->localY; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1117 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1118 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1119 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1120 | // |
742
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
1121 | Axis GLRenderer::getRelativeZ() const |
f10de1bf22e7
- vertex snapping is now smarter, does a depth compare to favor vertices closer to camera and does a short-range 2d check + out-of-range 2d check
Santeri Piippo <crimsondusk64@gmail.com>
parents:
741
diff
changeset
|
1122 | { |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1123 | const LDFixedCamera* cam = &g_FixedCameras[camera()]; |
1217 | 1124 | return (Axis)(3 - cam->localX - cam->localY); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1125 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1126 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1127 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1128 | // |
1217 | 1129 | void GLRenderer::compileObject(LDObject* obj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1130 | { |
1217 | 1131 | compiler()->stageForCompilation(obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1132 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1133 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1134 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1135 | // |
1217 | 1136 | void GLRenderer::forgetObject(LDObject* obj) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1137 | { |
1217 | 1138 | compiler()->dropObjectInfo(obj); |
1139 | compiler()->unstage(obj); | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
1140 | |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
1141 | if (m_objectAtCursor == obj) |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
1142 | m_objectAtCursor = nullptr; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1143 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1144 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1145 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1146 | // |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1147 | QByteArray GLRenderer::capturePixels() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1148 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1149 | QByteArray result; |
1217 | 1150 | result.resize(4 * width() * height()); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1151 | m_takingScreenCapture = true; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1152 | update(); // Smile! |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1153 | m_takingScreenCapture = false; |
1217 | 1154 | glReadPixels(0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast<uchar*>(result.data())); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1155 | return result; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1156 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1157 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1158 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1159 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1160 | void GLRenderer::slot_toolTipTimer() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1161 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1162 | // We come here if the cursor has stayed in one place for longer than a |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1163 | // a second. Check if we're holding it over a camera icon - if so, draw |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1164 | // a tooltip. |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1165 | for (CameraIcon & icon : m_cameraIcons) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1166 | { |
1217 | 1167 | if (icon.targetRect.contains(m_mousePosition)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1168 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1169 | m_toolTipCamera = icon.cam; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1170 | m_drawToolTip = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1171 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1172 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1173 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1174 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1175 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1176 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1177 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1178 | // |
1217 | 1179 | Axis GLRenderer::getCameraAxis(bool y, ECamera camid) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1180 | { |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
760
diff
changeset
|
1181 | if (camid == (ECamera) -1) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1182 | camid = camera(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1183 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1184 | const LDFixedCamera* cam = &g_FixedCameras[camid]; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1185 | return (y) ? cam->localY : cam->localX; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1186 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1187 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1188 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1189 | // |
1217 | 1190 | bool GLRenderer::setupOverlay(ECamera cam, QString file, int x, int y, int w, int h) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1191 | { |
1217 | 1192 | QImage* img = new QImage(QImage(file).convertToFormat(QImage::Format_ARGB32)); |
1193 | LDGLOverlay& info = getOverlay(cam); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1194 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1195 | if (img->isNull()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1196 | { |
1217 | 1197 | Critical(tr("Failed to load overlay image!")); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1198 | currentDocumentData().overlays[cam].invalid = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1199 | delete img; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1200 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1201 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1202 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1203 | delete info.img; // delete the old image |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1204 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1205 | info.fname = file; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1206 | info.lw = w; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1207 | info.lh = h; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1208 | info.ox = x; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1209 | info.oy = y; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1210 | info.img = img; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1211 | info.invalid = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1212 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1213 | if (info.lw == 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1214 | info.lw = (info.lh * img->width()) / img->height(); |
967 | 1215 | else if (info.lh == 0) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1216 | info.lh = (info.lw * img->height()) / img->width(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1217 | |
1217 | 1218 | const Axis x2d = getCameraAxis(false, cam), |
1219 | y2d = getCameraAxis(true, cam); | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1220 | const double negXFac = g_FixedCameras[cam].negatedX ? -1 : 1, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1221 | negYFac = g_FixedCameras[cam].negatedY ? -1 : 1; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1222 | |
1218
e0b59d183f96
replaced Origin with default-constructed Vertex
Santeri Piippo
parents:
1217
diff
changeset
|
1223 | info.v0 = info.v1 = Vertex {}; |
1217 | 1224 | info.v0.setCoordinate(x2d, -(info.ox * info.lw * negXFac) / img->width()); |
1225 | info.v0.setCoordinate(y2d,(info.oy * info.lh * negYFac) / img->height()); | |
1226 | info.v1.setCoordinate(x2d, info.v0[x2d] + info.lw); | |
1227 | info.v1.setCoordinate(y2d, info.v0[y2d] + info.lh); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1228 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1229 | // Set alpha of all pixels to 0.5 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1230 | for (long i = 0; i < img->width(); ++i) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1231 | for (long j = 0; j < img->height(); ++j) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1232 | { |
1217 | 1233 | uint32 pixel = img->pixel(i, j); |
1234 | img->setPixel(i, j, 0x80000000 |(pixel & 0x00FFFFFF)); | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1235 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1236 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1237 | updateOverlayObjects(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1238 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1239 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1240 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1241 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1242 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1243 | void GLRenderer::clearOverlay() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1244 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1245 | if (camera() == EFreeCamera) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1246 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1247 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1248 | LDGLOverlay& info = currentDocumentData().overlays[camera()]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1249 | delete info.img; |
984 | 1250 | info.img = nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1251 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1252 | updateOverlayObjects(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1253 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1254 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1255 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1256 | // |
1217 | 1257 | void GLRenderer::setDepthValue(double depth) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1258 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
1259 | if (camera() < EFreeCamera) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
1260 | currentDocumentData().depthValues[camera()] = depth; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1261 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1262 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1263 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1264 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1265 | double GLRenderer::getDepthValue() const |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1266 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
1267 | if (camera() < EFreeCamera) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
1268 | return currentDocumentData().depthValues[camera()]; |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
1269 | else |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
1270 | return 0.0; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1271 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1272 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1273 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1274 | // |
1217 | 1275 | QString GLRenderer::cameraName(ECamera camera) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1276 | { |
1217 | 1277 | switch(camera) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1278 | { |
1217 | 1279 | case ETopCamera: return tr("Top Camera"); |
1280 | case EFrontCamera: return tr("Front Camera"); | |
1281 | case ELeftCamera: return tr("Left Camera"); | |
1282 | case EBottomCamera: return tr("Bottom Camera"); | |
1283 | case EBackCamera: return tr("Back Camera"); | |
1284 | case ERightCamera: return tr("Right Camera"); | |
1285 | case EFreeCamera: return tr("Free Camera"); | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1286 | default: break; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1287 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1288 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1289 | return ""; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1290 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1291 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1292 | QString GLRenderer::currentCameraName() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1293 | { |
1217 | 1294 | return cameraName(camera()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1295 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1296 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1297 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1298 | // |
1217 | 1299 | LDGLOverlay& GLRenderer::getOverlay(int newcam) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1300 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1301 | return currentDocumentData().overlays[newcam]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1302 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1303 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1304 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1305 | // |
1217 | 1306 | void GLRenderer::zoomNotch(bool inward) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1307 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
1308 | zoom() *= inward ? 0.833f : 1.2f; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1309 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1310 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1311 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1312 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1313 | void GLRenderer::zoomToFit() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1314 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1315 | zoom() = 30.0f; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1316 | |
984 | 1317 | if (document() == nullptr or m_width == -1 or m_height == -1) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1318 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1319 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1320 | bool lastfilled = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1321 | bool firstrun = true; |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
1322 | enum { black = 0xFF000000 }; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1323 | bool inward = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1324 | int runaway = 50; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1325 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1326 | // Use the pick list while drawing the scene, this way we can tell whether borders |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1327 | // are background or not. |
1217 | 1328 | setPicking(true); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1329 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1330 | while (--runaway) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1331 | { |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
1332 | if (zoom() > 10000.0 or zoom() < 0.0) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1333 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
1334 | // Nothing to draw if we get here. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1335 | zoom() = 30.0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1336 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1337 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1338 | |
1217 | 1339 | zoomNotch(inward); |
1340 | QVector<unsigned char> capture(4 * m_width * m_height); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1341 | drawGLScene(); |
1217 | 1342 | glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, capture.data()); |
1343 | QImage image(capture.constData(), m_width, m_height, QImage::Format_ARGB32); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1344 | bool filled = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1345 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1346 | // Check the top and bottom rows |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
1347 | for (int i = 0; i < image.width(); ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1348 | { |
1217 | 1349 | if (image.pixel(i, 0) != black or image.pixel(i, m_height - 1) != black) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1350 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1351 | filled = true; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1352 | break; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1353 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1354 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1355 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1356 | // Left and right edges |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1357 | if (filled == false) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1358 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
1359 | for (int i = 0; i < image.height(); ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1360 | { |
1217 | 1361 | if (image.pixel(0, i) != black or image.pixel(m_width - 1, i) != black) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1362 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1363 | filled = true; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1364 | break; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1365 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1366 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1367 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1368 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1369 | if (firstrun) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1370 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1371 | // If this is the first run, we don't know enough to determine |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1372 | // whether the zoom was to fit, so we mark in our knowledge so |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1373 | // far and start over. |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1374 | inward = not filled; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1375 | firstrun = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1376 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1377 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1378 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1379 | // If this run filled the screen and the last one did not, the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1380 | // last run had ideal zoom - zoom a bit back and we should reach it. |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
1381 | if (filled and not lastfilled) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1382 | { |
1217 | 1383 | zoomNotch(false); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1384 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1385 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1386 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1387 | // If this run did not fill the screen and the last one did, we've |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1388 | // now reached ideal zoom so we're done here. |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
1389 | if (not filled and lastfilled) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1390 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1391 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1392 | inward = not filled; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1393 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1394 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1395 | lastfilled = filled; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1396 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1397 | |
1217 | 1398 | setPicking(false); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1399 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1400 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1401 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1402 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1403 | void GLRenderer::zoomAllToFit() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1404 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
1405 | zoomToFit(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1406 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1407 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1408 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1409 | // |
1217 | 1410 | void GLRenderer::mouseDoubleClickEvent(QMouseEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1411 | { |
1217 | 1412 | if (m_currentEditMode->mouseDoubleClicked(ev)) |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
1413 | ev->accept(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1414 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1415 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1416 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1417 | // |
1217 | 1418 | LDOverlay* GLRenderer::findOverlayObject(ECamera cam) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1419 | { |
944 | 1420 | for (LDObject* obj : document()->objects()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1421 | { |
1217 | 1422 | LDOverlay* overlay = dynamic_cast<LDOverlay*>(obj); |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
1423 | |
944 | 1424 | if (overlay and overlay->camera() == cam) |
1425 | return overlay; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1426 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1427 | |
944 | 1428 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1429 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1430 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1431 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1432 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1433 | // Read in overlays from the current file and update overlay info accordingly. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1434 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1435 | void GLRenderer::initOverlaysFromObjects() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1436 | { |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
760
diff
changeset
|
1437 | for (ECamera cam = EFirstCamera; cam < ENumCameras; ++cam) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1438 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1439 | if (cam == EFreeCamera) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1440 | continue; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1441 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1442 | LDGLOverlay& meta = currentDocumentData().overlays[cam]; |
1217 | 1443 | LDOverlay* ovlobj = findOverlayObject(cam); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1444 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1445 | if (ovlobj == nullptr and meta.img) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1446 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1447 | delete meta.img; |
984 | 1448 | meta.img = nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1449 | } |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1450 | else if (ovlobj and |
984 | 1451 | (meta.img == nullptr or meta.fname != ovlobj->fileName()) and |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
1452 | not meta.invalid) |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
1453 | { |
1217 | 1454 | setupOverlay(cam, ovlobj->fileName(), ovlobj->x(), |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1455 | ovlobj->y(), ovlobj->width(), ovlobj->height()); |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
1456 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1457 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1458 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1459 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1460 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1461 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1462 | void GLRenderer::updateOverlayObjects() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1463 | { |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
760
diff
changeset
|
1464 | for (ECamera cam = EFirstCamera; cam < ENumCameras; ++cam) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1465 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1466 | if (cam == EFreeCamera) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1467 | continue; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1468 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1469 | LDGLOverlay& meta = currentDocumentData().overlays[cam]; |
1217 | 1470 | LDOverlay* ovlobj = findOverlayObject(cam); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1471 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1472 | if (meta.img == nullptr and ovlobj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1473 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1474 | // If this is the last overlay image, we need to remove the empty space after it as well. |
944 | 1475 | LDObject* nextobj = ovlobj->next(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1476 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
1477 | if (nextobj and nextobj->type() == OBJ_Empty) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1478 | nextobj->destroy(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1479 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1480 | // If the overlay object was there and the overlay itself is |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1481 | // not, remove the object. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1482 | ovlobj->destroy(); |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1483 | } |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1484 | else if (meta.img and ovlobj == nullptr) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1485 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1486 | // Inverse case: image is there but the overlay object is |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1487 | // not, thus create the object. |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
1488 | ovlobj = LDSpawn<LDOverlay>(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1489 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1490 | // Find a suitable position to place this object. We want to place |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1491 | // this into the header, which is everything up to the first scemantic |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1492 | // object. If we find another overlay object, place this object after |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1493 | // the last one found. Otherwise, place it before the first schemantic |
1217 | 1494 | // object and put an empty object after it(though don't do this if |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1495 | // there was no schemantic elements at all) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1496 | int i, lastOverlay = -1; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1497 | bool found = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1498 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1499 | for (i = 0; i < document()->getObjectCount(); ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1500 | { |
1217 | 1501 | LDObject* obj = document()->getObject(i); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1502 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1503 | if (obj->isScemantic()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1504 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1505 | found = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1506 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1507 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1508 | |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
1509 | if (obj->type() == OBJ_Overlay) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1510 | lastOverlay = i; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1511 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1512 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1513 | if (lastOverlay != -1) |
1217 | 1514 | document()->insertObj(lastOverlay + 1, ovlobj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1515 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1516 | { |
1217 | 1517 | document()->insertObj(i, ovlobj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1518 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1519 | if (found) |
1217 | 1520 | document()->insertObj(i + 1, LDSpawn<LDEmpty>()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1521 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1522 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1523 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1524 | if (meta.img and ovlobj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1525 | { |
1217 | 1526 | ovlobj->setCamera(cam); |
1527 | ovlobj->setFileName(meta.fname); | |
1528 | ovlobj->setX(meta.ox); | |
1529 | ovlobj->setY(meta.oy); | |
1530 | ovlobj->setWidth(meta.lw); | |
1531 | ovlobj->setHeight(meta.lh); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1532 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1533 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1534 | |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
1535 | if (m_window->renderer() == this) |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
1536 | m_window->refresh(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1537 | } |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1538 | |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1539 | // ============================================================================= |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1540 | // |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1541 | void GLRenderer::highlightCursorObject() |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1542 | { |
1224 | 1543 | if (not config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1544 | return; |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1545 | |
946 | 1546 | LDObject* newObject = nullptr; |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1547 | LDObject* oldObject = objectAtCursor(); |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1548 | qint32 newIndex; |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1549 | |
1224 | 1550 | if (m_isCameraMoving or not config->highlightObjectBelowCursor()) |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1551 | { |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1552 | newIndex = 0; |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1553 | } |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1554 | else |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1555 | { |
1217 | 1556 | setPicking(true); |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1557 | drawGLScene(); |
1217 | 1558 | setPicking(false); |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1559 | |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1560 | unsigned char pixel[4]; |
1217 | 1561 | glReadPixels(m_mousePosition.x(), m_height - m_mousePosition.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel[0]); |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1562 | newIndex = pixel[0] * 0x10000 | pixel[1] * 0x100 | pixel[2]; |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1563 | } |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1564 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1565 | if (newIndex != (oldObject ? oldObject->id() : 0)) |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1566 | { |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1567 | if (newIndex != 0) |
1217 | 1568 | newObject = LDObject::fromID(newIndex); |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1569 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1570 | m_objectAtCursor = newObject; |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
1571 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1572 | if (oldObject) |
1217 | 1573 | compileObject(oldObject); |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1574 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1575 | if (newObject) |
1217 | 1576 | compileObject(newObject); |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1577 | } |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1578 | |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1579 | update(); |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1580 | } |
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
1581 | |
1217 | 1582 | void GLRenderer::dragEnterEvent(QDragEnterEvent* ev) |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1583 | { |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1584 | if (m_window and ev->source() == m_window->getPrimitivesTree() and m_window->getPrimitivesTree()->currentItem()) |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1585 | ev->acceptProposedAction(); |
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1586 | } |
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1587 | |
1217 | 1588 | void GLRenderer::dropEvent(QDropEvent* ev) |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1589 | { |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1590 | if (m_window and ev->source() == m_window->getPrimitivesTree()) |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1591 | { |
1217 | 1592 | PrimitiveTreeItem* item = static_cast<PrimitiveTreeItem*>(m_window->getPrimitivesTree()->currentItem()); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1593 | QString primitiveName = item->primitive()->name; |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1010
diff
changeset
|
1594 | LDSubfileReference* ref = LDSpawn<LDSubfileReference>(); |
1217 | 1595 | ref->setColor(MainColor); |
1596 | ref->setFileInfo(m_documents->getDocumentByName(primitiveName)); | |
1218
e0b59d183f96
replaced Origin with default-constructed Vertex
Santeri Piippo
parents:
1217
diff
changeset
|
1597 | ref->setPosition(Vertex {}); |
1219 | 1598 | ref->setTransform(Matrix {}); |
1217 | 1599 | currentDocument()->insertObj(m_window->suggestInsertPoint(), ref); |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1600 | ref->select(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
1601 | m_window->buildObjectList(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
1602 | m_window->renderer()->refresh(); |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1603 | ev->acceptProposedAction(); |
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1604 | } |
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
1605 | } |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1606 | |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1607 | Vertex const& GLRenderer::position3D() const |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1608 | { |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1609 | return m_position3D; |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1610 | } |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1611 | |
1217 | 1612 | const LDFixedCamera& GLRenderer::getFixedCamera(ECamera cam) const |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1613 | { |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1614 | return g_FixedCameras[cam]; |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
1615 | } |
827 | 1616 | |
1617 | bool GLRenderer::mouseHasMoved() const | |
1618 | { | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1619 | return m_totalMouseMove >= 10; |
827 | 1620 | } |
1621 | ||
1622 | QPoint const& GLRenderer::mousePosition() const | |
1623 | { | |
1624 | return m_mousePosition; | |
1625 | } | |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1626 | |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1627 | QPointF const& GLRenderer::mousePositionF() const |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1628 | { |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1629 | return m_mousePositionF; |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1630 | } |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1631 | |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1632 | void GLRenderer::doMakeCurrent() |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1633 | { |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1634 | makeCurrent(); |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1635 | initializeOpenGLFunctions(); |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
1636 | } |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1637 | |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1638 | int GLRenderer::depthNegateFactor() const |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1639 | { |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1640 | return g_FixedCameras[camera()].negatedDepth ? -1 : 1; |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1641 | } |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1642 | |
897
ef9e4469975a
- pressing ctrl while drawing now locks the draw to cardinal directions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
882
diff
changeset
|
1643 | Qt::KeyboardModifiers GLRenderer::keyboardModifiers() const |
ef9e4469975a
- pressing ctrl while drawing now locks the draw to cardinal directions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
882
diff
changeset
|
1644 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1645 | return m_currentKeyboardModifiers; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1646 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1647 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1648 | ECamera GLRenderer::camera() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1649 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1650 | return m_camera; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1651 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1652 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1653 | LDGLData& GLRenderer::currentDocumentData() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1654 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1655 | return *document()->glData(); |
897
ef9e4469975a
- pressing ctrl while drawing now locks the draw to cardinal directions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
882
diff
changeset
|
1656 | } |
ef9e4469975a
- pressing ctrl while drawing now locks the draw to cardinal directions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
882
diff
changeset
|
1657 | |
1217 | 1658 | double& GLRenderer::rotation(Axis ax) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1659 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1660 | return |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1661 | (ax == X) ? currentDocumentData().rotationX : |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1662 | (ax == Y) ? currentDocumentData().rotationY : |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1663 | currentDocumentData().rotationZ; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1664 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1665 | |
1217 | 1666 | double& GLRenderer::panning(Axis ax) |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1667 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1668 | return (ax == X) ? currentDocumentData().panX[camera()] : |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1669 | currentDocumentData().panY[camera()]; |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1670 | } |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1671 | |
1217 | 1672 | double GLRenderer::panning(Axis ax) const |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1673 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1674 | return (ax == X) ? currentDocumentData().panX[camera()] : |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1675 | currentDocumentData().panY[camera()]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1676 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1677 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1678 | double& GLRenderer::zoom() |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1679 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1680 | return currentDocumentData().zoom[camera()]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1681 | } |