Overview     Modules     Class Hierarchy     Classes     Members  

tlp::ColorScale Class Reference

This class represents a color scale to perform color mapping. The color scale can be either gradient or predefined colors steps. If the color scale is a gradient, returned colors are interpolated in function of the position. If the color scale isn't a gradient returned colors are the predefined colors steps. More...

#include <ColorScale.h>

Inheritance diagram for tlp::ColorScale:
Collaboration diagram for tlp::ColorScale:

List of all members.

Public Member Functions

  • ColorScale (const bool gradient=true)
  • ColorScale (const std::vector< Color > &colors, const bool gradient=true)
  • ColorScale (const ColorScale &scale)
  • ColorScale & operator= (const ColorScale &scale)
  • virtual ~ColorScale ()
  • virtual void setColorScale (const std::vector< Color > colors, const bool gradient=true)
    Configures the color scale. This method configures the color scale. If the scale was previously configured the old configuration is lost.
  • virtual void setColorAtPos (const float pos, const Color &color)
    Adds a color to the color scale at specific position. This method adds a color to the color scale at a specific position.
  • virtual Color getColorAtPos (const float pos) const
    Returns the color for a given position in the color scale. This method computes the color associated to a specific position in the color scale and returns it.
  • bool colorScaleInitialized () const
    Returns true is the color scale was initialized.
  • std::map< float, Color > getColorMap () const
    Returns 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 () const
    Returns true if the color scale is a gradient.

Protected Attributes


Detailed Description

This class represents a color scale to perform color mapping. The color scale can be either gradient or predefined colors steps. If the color scale is a gradient, returned colors are interpolated in function of the position. If the color scale isn't a gradient returned colors are the predefined colors steps.

 \// Creating the color scale.
 ColorScale colorScale;
 \// Color scale initialization : from blue to red with gradient.
 colorScale.setColorAtPos(0.0, Color(0,0,255));
 colorScale.setColorAtPos(1.0, Color(255,0,0));

 \// Get the color for the position 0.5, i.e. Color(127,0,127).
 colorScale.getColorAtPos(0.5);
 \// Reinitialize the color scale : from blue to red without gradient.
 vector<color> newColors;
 newColors.push_back(Color(0,0,255));
 newColors.push_back(Color(255,0,0));
 colorScale.setColorScale(newColors,false);
 \// Get the color for the position 0.3, i.e. Color(0,0,255).
 colorScale.getColorAtPos(0.3);
 \// Get the color for the position 0.7, i.e. Color(255,0,0).
 colorScale.getColorAtPos(0.7);

Constructor & Destructor Documentation

tlp::ColorScale::ColorScale ( const bool  gradient = true  ) 

Initializes a color scale with a default set of colors.

Parameters:
gradient Specify if the color scale should be a gradient or not.
tlp::ColorScale::ColorScale ( const std::vector< Color > &  colors,
const bool  gradient = true 
)

Initializes a color scale with a set of colors passed as parameter

Parameters:
colors a vector of colors defining the color scale (first color is at position 0, last color at position 1)
gradient Specify if the color scale should be a gradient or not.
tlp::ColorScale::ColorScale ( const ColorScale scale  ) 
virtual tlp::ColorScale::~ColorScale (  )  [virtual]

Member Function Documentation

bool tlp::ColorScale::colorScaleInitialized (  )  const [inline]

Returns true is the color scale was initialized.

virtual Color tlp::ColorScale::getColorAtPos ( const float  pos  )  const [virtual]

Returns the color for a given position in the color scale. This method computes the color associated to a specific position in the color scale and returns it.

Parameters:
pos This value defines the position of the color in the scale and must be between 0.0 and 1.0 (it will be clamped otherwise).
Returns:
The color corresponding to the position in the scale.
std::map<float, Color> tlp::ColorScale::getColorMap (  )  const [inline]

Returns 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 (  )  const [inline]

Returns true if the color scale is a gradient.

ColorScale& tlp::ColorScale::operator= ( const ColorScale scale  ) 

Reimplemented from tlp::OLOObject.

virtual void tlp::ColorScale::setColorAtPos ( const float  pos,
const Color color 
) [virtual]

Adds a color to the color scale at specific position. This method adds a color to the color scale at a specific position.

Parameters:
pos the position in the color scale (0.0 <= pos <= 1.0)
color the color to add at the specified position
virtual void tlp::ColorScale::setColorScale ( const std::vector< Color colors,
const bool  gradient = true 
) [virtual]

Configures the color scale. This method configures 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, color scale is a gradient

Member Data Documentation

std::map<float, Color> tlp::ColorScale::colorMap [protected]
bool tlp::ColorScale::gradient [protected]


Tulip Software by LaBRI Visualization Team    2001 - 2012