From 843e6acd81e94ce0e83b047c7a3084563de8b586 Mon Sep 17 00:00:00 2001 From: mtadel Date: Tue, 14 Nov 2006 16:27:39 +0000 Subject: [PATCH] Removed code for RGBAPalette; now in its own file. --- EVE/Reve/Reve.cxx | 104 +--------------------------------------------- EVE/Reve/Reve.h | 65 +++-------------------------- 2 files changed, 7 insertions(+), 162 deletions(-) diff --git a/EVE/Reve/Reve.cxx b/EVE/Reve/Reve.cxx index c39c4ea9aa8..6ab54f6a21d 100644 --- a/EVE/Reve/Reve.cxx +++ b/EVE/Reve/Reve.cxx @@ -206,7 +206,7 @@ GeoManagerHolder::~GeoManagerHolder() } /**************************************************************************/ -// Color, palette management +// Color management /**************************************************************************/ void ColorFromIdx(Color_t ci, UChar_t* col, Bool_t alpha) @@ -247,108 +247,6 @@ Color_t* FindColorVar(TObject* obj, const Text_t* varname) 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 diff --git a/EVE/Reve/Reve.h b/EVE/Reve/Reve.h index 4baf2fc84cd..f8ea6dc75b0 100644 --- a/EVE/Reve/Reve.h +++ b/EVE/Reve/Reve.h @@ -9,12 +9,14 @@ #include #include #include +#include class TVirtualPad; class TGeoManager; namespace Reve { +class RenderElement; /**************************************************************************/ // Exceptions, string functions @@ -107,6 +109,9 @@ public: 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(); } @@ -117,7 +122,7 @@ public: /**************************************************************************/ -// Color, palette management +// Color management /**************************************************************************/ void ColorFromIdx(Color_t ci, UChar_t* col, Bool_t alpha=kTRUE); @@ -125,64 +130,6 @@ void ColorFromIdx(Float_t f1, Color_t c1, Float_t f2, Color_t c2, 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 -- 2.39.3