ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Palette Class Reference

Loads colors from a text configuration file. More...

#include <palette.hpp>

Public Member Functions

 Palette (const std::string &file, const std::string &palette)
 Construct from file and palette names. More...
 
 Palette (const std::string &palette="default")
 Construct from palette name. More...
 
 Palette (const Palette &)=default
 
Paletteoperator= (const Palette &)=default
 
 Palette (Palette &&)=default
 
Paletteoperator= (Palette &&)=default
 
 ~Palette ()=default
 
const std::string & File () const
 Get the file from which colors are read. More...
 
PaletteFile (const std::string &file)
 Set the file from which colors are read. More...
 
const std::string & PaletteName () const
 Get the name of the palette from which colors are read. More...
 
PalettePaletteName (const std::string &palette)
 Set the name of the palette from which colors are read. More...
 
PalettePaletteName (const std::string &file, const std::string &palette)
 Set the file and name of the palette from which colors are read. More...
 
Int_t operator() (const std::string &color_name) const
 Gets the ROOT color number corresponding to a color in the configuration file. More...
 

Static Public Member Functions

static Int_t RGB (Int_t r, Int_t g, Int_t b)
 Gets the ROOT color number corresponding to a given RGB color. More...
 
static Int_t RGB (Float_t r, Float_t g, Float_t b)
 Gets the ROOT color number corresponding to a given RGB color. More...
 
static Int_t HSV (Float_t h, Float_t s, Float_t v)
 Gets the ROOT color number corresponding to a given HSV color. More...
 
static Int_t HLS (Int_t h, Int_t l, Int_t s)
 Gets the ROOT color number corresponding to a given HLS/HSL color. More...
 
static Int_t HLS (Float_t h, Float_t l, Float_t s)
 Gets the ROOT color number corresponding to a given HLS/HSL color. More...
 

Private Attributes

std::string file_
 File from which to read color definitions. More...
 
std::string palette_
 Palette name from which to read color definitions. More...
 

Detailed Description

Loads colors from a text configuration file.

The text files may have multiple palettes defined, with the start of each palette marker by a line containing "[palette_name]" and ended by the start of the next palette or the end of the file. Within each palette, colors are defined on separate lines using their RGB values as "color_name red green blue".

Definition at line 8 of file palette.hpp.

Constructor & Destructor Documentation

Palette::Palette ( const std::string &  file,
const std::string &  palette 
)

Construct from file and palette names.

Parameters
[in]fileFile from which to read colors
[in]palettePalette name from which to read colors

Definition at line 28 of file palette.cpp.

Palette::Palette ( const std::string &  palette = "default")
explicit

Construct from palette name.

Colors are read from the file "txt/colors.txt"

Parameters
[in]palettePalette name from which to read colors

Definition at line 40 of file palette.cpp.

Palette::Palette ( const Palette )
default
Palette::Palette ( Palette &&  )
default
Palette::~Palette ( )
default

Member Function Documentation

const string & Palette::File ( ) const

Get the file from which colors are read.

Returns
File from which colors are read

Definition at line 48 of file palette.cpp.

References file_.

Palette & Palette::File ( const std::string &  file)

Set the file from which colors are read.

Parameters
[in]fileFile from which colors are read
Returns
Reference to *this

Definition at line 58 of file palette.cpp.

References file_.

Int_t Palette::HLS ( Int_t  h,
Int_t  l,
Int_t  s 
)
static

Gets the ROOT color number corresponding to a given HLS/HSL color.

Parameters
[in]hHue in range [0, 255]
[in]lSaturation in range [0, 255].
[in]sValue or brightness in range [0, 255]
Returns
Number of color as used by ROOT's TColor system

Definition at line 193 of file palette.cpp.

References RGB().

Int_t Palette::HLS ( Float_t  h,
Float_t  l,
Float_t  s 
)
static

Gets the ROOT color number corresponding to a given HLS/HSL color.

Parameters
[in]hHue in range [0., 360.]
[in]lSaturation in range [0., 1.].
[in]sValue or brightness in range [0., 1.]
Returns
Number of color as used by ROOT's TColor system

Definition at line 209 of file palette.cpp.

References RGB().

Int_t Palette::HSV ( Float_t  h,
Float_t  s,
Float_t  v 
)
static

Gets the ROOT color number corresponding to a given HSV color.

Parameters
[in]hHue in range [0., 360.]
[in]sSaturation in range [0., 1.].
[in]vValue or brightness in range [0., 1.]
Returns
Number of color as used by ROOT's TColor system

Definition at line 177 of file palette.cpp.

References RGB().

Int_t Palette::operator() ( const std::string &  color_name) const

Gets the ROOT color number corresponding to a color in the configuration file.

Parameters
[in]color_nameName of color in current palette for which to obtain color number
Returns
Number of color as used by ROOT's TColor system

Definition at line 104 of file palette.cpp.

References DBG, ERROR, file_, palette_, ReplaceAll(), and RGB().

Palette& Palette::operator= ( const Palette )
default
Palette& Palette::operator= ( Palette &&  )
default
const string & Palette::PaletteName ( ) const

Get the name of the palette from which colors are read.

Returns
Name of the palette from which colors are read

Definition at line 67 of file palette.cpp.

References palette_.

Referenced by PaletteName().

Palette & Palette::PaletteName ( const std::string &  palette)

Set the name of the palette from which colors are read.

Parameters
[in]paletteName of the palette from which colors are read
Returns
Reference to *this

Definition at line 77 of file palette.cpp.

References file_, and PaletteName().

Palette & Palette::PaletteName ( const std::string &  file,
const std::string &  palette 
)

Set the file and name of the palette from which colors are read.

Parameters
[in]fileFile from which colors are read
[in]paletteName of the palette from which colors are read
Returns
Reference to *this

Definition at line 89 of file palette.cpp.

References file_, and palette_.

Int_t Palette::RGB ( Int_t  r,
Int_t  g,
Int_t  b 
)
static

Gets the ROOT color number corresponding to a given RGB color.

Parameters
[in]rRed value in range [0, 255]
[in]gGreen value in range [0, 255]
[in]bBlue value in range [0, 255]
Returns
Number of color as used by ROOT's TColor system

Definition at line 149 of file palette.cpp.

Referenced by HLS(), HSV(), main(), and operator()().

Int_t Palette::RGB ( Float_t  r,
Float_t  g,
Float_t  b 
)
static

Gets the ROOT color number corresponding to a given RGB color.

Parameters
[in]rRed value in range [0., 1.]
[in]gGreen value in range [0., 1.]
[in]bBlue value in range [0., 1.]
Returns
Number of color as used by ROOT's TColor system

Definition at line 163 of file palette.cpp.

Member Data Documentation

std::string Palette::file_
private

File from which to read color definitions.

Definition at line 38 of file palette.hpp.

Referenced by File(), operator()(), and PaletteName().

std::string Palette::palette_
private

Palette name from which to read color definitions.

Definition at line 39 of file palette.hpp.

Referenced by operator()(), and PaletteName().


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