]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/RGBAPalette.h
Getting rid of effC++ warnings about missing copy constructor and assignment operator.
[u/mrichter/AliRoot.git] / EVE / Reve / RGBAPalette.h
CommitLineData
8373e543 1// $Header$
2
3#ifndef REVE_RGBAPalette_H
4#define REVE_RGBAPalette_H
5
6#include <Reve/Reve.h>
7
8#include <TObject.h>
9
10namespace Reve {
11
12class RGBAPalette : public TObject, public ReferenceCount
13{
14 friend class RGBAPaletteEditor;
15 friend class RGBAPaletteSubEditor;
16
bc5158df 17public:
18 enum LimitAction_e { LA_Cut, LA_Mark, LA_Clip, LA_Wrap };
19
8373e543 20private:
21 RGBAPalette(const RGBAPalette&); // Not implemented
22 RGBAPalette& operator=(const RGBAPalette&); // Not implemented
23
24protected:
25 Int_t fLowLimit; // Low limit for Min/Max values (used by editor)
26 Int_t fHighLimit; // High limit for Min/Max values (used by editor)
27 Int_t fMinVal;
28 Int_t fMaxVal;
29 Int_t fNBins;
bc5158df 30
a290e33f 31 Bool_t fInterpolate;
32 Bool_t fShowDefValue;
33 Int_t fUnderflowAction;
34 Int_t fOverflowAction;
bc5158df 35
36 Color_t fDefaultColor; // Color for when value is not specified
8373e543 37 UChar_t fDefaultRGBA[4];
a290e33f 38 Color_t fUnderColor; // Underflow color
bc5158df 39 UChar_t fUnderRGBA[4];
a290e33f 40 Color_t fOverColor; // Overflow color
bc5158df 41 UChar_t fOverRGBA[4];
8373e543 42
43 mutable UChar_t* fColorArray; //[4*fNBins]
44
45 void SetupColor(Int_t val, UChar_t* pix) const;
46
47 static RGBAPalette* fgDefaultPalette;
48
49public:
50 RGBAPalette();
e0fa60e9 51 RGBAPalette(Int_t min, Int_t max, Bool_t interp=kFALSE, Bool_t showdef=kTRUE);
8373e543 52 virtual ~RGBAPalette();
53
54 void SetupColorArray() const;
55 void ClearColorArray();
56
8373e543 57 Bool_t WithinVisibleRange(Int_t val) const;
bc5158df 58 const UChar_t* ColorFromValue(Int_t val) const;
59 void ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha=kTRUE) const;
60 Bool_t ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha=kTRUE) const;
8373e543 61
bc5158df 62 Int_t GetMinVal() const { return fMinVal; }
63 Int_t GetMaxVal() const { return fMaxVal; }
8373e543 64
65 void SetLimits(Int_t low, Int_t high);
66 void SetMinMax(Int_t min, Int_t max);
67 void SetMin(Int_t min);
68 void SetMax(Int_t max);
bc5158df 69
fa90d41f 70 Int_t GetLowLimit() const { return fLowLimit; }
71 Int_t GetHighLimit() const { return fHighLimit; }
72
bc5158df 73 // ================================================================
74
75 Bool_t GetInterpolate() const { return fInterpolate; }
8373e543 76 void SetInterpolate(Bool_t b);
bc5158df 77
78 Bool_t GetShowDefValue() const { return fShowDefValue; }
79 void SetShowDefValue(Bool_t v) { fShowDefValue = v; }
80
a290e33f 81 Int_t GetUnderflowAction() const { return fUnderflowAction; }
82 Int_t GetOverflowAction() const { return fOverflowAction; }
83 void SetUnderflowAction(Int_t a) { fUnderflowAction = a; }
84 void SetOverflowAction(Int_t a) { fOverflowAction = a; }
bc5158df 85
86 // ================================================================
8373e543 87
88 Color_t GetDefaultColor() const { return fDefaultColor; }
89 Color_t* PtrDefaultColor() { return &fDefaultColor; }
90 UChar_t* GetDefaultRGBA() { return fDefaultRGBA; }
91 const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
92
93 void SetDefaultColor(Color_t ci);
94 void SetDefaultColor(Pixel_t pix);
95 void SetDefaultColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
96
bc5158df 97 // ----------------------------------------------------------------
98
99 Color_t GetUnderColor() const { return fUnderColor; }
100 Color_t* PtrUnderColor() { return &fUnderColor; }
101 UChar_t* GetUnderRGBA() { return fUnderRGBA; }
102 const UChar_t* GetUnderRGBA() const { return fUnderRGBA; }
103
104 void SetUnderColor(Color_t ci);
105 void SetUnderColor(Pixel_t pix);
106 void SetUnderColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
107
108 // ----------------------------------------------------------------
109
110 Color_t GetOverColor() const { return fOverColor; }
111 Color_t* PtrOverColor() { return &fOverColor; }
112 UChar_t* GetOverRGBA() { return fOverRGBA; }
113 const UChar_t* GetOverRGBA() const { return fOverRGBA; }
114
115 void SetOverColor(Color_t ci);
116 void SetOverColor(Pixel_t pix);
117 void SetOverColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
118
119 // ================================================================
120
8373e543 121 // ?? Should we emit some *SIGNALS* ??
122 // ?? Should we have a RendererTimeStamp ??
123
124 ClassDef(RGBAPalette, 1);
125}; // endclass RGBAPalette
126
127
bc5158df 128/**************************************************************************/
129// Inlines for RGBAPalette
130/**************************************************************************/
131
132inline Bool_t RGBAPalette::WithinVisibleRange(Int_t val) const
8373e543 133{
a290e33f 134 if ((val < fMinVal && fUnderflowAction == LA_Cut) ||
135 (val > fMaxVal && fOverflowAction == LA_Cut))
bc5158df 136 return kFALSE;
137 else
138 return kTRUE;
139}
140
141inline const UChar_t* RGBAPalette::ColorFromValue(Int_t val) const
142{
143 // Here we expect that LA_Cut has been checked; we further check
144 // for LA_Wrap and LA_Clip otherwise we proceed as for LA_Mark.
145
146 if (!fColorArray) SetupColorArray();
147 if (val < fMinVal) {
a290e33f 148 if (fUnderflowAction == LA_Wrap)
bc5158df 149 val = (val+1-fMinVal)%fNBins + fMaxVal;
a290e33f 150 else if (fUnderflowAction == LA_Clip)
bc5158df 151 val = fMinVal;
152 else
153 return fUnderRGBA;
154 }
155 else if(val > fMaxVal) {
a290e33f 156 if (fOverflowAction == LA_Wrap)
bc5158df 157 val = (val-1-fMaxVal)%fNBins + fMinVal;
a290e33f 158 else if (fOverflowAction == LA_Clip)
bc5158df 159 val = fMaxVal;
160 else
161 return fOverRGBA;
162 }
8373e543 163 return fColorArray + 4 * (val - fMinVal);
164}
165
bc5158df 166inline void RGBAPalette::ColorFromValue(Int_t val, UChar_t* pix, Bool_t alpha) const
8373e543 167{
bc5158df 168 const UChar_t* c = ColorFromValue(val);
8373e543 169 pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
170 if (alpha) pix[3] = c[3];
171}
172
bc5158df 173inline Bool_t RGBAPalette::ColorFromValue(Int_t val, Int_t defVal, UChar_t* pix, Bool_t alpha) const
8373e543 174{
bc5158df 175 if (val == defVal) {
176 if (fShowDefValue) {
177 pix[0] = fDefaultRGBA[0];
178 pix[1] = fDefaultRGBA[1];
179 pix[2] = fDefaultRGBA[2];
180 if (alpha) pix[3] = fDefaultRGBA[3];
181 return kTRUE;
182 } else {
183 return kFALSE;
184 }
185 }
186
187 if (WithinVisibleRange(val)) {
188 ColorFromValue(val, pix, alpha);
8373e543 189 return kTRUE;
bc5158df 190 } else {
191 return kFALSE;
192 }
8373e543 193}
194
195}
196
197#endif