7 #ifndef __FWDATA_TRANSFERFUNCTION_HPP__ 8 #define __FWDATA_TRANSFERFUNCTION_HPP__ 10 #include "fwData/config.hpp" 11 #include "fwData/Object.hpp" 13 fwCampAutoDeclareDataMacro((
fwData)(TransferFunction), FWDATA_API);
29 ::fwData::factory::New< TransferFunction >)
38 typedef double ColorType;
58 TFColor( ColorType _r, ColorType _g, ColorType _b, ColorType _a )
68 inline bool operator== (
const TFColor& _color)
const 70 return (r == _color.
r && g == _color.
g && b == _color.
b && a == _color.
a);
83 typedef double TFValueType;
84 typedef std::vector<TFValueType> TFValueVectorType;
86 typedef std::vector<TFColor> TFColorVectorType;
87 typedef std::map< TFValueType, TFColor > TFDataType;
89 typedef std::pair< TFValueType, TFValueType > TFValuePairType;
98 FWDATA_API
virtual ~TransferFunction();
101 FWDATA_API
void initTF();
104 FWDATA_API
static TransferFunction::sptr createDefaultTF();
107 FWDATA_API
void shallowCopy(
const Object::csptr& _source )
override;
110 FWDATA_API
void cachedDeepCopy(
const Object::csptr& _source, DeepCopyCacheType& cache)
override;
113 FWDATA_API TFValueVectorType getTFValues()
const;
116 FWDATA_API TFValueVectorType getScaledValues()
const;
119 FWDATA_API TFValuePairType getMinMaxTFValues()
const;
122 FWDATA_API TFValuePairType getWLMinMax()
const;
125 FWDATA_API
void setWLMinMax(
const TFValuePairType& minMax);
128 FWDATA_API TFValueType getNearestValue( TFValueType value )
const;
131 FWDATA_API
const TFDataType& getTFData()
const;
134 FWDATA_API
void setTFData(
const TFDataType& tfData );
137 FWDATA_API
void addTFColor( TFValueType value,
const TFColor& color );
140 FWDATA_API
void eraseTFValue( TFValueType value);
143 FWDATA_API
void clear();
146 FWDATA_API TFColorVectorType getTFColors()
const;
149 FWDATA_API
TFColor getNearestColor( TFValueType value )
const;
152 FWDATA_API
TFColor getLinearColor( TFValueType value )
const;
155 FWDATA_API
TFColor getInterpolatedColor( TFValueType value )
const;
158 FWDATA_API
const TFColor& getTFColor( TFValueType value )
const;
161 InterpolationMode getInterpolationMode ()
const;
163 void setInterpolationMode (InterpolationMode val);
166 double getLevel ()
const;
167 void setLevel (
double val);
170 double getWindow ()
const;
171 void setWindow (
double val);
174 const std::string& getName ()
const;
175 void setName (
const std::string& val);
178 bool getIsClamped ()
const;
179 void setIsClamped (
bool val);
182 const TFColor& getBackgroundColor ()
const;
183 void setBackgroundColor (
const TFColor& val);
221 InterpolationMode m_interpolationMode;
239 if(m_interpolationMode == LINEAR)
241 color = this->getLinearColor(value);
243 else if(m_interpolationMode == NEAREST)
245 color = this->getNearestColor(value);
254 return m_interpolationMode;
261 m_interpolationMode = val;
273 inline void TransferFunction::setLevel (
double val)
287 inline void TransferFunction::setWindow (
double val)
301 inline void TransferFunction::setName (
const std::string& val)
315 inline void TransferFunction::setIsClamped (
bool val)
324 return m_backgroundColor;
329 inline void TransferFunction::setBackgroundColor (
const TFColor& val)
331 m_backgroundColor = val;
338 #endif // __FWDATA_TRANSFERFUNCTION_HPP__ ColorType r
red color (value [0,1])
double getWindow() const
Window.
static FWDATA_API const std::string s_DEFAULT_TF_NAME
Default transfer function name.
FWDATA_API TFColor getInterpolatedColor(TFValueType value) const
Get the interpolated color of the TF for a value.The result depends of the current interpolation mode...
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
ColorType b
blue color (value [0,1])
ColorType a
alpha (value [0,1])
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
const TFColor & getBackgroundColor() const
set the TF background color when tf 'IsClamped' is true
Base class for each data object.
InterpolationMode getInterpolationMode() const
Interpolation mode.
This class defines a transfer function.
ColorType g
green color (value [0,1])
Contains the representation of the data objects used in the framework.
Macro for deep and shallow copies.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_WINDOWING_MODIFIED_SIG
Type of signal when points are modified.
::fwCom::Signal< void(double, double) > WindowingModifiedSignalType
Type of signal when window-level is modified (window, level)
const std::string & getName() const
Transfert function name.
double getLevel() const
Level.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINTS_MODIFIED_SIG
Type of signal when points are modified.
InterpolationMode
Defines the available modes {LINEAR, NEAREST} to interpolate color between two TF color points...
bool getIsClamped() const
is TF clamped