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