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 =========================================================================*/
106 #ifndef QVTKOpenGLWidget_h
107 #define QVTKOpenGLWidget_h
108 
109 #include <QOpenGLWidget>
110 
111 #include "QVTKInteractor.h" // needed for QVTKInteractor
112 #include "vtkGUISupportQtModule.h" // for export macro
113 #include "vtkNew.h" // needed for vtkNew
114 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
115 
116 class QOpenGLDebugLogger;
117 class QOpenGLFramebufferObject;
118 class QVTKInteractor;
120 class QVTKOpenGLWidgetObserver;
122 
123 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWidget : public QOpenGLWidget
124 {
125  Q_OBJECT
126  typedef QOpenGLWidget Superclass;
127 public:
128  QVTKOpenGLWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
129  virtual ~QVTKOpenGLWidget();
130 
132 
136  void SetRenderWindow(vtkRenderWindow* win);
137  virtual vtkRenderWindow* GetRenderWindow();
139 
143  virtual QVTKInteractor* GetInteractor();
144 
148  static void copyFromFormat(const QSurfaceFormat& format, vtkRenderWindow* win);
149 
153  static void copyToFormat(vtkRenderWindow* win, QSurfaceFormat& format);
154 
160  static QSurfaceFormat defaultFormat();
161 
165  virtual void setEnableHiDPI(bool enable);
166 
167 signals:
171  void mouseEvent(QMouseEvent* event);
172 
173 protected slots:
179  virtual void cleanupContext();
180 
181 private slots:
185  void recreateFBO();
186 
191  void startEventCallback();
192 
193 protected:
194  bool event(QEvent* evt) Q_DECL_OVERRIDE;
195  void initializeGL() Q_DECL_OVERRIDE;
196  void resizeGL(int w, int h) Q_DECL_OVERRIDE;
197  void paintGL() Q_DECL_OVERRIDE;
198  void moveEvent(QMoveEvent* event) 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
vtkRenderWindow * GetRenderWindow()
virtual void SetRenderWindow(vtkRenderWindow *renwin)
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