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);
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 
70  template<class T>
71  QList<T*> plots()const;
74  QList<vtkPlot*> lookupTablePlots(vtkLookupTable* lut)const;
76  QList<vtkPlot*> colorTransferFunctionPlots(vtkColorTransferFunction* colorTF)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:
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:
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
Q_INVOKABLE vtkChartXY * chart() const
virtual void addPlot(vtkPlot *plot)
vtkPlot * addPiecewiseFunction(vtkPiecewiseFunction *piecewiseTF, bool editable=true)
QList< vtkPlot * > opacityFunctionPlots() const
vtkPlot * addOpacityFunction(vtkPiecewiseFunction *opacityTF, bool editable=true)
vtkPlot * addColorTransferFunctionControlPoints(vtkColorTransferFunction *colorTF)
void moveAllPoints(double xOffset, double yOffset=0., bool dontMoveFirstAndLast=false)
virtual void boundAxesToChartBounds()
Reimplemented to set the bounds to the plots as well.
vtkPlot * addOpacityFunctionControlPoints(vtkPiecewiseFunction *opacityTF)
void setBordersVisible(bool show)
void setValidBounds(double bounds[4])
void setColorTransferFunctionToPlots(vtkColorTransferFunction *colorTF)
QScopedPointer< ctkVTKScalarsToColorsViewPrivate > d_ptr
QList< vtkPlot * > lookupTablePlots() const
void setPiecewiseFunctionToPlots(vtkPiecewiseFunction *piecewiseTF)
Q_INVOKABLE vtkPlot * addColorTransferFunction(vtkColorTransferFunction *colorTF, bool editable=true)
QList< vtkPlot * > colorTransferFunctionPlots() const
vtkPlot * addLookupTable(vtkLookupTable *lut)
QList< vtkPlot * > lookupTablePlots(vtkLookupTable *lut) const
void setPlotsUserBounds(double *bounds)
void setOpacityFunctionToPlots(vtkPiecewiseFunction *opacityTF)
vtkPlot * addCompositeFunctionControlPoints(vtkColorTransferFunction *colorTF, vtkPiecewiseFunction *opacityTF)
virtual ~ctkVTKScalarsToColorsView()
void spreadAllPoints(double factor=1., bool dontMoveFirstAndLast=false)
vtkPlot * addPiecewiseFunctionControlPoints(vtkPiecewiseFunction *piecewiseTF)
bool areBordersVisible() const
void validBounds(double bounds[4]) const
QList< vtkPlot * > plots() const
ctkVTKScalarsToColorsView(QWidget *parent=0)
QList< vtkPlot * > opacityFunctionPlots(vtkPiecewiseFunction *opacityTF) const
vtkPlot * addCompositeFunction(vtkColorTransferFunction *colorTF, vtkPiecewiseFunction *opacityTF, bool colorTFEditable=true, bool opacityTFEditable=true)
void setLookuptTableToPlots(vtkLookupTable *lut)
void editPoint(vtkObject *plot, void *pointId)
QList< vtkPlot * > colorTransferFunctionPlots(vtkColorTransferFunction *colorTF) const
QList< vtkControlPointsItem * > controlPointsItems() const
#define QVTK_OBJECT
Define VTK/Qt event/slot connection utility methods. It is a convenient macro that declares and defin...
Definition: ctkVTKObject.h:222