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>
template<typename PValue, int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
class DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >
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.
#include "Color.h"
#include "GradientColorMap.h"
{
Board b;
b.setPenColor( gradient( 230.0 ) );
GradientColorMap<int> grad3( 0, 500 );
b.setPenColor( grad3( 100 ) );
b.setPenColor( grad3( 300 ) );
}
- Template Parameters
-
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. |
- Examples
- geometry/meshes/curvature-comparator-ii-cnc-3d.cpp, geometry/meshes/curvature-measures-icnc-3d.cpp, geometry/meshes/curvature-measures-icnc-XY-3d.cpp, geometry/meshes/curvature-measures-nc-3d.cpp, geometry/meshes/curvature-measures-nc-XY-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-XY-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-XY-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-3d.cpp, and geometry/meshes/vol-curvature-measures-icnc-XY-3d.cpp.
Definition at line 119 of file GradientColorMap.h.
◆ Value
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
◆ GradientColorMap() [1/3]
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
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.
- Precondition
- min and max values must be different.
- Parameters
-
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. |
◆ ~GradientColorMap()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
◆ GradientColorMap() [2/3]
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Copy constructor.
- Parameters
-
other | the object to clone. |
◆ GradientColorMap() [3/3]
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Constructor. Forbidden by default (protected to avoid g++ warnings).
◆ addColor()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Adds a color to the list of color steps.
- Parameters
-
- Examples
- geometry/meshes/curvature-comparator-ii-cnc-3d.cpp, geometry/meshes/curvature-measures-icnc-3d.cpp, geometry/meshes/curvature-measures-icnc-XY-3d.cpp, geometry/meshes/curvature-measures-nc-3d.cpp, geometry/meshes/curvature-measures-nc-XY-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-XY-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-3d.cpp, geometry/meshes/obj-curvature-measures-icnc-XY-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-3d.cpp, and geometry/meshes/vol-curvature-measures-icnc-XY-3d.cpp.
Referenced by DGtal::Shortcuts< TKSpace >::getColorMap(), main(), makeColorMap(), TEST_CASE(), testBreadthFirstPropagation(), testDistancePropagation(), testLayers(), testSetTable(), and testSimplePoints2D().
◆ clearColors()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Clears the list of colors.
Referenced by main().
◆ getColor()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
static Color DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::getColor |
( |
const std::vector< Color > & |
colors, |
|
|
const PValue & |
min, |
|
|
const PValue & |
max, |
|
|
PValue |
value |
|
) |
| |
|
static |
Computes the color associated with a value in a given range.
- Precondition
- min and max values must be different.
- Parameters
-
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. |
- Returns
- A color whose color linearly depends on the position of [value] within the range [min]..[max].
◆ isValid()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Checks the validity/consistency of the object.
- Returns
- 'true' if the object is valid, 'false' otherwise.
◆ max()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
const PValue& DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::max |
( |
| ) |
const |
Returns the upper bound of the value range.
- Returns
- The upper bound of the value range.
◆ min()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
const PValue& DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::min |
( |
| ) |
const |
Returns the lower bound of the value range.
- Returns
- The lower bound of the value range.
◆ operator()()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Computes the color associated with a value in a given range.
- Parameters
-
value | A value within the value range. |
- Returns
- A color whose brightness linearly depends on the position of [value] within the current range.
◆ operator=()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
Assignment.
- Parameters
-
- Returns
- a reference on 'this'.
◆ selfDisplay()
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
void DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::selfDisplay |
( |
std::ostream & |
out | ) |
const |
Writes/Displays the object on an output stream.
- Parameters
-
out | the output stream where the object is written. |
◆ myColors
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
◆ myMax
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
◆ myMin
template<typename PValue , int PDefaultPreset = CMAP_CUSTOM, int PDefaultFirstColor = -1, int PDefaultLastColor = -1>
The documentation for this class was generated from the following file: