]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alieve_main/alieve_main.cxx
242d027bcdf2451bb357bf9c6a6af2e211a09456
[u/mrichter/AliRoot.git] / EVE / alieve_main / alieve_main.cxx
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 #include <EveBase/AliEveConfigManager.h>
10
11 #include <TInterpreter.h>
12 #include <TRint.h>
13 #include <TROOT.h>
14 #include <TPRegexp.h>
15 #include <TSystem.h>
16 #include <TError.h>
17 #include <RVersion.h>
18
19 #include <AliLog.h>
20
21 #include <TEveUtil.h>
22 #include <TEveManager.h>
23 #include <TEveSelection.h>
24 #include <TEveBrowser.h>
25 #include <TEveViewer.h>
26
27 #include <Getline.h>
28
29 // DEV Version includes
30 #include <EveBase/AliEveApplication.h>
31 #include <EveBase/AliEveMainWindow.h>
32
33
34 #include <iostream>
35 using namespace std;
36
37 int main(int argc, char **argv)
38 {
39     static const TEveException kEH("alieve::main");
40         
41     if(argc>1)
42     {
43         if(strcmp(argv[1],"-dev")==0 ){
44
45             AliEveApplication app("AliEve", &argc, argv);
46             AliEveMainWindow alieve("ALICE Event Display");
47
48             app.Connect(&alieve, "CloseWindow()", "TApplication", &app, "Terminate(=0)" );
49             app.Run();
50
51             return 0;
52         }
53     }
54     else
55     {
56             Info(kEH.Data(),"No parameters");
57     }
58     
59     if (gSystem->Getenv("ALICE_ROOT") == 0)
60     {
61         Error(kEH.Data(), "ALICE_ROOT is not defined, aborting.");
62         gSystem->Exit(1);
63     }
64
65     TString evedir(Form("%s/EVE", gSystem->Getenv("ALICE_ROOT")));
66
67     if (gSystem->AccessPathName(evedir) == kTRUE)
68     {
69         Error(kEH.Data(), "Directory $ALICE_ROOT/EVE does not exist.");
70         gSystem->Exit(1);
71     }
72
73     TString macPath(gROOT->GetMacroPath());
74     macPath += Form(":%s/macros", evedir.Data());
75     gInterpreter->AddIncludePath(evedir);
76     if (gSystem->Getenv("ALICE_ROOT") != 0)
77     {
78         macPath += Form(":%s/alice-macros", evedir.Data());
79         gInterpreter->AddIncludePath(Form("%s/EVE", gSystem->Getenv("ALICE_ROOT")));
80         gInterpreter->AddIncludePath(Form("%s/PWG0", gSystem->Getenv("ALICE_ROOT")));
81         gInterpreter->AddIncludePath(Form("%s/include", gSystem->Getenv("ALICE_ROOT")));
82         gInterpreter->AddIncludePath(gSystem->Getenv("ALICE_ROOT"));
83     }
84     {
85         // TabCom fails on double-colon in macro-path.
86         // I fixed this in ROOT sometime ago ... could be removed
87         // when we go to 5.26.
88         TPMERegexp doubleColon(":{2,}", "og");
89         doubleColon.Substitute(macPath, ":");
90     }
91     gROOT->SetMacroPath(macPath);
92
93     // make sure logger is instantiated
94     AliLog::GetRootLogger();
95     TApplication  *app = new TRint("App", &argc, argv);
96
97 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,4) || defined XXX_LATEST_ROOT
98     // Waiting for update by Pawel. Now GED in ROOT is better again :)
99     // Uncomment when fixed in AliEveGedXXX.
100     // TEveGListTreeEditorFrame::SetEditorClass("AliEveGedEditor");
101 #endif
102
103     TEveManager::Create();
104     gEve->GetDefaultViewer()->SetElementName("3D View");
105     gEve->GetSelection()->SetPickToSelect(TEveSelection::kPS_PableCompound);
106     gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_PableCompound);
107
108     gEve->RegisterGeometryAlias("Default", Form("%s/alice-data/default_geo.root", evedir.Data()));
109
110     try {AliEveConfigManager::InitializeMaster();}
111     catch (TEveException exc) {
112         AliErrorGeneral("alieve_main",exc.Data());
113     }
114
115     app->Connect("TEveBrowser", "CloseWindow()", "TApplication", app, "Kill()");
116     
117     app->Run(kTRUE);
118
119     cout<<"Terminate"<<endl;
120     
121     app->Terminate(0);
122     
123     cout<<"unmap"<<endl;
124     
125     if (gEve && gEve->GetBrowser())     gEve->GetBrowser()->UnmapWindow();
126
127     cout<<"teve terminate"<<endl;
128     
129     TEveManager::Terminate();
130
131     cout<<"delete"<<endl;
132     
133     if(gEve) {delete gEve; gEve = 0;}
134
135     cout<<"return"<<endl;
136     
137     return 0;
138 }