Logo ROOT  
Reference Guide
REveRGBAPalette.hxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_REveRGBAPalette
13 #define ROOT_REveRGBAPalette
14 
15 #include "ROOT/REveUtil.hxx"
16 
17 #include "TObject.h"
18 
19 #include "TMath.h"
20 
21 namespace ROOT {
22 namespace Experimental {
23 
24 class REveRGBAPalette : public TObject,
25  public REveRefCnt
26 {
27  friend class REveRGBAPaletteEditor;
29 
30  friend class REveRGBAPaletteOverlay;
31 
32 public:
34 
35 private:
36  REveRGBAPalette(const REveRGBAPalette&); // Not implemented
37  REveRGBAPalette& operator=(const REveRGBAPalette&); // Not implemented
38 
39 protected:
40  Double_t fUIf; // UI representation calculated as: d = fUIf*i + fUIc
41  Double_t fUIc; // UI representation calculated as: d = fUIf*i + fUIc
42 
43  Int_t fLowLimit; // Low limit for Min/Max values (used by editor)
44  Int_t fHighLimit; // High limit for Min/Max values (used by editor)
47 
48  Bool_t fUIDoubleRep; // Represent UI parts with real values.
49  Bool_t fInterpolate; // Interpolate colors for signal values.
50  Bool_t fShowDefValue; // Flags whether signals with default value should be shown.
51  Bool_t fFixColorRange; // If true, map palette to low/high limit otherwise to min/max value.
54 
55  Color_t fDefaultColor; // Color for when value is not specified
57  Color_t fUnderColor; // Underflow color
59  Color_t fOverColor; // Overflow color
61 
62  mutable Int_t fNBins; // Number of signal-color entries.
63  mutable Int_t fCAMin; // Minimal signal in color-array.
64  mutable Int_t fCAMax; // Maximal signal in color-array.
65  mutable UChar_t* fColorArray; //[4*fNBins]
66 
67  void SetupColor(Int_t val, UChar_t* pix) const;
68 
69  Double_t IntToDouble(Int_t i) const { return fUIf*i + fUIc; }
70  Int_t DoubleToInt(Double_t d) const { return TMath::Nint((d - fUIc) / fUIf); }
71 
74 
76 
77 public:
79  REveRGBAPalette(Int_t min, Int_t max, Bool_t interp=kTRUE,
80  Bool_t showdef=kTRUE, Bool_t fixcolrng=kFALSE);
81  virtual ~REveRGBAPalette();
82 
83  void SetupColorArray() const;
84  void ClearColorArray();
85 
86  Bool_t WithinVisibleRange(Int_t val) const;
87  const UChar_t* ColorFromValue(Int_t val) const;
88  void ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha=kTRUE) const;
89  Bool_t ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha=kTRUE) const;
90 
91  Int_t GetMinVal() const { return fMinVal; }
92  Int_t GetMaxVal() const { return fMaxVal; }
93 
94  void SetLimits(Int_t low, Int_t high);
95  void SetLimitsScaleMinMax(Int_t low, Int_t high);
96  void SetMinMax(Int_t min, Int_t max);
97  void SetMin(Int_t min);
98  void SetMax(Int_t max);
99 
100  Int_t GetLowLimit() const { return fLowLimit; }
101  Int_t GetHighLimit() const { return fHighLimit; }
102 
103  // ================================================================
104 
105  Bool_t GetUIDoubleRep() const { return fUIDoubleRep; }
106  void SetUIDoubleRep(Bool_t b, Double_t f=1, Double_t c=0);
107 
108  Bool_t GetInterpolate() const { return fInterpolate; }
109  void SetInterpolate(Bool_t b);
110 
113 
115  void SetFixColorRange(Bool_t v);
116 
121 
122  // ================================================================
123 
127  const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
128 
129  void SetDefaultColor(Color_t ci);
130  void SetDefaultColorPixel(Pixel_t pix);
132 
133  // ----------------------------------------------------------------
134 
135  Color_t GetUnderColor() const { return fUnderColor; }
138  const UChar_t* GetUnderRGBA() const { return fUnderRGBA; }
139 
140  void SetUnderColor(Color_t ci);
141  void SetUnderColorPixel(Pixel_t pix);
143 
144  // ----------------------------------------------------------------
145 
146  Color_t GetOverColor() const { return fOverColor; }
149  const UChar_t* GetOverRGBA() const { return fOverRGBA; }
150 
151  void SetOverColor(Color_t ci);
152  void SetOverColorPixel(Pixel_t pix);
154 
155  // ================================================================
156 
157  ClassDef(REveRGBAPalette, 0); // A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range truncation modes.
158 };
159 
160 
161 /******************************************************************************/
162 // Inlines for REveRGBAPalette
163 /******************************************************************************/
164 
165 //______________________________________________________________________________
167 {
168  if ((val < fMinVal && fUnderflowAction == kLA_Cut) ||
169  (val > fMaxVal && fOverflowAction == kLA_Cut))
170  return kFALSE;
171  else
172  return kTRUE;
173 }
174 
175 //______________________________________________________________________________
177 {
178  // Here we expect that kLA_Cut has been checked; we further check
179  // for kLA_Wrap and kLA_Clip otherwise we proceed as for kLA_Mark.
180 
182 
183  if (val < fMinVal)
184  {
185  if (fUnderflowAction == kLA_Wrap)
186  val = (val+1-fCAMin)%fNBins + fCAMax;
187  else if (fUnderflowAction == kLA_Clip)
188  val = fMinVal;
189  else
190  return fUnderRGBA;
191  }
192  else if(val > fMaxVal)
193  {
194  if (fOverflowAction == kLA_Wrap)
195  val = (val-1-fCAMax)%fNBins + fCAMin;
196  else if (fOverflowAction == kLA_Clip)
197  val = fMaxVal;
198  else
199  return fOverRGBA;
200  }
201 
202  return fColorArray + 4 * (val - fCAMin);
203 }
204 
205 //______________________________________________________________________________
206 inline void REveRGBAPalette::ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha) const
207 {
208  const UChar_t* c = ColorFromValue(val);
209  pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
210  if (alpha) pix[3] = c[3];
211 }
212 
213 //______________________________________________________________________________
214 inline Bool_t REveRGBAPalette::ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha) const
215 {
216  if (val == defVal) {
217  if (fShowDefValue) {
218  pix[0] = fDefaultRGBA[0];
219  pix[1] = fDefaultRGBA[1];
220  pix[2] = fDefaultRGBA[2];
221  if (alpha) pix[3] = fDefaultRGBA[3];
222  return kTRUE;
223  } else {
224  return kFALSE;
225  }
226  }
227 
228  if (WithinVisibleRange(val)) {
229  ColorFromValue(val, pix, alpha);
230  return kTRUE;
231  } else {
232  return kFALSE;
233  }
234 }
235 
236 } // namespace Experimental
237 } // namespace ROOT
238 
239 #endif
c
#define c(i)
Definition: RSha256.hxx:101
ROOT::Experimental::REveRGBAPalette::SetFixColorRange
void SetFixColorRange(Bool_t v)
Set flag specifying how the palette is mapped to signal values: true - LowLimit -> HighLimit false - ...
Definition: REveRGBAPalette.cxx:255
ROOT::Experimental::REveRGBAPalette::fgDefaultPalette
static REveRGBAPalette * fgDefaultPalette
Definition: REveRGBAPalette.hxx:75
ROOT::Experimental::REveRGBAPalette::fHighLimit
Int_t fHighLimit
Definition: REveRGBAPalette.hxx:44
ROOT::Experimental::REveRGBAPalette::ClearColorArray
void ClearColorArray()
Clear internal color array.
Definition: REveRGBAPalette.cxx:155
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
ROOT::Experimental::REveRGBAPalette::GetDefaultRGBA
const UChar_t * GetDefaultRGBA() const
Definition: REveRGBAPalette.hxx:127
ROOT::Experimental::REveRGBAPalette::fCAMin
Int_t fCAMin
Definition: REveRGBAPalette.hxx:63
ROOT::Experimental::REveRGBAPalette::kLA_Clip
@ kLA_Clip
Definition: REveRGBAPalette.hxx:33
ROOT::Experimental::REveRGBAPalette::ColorFromValue
const UChar_t * ColorFromValue(Int_t val) const
Definition: REveRGBAPalette.hxx:176
f
#define f(i)
Definition: RSha256.hxx:104
ROOT::Experimental::REveRGBAPalette::SetMin
void SetMin(Int_t min)
Set current min value.
Definition: REveRGBAPalette.cxx:200
ROOT::Experimental::REveRGBAPalette::GetOverRGBA
const UChar_t * GetOverRGBA() const
Definition: REveRGBAPalette.hxx:149
ROOT::Experimental::REveRGBAPalette::SetUnderflowAction
void SetUnderflowAction(Int_t a)
Definition: REveRGBAPalette.hxx:119
ROOT::Experimental::REveRGBAPalette::fMaxVal
Int_t fMaxVal
Definition: REveRGBAPalette.hxx:46
ROOT::Experimental::REveRGBAPalette::fLowLimit
Int_t fLowLimit
Definition: REveRGBAPalette.hxx:43
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
ROOT::Experimental::REveRGBAPalette::DoubleToInt
Int_t DoubleToInt(Double_t d) const
Definition: REveRGBAPalette.hxx:70
ROOT::Experimental::REveRGBAPalette::GetUnderRGBA
const UChar_t * GetUnderRGBA() const
Definition: REveRGBAPalette.hxx:138
r
ROOT::R::TRInterface & r
Definition: Object.C:4
ROOT::Experimental::REveRGBAPalette::GetShowDefValue
Bool_t GetShowDefValue() const
Definition: REveRGBAPalette.hxx:111
ROOT::Experimental::REveRGBAPalette::fMinVal
Int_t fMinVal
Definition: REveRGBAPalette.hxx:45
ROOT::Experimental::REveRGBAPalette::kLA_Wrap
@ kLA_Wrap
Definition: REveRGBAPalette.hxx:33
ROOT::Experimental::REveRGBAPalette::kLA_Cut
@ kLA_Cut
Definition: REveRGBAPalette.hxx:33
ROOT::Experimental::REveRGBAPalette::fNBins
Int_t fNBins
Definition: REveRGBAPalette.hxx:62
ROOT::Experimental::REveRGBAPalette::fUIDoubleRep
Bool_t fUIDoubleRep
Definition: REveRGBAPalette.hxx:48
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::Experimental::REveRGBAPalette::fUIc
Double_t fUIc
Definition: REveRGBAPalette.hxx:41
ROOT::Experimental::REveRGBAPalette::WithinVisibleRange
Bool_t WithinVisibleRange(Int_t val) const
Definition: REveRGBAPalette.hxx:166
ROOT::Experimental::REveRGBAPalette::GetDefaultColor
Color_t GetDefaultColor() const
Definition: REveRGBAPalette.hxx:124
ROOT::Experimental::REveRGBAPalette::fFixColorRange
Bool_t fFixColorRange
Definition: REveRGBAPalette.hxx:51
ROOT::Experimental::REveRGBAPalette::GetMinVal
Int_t GetMinVal() const
Definition: REveRGBAPalette.hxx:91
ROOT::Experimental::REveRGBAPalette::fUnderRGBA
UChar_t fUnderRGBA[4]
Definition: REveRGBAPalette.hxx:58
ROOT::Experimental::REveRefCnt
REveRefCnt REveRefCnt base-class (interface)
Definition: REveUtil.hxx:103
ROOT::Experimental::REveRGBAPalette::GetOverColor
Color_t GetOverColor() const
Definition: REveRGBAPalette.hxx:146
ROOT::Experimental::REveRGBAPalette::fOverflowAction
Int_t fOverflowAction
Definition: REveRGBAPalette.hxx:53
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
ROOT::Experimental::REveRGBAPalette::SetupColorArray
void SetupColorArray() const
Construct internal color array that maps signal value to RGBA color.
Definition: REveRGBAPalette.cxx:134
Color_t
short Color_t
Definition: RtypesCore.h:83
ROOT::Experimental::REveRGBAPalette::SetUnderColor
void SetUnderColor(Color_t ci)
Set underflow color.
Definition: REveRGBAPalette.cxx:293
v
@ v
Definition: rootcling_impl.cxx:3635
b
#define b(i)
Definition: RSha256.hxx:100
bool
ROOT::Experimental::REveRGBAPalette::PtrOverColor
Color_t * PtrOverColor()
Definition: REveRGBAPalette.hxx:147
ROOT::Experimental::REveRGBAPalette::GetOverflowAction
Int_t GetOverflowAction() const
Definition: REveRGBAPalette.hxx:118
ROOT::Experimental::REveRGBAPalette::SetMinMax
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
Definition: REveRGBAPalette.cxx:218
ROOT::Experimental::REveRGBAPalette::SetShowDefValue
void SetShowDefValue(Bool_t v)
Definition: REveRGBAPalette.hxx:112
ROOT::Experimental::REveRGBAPalette::GetFixColorRange
Bool_t GetFixColorRange() const
Definition: REveRGBAPalette.hxx:114
ROOT::Experimental::REveRGBAPalette::GetHighLimit
Int_t GetHighLimit() const
Definition: REveRGBAPalette.hxx:101
ROOT::Experimental::REveRGBAPalette::PtrUnderColor
Color_t * PtrUnderColor()
Definition: REveRGBAPalette.hxx:136
ROOT::Experimental::REveRGBAPalette::fUnderColor
Color_t fUnderColor
Definition: REveRGBAPalette.hxx:57
ROOT::Experimental::REveRGBAPalette::SetDefaultColor
void SetDefaultColor(Color_t ci)
Set default color.
Definition: REveRGBAPalette.cxx:264
TMath::Nint
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition: TMath.h:713
ROOT::Experimental::REveRGBAPalette::GetCAMaxAsDouble
Double_t GetCAMaxAsDouble() const
Definition: REveRGBAPalette.hxx:73
ROOT::Experimental::REveRGBAPalette::SetDefaultColorRGBA
void SetDefaultColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set default color.
Definition: REveRGBAPalette.cxx:281
ROOT::Experimental::REveRGBAPalette::operator=
REveRGBAPalette & operator=(const REveRGBAPalette &)
ROOT::Experimental::REveRGBAPalette::REveRGBAPaletteOverlay
friend class REveRGBAPaletteOverlay
Definition: REveRGBAPalette.hxx:30
ROOT::Experimental::REveRGBAPalette::GetDefaultRGBA
UChar_t * GetDefaultRGBA()
Definition: REveRGBAPalette.hxx:126
ROOT::Experimental::REveRGBAPalette::PtrDefaultColor
Color_t * PtrDefaultColor()
Definition: REveRGBAPalette.hxx:125
a
auto * a
Definition: textangle.C:12
ROOT::Experimental::REveRGBAPalette::SetDefaultColorPixel
void SetDefaultColorPixel(Pixel_t pix)
Set default color.
Definition: REveRGBAPalette.cxx:273
ROOT::Experimental::REveRGBAPalette::fOverRGBA
UChar_t fOverRGBA[4]
Definition: REveRGBAPalette.hxx:60
ROOT::Experimental::REveRGBAPalette::fShowDefValue
Bool_t fShowDefValue
Definition: REveRGBAPalette.hxx:50
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
ROOT::Experimental::REveRGBAPalette::kLA_Mark
@ kLA_Mark
Definition: REveRGBAPalette.hxx:33
ROOT::Experimental::REveRGBAPalette::fColorArray
UChar_t * fColorArray
Definition: REveRGBAPalette.hxx:65
ROOT::Experimental::REveRGBAPalette::SetOverColorRGBA
void SetOverColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set overflow color.
Definition: REveRGBAPalette.cxx:339
ROOT::Experimental::REveRGBAPalette::SetUnderColorPixel
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
Definition: REveRGBAPalette.cxx:302
ROOT::Experimental::REveRGBAPalette::GetUIDoubleRep
Bool_t GetUIDoubleRep() const
Definition: REveRGBAPalette.hxx:105
ROOT::Experimental::REveRGBAPalette::GetUnderflowAction
Int_t GetUnderflowAction() const
Definition: REveRGBAPalette.hxx:117
ROOT::Experimental::REveRGBAPalette::REveRGBAPaletteSubEditor
friend class REveRGBAPaletteSubEditor
Definition: REveRGBAPalette.hxx:28
ROOT::Experimental::REveRGBAPalette::fInterpolate
Bool_t fInterpolate
Definition: REveRGBAPalette.hxx:49
ROOT::Experimental::REveRGBAPalette::GetMaxVal
Int_t GetMaxVal() const
Definition: REveRGBAPalette.hxx:92
ROOT::Experimental::REveRGBAPalette::SetOverColorPixel
void SetOverColorPixel(Pixel_t pix)
Set overflow color.
Definition: REveRGBAPalette.cxx:331
ROOT::Experimental::REveRGBAPalette::GetUnderColor
Color_t GetUnderColor() const
Definition: REveRGBAPalette.hxx:135
ROOT::Experimental::REveRGBAPalette::SetLimitsScaleMinMax
void SetLimitsScaleMinMax(Int_t low, Int_t high)
Set low/high limits and rescale current min/max values.
Definition: REveRGBAPalette.cxx:184
ROOT::Experimental::REveRGBAPalette
Definition: REveRGBAPalette.hxx:26
ROOT::Experimental::REveRGBAPalette::GetLowLimit
Int_t GetLowLimit() const
Definition: REveRGBAPalette.hxx:100
Double_t
double Double_t
Definition: RtypesCore.h:59
ROOT::Experimental::REveRGBAPalette::GetCAMinAsDouble
Double_t GetCAMinAsDouble() const
Definition: REveRGBAPalette.hxx:72
ROOT::Experimental::REveRGBAPalette::SetupColor
void SetupColor(Int_t val, UChar_t *pix) const
Set RGBA color 'pixel' for signal-value 'val'.
Definition: REveRGBAPalette.cxx:109
ROOT::Experimental::REveRGBAPalette::fOverColor
Color_t fOverColor
Definition: REveRGBAPalette.hxx:59
ROOT::Experimental::REveRGBAPalette::GetOverRGBA
UChar_t * GetOverRGBA()
Definition: REveRGBAPalette.hxx:148
ROOT::Experimental::REveRGBAPalette::GetInterpolate
Bool_t GetInterpolate() const
Definition: REveRGBAPalette.hxx:108
TObject.h
ROOT::Experimental::REveRGBAPalette::SetMax
void SetMax(Int_t max)
Set current max value.
Definition: REveRGBAPalette.cxx:209
REveUtil.hxx
ROOT::Experimental::REveRGBAPalette::SetOverColor
void SetOverColor(Color_t ci)
Set overflow color.
Definition: REveRGBAPalette.cxx:322
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
ROOT::Experimental::REveRGBAPalette::~REveRGBAPalette
virtual ~REveRGBAPalette()
Destructor.
Definition: REveRGBAPalette.cxx:101
ROOT::Experimental::REveRGBAPalette::fDefaultColor
Color_t fDefaultColor
Definition: REveRGBAPalette.hxx:55
ROOT::Experimental::REveRGBAPalette::SetLimits
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
Definition: REveRGBAPalette.cxx:168
d
#define d(i)
Definition: RSha256.hxx:102
ROOT::Experimental::REveRGBAPalette::REveRGBAPaletteEditor
friend class REveRGBAPaletteEditor
Definition: REveRGBAPalette.hxx:27
ROOT::Experimental::REveRGBAPalette::SetOverflowAction
void SetOverflowAction(Int_t a)
Definition: REveRGBAPalette.hxx:120
ROOT::Experimental::REveRGBAPalette::SetUIDoubleRep
void SetUIDoubleRep(Bool_t b, Double_t f=1, Double_t c=0)
Set flag determining whether GUI editor and overlays should show limits and axis values as real value...
Definition: REveRGBAPalette.cxx:230
ROOT::Experimental::REveRGBAPalette::ELimitAction_e
ELimitAction_e
Definition: REveRGBAPalette.hxx:33
ROOT::Experimental::REveRGBAPalette::fUIf
Double_t fUIf
Definition: REveRGBAPalette.hxx:40
ROOT::Experimental::REveRGBAPalette::REveRGBAPalette
REveRGBAPalette()
Constructor.
Definition: REveRGBAPalette.cxx:36
ROOT::Experimental::REveRGBAPalette::fDefaultRGBA
UChar_t fDefaultRGBA[4]
Definition: REveRGBAPalette.hxx:56
ROOT::Experimental::REveRGBAPalette::SetUnderColorRGBA
void SetUnderColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set underflow color.
Definition: REveRGBAPalette.cxx:310
ROOT::Experimental::REveRGBAPalette::REveRGBAPalette
REveRGBAPalette(const REveRGBAPalette &)
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveRGBAPalette::SetInterpolate
void SetInterpolate(Bool_t b)
Set interpolation flag.
Definition: REveRGBAPalette.cxx:244
ROOT::Experimental::REveRGBAPalette::IntToDouble
Double_t IntToDouble(Int_t i) const
Definition: REveRGBAPalette.hxx:69
ROOT::Experimental::REveRGBAPalette::GetUnderRGBA
UChar_t * GetUnderRGBA()
Definition: REveRGBAPalette.hxx:137
TMath.h
ROOT::Experimental::REveRGBAPalette::fCAMax
Int_t fCAMax
Definition: REveRGBAPalette.hxx:64
int
ROOT::Experimental::REveRGBAPalette::fUnderflowAction
Int_t fUnderflowAction
Definition: REveRGBAPalette.hxx:52
g
#define g(i)
Definition: RSha256.hxx:105