CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkVTKAbstractView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkVTKAbstractView_h
22 #define __ctkVTKAbstractView_h
23 
24 // Qt includes
25 #include <QWidget>
26 
27 // VTK includes
28 #if CTK_USE_QVTKOPENGLWIDGET
29 #include <QVTKOpenGLWidget.h>
30 #else
31 #include <QVTKWidget.h>
32 #endif
33 
34 // CTK includes
35 #include "ctkVTKObject.h"
36 #include "ctkVisualizationVTKWidgetsExport.h"
37 class ctkVTKAbstractViewPrivate;
38 
39 class vtkCornerAnnotation;
40 class vtkInteractorObserver;
41 class vtkRenderWindowInteractor;
42 class vtkRenderWindow;
43 
45 class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKAbstractView : public QWidget
46 {
47  Q_OBJECT
49  Q_PROPERTY(QString cornerAnnotationText READ cornerAnnotationText WRITE setCornerAnnotationText)
50  Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
51  Q_PROPERTY(QColor backgroundColor2 READ backgroundColor2 WRITE setBackgroundColor)
52  Q_PROPERTY(bool gradientBackground READ gradientBackground WRITE setGradientBackground)
53  Q_PROPERTY(bool renderEnabled READ renderEnabled WRITE setRenderEnabled)
57  Q_PROPERTY(bool fpsVisible READ isFPSVisible WRITE setFPSVisible)
61  Q_PROPERTY(bool useDepthPeeling READ useDepthPeeling WRITE setUseDepthPeeling)
62 public:
63 
64  typedef QWidget Superclass;
65  explicit ctkVTKAbstractView(QWidget* parent = 0);
66  virtual ~ctkVTKAbstractView();
67 
68 public Q_SLOTS:
73  virtual void scheduleRender();
74 
78  virtual void forceRender();
79 
81  virtual void setBackgroundColor(const QColor& newBackgroundColor);
82 
85  virtual void setBackgroundColor2(const QColor& newBackgroundColor);
86 
89  virtual void setGradientBackground(bool enable);
90 
92  void setRenderEnabled(bool value);
93 
95  virtual void setCornerAnnotationText(const QString& text);
96 
98  void setFPSVisible(bool show);
99 
102  void setUseDepthPeeling(bool use);
103 
104 public:
106  Q_INVOKABLE vtkRenderWindow* renderWindow()const;
107 
109  Q_INVOKABLE vtkRenderWindowInteractor* interactor()const;
114  virtual void setInteractor(vtkRenderWindowInteractor* interactor);
115 
117  Q_INVOKABLE vtkInteractorObserver* interactorStyle()const;
118 
120  QString cornerAnnotationText() const;
121  Q_INVOKABLE vtkCornerAnnotation* cornerAnnotation()const;
122 
124 #if CTK_USE_QVTKOPENGLWIDGET
125  Q_INVOKABLE QVTKOpenGLWidget * VTKWidget() const;
126 #else
127  Q_INVOKABLE QVTKWidget * VTKWidget() const;
128 #endif
129 
131  virtual QColor backgroundColor() const;
132 
134  virtual QColor backgroundColor2() const;
135 
137  virtual bool gradientBackground() const;
138 
140  bool renderEnabled() const;
141 
143  bool isFPSVisible() const;
144 
146  double fps()const;
147 
150  bool useDepthPeeling()const;
151 
161  static void setMultiSamples(int);
162 
165  static int multiSamples();
166 
167  virtual QSize minimumSizeHint()const;
168  virtual QSize sizeHint()const;
169  virtual bool hasHeightForWidth()const;
170  virtual int heightForWidth(int width)const;
171 
172 protected Q_SLOTS:
173  void onRender();
174  void updateFPS();
175 
176 protected:
177  QScopedPointer<ctkVTKAbstractViewPrivate> d_ptr;
178  ctkVTKAbstractView(ctkVTKAbstractViewPrivate* pimpl, QWidget* parent);
179 
180 private:
181  Q_DECLARE_PRIVATE(ctkVTKAbstractView);
182  Q_DISABLE_COPY(ctkVTKAbstractView);
183 };
184 
185 #endif
#define QVTK_OBJECT
Define VTK/Qt event/slot connection utility methods. It is a convenient macro that declares and defin...
Definition: ctkVTKObject.h:222
QScopedPointer< ctkVTKAbstractViewPrivate > d_ptr