Visualization 2 - Lab Course
 All Classes Functions Enumerations Enumerator
renderwindow.h
1 #ifndef RENDERWINDOW_H
2 #define RENDERWINDOW_H
3 
4 #include <QWindow>
5 #include <QtOpenGL>
6 #include <QOpenGLFunctions_3_2_Core>
7 #include <QTimer>
8 
9 #include "Volume.h"
10 #include "cannyedge.h"
11 
12 #include "TransferWidget.hpp"
13 
14 #include "Tools.h"
15 
23 class RenderWindow : public QWindow
24 {
25  Q_OBJECT
26 
27 public:
28 
34  RenderWindow(QScreen *screen = 0);
35 
39  ~RenderWindow();
40 
45  void initialize();
46 
51  void update();
52 
57  void render();
58 
64  void updateAndRender();
65 
72  void resize(int width, int height);
73 
79  void setVolumeData(const std::string & strFilename);
80 
86  void setTransferfunction(const vector<TransferWidget::TransferFeature> &features);
87 
91  void initializeMatrices();
95  void initializeSettings();
96 
101  {
104  };
105 
110  {
113  };
114 
119  {
120  FRONT_TO_BACK = true,
121  BACK_TO_FRONT = false
122  };
123 
128  {
132  };
133 
134 public slots:
139  void onMessageLogged( QOpenGLDebugMessage message );
143  void onTimeout();
148  void updateSlice(int _value);
153  void setSliceDirection(int _dir);
159  void setRenderType(int _renderType);
165  void setIsPerspectiveProjection(bool _perspectiveProjection);
170  void setRenderShaded(bool _renderShaded);
175  void setVolumeStepSize(double _stepSize);
181  void setVolumeRenderMode(int _volumeRenderMode);
187  void setVolumeCompositionMode(bool _compositingMode);
192  void setRenderCannyEdges(bool _showCannyEdges);
197  void setRenderJunctions(bool _showJunctions);
202  void setRenderXJunctions(bool _showXJunctions);
207  void setUseBlurredTF(bool _useBlurredTF);
211  void calculateDepthEnergy();
212 
213 signals:
217  void depthOrderChanged(float);
218 
219 private:
220  void prepareShaders();
221  void prepareTextures();
222  void prepareFramebuffers();
223  void prepareQuadVertexArrayObject();
224  void prepareCubeVertexArrayObject();
225 
226  void updateSlice();
227  void updateVolume();
228  void renderSlice();
229  void renderVolume();
230  void renderCubeFrontfaces();
231  void renderCubeBackfaces();
232 
233  void renderTextureToScreen(GLuint texture, bool clearScreen = true);
234  void renderTextureRectToScreen(GLuint texture, bool clearScreen = true);
235  void renderQImageToScreen(const QImage &image, bool clearScreen = true);
236 
237  CannyEdge *cannyEdgeDetector;
238 
239  QOpenGLContext *v_context;
240 
241  QOpenGLFunctions_3_2_Core *v_funcs;
242 
243  QOpenGLShaderProgram *v_sliceShader;
244  QOpenGLShaderProgram *v_cubeShader;
245  QOpenGLShaderProgram *v_rayShader;
246  QOpenGLShaderProgram *v_imageRectShader;
247  QOpenGLShaderProgram *v_imageShader;
248 
249  QOpenGLFramebufferObject *v_frontFB;
250  QOpenGLFramebufferObject *v_backFB;
251  QOpenGLFramebufferObject *v_screenRectFB;
252 
253  QOpenGLVertexArrayObject v_quad;
254  QOpenGLVertexArrayObject v_cube;
255 
256  QOpenGLDebugLogger *m_logger;
257 
258  float *verticesFullscreenQuad;
259 
260  GLuint v_transferfunctionTex;
261  GLuint v_tmpTex;
262  QImage junctionImage;
263  QImage xJunctionImage;
264 
265  QMatrix4x4 vMatrixSlice;
266  float sliceNumber;
267  int sliceDirection;
268  GLuint v_sliceTex;
269 
270  Volume *volumeData;
271  QMatrix4x4 pMatrixVolume;
272  QMatrix4x4 vMatrixVolume;
273  QMatrix4x4 mMatrixVolume;
274  VolumeRenderMode volumeRenderMode;
275  VolumeCompositionMode volumeCompositionMode;
276  float volumeStepsize;
277  bool volumeShadedRendering;
278  bool showCannyEdges;
279  bool showJunctions;
280  bool showXJunctions;
281  bool useBluredTF;
282 
283  QMatrix4x4 mvpMatrixScreenRect;
284 
285  RenderType renderType;
286  ProjectionType projectionType;
287 
288  float alphaView;
289  float betaView;
290  float distanceView;
291  float inclinationView;
292  float azimuthView;
293  QVector3D viewPosVolume;
294  QPoint lastMousePos;
295  bool isMouseMoving;
296 
297  float depthOrdering;
298 
299  float *copyTransferfunctionValues;
300  float sigmaTF;
301  int filterSizeTF;
302 
303 protected:
308  void mousePressEvent(QMouseEvent *event);
313  void mouseMoveEvent(QMouseEvent *event);
318  void mouseReleaseEvent(QMouseEvent *event);
323  void wheelEvent(QWheelEvent *event);
324 };
325 
326 #endif // RENDERWINDOW_H