VTK  9.0.1
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());
128  ~QVTKOpenGLNativeWidget() override;
129 
131 
137  void setRenderWindow(vtkGenericOpenGLRenderWindow* win);
138  void setRenderWindow(vtkRenderWindow* win);
140 
144  vtkRenderWindow* renderWindow() const;
145 
149  QVTKInteractor* interactor() const;
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 
188  VTK_LEGACY(void SetRenderWindow(vtkGenericOpenGLRenderWindow* win));
189  VTK_LEGACY(void SetRenderWindow(vtkRenderWindow* win));
191 
193 
198  VTK_LEGACY(vtkRenderWindow* GetRenderWindow());
199  VTK_LEGACY(QVTKInteractor* GetInteractor());
201 
206  VTK_LEGACY(QVTKInteractorAdapter* GetInteractorAdapter());
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
QVTKOpenGLNativeWidget::unscaledDPI
int unscaledDPI() const
Definition: QVTKOpenGLNativeWidget.h:173
vtkGenericOpenGLRenderWindow
platform independent render window
Definition: vtkGenericOpenGLRenderWindow.h:42
vtkSmartPointer< vtkGenericOpenGLRenderWindow >
QVTKInteractorAdapter
Definition: QVTKInteractorAdapter.h:50
QVTKOpenGLNativeWidget::enableHiDPI
bool enableHiDPI() const
Definition: QVTKOpenGLNativeWidget.h:164
QVTKRenderWindowAdapter
Helper to manage Qt context and other OpenGL components.
Definition: QVTKRenderWindowAdapter.h:50
vtkSmartPointer.h
QVTKOpenGLNativeWidget::defaultCursor
const QCursor & defaultCursor() const
Definition: QVTKOpenGLNativeWidget.h:181
vtkNew.h
QVTKOpenGLNativeWidget::RenderWindowAdapter
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
Definition: QVTKOpenGLNativeWidget.h:236
QVTKOpenGLNativeWidget
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
Definition: QVTKOpenGLNativeWidget.h:119
QVTKInteractor.h
QVTKOpenGLNativeWidget::RenderWindow
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
Definition: QVTKOpenGLNativeWidget.h:235
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:93
QVTKInteractor
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
Definition: QVTKInteractor.h:58