1 #include "TEveBrowser.h"
2 #include "TEveViewer.h"
3 #include "TGLLightSet.h"
5 #include "display/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 GGSCOUT(ERROR) << R
"(Must provide at least one between input file (-i) and geometry file (-g))" << GGSENDL;
26 if (args.infilename) {
27 _fileToBeLoaded = args.infilename;
31 if (_FileManager->FileIsLoaded()) {
32 _MainWindow->SetFileName(_fileLoaded);
33 _FileManager->ReadEvent(0);
37 EDApplication::~EDApplication() {
43 void EDApplication::NextEvent() {
44 static const std::string routineName(
"EDApplication::NextEvent");
46 _FileManager->NextEvent();
47 _evtLoaded = _FileManager->GetNevent();
48 _MainWindow->SetEventNumber(_evtLoaded + 1);
51 void EDApplication::PrevEvent() {
52 static const std::string routineName(
"EDApplication::PrevEvent");
54 _FileManager->PrevEvent();
55 _evtLoaded = _FileManager->GetNevent();
56 _MainWindow->SetEventNumber(_evtLoaded + 1);
59 void EDApplication::LoadEvent() {
60 static const std::string routineName(
"EDApplication::LoadEvent");
62 if (_evtToBeLoaded == _evtLoaded)
65 _FileManager->ReadEvent(_evtToBeLoaded);
66 _evtLoaded = _evtToBeLoaded;
67 _MainWindow->SetEventNumber(_evtLoaded + 1);
70 void EDApplication::SetFileToBeLoaded(
char *text) { _fileToBeLoaded = text; }
72 void EDApplication::SetEventToBeLoaded(
char *text) {
73 _evtToBeLoaded = atoi(text) - 1;
74 if (_evtToBeLoaded < 0)
78 void EDApplication::SetDisplayDetector(
char *det) {
79 static const std::string routineName(
"EDApplication::SetDisplayDetector");
83 TGCheckButton *but = (TGCheckButton *)gTQSender;
87 _MainWindow->SetDisplayDetector(det, s);
90 void EDApplication::SetDisplayPartHits(Bool_t s) { _MainWindow->SetDisplayPartHits(s); }
92 void EDApplication::LoadRootFile() {
93 static const std::string routineName(
"EDApplication::LoadRootFile");
95 if (!_fileToBeLoaded.CompareTo(_fileLoaded))
98 _FileManager->Load(_fileToBeLoaded);
99 _fileLoaded = _fileToBeLoaded;
101 if (_MainWindow && _FileManager->FileIsLoaded()) {
102 _MainWindow->SetFileName(_fileLoaded);
103 _MainWindow->UpdateFileEntries();
104 _MainWindow->CreateMaps();
105 _FileManager->ReadEvent(0,
true);
106 _MainWindow->SetEventNumber(0);
110 void EDApplication::HandleArgs() {
112 int parse_status = argp_parse(&argp, Argc(), Argv(), 0, 0, &args);
117 void EDApplication::InitGUI() {
119 TEveUtil::SetupEnvironment();
120 TEveUtil::SetupGUI();
122 if (!args.flag_debug) {
123 _MainWindow->GetBrowser()->HideBottomTab();
129 void EDApplication::LoadGeometry() {
130 static const std::string routineName(
"EDApplication::EDApplication");
132 const std::string geoFileName = args.geofilename ? args.geofilename : args.infilename;
135 if (geoFileName.substr(geoFileName.size() - 5) ==
".gdml") {
136 TGeoManager::LockDefaultUnits(kFALSE);
137 TGeoManager::SetDefaultUnits(TGeoManager::EDefaultUnits::kRootUnits);
141 if (GGSSmartLog::verboseLevel < GGSSmartLog::DEBUG) {
142 GGSSmartLog::MuteOutput();
144 _MainWindow->GetGeometry(geoFileName);
145 GGSSmartLog::UnmuteOutput();
148 gGeoManager->DefaultColors();
150 _MainWindow->AddGlobalElement(_GeoManager->GetEveGeoTopNode());
151 _GeoManager->GetEveGeoTopNode()->ExpandIntoListTreesRecursively();
153 _MainWindow->FullRedraw3D(kTRUE);
155 _MainWindow->GetDefaultGLViewer()->GetClipSet()->SetClipType(TGLClip::EType(2));
157 _MainWindow->GetDefaultGLViewer()->ResetCameras();
158 _MainWindow->GetDefaultGLViewer()->CurrentCamera().RotateRad(-TMath::Pi() / 6, -9 * TMath::Pi() / 12);
159 _MainWindow->GetDefaultGLViewer()->GetLightSet()->SetUseSpecular(
false);
162 int EDApplication::ParseArgs(
int key,
char *arg,
struct argp_state *state) {
164 struct arguments *a = (
struct arguments *)state->input;
168 a->flag_debug = kTRUE;
176 a->geofilename = arg;
180 argp_failure(state, 1, 0,
"No arguments requested");
183 case ARGP_KEY_INIT: {
184 a->infilename = NULL;
185 a->geofilename = NULL;
186 a->flag_debug =
false;
190 if (a->geofilename ==
nullptr && a->infilename ==
nullptr) {
191 argp_failure(state, 1, 0, R
"(Must provide at least one between input file (-i) and geometry file (-g))");
206 struct argp_option
EDApplication::options[] = {{
"debug",
'd', 0, 0,
"Enable Debug Info", 0},
207 {
"input-file",
'i',
"FILE", 0,
"Input file", 0},
208 {
"geometry",
'g',
"FILE", 0,
"Geometry file", 0},
210 struct argp
EDApplication::argp = {options, EDApplication::ParseArgs, 0, 0, 0, 0, 0};