Wt  4.10.4
Public Member Functions | List of all members
Wt::Chart::WAbstractColorMap Class Referenceabstract

Maps numerical values to colors. More...

#include <WAbstractColorMap.h>

Inheritance diagram for Wt::Chart::WAbstractColorMap:
[legend]

Public Member Functions

 WAbstractColorMap (double min, double max)
 Constructor. More...
 
virtual WColor toColor (double value) const =0
 Converts a numerical value to a WColor.
 
virtual void createStrip (WPainter *painter, const WRectF &area=WRectF()) const =0
 Paints the colormap as a colored strip. More...
 
virtual void paintLegend (WPainter *painter, const WRectF &area=WRectF()) const =0
 Paints the colormap as a legend. 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
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. More...
 
std::unique_ptr< WObjectremoveChild (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. 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...
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 Default constructor.
 
virtual ~observable ()
 Destructor. More...
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...)) noexcept
 Protects a method call against object destruction. More...
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 Protects a const method call against object destruction. More...
 
template<typename Function >
auto bindSafe (const Function &function) noexcept
 Protects a function against object destruction. More...
 

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...
 

Detailed Description

Maps numerical values to colors.

The colormap has functionality to convert a numerical value to a WColor. For details on how, see the documentation of the implementations.

A colormap has a certain numerical range. When a colormap is painted as a colored strip or as a legend, this range is what will be presented, even if the colormap has the ability to convert values outside this range.

Constructor & Destructor Documentation

◆ WAbstractColorMap()

Wt::Chart::WAbstractColorMap::WAbstractColorMap ( double  min,
double  max 
)

Constructor.

Constructor taking a minimum and maximum value, determining the active range of the colormap. The default value for tickSpacing is 2 and the default label format is 2 decimal points.

Member Function Documentation

◆ createStrip()

virtual void Wt::Chart::WAbstractColorMap::createStrip ( WPainter painter,
const WRectF area = WRectF() 
) const
pure 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()

Implemented in Wt::Chart::WStandardColorMap.

◆ formatString()

const WString& Wt::Chart::WAbstractColorMap::formatString ( ) const

Returns the format string.

See also
setFormatString()

◆ labelFont()

const WFont& Wt::Chart::WAbstractColorMap::labelFont ( )

Returns the font to be used when drawing the labels in the legend.

See also
setLabelFont

◆ paintLegend()

virtual void Wt::Chart::WAbstractColorMap::paintLegend ( WPainter painter,
const WRectF area = WRectF() 
) const
pure 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()

Implemented in Wt::Chart::WStandardColorMap.

◆ setFormatString()

void Wt::Chart::WAbstractColorMap::setFormatString ( const WString format)

Sets the format for the labels on the colormap-legend.

The format string is interpreted by snprintf(). The default is a float with two decimal places.

See also
paintLegend()

◆ setLabelFont()

void Wt::Chart::WAbstractColorMap::setLabelFont ( const WFont font)

Sets the font to be used when drawing the labels in the legend.

The default is a default constructed WFont.

See also
paintLegend()

◆ setTickSpacing()

void Wt::Chart::WAbstractColorMap::setTickSpacing ( int  spacing)

Sets the tickspacing for the legend as a number of line-heights.

The tickspacing must be specified as an integer number of line-heigths. For example, the default value of 2 will leave two line-heights between the labels of the ticks.

See also
paintLegend()

◆ tickSpacing()

int Wt::Chart::WAbstractColorMap::tickSpacing ( ) const

Returns the tickspacing for the legend.

See also
setTickSpacing()