Wt: Wt::Chart::WStandardColorMap Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Wt::Chart::WStandardColorMap Class Reference

Standard colorMap. More...

`#include <WStandardColorMap.h>`

Inheritance diagram for Wt::Chart::WStandardColorMap:
[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.
| WStandardColorMap (double min, double max, const std::vector< WStandardColorMap::Pair > &colors, bool continuous)
| Construct a custom colormap.
void | discretise (int numberOfBands)
| Utility method to discretise a continuous colormap in a number of equally sized bands.
virtual WColor | toColor (double value) const override
| Converts a numerical value to a WColor.
virtual void | createStrip (WPainter *painter, const WRectF &area=WRectF()) const override
| Paints the colormap as a colored strip.
virtual void | paintLegend (WPainter *painter, const WRectF &area=WRectF()) const override
| Paints the colormap as a legend.
Public Member Functions inherited from Wt::Chart::WAbstractColorMap
| WAbstractColorMap (double min, double max)
| Constructor.
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.
int | tickSpacing () const
| Returns the tickspacing for the legend.
void | setFormatString (const WString &format)
| Sets the format for the labels on the colormap-legend.
const WString & | formatString () const
| Returns the format string.
void | setLabelFont (const WFont &font)
| Sets the font to be used when drawing the labels in the legend.
const WFont & | labelFont ()
| Returns the font to be used when drawing the labels in the legend.
Public Member Functions inherited from Wt::WObject
void | addChild (std::unique_ptr< WObject > child)
| Add a child WObject whose lifetime is determined by this WObject.
template<typename Child >
Child * | addChild (std::unique_ptr< Child > child)
| Add a child WObject, returning a raw pointer.
std::unique_ptr< WObject > | removeChild (WObject *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
template<typename Child >
std::unique_ptr< Child > | removeChild (Child *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
virtual const std::string | id () const
| Returns the (unique) identifier for this object.
virtual void | setObjectName (const std::string &name)
| Sets an object name.
virtual std::string | objectName () const
| Returns the object name.
void | resetLearnedSlots ()
| Resets learned stateless slot implementations.
template<class T >
void | resetLearnedSlot (void(T::*method)())
| Resets a learned stateless slot implementation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)())
| Declares a slot to be stateless and learn client-side behaviour on first invocation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)())
| Declares a slot to be stateless and learn client-side behaviour in advance.
void | isNotStateless ()
| Marks the current function as not stateless.
template<class T >
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode)
| Provides a JavaScript implementation for a method.
Public Member Functions inherited from Wt::Core::observable
| observable () noexcept
| Default constructor.
virtual | ~observable ()
| Destructor.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...)) noexcept
| Protects a method call against object destruction.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...) const) const noexcept
| Protects a const method call against object destruction.
template<typename Function >
auto | bindSafe (const Function &function) noexcept
| Protects a function against object destruction.

## Additional Inherited Members
Public Types inherited from Wt::WObject
typedef void(WObject::*) | Method()
| Typedef for a WObject method without arguments.
Static Public Member Functions inherited from Wt::WObject
Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * | getStateless (Method method)
| On-demand stateless slot implementation.
Protected Attributes inherited from Wt::Chart::WAbstractColorMap

## 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 - StandardColor::DarkRed", "1.0 - StandardColor::Red", "2.0 - StandardColor::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.

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()

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

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()

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

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.