cgv
Loading...
Searching...
No Matches
cgv::media::continuous_color_scale Class Reference

Implementation of a color_scale with a continuous input domain and output range using a continuous_color_scheme. More...

#include <color_scale.h>

Inheritance diagram for cgv::media::continuous_color_scale:
cgv::media::color_scale

Public Member Functions

 continuous_color_scale ()
 Construct using default arguments.
 
 continuous_color_scale (const continuous_color_scheme &scheme)
 Construct using the given color scheme.
 
bool is_discrete () const override
 See color_scale::is_discrete().
 
bool is_opaque () const override
 See color_scale::is_opaque().
 
void set_domain (cgv::vec2 domain) override
 See color_scale::set_domain().
 
void set_transform (ContinuousMappingTransform transform)
 Set the transform used to map scalars to colors.
 
ContinuousMappingTransform get_transform () const
 Get the transform used to map scalars to colors.
 
virtual void set_pow_exponent (float exponent)
 Set the exponent for power scales.
 
float get_pow_exponent () const
 Get the exponent for power scales.
 
virtual void set_log_base (float base)
 Set the base for logarithmic scales.
 
float get_log_base () const
 Get the base for logarithmic scales.
 
virtual void set_diverging (bool diverging)
 Set whether the scale uses a diverging mapping.
 
bool is_diverging () const
 Get whether the scale uses a diverging mapping.
 
virtual void set_midpoint (float midpoint)
 Set the midpoint for diverging scales.
 
float get_midpoint () const
 Get the midpoint for diverging scales.
 
float normalize_value (float value) const override
 See color_scale::normalize_value()
 
cgv::rgb get_mapped_color (float value) const override
 See color_scale::get_mapped_value()
 
std::vector< cgv::rgbaquantize (size_t count) const override
 See color_scale::quantize().
 
std::vector< float > get_ticks (size_t request_count) const override
 See color_scale::get_ticks().
 
void set_scheme (const continuous_color_scheme &scheme)
 Set the color scheme used as this scale's color ramp.
 
continuous_color_scheme get_scheme () const
 Get the color scheme used as this scale's color ramp.
 
- Public Member Functions inherited from cgv::media::color_scale
virtual ~color_scale ()
 Destruct this color scale.
 
cgv::vec2 get_domain () const
 Get the input domain of scalars that will be mapped.
 
virtual void set_clamped (bool clamped)
 Set whether the input values are clamped to the domain before mapping.
 
bool is_clamped () const
 Get whether the input values are clamped to the domain before mapping.
 
virtual void set_reversed (bool reverse)
 Set whether the output color ramp is reversed.
 
bool is_reversed () const
 Get whether the output color ramp is reversed.
 
virtual void set_unknown_color (cgv::rgba color)
 Set the color returned for scalars outside the domain if clamping is disabled.
 
cgv::rgba get_unknown_color () const
 Get the color returned for scalars outside the domain if clamping is disabled.
 
virtual cgv::rgba map_value (float value) const
 Map a value through the scale and return a RGBA color.
 
virtual float get_mapped_opacity (float value) const
 Map a value through the scale and return an opacity.
 
virtual cgv::rgba get_indexed_color (size_t index) const
 Map a discrete index through the lookup table and return a RGBA color.
 
virtual size_t get_indexed_color_count () const
 return the number of available indexed colors.
 
cgv::data::time_point get_modified_time () const
 Get the time point of the last modification of this object.
 

Additional Inherited Members

- Protected Member Functions inherited from cgv::media::color_scale
void modified ()
 Update the object's modified time.
 
bool is_unknown (float value) const
 Test whether the value is outside the domain according to the mapping options.
 
float map_range_safe (float value, float in_left, float in_right, float out_left, float out_right) const
 Remap a scalar value from an input range to and output range while safely handling empty ranges.
 

Detailed Description

Implementation of a color_scale with a continuous input domain and output range using a continuous_color_scheme.

The scale supports mapping input values to colors using one of the transforms defined in ContinuousMappingTransform.

Definition at line 221 of file color_scale.h.

Constructor & Destructor Documentation

◆ continuous_color_scale() [1/2]

cgv::media::continuous_color_scale::continuous_color_scale ( )
inline

Construct using default arguments.

Definition at line 224 of file color_scale.h.

◆ continuous_color_scale() [2/2]

cgv::media::continuous_color_scale::continuous_color_scale ( const continuous_color_scheme scheme)
inline

Construct using the given color scheme.

Parameters
schemeThe color scheme used as the color ramp.

Definition at line 229 of file color_scale.h.

Member Function Documentation

◆ get_log_base()

float cgv::media::continuous_color_scale::get_log_base ( ) const
inline

Get the base for logarithmic scales.

Returns
The base.

Definition at line 287 of file color_scale.h.

◆ get_mapped_color()

cgv::rgb cgv::media::continuous_color_scale::get_mapped_color ( float  value) const
overridevirtual

◆ get_midpoint()

float cgv::media::continuous_color_scale::get_midpoint ( ) const
inline

Get the midpoint for diverging scales.

Returns
The midpoint.

Definition at line 313 of file color_scale.h.

◆ get_pow_exponent()

float cgv::media::continuous_color_scale::get_pow_exponent ( ) const
inline

Get the exponent for power scales.

Returns
The exponent.

Definition at line 273 of file color_scale.h.

◆ get_scheme()

continuous_color_scheme cgv::media::continuous_color_scale::get_scheme ( ) const
inline

Get the color scheme used as this scale's color ramp.

Returns
The color scheme.

Definition at line 337 of file color_scale.h.

◆ get_ticks()

std::vector< float > cgv::media::continuous_color_scale::get_ticks ( size_t  request_count) const
overridevirtual

◆ get_transform()

ContinuousMappingTransform cgv::media::continuous_color_scale::get_transform ( ) const
inline

Get the transform used to map scalars to colors.

See also set_transform().

Returns
The transform type.

Definition at line 259 of file color_scale.h.

◆ is_discrete()

bool cgv::media::continuous_color_scale::is_discrete ( ) const
inlineoverridevirtual

See color_scale::is_discrete().

Returns
False.

Implements cgv::media::color_scale.

Definition at line 233 of file color_scale.h.

◆ is_diverging()

bool cgv::media::continuous_color_scale::is_diverging ( ) const
inline

Get whether the scale uses a diverging mapping.

Returns
True if diverging mapping is used, false otherwise.

Definition at line 300 of file color_scale.h.

◆ is_opaque()

bool cgv::media::continuous_color_scale::is_opaque ( ) const
inlineoverridevirtual

See color_scale::is_opaque().

Returns
True.

Reimplemented from cgv::media::color_scale.

Definition at line 239 of file color_scale.h.

◆ normalize_value()

float cgv::media::continuous_color_scale::normalize_value ( float  value) const
overridevirtual

◆ quantize()

std::vector< cgv::rgba > cgv::media::continuous_color_scale::quantize ( size_t  count) const
overridevirtual

◆ set_diverging()

void cgv::media::continuous_color_scale::set_diverging ( bool  diverging)
virtual

Set whether the scale uses a diverging mapping.

Diverging scales apply the transform mirrored around the midpoint.

Parameters
divergingSet to true to enable diverging mapping.

Definition at line 66 of file color_scale.cxx.

References cgv::media::color_scale::modified().

◆ set_domain()

void cgv::media::continuous_color_scale::set_domain ( cgv::vec2  domain)
overridevirtual

See color_scale::set_domain().

Reimplemented from cgv::media::color_scale.

Definition at line 40 of file color_scale.cxx.

References cgv::media::color_scale::set_domain().

◆ set_log_base()

void cgv::media::continuous_color_scale::set_log_base ( float  base)
virtual

Set the base for logarithmic scales.

Only used if get_transform() returns ContinuousMappingTransform::kLog. Defaults to 10.

Parameters
exponentThe exponent.

Definition at line 58 of file color_scale.cxx.

References cgv::media::color_scale::modified().

◆ set_midpoint()

void cgv::media::continuous_color_scale::set_midpoint ( float  midpoint)
virtual

Set the midpoint for diverging scales.

Only used if get_diverging() returns true. The midpoint should be inside the scales's domain.

Parameters
midpointThe midpoint.

Definition at line 73 of file color_scale.cxx.

References cgv::media::color_scale::modified().

◆ set_pow_exponent()

void cgv::media::continuous_color_scale::set_pow_exponent ( float  exponent)
virtual

Set the exponent for power scales.

Only used if get_transform() returns ContinuousMappingTransform::kPow. Defaults to 1.

Parameters
exponentThe exponent.

Definition at line 51 of file color_scale.cxx.

References cgv::media::color_scale::modified().

◆ set_scheme()

void cgv::media::continuous_color_scale::set_scheme ( const continuous_color_scheme scheme)

Set the color scheme used as this scale's color ramp.

Parameters
schemeThe color scheme.

Definition at line 163 of file color_scale.cxx.

References cgv::media::color_scale::modified().

◆ set_transform()

void cgv::media::continuous_color_scale::set_transform ( ContinuousMappingTransform  transform)

Set the transform used to map scalars to colors.

Power and log scales support negative domains. For scales with power or log transform and negative domains, input and output values are implicitly multiplied by -1. Log scale domains must be strictly-positive or strictly-negative; the domain must not include or cross zero. The behavior of the scale is undefined if a negative value is passed to a log scale with a positive domain or vice versa.

Parameters
transformThe transform type.

Definition at line 45 of file color_scale.cxx.

References cgv::media::color_scale::modified().


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