src/glRenderer.h

Mon, 30 Jan 2017 02:33:17 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 30 Jan 2017 02:33:17 +0200
changeset 1085
e22f07465d3b
parent 1072
9ce9496427f2
child 1092
7a50a7f6b492
permissions
-rw-r--r--

Removed the status bar, since it's not used for anything

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1072
9ce9496427f2 Happy new year 2017!
Teemu Piippo <teemu@hecknology.net>
parents: 1061
diff changeset
3 * Copyright (C) 2013 - 2017 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1006
a6b462051ae0 Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1000
diff changeset
8 * (at your option) any later version.
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QGLWidget>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "main.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "macros.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "ldObject.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "ldDocument.h"
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
25 #include "glShared.h"
830
a741a0b9df49 - updated filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents: 827
diff changeset
26 #include "editmodes/abstractEditMode.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
28 class GLCompiler;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 class MessageManager;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 class QDialogButtonBox;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 class RadioGroup;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 class QDoubleSpinBox;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 class QSpinBox;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 class QLineEdit;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 class QTimer;
823
1a2f593f0c02 - saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 818
diff changeset
36 class MagicWandMode;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
1034
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
38 struct CameraInfo
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
39 {
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
40 int glrotate[3];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
41 Axis localX;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
42 Axis localY;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
43 bool negatedX;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
44 bool negatedY;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
45 bool negatedDepth; // is greater depth value closer to camera?
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
46 };
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
47
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
48 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 // Meta for overlays
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
50 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 struct LDGLOverlay
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 {
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
53 LDGLOverlay();
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
54 ~LDGLOverlay();
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
55
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 Vertex v0,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 v1;
1032
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
58 int offsetX,
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
59 offsetY;
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
60 double width,
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
61 height;
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
62 QString fileName;
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
63 QImage* image;
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
64 bool invalid;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
67 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 // Document-specific data
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 struct LDGLData
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 {
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
72 double rotationX;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
73 double rotationY;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
74 double rotationZ;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
75 double panX[7];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
76 double panY[7];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
77 double zoom[7];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 double depthValues[6];
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 LDGLOverlay overlays[6];
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 bool init;
737
e58bdb21cc54 - more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents: 718
diff changeset
81 bool needZoomToFit;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
737
e58bdb21cc54 - more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents: 718
diff changeset
83 LDGLData() :
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
84 rotationX (0.0),
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
85 rotationY (0.0),
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
86 rotationZ (0.0),
737
e58bdb21cc54 - more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents: 718
diff changeset
87 init (false),
e58bdb21cc54 - more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents: 718
diff changeset
88 needZoomToFit (true)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 {
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
90 for (int i = 0; i < 7; ++i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 {
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
92 if (i < 6)
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
93 {
1032
376db8dd6a42 Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents: 1023
diff changeset
94 overlays[i].image = nullptr;
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
95 overlays[i].invalid = false;
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
96 depthValues[i] = 0.0f;
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
97 }
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
98
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
99 zoom[i] = 30.0;
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
100 panX[i] = 0.0;
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
101 panY[i] = 0.0;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105
1033
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
106 enum Camera
762
d259256e1394 - added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents: 760
diff changeset
107 {
1034
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
108 TopCamera,
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
109 FrontCamera,
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
110 LeftCamera,
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
111 BottomCamera,
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
112 BackCamera,
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
113 RightCamera,
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
114 FreeCamera,
762
d259256e1394 - added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents: 760
diff changeset
115 };
d259256e1394 - added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents: 760
diff changeset
116
1034
a05fc8256a3a Enum stuff
Teemu Piippo <teemu@compsta2.com>
parents: 1033
diff changeset
117 MAKE_ITERABLE_ENUM(Camera, TopCamera, FreeCamera)
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
118
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
119 struct CameraIcon
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
120 {
1033
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
121 QPixmap image;
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
122 QRect sourceRect;
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
123 QRect targetRect;
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
124 QRect hitRect;
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
125 Camera camera;
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
126 };
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
127
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
128 // The main renderer object, draws the brick on the screen, manages the camera and selection picking.
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
129 class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 {
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
131 Q_OBJECT
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
133 public:
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
134 GLRenderer (QWidget* parent = nullptr);
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
135 ~GLRenderer();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136
1033
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
137 Camera camera() const;
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
138 const CameraInfo& cameraInfo(Camera camera) const;
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
139 QString cameraName(Camera camera) const;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
140 QByteArray capturePixels();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
141 void clearOverlay();
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
142 void compileObject(LDObject* obj);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
143 GLCompiler* compiler() const;
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
144 Vertex convert2dTo3d(const QPoint& pos2d, bool snap) const;
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
145 QPoint convert3dTo2d(const Vertex& pos3d);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
146 QString currentCameraName() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
147 EditModeType currentEditModeType() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
148 int depthNegateFactor() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
149 LDDocument* document() const;
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
150 void drawPoint(QPainter& painter, QPointF pos, QColor color = QColor (64, 192, 0)) const;
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
151 void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
152 void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
153 void drawGLScene();
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
154 void forgetObject(LDObject* obj);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
155 Axis getCameraAxis(bool y, Camera camid = (Camera) -1);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
156 double getDepthValue() const;
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
157 LDGLOverlay& getOverlay(int newcam);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
158 void getRelativeAxes(Axis& relX, Axis& relY) const;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
159 Axis getRelativeZ() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
160 void hardRefresh();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
161 void highlightCursorObject();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
162 void initGLData();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
163 void initOverlaysFromObjects();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
164 bool isDrawOnly() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
165 bool isPicking() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
166 Qt::KeyboardModifiers keyboardModifiers() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
167 QPen linePen() const;
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1008
diff changeset
168 void makeCurrent();
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
169 MessageManager* messageLog() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
170 bool mouseHasMoved() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
171 QPoint const& mousePosition() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
172 QPointF const& mousePositionF() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
173 void needZoomToFit();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
174 LDObject* objectAtCursor() const;
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
175 void pick(int mouseX, int mouseY, bool additive);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
176 void pick(const QRect& range, bool additive);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
177 LDObject* pickOneObject(int mouseX, int mouseY);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
178 Vertex const& position3D() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
179 void refresh();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
180 void resetAllAngles();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
181 void resetAngles();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
182 void setBackground();
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
183 void setCamera(Camera cam);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
184 void setDepthValue(double depth);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
185 void setDocument(LDDocument* document);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
186 void setDrawOnly(bool value);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
187 void setEditMode(EditModeType type);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
188 void setPicking(bool a);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
189 bool setupOverlay(Camera camera, QString fileName, int x, int y, int w, int h);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
190 QPen textPen() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
191 void updateOverlayObjects();
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
192 void zoomNotch(bool inward);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
194 protected:
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
195 void contextMenuEvent(QContextMenuEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
196 void dragEnterEvent(QDragEnterEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
197 void dropEvent(QDropEvent* event);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
198 void initializeGL();
1056
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
199 void keyPressEvent(QKeyEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
200 void keyReleaseEvent(QKeyEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
201 void leaveEvent(QEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
202 void mouseDoubleClickEvent(QMouseEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
203 void mousePressEvent(QMouseEvent* event);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
204 void mouseMoveEvent(QMouseEvent* ev);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
205 void mouseReleaseEvent(QMouseEvent* ev);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
206 void paintEvent(QPaintEvent* ev);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
207 void resizeGL(int w, int h);
27b7991b3bea Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents: 1035
diff changeset
208 void wheelEvent(QWheelEvent* ev);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
210 private:
1061
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
211 MessageManager* m_messageLog = nullptr;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
212 LDDocument* m_document = nullptr;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
213 GLCompiler* m_compiler;
1061
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
214 LDObject* m_objectAtCursor = nullptr;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
215 CameraIcon m_cameraIcons[7];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
216 QTimer* m_toolTipTimer;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
217 Qt::MouseButtons m_lastButtons;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
218 Qt::KeyboardModifiers m_currentKeyboardModifiers;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
219 Vertex m_position3D;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
220 double m_virtualWidth;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
221 double m_virtualHeight;
1061
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
222 bool m_useDarkBackground = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
223 bool m_drawToolTip = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
224 bool m_takingScreenCapture = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
225 bool m_panning = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
226 bool m_initialized = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
227 bool m_isDrawOnly = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
228 bool m_isDrawingSelectionScene = false;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
229 bool m_isCameraMoving = false;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
230 QPoint m_mousePosition;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
231 QPoint m_globalpos;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
232 QPointF m_mousePositionF;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
233 QPen m_thinBorderPen;
1033
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
234 Camera m_camera;
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
235 Camera m_toolTipCamera;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
236 GLuint m_axeslist;
1061
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
237 int m_width = 0;
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
238 int m_height = 0;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
239 int m_totalMouseMove;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
240 QColor m_backgroundColor;
1061
273333700685 refactor
Teemu Piippo <teemu@hecknology.net>
parents: 1056
diff changeset
241 AbstractEditMode* m_currentEditMode = nullptr;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
242 GLuint m_axesVbo;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
243 GLuint m_axesColorVbo;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
244
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
245 void calcCameraIcons();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
246 void clampAngle (double& angle) const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
247 LDGLData& currentDocumentData() const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
248 void drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type);
1033
32153a1dbb15 - Refactoring...
Teemu Piippo <teemu@compsta2.com>
parents: 1032
diff changeset
249 LDOverlay* findOverlayObject (Camera cam);
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
250 double& panning (Axis ax);
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
251 double panning (Axis ax) const;
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
252 double& rotation (Axis ax);
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
253 double& zoom();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
254 void zoomToFit();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
255 void zoomAllToFit();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
257 template<typename... Args>
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
258 QString format (QString fmtstr, Args... args)
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
259 {
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
260 return ::format (fmtstr, args...);
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
261 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262
802
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
263 private slots:
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
264 void slot_toolTipTimer();
2e220b9083bf - refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
265 void initializeAxes();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 };

mercurial