Overview     Modules     Class Hierarchy     Classes     Members  

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:

Public Member Functions

 ColorScale (const bool gradient=true)
 ColorScale (const std::vector< Color > &colors, const bool gradient=true)
 ColorScale (const ColorScale &scale)
ColorScaleoperator= (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, ColorgetColorMap () 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.
- Public Member Functions inherited from tlp::Observable
 Observable ()
_DEPRECATED Observable (bool)
virtual ~Observable ()
tlp::Iterator< Observable * > * getOnlookers () const
 return an Iterator on all Onlookers
tlp::Iterator< Observable * > * getObservables () const
virtual void treatEvents (const std::vector< Event > &events)
virtual void _DEPRECATED update (std::set< Observable * >::iterator, std::set< Observable * >::iterator)
virtual void _DEPRECATED observableDestroyed (Observable *)
virtual void treatEvent (const Event &)
void addObserver (Observable *const obs) const
 use for old observer tulip compatibility
void addListener (Observable *const obs) const
 use for old observer tulip compatibility
void removeOnlooker (const Observable &, OLOEDGETYPE type) const
 remove an Observer/Listener of the observable
void removeObserver (Observable *const obs) const
 use for old observer tulip compatibility
void removeListener (Observable *const obs) const
void _DEPRECATED notifyObservers ()
 use for old observer tulip compatibility
void _DEPRECATED notifyDestroy ()
 use for old observer tulip compatibility
unsigned int countObservers () const
unsigned int countOnLookers () const
unsigned int countListeners () const
bool hasOnlookers () const
 remove all Observer/Listener of the observable
- Public Member Functions inherited from tlp::OLOObject
tlp::node getNode () const
 return the node representing that OLOObject in the OLOGraph
unsigned int getSent () const
 return the number of sent nofication
unsigned int getReceived () const
 return the number of received nofication

Protected Attributes

std::map< float, ColorcolorMap
bool gradient
bool colorScaleSet

Additional Inherited Members

- Static Public Member Functions inherited from tlp::Observable
static void holdObservers ()
 start delay of events to all Observer
static void unholdObservers ()
 Send queued event to all Observer.
static void _DEPRECATED unholdObservers (bool)
static unsigned int observersHoldCounter ()
- Protected Types inherited from tlp::OLOObject
enum  OLOEDGETYPE { OBSERVABLE = 0x01, OBSERVER = 0x02, LISTENER = 0x04 }
- Protected Member Functions inherited from tlp::Observable
void addOnlooker (const Observable &, OLOEDGETYPE type) const
 add an Observer/Listener to the observable
void sendEvent (const Event &)
 Enable to send an event to all Observer/Listener.
void observableDeleted ()
 Enable to send Event::DELETE before the deletion of subclass internal objects.

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
gradientSpecify 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
colorsa vector of colors defining the color scale (first color is at position 0, last color at position 1)
gradientSpecify 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
posThis 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)
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
posthe position in the color scale (0.0 <= pos <= 1.0)
colorthe 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
colorsThe colors to use in the color scale.
gradientIf set to true, color scale is a gradient

Member Data Documentation

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


Tulip Software by LaBRI Visualization Team    2001 - 2012