VTK  9.1.0
QVTKOpenGLWindow.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: QVTKOpenGLWindow.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=========================================================================*/
49#ifndef QVTKOpenGLWindow_h
50#define QVTKOpenGLWindow_h
51
52#include <QOpenGLWindow>
53#include <QScopedPointer> // for QScopedPointer.
54
55#include "QVTKInteractor.h" // needed for QVTKInteractor
56#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
57#include "vtkGUISupportQtModule.h" // for export macro
58#include "vtkNew.h" // needed for vtkNew
59#include "vtkSmartPointer.h" // needed for vtkSmartPointer
60
61class QVTKInteractor;
65
66class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWindow : public QOpenGLWindow
67{
68 Q_OBJECT
69 typedef QOpenGLWindow Superclass;
70
71public:
73 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
74 QVTKOpenGLWindow(QOpenGLContext* shareContext,
75 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
77 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
78 QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow* renderWindow, QOpenGLContext* shareContext,
79 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
81
83
92
97
102
106 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
107
109
115 void setEnableHiDPI(bool enable);
116 bool enableHiDPI() const { return this->EnableHiDPI; }
118
120
124 void setUnscaledDPI(int);
125 int unscaledDPI() const { return this->UnscaledDPI; }
127
129
142 void setCustomDevicePixelRatio(double cdpr);
143 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
146
148
151 void setDefaultCursor(const QCursor& cursor);
152 const QCursor& defaultCursor() const { return this->DefaultCursor; }
154
156
159 VTK_DEPRECATED_IN_9_0_0("Use QVTKOpenGLWindow::setRenderWindow")
160 void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
161 VTK_DEPRECATED_IN_9_0_0("Use QVTKOpenGLWindow::setRenderWindow")
162 void SetRenderWindow(vtkRenderWindow* win);
164
166
171 VTK_DEPRECATED_IN_9_0_0("Use QVTKOpenGLWindow::renderWindow")
172 vtkRenderWindow* GetRenderWindow();
174 QVTKInteractor* GetInteractor();
176
181 VTK_DEPRECATED_IN_9_0_0("Removed in 9.0.0 (internal)")
182 QVTKInteractorAdapter* GetInteractorAdapter();
183
188 VTK_DEPRECATED_IN_9_0_0("Use QWidget::setCursor")
189 void setQVTKCursor(const QCursor& cursor);
190
194 VTK_DEPRECATED_IN_9_0_0("Use QWidget::setDefaultCursor")
195 void setDefaultQVTKCursor(const QCursor& cursor);
196
197Q_SIGNALS:
202 void windowEvent(QEvent* e);
203
204protected Q_SLOTS:
210 void cleanupContext();
211
212 void updateSize();
213
220
221protected:
222 bool event(QEvent* evt) override;
223 void initializeGL() override;
224 void paintGL() override;
225 void resizeGL(int w, int h) override;
226
227protected:
229 QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
230
231private:
232 Q_DISABLE_COPY(QVTKOpenGLWindow);
233 bool EnableHiDPI;
234 int UnscaledDPI;
235 double CustomDevicePixelRatio;
236 QCursor DefaultCursor;
237};
238
239#endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
QWidget for displaying a vtkRenderWindow in a Qt Application.
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
void setRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set a render window to use.
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow *renderWindow, QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
~QVTKOpenGLWindow() override
QVTKOpenGLWindow(QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
double effectiveDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
void setUnscaledDPI(int)
Set/Get unscaled DPI value.
vtkRenderWindow * renderWindow() const
Returns the render window that is being shown in this widget.
QVTKInteractor * interactor() const
Get the QVTKInteractor that was either created by default or set by the user.
QVTKOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
int unscaledDPI() const
Set/Get unscaled DPI value.
void setDefaultCursor(const QCursor &cursor)
Set/get the default cursor to use for this widget.
void setCustomDevicePixelRatio(double cdpr)
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
void setRenderWindow(vtkRenderWindow *win)
Set a render window to use.
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.
QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow *renderWindow, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
Helper to manage Qt context and other OpenGL components.
vtkFrustumSelector is a vtkSelector that selects elements based on whether they are inside or interse...
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)