MEPP2 Project
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
FEVV::GradientColorMap< PValue > Class Template Reference

This templated class 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 <GradientColorMap.h>

Collaboration diagram for FEVV::GradientColorMap< PValue >:
Collaboration graph

Public Types

using Value = PValue
 

Public Member Functions

 GradientColorMap ()=delete
 
 GradientColorMap (const Value &_min, const Value &_max, const Color &_firstColor, const Color &_lastColor)
 
 GradientColorMap (const GradientColorMap &_other)
 
 ~GradientColorMap ()=default
 
Color operator() (const Value &_value) const
 
GradientColorMapoperator= (const GradientColorMap &_other)
 
void addColor (const Color &_color)
 
void clear ()
 
const ValueminValue () const
 
const ValuemaxValue () const
 

Static Public Member Functions

static Color getColor (const std::vector< Color > &_colors, const Value &_min, const Value &_max, const Value &_value)
 

Protected Attributes

Value myMin
 
Value myMax
 
std::vector< ColormyColors
 

Detailed Description

template<typename PValue>
class FEVV::GradientColorMap< PValue >

This templated class may be used to (linearly) convert scalar values in a given range into a color in a gradient defined by two or more colors.

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 <iostream>
#include "Base/Color.hpp"
using namespace FEVV;
// ...
{
GradientColorMap<float> gradient( 0.0, 1000.0, Color::White(), Color::Red() );
Color c = gradient( 230.0 );
std::cout << "Color: [" << c.red() << ";"
<< c.green() << ";"
<< c.blue() << "]" << std::endl;
}
Template Parameters
PValueThe type of the range values.
Note
This class has been ported from DGtal library (http://dgtal.org - GNU LGPL v3). Original author: Sebastien Fourey (Sebas.nosp@m.tien.nosp@m..Four.nosp@m.ey@g.nosp@m.reyc..nosp@m.ensi.nosp@m.caen..nosp@m.fr ) Groupe de Recherche en Informatique, Image, Automatique et Instrumentation de Caen - GREYC (CNRS, UMR 6072), ENSICAEN, France

Definition at line 59 of file GradientColorMap.h.

Member Typedef Documentation

◆ Value

template<typename PValue >
using FEVV::GradientColorMap< PValue >::Value = PValue

Definition at line 63 of file GradientColorMap.h.

Constructor & Destructor Documentation

◆ GradientColorMap() [1/3]

template<typename PValue >
FEVV::GradientColorMap< PValue >::GradientColorMap ( )
delete

Constructor.

◆ GradientColorMap() [2/3]

template<typename PValue >
FEVV::GradientColorMap< PValue >::GradientColorMap ( const Value _min,
const Value _max,
const Color _firstColor,
const Color _lastColor 
)
inline

Constructor.

Precondition
_min and _max values must be different. min < max.
Parameters
_minThe lower bound of the value range.
_maxThe upper bound of the value range.
_firstColorThe "left" color of the gradient.
_lastColorThe "right" color of the gradient.

Definition at line 15 of file GradientColorMap.inl.

Here is the call graph for this function:

◆ GradientColorMap() [3/3]

template<typename PValue >
FEVV::GradientColorMap< PValue >::GradientColorMap ( const GradientColorMap< PValue > &  _other)
inline

Copy constructor.

Parameters
_otherThe object to clone.

Definition at line 32 of file GradientColorMap.inl.

◆ ~GradientColorMap()

template<typename PValue >
FEVV::GradientColorMap< PValue >::~GradientColorMap ( )
default

Destructor.

Member Function Documentation

◆ addColor()

template<typename PValue >
void FEVV::GradientColorMap< PValue >::addColor ( const Color _color)
inline

Adds a color to the list of color steps.

Parameters
_colorA color.

Definition at line 65 of file GradientColorMap.inl.

◆ clear()

template<typename PValue >
void FEVV::GradientColorMap< PValue >::clear
inline

Clears the list of colors.

Definition at line 72 of file GradientColorMap.inl.

◆ getColor()

template<typename PValue >
FEVV::Color FEVV::GradientColorMap< PValue >::getColor ( const std::vector< Color > &  _colors,
const Value _min,
const Value _max,
const Value _value 
)
inlinestatic

Computes the color associated with a value in a given range.

Precondition
_min and _max values must be different. _min < _max.
Parameters
_colorsThe gradients boundary colors.
_minThe lower bound of the value range.
_maxThe upper bound of the value range.
_valueA value within the value range.
Returns
A color whose color linearly depends on the position of [_value] within the range [_min]..[_max].

Definition at line 93 of file GradientColorMap.inl.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxValue()

template<typename PValue >
const PValue & FEVV::GradientColorMap< PValue >::maxValue
inline

Returns the upper bound of the value range.

Returns
The upper bound of the value range.

Definition at line 86 of file GradientColorMap.inl.

◆ minValue()

template<typename PValue >
const PValue & FEVV::GradientColorMap< PValue >::minValue
inline

Returns the lower bound of the value range.

Returns
The lower bound of the value range.

Definition at line 79 of file GradientColorMap.inl.

◆ operator()()

template<typename PValue >
FEVV::Color FEVV::GradientColorMap< PValue >::operator() ( const Value _value) const
inline

Computes the color associated with a value in a given range.

Parameters
_valueA value within the value range.
Returns
A color whose brightness linearly depends on the position of [_value] within the current range.

Definition at line 58 of file GradientColorMap.inl.

Here is the call graph for this function:

◆ operator=()

template<typename PValue >
FEVV::GradientColorMap< PValue > & FEVV::GradientColorMap< PValue >::operator= ( const GradientColorMap< PValue > &  _other)

Assignment.

Parameters
_otherThe object to copy.
Returns
A reference on 'this'.

Definition at line 42 of file GradientColorMap.inl.

Member Data Documentation

◆ myColors

template<typename PValue >
std::vector< Color > FEVV::GradientColorMap< PValue >::myColors
protected

The gradients boundary colors.

Definition at line 161 of file GradientColorMap.h.

◆ myMax

template<typename PValue >
Value FEVV::GradientColorMap< PValue >::myMax
protected

The upper bound of the value range.

Definition at line 160 of file GradientColorMap.h.

◆ myMin

template<typename PValue >
Value FEVV::GradientColorMap< PValue >::myMin
protected

The lower bound of the value range.

Definition at line 159 of file GradientColorMap.h.


The documentation for this class was generated from the following files:
FEVV::Color::blue
void blue(const unsigned char _blueValue)
Definition: Color.inl:94
FEVV::Color::green
void green(const unsigned char _greenValue)
Definition: Color.inl:87
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Color
Definition: Color.hpp:18
FEVV::Color::Red
static Color Red(void)
Definition: Color.inl:335
FEVV::GradientColorMap
This templated class may be used to (linearly) convert scalar values in a given range into a color in...
Definition: GradientColorMap.h:60
FEVV::Color::White
static Color White(void)
Definition: Color.inl:329
Color.hpp
FEVV::Color::red
void red(const unsigned char _redValue)
Definition: Color.inl:80
GradientColorMap.h