Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveManager.cxx
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#include <ROOT/REveManager.hxx>
13
14#include <ROOT/REveCamera.hxx>
15#include <ROOT/REveUtil.hxx>
17#include <ROOT/REveViewer.hxx>
18#include <ROOT/REveScene.hxx>
20#include <ROOT/REveClient.hxx>
21#include <ROOT/RWebWindow.hxx>
22#include <ROOT/RLogger.hxx>
23#include <ROOT/REveSystem.hxx>
26#include <ROOT/REveText.hxx>
27
28#include "TGeoManager.h"
29#include "TGeoMatrix.h"
30#include "TObjString.h"
31#include "TROOT.h"
32#include "TSystem.h"
33#include "TFile.h"
34#include "TMap.h"
35#include "TExMap.h"
36#include "TEnv.h"
37#include "TError.h"
38#include "TColor.h"
39#include "TPRegexp.h"
40#include "TClass.h"
41#include "TMethod.h"
42#include "TMethodCall.h"
43#include "THttpServer.h"
44#include "TTimer.h"
45#include "TApplication.h"
46
47#include "REveAssetDir.hxx"
48
49#include <exception>
50#include <fstream>
51#include <memory>
52#include <sstream>
53#include <iostream>
54#include <regex>
55#include <system_error>
56#include <thread>
57
58#if defined(R__LINUX) || defined(R__MACOSX)
59#include <pthread.h>
60#endif
61
62#include <nlohmann/json.hpp>
63
64using namespace ROOT::Experimental;
65namespace REX = ROOT::Experimental;
66
67REveManager *REX::gEve = nullptr;
68
70{
71 std::vector<REveScene*> addedWatch;
72 std::vector<REveScene*> removedWatch;
73
74 void reset() {
75 addedWatch.clear();
76 removedWatch.clear();
77 }
78};
79
80thread_local std::vector<ROOT::RLogEntry> gEveLogEntries;
82
83namespace {
84
85/// Stack size of the calling thread in bytes, or 0 if it cannot be determined.
86size_t CurrentThreadStackSize()
87{
88#if defined(R__LINUX)
89 size_t size = 0;
90 pthread_attr_t attr;
91 if (pthread_getattr_np(pthread_self(), &attr) == 0) {
92 pthread_attr_getstacksize(&attr, &size);
93 pthread_attr_destroy(&attr);
94 }
95 return size;
96#elif defined(R__MACOSX)
97 return pthread_get_stacksize_np(pthread_self());
98#else
99 return 0;
100#endif
101}
102
103} // namespace
104
105/** \class REveManager
106\ingroup REve
107\ingroup webwidgets
108
109\brief Central application manager for web-based REve.
110
111Manages elements, GUI, GL scenes and GL viewers.
112
113Following parameters can be specified in .rootrc file
114
115WebEve.GLViewer: Three # kind of GLViewer, either Three, JSRoot or RCore
116WebEve.DisableShow: 1 # do not start new web browser when REveManager::Show is called
117WebEve.HTimeout: 200 # timeout in ms for elements highlight
118WebEve.DblClick: Off # mouse double click handling in GL viewer: Off or Reset
119WebEve.TableRowHeight: 33 # size of each row in pixels in the Table view, can be used to make design more compact
120*/
121
122////////////////////////////////////////////////////////////////////////////////
123
124REveManager::REveManager()
125 : // (Bool_t map_window, Option_t* opt) :
126 fExcHandler(nullptr), fVizDB(nullptr), fVizDBReplace(kTRUE), fVizDBUpdate(kTRUE), fGeometries(nullptr),
127 fGeometryAliases(nullptr),
128 fKeepEmptyCont(kFALSE)
129{
130 // Constructor.
131
132 static const REveException eh("REveManager::REveManager ");
133
134 if (REX::gEve)
135 throw eh + "There can be only one REve!";
136
137 REX::gEve = this;
138
140 fServerStatus.fTStart = std::time(nullptr);
141
143
144 fGeometries = new TMap;
148 fVizDB = new TMap;
150
151 fElementIdMap[0] = nullptr; // do not increase count for null element.
152
153 fWorld = new REveScene("EveWorld", "Top-level Eve Scene");
156
157 fSelectionList = new REveElement("Selection List");
158 fSelectionList->SetChildClass(TClass::GetClass<REveSelection>());
161 fSelection = new REveSelection("Global Selection", "", kRed, kViolet);
162 fSelection->SetIsMaster(true);
165 fHighlight = new REveSelection("Global Highlight", "", kGreen, kCyan);
166 fHighlight->SetIsMaster(true);
170
171 fViewers = new REveViewerList("Viewers");
174
175 fScenes = new REveSceneList("Scenes");
178
179 // --------------------------------
180 // Create camera list
181 // --------------------------------
182 fCameras = new REveElement("Cameras", "Camera list");
185
186 fGlobalScene = new REveScene("Geometry scene");
189
190 fEventScene = new REveScene("Event scene");
193
194 {
195 REveViewer *v = SpawnNewViewer("Default Viewer");
196 v->AddScene(fGlobalScene);
197 v->AddScene(fEventScene);
198 }
199
200 // !!! AMT increase threshold to enable color pick on client
202
203 // allow multiple connections
205
207 fWebWindow->UseServerThreads();
208 fWebWindow->SetDefaultPage("file:rootui5sys/eve7/index.html");
209
210 // Serve the SDF font and image directories, which can be set before the manager exists.
211 REX::Internal::REveAssetDir::RegisterAll();
212
213 const char *gl_viewer = gEnv->GetValue("WebEve.GLViewer", "RCore");
214 const char *gl_dblclick = gEnv->GetValue("WebEve.DblClick", "Off");
215 Int_t htimeout = gEnv->GetValue("WebEve.HTimeout", 250);
216 Int_t table_row_height = gEnv->GetValue("WebEve.TableRowHeight", 0);
217 fWebWindow->SetUserArgs(Form("{ GLViewer: \"%s\", DblClick: \"%s\", HTimeout: %d, TableRowHeight: %d }", gl_viewer,
218 gl_dblclick, htimeout, table_row_height));
219
220 if (strcmp(gl_viewer, "RCore") == 0)
221 fIsRCore = true;
222
223 // this is call-back, invoked when message received via websocket
224 fWebWindow->SetCallBacks([this](unsigned connid) { WindowConnect(connid); },
225 [this](unsigned connid, const std::string &arg) { WindowData(connid, arg); },
226 [this](unsigned connid) { WindowDisconnect(connid); });
227 fWebWindow->SetGeometry(900, 700); // configure predefined window geometry
228 fWebWindow->SetConnLimit(100); // maximal number of connections
229 fWebWindow->SetMaxQueueLength(1000); // number of allowed entries in the window queue
230
231 // The hover tooltip of GL viewers is drawn with this SDF font. Asserting it
232 // also serves the sdf-fonts/ location, which otherwise only happens when an
233 // REveText or viewer axes are created.
234 {
235 std::string fn = "LiberationSerif-Regular";
236 REveText::AssertSdfFont(fn, std::string(TROOT::GetDataDir().Data()) + "/fonts/" + fn + ".ttf");
237 }
238
239 fMIRExecThread = std::thread{[this] { MIRExecThread(); }};
240
241 // activate interpreter error report
242 gInterpreter->ReportDiagnosticsToErrorHandler();
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Destructor.
248
250{
251 fMIRExecThread.join();
252
253 // QQQQ How do we stop THttpServer / fWebWindow?
254
259 // Not needed - no more top-items: fScenes->Destroy();
260 fScenes = nullptr;
261
264 // Not needed - no more top-items: fViewers->Destroy();
265 fViewers = nullptr;
266
267 // fWindowManager->DestroyWindows();
268 // fWindowManager->DecDenyDestroy();
269 // fWindowManager->Destroy();
270 // fWindowManager = 0;
271
274
275 delete fGeometryAliases;
276 delete fGeometries;
277 delete fVizDB;
278 delete fExcHandler;
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Create a new GL viewer.
283
284REveViewer *REveManager::SpawnNewViewer(const char *name, const char *title)
285{
286 REveViewer *v = new REveViewer(name, title);
288 return v;
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Create a new scene.
293
294REveScene *REveManager::SpawnNewScene(const char *name, const char *title)
295{
296 REveScene *s = new REveScene(name, title);
298 return s;
299}
300
302{
303 printf("REveManager::RegisterRedraw3D() obsolete\n");
304}
305
306////////////////////////////////////////////////////////////////////////////////
307/// Perform 3D redraw of scenes and viewers whose contents has
308/// changed.
309
311{
312 printf("REveManager::DoRedraw3D() obsolete\n");
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Perform 3D redraw of all scenes and viewers.
317
318void REveManager::FullRedraw3D(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
319{
320 printf("REveManager::FullRedraw3D() obsolete\n");
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Clear all selection objects. Can make things easier for EVE when going to
325/// the next event. Still, destruction os selected object should still work
326/// correctly as long as it is executed within a change cycle.
327
329{
330 for (auto el : fSelectionList->fChildren) {
331 dynamic_cast<REveSelection *>(el)->ClearSelection();
332 }
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Add an element. If parent is not specified it is added into
337/// current event (which is created if does not exist).
338
340{
341 if (parent == nullptr) {
342 // XXXX
343 }
344
345 parent->AddElement(element);
346}
347
348////////////////////////////////////////////////////////////////////////////////
349/// Add a global element, i.e. one that does not change on each
350/// event, like geometry or projection manager.
351/// If parent is not specified it is added to a global scene.
352
354{
355 if (!parent)
356 parent = fGlobalScene;
357
358 parent->AddElement(element);
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Remove element from parent.
363
365{
366 parent->RemoveElement(element);
367}
368
369////////////////////////////////////////////////////////////////////////////////
370/// Lookup ElementId in element map and return corresponding REveElement*.
371/// Returns nullptr if the id is not found
372
374{
375 auto it = fElementIdMap.find(id);
376 return (it != fElementIdMap.end()) ? it->second : nullptr;
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Assign a unique ElementId to given element.
381
383{
384 static const REveException eh("REveManager::AssignElementId ");
385
387 throw eh + "ElementId map is full.";
388
389next_free_id:
390 while (fElementIdMap.find(++fLastElementId) != fElementIdMap.end())
391 ;
392 if (fLastElementId == 0)
393 goto next_free_id;
394 // MT - alternatively, we could spawn a thread to find next thousand or so ids and
395 // put them in a vector of ranges. Or collect them when they are freed.
396 // Don't think this won't happen ... online event display can run for months
397 // and easily produce 100000 objects per minute -- about a month to use up all id space!
398
399 element->fElementId = fLastElementId;
400 fElementIdMap.insert(std::make_pair(fLastElementId, element));
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Activate EVE browser (summary view) for specified element id
406
408{
409 nlohmann::json msg = {};
410 msg["content"] = "BrowseElement";
411 msg["id"] = id;
412
413 fWebWindow->Send(0, msg.dump());
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Ask every connected client to grab its GL viewers and POST each image to an
418/// image collector. Each client posts the views it shows, all tagged with the
419/// same `event_id`.
420///
421/// The body is `application/octet-stream`, width*height*4 bytes of RGBA8 with
422/// straight alpha and no background, so it composites onto any backdrop.
423/// Headers X-Width, X-Height, X-Event-ID and X-View-Type describe it; X-Flip-Y
424/// is 1 when the rows are in WebGL bottom-up order. RenderCore's
425/// util/image-gator.js is a reference receiver. The default collector is on
426/// loopback; a remote one needs TLS and authentication.
427///
428/// \param event_id tag recorded with the image, e.g. run/lumi/event
429/// \param url collector endpoint; empty takes rootrc `WebEve.ImageGatorUrl`,
430/// which defaults to http://localhost:3000/capture
431/// \param scale multiplier on the viewer viewport; 1 is what the operator sees
432/// \param viewers restrict to these viewer names; empty means all of them
433
434void REveManager::GrabImages(std::string_view event_id, std::string_view url, int scale,
435 const std::vector<std::string> &viewers)
436{
437 std::string dest(url);
438 if (dest.empty())
439 dest = gEnv->GetValue("WebEve.ImageGatorUrl", "http://localhost:3000/capture");
440
441 nlohmann::json msg = {};
442 // clang-format off
443 msg["content"] = "GrabImage";
444 msg["event_id"] = std::string(event_id);
445 msg["url"] = dest;
446 msg["scale"] = scale;
447 msg["viewers"] = viewers;
448 // clang-format on
449
450 fWebWindow->Send(0, msg.dump());
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Called from REveElement prior to its destruction so the
455/// framework components (like object editor) can unreference it.
456
458{
459 if (el->fImpliedSelected > 0) {
460 for (auto slc : fSelectionList->fChildren) {
461 REveSelection *sel = dynamic_cast<REveSelection *>(slc);
462 sel->RemoveImpliedSelectedReferencesTo(el);
463 }
464
465 if (el->fImpliedSelected != 0)
466 Error("REveManager::PreDeleteElement", "ImpliedSelected not zero (%d) after cleanup of selections.",
467 el->fImpliedSelected);
468 }
469 // Primary selection deregistration is handled through Niece removal from Aunts.
470
471 if (el->fElementId != 0) {
472 auto it = fElementIdMap.find(el->fElementId);
473 if (it != fElementIdMap.end()) {
474 if (it->second == el) {
475 fElementIdMap.erase(it);
477 } else
478 Error("PreDeleteElement", "element ptr in ElementIdMap does not match the argument element.");
479 } else
480 Error("PreDeleteElement", "element id %u was not registered in ElementIdMap.", el->fElementId);
481 } else
482 Error("PreDeleteElement", "element with 0 ElementId passed in.");
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Insert a new visualization-parameter database entry. Returns
487/// true if the element is inserted successfully.
488/// If entry with the same key already exists the behaviour depends on the
489/// 'replace' flag:
490/// - true - The old model is deleted and new one is inserted (default).
491/// Clients of the old model are transferred to the new one and
492/// if 'update' flag is true (default), the new model's parameters
493/// are assigned to all clients.
494/// - false - The old model is kept, false is returned.
495///
496/// If insert is successful, the ownership of the model-element is
497/// transferred to the manager.
498
500{
501 TPair *pair = (TPair *)fVizDB->FindObject(tag);
502 if (pair) {
503 if (replace) {
504 model->IncDenyDestroy();
505 model->SetRnrChildren(kFALSE);
506
507 REveElement *old_model = dynamic_cast<REveElement *>(pair->Value());
508 if (old_model) {
509 while (old_model->HasChildren()) {
510 REveElement *el = old_model->FirstChild();
511 el->SetVizModel(model);
512 if (update) {
513 el->CopyVizParams(model);
515 }
516 }
517 old_model->DecDenyDestroy();
518 }
519 pair->SetValue(dynamic_cast<TObject *>(model));
520 return kTRUE;
521 } else {
522 return kFALSE;
523 }
524 } else {
525 model->IncDenyDestroy();
526 model->SetRnrChildren(kFALSE);
527 fVizDB->Add(new TObjString(tag), dynamic_cast<TObject *>(model));
528 return kTRUE;
529 }
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Insert a new visualization-parameter database entry with the default
534/// parameters for replace and update, as specified by members
535/// fVizDBReplace(default=kTRUE) and fVizDBUpdate(default=kTRUE).
536/// See docs of the above function.
537
542
543////////////////////////////////////////////////////////////////////////////////
544/// Find a visualization-parameter database entry corresponding to tag.
545/// If the entry is not found 0 is returned.
546
548{
549 return dynamic_cast<REveElement *>(fVizDB->GetValue(tag));
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Load visualization-parameter database from file filename. The
554/// replace, update arguments replace the values of fVizDBReplace
555/// and fVizDBUpdate members for the duration of the macro
556/// execution.
557
559{
560 Bool_t ex_replace = fVizDBReplace;
561 Bool_t ex_update = fVizDBUpdate;
562 fVizDBReplace = replace;
564
566
567 fVizDBReplace = ex_replace;
568 fVizDBUpdate = ex_update;
569}
570
571////////////////////////////////////////////////////////////////////////////////
572/// Load visualization-parameter database from file filename.
573/// State of data-members fVizDBReplace and fVizDBUpdate determine
574/// how the registered entries are handled.
575
581
582////////////////////////////////////////////////////////////////////////////////
583/// Save visualization-parameter database to file filename.
584
586{
587 TPMERegexp re("(.+)\\.\\w+");
588 if (re.Match(filename) != 2) {
589 Error("SaveVizDB", "filename does not match required format '(.+)\\.\\w+'.");
590 return;
591 }
592
593 TString exp_filename(filename);
594 gSystem->ExpandPathName(exp_filename);
595
596 std::ofstream out(exp_filename, std::ios::out | std::ios::trunc);
597 out << "void " << re[1] << "()\n";
598 out << "{\n";
599 out << " REveManager::Create();\n";
600
602
603 Int_t var_id = 0;
604 TString var_name;
605 TIter next(fVizDB);
606 TObjString *key;
607 while ((key = (TObjString *)next())) {
608 REveElement *mdl = dynamic_cast<REveElement *>(fVizDB->GetValue(key));
609 if (mdl) {
610 var_name.Form("x%03d", var_id++);
611 mdl->SaveVizParams(out, key->String(), var_name);
612 } else {
613 Warning("SaveVizDB", "Saving failed for key '%s'.", key->String().Data());
614 }
615 }
616
617 out << "}\n";
618 out.close();
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// Get geometry with given filename.
623/// This is cached internally so the second time this function is
624/// called with the same argument the same geo-manager is returned.
625/// gGeoManager is set to the return value.
626
628{
629 static const REveException eh("REveManager::GetGeometry ");
630
631 TString exp_filename = filename;
632 gSystem->ExpandPathName(exp_filename);
633 printf("REveManager::GetGeometry loading: '%s' -> '%s'.\n", filename.Data(), exp_filename.Data());
634
636 if (gGeoManager) {
638 } else {
639 Bool_t locked = TGeoManager::IsLocked();
640 if (locked) {
641 Warning("REveManager::GetGeometry", "TGeoManager is locked ... unlocking it.");
643 }
644 if (TGeoManager::Import(filename) == nullptr) {
645 throw eh + "TGeoManager::Import() failed for '" + exp_filename + "'.";
646 }
647 if (locked) {
649 }
650
652
653 // Import colors exported by Gled, if they exist.
654 {
655 TFile f(exp_filename, "READ");
656 TObjArray *collist = (TObjArray *)f.Get("ColorList");
657 f.Close();
658 if (collist) {
660 TGeoVolume *vol;
661 while ((vol = (TGeoVolume *)next()) != nullptr) {
662 Int_t oldID = vol->GetLineColor();
663 TColor *col = (TColor *)collist->At(oldID);
664 Float_t r, g, b;
665 col->GetRGB(r, g, b);
666 Int_t newID = TColor::GetColor(r, g, b);
667 vol->SetLineColor(newID);
668 }
669 }
670 }
671
673 }
674 return gGeoManager;
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// Get geometry with given alias.
679/// The alias must be registered via RegisterGeometryAlias().
680
682{
683 static const REveException eh("REveManager::GetGeometry ");
684
685 TObjString *full_name = (TObjString *)fGeometryAliases->GetValue(alias);
686 if (!full_name)
687 throw eh + "geometry alias '" + alias + "' not registered.";
688 return GetGeometry(full_name->String());
689}
690
691////////////////////////////////////////////////////////////////////////////////
692/// Get the default geometry.
693/// It should be registered via RegisterGeometryName("Default", `<URL>`).
694
699
700////////////////////////////////////////////////////////////////////////////////
701/// Get the default viewer.
702///
703
705{
706 return dynamic_cast<REveViewer*>(fViewers->FirstChild());
707}
708
709////////////////////////////////////////////////////////////////////////////////
710/// Utility function to allow remote RWebWindow connections.
711/// Disable loopback when use remote client.
712/// Authentification key has to be disabled in the case of multiple connections.
713/// The default arguments prevent remote connections for the security reasons.
714//
715void REveManager::AllowMultipleRemoteConnections(bool loopBack, bool requireAuthKey)
716{
718 fWebWindow->SetRequireAuthKey(requireAuthKey);
719}
720
721////////////////////////////////////////////////////////////////////////////////
722/// Register 'name' as an alias for geometry file 'filename'.
723/// The old aliases are silently overwritten.
724/// After that the geometry can be retrieved also by calling:
725/// REX::gEve->GetGeometryByName(name);
726
731
732////////////////////////////////////////////////////////////////////////////////
733/// Work-around uber ugly hack used in SavePrimitive and co.
734
736{
737 gROOT->ResetClassSaved();
738}
739
740////////////////////////////////////////////////////////////////////////////////
741/// Register new directory to THttpServer
742// For example: AddLocation("mydir/", "/test/EveWebApp/ui5");
743//
744void REveManager::AddLocation(const std::string &locationName, const std::string &path)
745{
746 fWebWindow->GetServer()->AddLocation(locationName.c_str(), path.c_str());
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Set content of default window HTML page
751// Got example: SetDefaultHtmlPage("file:currentdir/test.html")
752//
753void REveManager::SetDefaultHtmlPage(const std::string &path)
754{
755 fWebWindow->SetDefaultPage(path);
756}
757
758////////////////////////////////////////////////////////////////////////////////
759/// Set client version, used as prefix in scripts URL
760/// When changed, web browser will reload all related JS files while full URL will be different
761/// Default is empty value - no extra string in URL
762/// Version should be string like "1.2" or "ver1.subv2" and not contain any special symbols
763void REveManager::SetClientVersion(const std::string &version)
764{
765 fWebWindow->SetClientVersion(version);
766}
767
768////////////////////////////////////////////////////////////////////////////////
769/// If global REveManager* REX::gEve is not set initialize it.
770/// Returns REX::gEve.
771
773{
774 static const REveException eh("REveManager::Create ");
775
776 if (!REX::gEve) {
777 // XXXX Initialize some server stuff ???
778
779 REX::gEve = new REveManager();
780 }
781 return REX::gEve;
782}
783
784////////////////////////////////////////////////////////////////////////////////
785/// Properly terminate global REveManager.
786
788{
789 if (!REX::gEve)
790 return;
791
792 delete REX::gEve;
793 REX::gEve = nullptr;
794}
795
796void REveManager::ExecuteInMainThread(std::function<void()> func)
797{
798 class XThreadTimer : public TTimer {
799 std::function<void()> foo_;
800 public:
801 XThreadTimer(std::function<void()> f) : foo_(f)
802 {
803 SetTime(0);
805 gSystem->AddTimer(this);
806 }
807 Bool_t Notify() override
808 {
809 foo_();
810 gSystem->RemoveTimer(this);
811 delete this;
812 return kTRUE;
813 }
814 };
815
816 new XThreadTimer(func);
817}
818
820{
822 // QQQQ Should call Terminate() but it needs to:
823 // - properly stop MIRExecThread;
824 // - shutdown civet/THttp/RWebWindow
826 });
827}
828
829////////////////////////////////////////////////////////////////////////////////
830/// Process new connection from web window.
831///
832/// This is called in a web-server thread, which can have a small stack (the
833/// builtin civetweb uses 100 KB unless configured otherwise). Streaming the
834/// scenes can need much more: the first IsA() of an element class makes cling
835/// load declarations, which recurses deeply. If the current thread's stack is
836/// small, the streaming runs in a thread with the default stack size instead,
837/// and this thread waits for it.
838
839void REveManager::WindowConnect(unsigned connid)
840{
841 static constexpr size_t kMinStackSize = 1024 * 1024;
842
843 size_t stack_size = CurrentThreadStackSize();
844 if (stack_size == 0 || stack_size >= kMinStackSize) {
845 StreamToNewConnection(connid);
846 return;
847 }
848
849 // An exception is passed back to this thread, where it would have appeared before.
850 std::exception_ptr exc;
851 std::thread thrd;
852 try {
853 thrd = std::thread([this, connid, &exc] {
854#if defined(R__LINUX)
855 pthread_setname_np(pthread_self(), "eve_connect");
856#endif
857 try {
858 StreamToNewConnection(connid);
859 } catch (...) {
860 exc = std::current_exception();
861 }
862 });
863 } catch (const std::system_error &e) {
864 ::Warning("REveManager::WindowConnect",
865 "could not start streaming thread (%s), streaming in the web-server thread with stack size %zu",
866 e.what(), stack_size);
867 StreamToNewConnection(connid);
868 return;
869 }
870 thrd.join();
871 if (exc)
872 std::rethrow_exception(exc);
873}
874
875////////////////////////////////////////////////////////////////////////////////
876/// Register new connection and stream the world and the mandatory scenes to it.
877
879{
880 std::unique_lock<std::mutex> lock(fServerState.fMutex);
881
883 {
884 fServerState.fCV.wait(lock);
885 }
886
887 fConnList.emplace_back(connid);
888 printf("connection established %u\n", connid);
889
890 // QQQQ do we want mir-time here as well? maybe set it at the end of function?
891 // Note, this is all under lock, so nobody will get state out in between.
892 fServerStatus.fTLastMir = fServerStatus.fTLastConnect = std::time(nullptr);
894
895 // This prepares core and render data buffers.
896 printf("\nEVEMNG ............. streaming the world scene.\n");
897
898 fWorld->AddSubscriber(std::make_unique<REveClient>(connid, fWebWindow));
900
901 printf(" sending json, len = %d\n", (int)fWorld->fOutputJson.size());
903 Send(connid, fWorld->fOutputJson);
904 printf(" for now assume world-scene has no render data, binary-size=%d\n", fWorld->fTotalBinarySize);
905 assert(fWorld->fTotalBinarySize == 0);
906 // Sent to this connection only; the next SendSceneChanges() must not send
907 // it to everyone again.
909
910 for (auto &c : fScenes->RefChildren()) {
911 REveScene *scene = dynamic_cast<REveScene *>(c);
912 if (!scene->GetMandatory())
913 continue;
914
915 scene->AddSubscriber(std::make_unique<REveClient>(connid, fWebWindow));
916 printf("\nEVEMNG ............. streaming scene %s [%s]\n", scene->GetCTitle(), scene->GetCName());
917
918 // This prepares core and render data buffers.
919 scene->StreamElements();
920
921 printf(" sending json, len = %d\n", (int)scene->fOutputJson.size());
923 Send(connid, scene->fOutputJson);
924
925 if (scene->fTotalBinarySize > 0) {
926 printf(" sending binary, len = %d\n", scene->fTotalBinarySize);
927 SendBinary(connid, &scene->fOutputBinary[0], scene->fTotalBinarySize);
928 } else {
929 printf(" NOT sending binary, len = %d\n", scene->fTotalBinarySize);
930 }
931 scene->ClearOutput();
932 }
933
934 fServerState.fCV.notify_all();
935}
936
937////////////////////////////////////////////////////////////////////////////////
938/// Process disconnect of web window
939
940void REveManager::WindowDisconnect(unsigned connid)
941{
942 std::unique_lock<std::mutex> lock(fServerState.fMutex);
943 auto conn = fConnList.end();
944 for (auto i = fConnList.begin(); i != fConnList.end(); ++i) {
945 if (i->fId == connid) {
946 conn = i;
947 break;
948 }
949 }
950 // this should not happen, just check
951 if (conn == fConnList.end()) {
952 printf("error, connection not found!");
953 } else {
954 printf("connection closed %u\n", connid);
955 fConnList.erase(conn);
956 for (auto &c : fScenes->RefChildren()) {
957 REveScene *scene = dynamic_cast<REveScene *>(c);
958 scene->RemoveSubscriber(connid);
959 }
960 fWorld->RemoveSubscriber(connid);
961 }
962
963 // User case: someone can close browser tab as clients are updateding
964 // note if scene changes are in progess the new serverstate will be changes after finish those
966 {
967 if (fPendingSceneChanges && !fConnList.empty()) {
968 // The closed connection was the last one busy: send the changes held
969 // back for it, as its acknowledgement would have.
970 fPendingSceneChanges = false;
973 } else {
974 // No one left to send to; the stamps stay for the next EndChange().
975 fPendingSceneChanges = false;
977 }
978 fServerState.fCV.notify_all();
979 }
980
981 fServerStatus.fTLastDisconnect = std::time(nullptr);
983
984 fServerState.fCV.notify_all();
985}
986
987////////////////////////////////////////////////////////////////////////////////
988/// Process data from web window
989
990void REveManager::WindowData(unsigned connid, const std::string &arg)
991{
992 static const REveException eh("REveManager::WindowData ");
993
994 // find connection object
995 bool found = false;
996 for (auto &conn : fConnList) {
997 if (conn.fId == connid) {
998 found = true;
999 break;
1000 }
1001 }
1002
1003 // this should not happen, just check
1004 if (!found) {
1005 R__LOG_ERROR(REveLog()) << "Internal error - no connection with id " << connid << " found";
1006 return;
1007 }
1008
1009
1010 if (arg.compare("__REveDoneChanges") == 0)
1011 {
1012 // client status data
1013 std::unique_lock<std::mutex> lock(fServerState.fMutex);
1014
1015 for (auto &conn : fConnList) {
1016 if (conn.fId == connid) {
1017 conn.fState = Conn::Free;
1018 break;
1019 }
1020 }
1021
1024 // Changes stamped while the previous ones were in flight. Sending
1025 // them leaves the clients busy again.
1026 fPendingSceneChanges = false;
1029 } else {
1031 }
1032 fServerState.fCV.notify_all();
1033 }
1034
1035 return;
1036 }
1038 {
1039 if (fHttpPublic)
1040 {
1041 R__LOG_INFO(REveLog()) << "REveManager::WindowData, file dialog is not allowed in restriced public mode";
1042 }
1043 else
1044 {
1046 }
1047 return;
1048 }
1049 else if (arg.compare(0, 11, "SETCHANNEL:") == 0) {
1050 std::string s = arg.substr(11);
1051 auto p = s.find(",");
1052 int eveid = std::stoi(s.substr(0, p));
1053 int chid = std::stoi(s.substr(p+1));
1054
1055 REveElement* n = FindElementById(eveid);
1056 auto nn = dynamic_cast<REveGeoTopNodeData*>(n);
1057 if (nn) nn->SetChannel(connid, chid);
1058
1059 return;
1060 }
1061
1062 nlohmann::json cj = nlohmann::json::parse(arg);
1063 if (gDebug > 0)
1064 ::Info("REveManager::WindowData", "MIR test %s\n", cj.dump().c_str());
1065
1066 std::string cmd = cj["mir"];
1067 int id = cj["fElementId"];
1068 std::string ctype = cj["class"];
1069
1070 ScheduleMIR(cmd, id, ctype, connid);
1071}
1072
1073//
1074//____________________________________________________________________
1075void REveManager::ScheduleMIR(const std::string &cmd, ElementId_t id, const std::string& ctype, unsigned connid)
1076{
1077 std::unique_lock<std::mutex> lock(fServerState.fMutex);
1078 fServerStatus.fTLastMir = std::time(nullptr);
1079 fMIRqueue.push(std::make_shared<MIR>(cmd, id, ctype, connid));
1080
1081 if (fMIRqueue.size() > 5)
1082 std::cout << "Warning, REveManager::ScheduleMIR(). queue size " << fMIRqueue.size() << std::endl;
1083
1085 fServerState.fCV.notify_all();
1086}
1087
1088//
1089//____________________________________________________________________
1090void REveManager::ExecuteMIR(std::shared_ptr<MIR> mir)
1091{
1092 static const REveException eh(""); // Empty -- all errors go to R__LOG
1093
1094 //if (gDebug > 0)
1095 ::Info("REveManager::ExecuteCommand", "MIR cmd %s", mir->fCmd.c_str());
1096
1097 std::string tag = mir->fCtype + "::<to-be-determined>";
1098
1099 try {
1100 REveElement *el = FindElementById(mir->fId);
1101 if ( ! el) throw eh + "Element with id " + mir->fId + " not found";
1102
1103 static const std::regex cmd_re("^(\\w[\\w\\d]*)\\(\\s*(.*)\\s*\\)\\s*;?\\s*$", std::regex::optimize);
1104 std::smatch m;
1105 std::regex_search(mir->fCmd, m, cmd_re);
1106 if (m.size() != 3)
1107 throw eh + "Command string parse error: '" + mir->fCmd + "'.";
1108
1109 static const TClass *elem_cls = TClass::GetClass<REX::REveElement>();
1110
1111 TClass *call_cls = TClass::GetClass(mir->fCtype.c_str());
1112 if ( ! call_cls)
1113 throw eh + "Class '" + mir->fCtype + "' not found.";
1114
1115 void *el_casted = call_cls->DynamicCast(elem_cls, el, false);
1116 if ( ! el_casted)
1117 throw eh + "Dynamic cast from REveElement to '" + mir->fCtype + "' failed.";
1118
1119 tag = mir->fCtype + "::" + m.str(1);
1120
1121 std::shared_ptr<TMethodCall> mc;
1122 auto mmi = fMethCallMap.find(tag);
1123 if (mmi != fMethCallMap.end())
1124 {
1125 mc = mmi->second;
1126 }
1127 else
1128 {
1129 const TMethod *meth = call_cls->GetMethodAllAny(m.str(1).c_str());
1130 if ( ! meth)
1131 throw eh + "Can not find TMethod matching '" + m.str(1) + "'.";
1132 mc = std::make_shared<TMethodCall>(meth);
1133 fMethCallMap.insert(std::make_pair(tag, mc));
1134 }
1135
1137
1139 mc->Execute(el_casted, m.str(2).c_str());
1140
1142 R__LOG_ERROR(REveLog()) << eh << "error executing " << tag << ":" << REveElement::stlMirErrorString << " (code " << REveElement::stlMirError << ").";
1143 }
1145
1146 // Alternative implementation through Cling. "Leaks" 200 kB per call.
1147 // This might be needed for function calls that involve data-types TMethodCall
1148 // can not handle.
1149 // std::stringstream cmd;
1150 // cmd << "((" << mir->fCtype << "*)" << std::hex << std::showbase << (size_t)el << ")->" << mir->fCmd << ";";
1151 // std::cout << cmd.str() << std::endl;
1152 // gROOT->ProcessLine(cmd.str().c_str());
1153 } catch (std::exception &e) {
1154 R__LOG_ERROR(REveLog()) << "caught exception executing " << tag << ": " << e.what();
1155 } catch (...) {
1156 R__LOG_ERROR(REveLog()) << "caught unknown execption.";
1157 }
1158}
1159
1160// Write scene change into scenes's internal json member
1162{
1164
1165 for (auto &el : fScenes->RefChildren())
1166 {
1167 REveScene* s = dynamic_cast<REveScene*>(el);
1169 }
1170}
1171
1172////////////////////////////////////////////////////////////////////////////////
1173/// Send transformation-only changes on the motion channel: the same websocket,
1174/// outside the BeginChanges/EndChanges cycle, with no acknowledgement. The
1175/// message is sent directly, so it goes only when every connection can take a
1176/// direct send. Otherwise the elements stay stamped and go out with the
1177/// regular changes, which carry the same matrix and motion. The motion's t0 is
1178/// stamped by REveTrans::SetMotion(), so the delay does not shift the
1179/// trajectory.
1180
1182{
1183 if (fConnList.empty())
1184 return;
1185
1186 for (auto &conn : fConnList)
1187 if (!fWebWindow->CanSend(conn.fId, true))
1188 return;
1189
1190 nlohmann::json arr = nlohmann::json::array();
1191
1193 for (auto &el : fScenes->RefChildren()) {
1194 auto s = dynamic_cast<REveScene *>(el);
1195 if (s)
1196 s->StreamMotionChanges(arr);
1197 }
1198
1199 if (arr.empty())
1200 return;
1201
1202 nlohmann::json msg = {};
1203 // clang-format off
1204 msg["content"] = "Motion";
1205 msg["els"] = arr;
1206 // clang-format on
1207
1208 std::string data = msg.dump();
1210
1211 for (auto &conn : fConnList) {
1213 fWebWindow->Send(conn.fId, data);
1214 }
1215}
1216
1217////////////////////////////////////////////////////////////////////////////////
1218// Send json and binary data to scene's connections
1220{
1221 // send begin message
1222 nlohmann::json jobj = {};
1223 jobj["content"] = "BeginChanges";
1224 SendToAllConnections(jobj.dump());
1225
1226 // send the change json
1228
1229 for (auto &el : fScenes->RefChildren())
1230 {
1231 REveScene* s = dynamic_cast<REveScene*>(el);
1233 }
1234
1235 // send end changes message and log messages
1236 jobj["content"] = "EndChanges";
1237
1238 if (!gEveLogEntries.empty()) {
1239 constexpr static int numLevels = static_cast<int>(ELogLevel::kDebug) + 1;
1240 constexpr static std::array<const char *, numLevels> sTag{
1241 {"{unset-error-level please report}", "FATAL", "Error", "Warning", "Info", "Debug"}};
1242
1243 jobj["log"] = nlohmann::json::array();
1244 std::stringstream strm;
1245 for (auto entry : gEveLogEntries) {
1246 strm.str("");
1247 nlohmann::json item = {};
1248 item["lvl"] = entry.fLevel;
1249 int cappedLevel = std::min(static_cast<int>(entry.fLevel), numLevels - 1);
1250 strm << "Server " << sTag[cappedLevel] << ":";
1251
1252 if (!entry.fLocation.fFuncName.empty())
1253 strm << " " << entry.fLocation.fFuncName;
1254 strm << " " << entry.fMessage;
1255 item["msg"] = strm.str();
1256 jobj["log"].push_back(item);
1257 }
1258 gEveLogEntries.clear();
1259 }
1260 SendToAllConnections(jobj.dump());
1261}
1262
1263//
1264//____________________________________________________________________
1266{
1267#if defined(R__LINUX)
1268 pthread_setname_np(pthread_self(), "mir_exec");
1269#endif
1270 while (true)
1271 {
1272 std::unique_lock<std::mutex> lock(fServerState.fMutex);
1273 underlock:
1275 {
1276 fServerState.fCV.wait(lock);
1277 goto underlock;
1278 }
1279 else
1280 {
1281 // set server state and update the queue under lock
1282 //
1284 std::shared_ptr<MIR> mir = fMIRqueue.front();
1285
1286 // reset local thread related data
1287 gMIRData.reset();
1288 fMIRqueue.pop();
1289
1290 lock.unlock();
1291
1292 // Ideally, as in gled, MIR execution would be steered by scenes themselves.
1293 // But this requires alpha/beta/gamma MIR elements and scene dependenices,
1294 // so dependent scenes can be locked, too.
1295 // On top of that, one could also implements authorization framework, as in gled.
1296
1299
1300 ExecuteMIR(mir);
1301
1304
1306
1307 // send changes (need to access client connection list) and set the state under lock
1308 //
1309 lock.lock();
1310
1311 // disconnect requested scene from clients
1312 for (auto &scene : gMIRData.removedWatch)
1313 scene->RemoveSubscriber(mir->fConnId);
1314
1315
1316 // connect and stream scenes to new clients
1317 for (auto &scene : gMIRData.addedWatch) {
1318 scene->AddSubscriber(std::make_unique<REveClient>(mir->fConnId, fWebWindow));
1319 scene->StreamElements();
1320 Send(mir->fConnId, scene->fOutputJson);
1321 if (scene->fTotalBinarySize > 0)
1322 SendBinary(mir->fConnId, &scene->fOutputBinary[0], scene->fTotalBinarySize);
1323 // Streamed to this connection only; SendSceneChanges() below must
1324 // not send it to every subscriber.
1325 scene->ClearOutput();
1326 }
1327
1329
1331 fServerState.fCV.notify_all();
1332 }
1333 }
1334}
1335
1336//____________________________________________________________________
1338{
1339 for (auto &c : view->RefChildren()) {
1340 REveSceneInfo *sinfo = dynamic_cast<REveSceneInfo *>(c);
1341 std::cout << "Disconnect scee " << sinfo->GetScene()->GetName();
1342 gMIRData.removedWatch.push_back(sinfo->GetScene());
1343 }
1344}
1345//____________________________________________________________________
1347{
1348 view->StampObjProps();
1349 for (auto &c : view->RefChildren()) {
1350 REveSceneInfo *sinfo = dynamic_cast<REveSceneInfo *>(c);
1351 std::cout << "Connect scene " << sinfo->GetScene()->GetName();
1352 gMIRData.addedWatch.push_back(sinfo->GetScene());
1353 }
1354}
1355
1356//____________________________________________________________________
1358{
1359 for (auto &conn : fConnList) {
1360 fWebWindow->Send(conn.fId, data);
1361 }
1362}
1363
1364void REveManager::Send(unsigned connid, const std::string &data)
1365{
1366 fWebWindow->Send(connid, data);
1367}
1368
1369void REveManager::SendBinary(unsigned connid, const void *data, std::size_t len)
1370{
1371 fWebWindow->SendBinary(connid, data, len);
1372}
1373
1374////////////////////////////////////////////////////////////////////////////////
1375/// Is there anything stamped and not yet streamed?
1376
1378{
1379 if (fWorld->IsChanged())
1380 return true;
1381
1382 for (auto &el : fScenes->RefChildren()) {
1383 auto s = dynamic_cast<REveScene *>(el);
1384 if (s && s->IsChanged())
1385 return true;
1386 }
1387 return false;
1388}
1389
1390////////////////////////////////////////////////////////////////////////////////
1391
1393{
1394 for (auto &conn : fConnList) {
1395 if (conn.fState != Conn::Free)
1396 return false;
1397 }
1398
1399 return true;
1400}
1401
1402// called from REveScene::SendChangesToSubscribers
1404{
1405 for (auto &conn : fConnList) {
1406 if (conn.fId == cinnId)
1407 {
1408 conn.fState = Conn::WaitingResponse;
1409 break;
1410 }
1411 }
1412}
1413
1414//////////////////////////////////////////////////////////////////
1415/// Show eve manager in specified browser.
1416
1417/// If rootrc variable WebEve.DisableShow is set, HTTP server will be
1418/// started and access URL printed on stdout.
1419
1421{
1422 if (gEnv->GetValue("WebEve.DisableShow", 0) != 0) {
1423 std::string url = fWebWindow->GetUrl(true);
1424 printf("EVE URL %s\n", url.c_str());
1425 } else {
1426 fWebWindow->Show(args);
1427 }
1428}
1429
1430
1431//____________________________________________________________________
1433{
1434 // set server state and tag scenes to begin accepting changees
1435 {
1436 std::unique_lock<std::mutex> lock(fServerState.fMutex);
1438 fServerState.fCV.wait(lock);
1439 }
1441 }
1444}
1445
1446//____________________________________________________________________
1447/// Stop accepting changes and stream them. If the clients have not yet
1448/// acknowledged the previous changes, keep the stamps and let the last
1449/// acknowledgement in WindowData() flush them. Stamps coalesce per element.
1450/// Motion changes are sent in either case when the connections can take a
1451/// direct send, see SendMotionChanges(). Changes made by a MIR are not held
1452/// back.
1453
1455{
1456 // tag scene to disable accepting chages, write the change json
1459
1460 std::unique_lock<std::mutex> lock(fServerState.fMutex);
1461
1462 // Motion is outside the change cycle, so it is sent even when changes
1463 // are held. What cannot be sent now stays stamped and goes with them.
1465
1466 if (!fConnList.empty() && !ClientConnectionsFree()) {
1467 // Previous changes not yet acknowledged. Leave everything stamped.
1468 if (AnySceneChanged())
1469 fPendingSceneChanges = true;
1470
1472 fServerState.fCV.notify_all();
1473 return;
1474 }
1475
1478 fPendingSceneChanges = false;
1479
1481 fServerState.fCV.notify_all();
1482}
1483
1484//____________________________________________________________________
1486{
1487 std::unique_lock<std::mutex> lock(fServerState.fMutex);
1489#if defined(_MSC_VER)
1490 std::timespec_get(&fServerStatus.fTReport, TIME_UTC);
1491#else
1492 fServerStatus.fTReport = std::time_t(nullptr);
1493#endif
1494 st = fServerStatus;
1495}
1496
1497/** \class REveManager::ChangeGuard
1498\ingroup REve
1499RAII guard for locking Eve manager (ctor) and processing changes (dtor).
1500*/
1501
1502//////////////////////////////////////////////////////////////////////
1503//
1504// Helper struct to guard update mechanism
1505//
1510
1515
1516// gInterpreter error handlder
1517void REveManager::ErrorHandler(Int_t level, Bool_t abort, const char * location, const char *msg)
1518{
1519 if (level >= kError)
1520 {
1522 entry.fMessage = msg;
1523 gEveLogEntries.emplace_back(entry);
1524 }
1525 ::DefaultErrorHandler(level, abort, location, msg);
1526}
1527
1528/** \class REveManager::RExceptionHandler
1529\ingroup REve
1530Exception handler for Eve exceptions.
1531*/
1532
1533////////////////////////////////////////////////////////////////////////////////
1534/// Handle exceptions deriving from REveException.
1535
1537{
1538 REveException *ex = dynamic_cast<REveException *>(&exc);
1539 if (ex) {
1540 Info("Handle", "Exception %s", ex->what());
1541 // REX::gEve->SetStatusLine(ex->Data());
1542 gSystem->Beep();
1543 return kSEHandled;
1544 }
1545 return kSEProceed;
1546}
1547
1548
1549////////////////////////////////////////////////////////////////////////////////
1550/// Utility to stream loggs to client.
1551/// Return false to supress further emission
1552
1554{
1555 gEveLogEntries.emplace_back(entry);
1556 return false;
1557}
1558
1559
1560////////////////////////////////////////////////////////////////////////////////
1561/// Restrict functionality for this server when open to public
1562
1564{
1565 R__LOG_INFO(REveLog()) << "Set public mode to " << x <<".";
1566 fHttpPublic = x;
1567}
thread_local std::vector< ROOT::RLogEntry > gEveLogEntries
thread_local MIR_TL_Data_t gMIRData
#define R__LOG_ERROR(...)
Definition RLogger.hxx:356
#define R__LOG_INFO(...)
Definition RLogger.hxx:358
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define e(i)
Definition RSha256.hxx:103
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kCyan
Definition Rtypes.h:66
@ kViolet
Definition Rtypes.h:67
R__EXTERN TApplication * gApplication
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
void DefaultErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
The default error handler function.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Definition TError.cxx:92
winID h TVirtualViewer3D TVirtualGLPainter p
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 dest
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 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 sel
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
char name[80]
Definition TGX11.cxx:142
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:538
R__EXTERN TVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD_CLING(mutex)
#define gInterpreter
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:792
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2571
R__EXTERN TVirtualMutex * gSystemMutex
Definition TSystem.h:254
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define R__LOCKGUARD2(mutex)
void DecDenyDestroy()
Decreases the deny-destroy count of the element.
const std::string & GetName() const
void SaveVizParams(std::ostream &out, const TString &tag, const TString &var)
Save visualization parameters for this element with given tag.
const char * GetCTitle() const
const char * GetCName() const
virtual void AddElement(REveElement *el)
Add el to the list of children.
static thread_local int stlMirError
virtual void DestroyElements()
Destroy all children of this element.
REveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
static void SetMirContext(REveElement *el)
void IncDenyDestroy()
Increases the deny-destroy count of the element.
static thread_local std::string stlMirErrorString
virtual void CopyVizParams(const REveElement *el)
Copy visualization parameters from element el.
void SetVizModel(REveElement *model)
Set visualization-parameter model element.
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
virtual void PropagateVizParamsToProjecteds()
Propagate visualization parameters to dependent elements.
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:42
void SetChannel(unsigned connid, int chid)
bool Emit(const RLogEntry &entry) override
Utility to stream loggs to client.
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.
void StreamToNewConnection(unsigned connid)
Register new connection and stream the world and the mandatory scenes to it.
void SendToAllConnections(const std::string &data)
std::shared_ptr< ROOT::RWebWindow > fWebWindow
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 GrabImages(std::string_view event_id, std::string_view url="", int scale=1, const std::vector< std::string > &viewers={})
Ask every connected client to grab its GL viewers and POST each image to an image collector.
void GetServerStatus(REveServerStatus &)
void SetDefaultHtmlPage(const std::string &path)
Set content of default window HTML page.
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.
void EndChange()
Stop accepting changes and stream them.
TGeoManager * GetGeometryByAlias(const TString &alias)
Get geometry with given alias.
bool AnySceneChanged() const
Is there anything stamped and not yet streamed?
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.
void SendMotionChanges()
Send transformation-only changes on the motion channel: the same websocket, outside the BeginChanges/...
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 *)
static void ErrorHandler(Int_t level, Bool_t abort, const char *location, const char *msg)
bool fPendingSceneChanges
Changes are stamped but not yet streamed, because the clients had not acknowledged the previous scene...
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.
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.
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.
void BrowseElement(ElementId_t id)
Activate EVE browser (summary view) for specified element id.
void WindowData(unsigned connid, const std::string &arg)
Process data from web window.
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
REveSceneInfo Scene in a viewer.
void BeginAcceptingChanges()
Loop-wrapers over Scene children, element type checked on insertion.
void DestroyScenes()
Destroy all scenes and their contents.
void AddSubscriber(std::unique_ptr< REveClient > &&sub)
Definition REveScene.cxx:70
void ClearOutput()
Drop the output of the last StreamElements() or StreamRepresentationChanges() once it has been sent,...
std::vector< char > fOutputBinary
!
Definition REveScene.hxx:76
void StreamRepresentationChanges()
Prepare data for sending element changes.
void StreamMotionChanges(nlohmann::json &arr)
Move every element whose only pending change is kCBTrans from the change list into arr,...
void RemoveSubscriber(unsigned int)
Definition REveScene.cxx:81
REveSelection Container for selected and highlighted elements.
static bool AssertSdfFont(const std::string &font_name, const std::string &ttf_font)
Check if font exists, otherwise try to create it.
Definition REveText.cxx:251
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition REveUtil.cxx:144
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 StampServerTime(std::string &msg)
Set the "server_time" that AppendServerTime() put at the end of msg to now.
Definition REveUtil.cxx:76
REveViewerList List of Viewers providing common operations on REveViewer collections.
void AddElement(REveElement *el) override
Call base-class implementation.
REveViewer Reve representation of TGLViewer.
A diagnostic that can be emitted by the RLogManager.
Definition RLogger.hxx:174
std::string fMessage
Definition RLogger.hxx:177
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
static bool EmbedFileDialog(const std::shared_ptr< RWebWindow > &window, unsigned connid, const std::string &args)
Create dialog instance to use as embedded dialog inside provided widget Loads libROOTBrowserv7 and tr...
static bool IsFileDialogMessage(const std::string &msg)
Check if this could be the message send by client to start new file dialog If returns true,...
static void SetSingleConnMode(bool on=true)
Enable or disable single connection mode (default on) If enabled, one connection only with any web wi...
static void SetLoopbackMode(bool on=true)
Set loopback mode for THttpServer used for web widgets By default is on.
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
Definition TClass.cxx:5032
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
Definition TClass.cxx:4501
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2999
The color creation and management class.
Definition TColor.h:22
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition TColor.h:55
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1939
static void SetColorThreshold(Float_t t)
This method specifies the color threshold used by GetColor to retrieve a color.
Definition TColor.cxx:2008
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
An identity transformation.
Definition TGeoMatrix.h:407
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
static void UnlockGeometry()
Unlock current geometry.
TObjArray * GetListOfVolumes() const
TObjArray * GetListOfMatrices() const
static Bool_t IsLocked()
Check lock state.
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
static void LockGeometry()
Lock current geometry so that no other geometry can be imported.
TGeoVolume * GetTopVolume() const
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:45
void VisibleDaughters(Bool_t vis=kTRUE)
set visibility for daughters
void SetLineColor(Color_t lcolor) override
Set the line color.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
void Add(TObject *obj) override
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
Definition TMap.cxx:53
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
Definition TMap.cxx:351
TObject * FindObject(const char *keyname) const override
Check if a (key,value) pair exists with keyname as name of the key.
Definition TMap.cxx:214
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition TMap.cxx:235
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
An array of TObjects.
Definition TObjArray.h:31
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
Collectable string class.
Definition TObjString.h:28
TString & String()
Definition TObjString.h:48
Mother of all ROOT objects.
Definition TObject.h:42
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition TPRegexp.h:97
Class used by TMap to store (key,value) pairs.
Definition TMap.h:103
void SetValue(TObject *val)
Definition TMap.h:123
TObject * Value() const
Definition TMap.h:122
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Definition TROOT.cxx:3406
Basic string class.
Definition TString.h:137
const char * Data() const
Definition TString.h:385
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2438
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
Definition TSystem.cxx:327
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1296
virtual int GetPid()
Get process id.
Definition TSystem.cxx:721
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:474
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
Definition TSystem.cxx:2516
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:484
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Double_t ex[n]
Definition legend1.C:17
Namespace for ROOT features in testing.
Definition TROOT.h:100
ROOT::RLogChannel & REveLog()
Log channel for Eve diagnostics.
Definition REveTypes.cxx:52
R__EXTERN REveManager * gEve
@ kDebug
Debug information; only useful for developers; can have added verbosity up to 255-kDebug.
@ kError
An error.
std::vector< REveScene * > removedWatch
std::vector< REveScene * > addedWatch
TMarker m
Definition textangle.C:8