Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RPalette Class Reference

A set of colors.

RColors can be conveniently generated from this.

A palette associates a color with an ordinal number: for a normalized palette, this number ranges from 0..1. For user-valued palettes, the palette yields a color for user-coordinates (for instance histogram content), in an arbitrary range.

A palette can be a smooth gradients by interpolation of support points, or a set of discrete colors.

Author
Axel Naumann axel@.nosp@m.cern.nosp@m..ch
Date
2017-09-26
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

Definition at line 38 of file RPalette.hxx.

Classes

struct  Discrete_t
 Tag type used to signal that the palette's colors should not be interpolated. More...
 
struct  OrdinalAndColor
 An ordinal value and its associated color. More...
 

Public Member Functions

 RPalette ()=default
 
 RPalette (const std::vector< OrdinalAndColor > &interpPoints)
 Construct a RPalette from a vector of (ordinal|color) pairs as interpolation points.
 
 RPalette (const std::vector< RColor > &interpPoints)
 Construct a normalized RPalette from a vector of colors as interpolation points.
 
 RPalette (Discrete_t, const std::vector< OrdinalAndColor > &points)
 Construct a RPalette from a vector of (ordinal|color) pairs.
 
 RPalette (Discrete_t, const std::vector< RColor > &points)
 Construct a normalized RPalette from a vector of colors.
 
RColor GetColor (double ordinal)
 Get the color associated with the ordinal value.
 
bool IsDiscrete () const
 Whether the palette is discrete, i.e. does no interpolation between colors.
 
bool IsGradient () const
 Whether the palette is a smooth gradient generated by interpolating between the color points.
 
bool IsNormalized () const
 Whether the palette is normalized, i.e. covers colors in the ordinal range 0..1.
 

Static Public Member Functions

Global Palettes
static void RegisterPalette (std::string_view name, const RPalette &palette)
 Register a palette in the set of global palettes, making it available to GetPalette().
 
static const RPaletteGetPalette (std::string_view name="")
 Get a global palette by name.
 

Static Public Attributes

static constexpr const Discrete_t kDiscrete {}
 Tag value used to signal that the palette's colors should not be interpolated.
 

Private Member Functions

 RPalette (bool interpolate, bool knownNormalized, const std::vector< OrdinalAndColor > &points)
 
 RPalette (bool interpolate, const std::vector< RColor > &points)
 

Private Attributes

std::vector< OrdinalAndColorfColors
 Palette colors: the color points and their ordinal value.
 
bool fInterpolate = true
 Whether to interpolate between the colors (in contrast to picking one of fColors).
 
bool fNormalized = true
 Whether the palette's ordinal numbers are normalized.
 

#include <ROOT/RPalette.hxx>

Constructor & Destructor Documentation

◆ RPalette() [1/7]

RPalette::RPalette ( bool  interpolate,
bool  knownNormalized,
const std::vector< OrdinalAndColor > &  points 
)
private

Definition at line 21 of file RPalette.cxx.

◆ RPalette() [2/7]

RPalette::RPalette ( bool  interpolate,
const std::vector< RColor > &  points 
)
private

Definition at line 52 of file RPalette.cxx.

◆ RPalette() [3/7]

ROOT::Experimental::RPalette::RPalette ( )
default

◆ RPalette() [4/7]

ROOT::Experimental::RPalette::RPalette ( const std::vector< OrdinalAndColor > &  interpPoints)
inline

Construct a RPalette from a vector of (ordinal|color) pairs as interpolation points.

Palette colors will be these points for the ordinal, and interpolated in between the ordinal points. The points will be sorted. The palette is normalized if the lowest ordinal is 0. and the highest ordinal is 1.; otherwise, the palette is a user-valued palette.

Definition at line 85 of file RPalette.hxx.

◆ RPalette() [5/7]

ROOT::Experimental::RPalette::RPalette ( Discrete_t  ,
const std::vector< OrdinalAndColor > &  points 
)
inline

Construct a RPalette from a vector of (ordinal|color) pairs.

For a given value, the palette returns the color with an ordinal that is closest to the value. The points will be sorted. The palette is normalized if the lowest ordinal is 0. and the highest ordinal is 1.; otherwise, the palette is a user-valued palette.

Definition at line 91 of file RPalette.hxx.

◆ RPalette() [6/7]

ROOT::Experimental::RPalette::RPalette ( const std::vector< RColor > &  interpPoints)
inline

Construct a normalized RPalette from a vector of colors as interpolation points.

The ordinal associated with each color is equidistant from 0..1, i.e. for three colors it will be 0., 0.5 and 1, respectively. Palette colors will be these points for the ordinal associated with the color, and interpolated in between the ordinal points.

Definition at line 97 of file RPalette.hxx.

◆ RPalette() [7/7]

ROOT::Experimental::RPalette::RPalette ( Discrete_t  ,
const std::vector< RColor > &  points 
)
inline

Construct a normalized RPalette from a vector of colors.

The ordinal associated with each color is equidistant from 0..1, i.e. for three colors it will be 0., 0.5 and 1, respectively. For a given value, the palette returns the color with an ordinal that is closest to the value.

Definition at line 102 of file RPalette.hxx.

Member Function Documentation

◆ GetColor()

RColor RPalette::GetColor ( double  ordinal)

Get the color associated with the ordinal value.

The value is expected to be 0..1 for a normalized palette.

Definition at line 56 of file RPalette.cxx.

◆ GetPalette()

const RPalette & RPalette::GetPalette ( std::string_view  name = "")
static

Get a global palette by name.

Returns an empty palette if no palette with that name is known. This function is not thread safe; any concurrent call to global Palette manipulation must be synchronized!

Definition at line 143 of file RPalette.cxx.

◆ IsDiscrete()

bool ROOT::Experimental::RPalette::IsDiscrete ( ) const
inline

Whether the palette is discrete, i.e. does no interpolation between colors.

Definition at line 108 of file RPalette.hxx.

◆ IsGradient()

bool ROOT::Experimental::RPalette::IsGradient ( ) const
inline

Whether the palette is a smooth gradient generated by interpolating between the color points.

Definition at line 111 of file RPalette.hxx.

◆ IsNormalized()

bool ROOT::Experimental::RPalette::IsNormalized ( ) const
inline

Whether the palette is normalized, i.e. covers colors in the ordinal range 0..1.

Definition at line 105 of file RPalette.hxx.

◆ RegisterPalette()

void RPalette::RegisterPalette ( std::string_view  name,
const RPalette palette 
)
static

Register a palette in the set of global palettes, making it available to GetPalette().

This function is not thread safe; any concurrent call to global Palette manipulation must be synchronized!

Definition at line 138 of file RPalette.cxx.

Member Data Documentation

◆ fColors

std::vector<OrdinalAndColor> ROOT::Experimental::RPalette::fColors
private

Palette colors: the color points and their ordinal value.

Definition at line 58 of file RPalette.hxx.

◆ fInterpolate

bool ROOT::Experimental::RPalette::fInterpolate = true
private

Whether to interpolate between the colors (in contrast to picking one of fColors).

Definition at line 61 of file RPalette.hxx.

◆ fNormalized

bool ROOT::Experimental::RPalette::fNormalized = true
private

Whether the palette's ordinal numbers are normalized.

Definition at line 64 of file RPalette.hxx.

◆ kDiscrete

constexpr const Discrete_t ROOT::Experimental::RPalette::kDiscrete {}
staticconstexpr

Tag value used to signal that the palette's colors should not be interpolated.

Can be passed to the constructor: RPalette palette(RPalette::kDiscrete, {{-100., RColor::kWhite}, {100., RColor::kRed}})

Definition at line 76 of file RPalette.hxx.

Libraries for ROOT::Experimental::RPalette:

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