VTK  9.7.1
QVTKOpenGLNativeWidget.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
91 #ifndef QVTKOpenGLNativeWidget_h
92 #define QVTKOpenGLNativeWidget_h
93 
94 #include <QOpenGLWidget>
95 #include <QScopedPointer> // for QScopedPointer.
96 
97 #include "QVTKInteractor.h" // needed for QVTKInteractor
98 #include "vtkGUISupportQtModule.h" // for export macro
99 #include "vtkNew.h" // needed for vtkNew
100 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
101 
102 VTK_ABI_NAMESPACE_BEGIN
103 class QVTKInteractor;
107 
108 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLNativeWidget : public QOpenGLWidget
109 {
110  Q_OBJECT
111  typedef QOpenGLWidget Superclass;
112 
113 public:
114  QVTKOpenGLNativeWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
115  QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow* window, QWidget* parent = nullptr,
116  Qt::WindowFlags f = Qt::WindowFlags());
117  ~QVTKOpenGLNativeWidget() override;
118 
120 
126  void setRenderWindow(vtkGenericOpenGLRenderWindow* win);
127  void setRenderWindow(vtkRenderWindow* win);
129 
133  vtkRenderWindow* renderWindow() const;
134 
138  QVTKInteractor* interactor() const;
139 
143  static QSurfaceFormat defaultFormat(bool stereo_capable = false);
144 
146 
151  void setEnableTouchEventProcessing(bool enable);
152  bool enableTouchEventProcesing() const { return this->EnableTouchEventProcessing; }
154 
156 
162  void setEnableHiDPI(bool enable);
163  bool enableHiDPI() const { return this->EnableHiDPI; }
165 
167 
171  void setUnscaledDPI(int);
172  int unscaledDPI() const { return this->UnscaledDPI; }
174 
176 
189  void setCustomDevicePixelRatio(double cdpr);
190  double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
191  double effectiveDevicePixelRatio() const;
193 
195 
198  void setDefaultCursor(const QCursor& cursor);
199  const QCursor& defaultCursor() const { return this->DefaultCursor; }
201 
203 
207  void setCursorCustom(const QCursor& cursor) { this->setCursor(cursor); }
208  QCursor cursorCustom() const { return this->cursor(); }
210 
211 protected Q_SLOTS:
217  virtual void cleanupContext();
218 
219  void updateSize();
220 
221 protected: // NOLINT(readability-redundant-access-specifiers)
222  bool event(QEvent* evt) override;
223  void initializeGL() override;
224  void paintGL() override;
225 
227  QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
228 
229 private:
230  Q_DISABLE_COPY(QVTKOpenGLNativeWidget);
231 
232  bool EnableTouchEventProcessing = true;
233  bool EnableHiDPI;
234  int UnscaledDPI;
235  double CustomDevicePixelRatio;
236  QCursor DefaultCursor;
237 };
238 
239 VTK_ABI_NAMESPACE_END
240 #endif
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
double customDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
void setCursorCustom(const QCursor &cursor)
Convenience method by symmetry with QVTKOpenGLStereoWidget.
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
int unscaledDPI() const
Set/Get unscaled DPI value.
platform independent render window
QCursor cursorCustom() const
Convenience method by symmetry with QVTKOpenGLStereoWidget.
create a window for renderers to draw into
Helper to manage Qt context and other OpenGL components.
bool enableTouchEventProcesing() const
Enable or disable support for touch event processing.