]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/macros/alieve_init.C
Comment code, hide public data-members.
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 * 
8  **************************************************************************/
9
10 #ifndef __CINT_
11 #include <list>
12 #include <string>
13 #endif
14
15 void alieve_init(const Text_t* path   = ".", Int_t event=0,
16                  const Text_t* cdburi = 0,
17                  Bool_t assert_runloader=kFALSE, Bool_t assert_esd=kFALSE)
18 {
19   Info("alieve_init", "Adding standard macros.");
20   TString  hack = gSystem->pwd(); // Problem with TGFileBrowser cding
21   alieve_init_import_macros();
22   gSystem->cd(hack);
23
24   // TEveUtil::AssertMacro("region_marker.C");
25   
26   gSystem->ProcessEvents();
27
28   // Open event
29   if(path != 0) {
30     AliEveEventManager::SetCdbUri(cdburi);
31     AliEveEventManager::SetAssertElements(assert_runloader, assert_esd);
32     printf("Opening event %d from '%s' ...", event, path); fflush(stdout);
33     gEvent = new AliEveEventManager(path, event);
34     printf(" done.\n");
35     gEve->AddEvent(gEvent);
36   }
37 }
38
39 void alieve_init_import_macros()
40 {
41   // Put macros in the list of browsables, add a macro browser to
42   // top-level GUI.
43
44   TString macdir("$(REVESYS)/alice-macros");
45   gSystem->ExpandPathName(macdir);
46
47   TFolder* f = gEve->GetMacroFolder();
48   void* dirhandle = gSystem->OpenDirectory(macdir.Data());
49   if(dirhandle != 0) {
50     char* filename;
51     TPRegexp re("\.C$");
52     std::list<string> names;
53     while((filename = gSystem->GetDirEntry(dirhandle)) != 0) {
54       if(re.Match(filename)) {
55         names.push_back(filename);
56       }
57     }
58     names.sort();
59     //PH The line below is replaced waiting for a fix in Root
60     //PH which permits to use variable siza arguments in CINT
61     //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
62     // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename)));
63     char fullName[1000];
64     for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
65     {
66       sprintf(fullName,"%s/%s", macdir.Data(), si->c_str());
67       f->Add(new TEveMacro(fullName));
68     }
69   }
70   gSystem->FreeDirectory(dirhandle);
71
72   gROOT->GetListOfBrowsables()->Add
73     // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
74     (new TSystemDirectory(macdir.Data(), macdir.Data()));
75
76   {
77     TEveBrowser   *br = gEve->GetBrowser();
78     TGFileBrowser *fb = 0;
79     fb = br->GetFileBrowser();
80     fb->GotoDir(macdir);
81     {
82       br->StartEmbedding(0);
83       fb = br->MakeFileBrowser();
84       fb->BrowseObj(f);
85       fb->Show();
86       br->StopEmbedding();
87       br->SetTabTitle("Macros", 0);
88       br->SetTab(0, 0);
89     }
90   }
91 }