|
cgv
|
Implementation of a color_scale with a discrete input domain and output range using a discrete_color_scheme. More...
#include <color_scale.h>
Public Member Functions | |
| discrete_color_scale (const discrete_color_scheme &scheme, size_t size) | |
| Construct using the given color scheme and size. | |
| bool | is_discrete () const override |
| See color_scale::is_discrete(). | |
| bool | is_opaque () const override |
| See color_scale::is_opaque(). | |
| float | normalize_value (float value) const override |
| See color_scale::normalize_value(). | |
| cgv::rgb | get_mapped_color (float value) const override |
| Map a value through the scale and return a RGB color. | |
| cgv::rgba | get_indexed_color (size_t index) const override |
| Return the RGBA color with the given index. | |
| size_t | get_indexed_color_count () const override |
| See color_scale::get_indexed_color_count(). | |
| std::vector< cgv::rgba > | quantize (size_t count) const override |
| Return a sequence of all indexed colors, ignoring count. | |
| std::vector< float > | get_ticks (size_t request_count) const override |
| Not implemented for discrete color scales. | |
| void | set_scheme (const discrete_color_scheme &scheme, size_t size) |
| Set the color scheme and size used as this scale's indexed color source. | |
| discrete_color_scheme | get_scheme () const |
| Get the color scheme used as this scale's indexed color source. | |
Public Member Functions inherited from cgv::media::color_scale | |
| virtual | ~color_scale () |
| Destruct this color scale. | |
| virtual void | set_domain (cgv::vec2 domain) |
| Set the input domain of scalars that will be mapped. | |
| 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. | |
| 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. | |
Implementation of a color_scale with a discrete input domain and output range using a discrete_color_scheme.
The scale is mainly used for mapping discrete indices to discrete colors for, e.g., categorical data. Additionally, discrete_color_scale supports mapping continuous input values to discrete colors.
Definition at line 373 of file color_scale.h.
|
inline |
Definition at line 376 of file color_scale.h.
|
inline |
Construct using the given color scheme and size.
| scheme | The color scheme used as the source for indexed colors. |
| size | The number of colors to extract from the scheme. |
Definition at line 382 of file color_scale.h.
|
overridevirtual |
Return the RGBA color with the given index.
| index | The index into the lookup table. |
Reimplemented from cgv::media::color_scale.
Definition at line 204 of file color_scale.cxx.
|
inlineoverridevirtual |
See color_scale::get_indexed_color_count().
Reimplemented from cgv::media::color_scale.
Definition at line 415 of file color_scale.h.
Referenced by quantize().
|
overridevirtual |
Map a value through the scale and return a RGB color.
Normalizes the value to the domain and discretizes it to an integer index in [0,n) where n is the number of indexed colors.
| value | The value to map. |
Reimplemented from cgv::media::color_scale.
Definition at line 190 of file color_scale.cxx.
References cgv::media::color_scale::get_unknown_color(), cgv::media::color_scale::is_unknown(), and normalize_value().
|
inline |
Get the color scheme used as this scale's indexed color source.
Definition at line 440 of file color_scale.h.
|
overridevirtual |
Not implemented for discrete color scales.
| request_count | Ignored. |
Implements cgv::media::color_scale.
Definition at line 219 of file color_scale.cxx.
|
inlineoverridevirtual |
See color_scale::is_discrete().
Implements cgv::media::color_scale.
Definition at line 388 of file color_scale.h.
|
inlineoverridevirtual |
Reimplemented from cgv::media::color_scale.
Definition at line 394 of file color_scale.h.
|
overridevirtual |
See color_scale::normalize_value().
Reimplemented from cgv::media::color_scale.
Definition at line 182 of file color_scale.cxx.
References cgv::media::color_scale::get_domain(), cgv::media::color_scale::is_clamped(), and cgv::media::color_scale::map_range_safe().
Referenced by get_mapped_color().
|
overridevirtual |
Return a sequence of all indexed colors, ignoring count.
Will return the reversed sequence if get_reversed() returns true.
| count | Ignored. |
Implements cgv::media::color_scale.
Definition at line 209 of file color_scale.cxx.
References get_indexed_color_count(), and cgv::media::color_scale::is_reversed().
| void cgv::media::discrete_color_scale::set_scheme | ( | const discrete_color_scheme & | scheme, |
| size_t | size | ||
| ) |
Set the color scheme and size used as this scale's indexed color source.
| scheme | The color scheme. |
Definition at line 223 of file color_scale.cxx.
References cgv::media::discrete_color_scheme::get_colors(), and cgv::media::color_scale::modified().