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 
104 
109 
114 
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
QVTKOpenGLWidget::QVTKOpenGLWidget
QVTKOpenGLWidget(vtkGenericOpenGLRenderWindow *w, QOpenGLContext *shareContext, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
QVTKOpenGLWidget::GetInteractorAdapter
virtual QVTKInteractorAdapter * GetInteractorAdapter()
Get the QEvent to VTK events translator.
QVTKOpenGLWidget::grabFramebuffer
QImage grabFramebuffer()
Expose internal QVTKOpenGLWindow::grabFramebuffer().
QVTKOpenGLWidget::setEnableHiDPI
virtual void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
QVTKOpenGLWindow
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
Definition: QVTKOpenGLWindow.h:79
QVTKOpenGLWidget::QVTKOpenGLWidget
QVTKOpenGLWidget(vtkGenericOpenGLRenderWindow *w, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
QVTKOpenGLWidget::SetRenderWindow
void SetRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set the VTK render window for the internal QVTKOpenGLWindow.
QVTKOpenGLWidget::defaultFormat
static QSurfaceFormat defaultFormat()
Returns a typical QSurfaceFormat suitable for most applications using QVTKOpenGLWidget.
vtkGenericOpenGLRenderWindow
platform independent render window
Definition: vtkGenericOpenGLRenderWindow.h:41
QVTKOpenGLWidget
QWidget for displaying a vtkRenderWindow in a Qt Application.
Definition: QVTKOpenGLWidget.h:85
QVTKOpenGLWidget::widgetEvent
void widgetEvent(QEvent *e)
Forward events to the internal QVTK window.
QVTKInteractorAdapter
Definition: QVTKInteractorAdapter.h:51
QVTKOpenGLWidget::setFormat
void setFormat(const QSurfaceFormat &format)
Set the QSurfaceFormat used to create the OpenGL context.
QVTKOpenGLWidget::GetRenderWindow
virtual vtkRenderWindow * GetRenderWindow()
Get the VTK render window from the internal QVTKOpenGLWindow.
QVTKOpenGLWidget::QVTKOpenGLWidget
QVTKOpenGLWidget(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
QVTKOpenGLWidget::QVTKOpenGLWidget
QVTKOpenGLWidget(QOpenGLContext *shareContext, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
QVTKOpenGLWidget::resizeEvent
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
QVTKOpenGLWidget::SetRenderWindow
void SetRenderWindow(vtkRenderWindow *win)
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:79
QVTKOpenGLWidget::~QVTKOpenGLWidget
~QVTKOpenGLWidget() override
QVTKOpenGLWidget::resized
void resized()
This signal will be emitted whenever a resize event occurs within the QVTK window.
QVTKOpenGLWidget::GetInteractor
virtual vtkRenderWindowInteractor * GetInteractor()
Get the VTK render window interactor from the internal QVTKOpenGLWindow.
QVTKOpenGLWidget::event
virtual bool event(QEvent *e) Q_DECL_OVERRIDE
QVTKOpenGLWidget::enableHiDPI
virtual bool enableHiDPI()
Definition: QVTKOpenGLWidget.h:136
QVTKOpenGLWidget::isValid
virtual bool isValid()
Returns true if the internal QOpenGLWindow's is valid, i.e.
QVTKOpenGLWidget::mouseEvent
void mouseEvent(QMouseEvent *event)
This signal will be emitted whenever a mouse event occurs within the QVTK window.
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:88
QVTKOpenGLWidget::testingEvent
virtual bool testingEvent(QEvent *e)
Forward events to the internal QVTKOpenGLWindow when events are explicitly sent to the widget.
QVTKOpenGLWidget::setQVTKCursor
void setQVTKCursor(const QCursor &cursor)
Set the cursor on this widget.