VTK  9.3.1
QQuickVTKRenderWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
104 #ifndef QQuickVTKRenderWindow_h
105 #define QQuickVTKRenderWindow_h
106 
107 // vtk includes
108 #include "vtkDeprecation.h"
109 #include "vtkSmartPointer.h" // For vtkSmartPointer
110 
111 // Qt includes
112 #include <QOpenGLFunctions> // For QOpenGLFunctions
113 #include <QPointer> // For QPointer
114 #include <QQuickItem>
115 
116 #include "vtkGUISupportQtQuickModule.h" // for export macro
117 
118 // Qt Forward declarations
119 class QEvent;
120 class QQuickWindow;
121 class QWheelEvent;
122 
123 VTK_ABI_NAMESPACE_BEGIN
124 
125 // VTK Forward declarations
128 class vtkImageData;
129 class vtkRenderWindow;
130 class vtkRenderer;
132 
134  "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKRenderWindow
135  : public QQuickItem
136  , protected QOpenGLFunctions
137 {
138  Q_OBJECT
139  typedef QQuickItem Superclass;
140 
141 public:
148  QQuickVTKRenderWindow(QQuickItem* parent = nullptr);
149 
153  ~QQuickVTKRenderWindow() override;
154 
163  static void setupGraphicsBackend();
164 
166 
175  virtual void setRenderWindow(vtkRenderWindow* renWin);
176  virtual void setRenderWindow(vtkGenericOpenGLRenderWindow* renWin);
177  vtkRenderWindow* renderWindow() const;
179 
183  virtual void mapToViewport(const QRectF& rect, double viewport[4]);
184 
188  QPointer<QQuickVTKInteractorAdapter> interactorAdapter() const;
189 
191 
198  virtual vtkSmartPointer<vtkImageData> captureScreenshot();
199  virtual vtkSmartPointer<vtkImageData> captureScreenshot(double* viewport);
201 
207  virtual bool isInitialized() const;
208 
209 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
218  virtual void sync();
219 
226  virtual void init();
227 
236  virtual void paint();
237 
242  virtual void cleanup();
243 
248  virtual void renderNow();
249 
257  virtual void render();
258 
259 protected Q_SLOTS:
260  virtual void handleWindowChanged(QQuickWindow* w);
261 
262 protected: // NOLINT(readability-redundant-access-specifiers)
263  QPointer<QQuickVTKInteractorAdapter> m_interactorAdapter;
265  bool m_initialized = false;
266 
267  // Screenshot stuff
268  bool m_screenshotScheduled = false;
271 
272  // Event handlers
273 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
274  void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override;
275 #else
276  void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override;
277 #endif
278 
282  bool checkGraphicsBackend();
283 
284 private:
286  void operator=(const QQuickVTKRenderWindow) = delete;
287 };
288 
289 VTK_ABI_NAMESPACE_END
290 #endif // QQuickVTKRenderWindow_h
vtkNew< vtkRenderer > m_dummyRenderer
abstract specification for renderers
Definition: vtkRenderer.h:61
[QQuickItem] subclass that manages the vtkRenderWindow and, in turn, the OpenGL context of the QML ap...
vtkSmartPointer< vtkGenericOpenGLRenderWindow > m_renderWindow
#define VTK_DEPRECATED_IN_9_3_0(reason)
platform independent render window
QPointer< QQuickVTKInteractorAdapter > m_interactorAdapter
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
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.
QQuickItem that manages a VTK rendering in the QML scenegraph.
Definition: QQuickVTKItem.h:26
vtkNew< vtkWindowToImageFilter > m_screenshotFilter