Wt  3.7.1
Classes | Public Member Functions | List of all members
Wt::Chart::WStandardColorMap Class Reference

Standard colorMap. More...

Inheritance diagram for Wt::Chart::WStandardColorMap:
Inheritance graph
[legend]

Classes

class  Pair
 Contains a pair of a numerical value and a WColor. More...
 

Public Member Functions

 WStandardColorMap (double min, double max, bool continuous)
 Construct a default colormap. More...
 
 WStandardColorMap (double min, double max, const std::vector< WStandardColorMap::Pair > &colors, bool continuous)
 Construct a custom colormap. More...
 
void discretise (int numberOfBands)
 Utility method to discretise a continuous colormap in a number of equally sized bands. More...
 
virtual WColor toColor (double value) const
 Converts a numerical value to a WColor.
 
virtual void createStrip (WPainter *painter, const WRectF &area=WRectF()) const
 Paints the colormap as a colored strip. More...
 
virtual void paintLegend (WPainter *painter, const WRectF &area=WRectF()) const
 Paints the colormap as a legend. More...
 
- Public Member Functions inherited from Wt::Chart::WAbstractColorMap
 WAbstractColorMap (double min, double max, WObject *parent=0)
 Constructor. More...
 
double minimum () const
 Returns the minimum of the colormap range.
 
double maximum () const
 Returns the maximum of the colormap range.
 
void setTickSpacing (int spacing)
 Sets the tickspacing for the legend as a number of line-heights. More...
 
int tickSpacing () const
 Returns the tickspacing for the legend. More...
 
void setFormatString (const WString &format)
 Sets the format for the labels on the colormap-legend. More...
 
const WStringformatString () const
 Returns the format string. More...
 
void setLabelFont (const WFont &font)
 Sets the font to be used when drawing the labels in the legend. More...
 
const WFontlabelFont ()
 Returns the font to be used when drawing the labels in the legend. More...
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object. More...
 
virtual ~WObject ()
 Destructor. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
void isNotStateless ()
 Marks the current function as not stateless. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
void addChild (WObject *child)
 Adds a child object. More...
 
virtual void removeChild (WObject *child)
 Removes a child object. More...
 
const std::vector< WObject * > & children () const
 Returns the children.
 
WObjectparent () const
 Returns the parent object.
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call. More...
 

Detailed Description

Standard colorMap.

The WStandardColorMap is defined by a list of value-to-color pairs. The WStandardColorMap has two modes: a continuous mode, in which the colors are linearly interpolated in between the pair values, and a non-continuous mode, where the values are not interpolated, so that the colormap has a banded effect. In non-continuous mode, the color of a given point P is the color of the pair with the largest value smaller than P.

Numerical values above the maximum value in the list map to the maximum value's color, all values below the minimum value in the list map to the minimum value's color. The range indicated by the minimum and maximum passed to the constructor determines which part of the colormap is drawn by createStrip() or paintLegend().

The figure below illustrates the possible colormaps that can be constructed from the list {"0.0 - darkRed", "1.0 - red", "2.0 - gray"}. The discrete map (on the left) has the range [0, 3], the continuous map (on the right) has the range [0, 2]. The utility method discretise() is also applied to the continuous colormap to obtain a colormap with 5 bands in the same range.

standardcolormaps.png
Different uses of WStandardColorMap

Constructor & Destructor Documentation

◆ WStandardColorMap() [1/2]

Wt::Chart::WStandardColorMap::WStandardColorMap ( double  min,
double  max,
bool  continuous 
)

Construct a default colormap.

The default colormap is a transition from yellow to red. The color-scheme was taken from ColorBrewer, which contains lots of useful info and example schemes you might want to use for your custom colormaps.

◆ WStandardColorMap() [2/2]

Wt::Chart::WStandardColorMap::WStandardColorMap ( double  min,
double  max,
const std::vector< WStandardColorMap::Pair > &  colors,
bool  continuous 
)

Construct a custom colormap.

This constructor allows you to pass a list of value-to-color pairs that define a colormap as described in the class description.

Member Function Documentation

◆ createStrip()

void Wt::Chart::WStandardColorMap::createStrip ( WPainter painter,
const WRectF area = WRectF() 
) const
virtual

Paints the colormap as a colored strip.

This paints the colormap from the minimum to the maximum value in the provided area (default = fill the entire paintdevice). This is no legend with ticks and labels, only the colors are painted.

See also
paintLegend()

Implements Wt::Chart::WAbstractColorMap.

◆ discretise()

void Wt::Chart::WStandardColorMap::discretise ( int  numberOfBands)

Utility method to discretise a continuous colormap in a number of equally sized bands.

This method makes a new list of value-to-color pairs by discretising the linear interpolation of the previous one into numberOfBands equally sized colorbands. This method only has effect if the colormap is continuous.

◆ paintLegend()

void Wt::Chart::WStandardColorMap::paintLegend ( WPainter painter,
const WRectF area = WRectF() 
) const
virtual

Paints the colormap as a legend.

The colormap is painted as a legend with ticks and value-labels. The parameter area can be used to specify a part of the paintdevice where the legend should be drawn. When drawing the legend, the tickspacing, labelformat and labelfont are taken into account.

See also
setTickSpacing(), setFormatString(), setLabelFont()

Implements Wt::Chart::WAbstractColorMap.


Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13