VTK  9.1.0
QVTKOpenGLNativeWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: QVTKOpenGLNativeWidget.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
103#ifndef QVTKOpenGLNativeWidget_h
104#define QVTKOpenGLNativeWidget_h
105
106#include <QOpenGLWidget>
107#include <QScopedPointer> // for QScopedPointer.
108
109#include "QVTKInteractor.h" // needed for QVTKInteractor
110#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
111#include "vtkGUISupportQtModule.h" // for export macro
112#include "vtkNew.h" // needed for vtkNew
113#include "vtkSmartPointer.h" // needed for vtkSmartPointer
114
115class QVTKInteractor;
119
120class VTKGUISUPPORTQT_EXPORT QVTKOpenGLNativeWidget : public QOpenGLWidget
121{
122 Q_OBJECT
123 typedef QOpenGLWidget Superclass;
124
125public:
126 QVTKOpenGLNativeWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
127 QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow* window, QWidget* parent = nullptr,
128 Qt::WindowFlags f = Qt::WindowFlags());
130
132
141
146
151
155 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
156
158
164 void setEnableHiDPI(bool enable);
165 bool enableHiDPI() const { return this->EnableHiDPI; }
167
169
173 void setUnscaledDPI(int);
174 int unscaledDPI() const { return this->UnscaledDPI; }
176
178
191 void setCustomDevicePixelRatio(double cdpr);
192 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
195
197
200 void setDefaultCursor(const QCursor& cursor);
201 const QCursor& defaultCursor() const { return this->DefaultCursor; }
203
205
208 VTK_DEPRECATED_IN_9_0_0("Use QVTKOpenGLNativeWidget::setRenderWindow")
209 void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
210 VTK_DEPRECATED_IN_9_0_0("Use QVTKOpenGLNativeWidget::setRenderWindow")
211 void SetRenderWindow(vtkRenderWindow* win);
213
215
221 vtkRenderWindow* GetRenderWindow();
222 VTK_DEPRECATED_IN_9_0_0("Removed in 9.0.0 (internal)")
223 QVTKInteractor* GetInteractor();
225
230 VTK_DEPRECATED_IN_9_0_0("Removed in 9.0.0 (internal)")
231 QVTKInteractorAdapter* GetInteractorAdapter();
232
237 VTK_DEPRECATED_IN_9_0_0("Use QWidget::setCursor")
238 void setQVTKCursor(const QCursor& cursor);
239
243 VTK_DEPRECATED_IN_9_0_0("Use QWidget::setDefaultCursor")
244 void setDefaultQVTKCursor(const QCursor& cursor);
245
246protected Q_SLOTS:
252 virtual void cleanupContext();
253
254 void updateSize();
255
256protected:
257 bool event(QEvent* evt) override;
258 void initializeGL() override;
259 void paintGL() override;
260
261protected:
263 QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
264
265private:
266 Q_DISABLE_COPY(QVTKOpenGLNativeWidget);
267
268 bool EnableHiDPI;
269 int UnscaledDPI;
270 double CustomDevicePixelRatio;
271 QCursor DefaultCursor;
272};
273
274#endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
int unscaledDPI() const
Set/Get unscaled DPI value.
void setCustomDevicePixelRatio(double cdpr)
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
~QVTKOpenGLNativeWidget() override
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
QVTKInteractor * interactor() const
Get the QVTKInteractor that was either created by default or set by the user.
void setRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set a render window to use.
double effectiveDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
vtkRenderWindow * renderWindow() const
Returns the render window that is being shown in this widget.
void setUnscaledDPI(int)
Set/Get unscaled DPI value.
QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow *window, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void setDefaultCursor(const QCursor &cursor)
Set/get the default cursor to use for this widget.
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
double customDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
QVTKOpenGLNativeWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void setRenderWindow(vtkRenderWindow *win)
Set a render window to use.
Helper to manage Qt context and other OpenGL components.
platform independent render window
create a window for renderers to draw into
Hold a reference to a vtkObjectBase instance.
#define VTK_DEPRECATED_IN_9_0_0(reason)