LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb::Colors Class Reference

#include "Colors.h"

Inheritance diagram for evdb::Colors:
evdb::Reconfigurable

Public Member Functions

 Colors (fhicl::ParameterSet const &p)
 
 ~Colors ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
void WhiteOnBlack ()
 
void BlackOnWhite ()
 
int Foreground (int i=0)
 
int Background (int i=0)
 
ColorScaleScale (const std::string &nm)
 
void do_reconfigure (fhicl::ParameterSet const &pset)
 

Private Member Functions

void UnpackColorScale (fhicl::ParameterSet const &p, const std::string &c)
 
void SetStyle ()
 

Private Attributes

int fFG [kMAX_FGBG]
 Foreground colors. More...
 
int fBG [kMAX_FGBG]
 
std::map< std::string, ColorScale * > fColorScales
 

Static Private Attributes

static const int kMAX_FGBG = 6
 

Detailed Description

Definition at line 21 of file Colors.h.

Constructor & Destructor Documentation

evdb::Colors::Colors ( fhicl::ParameterSet const &  p)

Definition at line 14 of file Colors.cc.

References reconfigure().

14  : Reconfigurable{p}
15  {
16  this->reconfigure(p);
17  }
Reconfigurable(fhicl::ParameterSet const &ps)
void reconfigure(fhicl::ParameterSet const &p)
Definition: Colors.cc:32
evdb::Colors::~Colors ( )

Definition at line 21 of file Colors.cc.

References fColorScales.

22  {
25  for (; itr!=itrEnd; ++itr) {
26  if (itr->second) { delete itr->second; itr->second = 0; }
27  }
28  }
intermediate_table::iterator iterator
std::map< std::string, ColorScale * > fColorScales
Definition: Colors.h:77

Member Function Documentation

int evdb::Colors::Background ( int  i = 0)

Return the background color

Parameters
i: 0 is highest contrast to foreground color, 5 is least

Definition at line 136 of file Colors.cc.

References fBG, and kMAX_FGBG.

Referenced by SetStyle().

137  {
138  i = std::max(0, i);
139  i = std::min(kMAX_FGBG-1,i);
140  return fBG[i];
141  }
int fBG[kMAX_FGBG]
Definition: Colors.h:73
static const int kMAX_FGBG
Definition: Colors.h:71
void evdb::Colors::BlackOnWhite ( )

Set foreground and background colors for black text on black background

Definition at line 114 of file Colors.cc.

References fBG, fFG, and SetStyle().

Referenced by reconfigure().

115  {
116  fFG[5] = fBG[0] = kWhite;
117  fFG[4] = fBG[1] = kGray;
118  fFG[3] = fBG[2] = kGray+1;
119  fFG[2] = fBG[3] = kGray+2;
120  fFG[1] = fBG[4] = kGray+3;
121  fFG[0] = fBG[5] = kBlack;
122  this->SetStyle();
123  }
int fFG[kMAX_FGBG]
Foreground colors.
Definition: Colors.h:72
int fBG[kMAX_FGBG]
Definition: Colors.h:73
void SetStyle()
Definition: Colors.cc:145
void evdb::Reconfigurable::do_reconfigure ( fhicl::ParameterSet const &  pset)
inlineinherited

Definition at line 16 of file Reconfigurable.h.

References evdb::Reconfigurable::reconfigure(), and evdb::Reconfigurable::~Reconfigurable().

16 { reconfigure(pset); }
virtual void reconfigure(fhicl::ParameterSet const &)=0
int evdb::Colors::Foreground ( int  i = 0)

Return the foreground color

Parameters
i: 0 is highest contrast to background color, 5 is least

Definition at line 127 of file Colors.cc.

References fFG, and kMAX_FGBG.

Referenced by SetStyle().

128  {
129  i = std::max(0, i);
130  i = std::min(kMAX_FGBG-1,i);
131  return fFG[i];
132  }
int fFG[kMAX_FGBG]
Foreground colors.
Definition: Colors.h:72
static const int kMAX_FGBG
Definition: Colors.h:71
void evdb::Colors::reconfigure ( fhicl::ParameterSet const &  p)
virtual

Implements evdb::Reconfigurable.

Definition at line 32 of file Colors.cc.

References BlackOnWhite(), fhicl::ParameterSet::get(), UnpackColorScale(), and WhiteOnBlack().

Referenced by Colors().

33  {
34  int black_on_white = p.get<int>("BlackOnWhite.val");
35  if (black_on_white) this->BlackOnWhite();
36  else this->WhiteOnBlack();
37 
38  std::vector<std::string>
39  cs = p.get<std::vector<std::string> >("ColorScales.val");
40  for (unsigned int i=0; i<cs.size(); ++i) {
41  this->UnpackColorScale(p,cs[i]);
42  }
43  }
void BlackOnWhite()
Definition: Colors.cc:114
void UnpackColorScale(fhicl::ParameterSet const &p, const std::string &c)
Definition: Colors.cc:47
void WhiteOnBlack()
Definition: Colors.cc:101
ColorScale & evdb::Colors::Scale ( const std::string &  nm)

Look up a color scale by name

Definition at line 90 of file Colors.cc.

References fColorScales.

91  {
92  ColorScale* cs = fColorScales[nm];
93  if (cs) return (*cs);
94 
95  static ColorScale gsDefaultCS(0,100);
96  return gsDefaultCS;
97  }
std::map< std::string, ColorScale * > fColorScales
Definition: Colors.h:77
void evdb::Colors::SetStyle ( )
private

Push the colors off to the ROOT style

Definition at line 145 of file Colors.cc.

References Background(), and Foreground().

Referenced by BlackOnWhite(), and WhiteOnBlack().

146  {
147  int bgcolor = this->Background(0);
148  int fgcolor = this->Foreground(1);
149  gStyle->SetAxisColor(fgcolor,"XYZ");
150  gStyle->SetLabelColor(fgcolor,"XYZ");
151  gStyle->SetTitleColor(fgcolor,"XYZ");
152  gStyle->SetCanvasColor(bgcolor);
153  gStyle->SetLegendFillColor(bgcolor);
154  gStyle->SetPadColor(bgcolor);
155  gStyle->SetFuncColor(kRed);
156  gStyle->SetGridColor(fgcolor);
157  gStyle->SetFrameFillColor(bgcolor);
158  gStyle->SetFrameLineColor(bgcolor);
159  // Leave histogram fill color clear
160  // gStyle->SetHistFillColor(bgcolor);
161  gStyle->SetHistLineColor(fgcolor);
162  gStyle->SetStatColor(bgcolor);
163  gStyle->SetStatTextColor(fgcolor);
164  gStyle->SetTitleFillColor(bgcolor);
165  gStyle->SetTitleTextColor(fgcolor);
166 
167  // Force this style on all histograms
168  gROOT->ForceStyle();
169  }
int Background(int i=0)
Definition: Colors.cc:136
int Foreground(int i=0)
Definition: Colors.cc:127
void evdb::Colors::UnpackColorScale ( fhicl::ParameterSet const &  p,
const std::string &  c 
)
private

Unpack the parameters for a named color scale

Definition at line 47 of file Colors.cc.

References fColorScales, fhicl::ParameterSet::get(), n, evdb::ColorScale::Palette(), r, scale, and evdb::ColorScale::Scale().

Referenced by reconfigure().

49  {
50  std::string palette_tag(nm); palette_tag += "_Palette.val";
51  std::string n_tag(nm); n_tag += "_N.val";
52  std::string r_tag(nm); r_tag += "_Range.val";
53  std::string scale_tag(nm); scale_tag += "_Scale.val";
54  std::string reverse_tag(nm); reverse_tag += "_Reverse.val";
55  std::string ofufc_tag(nm); ofufc_tag += "_UnderOverflowColors.val";
56  std::string hv_tag(nm); hv_tag += "_HVPairs.val";
57 
58  int n, reverse;
59  std::string palette, scale;
60  std::vector<float> r, hv;
61  std::vector<int> ofufc;
62  palette = p.get<std::string> (palette_tag);
63  n = p.get<int> (n_tag);
64  r = p.get<std::vector<float> >(r_tag);
65  scale = p.get<std::string> (scale_tag);
66  reverse = p.get<int> (reverse_tag);
67  ofufc = p.get<std::vector<int> > (ofufc_tag);
68  hv = p.get<std::vector<float> >(hv_tag);
69 
70  ColorScale* cs = new ColorScale(r[0],
71  r[1],
72  ColorScale::Palette(palette),
73  ColorScale::Scale(scale),
74  n,
75  hv[0],
76  hv[1],
77  hv[2],
78  hv[3]);
79  cs->SetUnderFlowColor(ofufc[0]);
80  cs->SetOverFlowColor(ofufc[1]);
81  if (reverse) cs->Reverse();
82  ColorScale* old = fColorScales[nm];
83  if (old) delete old;
84  fColorScales[nm] = cs;
85  }
TRandom r
Definition: spectrum.C:23
std::map< std::string, ColorScale * > fColorScales
Definition: Colors.h:77
Double_t scale
Definition: plot.C:24
static int Palette(const std::string &nm)
Definition: ColorScale.cxx:17
static int Scale(const std::string &nm)
Definition: ColorScale.cxx:32
Char_t n[5]
void evdb::Colors::WhiteOnBlack ( )

Set foreground and background colors for white text on black background

Definition at line 101 of file Colors.cc.

References fBG, fFG, and SetStyle().

Referenced by reconfigure().

102  {
103  fFG[0] = fBG[5] = kWhite;
104  fFG[1] = fBG[4] = kGray;
105  fFG[2] = fBG[3] = kGray+1;
106  fFG[3] = fBG[2] = kGray+2;
107  fFG[4] = fBG[1] = kGray+3;
108  fFG[5] = fBG[0] = kBlack;
109  this->SetStyle();
110  }
int fFG[kMAX_FGBG]
Foreground colors.
Definition: Colors.h:72
int fBG[kMAX_FGBG]
Definition: Colors.h:73
void SetStyle()
Definition: Colors.cc:145

Member Data Documentation

int evdb::Colors::fBG[kMAX_FGBG]
private

Background colors

Definition at line 73 of file Colors.h.

Referenced by Background(), BlackOnWhite(), and WhiteOnBlack().

std::map<std::string,ColorScale*> evdb::Colors::fColorScales
private

Collection of color scales managed by this class

Definition at line 77 of file Colors.h.

Referenced by Scale(), UnpackColorScale(), and ~Colors().

int evdb::Colors::fFG[kMAX_FGBG]
private

Foreground colors.

Definition at line 72 of file Colors.h.

Referenced by BlackOnWhite(), Foreground(), and WhiteOnBlack().

const int evdb::Colors::kMAX_FGBG = 6
staticprivate

Definition at line 71 of file Colors.h.

Referenced by Background(), and Foreground().


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