]>
Commit | Line | Data |
---|---|---|
ef42d733 | 1 | /* ************************************************************************* |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
18 | Revision 1.8 2000/07/12 08:56:32 fca | |
19 | Coding convention correction and warning removal | |
20 | ||
21 | Revision 1.7 2000/06/28 21:27:45 morsch | |
22 | Most coding rule violations corrected. | |
23 | Still to do: Split the file (on file per class) ? Avoid the global variables. | |
24 | Copy constructors and assignment operators (dummy ?) | |
25 | ||
26 | Revision 1.6 2000/04/14 11:07:46 morsch | |
27 | Correct volume to medium assignment in case several media are asigned to the | |
28 | same material. | |
29 | ||
30 | Revision 1.5 2000/03/20 15:11:03 fca | |
31 | Mods to make the code compile on HP | |
32 | ||
33 | Revision 1.4 2000/01/18 16:12:08 morsch | |
34 | Bug in calculation of number of volume divisions and number of positionings corrected | |
35 | Browser for Material and Media properties added | |
36 | ||
37 | Revision 1.3 1999/11/14 14:31:14 fca | |
38 | Correct small error and remove compilation warnings on HP | |
39 | ||
40 | Revision 1.2 1999/11/10 16:53:35 fca | |
41 | The new geometry viewer from A.Morsch | |
42 | ||
43 | */ | |
44 | ||
45 | /* | |
46 | * Version: 0 | |
47 | * Written by Andreas Morsch | |
48 | * | |
49 | * | |
50 | * | |
51 | * For questions critics and suggestions to this part of the code | |
52 | * contact andreas.morsch@cern.ch | |
53 | * | |
54 | **************************************************************************/ | |
55 | ||
56 | #include <stdlib.h> | |
57 | ||
58 | #include "TGMsgBox.h" | |
59 | #include "TGMenu.h" | |
60 | #include "TGTab.h" | |
61 | #include "TGFrame.h" | |
62 | #include "TGTextBuffer.h" | |
63 | #include "TGTextEntry.h" | |
64 | #include "TGLabel.h" | |
65 | #include "TGButton.h" | |
66 | #include "TGraph.h" | |
67 | #include "TCanvas.h" | |
68 | #include "TH1.h" | |
69 | #include "TApplication.h" | |
70 | #include "TGFileDialog.h" | |
71 | ||
72 | #include "AliGuiGeomMain.h" | |
73 | #include "AliGUIMaterial.h" | |
74 | #include "AliGuiGeomDialog.h" | |
75 | #include "AliDrawVolume.h" | |
76 | #include "AliGUIMedium.h" | |
77 | #include "TGeant3.h" | |
78 | ||
79 | ClassImp(AliGuiGeomMain) | |
80 | ||
81 | static Int_t gCurrentParticle = 1; | |
82 | static Int_t gCurrentProcess = 1; | |
83 | ||
84 | const Text_t* kLabelTextP[19] = | |
85 | {"PAIR ", "COMP ", "PHOT ", "PFIS ", "DRAY ", "ANNI ", "BREM ", | |
86 | "HADR ", "MUNU ", "DCAY ", "LOSS ", "MULS ", "GHCOR1", "BIRK1 ", | |
87 | "BIRK2 ", "BIRK3 ", "LABS ", "SYNC ", "STRA "}; | |
88 | ||
89 | ||
90 | const Text_t* kLabelTextC[10] = | |
91 | {"CUTGAM", "CUTELE", "CUTNEU", "CUTHAD", "CUTMUO", "BCUTE", "BCUTM", | |
92 | "DCUTE ", "DCUTM ", "PPCUTM"}; | |
93 | ||
94 | const Text_t* kLabelTextPart[24] = | |
95 | {"Photon", "Positron", "Electron", "Neutrino", "Muon+", "Muon-", | |
96 | "Pi0", "Pi+", "Pi-", "Kaon_L", "Kaon+", "Kaon-", "Neutron", "Proton", | |
97 | "Anti Proton", "Kaon_S", "Eta", "Lambda", "Sigma+", "Sigma0", "Sigma-", | |
98 | "Xi0", "Xi-", "Omega-"}; | |
99 | ||
100 | const Text_t* kLabelTextMechanism[24] = | |
101 | {"HADF", "INEF", "ELAF", "FISF", "CAPF", | |
102 | "HADG", "INEG", "ELAG", "FISG", "CAPG", | |
103 | "LOSS", "PHOT", "ANNI", "COMP", "BREM", | |
104 | "PAIR", "DRAY", "PFIS", "RAYL", "HADG", | |
105 | "MUNU", "RANG", "STEP", "MUON"}; | |
106 | ||
107 | ||
108 | ||
109 | ||
110 | enum ETestCommandIdentifiers { | |
111 | kFileOpen, | |
112 | kFileSave, | |
113 | kFileSaveAs, | |
114 | kFileExit, | |
115 | ||
116 | kTestDlg, | |
117 | ||
118 | kHelpContents, | |
119 | kHelpSearch, | |
120 | kHelpAbout, | |
121 | ||
122 | ||
123 | kVId1, | |
124 | kHId1, | |
125 | kVId2, | |
126 | kHId2, | |
127 | ||
128 | kVSId1, | |
129 | kHSId1, | |
130 | kVSId2, | |
131 | kHSId2 | |
132 | }; | |
133 | ||
134 | ||
135 | Int_t mbButtonId[9] = { kMBYes, kMBNo, kMBOk, kMBApply, | |
136 | kMBRetry, kMBIgnore, kMBCancel, | |
137 | kMBClose, kMBDismiss }; | |
138 | ||
139 | EMsgBoxIcon mbIcon[4] = { kMBIconStop, kMBIconQuestion, | |
140 | kMBIconExclamation, kMBIconAsterisk }; | |
141 | ||
142 | const char *kFileTypes[] = { "All files", "*", | |
143 | "ROOT files", "*.root", | |
144 | "ROOT macros", "*.C", | |
145 | 0, 0 }; | |
146 | ||
147 | ||
148 | ||
149 | ||
150 | TGListTreeItem* AliGuiGeomMain:: | |
151 | AddItem(TObject * obj, TGListTreeItem *parent, const char* name, const TGPicture *open, const TGPicture *closed) | |
152 | { | |
153 | // Add item to the list tree | |
154 | return fLt->AddItem(parent, name, obj, open, closed); | |
155 | } | |
156 | ||
157 | AliGuiGeomMain::AliGuiGeomMain(const TGWindow *p, UInt_t w, UInt_t h) | |
158 | : TGMainFrame(p, w, h) | |
159 | { | |
160 | // Create test main frame. A TGMainFrame is a top level window. | |
161 | // Create menubar and popup menus. The hint objects are used to place | |
162 | // and group the different menu widgets with respect to eachother. | |
163 | ||
164 | fDialog=0; | |
165 | fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, | |
166 | 0, 0, 1, 1); | |
167 | fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); | |
168 | fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight); | |
169 | ||
170 | fMenuFile = new TGPopupMenu(gClient->GetRoot()); | |
171 | fMenuFile->AddEntry("&Open...", kFileOpen); | |
172 | fMenuFile->AddEntry("&Save", kFileSave); | |
173 | fMenuFile->AddEntry("S&ave as...", kFileSaveAs); | |
174 | fMenuFile->AddEntry("&Close", -1); | |
175 | fMenuFile->AddSeparator(); | |
176 | fMenuFile->AddEntry("E&xit", kFileExit); | |
177 | ||
178 | fMenuFile->DisableEntry(kFileSaveAs); | |
179 | fMenuFile->DisableEntry(kFileOpen); | |
180 | fMenuFile->DisableEntry(kFileSave); | |
181 | ||
182 | ||
183 | ||
184 | fMenuTest = new TGPopupMenu(this); | |
185 | fMenuTest->AddLabel("Draw"); | |
186 | fMenuTest->AddSeparator(); | |
187 | fMenuTest->AddEntry("&Volume Draw Control", kTestDlg); | |
188 | fMenuTest->AddSeparator(); | |
189 | fMenuTest->Associate(this); | |
190 | ||
191 | ||
192 | fMenuHelp = new TGPopupMenu(gClient->GetRoot()); | |
193 | fMenuHelp->AddEntry("&Contents", kHelpContents); | |
194 | fMenuHelp->AddEntry("&Search...", kHelpSearch); | |
195 | fMenuHelp->AddSeparator(); | |
196 | fMenuHelp->AddEntry("&About", kHelpAbout); | |
197 | ||
198 | fMenuFile->DisableEntry(kHelpContents); | |
199 | fMenuFile->DisableEntry(kHelpSearch); | |
200 | fMenuFile->DisableEntry(kHelpAbout); | |
201 | // Menu button messages are handled by the main frame (i.e. "this") | |
202 | // ProcessMessage() method. | |
203 | fMenuFile->Associate(this); | |
204 | fMenuTest->Associate(this); | |
205 | fMenuHelp->Associate(this); | |
206 | ||
207 | fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame); | |
208 | fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout); | |
209 | fMenuBar->AddPopup("&Draw Control", fMenuTest, fMenuBarItemLayout); | |
210 | fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout); | |
211 | ||
212 | AddFrame(fMenuBar, fMenuBarLayout); | |
213 | ||
214 | // | |
215 | // Volumes | |
216 | // | |
217 | fTab = new TGTab(this, 400, 400); | |
218 | TGCompositeFrame *tf = fTab->AddTab("Volumes"); | |
219 | TGLayoutHints *lTab = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | | |
220 | kLHintsExpandY, 2, 2, 5, 1); | |
221 | AddFrame(fTab, lTab); | |
222 | ||
223 | // Create TGCanvas and a canvas container which uses a tile layout manager | |
224 | fCanvasWindow = new TGCanvas(tf, 400, 240); | |
225 | // Create TreeList | |
226 | fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame, | |
227 | fgWhitePixel); | |
228 | fLt->Associate(this); | |
229 | fCanvasWindow->SetContainer(fLt); | |
230 | ||
231 | ||
232 | TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY); | |
233 | tf->AddFrame(fCanvasWindow, lo); | |
234 | // | |
235 | // Materials | |
236 | // | |
237 | tf = fTab->AddTab("Materials"); | |
238 | fF2 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
239 | fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5); | |
240 | // ComboBox for materials | |
241 | fMaterialCombo = new TGComboBox(fF2, 1); | |
242 | fF2->AddFrame(fMaterialCombo, fL2); | |
243 | // | |
244 | // text labels with material properties | |
245 | // | |
246 | Text_t* labelText[6] = | |
247 | {"Material Number ", | |
248 | "Atomic Weight ", | |
249 | "Atomic Number ", | |
250 | "Density ", | |
251 | "Radiation Length ", | |
252 | "Absorption Length"}; | |
253 | ||
254 | TGLayoutHints* bly = | |
255 | new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5); | |
256 | TGLayoutHints* bFly1 = | |
257 | new TGLayoutHints(kLHintsLeft | kLHintsExpandX ); | |
258 | fF21 = new TGCompositeFrame(fF2, 60, 20, kVerticalFrame); | |
259 | fF2->AddFrame(fF21,fL2); | |
260 | { //Begin local scope for i | |
261 | for (Int_t i=0; i<6; i++) { | |
262 | Int_t idT=i+1; | |
263 | fHframe[i] = new TGHorizontalFrame(fF21, 400, 100, kFixedWidth); | |
264 | fF21->AddFrame(fHframe[i], bly); | |
265 | fTbh[i] = new TGTextBuffer(10); | |
266 | fTeh[i] = new TGTextEntry(fHframe[i], fTbh[i],idT); | |
267 | fTeh[i]->Associate(this); | |
268 | fLabel[i] = new TGLabel(fHframe[i], labelText[i]); | |
269 | fHframe[i]->AddFrame(fLabel[i], bFly1); | |
270 | fHframe[i]->AddFrame(fTeh[i], bFly1); | |
271 | } | |
272 | } //End local scope for i | |
273 | tf->AddFrame(fF2, fL2); | |
274 | fMaterialCombo->Resize(200, 20); | |
275 | fMaterialCombo->Associate(this); | |
276 | ||
277 | ||
278 | // Media Combo | |
279 | // | |
280 | tf = fTab->AddTab("Media"); | |
281 | fF3 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
282 | // ComboBox for tracking media | |
283 | fMediaCombo = new TGComboBox(fF3, 2); | |
284 | fF3->AddFrame(fMediaCombo, fL2); | |
285 | // | |
286 | // text labels with material properties | |
287 | // | |
288 | Text_t* labelTextM[8] = | |
289 | {"Sensitivity Flag ", | |
290 | "Magnetic Field Flag ", | |
291 | "Maximum Field ", | |
292 | "Max. Ang. Deviation ", | |
293 | "Maximum Step ", | |
294 | "Max. Frac. Energy Loss", | |
295 | "Crossing Precission ", | |
296 | "Minimum Step Size "}; | |
297 | ||
298 | fF31 = new TGCompositeFrame(fF3, 60, 20, kVerticalFrame); | |
299 | fF3->AddFrame(fF31,fL2); | |
300 | { //Begin local scope for i | |
301 | for (Int_t i=0; i<8; i++) { | |
302 | Int_t idT=i+1; | |
303 | fHframeM[i] = new TGHorizontalFrame(fF31, 400, 100, kFixedWidth); | |
304 | fF31->AddFrame(fHframeM[i], bly); | |
305 | fTbhM[i] = new TGTextBuffer(10); | |
306 | fTehM[i] = new TGTextEntry(fHframeM[i], fTbhM[i],idT); | |
307 | fTehM[i]->Associate(this); | |
308 | fLabelM[i] = new TGLabel(fHframeM[i], labelTextM[i]); | |
309 | fHframeM[i]->AddFrame(fLabelM[i], bFly1); | |
310 | fHframeM[i]->AddFrame(fTehM[i], bFly1); | |
311 | } | |
312 | } //End local scope for i | |
313 | tf->AddFrame(fF3, fL2); | |
314 | fMediaCombo->Resize(200, 20); | |
315 | fMediaCombo->Associate(this); | |
316 | // | |
317 | // Processes | |
318 | tf = fTab->AddTab("Processes"); | |
319 | fF4 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
320 | fProcessLB = new TGListBox(fF4, 1); | |
321 | fF4->AddFrame(fProcessLB, fL2); | |
322 | tf->AddFrame(fF4, fL2); | |
323 | fProcessLB->Resize(150, 350); | |
324 | fProcessLB->Associate(this); | |
325 | ||
326 | // | |
327 | // Cuts | |
328 | tf = fTab->AddTab("Cuts"); | |
329 | fF5 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
330 | fCutsLB = new TGListBox(fF5, 1); | |
331 | fF5->AddFrame(fCutsLB, fL2); | |
332 | tf->AddFrame(fF5, fL2); | |
333 | fCutsLB->Resize(150, 350); | |
334 | ||
335 | // | |
336 | // de/dx and cross-sections | |
337 | tf = fTab->AddTab("DE/DX and X-Sections"); | |
338 | fF6 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
339 | ||
340 | // ComboBox for particles | |
341 | fF61 = new TGCompositeFrame(fF6, 60, 20, kVerticalFrame); | |
342 | fF6->AddFrame(fF61, fL2); | |
343 | fParticleCombo = new TGComboBox(fF61, 3); | |
344 | fF61->AddFrame(fParticleCombo, fL2); | |
345 | { //Begin local scope for i | |
346 | for (Int_t i = 0; i < 24; i++) { | |
347 | char tmp[20]; | |
348 | sprintf(tmp, "%s", kLabelTextPart[i]); | |
349 | fParticleCombo->AddEntry(tmp, i+1); | |
350 | } | |
351 | } //End local scope for i | |
352 | fParticleCombo->Select(1); | |
353 | fParticleCombo->Resize(100, 20); | |
354 | fParticleCombo->Associate(this); | |
355 | ||
356 | // ComboBox for mechanisms | |
357 | fF63 = new TGCompositeFrame(fF6, 60, 20, kVerticalFrame); | |
358 | fF6->AddFrame(fF63, fL2); | |
359 | fMechanismCombo = new TGComboBox(fF63, 4); | |
360 | fF63->AddFrame(fMechanismCombo, fL2); | |
361 | { //Begin local scope for i | |
362 | for (Int_t i = 0; i < 24; i++) { | |
363 | char tmp[20]; | |
364 | sprintf(tmp, "%s", kLabelTextMechanism[i]); | |
365 | fMechanismCombo->AddEntry(tmp, i+1); | |
366 | } | |
367 | } //End local scope for i | |
368 | fMechanismCombo->Select(1); | |
369 | fMechanismCombo->Resize(100, 20); | |
370 | fMechanismCombo->Associate(this); | |
371 | ||
372 | // | |
373 | // Energy Range | |
374 | // | |
375 | fTbh61 = new TGTextBuffer(10); | |
376 | fTeh61 = new TGTextEntry(fF61, fTbh61,10); | |
377 | fTbh61->AddText(0, " 100"); | |
378 | fTeh61->Associate(this); | |
379 | ||
380 | fTbh62 = new TGTextBuffer(10); | |
381 | fTeh62 = new TGTextEntry(fF61, fTbh62,11); | |
382 | fTbh62->AddText(0, "0.001"); | |
383 | fTeh62->Associate(this); | |
384 | ||
385 | fTbh63 = new TGTextBuffer(10); | |
386 | fTeh63 = new TGTextEntry(fF61, fTbh63,12); | |
387 | fTbh63->AddText(0, "10."); | |
388 | fTeh63->Associate(this); | |
389 | ||
390 | fEmin=0.001; | |
391 | fEmax=10.; | |
392 | fNbins=100; | |
393 | ||
394 | fSLabel61 = new TGLabel(fF61, "Nbins-Emin-Emax"); | |
395 | bFly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX ); | |
396 | fF61->AddFrame(fSLabel61, bFly1); | |
397 | fF61->AddFrame(fTeh61, bFly1); | |
398 | fF61->AddFrame(fTeh62, bFly1); | |
399 | fF61->AddFrame(fTeh63, bFly1); | |
400 | // | |
401 | // Plot Button | |
402 | fF62 = new TGCompositeFrame(fF6, 60, 20, kHorizontalFrame); | |
403 | fF6->AddFrame(fF62, fL2); | |
404 | fPlotButton = new TGTextButton(fF62, "Plot", 1); | |
405 | fPlotButton -> Associate(this); | |
406 | fF62->AddFrame(fPlotButton); | |
407 | ||
408 | tf->AddFrame(fF6, fL2); | |
409 | // Window name and final mapping | |
410 | // | |
411 | SetWindowName("AliRoot Geometry Browser"); | |
412 | MapSubwindows(); | |
413 | // We need to use GetDefault...() to initialize the layout algorithm... | |
414 | Resize(GetDefaultSize()); | |
415 | MapWindow(); | |
416 | } | |
417 | ||
418 | AliGuiGeomMain::~AliGuiGeomMain() | |
419 | { | |
420 | // Delete all created widgets. | |
421 | ||
422 | delete fCanvasWindow; | |
423 | ||
424 | delete fMenuBarLayout; | |
425 | delete fMenuBarItemLayout; | |
426 | delete fMenuBarHelpLayout; | |
427 | ||
428 | delete fMenuFile; | |
429 | delete fMenuTest; | |
430 | delete fMenuHelp; | |
431 | } | |
432 | ||
433 | void AliGuiGeomMain::Streamer(TBuffer &) | |
434 | { | |
435 | // Dummy streamer | |
436 | ; | |
437 | } | |
438 | ||
439 | void AliGuiGeomMain::Plot() | |
440 | { | |
441 | // plot de/dx or cross-sections | |
442 | const Float_t kAvo=0.60221367; | |
443 | Float_t *tkin = new Float_t[fNbins]; | |
444 | Float_t *value = new Float_t[fNbins]; | |
445 | Float_t *pcut = new Float_t[fNbins]; | |
446 | Int_t ixst; | |
447 | Int_t imate=gCurrentMaterial->Id(); | |
448 | Float_t z=gCurrentMaterial->Z(); | |
449 | Float_t a=gCurrentMaterial->A(); | |
450 | Float_t density=gCurrentMaterial->Density(); | |
451 | ||
452 | Int_t ipart=gCurrentParticle; | |
453 | const char *kChMeca= kLabelTextMechanism[gCurrentProcess-1]; | |
454 | char* tmp; | |
455 | tmp = new char[5]; | |
456 | strncpy(tmp, kChMeca, 4); | |
457 | tmp[4]='\0'; | |
458 | Int_t kdim=fNbins; | |
459 | Float_t de=(fEmax-fEmin)/fNbins; | |
460 | { //Begin local scope for i | |
461 | for (Int_t i=0; i<kdim; i++) { | |
462 | tkin[i]=fEmin+Float_t(i)*de; | |
463 | value[i]=0.; | |
464 | } | |
465 | } //End local scope for i | |
466 | if (kChMeca!="MUON") { | |
467 | ((TGeant3*) gMC)->Gftmat(imate, ipart, tmp, kdim, tkin, value, pcut, ixst); | |
468 | } else { | |
469 | for (Int_t i=0; i<kdim; i++) { | |
470 | Float_t ekin=tkin[i]; | |
471 | value[i]+=((TGeant3*) gMC)->Gbrelm(z,ekin,1.e10); | |
472 | value[i]+=((TGeant3*) gMC)->Gprelm(z,ekin,1.e10); | |
473 | value[i]*=1000.*kAvo*density/a; | |
474 | } | |
475 | } | |
476 | ||
477 | ||
478 | printf("\n %d %d %s %d \n",imate, ipart, kChMeca, kdim); | |
479 | if (ixst) { | |
480 | TGraph *graph = new TGraph(kdim,tkin,value); | |
481 | TCanvas *c1 = new TCanvas("c1"," ",400,10,600,700); | |
482 | c1->Divide(1,1); | |
483 | c1->cd(1); | |
484 | ||
485 | graph->SetFillColor(42); | |
486 | graph->SetMarkerColor(4); | |
487 | graph->SetMarkerStyle(21); | |
488 | graph->Draw("AC"); | |
489 | graph->GetHistogram()->SetXTitle("Energy (GeV)"); | |
490 | if (kChMeca == "RANG" || kChMeca == "STEP") { | |
491 | graph->GetHistogram()->SetYTitle | |
492 | ("Distance (cm)"); | |
493 | } else if (kChMeca == "LOSS" || kChMeca == "MUON") { | |
494 | graph->GetHistogram()->SetYTitle("dE/dx (MeV/cm)"); | |
495 | } else { | |
496 | graph->GetHistogram()->SetYTitle | |
497 | ("Macroscopic X-Section (1/cm)"); | |
498 | } | |
499 | } | |
500 | ||
501 | delete tkin; | |
502 | delete value; | |
503 | delete pcut; | |
504 | ||
505 | ||
506 | } | |
507 | ||
508 | void AliGuiGeomMain::Update() | |
509 | { | |
510 | // Update widgets | |
511 | if (fDialog) { | |
512 | fDialog->Update(); | |
513 | } | |
514 | ||
515 | Int_t imat=gCurrentVolume->Material(); | |
516 | Int_t nmat=fComboEntries->GetEntriesFast(); | |
517 | Int_t i=0; | |
518 | for (i=0; i<nmat; i++) { | |
519 | gCurrentMaterial = (AliGUIMaterial*) | |
520 | (fComboEntries->UncheckedAt(i)); | |
521 | if (gCurrentMaterial->Id()==imat) break; | |
522 | } | |
523 | Int_t imed = gCurrentVolume->Medium(); | |
524 | Int_t nmed=fComboMediaEntries->GetEntriesFast(); | |
525 | for (i=0; i<nmed; i++) { | |
526 | gCurrentMedium = (AliGUIMedium*) | |
527 | (fComboMediaEntries->UncheckedAt(i)); | |
528 | if (gCurrentMedium->Id()==imed) break; | |
529 | } | |
530 | ||
531 | UpdateCombo(); | |
532 | UpdateListBox(); | |
533 | ||
534 | } | |
535 | ||
536 | void AliGuiGeomMain::UpdateCombo() | |
537 | { | |
538 | // Update combos | |
539 | ||
540 | Int_t imat = gCurrentMaterial->Id(); | |
541 | Float_t a = gCurrentMaterial->A(); | |
542 | Float_t z = gCurrentMaterial->Z(); | |
543 | Float_t dens = gCurrentMaterial->Density(); | |
544 | Float_t radl = gCurrentMaterial->RadiationLength(); | |
545 | Float_t absl = gCurrentMaterial->AbsorptionLength(); | |
546 | Int_t entry=gCurrentMaterial->ItemId(); | |
547 | // | |
548 | // | |
549 | fMaterialCombo->Select(entry); | |
550 | fMediaCombo->Select(entry); | |
551 | char buf[10]; | |
552 | ||
553 | sprintf(buf, "%10i", imat); | |
554 | fTbh[0]->Clear(); | |
555 | fTbh[0]->AddText(0, buf); | |
556 | gClient->NeedRedraw(fTeh[0]); | |
557 | sprintf(buf, "%10.2e", a); | |
558 | fTbh[1]->Clear(); | |
559 | fTbh[1]->AddText(0, buf); | |
560 | gClient->NeedRedraw(fTeh[1]); | |
561 | ||
562 | sprintf(buf, "%10.2e", z); | |
563 | fTbh[2]->Clear(); | |
564 | fTbh[2]->AddText(0, buf); | |
565 | gClient->NeedRedraw(fTeh[2]); | |
566 | ||
567 | sprintf(buf, "%10.2e", dens); | |
568 | fTbh[3]->Clear(); | |
569 | fTbh[3]->AddText(0, buf); | |
570 | gClient->NeedRedraw(fTeh[3]); | |
571 | ||
572 | sprintf(buf, "%10.2e", radl); | |
573 | fTbh[4]->Clear(); | |
574 | fTbh[4]->AddText(0, buf); | |
575 | gClient->NeedRedraw(fTeh[4]); | |
576 | ||
577 | sprintf(buf, "%10.2e", absl); | |
578 | fTbh[5]->Clear(); | |
579 | fTbh[5]->AddText(0, buf); | |
580 | gClient->NeedRedraw(fTeh[5]); | |
581 | ||
582 | // Media Combo | |
583 | sprintf(buf, "%10i", gCurrentMedium->Isvol()); | |
584 | fTbhM[0]->Clear(); | |
585 | fTbhM[0]->AddText(0, buf); | |
586 | gClient->NeedRedraw(fTehM[0]); | |
587 | ||
588 | ||
589 | sprintf(buf, "%10i", gCurrentMedium->Ifield()); | |
590 | fTbhM[1]->Clear(); | |
591 | fTbhM[1]->AddText(0, buf); | |
592 | gClient->NeedRedraw(fTehM[1]); | |
593 | ||
594 | sprintf(buf, "%10.2e", gCurrentMedium->Fieldm()); | |
595 | fTbhM[2]->Clear(); | |
596 | fTbhM[2]->AddText(0, buf); | |
597 | gClient->NeedRedraw(fTehM[2]); | |
598 | ||
599 | sprintf(buf, "%10.2e", gCurrentMedium->Tmaxfd()); | |
600 | fTbhM[3]->Clear(); | |
601 | fTbhM[3]->AddText(0, buf); | |
602 | gClient->NeedRedraw(fTehM[3]); | |
603 | ||
604 | sprintf(buf, "%10.2e", gCurrentMedium->Stemax()); | |
605 | fTbhM[4]->Clear(); | |
606 | fTbhM[4]->AddText(0, buf); | |
607 | gClient->NeedRedraw(fTehM[4]); | |
608 | ||
609 | sprintf(buf, "%10.2e", gCurrentMedium->Deemax()); | |
610 | fTbhM[5]->Clear(); | |
611 | fTbhM[5]->AddText(0, buf); | |
612 | gClient->NeedRedraw(fTehM[5]); | |
613 | ||
614 | sprintf(buf, "%10.2e", gCurrentMedium->Epsil()); | |
615 | fTbhM[6]->Clear(); | |
616 | fTbhM[6]->AddText(0, buf); | |
617 | gClient->NeedRedraw(fTehM[6]); | |
618 | ||
619 | sprintf(buf, "%10.2e", gCurrentMedium->Stmin()); | |
620 | fTbhM[7]->Clear(); | |
621 | fTbhM[7]->AddText(0, buf); | |
622 | gClient->NeedRedraw(fTehM[7]); | |
623 | } | |
624 | ||
625 | void AliGuiGeomMain::UpdateListBox() | |
626 | { | |
627 | // Update the list box | |
628 | Int_t i; | |
629 | fProcessLB->RemoveEntries(1,19); | |
630 | for (i=11; i < 30; i++) { | |
631 | Float_t p=gCurrentMedium->GetPar(i); | |
632 | char tmp[20]; | |
633 | sprintf(tmp, "%6s%5d", kLabelTextP[i-11], Int_t(p)); | |
634 | fProcessLB->AddEntry(tmp, i-10); | |
635 | } | |
636 | fProcessLB->MapSubwindows(); | |
637 | fProcessLB->Layout(); | |
638 | ||
639 | fCutsLB->RemoveEntries(1,10); | |
640 | for (i=1; i < 11; i++) { | |
641 | Float_t p=gCurrentMedium->GetPar(i); | |
642 | char tmp[20]; | |
643 | sprintf(tmp, "%6s%10.3e", kLabelTextC[i-1], p); | |
644 | fCutsLB->AddEntry(tmp,i); | |
645 | } | |
646 | fCutsLB->MapSubwindows(); | |
647 | fCutsLB->Layout(); | |
648 | } | |
649 | ||
650 | ||
651 | void AliGuiGeomMain::CloseWindow() | |
652 | { | |
653 | // Got close message for this MainFrame. Calls parent CloseWindow() | |
654 | // (which destroys the window) and terminate the application. | |
655 | // The close message is generated by the window manager when its close | |
656 | // window menu item is selected. | |
657 | ||
658 | TGMainFrame::CloseWindow(); | |
659 | gApplication->Terminate(0); | |
660 | } | |
661 | ||
662 | Bool_t AliGuiGeomMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) | |
663 | { | |
664 | // Process messages to widgets | |
665 | switch (GET_MSG(msg)) { | |
666 | // | |
667 | // Text entries for binning of cross-section plots | |
668 | case kC_TEXTENTRY: | |
669 | switch (GET_SUBMSG(msg)) { | |
670 | case kTE_TEXTCHANGED: | |
671 | switch (parm1) { | |
672 | case 10: | |
673 | fNbins=(Int_t) atof(fTbh61->GetString()); | |
674 | break; | |
675 | case 11: | |
676 | fEmin= atof(fTbh62->GetString()); | |
677 | break; | |
678 | case 12: | |
679 | fEmax= atof(fTbh63->GetString()); | |
680 | break; | |
681 | } | |
682 | printf("\n %d %f %f binning", fNbins, fEmin, fEmax); | |
683 | } | |
684 | break; | |
685 | // | |
686 | // ListTree for volumes | |
687 | case kC_LISTTREE: | |
688 | switch (GET_SUBMSG(msg)) { | |
689 | // | |
690 | // Handle mouse click | |
691 | case kCT_ITEMCLICK: | |
692 | // | |
693 | // Button 1: Select volume | |
694 | if (parm1 == kButton1) { | |
695 | TGListTreeItem *item; | |
696 | if ((item = fLt->GetSelected())) | |
697 | { | |
698 | gCurrentVolume=((AliDrawVolume *) item->GetUserData()); | |
699 | Update(); | |
700 | } | |
701 | } | |
702 | // | |
703 | // Button 2: Draw volume specifications | |
704 | ||
705 | if (parm1 == kButton2) { | |
706 | TGListTreeItem *item; | |
707 | if ((item = fLt->GetSelected())) | |
708 | { | |
709 | ||
710 | ((AliDrawVolume *) item->GetUserData())->DrawSpec(); | |
711 | ||
712 | gCurrentVolume=((AliDrawVolume *) item->GetUserData()); | |
713 | Update(); | |
714 | } | |
715 | } | |
716 | // | |
717 | // Button 3: Draw Volume | |
718 | if (parm1 == kButton3) { | |
719 | TGListTreeItem *item; | |
720 | if ((item = fLt->GetSelected())) | |
721 | { | |
722 | ((AliDrawVolume *) item->GetUserData())->Draw(); | |
723 | gCurrentVolume=((AliDrawVolume *) item->GetUserData()); | |
724 | Update(); | |
725 | } | |
726 | } | |
727 | ||
728 | ||
729 | break; | |
730 | case kCT_ITEMDBLCLICK: | |
731 | if (parm1 == kButton1) { | |
732 | if (fLt->GetSelected() != 0) { | |
733 | gClient->NeedRedraw(fLt); | |
734 | } | |
735 | } | |
736 | break; | |
737 | default: | |
738 | break; | |
739 | } | |
740 | break; | |
741 | case kC_COMMAND: | |
742 | switch (GET_SUBMSG(msg)) { | |
743 | case kCM_BUTTON: | |
744 | switch(parm1) { | |
745 | case 1: | |
746 | Plot(); | |
747 | break; | |
748 | } | |
749 | break; | |
750 | case kCM_COMBOBOX: | |
751 | // | |
752 | // Combo box bindings | |
753 | switch(parm1) { | |
754 | // | |
755 | // Material Combo | |
756 | case 1: | |
757 | gCurrentMaterial=(AliGUIMaterial*) | |
758 | (fComboEntries->UncheckedAt(Int_t(parm2-1))); | |
759 | gCurrentMedium=(AliGUIMedium*) | |
760 | (fComboMediaEntries->UncheckedAt(Int_t(parm2-1))); | |
761 | UpdateCombo(); | |
762 | UpdateListBox(); | |
763 | break; | |
764 | // | |
765 | // Media Combo | |
766 | case 2: | |
767 | gCurrentMedium=(AliGUIMedium*) | |
768 | (fComboMediaEntries->UncheckedAt(Int_t(parm2-1))); | |
769 | gCurrentMaterial=(AliGUIMaterial*) | |
770 | (fComboEntries->UncheckedAt(Int_t(parm2-1))); | |
771 | UpdateCombo(); | |
772 | UpdateListBox(); | |
773 | break; | |
774 | // | |
775 | // Particle Combo | |
776 | case 3: | |
777 | gCurrentParticle=Int_t(parm2); | |
778 | break; | |
779 | // | |
780 | // Mechanism Combo | |
781 | case 4: | |
782 | gCurrentProcess=Int_t(parm2); | |
783 | printf("\n Process %d", gCurrentProcess); | |
784 | break; | |
785 | } | |
786 | break; | |
787 | case kCM_MENUSELECT: | |
788 | break; | |
789 | ||
790 | case kCM_MENU: | |
791 | switch (parm1) { | |
792 | ||
793 | case kFileOpen: | |
794 | { | |
795 | TGFileInfo fi; | |
796 | fi.fFileTypes = (char **)kFileTypes; | |
797 | new TGFileDialog(gClient->GetRoot(), this, kFDOpen,&fi); | |
798 | } | |
799 | break; | |
800 | ||
801 | case kTestDlg: | |
802 | fDialog = new AliGuiGeomDialog | |
803 | (gClient->GetRoot(), this, 400, 200); | |
804 | break; | |
805 | ||
806 | case kFileSave: | |
807 | printf("kFileSave\n"); | |
808 | break; | |
809 | ||
810 | case kFileExit: | |
811 | CloseWindow(); // this also terminates theApp | |
812 | break; | |
813 | default: | |
814 | break; | |
815 | } | |
816 | default: | |
817 | break; | |
818 | } | |
819 | default: | |
820 | break; | |
821 | } | |
822 | return kTRUE; | |
823 | } | |
824 | ||
825 | void AliGuiGeomMain::AddMaterial(AliGUIMaterial *Material, Int_t i) | |
826 | { | |
827 | // Add material to material combo | |
828 | char* tmp; | |
829 | tmp=Material->Name(); | |
830 | Material->SetItemId(i); | |
831 | fMaterialCombo->AddEntry(tmp, i); | |
832 | fMaterialCombo->Select(i); | |
833 | fMaterialCombo->Resize(200, 20); | |
834 | } | |
835 | ||
836 | void AliGuiGeomMain::AddMedium(AliGUIMedium *Medium, Int_t i) | |
837 | { | |
838 | // Add medium to medium combo | |
839 | char* tmp; | |
840 | tmp=Medium->Name(); | |
841 | Medium->SetItemId(i); | |
842 | ||
843 | fMediaCombo->AddEntry(tmp, i); | |
844 | fMediaCombo->Select(i); | |
845 | fMediaCombo->Resize(200, 20); | |
846 | } | |
847 | ||
848 |