-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBagGL.h
152 lines (114 loc) · 3.5 KB
/
BagGL.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef BAGGL_H
#define BAGGL_H
#include <QOpenGLWidget>
#include "GLCamera.h"
#include "BagIO.h"
#include <QVector3D>
#include <QTime>
#include <memory>
#include <QOpenGLTexture>
#include <QOpenGLDebugLogger>
#include <QMatrix4x4>
#include <QVector2D>
#include "Bounds.h"
#include <QOpenGLShader>
#include <QtGui/QOpenGLFunctions_4_0_Core>
class QStatusBar;
class QLabel;
struct TileGL
{
QOpenGLTexture elevations;
QOpenGLTexture normals;
QOpenGLTexture uncertainties;
int lod;
int maxLod;
TileGL(): elevations(QOpenGLTexture::Target2D), normals(QOpenGLTexture::Target2D), uncertainties(QOpenGLTexture::Target2D) {}
~TileGL(){}
};
class BagGL: public QOpenGLWidget, protected QOpenGLFunctions_4_0_Core
{
Q_OBJECT
public:
BagGL(QWidget *parent=nullptr);
~BagGL();
void initializeGL() override;
void paintGL() override;
void resizeGL(int w, int h) override;
void render(bool picking=false);
bool openBag(QString const &bagFileName);
void closeBag();
void setColormap(std::string const &cm);
void setDrawStyle(std::string const &ds);
static const GLuint primitiveReset;
typedef std::pair<uint,uint> GridSize;
void setStatusBar(QStatusBar *sb);
public slots:
void resetView();
void messageLogged(const QOpenGLDebugMessage & debugMessage);
void newTile(TilePtr tile, bool isVR);
void checkAnimation();
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
private:
void checkGL(TilePtr t);
void updateLOD(TilePtr t);
void drawTile(TilePtr t);
GLCamera camera;
GLuint matrixUniform;
GLuint normMatrixUniform;
GLuint lightDirectionUniform;
GLuint minElevationUniform;
GLuint maxElevationUniform;
GLuint elevationMapUniform;
GLuint spacingUniform;
GLuint lowerLeftUniform;
GLuint tileSizeUniform;
GLuint colorMapUniform;
GLuint normalMapUniform;
GLuint eastElevationMapUniform;
GLuint eastNormalMapUniform;
GLuint eastSpacingUniform;
GLuint eastLowerLeftUniform;
GLuint eastTileSizeUniform;
GLuint hasEastUniform;
GLuint northElevationMapUniform;
GLuint northNormalMapUniform;
GLuint northSpacingUniform;
GLuint northLowerLeftUniform;
GLuint northTileSizeUniform;
GLuint hasNorthUniform;
GLuint northEastElevationMapUniform;
GLuint northEastNormalMapUniform;
GLuint northEastSpacingUniform;
GLuint northEastLowerLeftUniform;
GLuint hasNorthEastUniform;
GLuint tileVAO;
GLuint tileBuffer;
BagIO bag;
QOpenGLShaderProgram *program;
GLuint polygonMode;
#ifndef NDEBUG
QOpenGLDebugLogger gldebug;
#endif
typedef std::shared_ptr<QOpenGLTexture> QOpenGLTexturePtr;
typedef std::map<std::string,QOpenGLTexturePtr> ColormapMap;
ColormapMap colormaps;
std::string currentColormap;
bool rotating;
QPoint lastPosition;
bool translating;
QVector3D translateStartPosition, translateEndPosition;
QTime translateStartTime;
bool adjustingHeightExaggeration;
int lodBias;
TileMap overviewTiles;
TileMap vrTiles;
QStatusBar * statusBar;
QLabel * statusLabel;
bool m_animating;
};
#endif