tlp::ColorScale Class Reference#include <ColorScale.h>
Inherits tlp::Observable.
Inheritance diagram for tlp::ColorScale:
[legend]Collaboration diagram for tlp::ColorScale:
[legend]List of all members.
Detailed Description
Use this class to create a color scale and perform color mapping. The color scale can be either gradient or predefined colors steps. If the color scale is a gradient, returned color are interpolated in function of the position. If the color scale isn't a gradient returned colors are the predefined colors steps.
\
ColorScale colorScale;
\
vector<color> colors;
colors.push_back(Color(0,0,255));
colors.push_back(Color(255,0,0));
colorScale.setColorScale(colors,true);
\
colorScale.getColorAtPos(0.5);
\
vector<color> newColors;
newColors.push_back(Color(0,0,255));
newColors.push_back(Color(255,0,0));
colorScale.setColorScale(colors,false);
\
colorScale.getColorAtPos(0.3);
\
colorScale.getColorAtPos(0.7);
Public Member Functions
- ColorScale ()
- ColorScale (const ColorScale &scale)
- virtual ~ColorScale ()
- virtual void setColorScale (const std::vector< Color > colors, const bool gradient=true)
- Configure the color scale. This method is used to configure the color scale. If the scale was previously configured the old configuration is lost.
- virtual Color getColorAtPos (const float pos) const
- Compute the color for the given value.
- bool colorScaleInitialized () const
- Return true is the color scale was initialized.
- std::map< float, Color > getColorMap () const
- Return a map corresponding to the color scale. The index of the map is the position for the corresponding color in the color scale.
- bool isGradient ()
- Return true if the color scale use gradient.
Protected Attributes
Constructor & Destructor Documentation
tlp::ColorScale::ColorScale |
( |
|
) |
|
|
tlp::ColorScale::ColorScale |
( |
const ColorScale & |
scale |
) |
|
|
virtual tlp::ColorScale::~ColorScale |
( |
|
) |
[virtual] |
|
Member Function Documentation
bool tlp::ColorScale::colorScaleInitialized |
( |
|
) |
const [inline] |
|
|
Return true is the color scale was initialized.
|
virtual Color tlp::ColorScale::getColorAtPos |
( |
const float |
pos |
) |
const [virtual] |
|
|
Compute the color for the given value.
- Parameters:
-
| pos | This value define the position of the color in the scale and must be between 0 and 1.0. |
- Returns:
- The color corresponding to the position in the scale if the position is beetween 0 and 1.0. If the position is smaller than 0 the color corresponding to the position 0 is returned and if the position is greater than 1.0 the color corresponding to the position 1.0 is returned.
|
std::map<float, Color> tlp::ColorScale::getColorMap |
( |
|
) |
const [inline] |
|
|
Return a map corresponding to the color scale. The index of the map is the position for the corresponding color in the color scale.
|
bool tlp::ColorScale::isGradient |
( |
|
) |
[inline] |
|
|
Return true if the color scale use gradient.
|
virtual void tlp::ColorScale::setColorScale |
( |
const std::vector< Color > |
colors, |
|
|
const bool |
gradient = true |
|
) |
[virtual] |
|
|
Configure the color scale. This method is used to configure the color scale. If the scale was previously configured the old configuration is lost.
- Parameters:
-
| colors | The colors to use in the color scale. |
| gradient | If set to true perform a |
|
Member Data Documentation
|