VTK  9.2.6
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 "vtkGUISupportQtModule.h" // for export macro
111#include "vtkNew.h" // needed for vtkNew
112#include "vtkSmartPointer.h" // needed for vtkSmartPointer
113
114class QVTKInteractor;
118
119class VTKGUISUPPORTQT_EXPORT QVTKOpenGLNativeWidget : public QOpenGLWidget
120{
121 Q_OBJECT
122 typedef QOpenGLWidget Superclass;
123
124public:
125 QVTKOpenGLNativeWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
126 QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow* window, QWidget* parent = nullptr,
127 Qt::WindowFlags f = Qt::WindowFlags());
129
131
140
145
150
154 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
155
157
163 void setEnableHiDPI(bool enable);
164 bool enableHiDPI() const { return this->EnableHiDPI; }
166
168
172 void setUnscaledDPI(int);
173 int unscaledDPI() const { return this->UnscaledDPI; }
175
177
190 void setCustomDevicePixelRatio(double cdpr);
191 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
194
196
199 void setDefaultCursor(const QCursor& cursor);
200 const QCursor& defaultCursor() const { return this->DefaultCursor; }
202
203protected Q_SLOTS:
209 virtual void cleanupContext();
210
212
213protected:
214 bool event(QEvent* evt) override;
215 void initializeGL() override;
216 void paintGL() override;
217
218protected:
220 QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
221
222private:
223 Q_DISABLE_COPY(QVTKOpenGLNativeWidget);
224
225 bool EnableHiDPI;
226 int UnscaledDPI;
227 double CustomDevicePixelRatio;
228 QCursor DefaultCursor;
229};
230
231#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.
virtual void cleanupContext()
Called as a response to QOpenGLContext::aboutToBeDestroyed.
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.
bool event(QEvent *evt) override
~QVTKOpenGLNativeWidget() override
void initializeGL() 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.
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
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.
void paintGL() override
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.