CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
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"
27class ctkVTKScalarsToColorsViewPrivate;
28
29// VTK includes
30#include <vtkChartXY.h>
31
32class vtkColorTransferFunction;
33class vtkControlPointsItem;
34class vtkLookupTable;
35class vtkPiecewiseFunction;
36
38class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKScalarsToColorsView
39 : public ctkVTKChartView
40{
41 Q_OBJECT
45 Q_PROPERTY(bool bordersVisible READ areBordersVisible WRITE setBordersVisible)
46
47public:
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
96Q_SIGNALS:
101
102public 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
117protected Q_SLOTS:
119
120protected:
121 QScopedPointer<ctkVTKScalarsToColorsViewPrivate> d_ptr;
122
123private:
124 Q_DECLARE_PRIVATE(ctkVTKScalarsToColorsView);
125 Q_DISABLE_COPY(ctkVTKScalarsToColorsView);
126};
127
128// ----------------------------------------------------------------------------
129template<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)
QList< vtkPlot * > colorTransferFunctionPlots(vtkColorTransferFunction *colorTF) const
vtkPlot * addOpacityFunction(vtkPiecewiseFunction *opacityTF, bool editable=true)
Q_INVOKABLE vtkPlot * addColorTransferFunction(vtkColorTransferFunction *colorTF, bool editable=true)
QList< vtkControlPointsItem * > controlPointsItems() const
vtkPlot * addPiecewiseFunctionControlPoints(vtkPiecewiseFunction *piecewiseTF)
vtkPlot * addCompositeFunction(vtkColorTransferFunction *colorTF, vtkPiecewiseFunction *opacityTF, bool colorTFEditable=true, bool opacityTFEditable=true)
QList< vtkPlot * > colorTransferFunctionPlots() const
vtkPlot * addOpacityFunctionControlPoints(vtkPiecewiseFunction *opacityTF)
void moveAllPoints(double xOffset, double yOffset=0., bool dontMoveFirstAndLast=false)
virtual void boundAxesToChartBounds()
Reimplemented to set the bounds to the plots as well.
QList< vtkPlot * > opacityFunctionPlots() const
QList< vtkPlot * > opacityFunctionPlots(vtkPiecewiseFunction *opacityTF) const
void setBordersVisible(bool show)
void setValidBounds(double bounds[4])
void setColorTransferFunctionToPlots(vtkColorTransferFunction *colorTF)
QScopedPointer< ctkVTKScalarsToColorsViewPrivate > d_ptr
void setPiecewiseFunctionToPlots(vtkPiecewiseFunction *piecewiseTF)
vtkPlot * addLookupTable(vtkLookupTable *lut)
void setPlotsUserBounds(double *bounds)
void setOpacityFunctionToPlots(vtkPiecewiseFunction *opacityTF)
QList< vtkPlot * > lookupTablePlots() const
vtkPlot * addColorTransferFunctionControlPoints(vtkColorTransferFunction *colorTF)
virtual ~ctkVTKScalarsToColorsView()
void spreadAllPoints(double factor=1., bool dontMoveFirstAndLast=false)
bool areBordersVisible() const
void validBounds(double bounds[4]) const
QList< vtkPlot * > lookupTablePlots(vtkLookupTable *lut) const
ctkVTKScalarsToColorsView(QWidget *parent=0)
QList< vtkPlot * > plots() const
vtkPlot * addPiecewiseFunction(vtkPiecewiseFunction *piecewiseTF, bool editable=true)
vtkPlot * addCompositeFunctionControlPoints(vtkColorTransferFunction *colorTF, vtkPiecewiseFunction *opacityTF)
void setLookuptTableToPlots(vtkLookupTable *lut)
void editPoint(vtkObject *plot, void *pointId)
#define QVTK_OBJECT
Define VTK/Qt event/slot connection utility methods. It is a convenient macro that declares and defin...