-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglwidget.h
164 lines (129 loc) · 3.4 KB
/
glwidget.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
153
154
155
156
157
158
159
160
161
162
163
164
// Author: Marc Comino 2019
#ifndef GLWIDGET_H_
#define GLWIDGET_H_
#include <GL/glew.h>
#include <QGLWidget>
#include <QMouseEvent>
#include <QOpenGLShaderProgram>
#include <QString>
#include <QDateTime>
#include <glm/glm.hpp>
#include <memory>
#include "./camera.h"
#include "./cube.h"
#include "./volume.h"
class GLWidget : public QGLWidget {
Q_OBJECT
public:
explicit GLWidget(QWidget *parent = 0);
~GLWidget();
/**
* @brief LoadVolume Loads a volume model from the input path.
* @param filename Path to the stack of images composing the volume model.
* @return Whether it was able to load the volume.
*/
bool LoadVolume(const QString &filename);
/**
* @brief
* @return
*/
std::vector<double>& GetVolumeHistogram();
/**
Holds the transfer function values, 256 * 4, rgbargba...
*/
std::vector<float> transfer_function_values_;
/**
Sends the transfer function data to the GPU, will call updateGL
if enough time has passed since the last call
*/
void SetTransferFunction();
protected:
/**
* @brief initializeGL Initializes OpenGL variables and loads, compiles and
* links shaders.
*/
void initializeGL();
/**
* @brief resizeGL Resizes the viewport.
* @param w New viewport width.
* @param h New viewport height.
*/
void resizeGL(int w, int h);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
private:
/**
* @brief program_ A basic shader program.
*/
std::unique_ptr<QOpenGLShaderProgram> program_;
/**
* @brief program_ A basic point rendering shader program.
*/
std::unique_ptr<QOpenGLShaderProgram> program_points_;
/**
The VAO for the point rendering pipeline
*/
GLuint points_vao_;
/**
* @brief camera_ Class that computes the multiple camera transform matrices.
*/
data_visualization::Camera camera_;
/**
* @brief cube_ A cubic mesh used to render the colume.
*/
std::unique_ptr<data_representation::Cube> cube_;
/**
* @brief mesh_ Data structure representing a volume.
*/
std::unique_ptr<data_representation::Volume> vol_;
/**
* @brief initialized_ Whether the widget has finished initializations.
*/
bool initialized_;
/**
* @brief width_ Viewport current width.
*/
float width_;
/**
* @brief height_ Viewport current height.
*/
float height_;
/**
* @brief light_position_ The position of the point light
*/
glm::vec3 light_position_;
/**
* @brief light_color_ The color of the point light
*/
glm::vec3 light_color_;
/**
The texture id for the transfer function
*/
GLuint transfer_function_texture_id_;
/**
The timestamp for the last render
*/
qint64 last_render_timestamp_;
/**
Hold wether to perform phong and shadow calculations
*/
bool calc_phong_ = true;
bool calc_shadow_ = true;
protected slots:
/**
* @brief paintGL Function that handles rendering the scene.
*/
void paintGL();
public slots:
void LightPosXValueChanged(double arg);
void LightPosYValueChanged(double arg);
void LightPosZValueChanged(double arg);
void LightColorXValueChanged(double arg);
void LightColorYValueChanged(double arg);
void LightColorZValueChanged(double arg);
void SetPhongShadingCalc(bool arg);
void SetShadowsCalc(bool arg);
};
#endif // GLWIDGET_H_