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 =========================================================================*/
15 #ifndef QVTKOpenGLWidget_h
16 #define QVTKOpenGLWidget_h
17 
18 #include "vtkGUISupportQtModule.h" // For export macro
19 
20 #include <QWidget>
21 
22 // Forward Qt class declarations
23 class QSurfaceFormat;
24 class QOpenGLContext;
25 
26 //class QVTKInteractor;
28 class QVTKOpenGLWindow;
30 class vtkRenderWindow;
32 
84 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWidget : public QWidget
85 {
86  Q_OBJECT
87  typedef QWidget Superclass;
88 public:
89  QVTKOpenGLWidget(QWidget* parent = Q_NULLPTR,
90  Qt::WindowFlags f = Qt::WindowFlags());
91  QVTKOpenGLWidget(QOpenGLContext *shareContext, QWidget* parent = Q_NULLPTR,
92  Qt::WindowFlags f = Qt::WindowFlags());
94  QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
95  QVTKOpenGLWidget(vtkGenericOpenGLRenderWindow* w, QOpenGLContext *shareContext,
96  QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
97  ~QVTKOpenGLWidget() override;
98 
102  void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
103  void SetRenderWindow(vtkRenderWindow* win);
104 
108  virtual vtkRenderWindow* GetRenderWindow();
109 
113  virtual vtkRenderWindowInteractor* GetInteractor();
114 
118  virtual QVTKInteractorAdapter* GetInteractorAdapter();
119 
125  static QSurfaceFormat defaultFormat();
126 
130  void setFormat(const QSurfaceFormat& format);
131 
135  virtual void setEnableHiDPI(bool enable);
136  virtual bool enableHiDPI() { return this->EnableHiDPI; }
137 
141  void setQVTKCursor(const QCursor &cursor);
142 
147  virtual bool isValid();
148 
157  virtual bool testingEvent(QEvent* e);
158 
163  QImage grabFramebuffer();
164 
165 signals:
169  void mouseEvent(QMouseEvent* event);
170 
174  void resized();
175 
179  void widgetEvent(QEvent* e);
180 
181 private slots:
185  void windowEvent(QEvent* event);
186 
187 protected:
188  virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
189  virtual bool event(QEvent* e) Q_DECL_OVERRIDE;
190 
191  bool EnableHiDPI = true;
192 
193 private:
194  QVTKOpenGLWindow* qVTKOpenGLWindowInternal;
195 };
196 
197 #endif
virtual bool enableHiDPI()
platform-independent render window interaction including picking and frame rate control.
platform independent render window
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
create a window for renderers to draw into
QWidget for displaying a vtkRenderWindow in a Qt Application.