VTK
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 =========================================================================*/
107 #ifndef QVTKOpenGLNativeWidget_h
108 #define QVTKOpenGLNativeWidget_h
109 
110 #include <QOpenGLWidget>
111 #include <QScopedPointer> // for QScopedPointer.
112 
113 #include "QVTKInteractor.h" // needed for QVTKInteractor
114 #include "vtkGUISupportQtModule.h" // for export macro
115 #include "vtkNew.h" // needed for vtkNew
116 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
117 
118 class QVTKInteractor;
122 
123 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLNativeWidget : public QOpenGLWidget
124 {
125  Q_OBJECT
126  typedef QOpenGLWidget Superclass;
127 
128 public:
129  QVTKOpenGLNativeWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
130  QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow* window, QWidget* parent = nullptr,
131  Qt::WindowFlags f = Qt::WindowFlags());
132  ~QVTKOpenGLNativeWidget() override;
133 
135 
141  void setRenderWindow(vtkGenericOpenGLRenderWindow* win);
142  void setRenderWindow(vtkRenderWindow* win);
144 
148  vtkRenderWindow* renderWindow() const;
149 
153  QVTKInteractor* interactor() const;
154 
158  static QSurfaceFormat defaultFormat(bool stereo_capable = false);
159 
161 
167  void setEnableHiDPI(bool enable);
168  bool enableHiDPI() const { return this->EnableHiDPI; }
170 
172 
176  void setUnscaledDPI(int);
177  int unscaledDPI() const { return this->UnscaledDPI; }
179 
181 
184  void setDefaultCursor(const QCursor& cursor);
185  const QCursor& defaultCursor() const { return this->DefaultCursor; }
187 
189 
192  VTK_LEGACY(void SetRenderWindow(vtkGenericOpenGLRenderWindow* win));
193  VTK_LEGACY(void SetRenderWindow(vtkRenderWindow* win));
195 
197 
202  VTK_LEGACY(vtkRenderWindow* GetRenderWindow());
203  VTK_LEGACY(QVTKInteractor* GetInteractor());
205 
210  VTK_LEGACY(QVTKInteractorAdapter* GetInteractorAdapter());
211 
216  VTK_LEGACY(void setQVTKCursor(const QCursor& cursor));
217 
221  VTK_LEGACY(void setDefaultQVTKCursor(const QCursor& cursor));
222 
223 protected slots:
229  virtual void cleanupContext();
230 
231  void updateSize();
232 
233 protected:
234  bool event(QEvent* evt) override;
235  void initializeGL() override;
236  void paintGL() override;
237 
238 protected:
240  QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
241 
242 private:
243  Q_DISABLE_COPY(QVTKOpenGLNativeWidget);
244 
245  bool EnableHiDPI;
246  int UnscaledDPI;
247  QCursor DefaultCursor;
248 };
249 
250 #endif
QVTKOpenGLNativeWidget::unscaledDPI
int unscaledDPI() const
Definition: QVTKOpenGLNativeWidget.h:177
vtkGenericOpenGLRenderWindow
platform independent render window
Definition: vtkGenericOpenGLRenderWindow.h:33
vtkSmartPointer< vtkGenericOpenGLRenderWindow >
QVTKInteractorAdapter
Definition: QVTKInteractorAdapter.h:50
QVTKOpenGLNativeWidget::enableHiDPI
bool enableHiDPI() const
Definition: QVTKOpenGLNativeWidget.h:168
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:185
vtkNew.h
QVTKOpenGLNativeWidget::RenderWindowAdapter
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
Definition: QVTKOpenGLNativeWidget.h:240
QVTKOpenGLNativeWidget
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
Definition: QVTKOpenGLNativeWidget.h:123
QVTKInteractor.h
QVTKOpenGLNativeWidget::RenderWindow
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
Definition: QVTKOpenGLNativeWidget.h:239
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:84
QVTKInteractor
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
Definition: QVTKInteractor.h:58