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/REveElement.hxx"
16#include "ROOT/REveUtil.hxx"
17
18#include "TMath.h"
19
20namespace ROOT {
21namespace Experimental {
22
24 public REveAuntAsList,
25 public REveRefCnt
26{
29
31
32public:
34
35private:
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
77 void StampNieces();
78public:
80 REveRGBAPalette(Int_t min, Int_t max, Bool_t interp=kTRUE,
81 Bool_t showdef=kTRUE, Bool_t fixcolrng=kFALSE);
82 ~REveRGBAPalette() override;
83
84 void SetupColorArray() const;
85 void ClearColorArray();
86
88 const UChar_t* ColorFromValue(Int_t val) const;
89 void ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha=kTRUE) const;
90 Bool_t ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha=kTRUE) const;
91
92 Int_t GetMinVal() const { return fMinVal; }
93 Int_t GetMaxVal() const { return fMaxVal; }
94
95 void SetLimits(Int_t low, Int_t high);
96 void SetLimitsScaleMinMax(Int_t low, Int_t high);
97 void SetMinMax(Int_t min, Int_t max);
98 void SetMin(Int_t min);
99 void SetMax(Int_t max);
100
101 Int_t GetLowLimit() const { return fLowLimit; }
102 Int_t GetHighLimit() const { return fHighLimit; }
103
104 // ================================================================
105
108
110 void SetInterpolate(Bool_t b);
111
114
117
122
123 // ================================================================
124
128 const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
129
130 void SetDefaultColor(Color_t ci);
133
134 // ----------------------------------------------------------------
135
139 const UChar_t* GetUnderRGBA() const { return fUnderRGBA; }
140
141 void SetUnderColor(Color_t ci);
144
145 // ----------------------------------------------------------------
146
147 Color_t GetOverColor() const { return fOverColor; }
150 const UChar_t* GetOverRGBA() const { return fOverRGBA; }
151
152 void SetOverColor(Color_t ci);
155
156 void OnZeroRefCount() override { delete this; }
157 Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
158};
159
160/******************************************************************************/
161// Inlines for REveRGBAPalette
162/******************************************************************************/
163
164//______________________________________________________________________________
166{
167 if ((val < fMinVal && fUnderflowAction == kLA_Cut) ||
168 (val > fMaxVal && fOverflowAction == kLA_Cut))
169 return kFALSE;
170 else
171 return kTRUE;
172}
173
174//______________________________________________________________________________
176{
177 // Here we expect that kLA_Cut has been checked; we further check
178 // for kLA_Wrap and kLA_Clip otherwise we proceed as for kLA_Mark.
179
181
182 if (val < fMinVal)
183 {
185 val = (val+1-fCAMin)%fNBins + fCAMax;
186 else if (fUnderflowAction == kLA_Clip)
187 val = fMinVal;
188 else
189 return fUnderRGBA;
190 }
191 else if(val > fMaxVal)
192 {
194 val = (val-1-fCAMax)%fNBins + fCAMin;
195 else if (fOverflowAction == kLA_Clip)
196 val = fMaxVal;
197 else
198 return fOverRGBA;
199 }
200
201 return fColorArray + 4 * (val - fCAMin);
202}
203
204//______________________________________________________________________________
206{
207 const UChar_t* c = ColorFromValue(val);
208 pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
209 if (alpha) pix[3] = c[3];
210}
211
212//______________________________________________________________________________
214{
215 if (val == defVal) {
216 if (fShowDefValue) {
217 pix[0] = fDefaultRGBA[0];
218 pix[1] = fDefaultRGBA[1];
219 pix[2] = fDefaultRGBA[2];
220 if (alpha) pix[3] = fDefaultRGBA[3];
221 return kTRUE;
222 } else {
223 return kFALSE;
224 }
225 }
226
227 if (WithinVisibleRange(val)) {
228 ColorFromValue(val, pix, alpha);
229 return kTRUE;
230 } else {
231 return kFALSE;
232 }
233}
234
235} // namespace Experimental
236} // namespace ROOT
237
238#endif
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#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
bool Bool_t
Definition RtypesCore.h:63
short Color_t
Definition RtypesCore.h:85
unsigned char UChar_t
Definition RtypesCore.h:38
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
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 - ...
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Write core json.
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:693