1 #include "TEveBrowser.h"
2 #include "TEveViewer.h"
3 #include "TGLLightSet.h"
5 #include "application/Application.h"
7 EDApplication::EDApplication(
int argc,
char **argv)
8 : TApplication(
"GGSLeonard", &argc, argv, 0, -1), _MainWindow(0), _FileManager(0) {
9 static const std::string routineName(
"EDApplication::EDApplication");
12 _fileLoaded = _fileToBeLoaded =
"";
18 GGSSmartLog::verboseLevel = GGSSmartLog::DEBUG;
20 if (args.geofilename ==
nullptr && args.infilename ==
nullptr) {
21 COUT(ERROR) << R
"(Must provide at least one between input file (-i) and geometry file (-g))" << ENDL;
26 if (args.infilename) {
27 _fileToBeLoaded = args.infilename;
31 if (_FileManager->FileIsLoaded()) {
32 _MainWindow->SetFileName(_fileLoaded);
33 _FileManager->ReadEvent(0);
37 EDApplication::~EDApplication() {
44 void EDApplication::NextEvent() {
45 static const std::string routineName(
"EDApplication::NextEvent");
47 _FileManager->NextEvent();
48 _evtLoaded = _FileManager->GetNevent();
49 _MainWindow->SetEventNumber(_evtLoaded + 1);
52 void EDApplication::PrevEvent() {
53 static const std::string routineName(
"EDApplication::PrevEvent");
55 _FileManager->PrevEvent();
56 _evtLoaded = _FileManager->GetNevent();
57 _MainWindow->SetEventNumber(_evtLoaded + 1);
60 void EDApplication::LoadEvent() {
61 static const std::string routineName(
"EDApplication::LoadEvent");
63 if (_evtToBeLoaded == _evtLoaded)
66 _FileManager->ReadEvent(_evtToBeLoaded);
67 _evtLoaded = _evtToBeLoaded;
68 _MainWindow->SetEventNumber(_evtLoaded + 1);
71 void EDApplication::SetFileToBeLoaded(
char *text) { _fileToBeLoaded = text; }
73 void EDApplication::SetEventToBeLoaded(
char *text) {
74 _evtToBeLoaded = atoi(text) - 1;
75 if (_evtToBeLoaded < 0)
79 void EDApplication::SetDisplayDetector(
char *det) {
80 static const std::string routineName(
"EDApplication::SetDisplayDetector");
84 TGCheckButton *but = (TGCheckButton *)gTQSender;
88 _MainWindow->SetDisplayDetector(det, s);
91 void EDApplication::SetDisplayPartHits(Bool_t s) { _MainWindow->SetDisplayPartHits(s); }
93 void EDApplication::LoadRootFile() {
94 static const std::string routineName(
"EDApplication::LoadRootFile");
96 if (!_fileToBeLoaded.CompareTo(_fileLoaded))
99 _FileManager->Load(_fileToBeLoaded);
100 _fileLoaded = _fileToBeLoaded;
102 if (_MainWindow && _FileManager->FileIsLoaded()) {
103 _MainWindow->SetFileName(_fileLoaded);
104 _MainWindow->UpdateFileEntries();
105 _MainWindow->CreateMaps();
106 _FileManager->ReadEvent(0,
true);
107 _MainWindow->SetEventNumber(0);
111 void EDApplication::HandleArgs() {
113 int parse_status = argp_parse(&argp, Argc(), Argv(), 0, 0, &args);
118 void EDApplication::InitGUI() {
120 TEveUtil::SetupEnvironment();
121 TEveUtil::SetupGUI();
123 if (!args.flag_debug) {
124 _MainWindow->GetBrowser()->HideBottomTab();
130 void EDApplication::LoadGeometry() {
131 static const std::string routineName(
"EDApplication::EDApplication");
133 const std::string geoFileName = args.geofilename ? args.geofilename : args.infilename;
137 _GeoManager->DefaultColors();
139 _MainWindow->AddGlobalElement(_GeoManager->GetEveGeoTopNode());
140 _GeoManager->GetEveGeoTopNode()->ExpandIntoListTreesRecursively();
142 _MainWindow->FullRedraw3D(kTRUE);
144 _MainWindow->GetDefaultGLViewer()->GetClipSet()->SetClipType(TGLClip::EType(2));
146 _MainWindow->GetDefaultGLViewer()->ResetCameras();
147 _MainWindow->GetDefaultGLViewer()->CurrentCamera().RotateRad(-TMath::Pi() / 6, -9 * TMath::Pi() / 12);
148 _MainWindow->GetDefaultGLViewer()->GetLightSet()->SetUseSpecular(
false);
151 int EDApplication::ParseArgs(
int key,
char *arg,
struct argp_state *state) {
153 struct arguments *a = (
struct arguments *)state->input;
157 a->flag_debug = kTRUE;
165 a->geofilename = arg;
169 argp_failure(state, 1, 0,
"No arguments requested");
172 case ARGP_KEY_INIT: {
173 a->infilename = NULL;
174 a->geofilename = NULL;
175 a->flag_debug =
false;
179 if (a->geofilename ==
nullptr && a->infilename ==
nullptr) {
180 argp_failure(state, 1, 0, R
"(Must provide at least one between input file (-i) and geometry file (-g))");
195 struct argp_option
EDApplication::options[] = {{
"debug",
'd', 0, 0,
"Enable Debug Info", 0},
196 {
"input-file",
'i',
"FILE", 0,
"Input file", 0},
197 {
"geometry",
'g',
"FILE", 0,
"Geometry file", 0},
199 struct argp
EDApplication::argp = {options, EDApplication::ParseArgs, 0, 0, 0, 0, 0};
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...