VTK  9.0.2
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 
114 class QVTKInteractor;
118 
119 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLNativeWidget : public QOpenGLWidget
120 {
121  Q_OBJECT
122  typedef QOpenGLWidget Superclass;
123 
124 public:
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 
180  void setDefaultCursor(const QCursor& cursor);
181  const QCursor& defaultCursor() const { return this->DefaultCursor; }
183 
185 
189  VTK_LEGACY(void SetRenderWindow(vtkRenderWindow* win));
191 
193 
201 
207 
212  VTK_LEGACY(void setQVTKCursor(const QCursor& cursor));
213 
217  VTK_LEGACY(void setDefaultQVTKCursor(const QCursor& cursor));
218 
219 protected slots:
225  virtual void cleanupContext();
226 
227  void updateSize();
228 
229 protected:
230  bool event(QEvent* evt) override;
231  void initializeGL() override;
232  void paintGL() override;
233 
234 protected:
236  QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
237 
238 private:
239  Q_DISABLE_COPY(QVTKOpenGLNativeWidget);
240 
241  bool EnableHiDPI;
242  int UnscaledDPI;
243  QCursor DefaultCursor;
244 };
245 
246 #endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
QVTKInteractorAdapter * GetInteractorAdapter()
QVTKInteractor * interactor() const
Get the QVTKInteractor that was either created by default or set by the user.
void SetRenderWindow(vtkGenericOpenGLRenderWindow *win)
void setQVTKCursor(const QCursor &cursor)
virtual void cleanupContext()
Called as a response to QOpenGLContext::aboutToBeDestroyed.
bool event(QEvent *evt) override
~QVTKOpenGLNativeWidget() override
void initializeGL() override
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
void setRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set a render window to use.
void SetRenderWindow(vtkRenderWindow *win)
void setUnscaledDPI(int)
Set/Get unscaled DPI value.
const QCursor & defaultCursor() const
QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow *window, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
QVTKInteractor * GetInteractor()
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.
vtkRenderWindow * renderWindow() const
Returns the render window that is being shown in this widget.
vtkRenderWindow * GetRenderWindow()
These methods have be deprecated to fix naming style.
void paintGL() override
QVTKOpenGLNativeWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void setDefaultQVTKCursor(const QCursor &cursor)
void setRenderWindow(vtkRenderWindow *win)
Helper to manage Qt context and other OpenGL components.
platform independent render window
create a window for renderers to draw into