VTK
QVTKOpenGLWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QVTKOpenGLWindow.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 #ifndef QVTKOpenGLWindow_H
16 #define QVTKOpenGLWindow_H
17 
18 #include "vtkGUISupportQtModule.h" // For export macro
19 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
20 #include <QOpenGLWindow>
21 
22 class QOffscreenSurface;
23 // Forward VTK class declarations
27 class vtkObject;
28 class vtkRenderWindow;
29 
78 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWindow : public QOpenGLWindow
79 {
80  Q_OBJECT
81  typedef QOpenGLWindow Superclass;
82 public:
84 
86  QOpenGLContext *shareContext = QOpenGLContext::currentContext(),
87  UpdateBehavior updateBehavior = NoPartialUpdate,
88  QWindow *parent = Q_NULLPTR);
89 
90  QVTKOpenGLWindow(QOpenGLContext *shareContext,
91  UpdateBehavior updateBehavior = NoPartialUpdate,
92  QWindow *parent = Q_NULLPTR);
93 
95 
100 
105 
109  static void copyFromFormat(const QSurfaceFormat& format, vtkRenderWindow* win);
110 
114  static void copyToFormat(vtkRenderWindow* win, QSurfaceFormat& format);
115 
121  static QSurfaceFormat defaultFormat();
122 
127 
131  virtual void setEnableHiDPI(bool enable);
132 
137  bool ProcessEvent(QEvent* e);
138 
139 signals:
144  void windowEvent(QEvent* e);
145 
146 public slots:
150  virtual void MakeCurrent();
151 
155  virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event,
156  void* client_data, void* call_data);
157 
161  virtual void Frame();
162 
166  virtual void Start();
167 
171  virtual void End() {}
172 
176  virtual void IsDirect(vtkObject* caller, unsigned long vtk_event,
177  void* client_data, void* call_data);
178 
182  virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event,
183  void* client_data, void* call_data);
184 
188  virtual void UpdateStereoType(vtkObject* caller, unsigned long vtk_event,
189  void* client_data, void* call_data);
190 
191  /*
192  * slot to change the cursor
193  */
194  virtual void ChangeCursor(vtkObject* caller, unsigned long vtk_event,
195  void* client_data, void* call_data);
196 
200  virtual void widgetEvent(QEvent* e);
201 
206  virtual bool isValid();
207 
212  virtual bool isCurrent();
213 
214 private slots:
218  virtual void ResizeToVTKWindow();
219 
220 protected:
224  virtual void initializeGL();
225  virtual void paintGL();
226  virtual void moveEvent(QMoveEvent* event);
227  virtual bool event(QEvent* e);
228  virtual void mousePressEvent(QMouseEvent* event);
229  virtual void mouseMoveEvent(QMouseEvent* event);
230  virtual void mouseReleaseEvent(QMouseEvent* event);
231  virtual void mouseDoubleClickEvent(QMouseEvent* event);
232  virtual void keyPressEvent(QKeyEvent* event);
233  virtual void keyReleaseEvent(QKeyEvent* event);
234  virtual void enterEvent(QEvent*);
235  virtual void leaveEvent(QEvent*);
236  virtual void wheelEvent(QWheelEvent*);
237 
238 private:
243 
244  bool EnableHiDPI;
245  int OriginalDPI;
246 
250  QVTKInteractorAdapter* IrenAdapter;
251  vtkSmartPointer<vtkEventQtSlotConnect> EventSlotConnector;
252 
253  QOffscreenSurface* OffscreenSurface;
254 };
255 
256 #endif // QVTKOpenGLWindow_H
QVTKOpenGLWindow::wheelEvent
virtual void wheelEvent(QWheelEvent *)
QVTKOpenGLWindow::initializeGL
virtual void initializeGL()
Override event handler.
QVTKOpenGLWindow::GetRenderWindow
virtual vtkGenericOpenGLRenderWindow * GetRenderWindow()
Get the VTK render window used for rendering.
QVTKOpenGLWindow::enterEvent
virtual void enterEvent(QEvent *)
QVTKOpenGLWindow::event
virtual bool event(QEvent *e)
QVTKOpenGLWindow::leaveEvent
virtual void leaveEvent(QEvent *)
QVTKOpenGLWindow::isValid
virtual bool isValid()
Returns true if the internal QOpenGLWindow's is valid, i.e.
QVTKOpenGLWindow
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
Definition: QVTKOpenGLWindow.h:79
QVTKOpenGLWindow::UpdateStereoType
virtual void UpdateStereoType(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
slot called when the stereo type of the render window changed
vtkEventQtSlotConnect
Manage connections between VTK events and Qt slots.
Definition: vtkEventQtSlotConnect.h:63
QVTKOpenGLWindow::SupportsOpenGL
virtual void SupportsOpenGL(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
slot called when vtk wants to know if a window supports OpenGL
QVTKOpenGLWindow::Start
virtual void Start()
slot called when vtk wants to start the render
QVTKOpenGLWindow::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
QVTKOpenGLWindow::copyFromFormat
static void copyFromFormat(const QSurfaceFormat &format, vtkRenderWindow *win)
Sets up vtkRenderWindow ivars using QSurfaceFormat.
vtkGenericOpenGLRenderWindow
platform independent render window
Definition: vtkGenericOpenGLRenderWindow.h:41
vtkSmartPointer< vtkGenericOpenGLRenderWindow >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
QVTKOpenGLWindow::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event)
QVTKOpenGLWindow::moveEvent
virtual void moveEvent(QMoveEvent *event)
QVTKInteractorAdapter
Definition: QVTKInteractorAdapter.h:51
QVTKOpenGLWindow::QVTKOpenGLWindow
QVTKOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=Q_NULLPTR)
QVTKOpenGLWindow::copyToFormat
static void copyToFormat(vtkRenderWindow *win, QSurfaceFormat &format)
Using the vtkRenderWindow, setup QSurfaceFormat.
QVTKOpenGLWindow::End
virtual void End()
slot called when vtk wants to end the render
Definition: QVTKOpenGLWindow.h:171
QVTKOpenGLWindow::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *event)
QVTKOpenGLWindow::isCurrent
virtual bool isCurrent()
Returns true if the internal OpenGL contect is the actual current OpenGL context, false otherwise.
QVTKOpenGLWindow::Frame
virtual void Frame()
slot called when vtk wants to frame the window
QVTKOpenGLWindow::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QMouseEvent *event)
QVTKOpenGLWindow::keyReleaseEvent
virtual void keyReleaseEvent(QKeyEvent *event)
QVTKOpenGLWindow::ProcessEvent
bool ProcessEvent(QEvent *e)
Process a QEvent and send it to the internal render window interactor returns whether the event was r...
QVTKOpenGLWindow::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event)
QVTKOpenGLWindow::IsCurrent
virtual void IsCurrent(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
slot called when vtk wants to know if the context is current
vtkSmartPointer.h
QVTKOpenGLWindow::defaultFormat
static QSurfaceFormat defaultFormat()
Returns a typical QSurfaceFormat suitable for most applications using QVTKOpenGLWidget.
QVTKOpenGLWindow::IsDirect
virtual void IsDirect(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
slot called when vtk wants to know if a window is direct
QVTKOpenGLWindow::QVTKOpenGLWindow
QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow *w, QOpenGLContext *shareContext=QOpenGLContext::currentContext(), UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=Q_NULLPTR)
QVTKOpenGLWindow::setEnableHiDPI
virtual void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
QVTKOpenGLWindow::widgetEvent
virtual void widgetEvent(QEvent *e)
slot to process events coming from the widget containing this window
QVTKOpenGLWindow::ChangeCursor
virtual void ChangeCursor(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
QVTKOpenGLWindow::~QVTKOpenGLWindow
~QVTKOpenGLWindow()
QVTKOpenGLWindow::GetInteractorAdapter
virtual QVTKInteractorAdapter * GetInteractorAdapter()
Get the QEvent to VTK events translator.
QVTKOpenGLWindow::QVTKOpenGLWindow
QVTKOpenGLWindow()
QVTKOpenGLWindow::windowEvent
void windowEvent(QEvent *e)
Signal emitted when a QMouseEvent has been receive, with the corresponding event as argument.
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:88
QVTKOpenGLWindow::paintGL
virtual void paintGL()
QVTKOpenGLWindow::SetRenderWindow
virtual void SetRenderWindow(vtkGenericOpenGLRenderWindow *)
Set the VTK render window used for rendering.
QVTKOpenGLWindow::MakeCurrent
virtual void MakeCurrent()
slot to make this vtk render window current