Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveRGBAPalette.cxx
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#include "TEveRGBAPalette.h"
13
14#include "TColor.h"
15#include "TStyle.h"
16#include "TMath.h"
17
18/** \class TEveRGBAPalette
19\ingroup TEve
20A generic, speed-optimised mapping from value to RGBA color
21supporting different wrapping and range truncation modes.
22
23Flag fFixColorRange: specifies how the palette is mapped to signal values:
24 - true - LowLimit -> HighLimit
25 - false - MinValue -> MaxValue
26*/
27
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
33 TObject(), TQObject(),
34 TEveRefCnt(),
35
36 fUIf(1), fUIc(0),
37
38 fLowLimit(0), fHighLimit(0), fMinVal(0), fMaxVal(0),
39
40 fUIDoubleRep (kFALSE),
41 fInterpolate (kTRUE),
42 fShowDefValue (kTRUE),
43 fFixColorRange (kFALSE),
44 fUnderflowAction (kLA_Cut),
45 fOverflowAction (kLA_Clip),
46
47 fDefaultColor(-1),
48 fUnderColor (-1),
49 fOverColor (-1),
50
51 fNBins(0), fCAMin(0), fCAMax(0), fColorArray(nullptr)
52{
53 SetLimits(0, 1024);
54 SetMinMax(0, 512);
55
58 SetOverColor(2);
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Constructor.
63
66 TObject(), TQObject(),
67 TEveRefCnt(),
68
69 fUIf(1), fUIc(0),
70
71 fLowLimit(0), fHighLimit(0), fMinVal(0), fMaxVal(0),
72
73 fUIDoubleRep (kFALSE),
74 fInterpolate (interp),
75 fShowDefValue (showdef),
76 fFixColorRange (fixcolrng),
77 fUnderflowAction (kLA_Cut),
78 fOverflowAction (kLA_Clip),
79
80 fDefaultColor(-1),
81 fUnderColor (-1),
82 fOverColor (-1),
83
84 fNBins(0), fCAMin(0), fCAMax(0), fColorArray(nullptr)
85{
86 SetLimits(min, max);
87 SetMinMax(min, max);
88
91 SetOverColor(2);
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Destructor.
96
101
102////////////////////////////////////////////////////////////////////////////////
103/// Set RGBA color 'pixel' for signal-value 'val'.
104
106{
107 using namespace TMath;
108 Float_t div = Max(1, fCAMax - fCAMin);
110
111 Float_t f;
112 if (val >= fCAMax) f = nCol - 1;
113 else if (val <= fCAMin) f = 0;
114 else f = (val - fCAMin)/div*(nCol - 1);
115
116 if (fInterpolate) {
117 Int_t bin = (Int_t) f;
118 Float_t f2 = f - bin, f1 = 1.0f - f2;
120 f2, gStyle->GetColorPalette(Min(bin + 1, nCol - 1)),
121 pixel);
122 } else {
124 }
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Construct internal color array that maps signal value to RGBA color.
129
131{
132 if (fColorArray)
133 delete [] fColorArray;
134
135 if (fFixColorRange) {
137 } else {
139 }
140 fNBins = fCAMax - fCAMin + 1;
141
142 fColorArray = new UChar_t [4 * fNBins];
144 for(Int_t v = fCAMin; v <= fCAMax; ++v, p+=4)
145 SetupColor(v, p);
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Clear internal color array.
150
152{
153 if (fColorArray) {
154 delete [] fColorArray;
155 fColorArray = nullptr;
156 fNBins = fCAMin = fCAMax = 0;
157 }
158}
159
160////////////////////////////////////////////////////////////////////////////////
161/// Set low/high limits on signal value. Current min/max values are
162/// clamped into the new limits.
163
165{
166 fLowLimit = low;
167 fHighLimit = high;
168
173
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Set low/high limits and rescale current min/max values.
179
192
193////////////////////////////////////////////////////////////////////////////////
194/// Set current min value.
195
201
202////////////////////////////////////////////////////////////////////////////////
203/// Set current max value.
204
210
211////////////////////////////////////////////////////////////////////////////////
212/// Set current min/max values.
213
215{
216 fMinVal = min;
217 fMaxVal = max;
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Set flag determining whether GUI editor and overlays should show limits
223/// and axis values as real values with mapping from integer value i to real
224/// value d as: d = f*i + fc
225
227{
228 fUIDoubleRep = b;
229 if (fUIDoubleRep) {
230 fUIf = f; fUIc = c;
231 } else {
232 fUIf = 1; fUIc = 0;
233 }
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Set interpolation flag. This determines how colors from ROOT's
238/// palette are mapped into RGBA values for given signal.
239
245
246////////////////////////////////////////////////////////////////////////////////
247/// Set flag specifying how the palette is mapped to signal values:
248/// true - LowLimit -> HighLimit
249/// false - MinValue -> MaxValue
250
256
257////////////////////////////////////////////////////////////////////////////////
258/// Set default color.
259
265
266////////////////////////////////////////////////////////////////////////////////
267/// Set default color.
268
273
274////////////////////////////////////////////////////////////////////////////////
275/// Set default color.
276
285
286////////////////////////////////////////////////////////////////////////////////
287/// Set underflow color.
288
294
295////////////////////////////////////////////////////////////////////////////////
296/// Set underflow color.
297
302
303////////////////////////////////////////////////////////////////////////////////
304/// Set underflow color.
305
314
315////////////////////////////////////////////////////////////////////////////////
316/// Set overflow color.
317
323
324////////////////////////////////////////////////////////////////////////////////
325/// Set overflow color.
326
331
332////////////////////////////////////////////////////////////////////////////////
333/// Set overflow color.
334
343
344////////////////////////////////////////////////////////////////////////////////
345/// Emit the "MinMaxValChanged()" signal.
346/// This is NOT called automatically from SetMin/Max functions but
347/// it IS called from TEveRGBAPaletteEditor after it changes the
348/// min/max values.
349
351{
352 Emit("MinMaxValChanged()");
353}
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#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
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 pixel
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
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1926
void SetMax(Int_t max)
Set current max value.
void SetOverColor(Color_t ci)
Set overflow color.
UChar_t fDefaultRGBA[4]
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
~TEveRGBAPalette() override
Destructor.
UChar_t fOverRGBA[4]
void SetMin(Int_t min)
Set current min value.
void SetupColorArray() const
Construct internal color array that maps signal value to RGBA color.
void SetDefaultColor(Color_t ci)
Set default color.
void SetInterpolate(Bool_t b)
Set interpolation flag.
UChar_t * fColorArray
void SetDefaultColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set default color.
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.
void ClearColorArray()
Clear internal color array.
void SetUnderColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set underflow color.
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.
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...
Base-class for reference-counted objects.
Definition TEveUtil.h:163
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE)
Fill col with RGBA values corresponding to index ci.
Definition TEveUtil.cxx:187
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
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition TStyle.cxx:1102
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition TStyle.cxx:1176
TF1 * f1
Definition legend1.C:11
TMath.
Definition TMathBase.h:35
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:704
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:251
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199