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
22class TEveRGBAPalette : public TObject,
23 public TQObject,
24 public TEveRefCnt
25{
28
30
31public:
33
34private:
35 TEveRGBAPalette(const TEveRGBAPalette&); // Not implemented
36 TEveRGBAPalette& operator=(const TEveRGBAPalette&); // Not implemented
37
38protected:
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
76public:
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
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
106
108 void SetInterpolate(Bool_t b);
109
112
115
120
121 // ================================================================
122
126 const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
127
128 void SetDefaultColor(Color_t ci);
131
132 // ----------------------------------------------------------------
133
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 {
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 {
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//______________________________________________________________________________
207inline 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//______________________________________________________________________________
215inline 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
ULong_t Pixel_t
Definition: GuiTypes.h:39
ROOT::R::TRInterface & r
Definition: Object.C:4
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define c(i)
Definition: RSha256.hxx:101
#define g(i)
Definition: RSha256.hxx:105
int Int_t
Definition: RtypesCore.h:41
unsigned char UChar_t
Definition: RtypesCore.h:34
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
Editor for TEveRGBAPalette class.
Description of TEveRGBAPaletteOverlay.
Sub-editor for TEveRGBAPalette class.
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Bool_t GetShowDefValue() const
Int_t GetMinVal() const
Int_t GetHighLimit() const
void SetMax(Int_t max)
Set current max value.
TEveRGBAPalette(const TEveRGBAPalette &)
void SetOverColor(Color_t ci)
Set overflow color.
UChar_t fDefaultRGBA[4]
Bool_t GetFixColorRange() const
Color_t * PtrUnderColor()
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
UChar_t fOverRGBA[4]
Color_t GetUnderColor() const
void SetMin(Int_t min)
Set current min value.
virtual ~TEveRGBAPalette()
Destructor.
const UChar_t * GetOverRGBA() const
UChar_t * GetOverRGBA()
void SetupColorArray() const
Construct internal color array that maps signal value to RGBA color.
const UChar_t * GetUnderRGBA() const
Bool_t GetUIDoubleRep() const
static TEveRGBAPalette * fgDefaultPalette
Int_t GetMaxVal() const
void SetDefaultColor(Color_t ci)
Set default color.
Double_t GetCAMaxAsDouble() const
void SetInterpolate(Bool_t b)
Set interpolation flag.
TEveRGBAPalette & operator=(const TEveRGBAPalette &)
Color_t GetOverColor() const
Bool_t GetInterpolate() const
Int_t DoubleToInt(Double_t d) const
UChar_t * fColorArray
void SetDefaultColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set default color.
UChar_t * GetDefaultRGBA()
Color_t * PtrDefaultColor()
void SetShowDefValue(Bool_t v)
Color_t * PtrOverColor()
Double_t GetCAMinAsDouble() const
const UChar_t * ColorFromValue(Int_t val) const
Int_t GetUnderflowAction() const
Color_t GetDefaultColor() const
Bool_t WithinVisibleRange(Int_t val) const
UChar_t fUnderRGBA[4]
void SetLimitsScaleMinMax(Int_t low, Int_t high)
Set low/high limits and rescale current min/max values.
void SetDefaultColorPixel(Pixel_t pix)
Set default color.
Int_t GetOverflowAction() const
void ClearColorArray()
Clear internal color array.
Double_t IntToDouble(Int_t i) const
void SetUnderColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set underflow color.
const UChar_t * GetDefaultRGBA() const
void SetUnderflowAction(Int_t a)
void SetOverColorPixel(Pixel_t pix)
Set overflow color.
void SetFixColorRange(Bool_t v)
Set flag specifying how the palette is mapped to signal values: true - LowLimit -> HighLimit false - ...
void SetupColor(Int_t val, UChar_t *pix) const
Set RGBA color 'pixel' for signal-value 'val'.
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
void MinMaxValChanged()
Emit the "MinMaxValChanged()" signal.
void SetOverColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set overflow color.
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
void SetUnderColor(Color_t ci)
Set underflow color.
UChar_t * GetUnderRGBA()
Int_t GetLowLimit() const
TEveRGBAPalette()
Constructor.
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...
void SetOverflowAction(Int_t a)
Base-class for reference-counted objects.
Definition: TEveUtil.h:164
Mother of all ROOT objects.
Definition: TObject.h:37
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition: TMath.h:703
auto * a
Definition: textangle.C:12