Simox  2.3.74.0
simox::color::ColorMap Class Reference

A color map, mapping scalar values to colors. More...

Public Member Functions

 ColorMap ()
 Construct an unnamed empty color map. Will always return black. More...
 
 ColorMap (std::initializer_list< Color > init)
 Construct an unnamed color map with equidistant values from 0 to 1 (inclusive). More...
 
 ColorMap (std::initializer_list< std::pair< float, Color >> init)
 Construct an unnamed color map with given values. More...
 
 ColorMap (const std::string &name, std::initializer_list< Color > init)
 Construct a named color map with equidistant values from 0 to 1 (inclusive). More...
 
 ColorMap (const std::string &name, std::initializer_list< std::pair< float, Color >> init)
 Construct a named color map with given values. More...
 
bool empty () const
 
size_t size () const
 Get the number of keys. More...
 
void clear ()
 
void add_key (float value, const Color &color)
 Add a key color at the given value. More...
 
Color at (float value) const
 Get the color for the given scalar value. More...
 
Color at (float value, std::optional< float > vmin, std::optional< float > vmax) const
 Get the color for the given scalar value. More...
 
Color operator() (float value) const
 
template<typename V >
std::vector< Coloroperator() (const std::vector< V > &vector) const
 Apply this colormap to a vector. More...
 
template<typename K , typename V >
std::map< K, Coloroperator() (const std::map< K, V > &map) const
 Apply this colormap to a map's values. More...
 
std::string name () const
 
void setName (const std::string &name)
 
float vmin () const
 The value corresponding to the bottom color. More...
 
float vmax () const
 The value corresponding to the top color. More...
 
void set_vmin (float vmin)
 
void set_vmax (float vmax)
 
void set_vmin (const std::vector< float > &values)
 
void set_vmax (const std::vector< float > &values)
 
template<class T >
void set_vmin (const std::vector< T > &values, std::function< float(const T &)> unaryFunc)
 Set the value minimum to the minimum of values, measured by unaryFunc. You may have to specify the template argument (when template argument deduction fails). More...
 
template<class T >
void set_vmax (const std::vector< T > &values, std::function< float(const T &)> unaryFunc)
 Set the value maximum to the maximum of values, measured by unaryFunc. You may have to specify the template argument (when template argument deduction fails). More...
 
void set_vlimits (float vmin, float vmax)
 Sets the value limits, i.e. scales the color map to the range [vmin, vmax]. More...
 
void set_vlimits (const std::vector< float > &values)
 
template<class T >
void set_vlimits (const std::vector< T > &values, std::function< float(const T &)> unaryFunc)
 Set the value minimum and maximum to the minimum and maximum of values, measured by unaryFunc. You may have to specify the template argument (when template argument deduction fails). More...
 
ColorMap reversed () const
 Get this colormap reversed (but defined in the same value range as *this). More...
 

Detailed Description

A color map, mapping scalar values to colors.

Constructor & Destructor Documentation

◆ ColorMap() [1/5]

simox::color::ColorMap::ColorMap ( )

Construct an unnamed empty color map. Will always return black.

◆ ColorMap() [2/5]

simox::color::ColorMap::ColorMap ( std::initializer_list< Color init)

Construct an unnamed color map with equidistant values from 0 to 1 (inclusive).

◆ ColorMap() [3/5]

simox::color::ColorMap::ColorMap ( std::initializer_list< std::pair< float, Color >>  init)

Construct an unnamed color map with given values.

◆ ColorMap() [4/5]

simox::color::ColorMap::ColorMap ( const std::string &  name,
std::initializer_list< Color init 
)

Construct a named color map with equidistant values from 0 to 1 (inclusive).

◆ ColorMap() [5/5]

simox::color::ColorMap::ColorMap ( const std::string &  name,
std::initializer_list< std::pair< float, Color >>  init 
)

Construct a named color map with given values.

Member Function Documentation

◆ add_key()

void simox::color::ColorMap::add_key ( float  value,
const Color color 
)
inline

Add a key color at the given value.

◆ at() [1/2]

Color simox::color::ColorMap::at ( float  value) const

Get the color for the given scalar value.

Empty color maps always return black.

Parameters
valueThe scalar value.
Returns

◆ at() [2/2]

Color simox::color::ColorMap::at ( float  value,
std::optional< float >  vmin,
std::optional< float >  vmax 
) const

Get the color for the given scalar value.

Empty color maps always return black.

Parameters
valueThe scalar value.
vminOverride for vmin().
vmaxOverride for vmax().
Returns

◆ clear()

void simox::color::ColorMap::clear ( )
inline

◆ empty()

bool simox::color::ColorMap::empty ( ) const
inline

◆ name()

std::string simox::color::ColorMap::name ( ) const
inline

◆ operator()() [1/3]

Color simox::color::ColorMap::operator() ( float  value) const
inline
See also
ColorMap::at()

◆ operator()() [2/3]

template<typename V >
std::vector<Color> simox::color::ColorMap::operator() ( const std::vector< V > &  vector) const
inline

Apply this colormap to a vector.

◆ operator()() [3/3]

template<typename K , typename V >
std::map<K, Color> simox::color::ColorMap::operator() ( const std::map< K, V > &  map) const
inline

Apply this colormap to a map's values.

◆ reversed()

ColorMap simox::color::ColorMap::reversed ( ) const

Get this colormap reversed (but defined in the same value range as *this).

◆ set_vlimits() [1/3]

void simox::color::ColorMap::set_vlimits ( float  vmin,
float  vmax 
)
inline

Sets the value limits, i.e. scales the color map to the range [vmin, vmax].

◆ set_vlimits() [2/3]

void simox::color::ColorMap::set_vlimits ( const std::vector< float > &  values)
inline

◆ set_vlimits() [3/3]

template<class T >
void simox::color::ColorMap::set_vlimits ( const std::vector< T > &  values,
std::function< float(const T &)>  unaryFunc 
)
inline

Set the value minimum and maximum to the minimum and maximum of values, measured by unaryFunc. You may have to specify the template argument (when template argument deduction fails).

◆ set_vmax() [1/3]

void simox::color::ColorMap::set_vmax ( float  vmax)
inline

◆ set_vmax() [2/3]

void simox::color::ColorMap::set_vmax ( const std::vector< float > &  values)
inline

◆ set_vmax() [3/3]

template<class T >
void simox::color::ColorMap::set_vmax ( const std::vector< T > &  values,
std::function< float(const T &)>  unaryFunc 
)
inline

Set the value maximum to the maximum of values, measured by unaryFunc. You may have to specify the template argument (when template argument deduction fails).

◆ set_vmin() [1/3]

void simox::color::ColorMap::set_vmin ( float  vmin)
inline

◆ set_vmin() [2/3]

void simox::color::ColorMap::set_vmin ( const std::vector< float > &  values)
inline

◆ set_vmin() [3/3]

template<class T >
void simox::color::ColorMap::set_vmin ( const std::vector< T > &  values,
std::function< float(const T &)>  unaryFunc 
)
inline

Set the value minimum to the minimum of values, measured by unaryFunc. You may have to specify the template argument (when template argument deduction fails).

◆ setName()

void simox::color::ColorMap::setName ( const std::string &  name)
inline

◆ size()

size_t simox::color::ColorMap::size ( ) const
inline

Get the number of keys.

◆ vmax()

float simox::color::ColorMap::vmax ( ) const
inline

The value corresponding to the top color.

◆ vmin()

float simox::color::ColorMap::vmin ( ) const
inline

The value corresponding to the bottom color.