ColorScale.h
Go to the documentation of this file.
1 ///
2 /// \file ColorScale.h
3 /// \brief Build an association between a numerical range and a ROOT
4 /// color index
5 ///
6 /// \version $Id: ColorScale.h,v 1.5 2011-07-21 21:04:34 brebel Exp $
7 /// \author messier@indiana.edu
8 ///
9 #ifndef EVDB_COLORSCALE_H
10 #define EVDB_COLORSCALE_H
11 #include <string>
12 
13 namespace evdb {
14  /// \brief The list of default color options
16  kRainbow, /// ROY G. BIV (default)
17  kInvRainbow, /// Rainbow with high and low flipped
18  kLinGray, /// Linearized gray scale
19  kColdToHot, /// A color scale primarily in reds
20  kBlueToRed, /// Blue = cold, red = hot
21  kBlueToRedII, /// A color scale from dark blue (very cold) to red (hot) passing through yellow
22  kHeatedObject, /// A color scale from light to "burned"
23  kReds, /// A color scale primarily in reds
24  kGreens, /// A color scale primarily in greens
25  kBlues, /// A color scale primarily in blues
26  kGeographic, /// Light earth tones through green to blues
27  kBlueToGreen, /// Blue to green transition
28  kBlueToOrange, /// Blue to orange transition
29  kGreenToMagenta,/// Green to magenta transition
30  kSequential, /// Useful for sequential data
31  kFocus, /// Sequential data with focus in center of scale
32  kCustom /// User specfied
33  };
34 
35  /// \brief How to scale between low and high ranges
37  kLinear, /// Linearly (default)
38  kLog, /// According to log(x)
39  kSqrt /// According to sqrt(x)
40  };
41 
42  /// \brief Build an association between a numerical range and a ROOT
43  /// color index for use in, eg., the event display
44  class ColorScale {
45  public:
46  ColorScale(double xlo, double xhi,
47  int which=kRainbow,
48  int scale=kLinear,
49  int n=40,
50  double h1=0, double h2=0,
51  double v1=0, double v2=0);
52 
53  int operator()(double x) const;
54  int GetColor(double x) const;
55  bool InBounds(double x) const;
56  void SetPalette();
57  void SetBounds(double xlo, double xhi) { fXlo = xlo; fXhi = xhi; }
58  void SetUnderFlowColor(int c);
59  void SetOverFlowColor(int c);
60  void Reverse();
61 
62  static int Palette(const std::string& nm);
63  static int Scale(const std::string& nm);
64 
65  private:
66  void HSVtoRGB(double h, double s, double v,
67  double* r, double* g, double* b) const;
68 
69  void MakeHSVScale(int n, double h1, double h2, double vs1, double vs2);
70  void MakeSequential();
71  void MakeFocus();
72  void MakeInvRainbow();
73  void MakeRainbow();
74  void MakeGreenToMagenta();
75  void MakeBlueToRed();
76  void MakeBlueToRedII();
77  void MakeBlueToGreen();
78  void MakeBlueToOrange();
79  void MakeBrownToBlue();
80  void MakeLinGray();
81  void MakeHeatedObject();
82 
83  private:
84  double fXlo; /// Numeric value at low end of scale
85  double fXhi; /// Numeric value at high end of scale
86  int fScale; /// Linear? Log? Sqrt?
87  int fNcolor; /// How many colors in scale?
88  int fColors[256]; /// List of ROOT color indicies
89  int fUnderFlowColor; /// Color to use for under flows
90  int fOverFlowColor; /// Color to use for over flows
91  };
92 }
93 #endif
94 ////////////////////////////////////////////////////////////////////////
Blue to orange transition.
Definition: ColorScale.h:29
void MakeBlueToGreen()
Definition: ColorScale.cxx:925
According to log(x)
Definition: ColorScale.h:39
Useful for sequential data.
Definition: ColorScale.h:31
Sequential data with focus in center of scale.
Definition: ColorScale.h:32
Blue to green transition.
Definition: ColorScale.h:28
void SetOverFlowColor(int c)
Definition: ColorScale.cxx:99
ROY G. BIV (default)
Definition: ColorScale.h:17
static constexpr Double_t nm
Definition: Munits.h:133
void MakeBlueToOrange()
Definition: ColorScale.cxx:952
bool InBounds(double x) const
Definition: ColorScale.cxx:113
int GetColor(double x) const
Definition: ColorScale.cxx:126
Manage all things related to colors for the event display.
Definition: Display3DPad.h:11
int fColors[256]
How many colors in scale?
Definition: ColorScale.h:88
Linearly (default)
Definition: ColorScale.h:38
double fXhi
Numeric value at low end of scale.
Definition: ColorScale.h:85
const XML_Char * s
Definition: expat.h:262
Double_t scale
Definition: plot.C:25
void SetBounds(double xlo, double xhi)
Definition: ColorScale.h:57
Build an association between a numerical range and a ROOT color index for use in, eg...
Definition: ColorScale.h:44
A color scale primarily in greens.
Definition: ColorScale.h:25
void MakeHSVScale(int n, double h1, double h2, double vs1, double vs2)
Make a color scale of n colors ranging between two points in an HSV color space.
Definition: ColorScale.cxx:204
A color scale primarily in reds.
Definition: ColorScale.h:20
static int Palette(const std::string &nm)
Definition: ColorScale.cxx:17
static int Scale(const std::string &nm)
Definition: ColorScale.cxx:32
int fNcolor
Linear? Log? Sqrt?
Definition: ColorScale.h:87
A color scale primarily in blues.
Definition: ColorScale.h:26
Blue = cold, red = hot.
Definition: ColorScale.h:21
TH1F * h2
Definition: plot.C:45
Rainbow with high and low flipped.
Definition: ColorScale.h:18
TH1F * h1
void HSVtoRGB(double h, double s, double v, double *r, double *g, double *b) const
Definition: ColorScale.cxx:163
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Green to magenta transition.
Definition: ColorScale.h:30
ColorScale(double xlo, double xhi, int which=kRainbow, int scale=kLinear, int n=40, double h1=0, double h2=0, double v1=0, double v2=0)
Definition: ColorScale.cxx:57
_scale_options
How to scale between low and high ranges.
Definition: ColorScale.h:36
void MakeGreenToMagenta()
Definition: ColorScale.cxx:848
const hit & b
Definition: hits.cxx:21
void MakeBlueToRedII()
Definition: ColorScale.cxx:908
A color scale from dark blue (very cold) to red (hot) passing through yellow.
Definition: ColorScale.h:22
Light earth tones through green to blues.
Definition: ColorScale.h:27
void SetUnderFlowColor(int c)
Definition: ColorScale.cxx:95
TRandom3 r(0)
int operator()(double x) const
Definition: ColorScale.cxx:148
void MakeBrownToBlue()
Definition: ColorScale.cxx:983
int fUnderFlowColor
List of ROOT color indicies.
Definition: ColorScale.h:89
int fScale
Numeric value at high end of scale.
Definition: ColorScale.h:86
int fOverFlowColor
Color to use for under flows.
Definition: ColorScale.h:90
Linearized gray scale.
Definition: ColorScale.h:19
A color scale primarily in reds.
Definition: ColorScale.h:24
_color_scales
The list of default color options.
Definition: ColorScale.h:15
A color scale from light to "burned".
Definition: ColorScale.h:23