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
30class QVTKInteractor;
31class vtkObject;
32
33#include "vtkTDxConfigure.h" // defines VTK_USE_TDX
34#ifdef VTK_USE_TDX
35class vtkTDxDevice;
36#endif
37
39class VTKGUISUPPORTQTOPENGL_EXPORT QVTKWidget2 : public QGLWidget
40{
41 Q_OBJECT
42 typedef QGLWidget Superclass;
43public:
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
81 bool autoBufferSwap() const;
82
84
85signals:
86 void mouseEvent(QMouseEvent* e);
87
88public 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
97protected 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
113protected:
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
163private:
165 QVTKWidget2 const& operator=(QVTKWidget2 const&);
167 QVTKWidget2(const QVTKWidget2&);
168
169};
170
171#endif
QVTKWidget2 displays a VTK window in a Qt window.
Definition: QVTKWidget2.h:40
virtual void mousePressEvent(QMouseEvent *event)
QVTKWidget2(const QGLFormat &fmt, QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
virtual QVTKInteractor * GetInteractor()
virtual void paintGL()
QVTKWidget2(QGLContext *ctx, QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
virtual void dragEnterEvent(QDragEnterEvent *)
virtual void leaveEvent(QEvent *)
virtual bool event(QEvent *e)
virtual void IsDirect(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
void SetUseTDx(bool useTDx)
void setAutoBufferSwap(bool)
virtual void Frame()
virtual void IsCurrent(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
virtual void dragMoveEvent(QDragMoveEvent *)
bool autoBufferSwap() const
virtual vtkGenericOpenGLRenderWindow * GetRenderWindow()
virtual void wheelEvent(QWheelEvent *)
virtual void keyPressEvent(QKeyEvent *event)
virtual void mouseMoveEvent(QMouseEvent *event)
virtual void resizeGL(int, int)
QVTKWidget2(QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
constructor
bool GetUseTDx() const
void mouseEvent(QMouseEvent *e)
virtual void dropEvent(QDropEvent *)
virtual int GetMultiSamples() const
virtual void contextMenuEvent(QContextMenuEvent *)
virtual void moveEvent(QMoveEvent *event)
virtual void End()
virtual void MakeCurrent()
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void SupportsOpenGL(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
virtual void keyReleaseEvent(QKeyEvent *event)
virtual ~QVTKWidget2()
destructor
virtual void Start()
vtkSmartPointer< vtkGenericOpenGLRenderWindow > mRenWin
Definition: QVTKWidget2.h:157
virtual void SetRenderWindow(vtkGenericOpenGLRenderWindow *)
QVTKInteractorAdapter * mIrenAdapter
Definition: QVTKWidget2.h:160
virtual bool focusNextPrevChild(bool)
static QGLFormat GetDefaultVTKFormat(vtkGenericOpenGLRenderWindow *w=NULL)
virtual void dragLeaveEvent(QDragLeaveEvent *)
vtkSmartPointer< vtkEventQtSlotConnect > mConnect
Definition: QVTKWidget2.h:161
QVTKWidget2(vtkGenericOpenGLRenderWindow *w, QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
virtual void enterEvent(QEvent *)
virtual void initializeGL()
Manage connections between VTK events and Qt slots.
platform independent render window
abstract base class for most VTK objects
Definition: vtkObject.h:60
API to access a 3DConnexion input device.
Definition: vtkTDxDevice.h:38