Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveUtil.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, 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 ROOT7_REveUtil
13#define ROOT7_REveUtil
14
15#include "REveTypes.hxx"
16
17#include <string>
18#include <string_view>
19#include <map>
20
21class TObject;
22class TObjArray;
23class TGeoManager;
24
25namespace ROOT {
26namespace Experimental {
27
28class REveElement;
29
30////////////////////////////////////////////////////////////////////////////////
31/// REveUtil
32/// Standard utility functions for Reve.
33////////////////////////////////////////////////////////////////////////////////
34
36{
37private:
39
40public:
41 virtual ~REveUtil() {}
42
43 // Macro functions
44
45 static Bool_t CheckMacro(const char *mac);
46 static void AssertMacro(const char *mac);
47 static void Macro(const char *mac);
48 static void LoadMacro(const char *mac);
49
50 // Input string verification and sanitization
51
52 static bool VerifyObjectFilterOrTableExpression(std::string_view expr);
53
54 // Color management
55
56 static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha = kTRUE);
57 static void ColorFromIdx(Color_t ci, UChar_t col[4], Char_t transparency);
58 static void ColorFromIdx(Float_t f1, Color_t c1, Float_t f2, Color_t c2, 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 // Math utilities
64
65 static double ServerTimeMs();
66 static void AppendServerTime(std::string &msg);
67 static void StampServerTime(std::string &msg);
68
71
72 static Bool_t IsU1IntervalContainedByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ);
73 static Bool_t IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ);
74
75 static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ);
76};
77
79{
80 return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
81}
82
84{
85 return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
86}
87
88
89////////////////////////////////////////////////////////////////////////////////
90/// REveGeoManagerHolder
91/// Exception-safe global variable holders
92////////////////////////////////////////////////////////////////////////////////
93
95{
96private:
97 TGeoManager *fManager{nullptr}; ///<! hold manager
98 Int_t fNSegments{0}; ///<! previous settings for num segments
99
100public:
101 REveGeoManagerHolder(TGeoManager *new_gmgr = nullptr, Int_t n_seg = 0);
103};
104
105////////////////////////////////////////////////////////////////////////////////
106/// REveRefCnt
107/// REveRefCnt base-class (interface)
108////////////////////////////////////////////////////////////////////////////////
109
111{
112 REveRefCnt(const REveRefCnt &) = delete;
113 REveRefCnt &operator=(const REveRefCnt &) = delete;
114
115protected:
117
118public:
119 REveRefCnt() = default;
120 virtual ~REveRefCnt() {}
121
122 void IncRefCount() { ++fRefCount; }
124 {
125 if (--fRefCount <= 0)
127 }
128
129 virtual void OnZeroRefCount() = 0;
130};
131
132////////////////////////////////////////////////////////////////////////////////
133/// REveRefBackPtr
134/// reference-count with back pointers
135////////////////////////////////////////////////////////////////////////////////
136
138{
141
142protected:
143 typedef std::map<REveElement *, Int_t> RefMap_t;
144
146
147public:
148 REveRefBackPtr() = default;
149 ~REveRefBackPtr() override;
150
153 virtual void IncRefCount(REveElement *re);
154 virtual void DecRefCount(REveElement *re);
155
156 virtual void StampBackPtrElements(UChar_t stamps);
157};
158
159} // namespace Experimental
160} // namespace ROOT
161
162#endif
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
short Color_t
Color number (short)
Definition RtypesCore.h:100
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:52
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Base class for REveUtil visualization elements, providing hierarchy management, rendering control and...
REveGeoManagerHolder Exception-safe global variable holders.
Definition REveUtil.hxx:95
Int_t fNSegments
! previous settings for num segments
Definition REveUtil.hxx:98
TGeoManager * fManager
! hold manager
Definition REveUtil.hxx:97
REveGeoManagerHolder(TGeoManager *new_gmgr=nullptr, Int_t n_seg=0)
Constructor.
Definition REveUtil.cxx:411
REveRefBackPtr reference-count with back pointers.
Definition REveUtil.hxx:138
REveRefBackPtr(const REveRefBackPtr &)=delete
std::map< REveElement *, Int_t > RefMap_t
Definition REveUtil.hxx:143
REveRefBackPtr & operator=(const REveRefBackPtr &)=delete
~REveRefBackPtr() override
Destructor. Noop, should complain if back-ref list is not empty.
Definition REveUtil.cxx:458
virtual void StampBackPtrElements(UChar_t stamps)
Add given stamps to elements in the list of reverse references.
Definition REveUtil.cxx:490
REveRefCnt REveRefCnt base-class (interface)
Definition REveUtil.hxx:111
REveRefCnt(const REveRefCnt &)=delete
REveRefCnt & operator=(const REveRefCnt &)=delete
virtual void OnZeroRefCount()=0
REveUtil Standard utility functions for Reve.
Definition REveUtil.hxx:36
static Bool_t IsU1IntervalContainedByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ)
Definition REveUtil.hxx:78
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 REveUtil.cxx:362
static double ServerTimeMs()
Milliseconds from a monotonic clock, counted from first use.
Definition REveUtil.cxx:43
static void LoadMacro(const char *mac)
Makes sure that macro 'mac' is loaded, but do not reload it.
Definition REveUtil.cxx:156
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition REveUtil.cxx:144
static Bool_t CheckMacro(const char *mac)
Checks if macro 'mac' is loaded.
Definition REveUtil.cxx:116
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 REveUtil.cxx:381
static void AppendServerTime(std::string &msg)
Append "server_time" to the JSON message msg, a non-empty object or array: as its last key,...
Definition REveUtil.cxx:63
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 REveUtil.cxx:275
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 REveUtil.cxx:341
static Bool_t IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ)
Definition REveUtil.hxx:83
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE)
Fill col with RGBA values corresponding to index ci.
Definition REveUtil.cxx:187
static void StampServerTime(std::string &msg)
Set the "server_time" that AppendServerTime() put at the end of msg to now.
Definition REveUtil.cxx:76
static Color_t * FindColorVar(TObject *obj, const char *varname)
Find address of Color_t data-member with name varname in object obj.
Definition REveUtil.cxx:256
static void AssertMacro(const char *mac)
Load and execute macro 'mac' if it has not been loaded yet.
Definition REveUtil.cxx:134
static bool VerifyObjectFilterOrTableExpression(std::string_view expr)
Input string verification and sanitization.
Definition REveUtil.cxx:166
static TObjArray * fgDefaultColors
Definition REveUtil.hxx:38
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:42
return c1
Definition legend1.C:41
TF1 * f1
Definition legend1.C:11
return c2
Definition legend2.C:14