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
21namespace ROOT {
22namespace Experimental {
23
24class REveRGBAPalette : public TObject,
25 public REveRefCnt
26{
29
31
32public:
34
35private:
36 REveRGBAPalette(const REveRGBAPalette&); // Not implemented
37 REveRGBAPalette& operator=(const REveRGBAPalette&); // Not implemented
38
39protected:
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
77public:
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
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
107
109 void SetInterpolate(Bool_t b);
110
113
116
121
122 // ================================================================
123
127 const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
128
129 void SetDefaultColor(Color_t ci);
132
133 // ----------------------------------------------------------------
134
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 {
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 {
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//______________________________________________________________________________
206inline 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//______________________________________________________________________________
214inline 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
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:43
unsigned char UChar_t
Definition: RtypesCore.h:36
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
short Color_t
Definition: RtypesCore.h:81
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassDef(name, id)
Definition: Rtypes.h:322
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
REveRGBAPalette(const REveRGBAPalette &)
const UChar_t * GetDefaultRGBA() const
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...
const UChar_t * ColorFromValue(Int_t val) const
void SetupColorArray() const
Construct internal color array that maps signal value to RGBA color.
static REveRGBAPalette * fgDefaultPalette
void SetMin(Int_t min)
Set current min value.
REveRGBAPalette & operator=(const REveRGBAPalette &)
void ClearColorArray()
Clear internal color array.
void SetDefaultColorPixel(Pixel_t pix)
Set default color.
void SetUnderColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set underflow color.
void SetDefaultColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set default color.
void SetLimitsScaleMinMax(Int_t low, Int_t high)
Set low/high limits and rescale current min/max values.
void SetMax(Int_t max)
Set current max value.
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
Bool_t WithinVisibleRange(Int_t val) const
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
void SetInterpolate(Bool_t b)
Set interpolation flag.
Double_t IntToDouble(Int_t i) const
Int_t DoubleToInt(Double_t d) const
void SetOverColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set overflow color.
void SetFixColorRange(Bool_t v)
Set flag specifying how the palette is mapped to signal values: true - LowLimit -> HighLimit false - ...
void SetUnderColor(Color_t ci)
Set underflow color.
void SetDefaultColor(Color_t ci)
Set default color.
const UChar_t * GetUnderRGBA() const
void SetupColor(Int_t val, UChar_t *pix) const
Set RGBA color 'pixel' for signal-value 'val'.
void SetOverColor(Color_t ci)
Set overflow color.
void SetOverColorPixel(Pixel_t pix)
Set overflow color.
REveRefCnt REveRefCnt base-class (interface)
Definition: REveUtil.hxx:103
Mother of all ROOT objects.
Definition: TObject.h:37
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
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