Workspace 6.21.5
Public Member Functions | List of all members
ColorScale Class Reference

Class for mapping a value to a color.

#include <DataAnalysis/Color/colorscale.h>

Inheritance diagram for ColorScale:
[legend]

Public Member Functions

 ColorScale ()
 
 ColorScale (const ColorScale &mapper)
 
 ~ColorScale () override
 
ColorScaleclone () const override
 
QString getCacheId () const
 
double getMaximum () const
 
double getMinimum () const
 
const ColorSpectrumgetSpectrum () const
 
QColor mapToColor (double d) const
 
bool operator!= (const ColorScale &scale) const
 
ColorScaleoperator= (const ColorScale &mapper)
 
bool operator== (const ColorScale &scale) const
 
bool rangeIsValid () const
 
void setMaximum (double maximum)
 
void setMinimum (double minimum)
 
void setRange (double minimum, double maximum)
 
void setSpectrum (const ColorSpectrum &spectrum)
 
void setUseLog10 (bool val)
 
- Public Member Functions inherited from ObjectGroup
 ~ObjectGroup () override
 
bool add (const QString &name, DataObject &obj)
 
bool canSerialize () const override
 
ObjectGroupclone () const override=0
 
bool empty () const
 
void ensureGroupHasData ()
 
void erase (int index)
 
DataObjectgetChild (const QString &name)
 
const DataObjectgetChild (const QString &name) const
 
DataObjectgetDataObject (int index)
 
const DataObjectgetDataObject (int index) const
 
int getIndex (const QString &name) const
 
const QString & getName (int index) const
 
virtual QString getPreferedWidget (const QString &name) const
 
bool hasData () const
 
bool haveName (const QString &name) const
 
bool insert (const QString &name, DataObject &obj, int index=-1)
 
bool load (const QJsonDocument &doc)
 
bool load (const SerializedItem &item) override
 
bool save (QJsonDocument &doc) const
 
bool save (SerializedItem &item) const override
 
unsigned size () const
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 
- Public Member Functions inherited from Serialize
virtual ~Serialize ()=default
 
virtual bool canSerialize () const =0
 
virtual bool load (const SerializedItem &item)=0
 
virtual bool save (SerializedItem &item) const =0
 

Additional Inherited Members

- Protected Member Functions inherited from ObjectGroup
 ObjectGroup ()
 
void clear ()
 
ObjectGroupoperator= (const ObjectGroup &rhs)
 
bool operator== (const ObjectGroup &rhs) const
 
void swap (ObjectGroup &rhs)
 

Constructor & Destructor Documentation

◆ ColorScale() [1/2]

◆ ColorScale() [2/2]

ColorScale ( const ColorScale mapper)

◆ ~ColorScale()

~ColorScale ( )
override

Member Function Documentation

◆ clone()

ColorScale * clone ( ) const
overridevirtual
Returns
A clone of this object.
Note
Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.

We redeclare this function only so that the more derived return type is available without casting.

Implements ObjectGroup.

◆ getCacheId()

QString getCacheId ( ) const
Returns
A string which is a semi-human readable representation of the color scale. It will be more or less unique for different settings and is intended to be used as a cache ID for things that need a string identifier for the current settings.

◆ getMaximum()

double getMaximum ( ) const
Returns
The highest value in the color scale. This maps to the value 1 in the color spectrum returned from getSpectrum().

◆ getMinimum()

double getMinimum ( ) const
Returns
The lowest value in the color scale. This maps to the value 0 in the color spectrum returned from getSpectrum().

◆ getSpectrum()

const ColorSpectrum & getSpectrum ( ) const
Returns
The color spectrum being used by the color scale.

◆ mapToColor()

QColor mapToColor ( double  d) const
Parameters
dThe value for which the associated color is to be obtained.

This function maps the value d into the color space defined by the scale's color spectrum. A color spectrum operates on a fixed linear range from 0 to 1, whereas a color scale maps a floating linear scale between two arbitrary values into this [0,1] range.

Returns
The color that the value d maps to.

◆ operator!=()

bool operator!= ( const ColorScale scale) const
Parameters
scaleThe scale to compare against.
Returns
True if scale and this spectrum are not the same.
Note
See the comments for the equality operator regarding items in the object group having data or not.

◆ operator=()

ColorScale & operator= ( const ColorScale mapper)

◆ operator==()

bool operator== ( const ColorScale scale) const
Parameters
scaleThe color scale to compare against.
Returns
True if scale and this color scale are the same.

◆ rangeIsValid()

bool rangeIsValid ( ) const
Returns
True if the color scale range maximum is greater than the minimum.

◆ setMaximum()

void setMaximum ( double  maximum)
Parameters
maximumThe highest value in the color scale.

No check is made as to whether maximum is greater than the current minimum, since the minimum might be getting set after this call. For a safer way to set both the minimum and maximum, see setRange().

◆ setMinimum()

void setMinimum ( double  minimum)
Parameters
minimumThe lowest value in the color scale.

No check is made as to whether minimum is less than the current maximum, since the maximum might be getting set after this call. For a safer way to set both the minimum and maximum, see setRange().

◆ setRange()

void setRange ( double  minimum,
double  maximum 
)
Parameters
minimumThe lowest value in the color scale.
maximumThe hightest value in the color scale.

Note that minimum must be strictly less than the maximum or else this function will do nothing (ie the previous values will be retained).

◆ setSpectrum()

void setSpectrum ( const ColorSpectrum spectrum)
Parameters
spectrumThe new color spectrum to use.

◆ setUseLog10()

void setUseLog10 ( bool  val)