Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 ~TEveRGBAPalette() override;
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);
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);
153
154 void OnZeroRefCount() override { delete this; }
155
156 // ================================================================
157
158 void MinMaxValChanged(); // *SIGNAL*
159
160 ClassDefOverride(TEveRGBAPalette, 0); // A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range truncation modes.
161};
162
163
164/******************************************************************************/
165// Inlines for TEveRGBAPalette
166/******************************************************************************/
167
168//______________________________________________________________________________
170{
171 if ((val < fMinVal && fUnderflowAction == kLA_Cut) ||
172 (val > fMaxVal && fOverflowAction == kLA_Cut))
173 return kFALSE;
174 else
175 return kTRUE;
176}
177
178//______________________________________________________________________________
180{
181 // Here we expect that kLA_Cut has been checked; we further check
182 // for kLA_Wrap and kLA_Clip otherwise we proceed as for kLA_Mark.
183
185
186 if (val < fMinVal)
187 {
189 val = (val+1-fCAMin)%fNBins + fCAMax;
190 else if (fUnderflowAction == kLA_Clip)
191 val = fMinVal;
192 else
193 return fUnderRGBA;
194 }
195 else if(val > fMaxVal)
196 {
198 val = (val-1-fCAMax)%fNBins + fCAMin;
199 else if (fOverflowAction == kLA_Clip)
200 val = fMaxVal;
201 else
202 return fOverRGBA;
203 }
204
205 return fColorArray + 4 * (val - fCAMin);
206}
207
208//______________________________________________________________________________
210{
211 const UChar_t* c = ColorFromValue(val);
212 pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
213 if (alpha) pix[3] = c[3];
214}
215
216//______________________________________________________________________________
218{
219 if (val == defVal) {
220 if (fShowDefValue) {
221 pix[0] = fDefaultRGBA[0];
222 pix[1] = fDefaultRGBA[1];
223 pix[2] = fDefaultRGBA[2];
224 if (alpha) pix[3] = fDefaultRGBA[3];
225 return kTRUE;
226 } else {
227 return kFALSE;
228 }
229 }
230
231 if (WithinVisibleRange(val)) {
232 ColorFromValue(val, pix, alpha);
233 return kTRUE;
234 } else {
235 return kFALSE;
236 }
237}
238
239#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
int Int_t
Definition RtypesCore.h:45
short Color_t
Definition RtypesCore.h:85
unsigned char UChar_t
Definition RtypesCore.h:38
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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
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.
~TEveRGBAPalette() override
Destructor.
UChar_t fOverRGBA[4]
Color_t GetUnderColor() const
void SetMin(Int_t min)
Set current min value.
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
void OnZeroRefCount() override
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:163
Mother of all ROOT objects.
Definition TObject.h:41
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:693