Fixing bugs in Event Display
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveConfigManager.cxx
CommitLineData
7b3eaa01 1// $Id$
2// Author: Matevz Tadel 2009
3
4/**************************************************************************
5 * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliEveConfigManager.h"
11
3aff0c2e 12#include <AliEveMultiView.h>
7b3eaa01 13#include <TEveManager.h>
14#include <TEveBrowser.h>
a13d7c88 15#include <TEveWindow.h>
3aff0c2e 16#include <TGFileDialog.h>
7b3eaa01 17#include <TGMenu.h>
18
a13d7c88 19#include "AliEveEventManager.h"
20#include "AliEveMacroExecutor.h"
21#include "AliEveMacroExecutorWindow.h"
22#include "AliEveMacro.h"
23
164d3d29 24//Storage Manager:
9211a1f1 25#ifdef ZMQ
164d3d29 26#include "AliStorageAdministratorPanelListEvents.h"
27#include "AliStorageAdministratorPanelMarkEvent.h"
9211a1f1 28#endif
164d3d29 29
3aff0c2e 30class AliEveMacroExecutor;
31class TEveProjectionManager;
32class TEveGeoShape;
33class TEveUtil;
34
35#include <TSystem.h>
36#include <TPRegexp.h>
7b3eaa01 37#include <RVersion.h>
38
39//______________________________________________________________________________
40// Full description of AliEveConfigManager
41//
42
43ClassImp(AliEveConfigManager)
44
45AliEveConfigManager* AliEveConfigManager::fgMaster = 0;
46
47namespace
48{
49 enum EAliEveMenu_e
50 {
164d3d29 51 kAEMDefault, kAEMScreen, kAEMProjector, kAEMNotransparency, kAEMTransparentDark, kAEMTransparentLight, kAEMTransparentMonoDark, kAEMTransparentMonoLight, kAEMGreen, kAEMBright, kAEMYellow, kAEMTpc, kAEMAll, kAEM3d, kAEMRphi, kAEMRhoz, kAEMAllhr, kAEM3dhr, kAEMRphihr, kAEMRhozhr, kAEMSavemacros, kAEMLoadmacros, kAEMSave, kAEMOpen, kAEMSetDefault, kAEMResiduals, kAEMCuts, kAEMVectors, kAEMGui, kStorageListEvents, kStorageMarkEvent
7b3eaa01 52 };
53}
54
55//______________________________________________________________________________
56AliEveConfigManager* AliEveConfigManager::InitializeMaster()
57{
58 // Get main instance.
59
60 static const TEveException kEH("AliEveConfigManager::InitializeMaster ");
61
62 if (fgMaster)
63 throw kEH + "Master already initialized.";
64
65 fgMaster = new AliEveConfigManager;
66 return fgMaster;
67}
68
69//______________________________________________________________________________
70AliEveConfigManager* AliEveConfigManager::GetMaster()
71{
72 // Get main instance.
73
74 static const TEveException kEH("AliEveConfigManager::GetMaster ");
75
76 if (!fgMaster)
77 throw kEH + "Master not initialized.";
78
79 return fgMaster;
80}
81
82//______________________________________________________________________________
83AliEveConfigManager::AliEveConfigManager() :
84 TObject(),
6aafad45 85 fAnalysisPopup(0),
d52fea52 86 fAliEvePopup(0),
87 fAliEveGeometries(0),
88 fAliEvePictures(0),
89 fAliEvePicturesHR(0),
90 fAliEveDataSelection(0),
91 fAliEveVizDBs(0),
92 fLoadCheck(kFALSE)
7b3eaa01 93{
94 // Constructor.
95 // Expected TEveManager is already initialized.
96
3aff0c2e 97
d4476392 98 fAliEveGeometries = new TGPopupMenu(gClient->GetRoot());
99 fAliEveGeometries->AddEntry("&Default", kAEMDefault);
100 fAliEveGeometries->AddEntry("&Screen", kAEMScreen);
101 fAliEveGeometries->AddEntry("&Projector", kAEMProjector);
3aff0c2e 102
d4476392 103 fAliEveGeometries->AddSeparator();
3aff0c2e 104
d4476392 105 fAliEveGeometries->AddEntry("&Low transparency", kAEMNotransparency);
a13d7c88 106
d4476392 107 fAliEveGeometries->AddSeparator();
a13d7c88 108
d4476392 109 fAliEveGeometries->AddEntry("&Transparent screen", kAEMTransparentDark);
110 fAliEveGeometries->AddEntry("&Transparent projector", kAEMTransparentLight);
111 fAliEveGeometries->AddEntry("&Transparent mono dark", kAEMTransparentMonoDark);
112 fAliEveGeometries->AddEntry("&Transparent mono light", kAEMTransparentMonoLight);
3aff0c2e 113
d4476392 114 fAliEveGeometries->AddSeparator();
3aff0c2e 115
d4476392 116 fAliEveGeometries->AddEntry("&First collision setup", kAEMGreen);
117 fAliEveGeometries->AddEntry("&Bright", kAEMBright);
a13d7c88 118
d4476392 119 fAliEveGeometries->AddSeparator();
a13d7c88 120
d4476392 121 fAliEveGeometries->AddEntry("&TPC Yellow", kAEMYellow);
122 fAliEveGeometries->AddEntry("&TPC Blue", kAEMTpc);
a13d7c88 123
d4476392 124 fAliEveGeometries->AddSeparator();
a13d7c88 125
d4476392 126 fAliEvePictures = new TGPopupMenu(gClient->GetRoot());
a13d7c88 127
d4476392 128 fAliEvePictures->AddEntry("&Save all views", kAEMAll);
129 fAliEvePictures->AddEntry("&Save 3D View", kAEM3d);
130 fAliEvePictures->AddEntry("&Save RPhi View", kAEMRphi);
131 fAliEvePictures->AddEntry("&Save RhoZ View", kAEMRhoz);
a13d7c88 132
d4476392 133 fAliEvePictures->AddSeparator();
a13d7c88 134
d4476392 135 fAliEvePicturesHR = new TGPopupMenu(gClient->GetRoot());
136
137 fAliEvePicturesHR->AddEntry("&Save all views HR", kAEMAllhr);
138 fAliEvePicturesHR->AddEntry("&Save 3D View HR", kAEM3dhr);
139 fAliEvePicturesHR->AddEntry("&Save RPhi View HR", kAEMRphihr);
140 fAliEvePicturesHR->AddEntry("&Save RhoZ View HR", kAEMRhozhr);
141
142 fAliEvePicturesHR->AddSeparator();
a13d7c88 143
d4476392 144 fAliEveDataSelection = new TGPopupMenu(gClient->GetRoot());
a13d7c88 145
d4476392 146 fAliEveDataSelection->AddEntry("&Save Data Selection macros", kAEMSavemacros);
147 fAliEveDataSelection->AddEntry("&Load Data Selection macros", kAEMLoadmacros);
148
149 fAliEveDataSelection->AddSeparator();
150
151 fAliEveVizDBs = new TGPopupMenu(gClient->GetRoot());
152
153 fAliEveVizDBs->AddEntry("&Save VizDB", kAEMSave);
154 fAliEveVizDBs->AddEntry("&Load VizDB", kAEMOpen);
155
156 fAliEveVizDBs->AddSeparator();
157
158 fAliEvePopup = new TGPopupMenu(gClient->GetRoot());
159 fAliEvePopup->AddEntry("&Set Default Settings", kAEMSetDefault);
a13d7c88 160 fAliEvePopup->AddSeparator();
d4476392 161 fAliEvePopup->AddPopup("&Geometries/VizDBs", fAliEveGeometries);
a13d7c88 162 fAliEvePopup->AddSeparator();
d4476392 163 fAliEvePopup->AddPopup("&Pictures", fAliEvePictures);
a13d7c88 164 fAliEvePopup->AddSeparator();
d4476392 165 fAliEvePopup->AddPopup("&PicturesHR", fAliEvePicturesHR);
166 fAliEvePopup->AddSeparator();
167 fAliEvePopup->AddPopup("&VizDBs", fAliEveVizDBs);
168 fAliEvePopup->AddSeparator();
169 fAliEvePopup->AddPopup("&DataSelection", fAliEveDataSelection);
7b3eaa01 170 fAliEvePopup->AddSeparator();
171
6aafad45 172 fAnalysisPopup = new TGPopupMenu(gClient->GetRoot());
173// fAnalysisPopup->AddEntry("&Residuals", kAEMResiduals);
174// fAnalysisPopup->AddSeparator();
175 fAnalysisPopup->AddEntry("&Cuts", kAEMCuts);
176 fAnalysisPopup->AddSeparator();
177 fAnalysisPopup->AddEntry("&Momentum vectors", kAEMVectors);
178 fAnalysisPopup->AddSeparator();
179// fAnalysisPopup->AddEntry("&Gui Mode", kAEMGui);
180// fAnalysisPopup->AddSeparator();
181
7b3eaa01 182 fAliEvePopup->Connect("Activated(Int_t)", "AliEveConfigManager",
183 this, "AliEvePopupHandler(Int_t)");
6aafad45 184
185 fAnalysisPopup->Connect("Activated(Int_t)", "AliEveConfigManager",
186 this, "AliEvePopupHandler(Int_t)");
187
164d3d29 188 //Storage Manager:
9211a1f1 189#ifdef ZMQ
fae81379 190 gEve->GetBrowser()->StartEmbedding(0);
e6194cd4 191 AliStorageAdministratorPanelListEvents* fListEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
fae81379 192 gEve->GetBrowser()->StopEmbedding("List");
193
194 fListEventsTab->Connect("SelectedEvent()","AliEveConfigManager",this,"SetEventInEventManager()");
9211a1f1 195#endif
164d3d29 196
a13d7c88 197 fLoadCheck = kFALSE;
7b3eaa01 198
06219f85 199#if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,4)
200 TGMenuBar *mBar = gEve->GetBrowser()->GetMenuBar();
201 mBar->AddPopup("&AliEve", fAliEvePopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
6aafad45 202 ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
203 mBar->AddPopup("&Tools", fAnalysisPopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
164d3d29 204 ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
164d3d29 205
06219f85 206 gEve->GetBrowser()->GetTopMenuFrame()->Layout();
7b3eaa01 207#else
208 // Uber hack as TRootBrowser does not provede manu-bar getter.
209 TGFrameElement *xxFE = (TGFrameElement*) gEve->GetBrowser()->GetList()->First();
210 TGCompositeFrame *xxCF = (TGCompositeFrame*) xxFE->fFrame;
211 xxFE = (TGFrameElement*) xxCF->GetList()->First();
212 xxCF = (TGCompositeFrame*) xxFE->fFrame;
213 xxFE = (TGFrameElement*) xxCF->GetList()->First();
214 xxCF = (TGCompositeFrame*) xxFE->fFrame;
215 xxFE = (TGFrameElement*) xxCF->GetList()->First();
06219f85 216 TGMenuBar *mBar = (TGMenuBar*) xxFE->fFrame;
7b3eaa01 217 mBar->AddPopup("&AliEve", fAliEvePopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
218 ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
6aafad45 219 mBar->AddPopup("&Tools", fAnalysisPopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
220 ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
164d3d29 221 mBar->AddPopup("&Storage Manager",fStoragePopup,new TGLayoutHints(kLHintsTop | kLHintsLeft,0,4,0,0));
222 ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
06219f85 223#endif
7b3eaa01 224}
225
226//==============================================================================
227
a13d7c88 228#include <iostream>
229#include <fstream>
230#include <string>
231#include <sstream>
232
233using namespace std;
234
3aff0c2e 235namespace
236{
237const char *gMacroSaveAsTypes[] = {"CINT Macro", "*.C",
a13d7c88 238 0, 0}; //for saving/loading macros
239
240const char *gPictureSaveAsTypes[] = {"PNG Image", "*.png",
241 0, 0}; //for saving pictures
242
3aff0c2e 243}
244
0790c3e6 245void AliEveConfigManager::ConnectEventManagerSignals()
246{
247 AliEveEventManager *manager = AliEveEventManager::GetCurrent();
248 manager->Connect("StorageManagerOk()","AliEveConfigManager",this,"StorageManagerChangedState(=1)");
249 manager->Connect("StorageManagerDown()","AliEveConfigManager",this,"StorageManagerChangedState(=0)");
250}
251
7b3eaa01 252void AliEveConfigManager::AliEvePopupHandler(Int_t id)
253{
254 // Handle user selections from AliEve popup.
255
256 static const TEveException kEH("AliEveConfigManager::AliEvePopupHandler ");
257
258 switch (id)
259 {
3aff0c2e 260
a13d7c88 261 case kAEMDefault: //default geometry and VizDB
262 {
263 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 264
a13d7c88 265 mv->DestroyAllGeometries(); //destroy RPhi and Rhoz geometries before putting new
3aff0c2e 266
a13d7c88 267 gEve->LoadVizDB("geom_gentle_default.C", kTRUE, kTRUE); //loading geometry
3aff0c2e 268
a13d7c88 269 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE); //loading VizDB
3aff0c2e 270
a13d7c88 271 if(!gEve->GetViewers()->UseLightColorSet())
272 gEve->GetViewers()->SwitchColorSet(); //white background
3aff0c2e 273
a13d7c88 274 gEve->FullRedraw3D();
275
3aff0c2e 276 break;
3aff0c2e 277 }
278
a13d7c88 279 case kAEMScreen: //default geometry with black background
3aff0c2e 280 {
a13d7c88 281 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 282
a13d7c88 283 mv->DestroyAllGeometries();
3aff0c2e 284
285 gEve->LoadVizDB("geom_gentle_default.C", kTRUE, kTRUE);
286
a13d7c88 287 gEve->LoadVizDB("VizDB_scan_screen.C", kTRUE, kTRUE);
3aff0c2e 288
289 if(gEve->GetViewers()->UseLightColorSet())
290 gEve->GetViewers()->SwitchColorSet();
291
a13d7c88 292 gEve->FullRedraw3D();
293
3aff0c2e 294 break;
295 }
296
a13d7c88 297 case kAEMProjector: //default geometry with white background
3aff0c2e 298 {
a13d7c88 299 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 300
a13d7c88 301 mv->DestroyAllGeometries();
3aff0c2e 302
95fb6e56 303 gEve->LoadVizDB("geom_gentle_projector.C", kTRUE, kTRUE);
3aff0c2e 304
a13d7c88 305 gEve->LoadVizDB("VizDB_scan_projector.C", kTRUE, kTRUE);
3aff0c2e 306
a13d7c88 307 if(!gEve->GetViewers()->UseLightColorSet())
3aff0c2e 308 gEve->GetViewers()->SwitchColorSet();
309
310 gEve->FullRedraw3D();
311
312 break;
313 }
314
a13d7c88 315 case kAEMNotransparency: //default geometry with low transparency (5%)
3aff0c2e 316 {
a13d7c88 317 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 318
a13d7c88 319 mv->DestroyAllGeometries();
3aff0c2e 320
a13d7c88 321 gEve->LoadVizDB("geom_gentle_notransparency.C", kTRUE, kTRUE);
3aff0c2e 322
a13d7c88 323 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
3aff0c2e 324
325 if(!gEve->GetViewers()->UseLightColorSet())
326 gEve->GetViewers()->SwitchColorSet();
327
328 gEve->FullRedraw3D();
329
330 break;
331 }
332
3aff0c2e 333
a13d7c88 334 case kAEMTransparentDark: //default geometry with black background, high transparency (80%)
335 {
336 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 337
a13d7c88 338 mv->DestroyAllGeometries();
3aff0c2e 339
340 gEve->LoadVizDB("geom_gentle_transparent.C", kTRUE, kTRUE);
341
342 gEve->LoadVizDB("VizDB_scan_transparentdark.C", kTRUE, kTRUE);
343
344 if(gEve->GetViewers()->UseLightColorSet())
345 gEve->GetViewers()->SwitchColorSet();
346
347 gEve->FullRedraw3D();
348
349 break;
350 }
351
a13d7c88 352 case kAEMTransparentLight: //default geometry with white background, high transparency (80%)
3aff0c2e 353 {
a13d7c88 354 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 355
a13d7c88 356 mv->DestroyAllGeometries();
3aff0c2e 357
358 gEve->LoadVizDB("geom_gentle_transparent.C", kTRUE, kTRUE);
359
360 gEve->LoadVizDB("VizDB_scan_transparentlight.C", kTRUE, kTRUE);
361
362 if(!gEve->GetViewers()->UseLightColorSet())
363 gEve->GetViewers()->SwitchColorSet();
364
365 gEve->FullRedraw3D();
366
367 break;
368 }
369
370 case kAEMTransparentMonoDark:
371 {
a13d7c88 372 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 373
a13d7c88 374 mv->DestroyAllGeometries();
3aff0c2e 375
376 gEve->LoadVizDB("geom_gentle_transparentdark.C", kTRUE, kTRUE);
377
378 gEve->LoadVizDB("VizDB_scan_transparentdark.C", kTRUE, kTRUE);
379
380 if(gEve->GetViewers()->UseLightColorSet())
381 gEve->GetViewers()->SwitchColorSet();
382
383 gEve->FullRedraw3D();
384
385 break;
386 }
387
388 case kAEMTransparentMonoLight:
389 {
a13d7c88 390 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 391
a13d7c88 392 mv->DestroyAllGeometries();
3aff0c2e 393
394 gEve->LoadVizDB("geom_gentle_transparentlight.C", kTRUE, kTRUE);
395
396 gEve->LoadVizDB("VizDB_scan_transparentlight.C", kTRUE, kTRUE);
397
398 if(!gEve->GetViewers()->UseLightColorSet())
399 gEve->GetViewers()->SwitchColorSet();
400
401 gEve->FullRedraw3D();
402
403 break;
404 }
405
a13d7c88 406 case kAEMGreen:
407 {
408 AliEveMultiView *mv = AliEveMultiView::Instance();
409
410 mv->DestroyAllGeometries();
411
412 gEve->LoadVizDB("geom_gentle_green.C", kTRUE, kTRUE);
413
414 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
415
416 if(!gEve->GetViewers()->UseLightColorSet())
417 gEve->GetViewers()->SwitchColorSet();
418
419 gEve->FullRedraw3D();
420
421 break;
422 }
423
424 case kAEMBright:
3aff0c2e 425 {
a13d7c88 426 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 427
a13d7c88 428 mv->DestroyAllGeometries();
3aff0c2e 429
a13d7c88 430 gEve->LoadVizDB("geom_gentle_bright.C", kTRUE, kTRUE);
431
432 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
433
434 if(gEve->GetViewers()->UseLightColorSet())
435 gEve->GetViewers()->SwitchColorSet();
436
437 gEve->FullRedraw3D();
438
439 break;
440 }
441
442 case kAEMYellow:
443 {
444 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 445
a13d7c88 446 mv->DestroyAllGeometries();
447
448 gEve->LoadVizDB("geom_gentle_yellow.C", kTRUE, kTRUE);
449
450 gEve->LoadVizDB("VizDB_scan_yellow.C", kTRUE, kTRUE);
451
452 if(!gEve->GetViewers()->UseLightColorSet())
453 gEve->GetViewers()->SwitchColorSet();
454
455 gEve->FullRedraw3D();
456
457 break;
458 }
459
460 case kAEMTpc:
461 {
462 AliEveMultiView *mv = AliEveMultiView::Instance();
463
464 mv->DestroyAllGeometries();
3aff0c2e 465
466 gEve->LoadVizDB("geom_gentle_tpc.C", kTRUE, kTRUE);
467
468 gEve->LoadVizDB("VizDB_scan_tpc.C", kTRUE, kTRUE);
469
470 if(!gEve->GetViewers()->UseLightColorSet())
471 gEve->GetViewers()->SwitchColorSet();
472
473 gEve->FullRedraw3D();
474
7b3eaa01 475 break;
476 }
477
a13d7c88 478 case kAEMAll: //saving pictures from all three viewers
479 {
480
481 TGFileInfo fi;
482 fi.fFileTypes = gPictureSaveAsTypes;
483 fi.fIniDir = StrDup(""); // current directory
484 fi.fFileTypeIdx = 0;
485 fi.fOverwrite = kTRUE;
486 new TGFileDialog(gClient->GetDefaultRoot(),
487 gEve->GetMainWindow(), kFDSave, &fi); // dialog
488 if (!fi.fFilename) return;
489
490 TPMERegexp filere(".*/([^/]+$)");
491 if (filere.Match(fi.fFilename) != 2)
492 {
493 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
494 return;
495 }
496
497 TString file1(filere[1]);
498 TString file2(filere[1]);
499 TString file3(filere[1]);
500
501 if (!file1.EndsWith(".png"))
502 file1 += "_3D.png"; // adding extensions
503
504 if (!file2.EndsWith(".png"))
505 file2 += "_RPhi.png"; // adding extensions
506
507 if (!file3.EndsWith(".png"))
508 file3 += "_RhoZ.png"; // adding extensions
509
510 gSystem->ChangeDirectory(fi.fIniDir);
511
512 printf("Saving...\n");
513
514 TEveViewerList *viewers = gEve->GetViewers();
515 TEveElement::List_i i = viewers->BeginChildren();
516 i++;
517 TEveViewer* view3d = ((TEveViewer*)*i);
518 view3d->GetGLViewer()->SavePicture(file1); // saving pictures
519 i++;
520 TEveViewer* viewrphi = ((TEveViewer*)*i);
521 viewrphi->GetGLViewer()->SavePicture(file2); // saving pictures
522 i++;
523 TEveViewer* viewrhoz = ((TEveViewer*)*i);
524 viewrhoz->GetGLViewer()->SavePicture(file3); // saving pictures
525
526 printf("Done.\n");
527
528 break;
529 }
530
531 case kAEM3d: // saving only 3d view
532 {
533
534 TGFileInfo fi;
535 fi.fFileTypes = gPictureSaveAsTypes;
536 fi.fIniDir = StrDup(""); // current directory
537 fi.fFileTypeIdx = 0;
538 fi.fOverwrite = kTRUE;
539 new TGFileDialog(gClient->GetDefaultRoot(),
540 gEve->GetMainWindow(), kFDSave, &fi);
541 if (!fi.fFilename) return;
542
543 TPMERegexp filere(".*/([^/]+$)");
544 if (filere.Match(fi.fFilename) != 2)
545 {
546 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
547 return;
548 }
549
550 TString file1(filere[1]);
551
552 if (!file1.EndsWith(".png"))
553 file1 += ".png";
554
555 gSystem->ChangeDirectory(fi.fIniDir);
556
557 printf("Saving...\n");
558
559 TEveViewerList *viewers = gEve->GetViewers();
560 TEveElement::List_i i = viewers->BeginChildren();
561 i++;
562 TEveViewer* view3d = ((TEveViewer*)*i);
563 view3d->GetGLViewer()->SavePicture(file1);
564
565 printf("Done.\n");
566
567 break;
568 }
569
570 case kAEMRphi: // saving only RPhi view
571 {
572
573 TGFileInfo fi;
574 fi.fFileTypes = gPictureSaveAsTypes;
575 fi.fIniDir = StrDup(""); // current directory
576 fi.fFileTypeIdx = 0;
577 fi.fOverwrite = kTRUE;
578 new TGFileDialog(gClient->GetDefaultRoot(),
579 gEve->GetMainWindow(), kFDSave, &fi);
580 if (!fi.fFilename) return;
581
582 TPMERegexp filere(".*/([^/]+$)");
583 if (filere.Match(fi.fFilename) != 2)
584 {
585 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
586 return;
587 }
588
589 TString file1(filere[1]);
590
591 if (!file1.EndsWith(".png"))
592 file1 += ".png";
593
594 gSystem->ChangeDirectory(fi.fIniDir);
595
596 printf("Saving...\n");
597
598 TEveViewerList *viewers = gEve->GetViewers();
599 TEveElement::List_i i = viewers->BeginChildren();
600 i++;
601 i++;
602 TEveViewer* viewrphi = ((TEveViewer*)*i);
603 viewrphi->GetGLViewer()->SavePicture(file1);
604
605 printf("Done.\n");
606
607 break;
608 }
609
610 case kAEMRhoz: // saving only RhoZ view
611 {
612
613 TGFileInfo fi;
95fb6e56 614 fi.fFileTypes = gPictureSaveAsTypes;
a13d7c88 615 fi.fIniDir = StrDup(""); // current directory
616 fi.fFileTypeIdx = 0;
617 fi.fOverwrite = kTRUE;
618 new TGFileDialog(gClient->GetDefaultRoot(),
619 gEve->GetMainWindow(), kFDSave, &fi);
620 if (!fi.fFilename) return;
621
622 TPMERegexp filere(".*/([^/]+$)");
623 if (filere.Match(fi.fFilename) != 2)
624 {
625 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
626 return;
627 }
628
629 TString file1(filere[1]);
630
631 if (!file1.EndsWith(".png"))
632 file1 += ".png";
633
634 gSystem->ChangeDirectory(fi.fIniDir);
635
636 printf("Saving...\n");
637
638 TEveViewerList *viewers = gEve->GetViewers();
639 TEveElement::List_i i = viewers->BeginChildren();
640 i++;
641 i++;
642 i++;
643 TEveViewer* viewrhoz = ((TEveViewer*)*i);
644 viewrhoz->GetGLViewer()->SavePicture(file1);
645
646 printf("Done.\n");
647
648 break;
649 }
650
651 case kAEMAllhr: // saving all three views in high resolution
652 {
653
654 TGFileInfo fi;
655 fi.fFileTypes = gPictureSaveAsTypes;
656 fi.fIniDir = StrDup(""); // current directory
657 fi.fFileTypeIdx = 0;
658 fi.fOverwrite = kTRUE;
659 new TGFileDialog(gClient->GetDefaultRoot(),
660 gEve->GetMainWindow(), kFDSave, &fi);
661 if (!fi.fFilename) return;
662
663 TPMERegexp filere(".*/([^/]+$)");
664 if (filere.Match(fi.fFilename) != 2)
665 {
666 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
667 return;
668 }
669
670 TString file1(filere[1]);
671 TString file2(filere[1]);
672 TString file3(filere[1]);
673
674 if (!file1.EndsWith(".png"))
675 file1 += "_3D.png";
676
677 if (!file2.EndsWith(".png"))
678 file2 += "_RPhi.png";
679
680 if (!file3.EndsWith(".png"))
681 file3 += "_RhoZ.png";
682
683 gSystem->ChangeDirectory(fi.fIniDir);
684
685 printf("Saving...\n");
686
687 TEveViewerList *viewers = gEve->GetViewers();
688 TEveElement::List_i i = viewers->BeginChildren();
689 i++;
690 TEveViewer* view3d = ((TEveViewer*)*i);
6aafad45 691 view3d->GetGLViewer()->SavePictureScale(file1,6.0); // getting high resolution
a13d7c88 692 i++;
693 TEveViewer* viewrphi = ((TEveViewer*)*i);
6aafad45 694 viewrphi->GetGLViewer()->SavePictureScale(file2,6.0);
a13d7c88 695 i++;
696 TEveViewer* viewrhoz = ((TEveViewer*)*i);
6aafad45 697 viewrhoz->GetGLViewer()->SavePictureScale(file3,6.0);
a13d7c88 698
699 printf("Done.\n");
700
701 break;
702 }
703
704 case kAEM3dhr: // saving only 3d view in high resolution
705 {
706
707 TGFileInfo fi;
708 fi.fFileTypes = gPictureSaveAsTypes;
709 fi.fIniDir = StrDup(""); // current directory
710 fi.fFileTypeIdx = 0;
711 fi.fOverwrite = kTRUE;
712 new TGFileDialog(gClient->GetDefaultRoot(),
713 gEve->GetMainWindow(), kFDSave, &fi);
714 if (!fi.fFilename) return;
715
716 TPMERegexp filere(".*/([^/]+$)");
717 if (filere.Match(fi.fFilename) != 2)
718 {
719 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
720 return;
721 }
722
723 TString file1(filere[1]);
724
725 if (!file1.EndsWith(".png"))
726 file1 += ".png";
727
728 gSystem->ChangeDirectory(fi.fIniDir);
729
730 printf("Saving...\n");
731
732 TEveViewerList *viewers = gEve->GetViewers();
733 TEveElement::List_i i = viewers->BeginChildren();
734 i++;
735 TEveViewer* view3d = ((TEveViewer*)*i);
736 view3d->GetGLViewer()->SavePictureScale(file1,4.0);
737
738 printf("Done.\n");
739
740 break;
741 }
742
743 case kAEMRphihr: // saving only RPhi view in high resolution
744 {
745
746 TGFileInfo fi;
747 fi.fFileTypes = gPictureSaveAsTypes;
748 fi.fIniDir = StrDup(""); // current directory
749 fi.fFileTypeIdx = 0;
750 fi.fOverwrite = kTRUE;
751 new TGFileDialog(gClient->GetDefaultRoot(),
752 gEve->GetMainWindow(), kFDSave, &fi);
753 if (!fi.fFilename) return;
754
755 TPMERegexp filere(".*/([^/]+$)");
756 if (filere.Match(fi.fFilename) != 2)
757 {
758 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
759 return;
760 }
761
762 TString file1(filere[1]);
763
764 if (!file1.EndsWith(".png"))
765 file1 += ".png";
766
767 gSystem->ChangeDirectory(fi.fIniDir);
768
769 printf("Saving...\n");
770
771 TEveViewerList *viewers = gEve->GetViewers();
772 TEveElement::List_i i = viewers->BeginChildren();
773 i++;
774 i++;
775 TEveViewer* viewrphi = ((TEveViewer*)*i);
776 viewrphi->GetGLViewer()->SavePictureScale(file1,4.0);
777
778 printf("Done.\n");
779
780 break;
781 }
782
783 case kAEMRhozhr: // saving only RhoZ view in high resolution
784 {
785
786 TGFileInfo fi;
95fb6e56 787 fi.fFileTypes = gPictureSaveAsTypes;
a13d7c88 788 fi.fIniDir = StrDup(""); // current directory
789 fi.fFileTypeIdx = 0;
790 fi.fOverwrite = kTRUE;
791 new TGFileDialog(gClient->GetDefaultRoot(),
792 gEve->GetMainWindow(), kFDSave, &fi);
793 if (!fi.fFilename) return;
794
795 TPMERegexp filere(".*/([^/]+$)");
796 if (filere.Match(fi.fFilename) != 2)
797 {
798 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
799 return;
800 }
801
802 TString file1(filere[1]);
803
804 if (!file1.EndsWith(".png"))
805 file1 += ".png";
806
807 gSystem->ChangeDirectory(fi.fIniDir);
808
809 printf("Saving...\n");
810
811 TEveViewerList *viewers = gEve->GetViewers();
812 TEveElement::List_i i = viewers->BeginChildren();
813 i++;
814 i++;
815 i++;
816 TEveViewer* viewrhoz = ((TEveViewer*)*i);
817 viewrhoz->GetGLViewer()->SavePictureScale(file1,4.0);
818
819 printf("Done.\n");
820
821 break;
822 }
823
824 case kAEMSavemacros:// Saving Data Selection macros
825 {
826
827 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
828
829 exec->SaveAddedMacros();
830
831 break;
832 }
833
834 case kAEMLoadmacros://Loading Data Selection macros
835 {
836
837 TEveBrowser *browser = gEve->GetBrowser();
838 browser->ShowCloseTab(kFALSE);
839
840 if(fLoadCheck)
841 browser->RemoveTab(TRootBrowser::kRight, 5);//remove the tab with previous DataSelection window
842 else
843 browser->RemoveTab(TRootBrowser::kRight, 2);
844
845
846 TGFileInfo fi;
847 fi.fFileTypes = gMacroSaveAsTypes;
848 fi.fIniDir = StrDup(""); // current directory
849 fi.fFileTypeIdx = 0;
850 fi.fOverwrite = kTRUE;
851 new TGFileDialog(gClient->GetDefaultRoot(), gEve->GetMainWindow(), kFDOpen, &fi);//dialog
852 if (!fi.fFilename) return;
853
854 TPMERegexp filere(".*/([^/]+$)");
855 if (filere.Match(fi.fFilename) != 2)
856 {
857 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
858 return;
859 }
860 printf("Loading...\n");
861
862 TString file(filere[1]);
863 gSystem->ChangeDirectory(fi.fIniDir);
864
865 TEveUtil::Macro(file);//run macro
866
867 AliEveEventManager *eman = AliEveEventManager::GetMaster();//reload event (gEve->Refresh() crashes)
868 Int_t ev = eman->GetEventId();
869 eman->Close();
870 eman->Open();
871 eman->GotoEvent(ev);
872
873 printf("Done.\n");
874
875 fLoadCheck = kTRUE;
876
877 break;
878
879 }
880
881 case kAEMSave://saving VizDB
882 {
883 TGFileInfo fi;
884 fi.fFileTypes = gMacroSaveAsTypes;
885 fi.fIniDir = StrDup(""); // current directory
886 fi.fFileTypeIdx = 0;
887 fi.fOverwrite = kTRUE;
888 new TGFileDialog(gClient->GetDefaultRoot(), gEve->GetMainWindow(), kFDSave, &fi);
889 if (!fi.fFilename) return;
890
891 TPMERegexp filere(".*/([^/]+$)");
892 if (filere.Match(fi.fFilename) != 2)
893 {
894 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
895 return;
896 }
897 printf("Saving...\n");
898
899 TString file(filere[1]);
900 if (!file.EndsWith(".C"))
901 file += ".C";
902 gSystem->ChangeDirectory(fi.fIniDir);
903 gEve->SaveVizDB(file);
904
905//Last line "gEve->SaveVizDB(file);" gives macro with many unnecessary
906//lines like "x038->SetMinPt(0);" tahat are not interpreted properly later
907
908 string text;
909 string all;
910
911 ifstream myfile1(file);
912 if(myfile1.is_open())
913 {
914 while(!myfile1.eof())
915 {
916 getline(myfile1,text);
917 TString check(text);
918 if(!(check.EndsWith("MinPt(0);")||check.EndsWith("MaxPt(0);")
919 ||check.EndsWith("LimPt(0);")||check.EndsWith("MinP(0);")
920 ||check.EndsWith("MaxP(0);")||check.EndsWith("LimP(0);")))
921 {
922 all += text; //Cut off unnecessary lines and bring everything together
923 all += "\n";
924 }
925 }
926 myfile1.close();
927 }
928
929 ofstream myfile2(file); //Replacing old file with the one without "bad" lines
930 myfile2 << all;
931 myfile2.close();
932
933 printf("Done.\n");
934 break;
935
936 }
937
938 case kAEMOpen://Opening VizDB
939 {
940 TGFileInfo fi;
941 fi.fFileTypes = gMacroSaveAsTypes;
942 fi.fIniDir = StrDup(""); // current directory
943 fi.fFileTypeIdx = 0;
944 fi.fOverwrite = kTRUE;
945 new TGFileDialog(gClient->GetDefaultRoot(), gEve->GetMainWindow(), kFDOpen, &fi);
946 if (!fi.fFilename) return;
947
948 TPMERegexp filere(".*/([^/]+$)");
949 if (filere.Match(fi.fFilename) != 2)
950 {
951 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
952 return;
953 }
954 printf("Opening...\n");
955
956 TString file(filere[1]);
957
958 gSystem->ChangeDirectory(fi.fIniDir);
959
960 gEve->LoadVizDB(file, kTRUE, kTRUE);
961
962 gEve->Redraw3D(kTRUE);
963
964 printf("Done.\n");
965 break;
966
967 }
968
d4476392 969 case kAEMSetDefault://Restore default settings
970 {
971
972 printf("Setting...\n");
973
974 TEveBrowser *browser = gEve->GetBrowser();
975 browser->ShowCloseTab(kFALSE);
976
977 if(fLoadCheck)
978 browser->RemoveTab(TRootBrowser::kRight, 5);//remove the tab with previous DataSelection window
979 else
980 browser->RemoveTab(TRootBrowser::kRight, 2);
981
982 TEveUtil::Macro("geom_gentle_default.C");
983 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
984 TEveUtil::Macro("DataSelection_init.C");
985
986 if(!gEve->GetViewers()->UseLightColorSet())
987 gEve->GetViewers()->SwitchColorSet(); //white background
988
989 AliEveEventManager *eman = AliEveEventManager::GetMaster();//reload event (gEve->Refresh() crashes)
990 Int_t ev = eman->GetEventId();
991 eman->Close();
992 eman->Open();
993 eman->GotoEvent(ev);
994
995 printf("Done.\n");
996
997 fLoadCheck = kTRUE;
998
999 gEve->Redraw3D(kTRUE);
1000
1001
1002 }
1003
6aafad45 1004/*
1005 case kAEMResiduals:
1006 {
1007
1008 TEveUtil::Macro("make_residuals.C");
1009
1010 break;
1011
1012 }
1013*/
1014
1015 case kAEMCuts:
1016 {
1017
1018 TEveUtil::Macro("alieve_set_cuts.C");
1019
1020 break;
1021
1022 }
1023
1024 case kAEMVectors:
1025 {
1026
1027 TEveUtil::Macro("set_momentum_vectors.C");
1028
1029 break;
1030
1031 }
1032
1033/*
1034 case kAEMGui:
1035 {
1036
1037 TEveUtil::Macro("alieve_gui_mode.C");
1038
1039 break;
1040
1041 }
1042*/
fae81379 1043 /*
0790c3e6 1044 case kStorageListEvents:
1045 {
9211a1f1 1046#ifdef ZMQ
0790c3e6 1047 fListEventsWindow =
1048 AliStorageAdministratorPanelListEvents::GetInstance();
1049
1050 fListEventsWindow->Connect("SelectedEvent()","AliEveConfigManager",this,"SetEventInEventManager()");
1051#endif
1052 break;
1053
1054 }
fae81379 1055 */
0790c3e6 1056 case kStorageMarkEvent:
1057 {
9211a1f1 1058#ifdef ZMQ
0790c3e6 1059 AliStorageAdministratorPanelMarkEvent *markEventWindow =
1060 AliStorageAdministratorPanelMarkEvent::GetInstance();
9211a1f1 1061#endif
0790c3e6 1062 break;
1063 }
1064
1065 default:
1066 {
1067 Warning(kEH, "Unknown menu entry.");
1068 break;
1069 }
7b3eaa01 1070 }
1071}
164d3d29 1072
1073void AliEveConfigManager::SetEventInEventManager()
1074{
e6194cd4 1075#ifdef ZMQ
1076
164d3d29 1077 AliEveEventManager *manager = AliEveEventManager::GetMaster();
e6194cd4 1078 AliStorageAdministratorPanelListEvents* fListEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
fae81379 1079 AliESDEvent *event = fListEventsTab->GetSelectedEvent();
164d3d29 1080
1081 if(event)
1082 {
1083 cout<<"SETTING EVENT IN ED"<<endl;
1084 //fListEventsWindow->onExit();
1085 manager->SetAutoLoad(kFALSE);
1086 manager->PrepareForNewEvent(event);
1087 }
e6194cd4 1088#endif
0790c3e6 1089}
1090
1091void AliEveConfigManager::StorageManagerChangedState(int state)
1092{
7f97b015 1093 AliEveEventManager *manager = AliEveEventManager::GetMaster();
1094 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
1095
1096 if (manager->IsOnlineMode()) {
1097 if (state == 0)// storage manager is down
1098 {
1099 listEventsTab->SetOfflineMode(kTRUE);
1100 }
1101 else if(state == 1)// storage manager is alive
1102 {
1103 listEventsTab->SetOfflineMode(kFALSE);
1104 }
1105 }
164d3d29 1106}
1107
1108