IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Lib.ColorScale Class Reference

More...

+ Inheritance diagram for IG.Lib.ColorScale:
+ Collaboration diagram for IG.Lib.ColorScale:

Public Member Functions

 ColorScale (double minValue, double maxValue, params color[] definitionColors)
 Constructor. Creates a continuous scale. More...
 
 ColorScale (double minValue, double maxValue, int numCells, params color[] definitionColors)
 Constructor. Creates a discrete scale with the specified number of cells. More...
 
 ColorScale (double minValue, double maxValue, int numCells, bool isDiscrete, params color[] definitionColors)
 Constructor. More...
 
override double FromReference (double referenceValue)
 Transforms the specified value from reference domain (interval [0,1]) to actual domain. More...
 
override double ToReference (double actualValue)
 Transforms the specified value from actual domain to reference domain (interval [0,1]). More...
 
override color GetContinuousReferenceColor (double referenceValue)
 Returns the CONTINUOUS color from the current color scale that corresponds to the specified value in the REFERENCE domain (interval [0, 1]). More...
 
override double GetReferenceCellValue (int cellIndex)
 Returns the reference value (in the interval [0, 1]) corresponding to the specified cell in the discrete color map. This value is used to obtain the uniform (discrete) color of the cell by the methods that produces continuous scale colors (continuous methods are usually basis for scale definitions). More...
 
override int GetReferenceCellIndex (double referenceValue)
 Retuns index of the cell of the discrete color scale that corresponds to the specified value in the reference domain (interval [0, 1]). More...
 
- Public Member Functions inherited from IG.Lib.ColorScaleBase
virtual color GetColor (double value)
 Returns the color from the current collor scale that corresponds to the specified value. More...
 
virtual color GetReferenceColor (double referenceValue)
 Returns the color from the current color scale that corresponds to the specified value in the reference domain (interval [0,1]). More...
 
virtual color GetContinuousColor (double value)
 Returns the CONTINUOUS color from the current color scale that corresponds to the specified value. More...
 
virtual double GetCellValue (int cellIndex)
 Returns the value corresponding to the specified cell in the discrete color map. This value is used to obtain the uniform (discrete) color of the cell by the methods that produces continuous scale colors (continuous methods are usually basis for scale definitions). More...
 
virtual color GetCellColor (int cellIndex)
 Returns the (discrete) color corresponding to the specified cell index. If the index is out of range then the lowest or the highest cell color is returned, dependent on whether the value is smaller than lower bound or greater than upper bound. More...
 
virtual int GetCellIndex (double value)
 Retuns index of the cell of the discrete color scale that corresponds to the specified value (in the actusl domain). More...
 
virtual color GetDiscreteReferenceColor (double referenceValue)
 Returns a color from the DISCRETE color scale represented by the current object that corresponds to he specified value in the REFERENCE domain (interval [0, 1]). More...
 
virtual color GetDiscreteColor (double value)
 Returns a color from the DISCRETE color scale represented by the current object that corresponds to he specified value (in the actual domain). More...
 

Protected Member Functions

void SetDefinitionColors (color[] colors)
 Sets the definition colors that define the color scale. More...
 
virtual void UpdateAuxiliaryData ()
 Updates precalculated auxiliary data that are used for faster calculations. More...
 

Protected Attributes

int _numDefinitionColors
 Number of specified colors that define the color scale. More...
 
double _intervalLength
 Difference between maximal and minimal value. More...
 
- Protected Attributes inherited from IG.Lib.ColorScaleBase
int _numCells = 0
 

Properties

double MinValue [get, set]
 Lower bound for values for which color scale is defines. More...
 
double MaxValue [get, set]
 Upper bound for values for which color scale is defines. More...
 
- Properties inherited from IG.Lib.ColorScaleBase
bool IsDiscrete [get, protected set]
 Gets the flag indicating whether the color scale is discrete (with a finite number of possible colors, as opposed to continuous). More...
 
int NumCells [get, set]
 Number of cells in discrete color scale. More...
 
- Properties inherited from IG.Lib.IColorScale
bool IsDiscrete [get]
 Gets the flag indicating whether the color scale is discrete (with a finite number of possible colors, as opposed to continuous). More...
 
int NumCells [get, set]
 Number of cells in discrete color scale. More...
 

Private Attributes

color[] _definitionColors
 Table of definition colors. More...
 
double _minValue
 
double _maxvalue
 

Additional Inherited Members

- Static Public Member Functions inherited from IG.Lib.ColorScaleBase
static ColorScale Create (double minValue, double maxValue, params color[] scaleColors)
 Creates and returns a continuous color scale that runs through the specified colors. More...
 
static ColorScale Create (double minValue, double maxValue, int numCells, params color[] scaleColors)
 Creates and returns a discrete color scale that runs through the specified colors. More...
 
static ColorScale CreateDefault (double minValue, double maxValue)
 Creates and returns a continuous color scale that runs from blue through red till yellow color. More...
 
static ColorScale CreateDefault (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that runs from blue through red till yellow color. More...
 
static ColorScale CreateRainbowFull (double minValue, double maxValue)
 Creates and returns a continuous color scale that runs from violet till red color and passes rainbow colors in their natural order (red-orange-yellow-green-blue-indigo-violet). More...
 
static ColorScale CreateRainbowFull (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that runs from violet till red color and passes rainbow colors in their natural order (red-orange-yellow-green-blue-indigo-violet). More...
 
static ColorScale CreateRainbow (double minValue, double maxValue)
 Creates and returns a continuous color scale that runs from violet till red color and passes rainbow colors in their natural order (red-orange-yellow-green-blue-violet). More...
 
static ColorScale CreateRainbow (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that runs from violet till red color and passes rainbow colors in their natural order (red-orange-yellow-green-blue-indigo-violet). More...
 
static ColorScale CreateColorBlind (double minValue, double maxValue)
 Creates and returns a continuous color scale that is adapted to color blind people in general. More...
 
static ColorScale CreateColorBlind (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that is adapted to color blind people in general. More...
 
static ColorScale CreateColorBlindProtanopia (double minValue, double maxValue)
 Creates and returns a continuous color scale that is adapted to people with protanopia. More...
 
static ColorScale CreateColorBlindProtanopia (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that is adapted to people with protanopia. More...
 
static ColorScale CreateColorBlindDeuteranopia (double minValue, double maxValue)
 Creates and returns a continuous color scale that is adapted to people with deuteranopia. More...
 
static ColorScale CreateColorBlindDeuteranopia (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that is adapted to people with deuteranopia. More...
 
static ColorScale CreateColorBlindTritanopia (double minValue, double maxValue)
 Creates and returns a continuous color scale that is adapted to people with tritanopia. More...
 
static ColorScale CreateColorBlindTritanopia (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that is adapted to people with tritanopia. More...
 
static ColorScale CreateGray (double minValue, double maxValue)
 Creates and returns a continuous color scale with various hues of gray. More...
 
static ColorScale CreateGray (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale with various hues of gray. More...
 
static ColorScale CreateBlueRed (double minValue, double maxValue)
 Creates and returns a continuous color scale that ranges from dark blue to red. More...
 
static ColorScale CreateBlueRed (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that ranges from dark blue to red. More...
 
static ColorScale CreateBlueYellow (double minValue, double maxValue)
 Creates and returns a continuous color scale that ranges from dark blue to yellow. More...
 
static ColorScale CreateBlueYellow (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that ranges from dark blue to yellow. More...
 
static ColorScale CreateBlueRedYellow (double minValue, double maxValue)
 Creates and returns a continuous color scale that runs from blue through red till yellow color. More...
 
static ColorScale CreateBlueRedYellow (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that runs from blue through red till yellow color. More...
 
static IColorScale CreateBlueGreenYellow (double minValue, double maxValue)
 Creates and returns a continuous color scale that runs from blue through green till red color. More...
 
static ColorScale CreateBlueGreenRed (double minValue, double maxValue, int numCells)
 Creates and returns a discrete color scale that runs from blue through green till red color. More...
 

Detailed Description

Color scale; linearly mapped values, discrete scaling functionality, value to color mappiong defined through interpolation of table of provided mark colors.

Provides mapping from scalar values to colors, defining continuous or discrete color scales.

NOT thread safe.

Mapping from scalar value to color is usually defined continuously on the reference interval of values ranging from 0 to 1.

This class was initially used in GUI building for fadeouts, but has now broader applicaton and is used in all kins of graphical applications. This is also the reason that it is placed in the IG.Lib namespace. Discrete color values are added in 2011 for needs in graphic applications.

A set of colors define the continuous color scale. When a reference value changes from 0 to 1, the corresponding color on the color scale smoothly varies from the first to the last color and passes all eventual intermediate colros.

Discrete color scale is defined on basis of continuous scale in such a way that for whole subranges of values in the reference domain (interval [0, 1]) only a single color is picked. This color corresponds to a particular discrete value in the reference domain, usually in the middle of the subinterval in the reference space that corresponds to a given cell of the color scale.

Values our of range:

For continuous scale, values out of range will produce colors that correspond to either lower or upper bound of the range (dependent in which direction the range is exceeded). For discrete scale, either color of the lower or of the upper cell is produced.

The same object provides methods for getting collors either from continuous or form discrete color scale. There are methods such as ColorScaleBase.GetColor or ColorScaleBase.GetReferenceColor that return colors form either scale, dependent on the current value of the ColorScaleBase.IsDiscrete property.

See also:

http://www.sapdesignguild.org/resources/glossary_color/

$A Igor Jul08 Oct11;

Constructor & Destructor Documentation

IG.Lib.ColorScale.ColorScale ( double  minValue,
double  maxValue,
params color[]  definitionColors 
)
inline

Constructor. Creates a continuous scale.

Discrete scale has 10 cells.

Parameters
minValueLower bound of the range of values for which color scale is defined.
maxValueUpper bound of the range of values for which color scale is defined.
definitionColorsA set of colors that define the color scale. Color of the continuous scale will smoothly transition through these values when parameter in the reference domain would run form 0 to 1.

There should be at least one definition color (In this case, the color scale will have a uniform color).

IG.Lib.ColorScale.ColorScale ( double  minValue,
double  maxValue,
int  numCells,
params color[]  definitionColors 
)
inline

Constructor. Creates a discrete scale with the specified number of cells.

Parameters
minValueLower bound of the range of values for which color scale is defined.
maxValueUpper bound of the range of values for which color scale is defined.
numCellsNuber of cells in the discrete scale.
definitionColorsA set of colors that define the color scale. Color of the continuous scale will smoothly transition through these values when parameter in the reference domain would run form 0 to 1.

There should be at least one definition color (In this case, the color scale will have a uniform color).

IG.Lib.ColorScale.ColorScale ( double  minValue,
double  maxValue,
int  numCells,
bool  isDiscrete,
params color[]  definitionColors 
)
inline

Constructor.

Parameters
minValueLower bound of the range of values for which color scale is defined.
maxValueUpper bound of the range of values for which color scale is defined.
numCellsNuber of cells in the discrete scale.
isDiscreteDeterminse whether the main method such as ColorScaleBase.GetColor and ColorScaleBase.GetReferenceColor provide colors of continuous or discrete scale.
definitionColorsA set of colors that define the color scale. Color of the continuous scale will smoothly transition through these values when parameter in the reference domain would run form 0 to 1.

There should be at least one definition color (In this case, the color scale will have a uniform color).

Member Function Documentation

void IG.Lib.ColorScale.SetDefinitionColors ( color[]  colors)
inlineprotected

Sets the definition colors that define the color scale.

Internal table to store these colors is allocated anew and colors are copied to the table.

Parameters
colorsDefinition colors.
override double IG.Lib.ColorScale.FromReference ( double  referenceValue)
inline

Transforms the specified value from reference domain (interval [0,1]) to actual domain.

Parameters
referenceValueValue in the reference domain.
Returns
Value in the actual domain corresponding to the specified value in the reference domain.

Implements IG.Lib.IColorScale.

override double IG.Lib.ColorScale.ToReference ( double  actualValue)
inline

Transforms the specified value from actual domain to reference domain (interval [0,1]).

Parameters
actualValueValue in the actual domain.
Returns
Value in the reference domain corresponding to the specified value in the actual domain.

Implements IG.Lib.IColorScale.

virtual void IG.Lib.ColorScale.UpdateAuxiliaryData ( )
inlineprotectedvirtual

Updates precalculated auxiliary data that are used for faster calculations.

override color IG.Lib.ColorScale.GetContinuousReferenceColor ( double  referenceValue)
inline

Returns the CONTINUOUS color from the current color scale that corresponds to the specified value in the REFERENCE domain (interval [0, 1]).

Scale can be continuous or discrete (in the latter case ColorScaleBase.IsDiscrete is true).

Parameters
referenceValueValue in the reference domain (interval [0, 1]) for which the corresponding color is returned.

Implements IG.Lib.IColorScale.

References IG.Lib.color.Mixture(), and IG.Lib.color.Scale().

override double IG.Lib.ColorScale.GetReferenceCellValue ( int  cellIndex)
inline

Returns the reference value (in the interval [0, 1]) corresponding to the specified cell in the discrete color map. This value is used to obtain the uniform (discrete) color of the cell by the methods that produces continuous scale colors (continuous methods are usually basis for scale definitions).

Parameters
cellIndexIndex of the cell for which the corresponding characteristic value (usually in the middle of the cell interval) is returned.

Implements IG.Lib.IColorScale.

override int IG.Lib.ColorScale.GetReferenceCellIndex ( double  referenceValue)
inline

Retuns index of the cell of the discrete color scale that corresponds to the specified value in the reference domain (interval [0, 1]).

Parameters
referenceValueValue in the reference domain (interval [0, 1]) for wihich index of the discrete cell of the color scale is returned.

Implements IG.Lib.IColorScale.

Member Data Documentation

color [] IG.Lib.ColorScale._definitionColors
private

Table of definition colors.

int IG.Lib.ColorScale._numDefinitionColors
protected

Number of specified colors that define the color scale.

double IG.Lib.ColorScale._minValue
private
double IG.Lib.ColorScale._maxvalue
private
double IG.Lib.ColorScale._intervalLength
protected

Difference between maximal and minimal value.

Property Documentation

double IG.Lib.ColorScale.MinValue
getset

Lower bound for values for which color scale is defines.

To the values below this limit, the lowest-value color is assigned.

Referenced by IG.Gr3d.TestVtkGraphicBase.ColorBar(), IG.Gr3d.VtkCurvePlot.Create(), IG.Gr3d.VtkSurfacePlot.Create(), and IG.Gr3d.UtilVtk.LookUpTableRange().

double IG.Lib.ColorScale.MaxValue
getset

Upper bound for values for which color scale is defines.

To the values above this limit, the highest-value color is assigned.

Referenced by IG.Gr3d.TestVtkGraphicBase.ColorBar(), IG.Gr3d.VtkCurvePlot.Create(), IG.Gr3d.VtkSurfacePlot.Create(), and IG.Gr3d.UtilVtk.LookUpTableRange().


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