Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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 "TCanvas.h"
37#include "TSystem.h"
38#include "TApplication.h"
39#include "TColor.h"
40#include "TPluginManager.h"
41#include "TPRegexp.h"
42#include "TClass.h"
43
44#include <iostream>
45#include <fstream>
46
47TEveManager *gEve = nullptr;
48
49/** \class TEveManager
50\ingroup TEve
51Central application manager for Eve.
52Manages elements, GUI, GL scenes and GL viewers.
53*/
54
55
56////////////////////////////////////////////////////////////////////////////////
57
59 fExcHandler (nullptr),
61 fGeometries (nullptr),
62 fGeometryAliases (nullptr),
63 fBrowser (nullptr),
64
65 fMacroFolder (nullptr),
66
67 fWindowManager (nullptr),
68 fViewers (nullptr),
69 fScenes (nullptr),
70 fGlobalScene (nullptr),
71 fEventScene (nullptr),
72 fCurrentEvent (nullptr),
73
79 fRedrawTimer (),
80
81 fStampedElements(nullptr),
82 fSelection (nullptr),
83 fHighlight (nullptr),
84
85 fOrphanage (nullptr),
87{
88 // Constructor.
89 // If map_window is true, the TEveBrowser window is mapped.
90 //
91 // Option string is first parsed for the following characters:
92 // V - spawn a default GL viewer.
93 //
94 // The consumed characters are removed from the options and they
95 // are passed to TEveBrowser for creation of additional plugins.
96 //
97 // Default options: "FIV" - file-browser, command-line, GL-viewer.
98
99
100 static const TEveException eh("TEveManager::TEveManager ");
101
102 if (gEve != nullptr)
103 throw(eh + "There can be only one!");
104
105 gEve = this;
106
108
109 fGeometries = new TMap; fGeometries->SetOwnerKeyValue();
110 fGeometryAliases = new TMap; fGeometryAliases->SetOwnerKeyValue();
111 fVizDB = new TMap; fVizDB->SetOwnerKeyValue();
112
114
115 fSelection = new TEveSelection("Global Selection");
116 fSelection->IncDenyDestroy();
117 fHighlight = new TEveSelection("Global Highlight");
118 fHighlight->SetHighlightMode();
119 fHighlight->IncDenyDestroy();
120
121 fOrphanage = new TEveElementList("Global Orphanage");
122 fOrphanage->IncDenyDestroy();
123
124 fRedrawTimer.Connect("Timeout()", "TEveManager", this, "DoRedraw3D()");
125 fMacroFolder = new TFolder("EVE", "Visualization macros");
126 gROOT->GetListOfBrowsables()->Add(fMacroFolder);
127
128
129 fWindowManager = new TEveWindowManager("WindowManager", "Manager of EVE windows");
130
131 // Build GUI
132 fBrowser = new TEveBrowser(w, h);
133
134 // ListTreeEditor
135 fBrowser->StartEmbedding(0);
137 fBrowser->StopEmbedding("Eve");
138 fLTEFrame->ConnectSignals();
139
140 // See how many GL viewers are requested, remove from options.
141 TString str_opt(opt);
142 TPMERegexp viewer_re("V", "g");
143 Int_t viewer_count = viewer_re.Substitute(str_opt, "", kFALSE);
144
145 // Create the main window / browse.
146 fBrowser->InitPlugins(str_opt);
147 if (map_window)
148 fBrowser->MapWindow();
149
150 // --------------------------------
151
152 fWindowManager->IncDenyDestroy();
154
155 fViewers = new TEveViewerList("Viewers");
156 fViewers->IncDenyDestroy();
158
159 fScenes = new TEveSceneList ("Scenes");
160 fScenes->IncDenyDestroy();
162
163 fGlobalScene = new TEveScene("Geometry scene");
164 fGlobalScene->IncDenyDestroy();
165 fScenes->AddElement(fGlobalScene);
166
167 fEventScene = new TEveScene("Event scene");
168 fEventScene->IncDenyDestroy();
169 fScenes->AddElement(fEventScene);
170
171 for (Int_t vc = 0; vc < viewer_count; ++vc)
172 {
173 TEveViewer* v = SpawnNewViewer(Form("Viewer %d", vc+1));
174 v->AddScene(fGlobalScene);
175 v->AddScene(fEventScene);
176 }
177
178 if (GetDefaultViewer())
179 {
181 }
182
183 gSystem->ProcessEvents();
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Destructor.
188
190{
191 // Stop timer and deny further redraw requests.
192 fRedrawTimer.Stop();
194
195 delete fCurrentEvent;
196 fCurrentEvent = nullptr;
197
198 fGlobalScene->DecDenyDestroy();
199 fEventScene->DecDenyDestroy();
200 fScenes->DestroyScenes();
201 fScenes->DecDenyDestroy();
202 fScenes->Destroy();
203 fScenes = nullptr;
204
205 fViewers->DestroyElements();
206 fViewers->DecDenyDestroy();
207 fViewers->Destroy();
208 fViewers = nullptr;
209
210 fWindowManager->DestroyWindows();
211 fWindowManager->DecDenyDestroy();
212 fWindowManager->Destroy();
213 fWindowManager = nullptr;
214
215 fOrphanage->DecDenyDestroy();
216 fHighlight->DecDenyDestroy();
217 fSelection->DecDenyDestroy();
218
219 gROOT->GetListOfBrowsables()->Remove(fMacroFolder);
220 delete fMacroFolder;
221
222 delete fGeometryAliases;
223 delete fGeometries;
224 delete fVizDB;
225 delete fExcHandler;
226 delete fStampedElements;
227
228 fLTEFrame->DeleteWindow();
229
230 fBrowser->DontCallClose();
231 fBrowser->TRootBrowser::CloseWindow();
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Clear the orphanage.
236
238{
239 Bool_t old_state = fUseOrphanage;
241 fOrphanage->DestroyElements();
242 fUseOrphanage = old_state;
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Get the main window, i.e. EVE-browser.
247
249{
250 return fBrowser;
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Returns the default viewer - the first one in the fViewers list.
255
257{
258 return dynamic_cast<TEveViewer*>(fViewers->FirstChild());
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Get TGLViewer of the default TEveViewer.
263
265{
267 return ev ? ev->GetGLViewer() : nullptr;
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Returns main object editor.
272
274{
275 return fLTEFrame->GetEditor();
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Returns main window status bar.
280
282{
283 return fBrowser->GetStatusBar();
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Add a new canvas tab.
288
290{
291 fBrowser->StartEmbedding(1, -1);
292 TCanvas* c = new TCanvas;
293 fBrowser->StopEmbedding(name);
294
295 return c;
296}
297
298////////////////////////////////////////////////////////////////////////////////
299/// Create a new GL viewer.
300
301TEveViewer* TEveManager::SpawnNewViewer(const char* name, const char* title,
302 Bool_t embed)
303{
304 TEveWindowSlot* slot = nullptr;
305 if (embed)
306 {
307 slot = fWindowManager->GetCurrentWindowAsSlot();
308 if (slot == nullptr)
309 {
310 // In principle should have some default/current container
311 // in TEveWindowManager.
312 // Also to store closed windows.
313 slot = TEveWindow::CreateWindowInTab(fBrowser->GetTabRight());
314 fBrowser->SanitizeTabCounts();
315 }
316 }
317 else
318 {
320 }
321
322 TEveViewer* v = new TEveViewer(name, title);
323 v->SpawnGLViewer(embed ? GetEditor() : nullptr);
324
325 slot->ReplaceWindow(v);
326
327 fViewers->AddElement(v);
328
329 return v;
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Create a new scene.
334
335TEveScene* TEveManager::SpawnNewScene(const char* name, const char* title)
336{
337 TEveScene* s = new TEveScene(name, title);
339 return s;
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Find macro in fMacroFolder by name.
344
346{
347 return dynamic_cast<TMacro*>(fMacroFolder->FindObject(name));
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Show element in default editor.
352
354{
355 static const TEveException eh("TEveManager::EditElement ");
356
357 GetEditor()->DisplayElement(element);
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Register a request for 3D redraw.
362
368
369////////////////////////////////////////////////////////////////////////////////
370/// Perform 3D redraw of scenes and viewers whose contents has
371/// changed.
372
374{
375 static const TEveException eh("TEveManager::DoRedraw3D ");
376
377 // printf("TEveManager::DoRedraw3D redraw triggered\n");
378
379 // Process element visibility changes, mark relevant scenes as changed.
380 {
381 TEveElement::List_t scenes;
382 Long64_t key, value;
383 TExMapIter stamped_elements(fStampedElements);
384 while (stamped_elements.Next(key, value))
385 {
386 TEveElement *el = reinterpret_cast<TEveElement*>(key);
388 {
389 el->CollectSceneParents(scenes);
390 }
391 }
392 ScenesChanged(scenes);
393 }
394
395 // Process changes in scenes.
396 fScenes ->ProcessSceneChanges(fDropLogicals, fStampedElements);
397 fViewers->RepaintChangedViewers(fResetCameras, fDropLogicals);
398
399 // Process changed elements again, update GUI (just editor so far,
400 // but more can come).
401 {
402 Long64_t key, value;
403 TExMapIter stamped_elements(fStampedElements);
404 while (stamped_elements.Next(key, value))
405 {
406 TEveElement *el = reinterpret_cast<TEveElement*>(key);
407 if (GetEditor()->GetModel() == el->GetEditorObject(eh))
408 EditElement(el);
410
411 el->ClearStamps();
412 }
413 }
414 fStampedElements->Delete();
415 GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
416
419
421}
422
423////////////////////////////////////////////////////////////////////////////////
424/// Perform 3D redraw of all scenes and viewers.
425
426void TEveManager::FullRedraw3D(Bool_t resetCameras, Bool_t dropLogicals)
427{
428 fScenes ->RepaintAllScenes (dropLogicals);
429 fViewers->RepaintAllViewers(resetCameras, dropLogicals);
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Element was changed, perform framework side action.
434/// Called from TEveElement::ElementChanged().
435
436void TEveManager::ElementChanged(TEveElement* element, Bool_t update_scenes, Bool_t redraw)
437{
438 static const TEveException eh("TEveElement::ElementChanged ");
439
440 if (GetEditor()->GetModel() == element->GetEditorObject(eh))
441 EditElement(element);
443
444 if (update_scenes) {
445 TEveElement::List_t scenes;
446 element->CollectSceneParents(scenes);
447 ScenesChanged(scenes);
448 }
449
450 if (redraw)
451 Redraw3D();
452}
453
454////////////////////////////////////////////////////////////////////////////////
455/// Mark all scenes from the given list as changed.
456
458{
459 for (TEveElement::List_i s=scenes.begin(); s!=scenes.end(); ++s)
460 ((TEveScene*)*s)->Changed();
461}
462
463////////////////////////////////////////////////////////////////////////////////
464/// Mark element as changed -- it will be processed on next redraw.
465
467{
468 UInt_t slot;
469 if (fStampedElements->GetValue((ULong64_t) element, (Long64_t) element, slot) == 0)
470 {
471 fStampedElements->AddAt(slot, (ULong64_t) element, (Long64_t) element, 1);
472 }
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Get default list-tree widget.
477
479{
480 return fLTEFrame->fListTree;
481}
482
485{
486 // Add element as a top-level to a list-tree.
487 // Only add a single copy of a render-element as a top level.
488
489 if (lt == nullptr) lt = GetListTree();
490 TGListTreeItem* lti = re->AddIntoListTree(lt, (TGListTreeItem*)nullptr);
491 if (open) lt->OpenItem(lti);
492 return lti;
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Remove top-level element from list-tree with specified tree-item.
497
499 TGListTree* lt, TGListTreeItem* lti)
500{
501 static const TEveException eh("TEveManager::RemoveFromListTree ");
502
503 if (lti->GetParent())
504 throw(eh + "not a top-level item.");
505
506 element->RemoveFromListTree(lt, nullptr);
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Add a new event and make it the current event.
511/// It is added into the event-scene and as a top-level list-tree
512/// item.
513
515{
516 fCurrentEvent = event;
517 fCurrentEvent->IncDenyDestroy();
519 return AddToListTree(event, kTRUE);
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Add an element. If parent is not specified it is added into
524/// current event (which is created if does not exist).
525
527{
528 if (parent == nullptr) {
529 if (fCurrentEvent == nullptr)
530 AddEvent(new TEveEventManager("Event", "Auto-created event directory"));
531 parent = fCurrentEvent;
532 }
533
534 parent->AddElement(element);
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Add a global element, i.e. one that does not change on each
539/// event, like geometry or projection manager.
540/// If parent is not specified it is added to a global scene.
541
543{
544 if (parent == nullptr)
545 parent = fGlobalScene;
546
547 parent->AddElement(element);
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Remove element from parent.
552
554 TEveElement* parent)
555{
556 parent->RemoveElement(element);
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Called from TEveElement prior to its destruction so the
561/// framework components (like object editor) can unreference it.
562
564{
565 if (GetEditor()->GetEveElement() == element)
566 EditElement(nullptr);
568
569 if (fScenes)
570 fScenes->DestroyElementRenderers(element);
571
572 if (fStampedElements->GetValue((ULong64_t) element, (Long64_t) element) != 0)
573 fStampedElements->Remove((ULong64_t) element, (Long64_t) element);
574
575 if (element->fImpliedSelected > 0)
576 fSelection->RemoveImpliedSelected(element);
577 if (element->fImpliedHighlighted > 0)
578 fHighlight->RemoveImpliedSelected(element);
579}
580
581////////////////////////////////////////////////////////////////////////////////
582/// Select an element.
583/// Now it only calls EditElement() - should also update selection state.
584
586{
587 if (element != nullptr)
588 EditElement(element);
589}
590
591////////////////////////////////////////////////////////////////////////////////
592/// Paste has been called.
593
595{
596 // The object to paste is taken from the editor (this is not
597 // exactly right) and handed to 'element' for pasting.
598
600 if (src)
601 return element->HandleElementPaste(src);
602 return kFALSE;
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Insert a new visualization-parameter database entry. Returns
607/// true if the element is inserted successfully.
608/// If entry with the same key already exists the behaviour depends on the
609/// 'replace' flag:
610/// - true - The old model is deleted and new one is inserted (default).
611/// Clients of the old model are transferred to the new one and
612/// if 'update' flag is true (default), the new model's parameters
613/// are assigned to all clients.
614/// - false - The old model is kept, false is returned.
615///
616/// If insert is successful, the ownership of the model-element is
617/// transferred to the manager.
618
620 Bool_t replace, Bool_t update)
621{
622 TPair* pair = (TPair*) fVizDB->FindObject(tag);
623 if (pair)
624 {
625 if (replace)
626 {
627 model->IncDenyDestroy();
628 model->SetRnrChildren(kFALSE);
629
630 TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value());
631 if (old_model)
632 {
633 while (old_model->HasChildren())
634 {
635 TEveElement *el = old_model->FirstChild();
636 el->SetVizModel(model);
637 if (update)
638 {
639 el->CopyVizParams(model);
641 }
642 }
643 old_model->DecDenyDestroy();
644 }
645 pair->SetValue(dynamic_cast<TObject*>(model));
646 return kTRUE;
647 }
648 else
649 {
650 return kFALSE;
651 }
652 }
653 else
654 {
655 model->IncDenyDestroy();
656 model->SetRnrChildren(kFALSE);
657 fVizDB->Add(new TObjString(tag), dynamic_cast<TObject*>(model));
658 return kTRUE;
659 }
660}
661
662////////////////////////////////////////////////////////////////////////////////
663/// Insert a new visualization-parameter database entry with the default
664/// parameters for replace and update, as specified by members
665/// fVizDBReplace(default=kTRUE) and fVizDBUpdate(default=kTRUE).
666/// See docs of the above function.
667
672
673////////////////////////////////////////////////////////////////////////////////
674/// Find a visualization-parameter database entry corresponding to tag.
675/// If the entry is not found 0 is returned.
676
678{
679 return dynamic_cast<TEveElement*>(fVizDB->GetValue(tag));
680}
681
682////////////////////////////////////////////////////////////////////////////////
683/// Load visualization-parameter database from file filename. The
684/// replace, update arguments replace the values of fVizDBReplace
685/// and fVizDBUpdate members for the duration of the macro
686/// execution.
687
688void TEveManager::LoadVizDB(const TString& filename, Bool_t replace, Bool_t update)
689{
690 Bool_t ex_replace = fVizDBReplace;
691 Bool_t ex_update = fVizDBUpdate;
692 fVizDBReplace = replace;
694
695 LoadVizDB(filename);
696
697 fVizDBReplace = ex_replace;
698 fVizDBUpdate = ex_update;
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Load visualization-parameter database from file filename.
703/// State of data-members fVizDBReplace and fVizDBUpdate determine
704/// how the registered entries are handled.
705
706void TEveManager::LoadVizDB(const TString& filename)
707{
708 TEveUtil::Macro(filename);
709 Redraw3D();
710}
711
712////////////////////////////////////////////////////////////////////////////////
713/// Save visualization-parameter database to file filename.
714
715void TEveManager::SaveVizDB(const TString& filename)
716{
717 TPMERegexp re("(.+)\\.\\w+");
718 if (re.Match(filename) != 2) {
719 Error("SaveVizDB", "filename does not match required format '(.+)\\.\\w+'.");
720 return;
721 }
722
723 TString exp_filename(filename);
724 gSystem->ExpandPathName(exp_filename);
725
726 std::ofstream out(exp_filename, std::ios::out | std::ios::trunc);
727 out << "void " << re[1] << "()\n";
728 out << "{\n";
729 out << " TEveManager::Create();\n";
730
732
733 Int_t var_id = 0;
734 TString var_name;
735 TIter next(fVizDB);
736 TObjString *key;
737 while ((key = (TObjString*)next()))
738 {
739 TEveElement* mdl = dynamic_cast<TEveElement*>(fVizDB->GetValue(key));
740 if (mdl)
741 {
742 var_name.Form("x%03d", var_id++);
743 mdl->SaveVizParams(out, key->String(), var_name);
744 }
745 else
746 {
747 Warning("SaveVizDB", "Saving failed for key '%s'.", key->String().Data());
748 }
749 }
750
751 out << "}\n";
752 out.close();
753}
754
755////////////////////////////////////////////////////////////////////////////////
756/// Get geometry with given filename.
757/// This is cached internally so the second time this function is
758/// called with the same argument the same geo-manager is returned.
759/// gGeoManager is set to the return value.
760
762{
763 static const TEveException eh("TEveManager::GetGeometry ");
764
765 TString exp_filename = filename;
766 gSystem->ExpandPathName(exp_filename);
767 printf("%s loading: '%s' -> '%s'.\n", eh.Data(),
768 filename.Data(), exp_filename.Data());
769
770 gGeoManager = (TGeoManager*) fGeometries->GetValue(filename);
771 if (gGeoManager)
772 {
773 gGeoIdentity = (TGeoIdentity*) gGeoManager->GetListOfMatrices()->At(0);
774 }
775 else
776 {
777 Bool_t locked = TGeoManager::IsLocked();
778 if (locked) {
779 Warning(eh, "TGeoManager is locked ... unlocking it.");
781 }
782 if (TGeoManager::Import(filename) == nullptr) {
783 throw(eh + "TGeoManager::Import() failed for '" + exp_filename + "'.");
784 }
785 if (locked) {
787 }
788
789 gGeoManager->GetTopVolume()->VisibleDaughters(true);
790
791 // Import colors exported by Gled, if they exist.
792 if (gROOT->IsRootFile(exp_filename)) {
793 TFile f(exp_filename, "READ");
794 TObjArray* collist = (TObjArray*) f.Get("ColorList");
795 f.Close();
796 if (collist != nullptr) {
797 TIter next(gGeoManager->GetListOfVolumes());
798 TGeoVolume* vol;
799 while ((vol = (TGeoVolume*) next()) != nullptr)
800 {
801 Int_t oldID = vol->GetLineColor();
802 TColor* col = (TColor*)collist->At(oldID);
803 Float_t r, g, b;
804 col->GetRGB(r, g, b);
805 Int_t newID = TColor::GetColor(r,g,b);
806 vol->SetLineColor(newID);
807 }
808 }
809 }
810
811 fGeometries->Add(new TObjString(filename), gGeoManager);
812 }
813 return gGeoManager;
814}
815
816////////////////////////////////////////////////////////////////////////////////
817/// Get geometry with given alias.
818/// The alias must be registered via RegisterGeometryAlias().
819
821{
822 static const TEveException eh("TEveManager::GetGeometry ");
823
824 TObjString* full_name = (TObjString*) fGeometryAliases->GetValue(alias);
825 if (!full_name)
826 throw(eh + "geometry alias '" + alias + "' not registered.");
827 return GetGeometry(full_name->String());
828}
829
830////////////////////////////////////////////////////////////////////////////////
831/// Get the default geometry.
832/// It should be registered via RegisterGeometryName("Default", `<URL>`).
833
838
839////////////////////////////////////////////////////////////////////////////////
840/// Register 'name' as an alias for geometry file 'filename'.
841/// The old aliases are silently overwritten.
842/// After that the geometry can be retrieved also by calling:
843/// gEve->GetGeometryByName(name);
844
845void TEveManager::RegisterGeometryAlias(const TString& alias, const TString& filename)
846{
847 fGeometryAliases->Add(new TObjString(alias), new TObjString(filename));
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// Set the text in the right side of browser's status bar.
852
854{
855 fBrowser->SetStatusText(text, 1);
856}
857
858////////////////////////////////////////////////////////////////////////////////
859/// Work-around uber ugly hack used in SavePrimitive and co.
860
862{
863 gROOT->ResetClassSaved();
864}
865
866////////////////////////////////////////////////////////////////////////////////
867/// Close button has been clicked on EVE main window (browser).
868/// Cleanup and terminate application.
869
871{
873 TEveBrowser *eb = dynamic_cast<TEveBrowser*>(mf);
874 if (eb == fBrowser)
875 {
876 mf->DontCallClose();
877 Terminate();
878 gApplication->Terminate();
879 }
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// If global TEveManager* gEve is not set initialize it.
884/// Returns gEve.
885
887{
888 static const TEveException eh("TEveManager::Create ");
889
890 if (gEve == nullptr)
891 {
892 // Make sure that the GUI system is initialized.
893 if (gROOT->IsBatch())
894 {
895 throw eh + "ROOT is running in batch mode.";
896 }
898 gApplication->InitializeGraphics();
899 if (gROOT->IsBatch() || gClient == nullptr || gClient->IsZombie())
900 {
901 throw eh + "window system not initialized.";
902 }
903
904 Int_t w = 1024;
905 Int_t h = 768;
906
909 gEve = new TEveManager(w, h, map_window, opt);
910 }
911 return gEve;
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Properly terminate global TEveManager.
916
918{
919 if (!gEve) return;
920
922
923 delete gEve;
924 gEve = nullptr;
925}
926
927/** \class TEveManager::TExceptionHandler
928\ingroup TEve
929Exception handler for Eve exceptions.
930*/
931
932
933////////////////////////////////////////////////////////////////////////////////
934/// Handle exceptions deriving from TEveException.
935
938{
939 TEveException* ex = dynamic_cast<TEveException*>(&exc);
940 if (ex) {
941 Info("Handle", "%s", ex->Data());
942 gEve->SetStatusLine(ex->Data());
943 gSystem->Beep();
944 return kSEHandled;
945 } else {
946 return kSEProceed;
947 }
948}
ROOT::R::TRInterface & r
Definition Object.C:4
#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 h(i)
Definition RSha256.hxx:106
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:84
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
externTApplication * gApplication
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
externTEveManager * gEve
#define gClient
Definition TGClient.h:157
char name[80]
Definition TGX11.cxx:148
externTGeoManager * gGeoManager
externTGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:538
externvoid * gTQSender
Definition TQObject.h:46
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
externTSystem * gSystem
Definition TSystem.h:582
static void NeedGraphicsLibs()
Static method.
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
The Canvas class.
Definition TCanvas.h:23
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition TColor.h:55
static Int_t GetColor(const char *hexcolor)
Specialization of TRootBrowser for Eve.
A list of TEveElements.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
void SaveVizParams(std::ostream &out, const TString &tag, const TString &var)
Save visualization parameters for this element with given tag.
virtual void AddElement(TEveElement *el)
Add el to the list of children.
virtual TObject * GetEditorObject(const TEveException &eh) const
TEveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
void DecDenyDestroy()
Decreases the deny-destroy count of the element.
Bool_t HasChildren() const
Short_t fImpliedHighlighted
!
virtual void PropagateVizParamsToProjecteds()
Propagate visualization parameters to dependent elements.
virtual void CollectSceneParents(List_t &scenes)
Collect all parents of class TEveScene.
std::list< TEveElement * > List_t
Definition TEveElement.h:71
Short_t fImpliedSelected
!
virtual TGListTreeItem * AddIntoListTree(TGListTree *ltree, TGListTreeItem *parent_lti)
Add this element into ltree to an already existing item parent_lti.
void SetVizModel(TEveElement *model)
Set visualization-parameter model element.
virtual void RemoveElement(TEveElement *el)
Remove el from the list of children.
virtual Bool_t HandleElementPaste(TEveElement *el)
React to element being pasted or dnd-ed.
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
virtual void ClearStamps()
List_t::iterator List_i
Definition TEveElement.h:72
virtual Bool_t RemoveFromListTree(TGListTree *ltree, TGListTreeItem *parent_lti)
Remove element from list-tree 'ltree' where its parent item is 'parent_lti'.
UChar_t GetChangeBits() const
Base class for event management and navigation.
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
Composite GUI frame for parallel display of a TGListTree and TEveGedEditor.
Definition TEveBrowser.h:83
Specialization of TGedEditor for proper update propagation to TEveManager.
TEveElement * GetEveElement() const
Return eve-element if it is the model object.
static void ElementDeleted(TEveElement *el)
Element is being deleted. Close editors showing it.
void DisplayElement(TEveElement *re)
Show a TEveElement in editor.
static void DestroyEditors()
Destroys all editors. Called from EVE termination.
static void ElementChanged(TEveElement *el)
Element was changed. Update editors showing it.
Exception handler for Eve exceptions.
Definition TEveManager.h:72
EStatus Handle(std::exception &exc) override
Handle exceptions deriving from TEveException.
Central application manager for Eve.
Definition TEveManager.h:50
TMap * fVizDB
Definition TEveManager.h:85
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
TEveWindowManager * fWindowManager
Definition TEveManager.h:97
Int_t fRedrawDisabled
void AddGlobalElement(TEveElement *element, TEveElement *parent=nullptr)
Add a global element, i.e.
void DoRedraw3D()
Perform 3D redraw of scenes and viewers whose contents has changed.
void ClearOrphanage()
Clear the orphanage.
void SetStatusLine(const char *text)
Set the text in the right side of browser's status bar.
TGStatusBar * GetStatusBar() const
Returns main window status bar.
TEveViewerList * fViewers
Definition TEveManager.h:98
TGListTree * GetListTree() const
Get default list-tree widget.
TEveElementList * fOrphanage
TGeoManager * GetDefaultGeometry()
Get the default geometry.
TTimer fRedrawTimer
void RegisterRedraw3D()
Register a request for 3D redraw.
TEveSelection * fSelection
Bool_t fDropLogicals
Bool_t fTimerActive
static void Terminate()
Properly terminate global TEveManager.
void CloseEveWindow()
Close button has been clicked on EVE main window (browser).
void ClearROOTClassSaved()
Work-around uber ugly hack used in SavePrimitive and co.
void PreDeleteElement(TEveElement *element)
Called from TEveElement prior to its destruction so the framework components (like object editor) can...
TEveGListTreeEditorFrame * fLTEFrame
Definition TEveManager.h:93
Bool_t fVizDBUpdate
Definition TEveManager.h:87
TGeoManager * GetGeometryByAlias(const TString &alias)
Get geometry with given alias.
void ScenesChanged(TEveElement::List_t &scenes)
Mark all scenes from the given list as changed.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
TEveViewer * GetDefaultViewer() const
Returns the default viewer - the first one in the fViewers list.
TCanvas * AddCanvasTab(const char *name)
Add a new canvas tab.
TExceptionHandler * fExcHandler
Definition TEveManager.h:83
Bool_t fKeepEmptyCont
TEveScene * fGlobalScene
Bool_t ElementPaste(TEveElement *element)
Paste has been called.
void ElementChanged(TEveElement *element, Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE)
Element was changed, perform framework side action.
void ElementSelect(TEveElement *element)
Select an element.
virtual ~TEveManager()
Destructor.
void EditElement(TEveElement *element)
Show element in default editor.
TEveBrowser * fBrowser
Definition TEveManager.h:92
Bool_t InsertVizDBEntry(const TString &tag, TEveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
void RemoveElement(TEveElement *element, TEveElement *parent)
Remove element from parent.
TEveManager(const TEveManager &)
void RegisterGeometryAlias(const TString &alias, const TString &filename)
Register 'name' as an alias for geometry file 'filename'.
TEveSelection * fHighlight
TEveGedEditor * GetEditor() const
Returns main object editor.
TEveScene * fEventScene
void SaveVizDB(const TString &filename)
Save visualization-parameter database to file filename.
TEveViewer * SpawnNewViewer(const char *name, const char *title="", Bool_t embed=kTRUE)
Create a new GL viewer.
TEveElement * FindVizDBEntry(const TString &tag)
Find a visualization-parameter database entry corresponding to tag.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=nullptr)
TMacro * GetMacro(const char *name) const
Find macro in fMacroFolder by name.
void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Perform 3D redraw of all scenes and viewers.
TGListTreeItem * AddEvent(TEveEventManager *event)
Add a new event and make it the current event.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Bool_t fVizDBReplace
Definition TEveManager.h:86
TFolder * fMacroFolder
Definition TEveManager.h:95
TEveSceneList * fScenes
Definition TEveManager.h:99
TExMap * fStampedElements
Bool_t fResetCameras
void RemoveFromListTree(TEveElement *element, TGListTree *lt, TGListTreeItem *lti)
Remove top-level element from list-tree with specified tree-item.
TGWindow * GetMainWindow() const
Get the main window, i.e. EVE-browser.
void LoadVizDB(const TString &filename, Bool_t replace, Bool_t update)
Load visualization-parameter database from file filename.
TMap * fGeometryAliases
Definition TEveManager.h:90
TGeoManager * GetGeometry(const TString &filename)
Get geometry with given filename.
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
TMap * fGeometries
Definition TEveManager.h:89
Bool_t fUseOrphanage
void ElementStamped(TEveElement *element)
Mark element as changed – it will be processed on next redraw.
TEveEventManager * fCurrentEvent
List of Scenes providing common operations on TEveScene collections.
Definition TEveScene.h:80
Eve representation of TGLScene.
Definition TEveScene.h:27
Make sure there is a SINGLE running TEveSelection for each selection type (select/highlight).
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition TEveUtil.cxx:163
static void SetupGUI()
Setup icon pictures and mime-types.
Definition TEveUtil.cxx:92
static void SetupEnvironment()
Setup Include and Macro paths.
Definition TEveUtil.cxx:49
List of Viewers providing common operations on TEveViewer collections.
Definition TEveViewer.h:80
Eve representation of TGLViewer.
Definition TEveViewer.h:31
TGLViewer * GetGLViewer() const
Definition TEveViewer.h:51
Manager for EVE windows.
Description of TEveWindowSlot.
Definition TEveWindow.h:302
static TEveWindowSlot * CreateWindowMainFrame(TEveWindow *eve_parent=nullptr)
Create a new main-frame and populate it with a default window-slot.
void ReplaceWindow(TEveWindow *w)
Replace this window with the passed one.
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=nullptr)
Create a new tab in a given tab-widget and populate it with a default window-slot.
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:410
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
<div class="legacybox"><h2>Legacy Code</h2> TFolder is a legacy interface: there will be no bug fixes...
Definition TFolder.h:30
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:888
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition TGLViewer.h:55
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:197
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
void DontCallClose()
Typically call this method in the slot connected to the CloseWindow() signal to prevent the calling o...
Definition TGFrame.cxx:1772
Provides a StatusBar widget.
Definition TGStatusBar.h:21
ROOT GUI Window base class.
Definition TGWindow.h:23
An identity transformation.
Definition TGeoMatrix.h:407
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
static void UnlockGeometry()
Unlock current geometry.
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, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetLineColor(Color_t lcolor) override
Set the line color.
Class supporting a collection of lines with C++ code.
Definition TMacro.h:31
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
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
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1072
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition TPRegexp.h:97
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:961
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
Definition TPRegexp.cxx:795
Class used by TMap to store (key,value) pairs.
Definition TMap.h:103
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2363
STL class.
TText * text
Double_t ex[n]
Definition legend1.C:17