CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkVTKScalarsToColorsView.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 __ctkVTKScalarsToColorsView_h
22 #define __ctkVTKScalarsToColorsView_h
23 
24 // CTK includes
25 #include "ctkVTKChartView.h"
26 #include "ctkVTKObject.h"
27 class ctkVTKScalarsToColorsViewPrivate;
28 
29 // VTK includes
30 #include <vtkChartXY.h>
31 
32 class vtkColorTransferFunction;
33 class vtkControlPointsItem;
34 class vtkLookupTable;
35 class vtkPiecewiseFunction;
36 
38 class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKScalarsToColorsView
39  : public ctkVTKChartView
40 {
41  Q_OBJECT
45  Q_PROPERTY(bool bordersVisible READ areBordersVisible WRITE setBordersVisible)
46 
47 public:
49  ctkVTKScalarsToColorsView(QWidget* parent = 0);
50  virtual ~ctkVTKScalarsToColorsView();
51 
52  virtual void addPlot(vtkPlot* plot);
53 
54  vtkPlot* addLookupTable(vtkLookupTable* lut);
55  Q_INVOKABLE vtkPlot* addColorTransferFunction(vtkColorTransferFunction* colorTF, bool editable = true);
56  vtkPlot* addOpacityFunction(vtkPiecewiseFunction* opacityTF, bool editable = true);
57  vtkPlot* addCompositeFunction(vtkColorTransferFunction* colorTF,
58  vtkPiecewiseFunction* opacityTF,
59  bool colorTFEditable = true,
60  bool opacityTFEditable = true);
61  vtkPlot* addPiecewiseFunction(vtkPiecewiseFunction* piecewiseTF, bool editable = true);
62 
63  vtkPlot* addColorTransferFunctionControlPoints(vtkColorTransferFunction* colorTF);
64  vtkPlot* addOpacityFunctionControlPoints(vtkPiecewiseFunction* opacityTF);
65  vtkPlot* addCompositeFunctionControlPoints(vtkColorTransferFunction* colorTF,
66  vtkPiecewiseFunction* opacityTF);
67  vtkPlot* addPiecewiseFunctionControlPoints(vtkPiecewiseFunction* piecewiseTF);
68 
69  QList<vtkPlot*> plots()const;
70  template<class T>
71  QList<T*> plots()const;
72  QList<vtkControlPointsItem*> controlPointsItems()const;
73  QList<vtkPlot*> lookupTablePlots()const;
74  QList<vtkPlot*> lookupTablePlots(vtkLookupTable* lut)const;
75  QList<vtkPlot*> colorTransferFunctionPlots()const;
76  QList<vtkPlot*> colorTransferFunctionPlots(vtkColorTransferFunction* colorTF)const;
77  QList<vtkPlot*> opacityFunctionPlots()const;
78  QList<vtkPlot*> opacityFunctionPlots(vtkPiecewiseFunction* opacityTF)const;
79 
80  void setLookuptTableToPlots(vtkLookupTable* lut);
81  void setColorTransferFunctionToPlots(vtkColorTransferFunction* colorTF);
82  void setOpacityFunctionToPlots(vtkPiecewiseFunction* opacityTF);
83  void setPiecewiseFunctionToPlots(vtkPiecewiseFunction* piecewiseTF);
84 
85  bool areBordersVisible()const;
86  void setBordersVisible(bool show);
87 
88  void validBounds(double bounds[4])const;
89  void setValidBounds(double bounds[4]);
90 
91  void setPlotsUserBounds(double* bounds);
92 
94  virtual void boundAxesToChartBounds();
95 
96 Q_SIGNALS:
100  void functionChanged();
101 
102 public Q_SLOTS:
103  void editPoint(vtkObject* plot, void * pointId);
104 
107  void moveAllPoints(double xOffset, double yOffset = 0.,
108  bool dontMoveFirstAndLast = false);
109 
114  void spreadAllPoints(double factor = 1.,
115  bool dontMoveFirstAndLast = false);
116 
117 protected Q_SLOTS:
118  void onBoundsChanged();
119 
120 protected:
121  QScopedPointer<ctkVTKScalarsToColorsViewPrivate> d_ptr;
122 
123 private:
124  Q_DECLARE_PRIVATE(ctkVTKScalarsToColorsView);
125  Q_DISABLE_COPY(ctkVTKScalarsToColorsView);
126 };
127 
128 // ----------------------------------------------------------------------------
129 template<class T>
131 {
132  QList<T*> res;
133  const vtkIdType count = this->chart()->GetNumberOfPlots();
134  for(vtkIdType i = 0; i < count; ++i)
135  {
136  vtkPlot* plot = this->chart()->GetPlot(i);
137  if (T::SafeDownCast(plot) != 0)
138  {
139  res << T::SafeDownCast(plot);
140  }
141  }
142  return res;
143 }
144 
145 
146 #endif
ctkVTKObject.h
ctkVTKChartView
Definition: ctkVTKChartView.h:36
QList
Definition: ctkCmdLineModuleBackend.h:30
QVTK_OBJECT
#define QVTK_OBJECT
Define VTK/Qt event/slot connection utility methods. It is a convenient macro that declares and defin...
Definition: ctkVTKObject.h:222
ctkVTKScalarsToColorsView::plots
QList< vtkPlot * > plots() const
ctkVTKScalarsToColorsView::d_ptr
QScopedPointer< ctkVTKScalarsToColorsViewPrivate > d_ptr
Definition: ctkVTKScalarsToColorsView.h:121
ctkVTKChartView.h
ctkVTKScalarsToColorsView::Superclass
ctkVTKChartView Superclass
Definition: ctkVTKScalarsToColorsView.h:48
ctkVTKChartView::boundAxesToChartBounds
virtual void boundAxesToChartBounds()
ctkVTKChartView::addPlot
virtual Q_INVOKABLE void addPlot(vtkPlot *plot)
ctkVTKChartView::chart
Q_INVOKABLE vtkChartXY * chart() const
ctkVTKScalarsToColorsView
Definition: ctkVTKScalarsToColorsView.h:38