Map values within a range onto a set of colours, with a given distribution (linear, log etc) and optional colourmap rotation. More...

#include <ColourScale.h>

Collaboration diagram for ColourScale:
Collaboration graph

Classes

struct  Parameters
 

Public Member Functions

 ColourScale (Parameters parameters)
 Create a ColourScale with the given parameters. More...
 
 ~ColourScale ()
 
 ColourScale (const ColourScale &)=default
 
ColourScaleoperator= (const ColourScale &)=default
 
ColourScaleType getScale () const
 Return the general type of scale this is. More...
 
int getPixel (double value) const
 Return a pixel number (in the range 0-255 inclusive) corresponding to the given value. More...
 
QColor getColourForPixel (int pixel, int rotation) const
 Return the colour for the given pixel number (which must be in the range 0-255). More...
 
QColor getColour (double value, int rotation) const
 Return the colour corresponding to the given value. More...
 

Private Attributes

Parameters m_params
 
ColourMapper m_mapper
 
double m_mappedMin
 
double m_mappedMax
 

Static Private Attributes

static int m_maxPixel = 255
 

Detailed Description

Map values within a range onto a set of colours, with a given distribution (linear, log etc) and optional colourmap rotation.

Definition at line 34 of file ColourScale.h.

Constructor & Destructor Documentation

ColourScale::ColourScale ( Parameters  parameters)

Create a ColourScale with the given parameters.

Note that some parameters may be ignored for some scale distribution settings. For example, min and max are ignored for PlusMinusOneScale and PhaseColourScale and threshold and gain are ignored for PhaseColourScale.

Definition at line 28 of file ColourScale.cpp.

References Absolute, Log, m_mappedMax, m_mappedMin, m_params, ColourScale::Parameters::maxValue, ColourScale::Parameters::minValue, PlusMinusOne, ColourScale::Parameters::scaleType, and ColourScale::Parameters::threshold.

ColourScale::~ColourScale ( )

Definition at line 91 of file ColourScale.cpp.

ColourScale::ColourScale ( const ColourScale )
default

Member Function Documentation

ColourScale& ColourScale::operator= ( const ColourScale )
default
ColourScaleType ColourScale::getScale ( ) const

Return the general type of scale this is.

Definition at line 96 of file ColourScale.cpp.

References m_params, and ColourScale::Parameters::scaleType.

int ColourScale::getPixel ( double  value) const

Return a pixel number (in the range 0-255 inclusive) corresponding to the given value.

The pixel 0 is used only for values below the threshold supplied in the constructor. All other values are mapped onto the range 1-255.

Definition at line 102 of file ColourScale.cpp.

References Absolute, ColourScale::Parameters::gain, Log, m_mappedMax, m_mappedMin, m_maxPixel, m_params, Meter, ColourScale::Parameters::multiple, Phase, PlusMinusOne, ColourScale::Parameters::scaleType, and ColourScale::Parameters::threshold.

QColor ColourScale::getColourForPixel ( int  pixel,
int  rotation 
) const

Return the colour for the given pixel number (which must be in the range 0-255).

The pixel 0 is always the background colour. Other pixels are mapped taking into account the given colourmap rotation (which is also a value in the range 0-255).

Definition at line 157 of file ColourScale.cpp.

References ColourMapper::hasLightBackground(), m_mapper, m_maxPixel, and ColourMapper::map().

QColor ColourScale::getColour ( double  value,
int  rotation 
) const
inline

Return the colour corresponding to the given value.

This is equivalent to getColourForPixel(getPixel(value), rotation).

Definition at line 111 of file ColourScale.h.

Member Data Documentation

Parameters ColourScale::m_params
private

Definition at line 116 of file ColourScale.h.

Referenced by ColourScale(), getPixel(), and getScale().

ColourMapper ColourScale::m_mapper
private

Definition at line 117 of file ColourScale.h.

Referenced by getColourForPixel().

double ColourScale::m_mappedMin
private

Definition at line 118 of file ColourScale.h.

Referenced by ColourScale(), and getPixel().

double ColourScale::m_mappedMax
private

Definition at line 119 of file ColourScale.h.

Referenced by ColourScale(), and getPixel().

int ColourScale::m_maxPixel = 255
staticprivate

Definition at line 120 of file ColourScale.h.

Referenced by getColourForPixel(), and getPixel().


The documentation for this class was generated from the following files: