3 #ifndef REVE_RGBAPalette_H
4 #define REVE_RGBAPalette_H
12 class RGBAPalette : public TObject, public ReferenceCount
14 friend class RGBAPaletteEditor;
15 friend class RGBAPaletteSubEditor;
18 RGBAPalette(const RGBAPalette&); // Not implemented
19 RGBAPalette& operator=(const RGBAPalette&); // Not implemented
22 Int_t fLowLimit; // Low limit for Min/Max values (used by editor)
23 Int_t fHighLimit; // High limit for Min/Max values (used by editor)
27 Bool_t fCutLow; // Instruct renderer not to display quoads below fMinVal
28 Bool_t fCutHigh; // Instruct renderer not to display quoads above fMaxVal
31 Color_t fDefaultColor;
32 UChar_t fDefaultRGBA[4];
34 mutable UChar_t* fColorArray; //[4*fNBins]
36 void SetupColor(Int_t val, UChar_t* pix) const;
38 static RGBAPalette* fgDefaultPalette;
42 RGBAPalette(Int_t min, Int_t max);
43 RGBAPalette(Int_t min, Int_t max, Bool_t interp, Bool_t wrap);
44 virtual ~RGBAPalette();
46 void SetupColorArray() const;
47 void ClearColorArray();
49 UChar_t* ColorFromArray(Int_t val) const;
50 void ColorFromArray(Int_t val, UChar_t* pix, Bool_t alpha=kTRUE) const;
52 Bool_t WithinVisibleRange(Int_t val) const;
54 Int_t GetMinVal() const { return fMinVal; }
55 Int_t GetMaxVal() const { return fMaxVal; }
56 Bool_t GetInterpolate() const { return fInterpolate; }
57 Bool_t GetWrap() const { return fWrap; }
59 void SetLimits(Int_t low, Int_t high);
60 void SetMinMax(Int_t min, Int_t max);
61 void SetMin(Int_t min);
62 void SetMax(Int_t max);
63 void SetInterpolate(Bool_t b);
64 void SetWrap(Bool_t b);
66 Color_t GetDefaultColor() const { return fDefaultColor; }
67 Color_t* PtrDefaultColor() { return &fDefaultColor; }
68 UChar_t* GetDefaultRGBA() { return fDefaultRGBA; }
69 const UChar_t* GetDefaultRGBA() const { return fDefaultRGBA; }
71 void SetDefaultColor(Color_t ci);
72 void SetDefaultColor(Pixel_t pix);
73 void SetDefaultColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
75 // ?? Should we emit some *SIGNALS* ??
76 // ?? Should we have a RendererTimeStamp ??
78 ClassDef(RGBAPalette, 1);
79 }; // endclass RGBAPalette
82 inline UChar_t* RGBAPalette::ColorFromArray(Int_t val) const
84 if(!fColorArray) SetupColorArray();
85 if(val < fMinVal) val = fWrap ? ((val+1-fMinVal)%fNBins + fMaxVal) : fMinVal;
86 if(val > fMaxVal) val = fWrap ? ((val-1-fMaxVal)%fNBins + fMinVal) : fMaxVal;
87 return fColorArray + 4 * (val - fMinVal);
90 inline void RGBAPalette::ColorFromArray(Int_t val, UChar_t* pix, Bool_t alpha) const
92 UChar_t* c = ColorFromArray(val);
93 pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
94 if (alpha) pix[3] = c[3];
97 inline Bool_t RGBAPalette::WithinVisibleRange(Int_t val) const
99 if ((val < fMinVal && fCutLow) || (val > fMaxVal && fCutHigh))