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 
99  virtual void SetRenderWindow(vtkGenericOpenGLRenderWindow*);
100 
104  virtual vtkGenericOpenGLRenderWindow* GetRenderWindow();
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 
126  virtual QVTKInteractorAdapter* GetInteractorAdapter();
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 
194  virtual void widgetEvent(QEvent* e);
195 
200  virtual bool isValid();
201 
206  virtual bool isCurrent();
207 
208 private slots:
212  virtual void ResizeToVTKWindow();
213 
214 protected:
218  virtual void initializeGL();
219  virtual void paintGL();
220  virtual void moveEvent(QMoveEvent* event);
221  virtual bool event(QEvent* e);
222  virtual void mousePressEvent(QMouseEvent* event);
223  virtual void mouseMoveEvent(QMouseEvent* event);
224  virtual void mouseReleaseEvent(QMouseEvent* event);
225  virtual void mouseDoubleClickEvent(QMouseEvent* event);
226  virtual void keyPressEvent(QKeyEvent* event);
227  virtual void keyReleaseEvent(QKeyEvent* event);
228  virtual void enterEvent(QEvent*);
229  virtual void leaveEvent(QEvent*);
230  virtual void wheelEvent(QWheelEvent*);
231 
232 private:
237 
238  bool EnableHiDPI;
239  int OriginalDPI;
240 
244  QVTKInteractorAdapter* IrenAdapter;
245  vtkSmartPointer<vtkEventQtSlotConnect> EventSlotConnector;
246 
247  QOffscreenSurface* OffscreenSurface;
248 };
249 
250 #endif // QVTKOpenGLWindow_H
abstract base class for most VTK objects
Definition: vtkObject.h:53
Manage connections between VTK events and Qt slots.
platform independent render window
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
create a window for renderers to draw into
virtual void End()
slot called when vtk wants to end the render