VTK  9.2.6
QQuickVTKRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QQuickVTKRenderWindow.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 =========================================================================*/
116 #ifndef QQuickVTKRenderWindow_h
117 #define QQuickVTKRenderWindow_h
118 
119 // vtk includes
120 #include "vtkSmartPointer.h" // For vtkSmartPointer
121 
122 // Qt includes
123 #include <QOpenGLFunctions> // For QOpenGLFunctions
124 #include <QPointer> // For QPointer
125 #include <QQuickItem>
126 
127 #include "vtkGUISupportQtQuickModule.h" // for export macro
128 
129 // Forward declarations
130 class QEvent;
132 class QQuickWindow;
133 class QWheelEvent;
135 class vtkImageData;
136 class vtkRenderWindow;
137 class vtkRenderer;
139 
140 class VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKRenderWindow
141  : public QQuickItem
142  , protected QOpenGLFunctions
143 {
144  Q_OBJECT
145  typedef QQuickItem Superclass;
146 
147 public:
154  QQuickVTKRenderWindow(QQuickItem* parent = nullptr);
155 
160 
169  static void setupGraphicsBackend();
170 
172 
181  virtual void setRenderWindow(vtkRenderWindow* renWin);
182  virtual void setRenderWindow(vtkGenericOpenGLRenderWindow* renWin);
183  vtkRenderWindow* renderWindow() const;
185 
189  virtual void mapToViewport(const QRectF& rect, double viewport[4]);
190 
194  QPointer<QQuickVTKInteractorAdapter> interactorAdapter() const;
195 
197 
204  virtual vtkSmartPointer<vtkImageData> captureScreenshot();
205  virtual vtkSmartPointer<vtkImageData> captureScreenshot(double* viewport);
207 
213  virtual bool isInitialized() const;
214 
215 public Q_SLOTS:
224  virtual void sync();
225 
232  virtual void init();
233 
242  virtual void paint();
243 
248  virtual void cleanup();
249 
254  virtual void renderNow();
255 
263  virtual void render();
264 
265 protected Q_SLOTS:
266  virtual void handleWindowChanged(QQuickWindow* w);
267 
268 protected:
269  QPointer<QQuickVTKInteractorAdapter> m_interactorAdapter;
271  bool m_initialized = false;
272 
273  // Screenshot stuff
274  bool m_screenshotScheduled = false;
277 
278  // Event handlers
279 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
280  void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override;
281 #else
282  void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override;
283 #endif
284 
288  bool checkGraphicsBackend();
289 
290 private:
292  void operator=(const QQuickVTKRenderWindow) = delete;
293 };
294 
295 #endif // QQuickVTKRenderWindow_h
vtkNew< vtkRenderer > m_dummyRenderer
abstract specification for renderers
Definition: vtkRenderer.h:72
[QQuickItem] subclass that manages the vtkRenderWindow and, in turn, the OpenGL context of the QML ap...
vtkSmartPointer< vtkGenericOpenGLRenderWindow > m_renderWindow
platform independent render window
QPointer< QQuickVTKInteractorAdapter > m_interactorAdapter
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
Use a vtkWindow as input to image pipeline.
create a window for renderers to draw into
Intermediate class that handles relaying Qt events to VTK.
vtkNew< vtkWindowToImageFilter > m_screenshotFilter