Logo ROOT   6.19/01
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&); // Not implemented
46  REveManager& operator=(const REveManager&); // Not implemented
47 
48 public:
50  private:
51  RRedrawDisabler(const RRedrawDisabler &); // Not implemented
52  RRedrawDisabler &operator=(const RRedrawDisabler &); // Not implemented
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 
183  // VizDB - Visualization-parameter data-base.
184  Bool_t InsertVizDBEntry(const TString& tag, REveElement* model,
185  Bool_t replace, Bool_t update);
186  Bool_t InsertVizDBEntry(const TString& tag, REveElement* model);
187  REveElement* FindVizDBEntry (const TString& tag);
188 
189  void LoadVizDB(const TString& filename, Bool_t replace, Bool_t update);
190  void LoadVizDB(const TString& filename);
191  void SaveVizDB(const TString& filename);
192 
194  Bool_t GetVizDBUpdate () const { return fVizDBUpdate; }
197 
198 
199  // Geometry management.
200  TGeoManager* GetGeometry(const TString& filename);
201  TGeoManager* GetGeometryByAlias(const TString& alias);
203  void RegisterGeometryAlias(const TString& alias, const TString& filename);
204 
205  void ClearROOTClassSaved();
206 
207  void AddLocation(const std::string& name, const std::string& path);
208  void SetDefaultHtmlPage(const std::string& path);
209  void SetClientVersion(const std::string& version);
210 
211  static REveManager* Create();
212  static void Terminate();
213 
214  // Access to internals, needed for low-level control in advanced
215  // applications.
216 
218 
219  // void Send(void* buff, unsigned connid);
220  void Send(unsigned connid, const std::string &data);
221  void SendBinary(unsigned connid, const void *data, std::size_t len);
222 
224 
226 
227  void Show(const RWebDisplayArgs &args = "");
228 
229  std::shared_ptr<REveGeomViewer> ShowGeometry(const RWebDisplayArgs &args = "");
230 };
231 
233 
234 }}
235 
236 #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:42
auto * m
Definition: textangle.C:8
REveViewer Reve representation of TGLViewer.
Definition: REveViewer.hxx:27
VSD Structures.
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.
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
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:326
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:77
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
void DestroyElementsOf(REveElement::List_t &els)
unsigned int ElementId_t
Definition: REveTypes.hxx:25
const Bool_t kFALSE
Definition: RtypesCore.h:88
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.
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.
RRedrawDisabler & operator=(const RRedrawDisabler &)
void WindowDisconnect(unsigned connid)
Process disconnect of web window.
REveSelection Container for selected and highlighted elements.
const Bool_t kTRUE
Definition: RtypesCore.h:87
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.
REveManager & operator=(const REveManager &)