From Pawel Debski.
[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
3aff0c2e 24class AliEveMacroExecutor;
25class TEveProjectionManager;
26class TEveGeoShape;
27class TEveUtil;
28
29#include <TSystem.h>
30#include <TPRegexp.h>
7b3eaa01 31#include <RVersion.h>
32
33//______________________________________________________________________________
34// Full description of AliEveConfigManager
35//
36
37ClassImp(AliEveConfigManager)
38
39AliEveConfigManager* AliEveConfigManager::fgMaster = 0;
40
41namespace
42{
43 enum EAliEveMenu_e
44 {
a13d7c88 45 kAEMDefault, kAEMScreen, kAEMProjector, kAEMNotransparency, kAEMTransparentDark, kAEMTransparentLight, kAEMTransparentMonoDark, kAEMTransparentMonoLight, kAEMGreen, kAEMBright, kAEMYellow, kAEMTpc, kAEMAll, kAEM3d, kAEMRphi, kAEMRhoz, kAEMAllhr, kAEM3dhr, kAEMRphihr, kAEMRhozhr, kAEMSavemacros, kAEMLoadmacros, kAEMSave, kAEMOpen
7b3eaa01 46 };
47}
48
49//______________________________________________________________________________
50AliEveConfigManager* AliEveConfigManager::InitializeMaster()
51{
52 // Get main instance.
53
54 static const TEveException kEH("AliEveConfigManager::InitializeMaster ");
55
56 if (fgMaster)
57 throw kEH + "Master already initialized.";
58
59 fgMaster = new AliEveConfigManager;
60 return fgMaster;
61}
62
63//______________________________________________________________________________
64AliEveConfigManager* AliEveConfigManager::GetMaster()
65{
66 // Get main instance.
67
68 static const TEveException kEH("AliEveConfigManager::GetMaster ");
69
70 if (!fgMaster)
71 throw kEH + "Master not initialized.";
72
73 return fgMaster;
74}
75
76//______________________________________________________________________________
77AliEveConfigManager::AliEveConfigManager() :
78 TObject(),
79 fAliEvePopup(0)
80{
81 // Constructor.
82 // Expected TEveManager is already initialized.
83
84 fAliEvePopup = new TGPopupMenu(gClient->GetRoot());
3aff0c2e 85
86 fAliEvePopup->AddEntry("&Default", kAEMDefault);
87 fAliEvePopup->AddEntry("&Screen", kAEMScreen);
88 fAliEvePopup->AddEntry("&Projector", kAEMProjector);
89
90 fAliEvePopup->AddSeparator();
91
a13d7c88 92 fAliEvePopup->AddEntry("&Low transparency", kAEMNotransparency);
93
94 fAliEvePopup->AddSeparator();
95
3aff0c2e 96 fAliEvePopup->AddEntry("&Transparent screen", kAEMTransparentDark);
97 fAliEvePopup->AddEntry("&Transparent projector", kAEMTransparentLight);
98 fAliEvePopup->AddEntry("&Transparent mono dark", kAEMTransparentMonoDark);
99 fAliEvePopup->AddEntry("&Transparent mono light", kAEMTransparentMonoLight);
100
101 fAliEvePopup->AddSeparator();
102
a13d7c88 103 fAliEvePopup->AddEntry("&First collision setup", kAEMGreen);
104 fAliEvePopup->AddEntry("&Bright", kAEMBright);
105
106 fAliEvePopup->AddSeparator();
107
108 fAliEvePopup->AddEntry("&TPC Yellow", kAEMYellow);
109 fAliEvePopup->AddEntry("&TPC Blue", kAEMTpc);
110
111 fAliEvePopup->AddSeparator();
112 fAliEvePopup->AddSeparator();
113 fAliEvePopup->AddSeparator();
114
115 fAliEvePopup->AddEntry("&Save all views", kAEMAll);
116 fAliEvePopup->AddEntry("&Save 3D View", kAEM3d);
117 fAliEvePopup->AddEntry("&Save RPhi View", kAEMRphi);
118 fAliEvePopup->AddEntry("&Save RhoZ View", kAEMRhoz);
119
120 fAliEvePopup->AddSeparator();
121
122 fAliEvePopup->AddEntry("&Save all views HR", kAEMAllhr);
123 fAliEvePopup->AddEntry("&Save 3D View HR", kAEM3dhr);
124 fAliEvePopup->AddEntry("&Save RPhi View HR", kAEMRphihr);
125 fAliEvePopup->AddEntry("&Save RhoZ View HR", kAEMRhozhr);
126
127 fAliEvePopup->AddSeparator();
128 fAliEvePopup->AddSeparator();
129 fAliEvePopup->AddSeparator();
130
131 fAliEvePopup->AddEntry("&Save Data Selection macros", kAEMSavemacros);
132 fAliEvePopup->AddEntry("&Load Data Selection macros", kAEMLoadmacros);
133
134 fAliEvePopup->AddSeparator();
135 fAliEvePopup->AddSeparator();
136 fAliEvePopup->AddSeparator();
137
138 fAliEvePopup->AddEntry("&Save VizDB", kAEMSave);
139 fAliEvePopup->AddEntry("&Load VizDB", kAEMOpen);
7b3eaa01 140
141 fAliEvePopup->AddSeparator();
142
143 fAliEvePopup->Connect("Activated(Int_t)", "AliEveConfigManager",
144 this, "AliEvePopupHandler(Int_t)");
a13d7c88 145 fLoadCheck = kFALSE;
7b3eaa01 146
06219f85 147#if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,4)
148 TGMenuBar *mBar = gEve->GetBrowser()->GetMenuBar();
149 mBar->AddPopup("&AliEve", fAliEvePopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
150 gEve->GetBrowser()->GetTopMenuFrame()->Layout();
7b3eaa01 151#else
152 // Uber hack as TRootBrowser does not provede manu-bar getter.
153 TGFrameElement *xxFE = (TGFrameElement*) gEve->GetBrowser()->GetList()->First();
154 TGCompositeFrame *xxCF = (TGCompositeFrame*) xxFE->fFrame;
155 xxFE = (TGFrameElement*) xxCF->GetList()->First();
156 xxCF = (TGCompositeFrame*) xxFE->fFrame;
157 xxFE = (TGFrameElement*) xxCF->GetList()->First();
158 xxCF = (TGCompositeFrame*) xxFE->fFrame;
159 xxFE = (TGFrameElement*) xxCF->GetList()->First();
06219f85 160 TGMenuBar *mBar = (TGMenuBar*) xxFE->fFrame;
7b3eaa01 161 mBar->AddPopup("&AliEve", fAliEvePopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
162 ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
06219f85 163#endif
7b3eaa01 164}
165
166//==============================================================================
167
a13d7c88 168#include <iostream>
169#include <fstream>
170#include <string>
171#include <sstream>
172
173using namespace std;
174
3aff0c2e 175namespace
176{
177const char *gMacroSaveAsTypes[] = {"CINT Macro", "*.C",
a13d7c88 178 0, 0}; //for saving/loading macros
179
180const char *gPictureSaveAsTypes[] = {"PNG Image", "*.png",
181 0, 0}; //for saving pictures
182
3aff0c2e 183}
184
7b3eaa01 185void AliEveConfigManager::AliEvePopupHandler(Int_t id)
186{
187 // Handle user selections from AliEve popup.
188
189 static const TEveException kEH("AliEveConfigManager::AliEvePopupHandler ");
190
191 switch (id)
192 {
3aff0c2e 193
a13d7c88 194 case kAEMDefault: //default geometry and VizDB
195 {
196 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 197
a13d7c88 198 mv->DestroyAllGeometries(); //destroy RPhi and Rhoz geometries before putting new
3aff0c2e 199
a13d7c88 200 gEve->LoadVizDB("geom_gentle_default.C", kTRUE, kTRUE); //loading geometry
3aff0c2e 201
a13d7c88 202 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE); //loading VizDB
3aff0c2e 203
a13d7c88 204 if(!gEve->GetViewers()->UseLightColorSet())
205 gEve->GetViewers()->SwitchColorSet(); //white background
3aff0c2e 206
a13d7c88 207 gEve->FullRedraw3D();
208
3aff0c2e 209 break;
3aff0c2e 210 }
211
a13d7c88 212 case kAEMScreen: //default geometry with black background
3aff0c2e 213 {
a13d7c88 214 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 215
a13d7c88 216 mv->DestroyAllGeometries();
3aff0c2e 217
218 gEve->LoadVizDB("geom_gentle_default.C", kTRUE, kTRUE);
219
a13d7c88 220 gEve->LoadVizDB("VizDB_scan_screen.C", kTRUE, kTRUE);
3aff0c2e 221
222 if(gEve->GetViewers()->UseLightColorSet())
223 gEve->GetViewers()->SwitchColorSet();
224
a13d7c88 225 gEve->FullRedraw3D();
226
3aff0c2e 227 break;
228 }
229
a13d7c88 230 case kAEMProjector: //default geometry with white background
3aff0c2e 231 {
a13d7c88 232 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 233
a13d7c88 234 mv->DestroyAllGeometries();
3aff0c2e 235
95fb6e56 236 gEve->LoadVizDB("geom_gentle_projector.C", kTRUE, kTRUE);
3aff0c2e 237
a13d7c88 238 gEve->LoadVizDB("VizDB_scan_projector.C", kTRUE, kTRUE);
3aff0c2e 239
a13d7c88 240 if(!gEve->GetViewers()->UseLightColorSet())
3aff0c2e 241 gEve->GetViewers()->SwitchColorSet();
242
243 gEve->FullRedraw3D();
244
245 break;
246 }
247
a13d7c88 248 case kAEMNotransparency: //default geometry with low transparency (5%)
3aff0c2e 249 {
a13d7c88 250 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 251
a13d7c88 252 mv->DestroyAllGeometries();
3aff0c2e 253
a13d7c88 254 gEve->LoadVizDB("geom_gentle_notransparency.C", kTRUE, kTRUE);
3aff0c2e 255
a13d7c88 256 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
3aff0c2e 257
258 if(!gEve->GetViewers()->UseLightColorSet())
259 gEve->GetViewers()->SwitchColorSet();
260
261 gEve->FullRedraw3D();
262
263 break;
264 }
265
3aff0c2e 266
a13d7c88 267 case kAEMTransparentDark: //default geometry with black background, high transparency (80%)
268 {
269 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 270
a13d7c88 271 mv->DestroyAllGeometries();
3aff0c2e 272
273 gEve->LoadVizDB("geom_gentle_transparent.C", kTRUE, kTRUE);
274
275 gEve->LoadVizDB("VizDB_scan_transparentdark.C", kTRUE, kTRUE);
276
277 if(gEve->GetViewers()->UseLightColorSet())
278 gEve->GetViewers()->SwitchColorSet();
279
280 gEve->FullRedraw3D();
281
282 break;
283 }
284
a13d7c88 285 case kAEMTransparentLight: //default geometry with white background, high transparency (80%)
3aff0c2e 286 {
a13d7c88 287 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 288
a13d7c88 289 mv->DestroyAllGeometries();
3aff0c2e 290
291 gEve->LoadVizDB("geom_gentle_transparent.C", kTRUE, kTRUE);
292
293 gEve->LoadVizDB("VizDB_scan_transparentlight.C", kTRUE, kTRUE);
294
295 if(!gEve->GetViewers()->UseLightColorSet())
296 gEve->GetViewers()->SwitchColorSet();
297
298 gEve->FullRedraw3D();
299
300 break;
301 }
302
303 case kAEMTransparentMonoDark:
304 {
a13d7c88 305 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 306
a13d7c88 307 mv->DestroyAllGeometries();
3aff0c2e 308
309 gEve->LoadVizDB("geom_gentle_transparentdark.C", kTRUE, kTRUE);
310
311 gEve->LoadVizDB("VizDB_scan_transparentdark.C", kTRUE, kTRUE);
312
313 if(gEve->GetViewers()->UseLightColorSet())
314 gEve->GetViewers()->SwitchColorSet();
315
316 gEve->FullRedraw3D();
317
318 break;
319 }
320
321 case kAEMTransparentMonoLight:
322 {
a13d7c88 323 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 324
a13d7c88 325 mv->DestroyAllGeometries();
3aff0c2e 326
327 gEve->LoadVizDB("geom_gentle_transparentlight.C", kTRUE, kTRUE);
328
329 gEve->LoadVizDB("VizDB_scan_transparentlight.C", kTRUE, kTRUE);
330
331 if(!gEve->GetViewers()->UseLightColorSet())
332 gEve->GetViewers()->SwitchColorSet();
333
334 gEve->FullRedraw3D();
335
336 break;
337 }
338
a13d7c88 339 case kAEMGreen:
340 {
341 AliEveMultiView *mv = AliEveMultiView::Instance();
342
343 mv->DestroyAllGeometries();
344
345 gEve->LoadVizDB("geom_gentle_green.C", kTRUE, kTRUE);
346
347 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
348
349 if(!gEve->GetViewers()->UseLightColorSet())
350 gEve->GetViewers()->SwitchColorSet();
351
352 gEve->FullRedraw3D();
353
354 break;
355 }
356
357 case kAEMBright:
3aff0c2e 358 {
a13d7c88 359 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 360
a13d7c88 361 mv->DestroyAllGeometries();
3aff0c2e 362
a13d7c88 363 gEve->LoadVizDB("geom_gentle_bright.C", kTRUE, kTRUE);
364
365 gEve->LoadVizDB("VizDB_scan.C", kTRUE, kTRUE);
366
367 if(gEve->GetViewers()->UseLightColorSet())
368 gEve->GetViewers()->SwitchColorSet();
369
370 gEve->FullRedraw3D();
371
372 break;
373 }
374
375 case kAEMYellow:
376 {
377 AliEveMultiView *mv = AliEveMultiView::Instance();
3aff0c2e 378
a13d7c88 379 mv->DestroyAllGeometries();
380
381 gEve->LoadVizDB("geom_gentle_yellow.C", kTRUE, kTRUE);
382
383 gEve->LoadVizDB("VizDB_scan_yellow.C", kTRUE, kTRUE);
384
385 if(!gEve->GetViewers()->UseLightColorSet())
386 gEve->GetViewers()->SwitchColorSet();
387
388 gEve->FullRedraw3D();
389
390 break;
391 }
392
393 case kAEMTpc:
394 {
395 AliEveMultiView *mv = AliEveMultiView::Instance();
396
397 mv->DestroyAllGeometries();
3aff0c2e 398
399 gEve->LoadVizDB("geom_gentle_tpc.C", kTRUE, kTRUE);
400
401 gEve->LoadVizDB("VizDB_scan_tpc.C", kTRUE, kTRUE);
402
403 if(!gEve->GetViewers()->UseLightColorSet())
404 gEve->GetViewers()->SwitchColorSet();
405
406 gEve->FullRedraw3D();
407
7b3eaa01 408 break;
409 }
410
a13d7c88 411 case kAEMAll: //saving pictures from all three viewers
412 {
413
414 TGFileInfo fi;
415 fi.fFileTypes = gPictureSaveAsTypes;
416 fi.fIniDir = StrDup(""); // current directory
417 fi.fFileTypeIdx = 0;
418 fi.fOverwrite = kTRUE;
419 new TGFileDialog(gClient->GetDefaultRoot(),
420 gEve->GetMainWindow(), kFDSave, &fi); // dialog
421 if (!fi.fFilename) return;
422
423 TPMERegexp filere(".*/([^/]+$)");
424 if (filere.Match(fi.fFilename) != 2)
425 {
426 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
427 return;
428 }
429
430 TString file1(filere[1]);
431 TString file2(filere[1]);
432 TString file3(filere[1]);
433
434 if (!file1.EndsWith(".png"))
435 file1 += "_3D.png"; // adding extensions
436
437 if (!file2.EndsWith(".png"))
438 file2 += "_RPhi.png"; // adding extensions
439
440 if (!file3.EndsWith(".png"))
441 file3 += "_RhoZ.png"; // adding extensions
442
443 gSystem->ChangeDirectory(fi.fIniDir);
444
445 printf("Saving...\n");
446
447 TEveViewerList *viewers = gEve->GetViewers();
448 TEveElement::List_i i = viewers->BeginChildren();
449 i++;
450 TEveViewer* view3d = ((TEveViewer*)*i);
451 view3d->GetGLViewer()->SavePicture(file1); // saving pictures
452 i++;
453 TEveViewer* viewrphi = ((TEveViewer*)*i);
454 viewrphi->GetGLViewer()->SavePicture(file2); // saving pictures
455 i++;
456 TEveViewer* viewrhoz = ((TEveViewer*)*i);
457 viewrhoz->GetGLViewer()->SavePicture(file3); // saving pictures
458
459 printf("Done.\n");
460
461 break;
462 }
463
464 case kAEM3d: // saving only 3d view
465 {
466
467 TGFileInfo fi;
468 fi.fFileTypes = gPictureSaveAsTypes;
469 fi.fIniDir = StrDup(""); // current directory
470 fi.fFileTypeIdx = 0;
471 fi.fOverwrite = kTRUE;
472 new TGFileDialog(gClient->GetDefaultRoot(),
473 gEve->GetMainWindow(), kFDSave, &fi);
474 if (!fi.fFilename) return;
475
476 TPMERegexp filere(".*/([^/]+$)");
477 if (filere.Match(fi.fFilename) != 2)
478 {
479 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
480 return;
481 }
482
483 TString file1(filere[1]);
484
485 if (!file1.EndsWith(".png"))
486 file1 += ".png";
487
488 gSystem->ChangeDirectory(fi.fIniDir);
489
490 printf("Saving...\n");
491
492 TEveViewerList *viewers = gEve->GetViewers();
493 TEveElement::List_i i = viewers->BeginChildren();
494 i++;
495 TEveViewer* view3d = ((TEveViewer*)*i);
496 view3d->GetGLViewer()->SavePicture(file1);
497
498 printf("Done.\n");
499
500 break;
501 }
502
503 case kAEMRphi: // saving only RPhi view
504 {
505
506 TGFileInfo fi;
507 fi.fFileTypes = gPictureSaveAsTypes;
508 fi.fIniDir = StrDup(""); // current directory
509 fi.fFileTypeIdx = 0;
510 fi.fOverwrite = kTRUE;
511 new TGFileDialog(gClient->GetDefaultRoot(),
512 gEve->GetMainWindow(), kFDSave, &fi);
513 if (!fi.fFilename) return;
514
515 TPMERegexp filere(".*/([^/]+$)");
516 if (filere.Match(fi.fFilename) != 2)
517 {
518 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
519 return;
520 }
521
522 TString file1(filere[1]);
523
524 if (!file1.EndsWith(".png"))
525 file1 += ".png";
526
527 gSystem->ChangeDirectory(fi.fIniDir);
528
529 printf("Saving...\n");
530
531 TEveViewerList *viewers = gEve->GetViewers();
532 TEveElement::List_i i = viewers->BeginChildren();
533 i++;
534 i++;
535 TEveViewer* viewrphi = ((TEveViewer*)*i);
536 viewrphi->GetGLViewer()->SavePicture(file1);
537
538 printf("Done.\n");
539
540 break;
541 }
542
543 case kAEMRhoz: // saving only RhoZ view
544 {
545
546 TGFileInfo fi;
95fb6e56 547 fi.fFileTypes = gPictureSaveAsTypes;
a13d7c88 548 fi.fIniDir = StrDup(""); // current directory
549 fi.fFileTypeIdx = 0;
550 fi.fOverwrite = kTRUE;
551 new TGFileDialog(gClient->GetDefaultRoot(),
552 gEve->GetMainWindow(), kFDSave, &fi);
553 if (!fi.fFilename) return;
554
555 TPMERegexp filere(".*/([^/]+$)");
556 if (filere.Match(fi.fFilename) != 2)
557 {
558 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
559 return;
560 }
561
562 TString file1(filere[1]);
563
564 if (!file1.EndsWith(".png"))
565 file1 += ".png";
566
567 gSystem->ChangeDirectory(fi.fIniDir);
568
569 printf("Saving...\n");
570
571 TEveViewerList *viewers = gEve->GetViewers();
572 TEveElement::List_i i = viewers->BeginChildren();
573 i++;
574 i++;
575 i++;
576 TEveViewer* viewrhoz = ((TEveViewer*)*i);
577 viewrhoz->GetGLViewer()->SavePicture(file1);
578
579 printf("Done.\n");
580
581 break;
582 }
583
584 case kAEMAllhr: // saving all three views in high resolution
585 {
586
587 TGFileInfo fi;
588 fi.fFileTypes = gPictureSaveAsTypes;
589 fi.fIniDir = StrDup(""); // current directory
590 fi.fFileTypeIdx = 0;
591 fi.fOverwrite = kTRUE;
592 new TGFileDialog(gClient->GetDefaultRoot(),
593 gEve->GetMainWindow(), kFDSave, &fi);
594 if (!fi.fFilename) return;
595
596 TPMERegexp filere(".*/([^/]+$)");
597 if (filere.Match(fi.fFilename) != 2)
598 {
599 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
600 return;
601 }
602
603 TString file1(filere[1]);
604 TString file2(filere[1]);
605 TString file3(filere[1]);
606
607 if (!file1.EndsWith(".png"))
608 file1 += "_3D.png";
609
610 if (!file2.EndsWith(".png"))
611 file2 += "_RPhi.png";
612
613 if (!file3.EndsWith(".png"))
614 file3 += "_RhoZ.png";
615
616 gSystem->ChangeDirectory(fi.fIniDir);
617
618 printf("Saving...\n");
619
620 TEveViewerList *viewers = gEve->GetViewers();
621 TEveElement::List_i i = viewers->BeginChildren();
622 i++;
623 TEveViewer* view3d = ((TEveViewer*)*i);
624 view3d->GetGLViewer()->SavePictureScale(file1,4.0); // getting high resolution
625 i++;
626 TEveViewer* viewrphi = ((TEveViewer*)*i);
627 viewrphi->GetGLViewer()->SavePictureScale(file2,4.0);
628 i++;
629 TEveViewer* viewrhoz = ((TEveViewer*)*i);
630 viewrhoz->GetGLViewer()->SavePictureScale(file3,4.0);
631
632 printf("Done.\n");
633
634 break;
635 }
636
637 case kAEM3dhr: // saving only 3d view in high resolution
638 {
639
640 TGFileInfo fi;
641 fi.fFileTypes = gPictureSaveAsTypes;
642 fi.fIniDir = StrDup(""); // current directory
643 fi.fFileTypeIdx = 0;
644 fi.fOverwrite = kTRUE;
645 new TGFileDialog(gClient->GetDefaultRoot(),
646 gEve->GetMainWindow(), kFDSave, &fi);
647 if (!fi.fFilename) return;
648
649 TPMERegexp filere(".*/([^/]+$)");
650 if (filere.Match(fi.fFilename) != 2)
651 {
652 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
653 return;
654 }
655
656 TString file1(filere[1]);
657
658 if (!file1.EndsWith(".png"))
659 file1 += ".png";
660
661 gSystem->ChangeDirectory(fi.fIniDir);
662
663 printf("Saving...\n");
664
665 TEveViewerList *viewers = gEve->GetViewers();
666 TEveElement::List_i i = viewers->BeginChildren();
667 i++;
668 TEveViewer* view3d = ((TEveViewer*)*i);
669 view3d->GetGLViewer()->SavePictureScale(file1,4.0);
670
671 printf("Done.\n");
672
673 break;
674 }
675
676 case kAEMRphihr: // saving only RPhi view in high resolution
677 {
678
679 TGFileInfo fi;
680 fi.fFileTypes = gPictureSaveAsTypes;
681 fi.fIniDir = StrDup(""); // current directory
682 fi.fFileTypeIdx = 0;
683 fi.fOverwrite = kTRUE;
684 new TGFileDialog(gClient->GetDefaultRoot(),
685 gEve->GetMainWindow(), kFDSave, &fi);
686 if (!fi.fFilename) return;
687
688 TPMERegexp filere(".*/([^/]+$)");
689 if (filere.Match(fi.fFilename) != 2)
690 {
691 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
692 return;
693 }
694
695 TString file1(filere[1]);
696
697 if (!file1.EndsWith(".png"))
698 file1 += ".png";
699
700 gSystem->ChangeDirectory(fi.fIniDir);
701
702 printf("Saving...\n");
703
704 TEveViewerList *viewers = gEve->GetViewers();
705 TEveElement::List_i i = viewers->BeginChildren();
706 i++;
707 i++;
708 TEveViewer* viewrphi = ((TEveViewer*)*i);
709 viewrphi->GetGLViewer()->SavePictureScale(file1,4.0);
710
711 printf("Done.\n");
712
713 break;
714 }
715
716 case kAEMRhozhr: // saving only RhoZ view in high resolution
717 {
718
719 TGFileInfo fi;
95fb6e56 720 fi.fFileTypes = gPictureSaveAsTypes;
a13d7c88 721 fi.fIniDir = StrDup(""); // current directory
722 fi.fFileTypeIdx = 0;
723 fi.fOverwrite = kTRUE;
724 new TGFileDialog(gClient->GetDefaultRoot(),
725 gEve->GetMainWindow(), kFDSave, &fi);
726 if (!fi.fFilename) return;
727
728 TPMERegexp filere(".*/([^/]+$)");
729 if (filere.Match(fi.fFilename) != 2)
730 {
731 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
732 return;
733 }
734
735 TString file1(filere[1]);
736
737 if (!file1.EndsWith(".png"))
738 file1 += ".png";
739
740 gSystem->ChangeDirectory(fi.fIniDir);
741
742 printf("Saving...\n");
743
744 TEveViewerList *viewers = gEve->GetViewers();
745 TEveElement::List_i i = viewers->BeginChildren();
746 i++;
747 i++;
748 i++;
749 TEveViewer* viewrhoz = ((TEveViewer*)*i);
750 viewrhoz->GetGLViewer()->SavePictureScale(file1,4.0);
751
752 printf("Done.\n");
753
754 break;
755 }
756
757 case kAEMSavemacros:// Saving Data Selection macros
758 {
759
760 AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
761
762 exec->SaveAddedMacros();
763
764 break;
765 }
766
767 case kAEMLoadmacros://Loading Data Selection macros
768 {
769
770 TEveBrowser *browser = gEve->GetBrowser();
771 browser->ShowCloseTab(kFALSE);
772
773 if(fLoadCheck)
774 browser->RemoveTab(TRootBrowser::kRight, 5);//remove the tab with previous DataSelection window
775 else
776 browser->RemoveTab(TRootBrowser::kRight, 2);
777
778
779 TGFileInfo fi;
780 fi.fFileTypes = gMacroSaveAsTypes;
781 fi.fIniDir = StrDup(""); // current directory
782 fi.fFileTypeIdx = 0;
783 fi.fOverwrite = kTRUE;
784 new TGFileDialog(gClient->GetDefaultRoot(), gEve->GetMainWindow(), kFDOpen, &fi);//dialog
785 if (!fi.fFilename) return;
786
787 TPMERegexp filere(".*/([^/]+$)");
788 if (filere.Match(fi.fFilename) != 2)
789 {
790 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
791 return;
792 }
793 printf("Loading...\n");
794
795 TString file(filere[1]);
796 gSystem->ChangeDirectory(fi.fIniDir);
797
798 TEveUtil::Macro(file);//run macro
799
800 AliEveEventManager *eman = AliEveEventManager::GetMaster();//reload event (gEve->Refresh() crashes)
801 Int_t ev = eman->GetEventId();
802 eman->Close();
803 eman->Open();
804 eman->GotoEvent(ev);
805
806 printf("Done.\n");
807
808 fLoadCheck = kTRUE;
809
810 break;
811
812 }
813
814 case kAEMSave://saving VizDB
815 {
816 TGFileInfo fi;
817 fi.fFileTypes = gMacroSaveAsTypes;
818 fi.fIniDir = StrDup(""); // current directory
819 fi.fFileTypeIdx = 0;
820 fi.fOverwrite = kTRUE;
821 new TGFileDialog(gClient->GetDefaultRoot(), gEve->GetMainWindow(), kFDSave, &fi);
822 if (!fi.fFilename) return;
823
824 TPMERegexp filere(".*/([^/]+$)");
825 if (filere.Match(fi.fFilename) != 2)
826 {
827 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
828 return;
829 }
830 printf("Saving...\n");
831
832 TString file(filere[1]);
833 if (!file.EndsWith(".C"))
834 file += ".C";
835 gSystem->ChangeDirectory(fi.fIniDir);
836 gEve->SaveVizDB(file);
837
838//Last line "gEve->SaveVizDB(file);" gives macro with many unnecessary
839//lines like "x038->SetMinPt(0);" tahat are not interpreted properly later
840
841 string text;
842 string all;
843
844 ifstream myfile1(file);
845 if(myfile1.is_open())
846 {
847 while(!myfile1.eof())
848 {
849 getline(myfile1,text);
850 TString check(text);
851 if(!(check.EndsWith("MinPt(0);")||check.EndsWith("MaxPt(0);")
852 ||check.EndsWith("LimPt(0);")||check.EndsWith("MinP(0);")
853 ||check.EndsWith("MaxP(0);")||check.EndsWith("LimP(0);")))
854 {
855 all += text; //Cut off unnecessary lines and bring everything together
856 all += "\n";
857 }
858 }
859 myfile1.close();
860 }
861
862 ofstream myfile2(file); //Replacing old file with the one without "bad" lines
863 myfile2 << all;
864 myfile2.close();
865
866 printf("Done.\n");
867 break;
868
869 }
870
871 case kAEMOpen://Opening VizDB
872 {
873 TGFileInfo fi;
874 fi.fFileTypes = gMacroSaveAsTypes;
875 fi.fIniDir = StrDup(""); // current directory
876 fi.fFileTypeIdx = 0;
877 fi.fOverwrite = kTRUE;
878 new TGFileDialog(gClient->GetDefaultRoot(), gEve->GetMainWindow(), kFDOpen, &fi);
879 if (!fi.fFilename) return;
880
881 TPMERegexp filere(".*/([^/]+$)");
882 if (filere.Match(fi.fFilename) != 2)
883 {
884 Warning("AliEvePopupHandler", "file '%s' bad.", fi.fFilename);
885 return;
886 }
887 printf("Opening...\n");
888
889 TString file(filere[1]);
890
891 gSystem->ChangeDirectory(fi.fIniDir);
892
893 gEve->LoadVizDB(file, kTRUE, kTRUE);
894
895 gEve->Redraw3D(kTRUE);
896
897 printf("Done.\n");
898 break;
899
900 }
901
7b3eaa01 902 default:
903 {
904 Warning(kEH, "Unknown menu entry.");
905 break;
906 }
907 }
908}