VTK  9.0.3
QVTKRenderWindowAdapter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QVTKRenderWindowAdapter.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 QVTKRenderWindowAdapter_h
16 #define QVTKRenderWindowAdapter_h
17 
37 #include "vtkGUISupportQtModule.h" // For export macro
38 #include <QObject>
39 
40 #include <QCursor> // for ivar
41 #include <QScopedPointer> // for ivar
42 
43 class QOpenGLContext;
44 class QSurfaceFormat;
45 class QWidget;
46 class QWindow;
48 class vtkObject;
49 
50 class VTKGUISUPPORTQT_EXPORT QVTKRenderWindowAdapter : public QObject
51 {
52  Q_OBJECT;
53  using Superclass = QObject;
54 
55 public:
57 
65  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QWindow* parent);
67  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QWidget* parent);
69 
71 
94  static QSurfaceFormat defaultFormat(bool stereo_capable = false);
95 
99  QOpenGLContext* context() const;
100 
106  void paint();
107 
119  void resize(int width, int height);
120 
122 
126  bool blit(
127  unsigned int targetId, int targetAttachement, const QRect& targetRect, bool left = true);
128  bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
129  {
130  return this->blit(targetId, targetAttachement, targetRect, true);
131  }
132  bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
133  {
134  return this->blit(targetId, targetAttachement, targetRect, false);
135  }
137 
142  bool handleEvent(QEvent* evt);
143 
145 
148  void setDefaultCursor(const QCursor& cursor) { this->DefaultCursor = cursor; }
149  const QCursor& defaultCursor() const { return this->DefaultCursor; }
151 
153 
163  void setEnableHiDPI(bool value);
165 
167 
173 
174 private slots:
175  void contextAboutToBeDestroyed();
176 
177 private:
179  QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QObject* widgetOrWindow);
180  Q_DISABLE_COPY(QVTKRenderWindowAdapter);
181 
182  class QVTKInternals;
183  QScopedPointer<QVTKInternals> Internals;
184 
185  QCursor DefaultCursor;
186 };
187 
188 #endif
Helper to manage Qt context and other OpenGL components.
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
QOpenGLContext * context() const
Get the context to use for rendering.
~QVTKRenderWindowAdapter() override
QVTKRenderWindowAdapter(QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWidget *parent)
void setUnscaledDPI(int value)
Set the unscaled DPI to use when scaling DPI.
const QCursor & defaultCursor() const
void resize(int width, int height)
Call this method to resize the render window.
bool blit(unsigned int targetId, int targetAttachement, const QRect &targetRect, bool left=true)
Convenience methods to blit the results rendered in the internal FBO to a target.
bool handleEvent(QEvent *evt)
Process the event and return true if the event have been processed successfully.
bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
void paint()
Call this method in paintGL to request a render.
QVTKRenderWindowAdapter(QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWindow *parent)
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i....
void setEnableHiDPI(bool value)
Enable/disable DPI scaling.
void setDefaultCursor(const QCursor &cursor)
Get/set the default cursor.
platform independent render window
abstract base class for most VTK objects
Definition: vtkObject.h:54
@ value
Definition: vtkX3D.h:226
@ height
Definition: vtkX3D.h:260