EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EtmPalette.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EtmPalette.h
1 
2 #include <map>
3 
4 #include <TObject.h>
5 #include <TString.h>
6 
7 #ifndef _ETM_PALETTE_
8 #define _ETM_PALETTE_
9 
10 #include <EtmOrphans.h>
11 
12 // NB: kWhite=0, so I seemingly need two distinct GetColor() return values:
13 // -1 (does not exist), and some odd number (gap);
14 #define _GAP_COLOR_ (-12345678)
15 
16 // "MARKER" tag is hardcoded;
17 #define _MARKER_ ("MARKER")
18 
19 class EtmPaletteEntry: public TObject {
20  public:
21  EtmPaletteEntry(int fillcolor = 0, int linecolor = 1):
22  mFillColor(fillcolor), mLineColor(linecolor), mTextColor(kBlack), mLineStyle(etm::solid) {};
24 
25  // Line color, fill color and line style is the same for all polygons;
28 
29  ClassDef(EtmPaletteEntry, 1)
30 };
31 
32 class EtmPalette: public TObject {
33  public:
34  EtmPalette();
36 
37  bool AddEntry(const char *tag, int color);
38 
39  int GetColor(const char *tag) const { return (Exists(tag) ? mColors.at(tag) : -1); };
40  const char *GetTag(int color) const { return (Exists(color) ? mTags.at(color).Data() : 0); };
41 
42  private:
43  bool Exists(const char *tag) const { return mColors.find(tag) != mColors.end(); };
44  bool Exists(int color) const { return mTags.find(color) != mTags.end(); };
45 
46  // There is no C++ STL container with unique key and value; create both;
47  std::map<TString, int> mColors;
48  std::map<int, TString> mTags;
49 
50  ClassDef(EtmPalette, 1)
51 };
52 
53 #endif