iRoCS Toolbox  1.1.0
OpenGlRenderingWidget.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * This file belongs to the iRoCS Toolbox.
4  *
5  * Copyright (C) 2015 Thorsten Falk
6  *
7  * Image Analysis Lab, University of Freiburg, Germany
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  **************************************************************************/
24 
25 #ifndef OPENGLRENDERINGWIDGET_HH
26 #define OPENGLRENDERINGWIDGET_HH
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.hh>
30 #endif
31 
32 #ifdef WIN32
33 #include <windows.h>
34 #endif
35 
36 #include <QtOpenGL/QGLWidget>
37 #include <QtGui/QMouseEvent>
38 
39 #include <blitz/array.h>
40 
42 
43 class OpenGlRenderingWidget : public QGLWidget
44 {
45 
46  Q_OBJECT
47 
48 public:
49 
51  QWidget *parent = NULL);
53 
54 public slots:
55 
56  void resetView();
57 
58 private:
59 
60  void _paintPlane(
61  GLuint textureID,
62  blitz::Array<blitz::TinyVector<unsigned char,4>,2> const &image,
63  blitz::TinyVector<blitz::TinyVector<float,3>,4> const &corners);
64 
65  void initializeGL();
66  void resizeGL(int width, int height);
67  void paintGL();
68 
69  void mousePressEvent(QMouseEvent *event);
70  void mouseReleaseEvent(QMouseEvent *event);
71  void mouseMoveEvent(QMouseEvent *event);
72  void wheelEvent(QWheelEvent *event);
73 
75 
76  QPoint _lastMousePosition;
77  blitz::TinyMatrix<double,4,4> _rotation;
78  blitz::TinyVector<float,2> _translation;
79  float _distanceToOrigin;
80 
81  GLuint _textureXY, _textureXZ, _textureZY;
82 
84 
85 };
86 
87 #endif
OpenGlRenderingWidget(OpenGlRenderingViewWidget *view=NULL, QWidget *parent=NULL)