VTK  9.3.20240328
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 
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 
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
Helper to manage Qt context and other OpenGL components.
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
Convenience methods to blit the results rendered in the internal FBO to a target.
~QVTKRenderWindowAdapter() override
QVTKRenderWindowAdapter(QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWidget *parent)
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i....
void setUnscaledDPI(int value)
Set the unscaled DPI to use when scaling DPI.
const QCursor & defaultCursor() const
Get/set the default cursor.
void setCustomDevicePixelRatio(double dpr)
Get/Set the custom device pixel ratio to use.
void resize(int width, int height)
Call this method to resize the render window.
bool blit(unsigned int targetId, int targetAttachement, const QRect &targetRect, bool left=true)
Convenience methods to blit the results rendered in the internal FBO to a target.
bool handleEvent(QEvent *evt)
Process the event and return true if the event have been processed successfully.
bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
Convenience methods to blit the results rendered in the internal FBO to a target.
void paint()
Call this method in paintGL to request a render.
QVTKRenderWindowAdapter(QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWindow *parent)
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i....
void setEnableHiDPI(bool value)
Enable/disable DPI scaling.
void setDefaultCursor(const QCursor &cursor)
Get/set the default cursor.
platform independent render window
abstract base class for most VTK objects
Definition: vtkObject.h:161
@ value
Definition: vtkX3D.h:220
@ height
Definition: vtkX3D.h:254