Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 virtual void OnZeroRefCount() { delete this; }
156
157 // ================================================================
158
159 ClassDef(REveRGBAPalette, 0); // A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range truncation modes.
160};
161
162
163/******************************************************************************/
164// Inlines for REveRGBAPalette
165/******************************************************************************/
166
167//______________________________________________________________________________
169{
170 if ((val < fMinVal && fUnderflowAction == kLA_Cut) ||
171 (val > fMaxVal && fOverflowAction == kLA_Cut))
172 return kFALSE;
173 else
174 return kTRUE;
175}
176
177//______________________________________________________________________________
179{
180 // Here we expect that kLA_Cut has been checked; we further check
181 // for kLA_Wrap and kLA_Clip otherwise we proceed as for kLA_Mark.
182
184
185 if (val < fMinVal)
186 {
188 val = (val+1-fCAMin)%fNBins + fCAMax;
189 else if (fUnderflowAction == kLA_Clip)
190 val = fMinVal;
191 else
192 return fUnderRGBA;
193 }
194 else if(val > fMaxVal)
195 {
197 val = (val-1-fCAMax)%fNBins + fCAMin;
198 else if (fOverflowAction == kLA_Clip)
199 val = fMaxVal;
200 else
201 return fOverRGBA;
202 }
203
204 return fColorArray + 4 * (val - fCAMin);
205}
206
207//______________________________________________________________________________
208inline void REveRGBAPalette::ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha) const
209{
210 const UChar_t* c = ColorFromValue(val);
211 pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
212 if (alpha) pix[3] = c[3];
213}
214
215//______________________________________________________________________________
216inline Bool_t REveRGBAPalette::ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha) const
217{
218 if (val == defVal) {
219 if (fShowDefValue) {
220 pix[0] = fDefaultRGBA[0];
221 pix[1] = fDefaultRGBA[1];
222 pix[2] = fDefaultRGBA[2];
223 if (alpha) pix[3] = fDefaultRGBA[3];
224 return kTRUE;
225 } else {
226 return kFALSE;
227 }
228 }
229
230 if (WithinVisibleRange(val)) {
231 ColorFromValue(val, pix, alpha);
232 return kTRUE;
233 } else {
234 return kFALSE;
235 }
236}
237
238} // namespace Experimental
239} // namespace ROOT
240
241#endif
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
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
#define a(i)
Definition RSha256.hxx:99
int Int_t
Definition RtypesCore.h:45
unsigned char UChar_t
Definition RtypesCore.h:38
const Bool_t kFALSE
Definition RtypesCore.h:92
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
short Color_t
Definition RtypesCore.h:83
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
REveRGBAPalette(const REveRGBAPalette &)
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.
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.
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:107
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...
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:713