}
/**************************************************************************/
-// Color, palette management
+// Color management
/**************************************************************************/
void ColorFromIdx(Color_t ci, UChar_t* col, Bool_t alpha)
return (Color_t*) (((char*)obj) + off);
}
-/**************************************************************************/
-// RGBAPalette
-/**************************************************************************/
-
-RGBAPalette::RGBAPalette() :
- TObject(),
- Reve::ReferenceCount(),
- fInterpolate (kFALSE),
- fWrap (kFALSE),
- fColorArray (0)
-{
- SetMinMax(0, 100);
-}
-
-RGBAPalette::RGBAPalette(Int_t min, Int_t max) :
- TObject(),
- Reve::ReferenceCount(),
- fInterpolate (kFALSE),
- fWrap (kFALSE),
- fColorArray (0)
-{
- SetMinMax(min, max);
-}
-
-RGBAPalette::RGBAPalette(Int_t min, Int_t max, Bool_t interp, Bool_t wrap) :
- TObject(),
- Reve::ReferenceCount(),
- fInterpolate (interp),
- fWrap (wrap),
- fColorArray (0)
-{
- SetMinMax(min, max);
-}
-
-RGBAPalette::~RGBAPalette()
-{
- delete [] fColorArray;
-}
-
-/**************************************************************************/
-
-void RGBAPalette::SetupColor(Int_t val, UChar_t* pixel) const
-{
- using namespace TMath;
- Float_t div = Max(1, fMaxVal - fMinVal);
- Int_t nCol = gStyle->GetNumberOfColors();
-
- Float_t f;
- if (val <= fMinVal) f = 0;
- else if (val >= fMaxVal) f = nCol - 1;
- else f = (val - fMinVal)/div*(nCol - 1);
-
- if (fInterpolate) {
- Int_t bin = (Int_t) f;
- Float_t f1 = f - bin, f2 = 1.0f - f1;
- ColorFromIdx(f1, gStyle->GetColorPalette(bin),
- f2, gStyle->GetColorPalette(Min(bin + 1, nCol - 1)),
- pixel);
- } else {
- ColorFromIdx(gStyle->GetColorPalette((Int_t) Nint(f)), pixel);
- }
-}
-
-void RGBAPalette::SetupColorArray() const
-{
- if(fColorArray)
- return;
-
- fColorArray = new UChar_t [4 * fNBins];
- UChar_t* p = fColorArray;
- for(Int_t v=fMinVal; v<=fMaxVal; ++v, p+=4)
- SetupColor(v, p);
-}
-
-void RGBAPalette::ClearColorArray()
-{
- if(fColorArray) {
- delete [] fColorArray;
- fColorArray = 0;
- }
-}
-
-/**************************************************************************/
-
-void RGBAPalette::SetMinMax(Int_t min, Int_t max)
-{
- fMinVal = min;
- fMaxVal = max;
- fNBins = max - min + 1;
- ClearColorArray();
-}
-
-void RGBAPalette::SetInterpolate(Bool_t b)
-{
- fInterpolate = b;
- ClearColorArray();
-}
-
-void RGBAPalette::SetWrap(Bool_t b)
-{
- fWrap = b;
-}
/**************************************************************************/
} // end namespace Reve
#include <TString.h>
#include <TError.h>
#include <Gtypes.h>
+#include <GuiTypes.h>
class TVirtualPad;
class TGeoManager;
namespace Reve {
+class RenderElement;
/**************************************************************************/
// Exceptions, string functions
ReferenceCount() : fRefCount(0) {}
virtual ~ReferenceCount() {}
+ ReferenceCount(const ReferenceCount&) : fRefCount(0) {}
+ ReferenceCount& operator=(const ReferenceCount&) { return *this; }
+
void IncRefCount() { ++fRefCount; }
void DecRefCount() { if(--fRefCount <= 0) OnZeroRefCount(); }
/**************************************************************************/
-// Color, palette management
+// Color management
/**************************************************************************/
void ColorFromIdx(Color_t ci, UChar_t* col, Bool_t alpha=kTRUE);
UChar_t* col, Bool_t alpha=kTRUE);
Color_t* FindColorVar(TObject* obj, const Text_t* varname);
-class RGBAPalette : public TObject, public ReferenceCount
-{
- RGBAPalette(const RGBAPalette&); // Not implemented
- RGBAPalette& operator=(const RGBAPalette&); // Not implemented
-
-protected:
- Int_t fMinVal;
- Int_t fMaxVal;
- Int_t fNBins;
- Bool_t fInterpolate;
- Bool_t fWrap;
-
- mutable UChar_t* fColorArray; //!
-
- void SetupColor(Int_t val, UChar_t* pix) const;
-
-public:
- RGBAPalette();
- RGBAPalette(Int_t min, Int_t max);
- RGBAPalette(Int_t min, Int_t max, Bool_t interp, Bool_t wrap);
- virtual ~RGBAPalette();
-
- void SetupColorArray() const;
- void ClearColorArray();
-
- UChar_t* ColorFromArray(Int_t val) const;
- void ColorFromArray(Int_t val, UChar_t* pix, Bool_t alpha=kTRUE) const;
-
- Int_t GetMinVal() const { return fMinVal; }
- Int_t GetMaxVal() const { return fMaxVal; }
- Bool_t GetInterpolate() const { return fInterpolate; }
- Bool_t GetWrap() const { return fWrap; }
-
- void SetMinMax(Int_t min, Int_t max);
- void SetInterpolate(Bool_t b);
- void SetWrap(Bool_t b);
-
- ClassDef(RGBAPalette, 1)
-};
-
-
-inline UChar_t* RGBAPalette::ColorFromArray(Int_t val) const
-{
- if(!fColorArray) SetupColorArray();
- if(val < fMinVal) val = fWrap ? ((val+1-fMinVal)%fNBins + fMaxVal) : fMinVal;
- if(val > fMaxVal) val = fWrap ? ((val-1-fMaxVal)%fNBins + fMinVal) : fMaxVal;
- return fColorArray + 4 * (val - fMinVal);
-}
-
-inline void RGBAPalette::ColorFromArray(Int_t val, UChar_t* pix, Bool_t alpha) const
-{
- UChar_t* c = ColorFromArray(val);
- pix[0] = c[0]; pix[1] = c[1]; pix[2] = c[2];
- if (alpha) pix[3] = c[3];
-}
-
-/**************************************************************************/
-
}
#endif