VTK
QVTKOpenGLWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QVTKOpenGLWidget.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 =========================================================================*/
105 #ifndef QVTKOpenGLWidget_h
106 #define QVTKOpenGLWidget_h
107 
108 #include <QOpenGLWidget>
109 
110 #include "QVTKInteractor.h" // needed for QVTKInteractor
111 #include "vtkGUISupportQtModule.h" // for export macro
112 #include "vtkNew.h" // needed for vtkNew
113 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
114 
115 class QOpenGLDebugLogger;
116 class QOpenGLFramebufferObject;
117 class QVTKInteractor;
119 class QVTKOpenGLWidgetObserver;
121 
122 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWidget : public QOpenGLWidget
123 {
124  Q_OBJECT
125  typedef QOpenGLWidget Superclass;
126 public:
127  QVTKOpenGLWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
128  ~QVTKOpenGLWidget() override;
129 
131 
136  void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
137  void SetRenderWindow(vtkRenderWindow* win);
138  virtual vtkRenderWindow* GetRenderWindow();
140 
144  virtual QVTKInteractor* GetInteractor();
145 
149  static void copyFromFormat(const QSurfaceFormat& format, vtkRenderWindow* win);
150 
154  static void copyToFormat(vtkRenderWindow* win, QSurfaceFormat& format);
155 
161  static QSurfaceFormat defaultFormat();
162 
166  virtual void setEnableHiDPI(bool enable);
167 
168 signals:
172  void mouseEvent(QMouseEvent* event);
173 
174 protected slots:
180  virtual void cleanupContext();
181 
182 private slots:
186  void recreateFBO();
187 
192  void startEventCallback();
193 
194 protected:
195  bool event(QEvent* evt) Q_DECL_OVERRIDE;
196  void initializeGL() Q_DECL_OVERRIDE;
197  void resizeGL(int w, int h) Q_DECL_OVERRIDE;
198  void paintGL() Q_DECL_OVERRIDE;
199 
200  void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
201  void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
202  void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
203  void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
204 
211  void requireRenderWindowInitialization();
212 
233  virtual bool renderVTK();
234 
235 protected:
238 
241 
242 private:
243  Q_DISABLE_COPY(QVTKOpenGLWidget);
244 
249  void windowFrameEventCallback();
250 
251  QOpenGLFramebufferObject* FBO;
252  bool InPaintGL;
253  bool DoVTKRenderInPaintGL;
255  friend class QVTKOpenGLWidgetObserver;
256  QOpenGLDebugLogger* Logger;
257 };
258 
259 #endif
an interactor for QVTKOpenGLWidget (and QVTKWiget).
platform independent render window
create a window for renderers to draw into
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
QVTKInteractorAdapter * InteractorAdaptor
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow