scoop  0.1.4
Scoop - Simple ColoR pAleTtes and mappERs
scoop::SequentialColorMap Class Reference

Class for sequential color mapppers. More...

#include <SequentialColorMap.h>

+ Collaboration diagram for scoop::SequentialColorMap:

Public Types

enum  ColorInterpolation { RGB_INTERPOLATION = 0, HSV_INTERPOLATION }
 Types of interpolation supported.
 

Public Member Functions

 SequentialColorMap (float minValue_=0.f, const Color &minColor=Color(0, 0, 0), float maxValue_=1.f, const Color &maxColor=Color(255, 255, 255))
 Default constructor. More...
 
 SequentialColorMap (const std::vector< float > &values, const ColorPalette &palette)
 Constructs a sequential color mapper based on a container of values and a color palette. More...
 
 SequentialColorMap (const ColorPalette &palette, float minValue=0.f, float maxValue=1.f)
 Constructs a sequential color mapper based on a min and max values and a color palette. More...
 
void setFromPalette (const std::vector< float > &values, const ColorPalette &palette)
 Sets the sequential color mapper based on a container of values and a color palette. More...
 
float minValue (void) const
 Returns the minimum key value. More...
 
float maxValue (void) const
 Returns the maximum key value. More...
 
void addColor (const float value, const Color &color)
 Adds a new key value and its associated color. More...
 
Color getColor (const float value, const ColorInterpolation interpolation=RGB_INTERPOLATION) const
 Gets the color associated to a value. More...
 

Protected Member Functions

Color _rgbInterpolation (const Color &color1, const Color &color2, float normDist) const
 
Color _hsvInterpolation (const Color &color1, const Color &color2, float normDist) const
 

Protected Attributes

std::map< float, Color > _valuesToColors
 Ordered container with the mapping between values and colors.
 

Detailed Description

Class for sequential color mapppers.

This class allows to define a sequential color mapper. It allows to define a set of key values (floats) associated to colors. It also provides methods to get a color in between key values and obtain the interpolated color, both in RGB and HSV space. In order to be created at least two key points and two colors have to be defined, otherwise it will use 0.0f and 1.0f as key values and black and white as theis associated colors.

Definition at line 43 of file SequentialColorMap.h.

Constructor & Destructor Documentation

scoop::SequentialColorMap::SequentialColorMap ( float  minValue_ = 0.f,
const Color &  minColor = Color(0, 0, 0),
float  maxValue_ = 1.f,
const Color &  maxColor = Color(255, 255, 255) 
)

Default constructor.

Parameters
[in]minValue_minimum key value
[in]minColorcolor associated to maximum key value
[in]maxValue_maximum key value
[in]maxColorcolor associated to maximum key value
scoop::SequentialColorMap::SequentialColorMap ( const std::vector< float > &  values,
const ColorPalette palette 
)

Constructs a sequential color mapper based on a container of values and a color palette.

The size of the container of values and the palette have to be the same and at least 2, otherwise an exception will be raised.

Parameters
[in]valuescontainer of values
[in]palettepalette to be used
scoop::SequentialColorMap::SequentialColorMap ( const ColorPalette palette,
float  minValue = 0.f,
float  maxValue = 1.f 
)

Constructs a sequential color mapper based on a min and max values and a color palette.

A set of key values, of the size of the palette, will ba created equally distributed in the range [minValue_,maxValue_]

Parameters
[in]palettepalette to be used
[in]minValueminimum key value
[in]maxValuemaximum key value

Member Function Documentation

void scoop::SequentialColorMap::addColor ( const float  value,
const Color &  color 
)

Adds a new key value and its associated color.

If key valye exists the color will be overwritten

Parameters
[in]valuenew key value
[in]colorcolor to be assoaciated to the key value
Color scoop::SequentialColorMap::getColor ( const float  value,
const ColorInterpolation  interpolation = RGB_INTERPOLATION 
) const

Gets the color associated to a value.

If the value has not been registered with a color then the color returned will be interpolated in RGB os HSV color space.

Parameters
[in]valuevalue to query its color
[in]interpolationspace in which the interpolation, if needed, will be carried out
Returns
the color associated to the input value
float scoop::SequentialColorMap::maxValue ( void  ) const

Returns the maximum key value.

Returns
maximum key value
float scoop::SequentialColorMap::minValue ( void  ) const

Returns the minimum key value.

Returns
maximum key value
void scoop::SequentialColorMap::setFromPalette ( const std::vector< float > &  values,
const ColorPalette palette 
)

Sets the sequential color mapper based on a container of values and a color palette.

The size of the container of values and the palette have to be the same and at least 2, otherwise an exception will be raised. Current key values and colors are cleared.

Parameters
[in]valuescontainer of values
[in]palettepalette to be used

The documentation for this class was generated from the following file: