Thu, 09 Feb 2017 00:32:24 +0200
Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
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 | 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 | 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 | { |
1095
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
72 | QGenericMatrix<4, 4, GLfloat> rotationMatrix; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
73 | double panX[7]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
74 | double panY[7]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
75 | double zoom[7]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | double depthValues[6]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | LDGLOverlay overlays[6]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | 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
|
79 | bool needZoomToFit; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | |
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 | LDGLData() : |
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
|
82 | 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
|
83 | needZoomToFit (true) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
85 | for (int i = 0; i < 7; ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
87 | if (i < 6) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
88 | { |
1032
376db8dd6a42
Unabbreviated overlay member names
Teemu Piippo <teemu@compsta2.com>
parents:
1023
diff
changeset
|
89 | overlays[i].image = nullptr; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
90 | overlays[i].invalid = false; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
91 | depthValues[i] = 0.0f; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
92 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
93 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
94 | zoom[i] = 30.0; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
95 | panX[i] = 0.0; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
96 | panY[i] = 0.0; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | |
1033 | 101 | 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
|
102 | { |
1034 | 103 | TopCamera, |
104 | FrontCamera, | |
105 | LeftCamera, | |
106 | BottomCamera, | |
107 | BackCamera, | |
108 | RightCamera, | |
109 | 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
|
110 | }; |
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
|
111 | |
1034 | 112 | 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
|
113 | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
114 | struct CameraIcon |
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
115 | { |
1033 | 116 | QPixmap image; |
117 | QRect sourceRect; | |
118 | QRect targetRect; | |
119 | QRect hitRect; | |
120 | Camera camera; | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
121 | }; |
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
122 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
123 | // 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
|
124 | class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | { |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
126 | Q_OBJECT |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
128 | public: |
1097
9a9e6ce0c5dc
Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents:
1096
diff
changeset
|
129 | GLRenderer(LDDocument* document, QWidget* parent = nullptr); |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
130 | ~GLRenderer(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | |
1033 | 132 | Camera camera() const; |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
133 | const CameraInfo& cameraInfo(Camera camera) const; |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
134 | QString cameraName(Camera camera) const; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
135 | QByteArray capturePixels(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
136 | void clearOverlay(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
137 | void compileObject(LDObject* obj); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
138 | GLCompiler* compiler() const; |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
139 | Vertex convert2dTo3d(const QPoint& pos2d, bool snap) const; |
1096
7cc929d8fc4d
Simplified GLRenderer::convert3dTo2d. The multiplication with the modelview matrix is not necessary, it's identity all the time... with that, I think the function makes much more sense now.
Teemu Piippo <teemu@hecknology.net>
parents:
1095
diff
changeset
|
140 | QPoint convert3dTo2d(const Vertex& pos3d) const; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
141 | QString currentCameraName() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
142 | EditModeType currentEditModeType() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
143 | int depthNegateFactor() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
144 | LDDocument* document() const; |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
145 | 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
|
146 | void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
147 | void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
148 | void drawGLScene(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
149 | void forgetObject(LDObject* obj); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
150 | Axis getCameraAxis(bool y, Camera camid = (Camera) -1); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
151 | double getDepthValue() const; |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
152 | LDGLOverlay& getOverlay(int newcam); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
153 | void getRelativeAxes(Axis& relX, Axis& relY) const; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
154 | Axis getRelativeZ() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
155 | void hardRefresh(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
156 | void highlightCursorObject(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
157 | void initGLData(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
158 | void initOverlaysFromObjects(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
159 | bool isDrawOnly() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
160 | bool isPicking() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
161 | Qt::KeyboardModifiers keyboardModifiers() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
162 | QPen linePen() const; |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1008
diff
changeset
|
163 | void makeCurrent(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
164 | bool mouseHasMoved() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
165 | QPoint const& mousePosition() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
166 | QPointF const& mousePositionF() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
167 | void needZoomToFit(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
168 | LDObject* objectAtCursor() const; |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
169 | void pick(int mouseX, int mouseY, bool additive); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
170 | void pick(const QRect& range, bool additive); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
171 | LDObject* pickOneObject(int mouseX, int mouseY); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
172 | Vertex const& position3D() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
173 | void refresh(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
174 | void resetAllAngles(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
175 | void resetAngles(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
176 | void setBackground(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
177 | void setCamera(Camera cam); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
178 | void setDepthValue(double depth); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
179 | void setDrawOnly(bool value); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
180 | void setEditMode(EditModeType type); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
181 | void setPicking(bool a); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
182 | 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
|
183 | QPen textPen() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
184 | void updateOverlayObjects(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
185 | void zoomNotch(bool inward); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
187 | protected: |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
188 | void contextMenuEvent(QContextMenuEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
189 | void dragEnterEvent(QDragEnterEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
190 | void dropEvent(QDropEvent* event); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
191 | void initializeGL(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
192 | void keyPressEvent(QKeyEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
193 | void keyReleaseEvent(QKeyEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
194 | void leaveEvent(QEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
195 | void mouseDoubleClickEvent(QMouseEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
196 | void mousePressEvent(QMouseEvent* event); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
197 | void mouseMoveEvent(QMouseEvent* ev); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
198 | void mouseReleaseEvent(QMouseEvent* ev); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
199 | void paintEvent(QPaintEvent* ev); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
200 | void resizeGL(int w, int h); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1035
diff
changeset
|
201 | void wheelEvent(QWheelEvent* ev); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
203 | private: |
1061 | 204 | LDDocument* m_document = nullptr; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
205 | GLCompiler* m_compiler; |
1061 | 206 | LDObject* m_objectAtCursor = nullptr; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
207 | CameraIcon m_cameraIcons[7]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
208 | QTimer* m_toolTipTimer; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
209 | Qt::MouseButtons m_lastButtons; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
210 | Qt::KeyboardModifiers m_currentKeyboardModifiers; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
211 | Vertex m_position3D; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
212 | double m_virtualWidth; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
213 | double m_virtualHeight; |
1061 | 214 | bool m_useDarkBackground = false; |
215 | bool m_drawToolTip = false; | |
216 | bool m_takingScreenCapture = false; | |
217 | bool m_panning = false; | |
218 | bool m_initialized = false; | |
219 | bool m_isDrawOnly = false; | |
220 | bool m_isDrawingSelectionScene = false; | |
221 | bool m_isCameraMoving = false; | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
222 | QPoint m_mousePosition; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
223 | QPoint m_globalpos; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
224 | QPointF m_mousePositionF; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
225 | QPen m_thinBorderPen; |
1033 | 226 | Camera m_camera; |
227 | Camera m_toolTipCamera; | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
228 | GLuint m_axeslist; |
1061 | 229 | int m_width = 0; |
230 | int m_height = 0; | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
231 | int m_totalMouseMove; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
232 | QColor m_backgroundColor; |
1061 | 233 | AbstractEditMode* m_currentEditMode = nullptr; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
234 | GLuint m_axesVbo; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
235 | GLuint m_axesColorVbo; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
236 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
237 | void calcCameraIcons(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
238 | LDGLData& currentDocumentData() const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
239 | void drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type); |
1033 | 240 | LDOverlay* findOverlayObject (Camera cam); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
241 | double& panning (Axis ax); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
242 | double panning (Axis ax) const; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
243 | double& zoom(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
244 | void zoomToFit(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
245 | void zoomAllToFit(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
247 | template<typename... Args> |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
248 | QString format (QString fmtstr, Args... args) |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
249 | { |
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
250 | return ::format (fmtstr, args...); |
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
251 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | |
802
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
253 | private slots: |
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
254 | void slot_toolTipTimer(); |
2e220b9083bf
- refactor glRenderer.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
790
diff
changeset
|
255 | void initializeAxes(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | }; |