VTK  9.7.1
QVTKRenderWindowAdapter.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
3 #ifndef QVTKRenderWindowAdapter_h
4 #define QVTKRenderWindowAdapter_h
5 
25 #include "vtkGUISupportQtModule.h" // For export macro
26 #include <QObject>
27 
28 #include <QCursor> // for ivar
29 #include <QScopedPointer> // for ivar
30 
31 class QOpenGLContext;
32 class QSurfaceFormat;
33 class QWidget;
34 class QWindow;
35 
36 VTK_ABI_NAMESPACE_BEGIN
38 class vtkObject;
39 
40 class VTKGUISUPPORTQT_EXPORT QVTKRenderWindowAdapter : public QObject
41 {
42  Q_OBJECT;
43  using Superclass = QObject;
44 
45 public:
47 
55  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QWindow* parent);
57  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QWidget* parent);
59 
60  ~QVTKRenderWindowAdapter() override;
61 
84  static QSurfaceFormat defaultFormat(bool stereo_capable = false);
85 
91  void paint();
92 
104  void resize(int width, int height);
105 
107 
111  bool blit(
112  unsigned int targetId, int targetAttachement, const QRect& targetRect, bool left = true);
113  bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
114  {
115  return this->blit(targetId, targetAttachement, targetRect, true);
116  }
117  bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
118  {
119  return this->blit(targetId, targetAttachement, targetRect, false);
120  }
122 
127  bool handleEvent(QEvent* evt);
128 
130 
133  void setDefaultCursor(const QCursor& cursor) { this->DefaultCursor = cursor; }
134  const QCursor& defaultCursor() const { return this->DefaultCursor; }
136 
138 
142  void setEnableTouchEventProcessing(bool value);
144 
146 
156  void setEnableHiDPI(bool value);
158 
160 
164  void setUnscaledDPI(int value);
166 
168 
172  void setCustomDevicePixelRatio(double dpr);
174 
175 private Q_SLOTS:
176  void contextAboutToBeDestroyed();
177 
178 private: // NOLINT(readability-redundant-access-specifiers)
180  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QObject* widgetOrWindow);
181  Q_DISABLE_COPY(QVTKRenderWindowAdapter);
182 
183  class QVTKInternals;
184  QScopedPointer<QVTKInternals> Internals;
185 
186  QCursor DefaultCursor;
187 };
188 
189 VTK_ABI_NAMESPACE_END
190 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:52
const QCursor & defaultCursor() const
Get/set the default cursor.
platform independent render window
bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
Convenience methods to blit the results rendered in the internal FBO to a target. ...
bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
Convenience methods to blit the results rendered in the internal FBO to a target. ...
Helper to manage Qt context and other OpenGL components.
void setDefaultCursor(const QCursor &cursor)
Get/set the default cursor.