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 "TMath.h"
18
19namespace ROOT {
20namespace Experimental {
21
23{
26
28
29public:
31
32private:
35
36protected:
37 Double_t fUIf; // UI representation calculated as: d = fUIf*i + fUIc
38 Double_t fUIc; // UI representation calculated as: d = fUIf*i + fUIc
39
40 Int_t fLowLimit; // Low limit for Min/Max values (used by editor)
41 Int_t fHighLimit; // High limit for Min/Max values (used by editor)
44
45 Bool_t fUIDoubleRep; // Represent UI parts with real values.
46 Bool_t fInterpolate; // Interpolate colors for signal values.
47 Bool_t fShowDefValue; // Flags whether signals with default value should be shown.
48 Bool_t fFixColorRange; // If true, map palette to low/high limit otherwise to min/max value.
51
52 Color_t fDefaultColor; // Color for when value is not specified
54 Color_t fUnderColor; // Underflow color
56 Color_t fOverColor; // Overflow color
58
59 mutable Int_t fNBins; // Number of signal-color entries.
60 mutable Int_t fCAMin; // Minimal signal in color-array.
61 mutable Int_t fCAMax; // Maximal signal in color-array.
62 mutable UChar_t* fColorArray; //[4*fNBins]
63
64 void SetupColor(Int_t val, UChar_t* pix) const;
65
66 Double_t IntToDouble(Int_t i) const { return fUIf*i + fUIc; }
67 Int_t DoubleToInt(Double_t d) const { return TMath::Nint((d - fUIc) / fUIf); }
68
71
73
74public:
76 REveRGBAPalette(Int_t min, Int_t max, Bool_t interp=kTRUE,
77 Bool_t showdef=kTRUE, Bool_t fixcolrng=kFALSE);
78 virtual ~REveRGBAPalette();
79
80 void SetupColorArray() const;
81 void ClearColorArray();
82
84 const UChar_t* ColorFromValue(Int_t val) const;
85 void ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha=kTRUE) const;
86 Bool_t ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha=kTRUE) const;
87
88 Int_t GetMinVal() const { return fMinVal; }
89 Int_t GetMaxVal() const { return fMaxVal; }
90
91 void SetLimits(Int_t low, Int_t high);
92 void SetLimitsScaleMinMax(Int_t low, Int_t high);
93 void SetMinMax(Int_t min, Int_t max);
94 void SetMin(Int_t min);
95 void SetMax(Int_t max);
96
97 Int_t GetLowLimit() const { return fLowLimit; }
98 Int_t GetHighLimit() const { return fHighLimit; }
99
100 // ================================================================
101
104
106 void SetInterpolate(Bool_t b);
107
110
113
118
119 // ================================================================
120
124 const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
125
126 void SetDefaultColor(Color_t ci);
129
130 // ----------------------------------------------------------------
131
135 const UChar_t* GetUnderRGBA() const { return fUnderRGBA; }
136
137 void SetUnderColor(Color_t ci);
138 void SetUnderColorPixel(Pixel_t pix);
140
141 // ----------------------------------------------------------------
142
143 Color_t GetOverColor() const { return fOverColor; }
146 const UChar_t* GetOverRGBA() const { return fOverRGBA; }
147
148 void SetOverColor(Color_t ci);
149 void SetOverColorPixel(Pixel_t pix);
151
152 void OnZeroRefCount() override { delete this; }
153
154};
155
156/******************************************************************************/
157// Inlines for REveRGBAPalette
158/******************************************************************************/
159
160//______________________________________________________________________________
162{
163 if ((val < fMinVal && fUnderflowAction == kLA_Cut) ||
164 (val > fMaxVal && fOverflowAction == kLA_Cut))
165 return kFALSE;
166 else
167 return kTRUE;
168}
169
170//______________________________________________________________________________
172{
173 // Here we expect that kLA_Cut has been checked; we further check
174 // for kLA_Wrap and kLA_Clip otherwise we proceed as for kLA_Mark.
175
177
178 if (val < fMinVal)
179 {
181 val = (val+1-fCAMin)%fNBins + fCAMax;
182 else if (fUnderflowAction == kLA_Clip)
183 val = fMinVal;
184 else
185 return fUnderRGBA;
186 }
187 else if(val > fMaxVal)
188 {
190 val = (val-1-fCAMax)%fNBins + fCAMin;
191 else if (fOverflowAction == kLA_Clip)
192 val = fMaxVal;
193 else
194 return fOverRGBA;
195 }
196
197 return fColorArray + 4 * (val - fCAMin);
198}
199
200//______________________________________________________________________________
201inline void REveRGBAPalette::ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha) const
202{
203 const UChar_t* c = ColorFromValue(val);
204 pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
205 if (alpha) pix[3] = c[3];
206}
207
208//______________________________________________________________________________
209inline Bool_t REveRGBAPalette::ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha) const
210{
211 if (val == defVal) {
212 if (fShowDefValue) {
213 pix[0] = fDefaultRGBA[0];
214 pix[1] = fDefaultRGBA[1];
215 pix[2] = fDefaultRGBA[2];
216 if (alpha) pix[3] = fDefaultRGBA[3];
217 return kTRUE;
218 } else {
219 return kFALSE;
220 }
221 }
222
223 if (WithinVisibleRange(val)) {
224 ColorFromValue(val, pix, alpha);
225 return kTRUE;
226 } else {
227 return kFALSE;
228 }
229}
230
231} // namespace Experimental
232} // namespace ROOT
233
234#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
unsigned char UChar_t
Definition RtypesCore.h:38
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
short Color_t
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:100
REveRGBAPalette & operator=(const REveRGBAPalette &)=delete
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
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.
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.
REveRGBAPalette(const REveRGBAPalette &)=delete
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
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:663