Logo ROOT   6.14/05
Reference Guide
TEveManager.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 "TEveManager.h"
13 
14 #include "TEveSelection.h"
15 #include "TEveViewer.h"
16 #include "TEveScene.h"
17 #include "TEveEventManager.h"
18 #include "TEveWindowManager.h"
19 
20 #include "TEveBrowser.h"
21 #include "TEveGedEditor.h"
22 
23 #include "TGStatusBar.h"
24 
25 #include "TGLSAViewer.h"
26 
27 #include "TGeoManager.h"
28 #include "TGeoMatrix.h"
29 #include "TObjString.h"
30 #include "TROOT.h"
31 #include "TFile.h"
32 #include "TMap.h"
33 #include "TExMap.h"
34 #include "TMacro.h"
35 #include "TFolder.h"
36 #include "TBrowser.h"
37 #include "TCanvas.h"
38 #include "TSystem.h"
39 #include "TRint.h"
40 #include "TVirtualX.h"
41 #include "TEnv.h"
42 #include "TColor.h"
43 #include "TVirtualGL.h"
44 #include "TPluginManager.h"
45 #include "TPRegexp.h"
46 #include "TClass.h"
47 
48 #include "Riostream.h"
49 
51 
52 /** \class TEveManager
53 \ingroup TEve
54 Central application manager for Eve.
55 Manages elements, GUI, GL scenes and GL viewers.
56 */
57 
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 
63  fExcHandler (0),
64  fVizDB (0), fVizDBReplace(kTRUE), fVizDBUpdate(kTRUE),
65  fGeometries (0),
66  fGeometryAliases (0),
67  fBrowser (0),
68 
69  fMacroFolder (0),
70 
71  fWindowManager (0),
72  fViewers (0),
73  fScenes (0),
74  fGlobalScene (0),
75  fEventScene (0),
76  fCurrentEvent (0),
77 
78  fRedrawDisabled (0),
79  fResetCameras (kFALSE),
80  fDropLogicals (kFALSE),
81  fKeepEmptyCont (kFALSE),
82  fTimerActive (kFALSE),
83  fRedrawTimer (),
84 
85  fStampedElements(0),
86  fSelection (0),
87  fHighlight (0),
88 
89  fOrphanage (0),
90  fUseOrphanage (kFALSE)
91 {
92  // Constructor.
93  // If map_window is true, the TEveBrowser window is mapped.
94  //
95  // Option string is first parsed for the following characters:
96  // V - spawn a default GL viewer.
97  //
98  // The consumed characters are removed from the options and they
99  // are passed to TEveBrowser for creation of additional plugins.
100  //
101  // Default options: "FIV" - file-browser, command-line, GL-viewer.
102 
103 
104  static const TEveException eh("TEveManager::TEveManager ");
105 
106  if (gEve != 0)
107  throw(eh + "There can be only one!");
108 
109  gEve = this;
110 
112 
116 
117  fStampedElements = new TExMap;
118 
119  fSelection = new TEveSelection("Global Selection");
121  fHighlight = new TEveSelection("Global Highlight");
124 
125  fOrphanage = new TEveElementList("Global Orphanage");
127 
128  fRedrawTimer.Connect("Timeout()", "TEveManager", this, "DoRedraw3D()");
129  fMacroFolder = new TFolder("EVE", "Visualization macros");
130  gROOT->GetListOfBrowsables()->Add(fMacroFolder);
131 
132 
133  fWindowManager = new TEveWindowManager("WindowManager", "Manager of EVE windows");
134 
135  // Build GUI
136  fBrowser = new TEveBrowser(w, h);
137 
138  // ListTreeEditor
141  fBrowser->StopEmbedding("Eve");
143 
144  // See how many GL viewers are requested, remove from options.
145  TString str_opt(opt);
146  TPMERegexp viewer_re("V", "g");
147  Int_t viewer_count = viewer_re.Substitute(str_opt, "", kFALSE);
148 
149  // Create the main window / browse.
150  fBrowser->InitPlugins(str_opt);
151  if (map_window)
152  fBrowser->MapWindow();
153 
154  // --------------------------------
155 
158 
159  fViewers = new TEveViewerList("Viewers");
162 
163  fScenes = new TEveSceneList ("Scenes");
166 
167  fGlobalScene = new TEveScene("Geometry scene");
170 
171  fEventScene = new TEveScene("Event scene");
174 
175  for (Int_t vc = 0; vc < viewer_count; ++vc)
176  {
177  TEveViewer* v = SpawnNewViewer(Form("Viewer %d", vc+1));
179  v->AddScene(fEventScene);
180  }
181 
182  if (GetDefaultViewer())
183  {
185  }
186 
188 }
189 
190 ////////////////////////////////////////////////////////////////////////////////
191 /// Destructor.
192 
194 {
195  // Stop timer and deny further redraw requests.
196  fRedrawTimer.Stop();
198 
199  delete fCurrentEvent;
200  fCurrentEvent = 0;
201 
206  fScenes->Destroy();
207  fScenes = 0;
208 
211  fViewers->Destroy();
212  fViewers = 0;
213 
217  fWindowManager = 0;
218 
222 
223  gROOT->GetListOfBrowsables()->Remove(fMacroFolder);
224  delete fMacroFolder;
225 
226  delete fGeometryAliases;
227  delete fGeometries;
228  delete fVizDB;
229  delete fExcHandler;
230  delete fStampedElements;
231 
233 
235  fBrowser->TRootBrowser::CloseWindow();
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 /// Clear the orphanage.
240 
242 {
243  Bool_t old_state = fUseOrphanage;
246  fUseOrphanage = old_state;
247 }
248 
249 ////////////////////////////////////////////////////////////////////////////////
250 /// Get the main window, i.e. EVE-browser.
251 
253 {
254  return fBrowser;
255 }
256 
257 ////////////////////////////////////////////////////////////////////////////////
258 /// Returns the default viewer - the first one in the fViewers list.
259 
261 {
262  return dynamic_cast<TEveViewer*>(fViewers->FirstChild());
263 }
264 
265 ////////////////////////////////////////////////////////////////////////////////
266 /// Get TGLViewer of the default TEveViewer.
267 
269 {
271  return ev ? ev->GetGLViewer() : 0;
272 }
273 
274 ////////////////////////////////////////////////////////////////////////////////
275 /// Returns main object editor.
276 
278 {
279  return fLTEFrame->GetEditor();
280 }
281 
282 ////////////////////////////////////////////////////////////////////////////////
283 /// Returns main window status bar.
284 
286 {
287  return fBrowser->GetStatusBar();
288 }
289 
290 ////////////////////////////////////////////////////////////////////////////////
291 /// Add a new canvas tab.
292 
294 {
295  fBrowser->StartEmbedding(1, -1);
296  TCanvas* c = new TCanvas;
297  fBrowser->StopEmbedding(name);
298 
299  return c;
300 }
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 /// Create a new GL viewer.
304 
305 TEveViewer* TEveManager::SpawnNewViewer(const char* name, const char* title,
306  Bool_t embed)
307 {
308  TEveWindowSlot* slot = 0;
309  if (embed)
310  {
312  if (slot == 0)
313  {
314  // In principle should have some default/current container
315  // in TEveWindowManager.
316  // Also to store closed windows.
319  }
320  }
321  else
322  {
324  }
325 
326  TEveViewer* v = new TEveViewer(name, title);
327  v->SpawnGLViewer(embed ? GetEditor() : 0);
328 
329  slot->ReplaceWindow(v);
330 
331  fViewers->AddElement(v);
332 
333  return v;
334 }
335 
336 ////////////////////////////////////////////////////////////////////////////////
337 /// Create a new scene.
338 
339 TEveScene* TEveManager::SpawnNewScene(const char* name, const char* title)
340 {
341  TEveScene* s = new TEveScene(name, title);
342  AddElement(s, fScenes);
343  return s;
344 }
345 
346 ////////////////////////////////////////////////////////////////////////////////
347 /// Find macro in fMacroFolder by name.
348 
349 TMacro* TEveManager::GetMacro(const char* name) const
350 {
351  return dynamic_cast<TMacro*>(fMacroFolder->FindObject(name));
352 }
353 
354 ////////////////////////////////////////////////////////////////////////////////
355 /// Show element in default editor.
356 
358 {
359  static const TEveException eh("TEveManager::EditElement ");
360 
361  GetEditor()->DisplayElement(element);
362 }
363 
364 ////////////////////////////////////////////////////////////////////////////////
365 /// Register a request for 3D redraw.
366 
368 {
371 }
372 
373 ////////////////////////////////////////////////////////////////////////////////
374 /// Perform 3D redraw of scenes and viewers whose contents has
375 /// changed.
376 
378 {
379  static const TEveException eh("TEveManager::DoRedraw3D ");
380 
381  // printf("TEveManager::DoRedraw3D redraw triggered\n");
382 
383  // Process element visibility changes, mark relevant scenes as changed.
384  {
385  TEveElement::List_t scenes;
386  Long64_t key, value;
387  TExMapIter stamped_elements(fStampedElements);
388  while (stamped_elements.Next(key, value))
389  {
390  TEveElement *el = reinterpret_cast<TEveElement*>(key);
392  {
393  el->CollectSceneParents(scenes);
394  }
395  }
396  ScenesChanged(scenes);
397  }
398 
399  // Process changes in scenes.
402 
403  // Process changed elements again, update GUI (just editor so far,
404  // but more can come).
405  {
406  Long64_t key, value;
407  TExMapIter stamped_elements(fStampedElements);
408  while (stamped_elements.Next(key, value))
409  {
410  TEveElement *el = reinterpret_cast<TEveElement*>(key);
411  if (GetEditor()->GetModel() == el->GetEditorObject(eh))
412  EditElement(el);
414 
415  el->ClearStamps();
416  }
417  }
419  GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
420 
423 
425 }
426 
427 ////////////////////////////////////////////////////////////////////////////////
428 /// Perform 3D redraw of all scenes and viewers.
429 
430 void TEveManager::FullRedraw3D(Bool_t resetCameras, Bool_t dropLogicals)
431 {
432  fScenes ->RepaintAllScenes (dropLogicals);
433  fViewers->RepaintAllViewers(resetCameras, dropLogicals);
434 }
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// Element was changed, perform framework side action.
438 /// Called from TEveElement::ElementChanged().
439 
440 void TEveManager::ElementChanged(TEveElement* element, Bool_t update_scenes, Bool_t redraw)
441 {
442  static const TEveException eh("TEveElement::ElementChanged ");
443 
444  if (GetEditor()->GetModel() == element->GetEditorObject(eh))
445  EditElement(element);
447 
448  if (update_scenes) {
449  TEveElement::List_t scenes;
450  element->CollectSceneParents(scenes);
451  ScenesChanged(scenes);
452  }
453 
454  if (redraw)
455  Redraw3D();
456 }
457 
458 ////////////////////////////////////////////////////////////////////////////////
459 /// Mark all scenes from the given list as changed.
460 
462 {
463  for (TEveElement::List_i s=scenes.begin(); s!=scenes.end(); ++s)
464  ((TEveScene*)*s)->Changed();
465 }
466 
467 ////////////////////////////////////////////////////////////////////////////////
468 /// Mark element as changed -- it will be processed on next redraw.
469 
471 {
472  UInt_t slot;
473  if (fStampedElements->GetValue((ULong64_t) element, (Long64_t) element, slot) == 0)
474  {
475  fStampedElements->AddAt(slot, (ULong64_t) element, (Long64_t) element, 1);
476  }
477 }
478 
479 ////////////////////////////////////////////////////////////////////////////////
480 /// Get default list-tree widget.
481 
483 {
484  return fLTEFrame->fListTree;
485 }
486 
489 {
490  // Add element as a top-level to a list-tree.
491  // Only add a single copy of a render-element as a top level.
492 
493  if (lt == 0) lt = GetListTree();
494  TGListTreeItem* lti = re->AddIntoListTree(lt, (TGListTreeItem*)0);
495  if (open) lt->OpenItem(lti);
496  return lti;
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// Remove top-level element from list-tree with specified tree-item.
501 
503  TGListTree* lt, TGListTreeItem* lti)
504 {
505  static const TEveException eh("TEveManager::RemoveFromListTree ");
506 
507  if (lti->GetParent())
508  throw(eh + "not a top-level item.");
509 
510  element->RemoveFromListTree(lt, 0);
511 }
512 
513 ////////////////////////////////////////////////////////////////////////////////
514 /// Add a new event and make it the current event.
515 /// It is added into the event-scene and as a top-level list-tree
516 /// item.
517 
519 {
520  fCurrentEvent = event;
523  return AddToListTree(event, kTRUE);
524 }
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// Add an element. If parent is not specified it is added into
528 /// current event (which is created if does not exist).
529 
531 {
532  if (parent == 0) {
533  if (fCurrentEvent == 0)
534  AddEvent(new TEveEventManager("Event", "Auto-created event directory"));
535  parent = fCurrentEvent;
536  }
537 
538  parent->AddElement(element);
539 }
540 
541 ////////////////////////////////////////////////////////////////////////////////
542 /// Add a global element, i.e. one that does not change on each
543 /// event, like geometry or projection manager.
544 /// If parent is not specified it is added to a global scene.
545 
547 {
548  if (parent == 0)
549  parent = fGlobalScene;
550 
551  parent->AddElement(element);
552 }
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// Remove element from parent.
556 
558  TEveElement* parent)
559 {
560  parent->RemoveElement(element);
561 }
562 
563 ////////////////////////////////////////////////////////////////////////////////
564 /// Called from TEveElement prior to its destruction so the
565 /// framework components (like object editor) can unreference it.
566 
568 {
569  if (GetEditor()->GetEveElement() == element)
570  EditElement(0);
572 
573  if (fScenes)
575 
576  if (fStampedElements->GetValue((ULong64_t) element, (Long64_t) element) != 0)
577  fStampedElements->Remove((ULong64_t) element, (Long64_t) element);
578 
579  if (element->fImpliedSelected > 0)
581  if (element->fImpliedHighlighted > 0)
583 }
584 
585 ////////////////////////////////////////////////////////////////////////////////
586 /// Select an element.
587 /// Now it only calls EditElement() - should also update selection state.
588 
590 {
591  if (element != 0)
592  EditElement(element);
593 }
594 
595 ////////////////////////////////////////////////////////////////////////////////
596 /// Paste has been called.
597 
599 {
600  // The object to paste is taken from the editor (this is not
601  // exactly right) and handed to 'element' for pasting.
602 
603  TEveElement* src = GetEditor()->GetEveElement();
604  if (src)
605  return element->HandleElementPaste(src);
606  return kFALSE;
607 }
608 
609 ////////////////////////////////////////////////////////////////////////////////
610 /// Insert a new visualization-parameter database entry. Returns
611 /// true if the element is inserted successfully.
612 /// If entry with the same key already exists the behaviour depends on the
613 /// 'replace' flag:
614 /// - true - The old model is deleted and new one is inserted (default).
615 /// Clients of the old model are transferred to the new one and
616 /// if 'update' flag is true (default), the new model's parameters
617 /// are assigned to all clients.
618 /// - false - The old model is kept, false is returned.
619 ///
620 /// If insert is successful, the ownership of the model-element is
621 /// transferred to the manager.
622 
624  Bool_t replace, Bool_t update)
625 {
626  TPair* pair = (TPair*) fVizDB->FindObject(tag);
627  if (pair)
628  {
629  if (replace)
630  {
631  model->IncDenyDestroy();
632  model->SetRnrChildren(kFALSE);
633 
634  TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value());
635  if (old_model)
636  {
637  while (old_model->HasChildren())
638  {
639  TEveElement *el = old_model->FirstChild();
640  el->SetVizModel(model);
641  if (update)
642  {
643  el->CopyVizParams(model);
645  }
646  }
647  old_model->DecDenyDestroy();
648  }
649  pair->SetValue(dynamic_cast<TObject*>(model));
650  return kTRUE;
651  }
652  else
653  {
654  return kFALSE;
655  }
656  }
657  else
658  {
659  model->IncDenyDestroy();
660  model->SetRnrChildren(kFALSE);
661  fVizDB->Add(new TObjString(tag), dynamic_cast<TObject*>(model));
662  return kTRUE;
663  }
664 }
665 
666 ////////////////////////////////////////////////////////////////////////////////
667 /// Insert a new visualization-parameter database entry with the default
668 /// parameters for replace and update, as specified by members
669 /// fVizDBReplace(default=kTRUE) and fVizDBUpdate(default=kTRUE).
670 /// See docs of the above function.
671 
673 {
674  return InsertVizDBEntry(tag, model, fVizDBReplace, fVizDBUpdate);
675 }
676 
677 ////////////////////////////////////////////////////////////////////////////////
678 /// Find a visualization-parameter database entry corresponding to tag.
679 /// If the entry is not found 0 is returned.
680 
682 {
683  return dynamic_cast<TEveElement*>(fVizDB->GetValue(tag));
684 }
685 
686 ////////////////////////////////////////////////////////////////////////////////
687 /// Load visualization-parameter database from file filename. The
688 /// replace, update arguments replace the values of fVizDBReplace
689 /// and fVizDBUpdate members for the duration of the macro
690 /// execution.
691 
692 void TEveManager::LoadVizDB(const TString& filename, Bool_t replace, Bool_t update)
693 {
694  Bool_t ex_replace = fVizDBReplace;
695  Bool_t ex_update = fVizDBUpdate;
696  fVizDBReplace = replace;
698 
699  LoadVizDB(filename);
700 
701  fVizDBReplace = ex_replace;
702  fVizDBUpdate = ex_update;
703 }
704 
705 ////////////////////////////////////////////////////////////////////////////////
706 /// Load visualization-parameter database from file filename.
707 /// State of data-members fVizDBReplace and fVizDBUpdate determine
708 /// how the registered entries are handled.
709 
710 void TEveManager::LoadVizDB(const TString& filename)
711 {
712  TEveUtil::Macro(filename);
713  Redraw3D();
714 }
715 
716 ////////////////////////////////////////////////////////////////////////////////
717 /// Save visualization-parameter database to file filename.
718 
719 void TEveManager::SaveVizDB(const TString& filename)
720 {
721  TPMERegexp re("(.+)\\.\\w+");
722  if (re.Match(filename) != 2) {
723  Error("SaveVizDB", "filename does not match required format '(.+)\\.\\w+'.");
724  return;
725  }
726 
727  TString exp_filename(filename);
728  gSystem->ExpandPathName(exp_filename);
729 
730  std::ofstream out(exp_filename, std::ios::out | std::ios::trunc);
731  out << "void " << re[1] << "()\n";
732  out << "{\n";
733  out << " TEveManager::Create();\n";
734 
736 
737  Int_t var_id = 0;
738  TString var_name;
739  TIter next(fVizDB);
740  TObjString *key;
741  while ((key = (TObjString*)next()))
742  {
743  TEveElement* mdl = dynamic_cast<TEveElement*>(fVizDB->GetValue(key));
744  if (mdl)
745  {
746  var_name.Form("x%03d", var_id++);
747  mdl->SaveVizParams(out, key->String(), var_name);
748  }
749  else
750  {
751  Warning("SaveVizDB", "Saving failed for key '%s'.", key->String().Data());
752  }
753  }
754 
755  out << "}\n";
756  out.close();
757 }
758 
759 ////////////////////////////////////////////////////////////////////////////////
760 /// Get geometry with given filename.
761 /// This is cached internally so the second time this function is
762 /// called with the same argument the same geo-manager is returned.
763 /// gGeoManager is set to the return value.
764 
766 {
767  static const TEveException eh("TEveManager::GetGeometry ");
768 
769  TString exp_filename = filename;
770  gSystem->ExpandPathName(exp_filename);
771  printf("%s loading: '%s' -> '%s'.\n", eh.Data(),
772  filename.Data(), exp_filename.Data());
773 
775  if (gGeoManager)
776  {
777  gGeoIdentity = (TGeoIdentity*) gGeoManager->GetListOfMatrices()->At(0);
778  }
779  else
780  {
781  Bool_t locked = TGeoManager::IsLocked();
782  if (locked) {
783  Warning(eh, "TGeoManager is locked ... unlocking it.");
785  }
786  if (TGeoManager::Import(filename) == 0) {
787  throw(eh + "TGeoManager::Import() failed for '" + exp_filename + "'.");
788  }
789  if (locked) {
791  }
792 
793  gGeoManager->GetTopVolume()->VisibleDaughters(1);
794 
795  // Import colors exported by Gled, if they exist.
796  {
797  TFile f(exp_filename, "READ");
798  TObjArray* collist = (TObjArray*) f.Get("ColorList");
799  f.Close();
800  if (collist != 0) {
801  TIter next(gGeoManager->GetListOfVolumes());
802  TGeoVolume* vol;
803  while ((vol = (TGeoVolume*) next()) != 0)
804  {
805  Int_t oldID = vol->GetLineColor();
806  TColor* col = (TColor*)collist->At(oldID);
807  Float_t r, g, b;
808  col->GetRGB(r, g, b);
809  Int_t newID = TColor::GetColor(r,g,b);
810  vol->SetLineColor(newID);
811  }
812  }
813  }
814 
815  fGeometries->Add(new TObjString(filename), gGeoManager);
816  }
817  return gGeoManager;
818 }
819 
820 ////////////////////////////////////////////////////////////////////////////////
821 /// Get geometry with given alias.
822 /// The alias must be registered via RegisterGeometryAlias().
823 
825 {
826  static const TEveException eh("TEveManager::GetGeometry ");
827 
828  TObjString* full_name = (TObjString*) fGeometryAliases->GetValue(alias);
829  if (!full_name)
830  throw(eh + "geometry alias '" + alias + "' not registered.");
831  return GetGeometry(full_name->String());
832 }
833 
834 ////////////////////////////////////////////////////////////////////////////////
835 /// Get the default geometry.
836 /// It should be registered via RegisterGeometryName("Default", <URL>).
837 
839 {
840  return GetGeometryByAlias("Default");
841 }
842 
843 ////////////////////////////////////////////////////////////////////////////////
844 /// Register 'name' as an alias for geometry file 'filename'.
845 /// The old aliases are silently overwritten.
846 /// After that the geometry can be retrieved also by calling:
847 /// gEve->GetGeometryByName(name);
848 
849 void TEveManager::RegisterGeometryAlias(const TString& alias, const TString& filename)
850 {
851  fGeometryAliases->Add(new TObjString(alias), new TObjString(filename));
852 }
853 
854 ////////////////////////////////////////////////////////////////////////////////
855 /// Set the text in the right side of browser's status bar.
856 
858 {
859  fBrowser->SetStatusText(text, 1);
860 }
861 
862 ////////////////////////////////////////////////////////////////////////////////
863 /// Work-around uber ugly hack used in SavePrimitive and co.
864 
866 {
867  TIter nextcl(gROOT->GetListOfClasses());
868  TClass *cls;
869  while((cls = (TClass *)nextcl()))
870  {
872  }
873 }
874 
875 ////////////////////////////////////////////////////////////////////////////////
876 /// Close button has been clicked on EVE main window (browser).
877 /// Cleanup and terminate application.
878 
880 {
882  TEveBrowser *eb = dynamic_cast<TEveBrowser*>(mf);
883  if (eb == fBrowser)
884  {
885  mf->DontCallClose();
886  Terminate();
888  }
889 }
890 
891 ////////////////////////////////////////////////////////////////////////////////
892 /// If global TEveManager* gEve is not set initialize it.
893 /// Returns gEve.
894 
896 {
897  static const TEveException eh("TEveManager::Create ");
898 
899  if (gEve == 0)
900  {
901  // Make sure that the GUI system is initialized.
902  if (gROOT->IsBatch())
903  {
904  throw eh + "ROOT is running in batch mode.";
905  }
908  if (gROOT->IsBatch() || gClient == 0 || gClient->IsZombie())
909  {
910  throw eh + "window system not initialized.";
911  }
912 
913  Int_t w = 1024;
914  Int_t h = 768;
915 
918  gEve = new TEveManager(w, h, map_window, opt);
919  }
920  return gEve;
921 }
922 
923 ////////////////////////////////////////////////////////////////////////////////
924 /// Properly terminate global TEveManager.
925 
927 {
928  if (!gEve) return;
929 
931 
932  delete gEve;
933  gEve = 0;
934 }
935 
936 /** \class TEveManager::TExceptionHandler
937 \ingroup TEve
938 Exception handler for Eve exceptions.
939 */
940 
942 
943 ////////////////////////////////////////////////////////////////////////////////
944 /// Handle exceptions deriving from TEveException.
945 
948 {
949  TEveException* ex = dynamic_cast<TEveException*>(&exc);
950  if (ex) {
951  Info("Handle", "%s", ex->Data());
952  gEve->SetStatusLine(ex->Data());
953  gSystem->Beep();
954  return kSEHandled;
955  } else {
956  return kSEProceed;
957  }
958 }
void ElementStamped(TEveElement *element)
Mark element as changed – it will be processed on next redraw.
TEveWindowManager * fWindowManager
Definition: TEveManager.h:97
void DecDenyDestroy()
Decreases the deny-destroy count of the element.
TEveBrowser * fBrowser
Definition: TEveManager.h:92
void SetVizModel(TEveElement *model)
Set visualization-parameter model element.
A TFolder object is a collection of objects and folders.
Definition: TFolder.h:30
void Remove(ULong64_t hash, Long64_t key)
Remove entry with specified key from the TExMap.
Definition: TExMap.cxx:216
An array of TObjects.
Definition: TObjArray.h:37
TEveWindowSlot * GetCurrentWindowAsSlot() const
Return current window dynamic-casted to TEveWindowSlot.
void DisplayElement(TEveElement *re)
Show a TEveElement in editor.
Base class for event management and navigation.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:424
virtual void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1)
Start embedding external frame in the tab "pos" and tab element "subpos".
The manager class for any TGeo geometry.
Definition: TGeoManager.h:38
long long Long64_t
Definition: RtypesCore.h:69
TEveManager * gEve
Definition: TEveManager.cxx:50
TEveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
Eve representation of TGLScene.
Definition: TEveScene.h:26
void DoRedraw3D()
Perform 3D redraw of scenes and viewers whose contents has changed.
List of Viewers providing common operations on TEveViewer collections.
Definition: TEveViewer.h:79
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=0)
Create a new tab in a given tab-widget and populate it with a default window-slot.
void EditElement(TEveElement *element)
Show element in default editor.
Collectable string class.
Definition: TObjString.h:28
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Specialization of TGedEditor for proper update propagation to TEveManager.
Definition: TEveGedEditor.h:26
R__EXTERN void * gTQSender
Definition: TQObject.h:45
virtual ~TEveManager()
Destructor.
#define g(i)
Definition: RSha256.hxx:105
TEveViewerList * fViewers
Definition: TEveManager.h:98
void DestroyElementRenderers(TEveElement *element)
Loop over all scenes and remove all instances of element from them.
Definition: TEveScene.cxx:287
Bool_t HasChildren() const
Definition: TEveElement.h:169
An identity transformation.
Definition: TGeoMatrix.h:383
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
static void DestroyEditors()
Destroys all editors. Called from EVE termination.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:47
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
TEveSceneList * fScenes
Definition: TEveManager.h:99
List_t::iterator List_i
Definition: TEveElement.h:70
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
TTimer fRedrawTimer
Definition: TEveManager.h:111
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Definition: TMap.cxx:53
void IncDenyDestroy()
Increases the deny-destroy count of the element.
#define gROOT
Definition: TROOT.h:410
Specialization of TRootBrowser for Eve.
Definition: TEveBrowser.h:129
TEveGedEditor * GetEditor() const
Definition: TEveBrowser.h:115
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:31
void RegisterGeometryAlias(const TString &alias, const TString &filename)
Register &#39;name&#39; as an alias for geometry file &#39;filename&#39;.
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
Basic string class.
Definition: TString.h:131
#define gClient
Definition: TGClient.h:166
Description of TEveWindowSlot.
Definition: TEveWindow.h:301
Bool_t ElementPaste(TEveElement *element)
Paste has been called.
virtual void CollectSceneParents(List_t &scenes)
Collect all parents of class TEveScene.
virtual void Destroy()
Destroy this element.
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TEveElement * FindVizDBEntry(const TString &tag)
Find a visualization-parameter database entry corresponding to tag.
TEveScene * fEventScene
Definition: TEveManager.h:102
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=0)
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
void SaveVizDB(const TString &filename)
Save visualization-parameter database to file filename.
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Bool_t fResetCameras
Definition: TEveManager.h:107
void RemoveFromListTree(TEveElement *element, TGListTree *lt, TGListTreeItem *lti)
Remove top-level element from list-tree with specified tree-item.
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition: TColor.h:50
TEveSelection * fSelection
Definition: TEveManager.h:117
void DontCallClose()
Typically call this method in the slot connected to the CloseWindow() signal to prevent the calling o...
Definition: TGFrame.cxx:1738
virtual void PropagateVizParamsToProjecteds()
Propagate visualization parameters to dependent elements.
TEveElementList * fOrphanage
Definition: TEveManager.h:120
Bool_t fVizDBUpdate
Definition: TEveManager.h:87
A list of TEveElements.
Definition: TEveElement.h:459
TExMap * fStampedElements
Definition: TEveManager.h:114
TGeoManager * GetDefaultGeometry()
Get the default geometry.
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
void LoadVizDB(const TString &filename, Bool_t replace, Bool_t update)
Load visualization-parameter database from file filename.
TGListTree * GetListTree() const
Get default list-tree widget.
virtual void RemoveElement(TEveElement *el)
Remove el from the list of children.
TGeoManager * GetGeometryByAlias(const TString &alias)
Get geometry with given alias.
static TEveWindowSlot * CreateWindowMainFrame(TEveWindow *eve_parent=0)
Create a new main-frame and populate it with a default window-slot.
Definition: TEveWindow.cxx:977
virtual TObject * GetModel() const
Definition: TGedEditor.h:90
static void Terminate()
Properly terminate global TEveManager.
void SetStatusLine(const char *text)
Set the text in the right side of browser&#39;s status bar.
void ReplaceWindow(TEveWindow *w)
Replace this window with the passed one.
Definition: TEveWindow.cxx:819
TCanvas * AddCanvasTab(const char *name)
Add a new canvas tab.
Bool_t fDropLogicals
Definition: TEveManager.h:108
void ClearROOTClassSaved()
Work-around uber ugly hack used in SavePrimitive and co.
static Bool_t IsLocked()
Check lock state.
virtual void Start(Long_t milliSec=-1, Bool_t singleShot=kFALSE)
Starts the timer with a milliSec timeout.
Definition: TTimer.cxx:211
TMap * fGeometryAliases
Definition: TEveManager.h:90
TMap * fVizDB
Definition: TEveManager.h:85
void Info(const char *location, const char *msgfmt,...)
TExceptionHandler * fExcHandler
Definition: TEveManager.h:83
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
TGStatusBar * GetStatusBar() const
Definition: TRootBrowser.h:139
void RepaintAllViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint all viewers.
Definition: TEveViewer.cxx:457
static void SetupEnvironment()
Setup Include and Macro paths.
Definition: TEveUtil.cxx:54
void SaveVizParams(std::ostream &out, const TString &tag, const TString &var)
Save visualization parameters for this element with given tag.
virtual void DestroyElements()
Destroy all children of this element.
TObject * Value() const
Definition: TMap.h:121
void Error(const char *location, const char *msgfmt,...)
TGWindow * GetMainWindow() const
Get the main window, i.e. EVE-browser.
virtual void ClearStamps()
Definition: TEveElement.h:402
TMap * fGeometries
Definition: TEveManager.h:89
void RegisterRedraw3D()
Register a request for 3D redraw.
TGeoManager * GetGeometry(const TString &filename)
Get geometry with given filename.
void SanitizeTabCounts()
TRootBrowser keeps (somewhat unnecessarily) counters for number ob tabs on each position.
void ScenesChanged(TEveElement::List_t &scenes)
Mark all scenes from the given list as changed.
TFolder * fMacroFolder
Definition: TEveManager.h:95
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
void SetValue(TObject *val)
Definition: TMap.h:122
void ElementChanged(TEveElement *element, Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE)
Element was changed, perform framework side action.
TGListTreeItem * AddEvent(TEveEventManager *event)
Add a new event and make it the current event.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:867
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
Definition: TMap.cxx:351
void DestroyScenes()
Destroy all scenes and their contents.
Definition: TEveScene.cxx:247
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
static void NeedGraphicsLibs()
Static method.
ROOT::R::TRInterface & r
Definition: Object.C:4
static void ElementChanged(TEveElement *el)
Element was changed. Update editors showing it.
static void LockGeometry()
Lock current geometry so that no other geometry can be imported.
virtual TGListTreeItem * AddIntoListTree(TGListTree *ltree, TGListTreeItem *parent_lti)
Add this element into ltree to an already existing item parent_lti.
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
TMacro * GetMacro(const char *name) const
Find macro in fMacroFolder by name.
SVector< double, 2 > v
Definition: Dict.h:5
virtual void SetStatusText(const char *txt, Int_t col)
Set text in culumn col in status bar.
void CloseEveWindow()
Close button has been clicked on EVE main window (browser).
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
void SetHighlightMode()
Set to &#39;highlight&#39; mode.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2264
void ClearOrphanage()
Clear the orphanage.
TEveGedEditor * GetEditor() const
Returns main object editor.
TEveViewer * SpawnNewViewer(const char *name, const char *title="", Bool_t embed=kTRUE)
Create a new GL viewer.
TEveEventManager * fCurrentEvent
Definition: TEveManager.h:103
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
TGListTree * fListTree
Definition: TEveBrowser.h:94
List of Scenes providing common operations on TEveScene collections.
Definition: TEveScene.h:79
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:1758
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
virtual void AddElement(TEveElement *el)
Add el to the list of children.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
void Warning(const char *location, const char *msgfmt,...)
Make sure there is a SINGLE running TEveSelection for each selection type (select/highlight).
Definition: TEveSelection.h:21
TString & String()
Definition: TObjString.h:49
void Delete(Option_t *opt="")
Delete all entries stored in the TExMap.
Definition: TExMap.cxx:163
#define h(i)
Definition: RSha256.hxx:106
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition: TGCanvas.cxx:888
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual Bool_t RemoveFromListTree(TGListTree *ltree, TGListTreeItem *parent_lti)
Remove element from list-tree &#39;ltree&#39; where its parent item is &#39;parent_lti&#39;.
void InitializeGraphics()
Initialize the graphics environment.
void InitPlugins(Option_t *opt="FI")
Initialize standard plugins.
TGListTreeItem * GetParent() const
Definition: TGListTree.h:73
The Canvas class.
Definition: TCanvas.h:31
Class used by TMap to store (key,value) pairs.
Definition: TMap.h:102
std::list< TEveElement * > List_t
Definition: TEveElement.h:69
TGLViewer * GetGLViewer() const
Definition: TEveViewer.h:51
virtual void RemoveImpliedSelected(TEveElement *el)
Remove element from all implied-selected sets.
#define ClassImp(name)
Definition: Rtypes.h:359
UChar_t GetChangeBits() const
Definition: TEveElement.h:404
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:562
void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Perform 3D redraw of all scenes and viewers.
TText * text
static void Macro(const char *mac)
Execute macro &#39;mac&#39;. Do not reload the macro.
Definition: TEveUtil.cxx:168
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual Bool_t SetRnrChildren(Bool_t rnr)
Set render state of this element&#39;s children, i.e.
Central application manager for Eve.
Definition: TEveManager.h:49
static constexpr double s
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:332
The color creation and management class.
Definition: TColor.h:19
virtual void StopEmbedding(const char *name=0)
Definition: TRootBrowser.h:152
virtual TObject * FindObject(const char *name) const
Search object identified by name in the tree of folders inside this folder.
Definition: TFolder.cxx:310
TEveViewer * GetDefaultViewer() const
Returns the default viewer - the first one in the fViewers list.
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex &#39;this&#39; was created with.
Definition: TPRegexp.cxx:708
TEveGListTreeEditorFrame * fLTEFrame
Definition: TEveManager.h:93
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
Definition: TMap.cxx:214
R__EXTERN TGeoIdentity * gGeoIdentity
Definition: TGeoMatrix.h:478
void RepaintChangedViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint viewers that are tagged as changed.
Definition: TEveViewer.cxx:437
void RemoveElement(TEveElement *element, TEveElement *parent)
Remove element from parent.
Manager for EVE windows.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition: TPRegexp.h:97
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
Definition: TExMap.cxx:411
virtual void MapWindow()
Definition: TGFrame.h:251
void ConnectSignals()
Connect list-tree signals.
virtual void AddElement(TEveElement *el)
Call base-class implementation.
Definition: TEveViewer.cxx:358
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Bool_t fUseOrphanage
Definition: TEveManager.h:121
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
void ProcessSceneChanges(Bool_t dropLogicals, TExMap *stampMap)
Loop over all scenes and update them accordingly:
Definition: TEveScene.cxx:307
virtual EStatus Handle(std::exception &exc)
Handle exceptions deriving from TEveException.
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
#define c(i)
Definition: RSha256.hxx:101
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:235
void RepaintAllScenes(Bool_t dropLogicals)
Repaint all scenes.
Definition: TEveScene.cxx:276
Bool_t InsertVizDBEntry(const TString &tag, TEveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
virtual void Stop()
Definition: TTimer.h:93
Composite GUI frame for parallel display of a TGListTree and TEveGedEditor.
Definition: TEveBrowser.h:82
TEveScene * fGlobalScene
Definition: TEveManager.h:101
void ResetBit(UInt_t f)
Definition: TObject.h:171
TEveManager(const TEveManager &)
void ElementSelect(TEveElement *element)
Select an element.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1254
Exception handler for Eve exceptions.
Definition: TEveManager.h:71
static void ElementDeleted(TEveElement *el)
Element is being deleted. Close editors showing it.
void PreDeleteElement(TEveElement *element)
Called from TEveElement prior to its destruction so the framework components (like object editor) can...
Int_t Substitute(TString &s, const TString &r, Bool_t doDollarSubst=kTRUE)
Substitute matching part of s with r, dollar back-ref substitution is performed if doDollarSubst is t...
Definition: TPRegexp.cxx:874
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
void DestroyWindows()
Wait for all windows to shut-down.
virtual TObject * GetEditorObject(const TEveException &eh) const
Definition: TEveElement.h:197
const Bool_t kTRUE
Definition: RtypesCore.h:87
TEveElement * GetEveElement() const
Return eve-element if it is the model object.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
Bool_t fVizDBReplace
Definition: TEveManager.h:86
Double_t ex[n]
Definition: legend1.C:17
static void UnlockGeometry()
Unlock current geometry.
char name[80]
Definition: TGX11.cxx:109
static void SetupGUI()
Setup icon pictures and mime-types.
Definition: TEveUtil.cxx:97
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
Eve representation of TGLViewer.
Definition: TEveViewer.h:30
TGStatusBar * GetStatusBar() const
Returns main window status bar.
void AddAt(UInt_t slot, ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table.
Definition: TExMap.cxx:116
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:917
virtual Bool_t HandleElementPaste(TEveElement *el)
React to element being pasted or dnd-ed.
const char * Data() const
Definition: TString.h:364
TGLSAViewer * SpawnGLViewer(TGedEditor *ged=0, Bool_t stereo=kFALSE, Bool_t quad_buf=kTRUE)
Spawn new GLViewer and adopt it.
Definition: TEveViewer.cxx:155
Bool_t fTimerActive
Definition: TEveManager.h:110
virtual void AddScene(TEveScene *scene)
Add &#39;scene&#39; to the list of scenes.
Definition: TEveViewer.cxx:261
TEveSelection * fHighlight
Definition: TEveManager.h:118