|
DGtal 2.0.0
|
Aim: This class template may be used to (linearly) convert scalar values in a given range into a color in a gradient defined by two or more colors. More...
#include <DGtal/io/colormaps/GradientColorMap.h>
Public Types | |
| typedef PValue | Value |
Public Member Functions | |
| GradientColorMap (const PValue &min, const PValue &max, const ColorGradientPreset preset=static_cast< ColorGradientPreset >(PDefaultPreset), const Color firstColor=(PDefaultFirstColor==-1) ? Color::None :Color(DGTAL_RED_COMPONENT(PDefaultFirstColor), DGTAL_GREEN_COMPONENT(PDefaultFirstColor), DGTAL_BLUE_COMPONENT(PDefaultFirstColor)), const Color lastColor=(PDefaultFirstColor==-1) ? Color::None :Color(DGTAL_RED_COMPONENT(PDefaultLastColor), DGTAL_GREEN_COMPONENT(PDefaultLastColor), DGTAL_BLUE_COMPONENT(PDefaultLastColor))) | |
| Color | operator() (const PValue &value) const |
| ~GradientColorMap () | |
| GradientColorMap (const GradientColorMap &other) | |
| GradientColorMap & | operator= (const GradientColorMap &other) |
| void | clearColors () |
| void | addColor (const Color &color) |
| void | selfDisplay (std::ostream &out) const |
| bool | isValid () const |
| const PValue & | min () const |
| const PValue & | max () const |
Static Public Member Functions | |
| static Color | getColor (const std::vector< Color > &colors, const PValue &min, const PValue &max, PValue value) |
Protected Member Functions | |
| GradientColorMap () | |
Protected Attributes | |
| PValue | myMin |
| PValue | myMax |
| std::vector< Color > | myColors |
Aim: This class template may be used to (linearly) convert scalar values in a given range into a color in a gradient defined by two or more colors.
Description of template class 'GradientColorMap'
The GradientColorMap can be used either as a functor object (the value range is given at the object's construction, together with the reference color) which converts a value into a Color structure, or it can be used through a static method taking both the range and the value as parameters.
The code below shows a possible use of this class.
| PValue | The type of the range values. |
| PDefaultPreset | The default gradient preset (e.g. CMAP_GRAYSCALE, CMAP_HOT, or CMAP_CUSTOM |
| PDefaultFirstColor | If DefaultPreset is CMAP_CUSTOM, this is the starting color of the gradient. |
| PDefaultLastColor | If DefaultPreset is CMAP_CUSTOM, this is the ending color of the gradient. |
Definition at line 119 of file GradientColorMap.h.
| typedef PValue DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::Value |
Definition at line 124 of file GradientColorMap.h.
| DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::GradientColorMap | ( | const PValue & | min, |
| const PValue & | max, | ||
| const ColorGradientPreset | preset = static_cast< ColorGradientPreset >(PDefaultPreset), | ||
| const Color | firstColor = (PDefaultFirstColor==-1) ? Color::None :Color(DGTAL_RED_COMPONENT(PDefaultFirstColor), DGTAL_GREEN_COMPONENT(PDefaultFirstColor), DGTAL_BLUE_COMPONENT(PDefaultFirstColor)), | ||
| const Color | lastColor = (PDefaultFirstColor==-1) ? Color::None :Color(DGTAL_RED_COMPONENT(PDefaultLastColor), DGTAL_GREEN_COMPONENT(PDefaultLastColor), DGTAL_BLUE_COMPONENT(PDefaultLastColor)) ) |
Constructor.
| min | The lower bound of the value range. |
| max | The upper bound of the value range. |
| preset | A preset identifier. |
| firstColor | The "left" color of the gradient if preset is CMAP_CUSTOM. |
| lastColor | The "right" color of the gradient if preset is CMAP_CUSTOM. |
| DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::~GradientColorMap | ( | ) |
Destructor.
| DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::GradientColorMap | ( | const GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor > & | other | ) |
Copy constructor.
| other | the object to clone. |
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
| void DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor | ( | const Color & | color | ) |
Adds a color to the list of color steps.
| color | A color. |
Referenced by DGtal::Shortcuts< Z3i::KSpace >::getColorMap(), main(), main(), main(), makeColorMap(), TEST_CASE(), testBreadthFirstPropagation(), testDistancePropagation(), testLayers(), testSetTable(), and testSimplePoints2D().
| void DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::clearColors | ( | ) |
Clears the list of colors.
Referenced by main().
|
static |
Computes the color associated with a value in a given range.
| colors | The gradients boundary colors. |
| min | The lower bound of the value range. |
| max | The upper bound of the value range. |
| value | A value within the value range. |
| bool DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
| const PValue & DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::max | ( | ) | const |
Returns the upper bound of the value range.
| const PValue & DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::min | ( | ) | const |
Returns the lower bound of the value range.
| Color DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::operator() | ( | const PValue & | value | ) | const |
| GradientColorMap & DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::operator= | ( | const GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor > & | other | ) |
Assignment.
| other | the object to copy. |
| void DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
| out | the output stream where the object is written. |
|
protected |
The gradients boundary colors.
Definition at line 255 of file GradientColorMap.h.
|
protected |
The lower bound of the value range.
Definition at line 254 of file GradientColorMap.h.
|
protected |
The lower bound of the value range.
Definition at line 253 of file GradientColorMap.h.