anatomist 6.0.4
3D neuroimaging data viewer
glwidgetmanager.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef ANATOMIST_WINDOW_GLWIDGETMANAGER_H
36#define ANATOMIST_WINDOW_GLWIDGETMANAGER_H
37
41
42#ifdef ANA_USE_QOPENGLWIDGET
43#include <QOpenGLWidget>
44#else
45#include <QtOpenGL/QGLWidget>
46#endif
47class QGestureEvent;
48class QTouchEvent;
49
50
51namespace aims
52{
53 class Quaternion;
54}
55
57
58
59namespace anatomist
60{
61 class AWindow;
62
63 namespace internal
64 {
65 class AGraphicsView;
66 }
67
68
74 {
75 public:
84
85 virtual QSize sizeHint() const;
86 virtual QSize minimumSizeHint() const;
87
88 virtual void updateGL();
92 virtual void paintScene();
93
94 virtual void initializeGL();
95 virtual void resizeGL( int w, int h );
96 virtual void paintGL();
97 virtual void gestureEvent( QGestureEvent *event );
98 virtual void touchEvent( QTouchEvent *event );
99 virtual void mousePressEvent( QMouseEvent* me );
100 virtual void mouseReleaseEvent( QMouseEvent* me );
101 virtual void mouseMoveEvent( QMouseEvent* me );
102 virtual void mouseDoubleClickEvent( QMouseEvent * );
103 virtual void keyPressEvent( QKeyEvent* ev );
104 virtual void keyReleaseEvent( QKeyEvent* ev );
105 virtual void focusInEvent( QFocusEvent * );
106 virtual void focusOutEvent( QFocusEvent * );
107 virtual void wheelEvent( QWheelEvent * );
108
109 public:
110 // this private structure is public because it's used by internal functions
111 struct Private;
112 friend class ::GLWidgetManager_Private_QObject;
113
114#ifdef ANA_USE_QOPENGLWIDGET
115 GLWidgetManager( anatomist::AWindow* win, QOpenGLWidget* widget );
116#else
117 GLWidgetManager( anatomist::AWindow* win, QGLWidget* widget );
118#endif
120
121#ifdef ANA_USE_QOPENGLWIDGET
122 QOpenGLWidget* qglWidget();
123#else
124 QGLWidget* qglWidget();
125#endif
128 QObject* qobject();
129
137 void setExtrema( const Point3df & bmin, const Point3df & bmax );
139 void setWindowExtrema( const Point3df & bmin, const Point3df & bmax );
144 void setLightGLList( GLuint l );
145 GLuint lightGLList() const;
146 void setPreferredSize( int, int );
147 void setMinimumSizeHint( const QSize & );
148 virtual bool positionFromCursor( int x, int y, Point3df & position );
149 virtual bool cursorFromPosition( const Point3df & position, Point3df & cursor );
150 virtual Point3df objectPositionFromWindow( const Point3df & winpos );
151 virtual void readBackBuffer( int x, int y, GLubyte & red, GLubyte & green,
152 GLubyte & blue );
154 virtual bool translateCursorPosition( float x, float y,
155 Point3df & position );
156
157 virtual std::string name() const;
158 void setZoom( float z );
159 float zoom() const;
163 void setQuaternion( const Point4df & q );
165 const float* rotation() const;
166 void setXDirection( bool invert );
167 void setYDirection( bool invert );
168 void setZDirection( bool invert );
169 bool invertedX() const;
170 bool invertedY() const;
171 bool invertedZ() const;
174 bool perspectiveEnabled() const;
175 void enablePerspective( bool );
176 float perspectiveAngle() const;
177 void setPerspectiveAngle( float a );
180 float perspectiveFarPlane() const;
181 void setPerspectiveFarPlane( float d );
182 float perspectiveNearPlane() const;
185 void setAutoCentering( bool );
186 bool autoCentering() const;
187 virtual void recordStart( const QString & basename,
188 const QString & format = QString(),
189 int width=0, int height=0 );
190 void saveContents( const QString & filename, const QString & format,
191 int width=0, int height=0 );
192 QImage snapshotImage( int bufmode, int width=0, int height=0 );
193 void saveOtherBuffer( const QString & filename,
194 const QString & format, int mode,
195 int width=0, int height=0 );
196 void setOtherBuffersSaveMode( int mode );
198
203 void enableDepthPeeling( bool );
204 unsigned depthPeelingPasses() const;
205 void setDepthPeelingPasses( unsigned n );
206 unsigned numTextureUnits() const;
207 bool recording() const;
208
209#ifdef ANA_USE_QOPENGLWIDGET
210 static QOpenGLWidget* sharedWidget();
211#else
212 static QGLWidget* sharedWidget();
213#endif
214 void setBackgroundAlpha( float a );
215
220
222 const AWindow * aWindow() const;
223
224 virtual int width() = 0;
225 virtual int height() = 0;
226 // public slots:
227
228 virtual void saveContents();
230 virtual void recordStart();
232 virtual void recordStop();
233
234 bool hasCameraChanged() const;
237 void resizeOtherFramebuffers( int w, int h );
238
241
242 protected:
243 virtual void project( int virtualWidth=0, int virtualHeight=0 );
244 virtual void setupView( int virtualWidth=0, int virtualHeight=0 );
250 virtual void paintGL( DrawMode m, int virtualWidth=0, int virtualHeight=0 );
251 void record();
252
255
256 virtual void updateZBuffer();
257 bool isZBufferUpToDate() const;
258 void setZBufferUpdated( bool );
262
263 private:
264 Private *_pd;
265 };
266
267};
268
269
272{
273 Q_OBJECT
274
275public:
279
280public slots:
286
287protected slots:
289
290private:
292};
293
294
295#endif
#define slots
GLWidgetManager_Private_QObject(QObject *parent, anatomist::GLWidgetManager *man)
Abstract base class Anatomist window.
Definition Window.h:59
Base class for OpenGL-rendering widget.
bool perspectiveEnabled() const
void setOtherBuffersSaveMode(int mode)
GLWidgetManager * rightEye()
bool depthPeelingEnabled() const
bool depthPeelingAllowed() const
void setYDirection(bool invert)
virtual void resizeGL(int w, int h)
const aims::Quaternion & quaternion() const
The quaternion rotates the initial eye direction (0, 0, 1) into the view coordinates,...
void setMinimumSizeHint(const QSize &)
void saveOtherBuffer(const QString &filename, const QString &format, int mode, int width=0, int height=0)
virtual bool positionFromCursor(int x, int y, Point3df &position)
void setLightGLList(GLuint l)
virtual void focusInEvent(QFocusEvent *)
void setRightEye(GLWidgetManager *)
bool perspectiveAutoFarPlane() const
void setWindowExtrema(const Point3df &bmin, const Point3df &bmax)
set window extrema (in the local orientation)
const AWindow * aWindow() const
bool isZBufferUpToDate() const
float perspectiveNearPlane() const
void drawObjects(DrawMode m=Normal)
void resizeOtherFramebuffers(int w, int h)
void setPerspectiveAngle(float a)
virtual bool cursorFromPosition(const Point3df &position, Point3df &cursor)
virtual void keyPressEvent(QKeyEvent *ev)
Point3df rotationCenter() const
virtual void recordStart()
void setLeftEye(GLWidgetManager *)
virtual void mouseReleaseEvent(QMouseEvent *me)
virtual void gestureEvent(QGestureEvent *event)
virtual void paintScene()
basically calls paintGL()
virtual void mousePressEvent(QMouseEvent *me)
GLWidgetManager(anatomist::AWindow *win, QGLWidget *widget)
virtual void keyReleaseEvent(QKeyEvent *ev)
Point3df windowBoundingMin() const
virtual void focusOutEvent(QFocusEvent *)
Point3df boundingMin() const
GLuint lightGLList() const
virtual void readBackBuffer(int x, int y, GLubyte &red, GLubyte &green, GLubyte &blue)
void setPerspectiveAutoFarPlane(bool x)
virtual void paintGL(DrawMode m, int virtualWidth=0, int virtualHeight=0)
Virtual width and height are used to perform off-screen rendering.
GLWidgetManager * leftEye()
virtual void recordStart(const QString &basename, const QString &format=QString(), int width=0, int height=0)
QImage snapshotImage(int bufmode, int width=0, int height=0)
virtual void setupView(int virtualWidth=0, int virtualHeight=0)
virtual void initializeGL()
void setRotationCenter(const Point3df &)
anatomist::GLPrimitives primitives() const
float perspectiveFarPlane() const
bool isRGBBufferUpToDate() const
virtual void updateZBuffer()
virtual void saveContents()
unsigned depthPeelingPasses() const
unsigned numTextureUnits() const
void setSelectionPrimitives(const anatomist::GLPrimitives &li)
virtual std::string name() const
bool hasTransparentObjects() const
void bindOtherFramebuffer(DrawMode m)
virtual void mouseMoveEvent(QMouseEvent *me)
float perspectiveNearPlaneRatio() const
void depthPeelingRender(DrawMode m=Normal)
void saveContents(const QString &filename, const QString &format, int width=0, int height=0)
void setQuaternion(const Point4df &q)
int otherBuffersSaveMode() const
anatomist::GLPrimitives _selectprimitives
anatomist::GLPrimitives selectionPrimitives() const
void setPerspectiveNearPlaneRatio(float d)
void setPreferredSize(int, int)
virtual void project(int virtualWidth=0, int virtualHeight=0)
virtual bool translateCursorPosition(float x, float y, Point3df &position)
void setExtrema(const Point3df &bmin, const Point3df &bmax)
set objects extrema, this also automatically sets the window bounding box
virtual void touchEvent(QTouchEvent *event)
virtual QSize minimumSizeHint() const
void setDepthPeelingPasses(unsigned n)
void renderBackBuffer(ViewState::glSelectRenderMode selectmode)
void setXDirection(bool invert)
virtual Point3df objectPositionFromWindow(const Point3df &winpos)
virtual QSize sizeHint() const
void setBackgroundAlpha(float a)
GLubyte * getTextureFromBackBuffer()
void setPrimitives(const anatomist::GLPrimitives &li)
virtual void mouseDoubleClickEvent(QMouseEvent *)
Point3df boundingMax() const
float perspectiveAngle() const
QObject * qobject()
this QObject is used for slots: updateZBuffer, saveContents, recordStart, recordStop
void setPerspectiveFarPlane(float d)
void setZDirection(bool invert)
virtual void wheelEvent(QWheelEvent *)
static QGLWidget * sharedWidget()
Point3df windowBoundingMax() const
void setQuaternion(const aims::Quaternion &q)
const float * rotation() const
anatomist::GLPrimitives _primitives
see http://doc.qt.digia.com/qq/qq26-openglcanvas.html
std::list< RefGLItem > GLPrimitives
Definition primitive.h:156
AimsVector< float, 3 > Point3df
AimsVector< float, 4 > Point4df