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