VTK
QVTKWidget2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QVTKWidget2.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME QVTKWidget2 - Display a vtkRenderWindow in a Qt's QGLWidget.
16 // .SECTION Description
17 // QVTKWidget2 provides a way to display VTK data in a Qt OpenGL widget.
18 
19 #ifndef Q_VTK_WIDGET2_H
20 #define Q_VTK_WIDGET2_H
21 
22 #include "vtkGUISupportQtOpenGLModule.h" // For export macro
23 #include <QtOpenGL/QGLWidget>
24 #include "vtkSmartPointer.h"
25 #include "QVTKWin32Header.h"
26 
30 class QVTKInteractor;
31 class vtkObject;
32 
33 #include "vtkTDxConfigure.h" // defines VTK_USE_TDX
34 #ifdef VTK_USE_TDX
35 class vtkTDxDevice;
36 #endif
37 
39 class VTKGUISUPPORTQTOPENGL_EXPORT QVTKWidget2 : public QGLWidget
40 {
41  Q_OBJECT
42  typedef QGLWidget Superclass;
43 public:
45  QVTKWidget2(QWidget* parent = NULL, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
46  QVTKWidget2(vtkGenericOpenGLRenderWindow* w, QWidget* parent = NULL, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
47  QVTKWidget2(QGLContext* ctx, QWidget* parent = NULL, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
48  QVTKWidget2(const QGLFormat& fmt, QWidget* parent = NULL, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
50  virtual ~QVTKWidget2();
51 
52  // Description:
53  // Set the vtk render window, if you wish to use your own vtkRenderWindow
55 
56  // Description:
57  // Get the vtk render window.
59 
60  // Description:
61  // Get the Qt/vtk interactor that was either created by default or set by the user
63 
64  // Description:
65  // Get the number of multisamples used for antialiasing
66  virtual int GetMultiSamples() const;
67 
68  // Description:
69  // Use a 3DConnexion device. Initial value is false.
70  // If VTK is not build with the TDx option, this is no-op.
71  // If VTK is build with the TDx option, and a device is not connected,
72  // a warning is emitted.
73  // It is must be called before the first Render to be effective, otherwise
74  // it is ignored.
75  void SetUseTDx(bool useTDx);
76  bool GetUseTDx() const;
77 
78  // Description:
79  // Make the swap buffers functions public
80  void setAutoBufferSwap(bool);
81  bool autoBufferSwap() const;
82 
84 
85 signals:
86  void mouseEvent(QMouseEvent* e);
87 
88 public Q_SLOTS:
89 
90  // Description:
91  // Receive notification of the creation of the TDxDevice.
92  // Only relevant for Unix.
93 #ifdef VTK_USE_TDX
94  void setDevice(vtkTDxDevice *device);
95 #endif
96 
97 protected Q_SLOTS:
98  // slot to make this vtk render window current
99  virtual void MakeCurrent();
100  // slot called when vtk wants to know if the context is current
101  virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
102  // slot called when vtk wants to frame the window
103  virtual void Frame();
104  // slot called when vtk wants to start the render
105  virtual void Start();
106  // slot called when vtk wants to end the render
107  virtual void End();
108  // slot called when vtk wants to know if a window is direct
109  virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
110  // slot called when vtk wants to know if a window supports OpenGL
111  virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
112 
113 protected:
114  // overloaded initialize handler
115  virtual void initializeGL();
116  // overloaded resize handler
117  virtual void resizeGL(int, int);
118  // overloaded paint handler
119  virtual void paintGL();
120  // overloaded move handler
121  virtual void moveEvent(QMoveEvent* event);
122 
123  // overloaded touch events
124  virtual bool event(QEvent* e);
125  // overloaded mouse press handler
126  virtual void mousePressEvent(QMouseEvent* event);
127  // overloaded mouse move handler
128  virtual void mouseMoveEvent(QMouseEvent* event);
129  // overloaded mouse release handler
130  virtual void mouseReleaseEvent(QMouseEvent* event);
131  // overloaded key press handler
132  virtual void keyPressEvent(QKeyEvent* event);
133  // overloaded key release handler
134  virtual void keyReleaseEvent(QKeyEvent* event);
135  // overloaded enter event
136  virtual void enterEvent(QEvent*);
137  // overloaded leave event
138  virtual void leaveEvent(QEvent*);
139  // overload wheel mouse event
140  virtual void wheelEvent(QWheelEvent*);
141 
142  // overload context menu event
143  virtual void contextMenuEvent(QContextMenuEvent*);
144  // overload drag enter event
145  virtual void dragEnterEvent(QDragEnterEvent*);
146  // overload drag move event
147  virtual void dragMoveEvent(QDragMoveEvent*);
148  // overload drag leave event
149  virtual void dragLeaveEvent(QDragLeaveEvent*);
150  // overload drop event
151  virtual void dropEvent(QDropEvent*);
152 
153  // overload focus handling so tab key is passed to VTK
154  virtual bool focusNextPrevChild(bool);
155 
156  // the vtk render window
158  bool UseTDx;
159 
162 
163 private:
165  QVTKWidget2 const& operator=(QVTKWidget2 const&);
167  QVTKWidget2(const QVTKWidget2&);
168 
169 };
170 
171 #endif
QVTKWidget2::QVTKWidget2
QVTKWidget2(vtkGenericOpenGLRenderWindow *w, QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
QVTKWidget2
QVTKWidget2 displays a VTK window in a Qt window.
Definition: QVTKWidget2.h:40
QVTKWidget2::mConnect
vtkSmartPointer< vtkEventQtSlotConnect > mConnect
Definition: QVTKWidget2.h:161
QVTKWidget2::IsDirect
virtual void IsDirect(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
QVTKWidget2::GetMultiSamples
virtual int GetMultiSamples() const
QVTKWidget2::leaveEvent
virtual void leaveEvent(QEvent *)
QVTKWidget2::dragMoveEvent
virtual void dragMoveEvent(QDragMoveEvent *)
QVTKWidget2::keyReleaseEvent
virtual void keyReleaseEvent(QKeyEvent *event)
vtkEventQtSlotConnect
Manage connections between VTK events and Qt slots.
Definition: vtkEventQtSlotConnect.h:63
QVTKWidget2::GetRenderWindow
virtual vtkGenericOpenGLRenderWindow * GetRenderWindow()
QVTKWidget2::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *)
vtkGenericOpenGLRenderWindow
platform independent render window
Definition: vtkGenericOpenGLRenderWindow.h:34
vtkSmartPointer< vtkGenericOpenGLRenderWindow >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
QVTKWidget2::moveEvent
virtual void moveEvent(QMoveEvent *event)
QVTKWidget2::SupportsOpenGL
virtual void SupportsOpenGL(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
QVTKWidget2::Start
virtual void Start()
QVTKWidget2::event
virtual bool event(QEvent *e)
QVTKInteractorAdapter
Definition: QVTKInteractorAdapter.h:51
QVTKWidget2::GetInteractor
virtual QVTKInteractor * GetInteractor()
QVTKWidget2::IsCurrent
virtual void IsCurrent(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
QVTKWidget2::paintGL
virtual void paintGL()
QVTKWidget2::QVTKWidget2
QVTKWidget2(QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
constructor
QVTKWidget2::resizeGL
virtual void resizeGL(int, int)
QVTKWidget2::mIrenAdapter
QVTKInteractorAdapter * mIrenAdapter
Definition: QVTKWidget2.h:160
QVTKWidget2::GetDefaultVTKFormat
static QGLFormat GetDefaultVTKFormat(vtkGenericOpenGLRenderWindow *w=NULL)
QVTKWidget2::QVTKWidget2
QVTKWidget2(QGLContext *ctx, QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
vtkSmartPointer.h
QVTKWidget2::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *event)
QVTKWidget2::SetRenderWindow
virtual void SetRenderWindow(vtkGenericOpenGLRenderWindow *)
QVTKWidget2::dropEvent
virtual void dropEvent(QDropEvent *)
QVTKWidget2::MakeCurrent
virtual void MakeCurrent()
QVTKWidget2::End
virtual void End()
QVTKWin32Header.h
vtkTDxDevice
API to access a 3DConnexion input device.
Definition: vtkTDxDevice.h:38
QVTKWidget2::Frame
virtual void Frame()
QVTKWidget2::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
QVTKWidget2::UseTDx
bool UseTDx
Definition: QVTKWidget2.h:158
QVTKWidget2::setAutoBufferSwap
void setAutoBufferSwap(bool)
QVTKWidget2::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event)
QVTKWidget2::QVTKWidget2
QVTKWidget2(const QGLFormat &fmt, QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
QVTKWidget2::mRenWin
vtkSmartPointer< vtkGenericOpenGLRenderWindow > mRenWin
Definition: QVTKWidget2.h:157
QVTKWidget2::autoBufferSwap
bool autoBufferSwap() const
QVTKWidget2::~QVTKWidget2
virtual ~QVTKWidget2()
destructor
QVTKWidget2::dragLeaveEvent
virtual void dragLeaveEvent(QDragLeaveEvent *)
QVTKWidget2::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event)
QVTKWidget2::GetUseTDx
bool GetUseTDx() const
QVTKWidget2::enterEvent
virtual void enterEvent(QEvent *)
QVTKWidget2::mouseEvent
void mouseEvent(QMouseEvent *e)
QVTKWidget2::SetUseTDx
void SetUseTDx(bool useTDx)
QVTKWidget2::wheelEvent
virtual void wheelEvent(QWheelEvent *)
QVTKWidget2::focusNextPrevChild
virtual bool focusNextPrevChild(bool)
QVTKInteractor
Definition: QVTKInteractor.h:65
QVTKWidget2::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *)
QVTKWidget2::initializeGL
virtual void initializeGL()