VTK  9.3.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 
148  void setEnableHiDPI(bool value);
150 
152 
156  void setUnscaledDPI(int value);
158 
160 
164  void setCustomDevicePixelRatio(double dpr);
166 
167 private Q_SLOTS:
168  void contextAboutToBeDestroyed();
169 
170 private: // NOLINT(readability-redundant-access-specifiers)
172  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QObject* widgetOrWindow);
173  Q_DISABLE_COPY(QVTKRenderWindowAdapter);
174 
175  class QVTKInternals;
176  QScopedPointer<QVTKInternals> Internals;
177 
178  QCursor DefaultCursor;
179 };
180 
181 VTK_ABI_NAMESPACE_END
182 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:51
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.