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