Logo ROOT   master
Reference Guide
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 
17 #include <ROOT/RWebDisplayArgs.hxx>
18 
19 #include "TSysEvtHandler.h"
20 #include "TTimer.h"
21 
22 #include <memory>
23 #include <unordered_map>
24 
25 class TMap;
26 class TExMap;
27 class TMacro;
28 class TFolder;
29 class TGeoManager;
30 
31 namespace ROOT {
32 namespace Experimental {
33 
34 class REveSelection;
35 class REveViewer;
36 class REveViewerList;
37 class REveScene;
38 class REveSceneList;
39 
40 class RWebWindow;
41 class REveGeomViewer;
42 
44 {
45  REveManager(const REveManager&) = delete;
46  REveManager& operator=(const REveManager&) = delete;
47 
48 public:
50  private:
51  RRedrawDisabler(const RRedrawDisabler &) = delete;
52  RRedrawDisabler &operator=(const RRedrawDisabler &) = delete;
53 
54  REveManager *fMgr{nullptr};
55 
56  public:
58  {
59  if (fMgr)
61  }
62  virtual ~RRedrawDisabler()
63  {
64  if (fMgr)
65  fMgr->EnableRedraw();
66  }
67  };
68 
70  public:
72  virtual ~RExceptionHandler() { Remove(); }
73 
74  virtual EStatus Handle(std::exception& exc);
75 
77  };
78 
79  struct Conn
80  {
81  unsigned fId{0};
82 
83  Conn() = default;
84  Conn(unsigned int cId) : fId(cId) {}
85  };
86 
87 protected:
88  RExceptionHandler *fExcHandler{nullptr}; //!< exception handler
89 
90  TMap *fVizDB{nullptr};
93 
94  TMap *fGeometries{nullptr}; // TODO: use std::map<std::string, std::unique_ptr<TGeoManager>>
95  TMap *fGeometryAliases{nullptr}; // TODO: use std::map<std::string, std::string>
96 
97  TFolder *fMacroFolder{nullptr};
98 
99  REveScene *fWorld{nullptr};
100 
103 
106 
114 
115  // ElementId management
116  std::unordered_map<ElementId_t, REveElement*> fElementIdMap;
119  ElementId_t fMaxElementIds{std::numeric_limits<ElementId_t>::max()};
120 
121  // Selection / highlight elements
125 
126  std::shared_ptr<ROOT::Experimental::RWebWindow> fWebWindow;
127  std::vector<Conn> fConnList;
128 
129  void WindowConnect(unsigned connid);
130  void WindowData(unsigned connid, const std::string &arg);
131  void WindowDisconnect(unsigned connid);
132 
133 public:
134  REveManager(); // (Bool_t map_window=kTRUE, Option_t* opt="FI");
135  virtual ~REveManager();
136 
138 
139  REveSelection *GetSelection() const { return fSelection; }
140  REveSelection *GetHighlight() const { return fHighlight; }
141 
142  REveSceneList *GetScenes() const { return fScenes; }
143  REveViewerList *GetViewers() const { return fViewers; }
144 
145  REveScene *GetGlobalScene() const { return fGlobalScene; }
146  REveScene *GetEventScene() const { return fEventScene; }
147 
148  REveScene *GetWorld() const { return fWorld; }
149 
150  REveViewer *SpawnNewViewer(const char *name, const char *title = "");
151  REveScene *SpawnNewScene(const char *name, const char *title = "");
152 
153  TFolder *GetMacroFolder() const { return fMacroFolder; }
154  TMacro *GetMacro(const char *name) const;
155 
158 
159  void Redraw3D(Bool_t resetCameras = kFALSE, Bool_t dropLogicals = kFALSE)
160  {
162  if (resetCameras) fResetCameras = kTRUE;
163  if (dropLogicals) fDropLogicals = kTRUE;
164  }
165  void RegisterRedraw3D();
166  void DoRedraw3D();
167  void FullRedraw3D(Bool_t resetCameras = kFALSE, Bool_t dropLogicals = kFALSE);
168 
169  void ClearAllSelections();
170 
173 
174  void AddElement(REveElement *element, REveElement *parent = nullptr);
175  void AddGlobalElement(REveElement *element, REveElement *parent = nullptr);
176 
177  void RemoveElement(REveElement* element, REveElement *parent);
178 
180  void AssignElementId (REveElement* element);
181  void PreDeleteElement(REveElement* element);
182  void BrowseElement(ElementId_t id);
183 
184  // VizDB - Visualization-parameter data-base.
185  Bool_t InsertVizDBEntry(const TString& tag, REveElement* model,
186  Bool_t replace, Bool_t update);
187  Bool_t InsertVizDBEntry(const TString& tag, REveElement* model);
188  REveElement *FindVizDBEntry (const TString& tag);
189 
190  void LoadVizDB(const TString& filename, Bool_t replace, Bool_t update);
191  void LoadVizDB(const TString& filename);
192  void SaveVizDB(const TString& filename);
193 
195  Bool_t GetVizDBUpdate () const { return fVizDBUpdate; }
198 
199 
200  // Geometry management.
201  TGeoManager *GetGeometry(const TString& filename);
202  TGeoManager *GetGeometryByAlias(const TString& alias);
204  void RegisterGeometryAlias(const TString& alias, const TString& filename);
205 
206  void ClearROOTClassSaved();
207 
208  void AddLocation(const std::string& name, const std::string& path);
209  void SetDefaultHtmlPage(const std::string& path);
210  void SetClientVersion(const std::string& version);
211 
212  static REveManager* Create();
213  static void Terminate();
214 
215  // Access to internals, needed for low-level control in advanced
216  // applications.
217 
219 
220  // void Send(void* buff, unsigned connid);
221  void Send(unsigned connid, const std::string &data);
222  void SendBinary(unsigned connid, const void *data, std::size_t len);
223 
225 
227 
228  void Show(const RWebDisplayArgs &args = "");
229 
230  std::shared_ptr<REveGeomViewer> ShowGeometry(const RWebDisplayArgs &args = "");
231 };
232 
234 
235 }}
236 
237 #endif
A TFolder object is a collection of objects and folders.
Definition: TFolder.h:30
R__EXTERN REveManager * gEve
void WindowData(unsigned connid, const std::string &arg)
Process data from web window.
The manager class for any TGeo geometry.
Definition: TGeoManager.h:44
auto * m
Definition: textangle.C:8
REveViewer Reve representation of TGLViewer.
Definition: REveViewer.hxx:27
Returns the available number of logical cores.
Definition: StringConv.hxx:21
std::shared_ptr< ROOT::Experimental::RWebWindow > fWebWindow
RExceptionHandler * GetExcHandler() const
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
TFolder * GetMacroFolder() const
virtual EStatus Handle(std::exception &exc)
Handle exceptions deriving from REveException.
void RemoveElement(REveElement *element, REveElement *parent)
Remove element from parent.
void AddLocation(const std::string &name, const std::string &path)
Register new directory to THttpServer.
REveManager & operator=(const REveManager &)=delete
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:31
void PreDeleteElement(REveElement *element)
Called from REveElement prior to its destruction so the framework components (like object editor) can...
virtual void Remove()
Remove std::exception handler from system handler list.
Basic string class.
Definition: TString.h:131
bool Bool_t
Definition: RtypesCore.h:61
REveViewerList * GetViewers() const
std::unordered_map< ElementId_t, REveElement * > fElementIdMap
void RegisterRedraw3D()
Register a request for 3D redraw.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
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 LoadVizDB(const TString &filename, Bool_t replace, Bool_t update)
Load visualization-parameter database from file filename.
REveSelection * GetSelection() const
std::shared_ptr< REveGeomViewer > ShowGeometry(const RWebDisplayArgs &args="")
Show current geometry in web browser.
void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Perform 3D redraw of all scenes and viewers.
virtual ~REveManager()
Destructor.
#define ClassDef(name, id)
Definition: Rtypes.h:322
void BroadcastElementsOf(REveElement::List_t &els)
REveScene * GetEventScene() const
void SendBinary(unsigned connid, const void *data, std::size_t len)
void RegisterGeometryAlias(const TString &alias, const TString &filename)
Register &#39;name&#39; as an alias for geometry file &#39;filename&#39;.
REveElement * FindElementById(ElementId_t id) const
Lookup ElementId in element map and return corresponding REveElement*.
REveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
TGeoManager * GetGeometryByAlias(const TString &alias)
Get geometry with given alias.
TMacro * GetMacro(const char *name) const
Find macro in fMacroFolder by name.
std::list< REveElement * > List_t
Definition: REveElement.hxx:87
TGeoManager * GetGeometry(const TString &filename)
Get geometry with given filename.
REveSelection * GetHighlight() const
ROOT::R::TRInterface & r
Definition: Object.C:4
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
REveSceneList * GetScenes() const
static REveManager * Create()
If global REveManager* REX::gEve is not set initialize it.
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
void AssignElementId(REveElement *element)
Assign a unique ElementId to given element.
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
RExceptionHandler * fExcHandler
exception handler
Definition: REveManager.hxx:88
RRedrawDisabler(const RRedrawDisabler &)=delete
void DestroyElementsOf(REveElement::List_t &els)
unsigned int ElementId_t
Definition: REveTypes.hxx:25
const Bool_t kFALSE
Definition: RtypesCore.h:90
REveElement * FindVizDBEntry(const TString &tag)
Find a visualization-parameter database entry corresponding to tag.
void WindowConnect(unsigned connid)
Process new connection from web window.
REveScene * GetGlobalScene() const
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
void Send(unsigned connid, const std::string &data)
REveViewerList List of Viewers providing common operations on REveViewer collections.
Definition: REveViewer.hxx:52
void AddElement(REveElement *element, REveElement *parent=nullptr)
Add an element.
std::vector< Conn > fConnList
void ClearAllSelections()
Clear all selection objects.
REveViewer * SpawnNewViewer(const char *name, const char *title="")
Create a new GL viewer.
static void Terminate()
Properly terminate global REveManager.
#define R__EXTERN
Definition: DllImport.h:27
void ClearROOTClassSaved()
Work-around uber ugly hack used in SavePrimitive and co.
void BrowseElement(ElementId_t id)
Activate EVE browser (summary view) for specified element id.
Bool_t InsertVizDBEntry(const TString &tag, REveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
void DoRedraw3D()
Perform 3D redraw of scenes and viewers whose contents has changed.
void WindowDisconnect(unsigned connid)
Process disconnect of web window.
REveSelection Container for selected and highlighted elements.
RRedrawDisabler & operator=(const RRedrawDisabler &)=delete
const Bool_t kTRUE
Definition: RtypesCore.h:89
virtual void Add()
Add std::exception handler to system handler list.
char name[80]
Definition: TGX11.cxx:109
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
void SaveVizDB(const TString &filename)
Save visualization-parameter database to file filename.
TGeoManager * GetDefaultGeometry()
Get the default geometry.
REveScene * GetWorld() const
void SetDefaultHtmlPage(const std::string &path)
Set content of default window HTML page.
void AddGlobalElement(REveElement *element, REveElement *parent=nullptr)
Add a global element, i.e.