Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveManager.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
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_REveManager
13#define ROOT7_REveManager
14
15#include <ROOT/REveElement.hxx>
16#include <ROOT/REveSystem.hxx>
17#include <ROOT/RLogger.hxx>
18
20
21#include "TSysEvtHandler.h"
22
23#include <thread>
24#include <mutex>
25#include <condition_variable>
26#include <memory>
27#include <queue>
28#include <unordered_map>
29
30class TMap;
31class TExMap;
32class TGeoManager;
33class TMethodCall;
34
35namespace ROOT {
36namespace Experimental {
37
38class REveSelection;
39class REveViewer;
40class REveViewerList;
41class REveScene;
42class REveSceneList;
43
44class RWebWindow;
45
47{
48 REveManager(const REveManager&) = delete;
50
51public:
53 public:
55 ~RExceptionHandler() override { Remove(); }
56
57 EStatus Handle(std::exception& exc) override;
58 };
59
61 public:
64 };
65
66 struct Conn
67 {
69 unsigned fId{0};
71
72 Conn() = default;
73 Conn(unsigned int cId) : fId(cId) {}
74 };
75
77 {
78 public:
80
81 std::mutex fMutex{};
82 std::condition_variable fCV{};
83
85 };
86
87 class MIR
88 {
89 public:
90 MIR(const std::string& cmd, ElementId_t id, const std::string& ctype, unsigned connid)
91 :fCmd(cmd), fId(id), fCtype(ctype), fConnId(connid){}
92
93 std::string fCmd;
95 std::string fCtype;
96 unsigned fConnId;
97 };
98
99 struct Logger {
100 class Handler : public RLogHandler {
101 public:
102 bool Emit(const RLogEntry &entry) override;
103 };
104
107 {
108 auto uptr = std::make_unique<Handler>();
109 fHandler = uptr.get();
110 RLogManager::Get().PushFront(std::move(uptr));
111 }
112
114 };
115
116protected:
117 RExceptionHandler *fExcHandler{nullptr}; //!< exception handler
118
119 TMap *fVizDB{nullptr};
122
123 TMap *fGeometries{nullptr}; // TODO: use std::map<std::string, std::unique_ptr<TGeoManager>>
124 TMap *fGeometryAliases{nullptr}; // TODO: use std::map<std::string, std::string>
125
126 REveScene *fWorld{nullptr};
127
130
136
137 // ElementId management
138 std::unordered_map<ElementId_t, REveElement*> fElementIdMap;
141 ElementId_t fMaxElementIds{std::numeric_limits<ElementId_t>::max()};
142
143 // Selection / highlight elements
147
148 std::shared_ptr<ROOT::RWebWindow> fWebWindow;
149 std::vector<Conn> fConnList;
150 std::queue<std::shared_ptr<MIR> > fMIRqueue;
151
152 // MIR execution
153 std::thread fMIRExecThread;
155 std::unordered_map<std::string, std::shared_ptr<TMethodCall> > fMethCallMap;
156
159 bool fIsRCore{false};
160
161 // restricted functionality for public use
162 bool fHttpPublic{false};
163
164 void WindowConnect(unsigned connid);
165 void WindowData(unsigned connid, const std::string &arg);
166 void WindowDisconnect(unsigned connid);
167
168 void MIRExecThread();
169 void ExecuteMIR(std::shared_ptr<MIR> mir);
170
172 void SendSceneChanges();
173
174public:
175 REveManager(); // (Bool_t map_window=kTRUE, Option_t* opt="FI");
176 virtual ~REveManager();
177
179
182
183 REveSceneList *GetScenes() const { return fScenes; }
184 REveViewerList *GetViewers() const { return fViewers; }
185
188
189 REveScene *GetWorld() const { return fWorld; }
190
192
193 REveViewer *SpawnNewViewer(const char *name, const char *title = "");
194 REveScene *SpawnNewScene (const char *name, const char *title = "");
195
196 void AllowMultipleRemoteConnections(bool loopBack = true, bool useAuthKey = true);
197
198 void BeginChange();
199 void EndChange();
200
201 void SceneSubscriberProcessingChanges(unsigned cinnId);
202 void SceneSubscriberWaitingResponse(unsigned cinnId);
203
204 bool ClientConnectionsFree() const;
205
206 void DisableRedraw() { printf("REveManager::DisableRedraw obsolete \n"); }
207 void EnableRedraw() { printf("REveManager::EnableRedraw obsolete \n"); }
208
209 void Redraw3D(Bool_t resetCameras = kFALSE, Bool_t dropLogicals = kFALSE)
210 {
211 printf("REveManager::Redraw3D oboslete %d %d\n",resetCameras , dropLogicals);
212 }
213 void RegisterRedraw3D();
214 void DoRedraw3D();
215 void FullRedraw3D(Bool_t resetCameras = kFALSE, Bool_t dropLogicals = kFALSE);
216
217 void ClearAllSelections();
218
221
222 void AddElement(REveElement *element, REveElement *parent = nullptr);
223 void AddGlobalElement(REveElement *element, REveElement *parent = nullptr);
224
225 void RemoveElement(REveElement* element, REveElement *parent);
226
228 void AssignElementId (REveElement* element);
229 void PreDeleteElement(REveElement* element);
230 void BrowseElement(ElementId_t id);
231
232 // VizDB - Visualization-parameter data-base.
233 Bool_t InsertVizDBEntry(const TString& tag, REveElement* model,
234 Bool_t replace, Bool_t update);
235 Bool_t InsertVizDBEntry(const TString& tag, REveElement* model);
236 REveElement *FindVizDBEntry (const TString& tag);
237
238 void LoadVizDB(const TString& filename, Bool_t replace, Bool_t update);
239 void LoadVizDB(const TString& filename);
240 void SaveVizDB(const TString& filename);
241
243 Bool_t GetVizDBUpdate () const { return fVizDBUpdate; }
246
247
248 // Geometry management.
252 void RegisterGeometryAlias(const TString& alias, const TString& filename);
253
254 void ClearROOTClassSaved();
255
256 void AddLocation(const std::string& name, const std::string& path);
257 void SetDefaultHtmlPage(const std::string& path);
258 void SetClientVersion(const std::string& version);
259
260 void ScheduleMIR(const std::string &cmd, ElementId_t i, const std::string& ctype, unsigned connid);
261
262 static REveManager* Create();
263 static void Terminate();
264 static void ExecuteInMainThread(std::function<void()> func);
265 static void QuitRoot();
266
267 static void ErrorHandler(Int_t level, Bool_t abort, const char *location,
268 const char *msg);
269
270
271 // Access to internals, needed for low-level control in advanced
272 // applications.
273
274 std::shared_ptr<ROOT::RWebWindow> GetWebWindow() const { return fWebWindow; }
275
276 // void Send(void* buff, unsigned connid);
277 void Send(unsigned connid, const std::string &data);
278 void SendBinary(unsigned connid, const void *data, std::size_t len);
279
280 void Show(const RWebDisplayArgs &args = "");
281
284
286 bool IsRCore() const { return fIsRCore; }
287
288 bool GetHttpPublic() { return fHttpPublic;}
289 void SetHttpPublic(bool);
290};
291
293
294}}
295
296#endif
#define R__EXTERN
Definition DllImport.h:26
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
bool Bool_t
Definition RtypesCore.h:63
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition TGX11.cxx:110
List of Scenes providing common operations on REveScene collections.
Eve representation of TGLScene.
Make sure there is a SINGLE running REveSelection for each selection type (select/highlight).
List of Viewers providing common operations on REveViewer collections.
Eve representation of a GL view.
bool Emit(const RLogEntry &entry) override
Utility to stream loggs to client.
MIR(const std::string &cmd, ElementId_t id, const std::string &ctype, unsigned connid)
EStatus Handle(std::exception &exc) override
Handle exceptions deriving from REveException.
void DisconnectEveViewer(REveViewer *)
void ScheduleMIR(const std::string &cmd, ElementId_t i, const std::string &ctype, unsigned connid)
void ClearROOTClassSaved()
Work-around uber ugly hack used in SavePrimitive and co.
REveManager(const REveManager &)=delete
REveScene * GetEventScene() const
std::shared_ptr< ROOT::RWebWindow > fWebWindow
REveSelection * GetHighlight() const
void RegisterGeometryAlias(const TString &alias, const TString &filename)
Register 'name' as an alias for geometry file 'filename'.
void PreDeleteElement(REveElement *element)
Called from REveElement prior to its destruction so the framework components (like object editor) can...
void ExecuteMIR(std::shared_ptr< MIR > mir)
REveSceneList * GetScenes() const
void ClearAllSelections()
Clear all selection objects.
RExceptionHandler * fExcHandler
exception handler
void AssignElementId(REveElement *element)
Assign a unique ElementId to given element.
TGeoManager * GetDefaultGeometry()
Get the default geometry.
static void ExecuteInMainThread(std::function< void()> func)
void GetServerStatus(REveServerStatus &)
void SceneSubscriberProcessingChanges(unsigned cinnId)
void SetDefaultHtmlPage(const std::string &path)
Set content of default window HTML page.
REveSelection * GetSelection() const
void AddLocation(const std::string &name, const std::string &path)
Register new directory to THttpServer.
void Send(unsigned connid, const std::string &data)
static void Terminate()
Properly terminate global REveManager.
REveElement * FindElementById(ElementId_t id) const
Lookup ElementId in element map and return corresponding REveElement*.
void SaveVizDB(const TString &filename)
Save visualization-parameter database to file filename.
TGeoManager * GetGeometryByAlias(const TString &alias)
Get geometry with given alias.
std::unordered_map< ElementId_t, REveElement * > fElementIdMap
static REveManager * Create()
If global REveManager* REX::gEve is not set initialize it.
std::unordered_map< std::string, std::shared_ptr< TMethodCall > > fMethCallMap
void WindowConnect(unsigned connid)
Process new connection from web window.
void AllowMultipleRemoteConnections(bool loopBack=true, bool useAuthKey=true)
Utility function to allow remote RWebWindow connections.
REveElement * FindVizDBEntry(const TString &tag)
Find a visualization-parameter database entry corresponding to tag.
TGeoManager * GetGeometry(const TString &filename)
Get geometry with given filename.
void ConnectEveViewer(REveViewer *)
REveScene * GetGlobalScene() const
static void ErrorHandler(Int_t level, Bool_t abort, const char *location, const char *msg)
std::queue< std::shared_ptr< MIR > > fMIRqueue
void LoadVizDB(const TString &filename, Bool_t replace, Bool_t update)
Load visualization-parameter database from file filename.
void DoRedraw3D()
Perform 3D redraw of scenes and viewers whose contents has changed.
REveManager & operator=(const REveManager &)=delete
void SendBinary(unsigned connid, const void *data, std::size_t len)
void AddElement(REveElement *element, REveElement *parent=nullptr)
Add an element.
void SetClientVersion(const std::string &version)
Set client version, used as prefix in scripts URL When changed, web browser will reload all related J...
void AddGlobalElement(REveElement *element, REveElement *parent=nullptr)
Add a global element, i.e.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
void SceneSubscriberWaitingResponse(unsigned cinnId)
REveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
void SetHttpPublic(bool)
Restrict functionality for this server when open to public.
std::shared_ptr< ROOT::RWebWindow > GetWebWindow() const
void RemoveElement(REveElement *element, REveElement *parent)
Remove element from parent.
virtual ~REveManager()
Destructor.
void WindowDisconnect(unsigned connid)
Process disconnect of web window.
void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Perform 3D redraw of all scenes and viewers.
REveViewer * SpawnNewViewer(const char *name, const char *title="")
Create a new GL viewer.
Bool_t InsertVizDBEntry(const TString &tag, REveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
REveViewer * GetDefaultViewer() const
Get the default viewer.
RExceptionHandler * GetExcHandler() const
void BrowseElement(ElementId_t id)
Activate EVE browser (summary view) for specified element id.
REveViewerList * GetViewers() const
void WindowData(unsigned connid, const std::string &arg)
Process data from web window.
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
REveSelection Container for selected and highlighted elements.
REveViewerList List of Viewers providing common operations on REveViewer collections.
REveViewer Reve representation of TGLViewer.
A diagnostic that can be emitted by the RLogManager.
Definition RLogger.hxx:178
Abstract RLogHandler base class.
Definition RLogger.hxx:85
std::unique_ptr< RLogHandler > Remove(RLogHandler *handler)
Remove and return the given log handler. Returns nullptr if not found.
Definition RLogger.cxx:68
static RLogManager & Get()
Definition RLogger.cxx:62
void PushFront(std::unique_ptr< RLogHandler > handler)
Add a RLogHandler in the front - to be called before all others.
Definition RLogger.hxx:150
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
Method or function calling interface.
Definition TMethodCall.h:37
void Add() override
Add std::exception handler to system handler list.
void Remove() override
Remove std::exception handler from system handler list.
Basic string class.
Definition TString.h:139
R__EXTERN REveManager * gEve
unsigned int ElementId_t
Definition REveTypes.hxx:27
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...