#ifndef ROOT_TEveUtil
#define ROOT_TEveUtil
#include "TObject.h"
#include "TString.h"
#include "TError.h"
#include "GuiTypes.h"
#include <list>
#include <set>
#include <exception>
class TVirtualPad;
class TGeoManager;
class TEveElement;
class TEveUtil
{
private:
static TObjArray* fgDefaultColors;
public:
virtual ~TEveUtil() {}
static void SetupEnvironment();
static void SetupGUI();
static Bool_t CheckMacro(const char* mac);
static void AssertMacro(const char* mac);
static void Macro(const char* mac);
static void LoadMacro(const char* mac);
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE);
static void ColorFromIdx(Color_t ci, UChar_t col[4], UChar_t transparency);
static void ColorFromIdx(Float_t f1, Color_t c1, Float_t f2, Color_t c2,
UChar_t col[4], Bool_t alpha=kTRUE);
static Color_t* FindColorVar(TObject* obj, const char* varname);
static void SetColorBrightness(Float_t value, Bool_t full_redraw=kFALSE);
static Bool_t IsU1IntervalContainedByMinMax (Float_t minM, Float_t maxM,
Float_t minQ, Float_t maxQ);
static Bool_t IsU1IntervalOverlappingByMinMax(Float_t minM, Float_t maxM,
Float_t minQ, Float_t maxQ);
static Bool_t IsU1IntervalContainedByMeanDelta (Float_t meanM, Float_t deltaM,
Float_t meanQ, Float_t deltaQ);
static Bool_t IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM,
Float_t meanQ, Float_t deltaQ);
static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ);
ClassDef(TEveUtil, 0);
};
inline Bool_t TEveUtil::IsU1IntervalContainedByMeanDelta(Float_t meanM, Float_t deltaM,
Float_t meanQ, Float_t deltaQ)
{
return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
}
inline Bool_t TEveUtil::IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM,
Float_t meanQ, Float_t deltaQ)
{
return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
}
bool operator==(const TString& t, const std::string& s);
bool operator==(const std::string& s, const TString& t);
class TEveException : public std::exception, public TString
{
public:
TEveException() {}
TEveException(const TString& s) : TString(s) {}
TEveException(const char* s) : TString(s) {}
TEveException(const std::string& s);
virtual ~TEveException() throw () {}
virtual const char* what() const throw () { return Data(); }
ClassDef(TEveException, 1);
};
TEveException operator+(const TEveException &s1, const std::string &s2);
TEveException operator+(const TEveException &s1, const TString &s2);
TEveException operator+(const TEveException &s1, const char *s2);
class TEvePadHolder
{
private:
TVirtualPad *fOldPad;
Bool_t fModifyUpdateP;
TEvePadHolder(const TEvePadHolder&);
TEvePadHolder& operator=(const TEvePadHolder&);
public:
TEvePadHolder(Bool_t modify_update_p, TVirtualPad* new_pad=0, Int_t subpad=0);
virtual ~TEvePadHolder();
ClassDef(TEvePadHolder, 0);
};
class TEveGeoManagerHolder
{
private:
TGeoManager *fManager;
Int_t fNSegments;
TEveGeoManagerHolder(const TEveGeoManagerHolder&);
TEveGeoManagerHolder& operator=(const TEveGeoManagerHolder&);
public:
TEveGeoManagerHolder(TGeoManager* new_gmgr=0, Int_t n_seg=0);
virtual ~TEveGeoManagerHolder();
ClassDef(TEveGeoManagerHolder, 0);
};
class TEveRefCnt
{
protected:
Int_t fRefCount;
public:
TEveRefCnt() : fRefCount(0) {}
virtual ~TEveRefCnt() {}
TEveRefCnt(const TEveRefCnt&) : fRefCount(0) {}
TEveRefCnt& operator=(const TEveRefCnt&) { return *this; }
void IncRefCount() { ++fRefCount; }
void DecRefCount() { if(--fRefCount <= 0) OnZeroRefCount(); }
virtual void OnZeroRefCount() { delete this; }
ClassDef(TEveRefCnt, 0);
};
class TEveRefBackPtr : public TEveRefCnt
{
protected:
std::list<TEveElement*> fBackRefs;
public:
TEveRefBackPtr();
virtual ~TEveRefBackPtr();
TEveRefBackPtr(const TEveRefBackPtr&);
TEveRefBackPtr& operator=(const TEveRefBackPtr&);
using TEveRefCnt::IncRefCount;
using TEveRefCnt::DecRefCount;
virtual void IncRefCount(TEveElement* re);
virtual void DecRefCount(TEveElement* re);
virtual void StampBackPtrElements(UChar_t stamps);
ClassDef(TEveRefBackPtr, 0);
};
#endif