VideoVis  0.9
Generates a volume visualisation of a video
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
glwidget.h
Go to the documentation of this file.
1 #ifndef GLWIDGET_H
2 #define GLWIDGET_H
3 
4 
5 
6 
7 #include <QOpenGLBuffer>
8 #include <QOpenGLShader>
9 #include <QOpenGLFunctions>
10 #include <QOpenGLFramebufferObject>
11 
12 #include <QGLWidget>
13 #include <QWidget>
14 
16 
17 #define VV_DRAWMODE_VOLUME 0
18 #define VV_DRAWMODE_VIDEODIFF 1
19 
20 #define VV_METRIC_NONE 0
21 #define VV_METRIC_IQDIF 1
22 #define VV_METRIC_YDIF 2
23 #define VV_METRIC_YNDIF 3
24 #define VV_METRIC_YMSE 4
25 #define VV_METRIC_YNMSE 5
26 
27 typedef uint VVMetric;
28 
30 
36 class GLWidget : public QGLWidget, protected QOpenGLFunctions//, protected QGLFunctions
37 {
38  Q_OBJECT
39 
40 public:
42 
46  GLWidget(QWidget *parent = 0);
47 
49  ~GLWidget();
50 
51  QSize minimumSizeHint() const;
52  QSize sizeHint() const;
53 
55 
65  VFLResult openVideoFile(const QString& videoFilePath, int *hRes, int *vRes);
66 
68 
77  VFLResult loadVideoFile(int startFrame, int stepSize, int endFrame);
78 
80 
84  int getFrameCount();
85 
87 
92  void setFrameOffset(int frameOffset);
93 
95 
100  void setStyle(bool horseShoeView);
101 
103 
109  void setBoxSize(int boxSize);
110 
112 
117  void setStepSize(float stepSize);
118 
120 
126  void setMetric(VVMetric metric);
127 
129 
138  void setTransferFunction(GLfloat *tfArray, int arraySize);
139 
140 protected:
141  void initializeGL();
142  void paintGL();
143  void resizeGL(int width, int height);
144  void mouseMoveEvent(QMouseEvent *event);
145  void mousePressEvent(QMouseEvent *event);
146  void mouseReleaseEvent(QMouseEvent *event);
147  void wheelEvent(QWheelEvent *event);
148 
149  PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
150  PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
151  PFNGLTEXIMAGE3DPROC glTexImage3D;
152 private:
153  bool loadShaders();
154  bool prepareShaderProgram( const QString& vertexShaderPath,const QString& fragmentShaderPath, QOpenGLShaderProgram **shader);
155  void createBufferObjects();
156 
157  void setupCamera();
158  void setupModelMatrix();
159 
160  void calculateVideoDiffBuffer(bool normalized);
161  void calculateMeanAndStdDev();
162 
163  QOpenGLShaderProgram *m_volumeShader;
164  QOpenGLShaderProgram *m_videoDiffShader;
165  QOpenGLBuffer *m_boxPosVBO;
166  QOpenGLBuffer *m_texCoordVBO;
167  QOpenGLBuffer *m_boxIBO;
168  QOpenGLBuffer *m_squarePosVBO;
169  QOpenGLBuffer *m_squareTexCoordVBO;
170  QOpenGLBuffer *m_squareIBO;
171 
172  GLuint m_videoTexture;
173  GLuint m_transferTexture;
174  GLuint m_meanTexture;
175  GLuint m_varTexture;
176  GLuint m_boxVAO;
177  GLuint m_squareVAO;
178 
179  QMatrix4x4 m_viewMatrix;
180  QMatrix4x4 m_projectionMatrix;
181  QMatrix4x4 m_modelMatrix;
182 
183  CVideoFrameToTextureLoader *p_videoFrameToTextureLoader;
184  PBYTE p_videoBuffer;
185  PBYTE p_videoDiffBuffer;
186  PBYTE p_videoNDiffBuffer;
187  // GLfloat *pVideoDiffMeanBuffer;
188  // GLfloat *p_videoDiffDeviationBuffer;
189 
190  int m_videoWidth;
191  int m_videoHeight;
192  int m_frameCount;
193 
194  uint m_drawMode;
195 
196  float m_frameOffset;
197  float m_cameraAngleUp;
198  float m_cameraAngleSide;
199  float m_cameraDistance;
200 
201  QVector3D m_cameraCenter;
202  QVector3D m_backgroundColor;
203  QVector3D m_cameraPosition;
204 
205  GLfloat *p_transferFunction;
206 
207  bool m_horseShowView;
208  float m_stepSize;
209  int m_boxSize;
210 
211  VVMetric m_metric;
212 
213  QPoint m_oldMousePos;
214 };
215 
216 #endif // GLWIDGET_H