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