VTK  9.2.6
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 "vtkGUISupportQtModule.h" // for export macro
57#include "vtkNew.h" // needed for vtkNew
58#include "vtkSmartPointer.h" // needed for vtkSmartPointer
59
60class QVTKInteractor;
64
65class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWindow : public QOpenGLWindow
66{
67 Q_OBJECT
68 typedef QOpenGLWindow Superclass;
69
70public:
72 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
73 QVTKOpenGLWindow(QOpenGLContext* shareContext,
74 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
76 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
78 QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
80
82
91
96
101
105 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
106
108
114 void setEnableHiDPI(bool enable);
115 bool enableHiDPI() const { return this->EnableHiDPI; }
117
119
123 void setUnscaledDPI(int);
124 int unscaledDPI() const { return this->UnscaledDPI; }
126
128
141 void setCustomDevicePixelRatio(double cdpr);
142 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
145
147
150 void setDefaultCursor(const QCursor& cursor);
151 const QCursor& defaultCursor() const { return this->DefaultCursor; }
153
154Q_SIGNALS:
159 void windowEvent(QEvent* e);
160
161protected Q_SLOTS:
168
170
177
178protected:
179 bool event(QEvent* evt) override;
180 void initializeGL() override;
181 void paintGL() override;
182 void resizeGL(int w, int h) override;
183
184protected:
186 QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
187
188private:
189 Q_DISABLE_COPY(QVTKOpenGLWindow);
190 bool EnableHiDPI;
191 int UnscaledDPI;
192 double CustomDevicePixelRatio;
193 QCursor DefaultCursor;
194};
195
196#endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
void setRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set a render window to use.
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
void paintGL() override
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)
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
void windowEvent(QEvent *e)
Signal emitted when any event has been receive, with the corresponding event as argument.
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
int unscaledDPI() const
Set/Get unscaled DPI value.
friend class QVTKOpenGLStereoWidget
QVTKOpenGLStereoWidget is given friendship so it can call cleanupContext in its destructor to ensure ...
void cleanupContext()
Called as a response to QOpenGLContext::aboutToBeDestroyed.
void setDefaultCursor(const QCursor &cursor)
Set/get the default cursor to use for this widget.
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
void initializeGL() override
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.
void resizeGL(int w, int h) override
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
bool event(QEvent *evt) override
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.
platform independent render window
create a window for renderers to draw into
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.