Logo ROOT   6.18/05
Reference Guide
TEveUtil.h
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TEveUtil
13#define ROOT_TEveUtil
14
15#include "TObject.h"
16#include "TString.h"
17#include "TError.h"
18
19#include "GuiTypes.h"
20
21#include <list>
22#include <map>
23#include <set>
24#include <exception>
25
26class TVirtualPad;
27class TGeoManager;
28
29class TEveElement;
30
31/******************************************************************************/
32// TEveUtil
33/******************************************************************************/
34
36{
37private:
39
40public:
41 virtual ~TEveUtil() {}
42
43 // Environment, Macro functions
44
45 static void SetupEnvironment();
46 static void SetupGUI();
47
48 static Bool_t CheckMacro(const char* mac);
49 static void AssertMacro(const char* mac);
50 static void Macro(const char* mac);
51 static void LoadMacro(const char* mac);
52
53 // Color management
54
55 static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE);
56 static void ColorFromIdx(Color_t ci, UChar_t col[4], Char_t transparency);
58 UChar_t col[4], Bool_t alpha=kTRUE);
59 static Color_t* FindColorVar(TObject* obj, const char* varname);
60
61 static void SetColorBrightness(Float_t value, Bool_t full_redraw=kFALSE);
62
63
64 // Math utilities
65
67 Float_t minQ, Float_t maxQ);
69 Float_t minQ, Float_t maxQ);
70
72 Float_t meanQ, Float_t deltaQ);
74 Float_t meanQ, Float_t deltaQ);
75
76 static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ);
77
78
79 ClassDef(TEveUtil, 0); // Standard utility functions for Reve.
80};
81
83 Float_t meanQ, Float_t deltaQ)
84{
85 return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
86}
87
89 Float_t meanQ, Float_t deltaQ)
90{
91 return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
92}
93
94
95/******************************************************************************/
96// Exceptions, string functions
97/******************************************************************************/
98
99bool operator==(const TString& t, const std::string& s);
100bool operator==(const std::string& s, const TString& t);
101
102class TEveException : public std::exception, public TString
103{
104public:
107 TEveException(const char* s) : TString(s) {}
108 TEveException(const std::string& s);
109
110 virtual ~TEveException() noexcept {}
111
112 virtual const char* what() const noexcept { return Data(); }
113
114 ClassDef(TEveException, 1); // Exception-type thrown by Eve classes.
115};
116
117TEveException operator+(const TEveException &s1, const std::string &s2);
119TEveException operator+(const TEveException &s1, const char *s2);
120
121
122/******************************************************************************/
123// Exception-safe global variable holders
124/******************************************************************************/
125
127{
128private:
131
132 TEvePadHolder(const TEvePadHolder&); // Not implemented
133 TEvePadHolder& operator=(const TEvePadHolder&); // Not implemented
134
135public:
136 TEvePadHolder(Bool_t modify_update_p, TVirtualPad* new_pad=0, Int_t subpad=0);
137 virtual ~TEvePadHolder();
138
139 ClassDef(TEvePadHolder, 0); // Exception-safe wrapper for temporary setting of gPad variable.
140};
141
143{
144private:
147
148 TEveGeoManagerHolder(const TEveGeoManagerHolder&); // Not implemented
150
151public:
152 TEveGeoManagerHolder(TGeoManager* new_gmgr=0, Int_t n_seg=0);
153 virtual ~TEveGeoManagerHolder();
154
155 ClassDef(TEveGeoManagerHolder, 0); // Exception-safe wrapper for temporary setting of gGeoManager variable.
156};
157
158
159/******************************************************************************/
160// TEveRefCnt base-class (interface)
161/******************************************************************************/
162
164{
165protected:
167
168public:
170 virtual ~TEveRefCnt() {}
171
173 TEveRefCnt& operator=(const TEveRefCnt&) { return *this; }
174
175 void IncRefCount() { ++fRefCount; }
176 void DecRefCount() { if(--fRefCount <= 0) OnZeroRefCount(); }
177
178 virtual void OnZeroRefCount() { delete this; }
179
180 ClassDef(TEveRefCnt, 0); // Base-class for reference-counted objects.
181};
182
183/******************************************************************************/
184// TEveRefBackPtr reference-count with back pointers
185/******************************************************************************/
186
188{
189protected:
190 typedef std::map<TEveElement*, Int_t> RefMap_t;
191 typedef RefMap_t::iterator RefMap_i;
192
194
195public:
197 virtual ~TEveRefBackPtr();
198
201
204 virtual void IncRefCount(TEveElement* re);
205 virtual void DecRefCount(TEveElement* re);
206
207 virtual void StampBackPtrElements(UChar_t stamps);
208
209 ClassDef(TEveRefBackPtr, 0); // Base-class for reference-counted objects with reverse references to TEveElement objects.
210};
211
212#endif
#define s1(x)
Definition: RSha256.hxx:91
int Int_t
Definition: RtypesCore.h:41
unsigned char UChar_t
Definition: RtypesCore.h:34
char Char_t
Definition: RtypesCore.h:29
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
short Color_t
Definition: RtypesCore.h:79
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
bool operator==(const TString &t, const std::string &s)
Definition: TEveUtil.cxx:413
TEveException operator+(const TEveException &s1, const std::string &s2)
Definition: TEveUtil.cxx:428
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:34
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:103
TEveException(const char *s)
Definition: TEveUtil.h:107
virtual const char * what() const noexcept
Definition: TEveUtil.h:112
TEveException(const TString &s)
Definition: TEveUtil.h:106
virtual ~TEveException() noexcept
Definition: TEveUtil.h:110
Exception safe wrapper for setting gGeoManager.
Definition: TEveUtil.h:143
TGeoManager * fManager
Definition: TEveUtil.h:145
TEveGeoManagerHolder(const TEveGeoManagerHolder &)
TEveGeoManagerHolder & operator=(const TEveGeoManagerHolder &)
virtual ~TEveGeoManagerHolder()
Destructor.
Definition: TEveUtil.cxx:508
Exception safe wrapper for setting gPad.
Definition: TEveUtil.h:127
TVirtualPad * fOldPad
Definition: TEveUtil.h:129
Bool_t fModifyUpdateP
Definition: TEveUtil.h:130
virtual ~TEvePadHolder()
Destructor.
Definition: TEveUtil.cxx:462
TEvePadHolder & operator=(const TEvePadHolder &)
TEvePadHolder(const TEvePadHolder &)
Base-class for reference-counted objects with reverse references to TEveElement objects.
Definition: TEveUtil.h:188
virtual void StampBackPtrElements(UChar_t stamps)
Add given stamps to elements in the list of reverse references.
Definition: TEveUtil.cxx:608
TEveRefBackPtr & operator=(const TEveRefBackPtr &)
Assignment operator.
Definition: TEveUtil.cxx:573
RefMap_t::iterator RefMap_i
Definition: TEveUtil.h:191
virtual ~TEveRefBackPtr()
Destructor. Noop, should complain if back-ref list is not empty.
Definition: TEveUtil.cxx:553
void IncRefCount()
Definition: TEveUtil.h:175
void DecRefCount()
Definition: TEveUtil.h:176
RefMap_t fBackRefs
Definition: TEveUtil.h:193
std::map< TEveElement *, Int_t > RefMap_t
Definition: TEveUtil.h:190
TEveRefBackPtr()
Default constructor.
Definition: TEveUtil.cxx:544
Base-class for reference-counted objects.
Definition: TEveUtil.h:164
TEveRefCnt & operator=(const TEveRefCnt &)
Definition: TEveUtil.h:173
virtual ~TEveRefCnt()
Definition: TEveUtil.h:170
TEveRefCnt(const TEveRefCnt &)
Definition: TEveUtil.h:172
virtual void OnZeroRefCount()
Definition: TEveUtil.h:178
Int_t fRefCount
Definition: TEveUtil.h:166
void IncRefCount()
Definition: TEveUtil.h:175
void DecRefCount()
Definition: TEveUtil.h:176
TEveRefCnt()
Definition: TEveUtil.h:169
Standard utility functions for Eve.
Definition: TEveUtil.h:36
static TObjArray * fgDefaultColors
Definition: TEveUtil.h:38
static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Get fraction of interval [minQ, maxQ] in [minM, maxM].
Definition: TEveUtil.cxx:386
static void SetColorBrightness(Float_t value, Bool_t full_redraw=kFALSE)
Tweak all ROOT colors to become brighter (if value > 0) or darker (value < 0).
Definition: TEveUtil.cxx:280
static Bool_t IsU1IntervalOverlappingByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is overlapping within interval M for U1 variables.
Definition: TEveUtil.cxx:367
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition: TEveUtil.cxx:168
static void AssertMacro(const char *mac)
Load and execute macro 'mac' if it has not been loaded yet.
Definition: TEveUtil.cxx:158
static void SetupGUI()
Setup icon pictures and mime-types.
Definition: TEveUtil.cxx:97
static Color_t * FindColorVar(TObject *obj, const char *varname)
Find address of Color_t data-member with name varname in object obj.
Definition: TEveUtil.cxx:261
static Bool_t IsU1IntervalContainedByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is contained within interval M for U1 variables.
Definition: TEveUtil.cxx:346
virtual ~TEveUtil()
Definition: TEveUtil.h:41
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE)
Fill col with RGBA values corresponding to index ci.
Definition: TEveUtil.cxx:192
static void SetupEnvironment()
Setup Include and Macro paths.
Definition: TEveUtil.cxx:54
static Bool_t IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ)
Definition: TEveUtil.h:88
static void LoadMacro(const char *mac)
Makes sure that macro 'mac' is loaded, but do not reload it.
Definition: TEveUtil.cxx:180
static Bool_t IsU1IntervalContainedByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ)
Definition: TEveUtil.h:82
static Bool_t CheckMacro(const char *mac)
Checks if macro 'mac' is loaded.
Definition: TEveUtil.cxx:140
The manager class for any TGeo geometry.
Definition: TGeoManager.h:43
An array of TObjects.
Definition: TObjArray.h:37
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
return c1
Definition: legend1.C:41
TF1 * f1
Definition: legend1.C:11
return c2
Definition: legend2.C:14
static constexpr double s