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 
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
abstract base class for most VTK objects
Definition: vtkObject.h:59
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