src/gldraw.cpp

Tue, 22 Oct 2013 22:09:53 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 22 Oct 2013 22:09:53 +0300
changeset 534
3ed2ebcbc84f
parent 529
c294b2070185
child 538
2f85d4d286e5
child 665
4355e72ffd47
permissions
-rw-r--r--

Made rotation/pan/zoom values camera-dependant (so now there's 7 sets of them instead of 1)

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

mercurial