9e78371d |
1 | // $Id: alieve_init.C 30728 2009-01-22 18:14:34Z mtadel $ |
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 | **************************************************************************/ |
1d8ae8b6 |
9 | #if !defined(__CINT__) || defined(__MAKECINT__) |
10 | #include "TROOT.h" |
11 | #include "TSystem.h" |
12 | #include "TString.h" |
13 | #include "TFolder.h" |
14 | #include "TPRegexp.h" |
15 | #include "TEveUtil.h" |
9e78371d |
16 | |
1d8ae8b6 |
17 | #include "TEveManager.h" |
18 | #include "TEvePointSet.h" |
19 | #include "TEveBrowser.h" |
9e78371d |
20 | |
1d8ae8b6 |
21 | #include "TSystemDirectory.h" |
22 | #include "TGFileBrowser.h" |
23 | #include "TEveMacro.h" |
24 | #endif |
25 | |
26 | using namespace std; |
27 | |
28 | typedef list<string> StringList; |
9e78371d |
29 | |
9e78371d |
30 | |
31 | void alieve_init_import_macros() |
32 | { |
33 | // Put macros in the list of browsables, add a macro browser to |
34 | // top-level GUI. |
1d8ae8b6 |
35 | typedef list<string> StringList; |
9e78371d |
36 | |
37 | TString macdir("$(ALICE_ROOT)/EVE/alice-macros"); |
38 | gSystem->ExpandPathName(macdir); |
39 | |
40 | TFolder* f = gEve->GetMacroFolder(); |
41 | void* dirhandle = gSystem->OpenDirectory(macdir.Data()); |
42 | if (dirhandle != 0) |
43 | { |
44 | char* filename; |
45 | TPMERegexp re("\\.C$"); |
1d8ae8b6 |
46 | StringList names; // This form understood by cint (fails with std::string). |
47 | while ((filename = (char*)gSystem->GetDirEntry(dirhandle)) != 0) |
9e78371d |
48 | { |
49 | if (re.Match(filename)) |
50 | names.push_back(filename); |
51 | } |
52 | names.sort(); |
53 | //PH The line below is replaced waiting for a fix in Root |
54 | //PH which permits to use variable siza arguments in CINT |
55 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) |
56 | // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename))); |
57 | char fullName[1000]; |
1d8ae8b6 |
58 | for (StringList::iterator si=names.begin(); si!=names.end(); ++si) |
9e78371d |
59 | { |
60 | sprintf(fullName,"%s/%s", macdir.Data(), si->c_str()); |
61 | f->Add(new TEveMacro(fullName)); |
62 | } |
63 | } |
64 | gSystem->FreeDirectory(dirhandle); |
65 | |
66 | gROOT->GetListOfBrowsables()->Add |
67 | // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works |
68 | (new TSystemDirectory(macdir.Data(), macdir.Data())); |
69 | |
70 | { |
71 | TEveBrowser *br = gEve->GetBrowser(); |
72 | TGFileBrowser *fb = 0; |
73 | fb = br->GetFileBrowser(); |
74 | fb->GotoDir(macdir); |
75 | { |
76 | br->StartEmbedding(0); |
77 | fb = br->MakeFileBrowser(); |
78 | fb->BrowseObj(f); |
79 | fb->Show(); |
80 | br->StopEmbedding(); |
81 | br->SetTabTitle("Macros", 0); |
82 | br->SetTab(0, 0); |
83 | } |
84 | } |
85 | } |
86 | |
87 | void alieve_init_basic_vizdb() |
88 | { |
89 | TEvePointSet* ps; |
90 | |
91 | ps = new TEvePointSet(); |
92 | ps->SetMarkerColor(4); |
93 | ps->SetMarkerSize(0.2); |
94 | ps->SetMarkerStyle(2); |
95 | gEve->InsertVizDBEntry("Clusters", ps); |
96 | } |
1d8ae8b6 |
97 | |
98 | void hlt_alieve_init() |
99 | { |
100 | typedef list<string> StringList; |
101 | |
102 | Info("alieve_init", "Adding standard macros."); |
103 | TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding |
104 | alieve_init_import_macros(); |
105 | gSystem->cd(hack); |
106 | |
107 | alieve_init_basic_vizdb(); |
108 | // Temporarily assert also default vizdb. |
109 | TEveUtil::AssertMacro("VizDB_scan.C"); |
110 | |
111 | gSystem->ProcessEvents(); |
112 | } |
113 | |