]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant3/TGeant3GUI.cxx
More details on installation pre-requisites
[u/mrichter/AliRoot.git] / TGeant3 / TGeant3GUI.cxx
CommitLineData
78976106 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. *
9549377e 14 **************************************************************************/
15
16/*
17$Log$
f70a166f 18Revision 1.2 1999/11/10 16:53:35 fca
19The new geometry viewer from A.Morsch
20
9549377e 21*/
22
23/*
78976106 24 * Version: 0
25 * Written by Andreas Morsch
26 *
27 *
28 *
29 * For questions critics and suggestions to this part of the code
30 * contact andreas.morsch@cern.ch
31 *
32 **************************************************************************/
33#include <stdlib.h>
34#include <TROOT.h>
35#include <AliRun.h>
36#include <AliMC.h>
37#include <TGeant3.h>
38#include <THIGZ.h>
39#include <TApplication.h>
40#include <TVirtualX.h>
41#include <TGListBox.h>
42#include <TGListTree.h>
43#include <TGClient.h>
44#include <TGFrame.h>
45#include <TGIcon.h>
46#include <TGLabel.h>
47#include <TGButton.h>
48#include <TGTextEntry.h>
49#include <TGMsgBox.h>
50#include <TGMenu.h>
51#include <TGCanvas.h>
52#include <TGComboBox.h>
53#include <TGTab.h>
54#include <TGSlider.h>
55#include <TGDoubleSlider.h>
56#include <TGFileDialog.h>
57#include <TRootEmbeddedCanvas.h>
58#include <TCanvas.h>
59#include <TH1.h>
60#include <TH2.h>
61#include <TRandom.h>
62#include <TSystem.h>
63#include <TEnv.h>
64#include <TGPicture.h>
65
66#include "TGeant3GUI.h"
67
68static AliDrawVolume * gCurrentVolume = new AliDrawVolume("NULL");
69
70ClassImp(AliGeant3GeometryGUI)
71
72 AliGeant3GeometryGUI::AliGeant3GeometryGUI()
73{
74 fPanel = new AliGuiGeomMain(gClient->GetRoot(), 500, 500);
75 fNstack = 0;
76 fVolumes = new TClonesArray("AliDrawVolume",100);
77 TGeant3 *geant3 = (TGeant3*) gMC;
78 fZlq=geant3->Lq();
79 fZq=geant3->Q();
80 fGclink=geant3->Gclink();
81}
f70a166f 82void AliGeant3GeometryGUI::Streamer(TBuffer &)
78976106 83{
84;
85}
86
87void AliGeant3GeometryGUI::ReadGeometryTree()
88{
89 char *vname;
f70a166f 90 char /* *namec, */ *tmp;
91 char namec[30];
78976106 92 const TGPicture* Folder = gClient->GetPicture("folder_t.xpm");
93 const TGPicture* OpenFolder = gClient->GetPicture("ofolder_t.xpm");
94 const TGPicture* Document = gClient->GetPicture("doc_t.xpm");
95
96 AliDrawVolume *volume;
97
98 Int_t nst=0;
99 Int_t nlevel=1;
100 Int_t newlevel=nlevel;
101
102 volume = new AliDrawVolume("ALIC");
103 volume->SetIdVolume(((TGeant3*)gMC)->VolId("ALIC"));
104 volume->SetIdCopy(0);
105 volume->SetItem(NULL);
106 (*fVolumes)[0]=volume;
107
108 while(nlevel>nst) {
109 for (Int_t i=nst; i<nlevel; i++)
110 {
111 TGListTreeItem *itemi, *item2;
112 Int_t ivol=TMath::Abs(Volume(i)->GetIdVolume());
113
114 Int_t nch = NChildren(ivol);
f70a166f 115// namec= ((TGeant3*)gMC)->VolName(ivol);
116 strcpy(namec,((TGeant3*)gMC)->VolName(ivol));
78976106 117 if (nch >= 0) {
118 printf("\n %s has %d children \n ", namec, nch);
119 } else {
120 printf("\n %s has %d divisions \n ", namec, -nch);
121 }
122 vname = new char[5];
123 strncpy(vname,namec, 4);
124 vname[4]='\0';
125 Int_t icopy = Volume(i)->GetIdCopy();
126 if (icopy >1) {
127 sprintf(namec,"%s*%3dPos",namec,icopy);
128 } else if (icopy <0) {
129 sprintf(namec,"%s*%3dDiv",namec,-icopy);
130 }
131 if (i>0) {
132 itemi=Volume(i)->GetItem();
133 } else {
134 itemi=NULL;
135 }
136
137
138 if (nch!=0) {
139 item2 = fPanel->AddItem(new AliDrawVolume(vname),
140 itemi, namec, OpenFolder, Folder);
141 } else {
142 item2 = fPanel->AddItem(new AliDrawVolume(vname),
143 itemi, namec, Document, Document);
144 }
145
146 if (nch < 0) {
147 Int_t icvol=Child(ivol,1);
f70a166f 148// namec= ((TGeant3*)gMC)->VolName(-icvol);
149 strcpy(namec,((TGeant3*)gMC)->VolName(-icvol));
78976106 150 tmp = new char[4];
151 strncpy(tmp,(char *) &namec, 4);
152 volume = new AliDrawVolume(namec);
153 volume->SetIdVolume(-icvol);
154 volume->SetIdCopy(nch);
155 volume->SetItem(item2);
156 (*fVolumes)[newlevel]=volume;
157 printf("\n volume %s %d", namec, icvol);
158 newlevel++;
159 } else {
160 Int_t nnew=0;
161 for (Int_t j=0; j<nch; j++)
162 {
163 Int_t icvol=Child(ivol,j+1);
164 icvol = TMath::Abs(icvol);
165 Bool_t inList=kFALSE;
166 for (Int_t k=0; k<nnew; k++) {
167 if (icvol==
168 Volume(newlevel-k-1)->GetIdVolume())
169 {
170 Volume(newlevel-k-1)->AddCopy();
171 inList=kTRUE;
172 }
173 }
174 if (!inList) {
f70a166f 175// namec=((TGeant3*)gMC)->VolName(icvol);
176 strcpy(namec,((TGeant3*)gMC)->VolName(icvol));
78976106 177 tmp = new char[4];
178 strncpy(tmp,(char *) &namec, 4);
179 volume = new AliDrawVolume(namec);
180 volume->SetIdVolume(icvol);
181 volume->SetIdCopy(1);
182 volume->SetItem(item2);
183 (*fVolumes)[newlevel]=volume;
184 printf("\n volume %s", namec);
185 newlevel++;
186 nnew++;
187 }
188 }
189 }
190 }
191 nst=nlevel;
192 nlevel=newlevel;
193 }
194}
195
196
197Int_t AliGeant3GeometryGUI::NChildren(Int_t idvol)
198{
199 Int_t jvo = fZlq[fGclink->jvolum-idvol];
200 Int_t nin = Int_t(fZq[jvo+3]);
201 return nin;
202}
203
204Int_t AliGeant3GeometryGUI::Child(Int_t idvol, Int_t idc)
205{
206 Int_t jvo = fZlq[fGclink->jvolum-idvol];
207 Int_t nin=idc;
208 Int_t jin = fZlq[jvo-nin];
209 Int_t numb = Int_t (fZq[jin +3]);
210 if (numb > 1) {
211 return -Int_t(fZq[jin+2]);
212 } else {
213 return Int_t(fZq[jin+2]);
214 }
215}
216
217
218ClassImp(AliDrawVolume)
219enum AliDrawParamId {
220 P_Theta,
221 P_Phi,
222 P_Psi,
223 P_U,
224 P_V,
225 P_Uscale,
226 P_Vscale,
227 P_Shadow,
228 P_Hide,
229 P_Fill,
230 P_Seen,
231 P_Clip,
232 P_ClipXmin,
233 P_ClipXmax,
234 P_ClipYmin,
235 P_ClipYmax,
236 P_ClipZmin,
237 P_ClipZmax
238};
239
240
241AliDrawVolume::AliDrawVolume(char* name)
242{
243 fName = name;
244 fTheta = 30;
245 fPhi = 30;
246 fPsi = 0;
247 fU = 10;
248 fV = 10;
249 fUscale = 0.01;
250 fVscale = 0.01;
251 fHide=0;
252 fShadow=0;
253 fFill=1;
254 fSeen=1;
255 fClip=0;
256 fClipXmin=0.;
257 fClipXmax=2000.;
258 fClipYmin=0.;
259 fClipYmax=2000.;
260 fClipZmin=0.;
261 fClipZmax=2000.;
262}
263
264char* AliDrawVolume::Name()
265{
266 return fName;
267}
268
269
f70a166f 270void AliDrawVolume::Streamer(TBuffer &)
78976106 271{
272;
273}
274
275
276
f70a166f 277void AliDrawVolume::Draw(Option_t *)
78976106 278{
279 gMC->Gsatt(fName,"seen", fSeen);
280
281 if (fHide) {
282 gMC->Gdopt("hide", "on");
283 } else {
284 gMC->Gdopt("hide", "off");
285 }
286
287 if (fShadow) {
288 gMC->Gdopt("shad", "on");
289 gMC->Gsatt("*", "fill", fFill);
290 } else {
291 gMC->Gdopt("shad", "off");
292 }
293
294 gMC->SetClipBox(".");
295 if (fClip) {
296 gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
297 } else {
298 gMC->SetClipBox(".");
299 }
300
301
302 gMC->Gdraw(fName, fTheta, fPhi, fPsi, fU, fV, fUscale, fVscale);
303 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
304 if (higz) higz->Update();
305}
306
307void AliDrawVolume::DrawSpec()
308{
309 gMC->Gsatt(fName,"seen", fSeen);
310
311 if (fHide) {
312 gMC->Gdopt("hide", "on");
313 } else {
314 gMC->Gdopt("hide", "off");
315 }
316
317 if (fShadow) {
318 gMC->Gdopt("shad", "on");
319 gMC->Gsatt("*", "fill", fFill);
320 } else {
321 gMC->Gdopt("shad", "off");
322 }
323
324 gMC->SetClipBox(".");
325 if (fClip) {
326 gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
327 } else {
328 gMC->SetClipBox(".");
329 }
330
331
332 ((TGeant3*) gMC)->DrawOneSpec(fName);
333 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
334 if (higz) higz->Update();
335}
336
337void AliDrawVolume::SetParam(Int_t ip, Float_t param)
338{
339 switch (ip) {
340 case P_Theta:
341 fTheta=param;
342 break;
343 case P_Phi:
344 fPhi=param;
345 break;
346 case P_Psi:
347 fPsi=param;
348 break;
349 case P_U:
350 fU=param;
351 break;
352 case P_V:
353 fV=param;
354 break;
355 case P_Uscale:
356 fUscale=param;
357 break;
358 case P_Vscale:
359 fVscale=param;
360 break;
361 case P_Hide:
362 fHide=Int_t(param);
363 break;
364 case P_Shadow:
365 fShadow=Int_t(param);
366 break;
367 case P_Fill:
368 fFill=Int_t(param);
369 break;
370 case P_Seen:
371 fSeen=Int_t(param);
372 break;
373 case P_Clip:
374 fClip=Int_t(param);
375 break;
376 case P_ClipXmin:
377 fClipXmin=param;
378 break;
379 case P_ClipXmax:
380 fClipXmax=param;
381 break;
382 case P_ClipYmin:
383 fClipYmin=param;
384 break;
385 case P_ClipYmax:
386 fClipYmax=param;
387 break;
388 case P_ClipZmin:
389 fClipZmin=param;
390 break;
391 case P_ClipZmax:
392 fClipZmax=param;
393 break;
394 }
395}
396
397Float_t AliDrawVolume::GetParam(Int_t ip)
398{
399 switch (ip) {
400 case P_Theta:
401 return fTheta;
78976106 402 case P_Phi:
403 return fPhi;
78976106 404 case P_Psi:
405 return fPsi;
78976106 406 case P_U:
407 return fU;
78976106 408 case P_V:
409 return fV;
78976106 410 case P_Uscale:
411 return fUscale;
78976106 412 case P_Vscale:
413 return fVscale;
78976106 414 case P_Hide:
415 return Float_t(fHide);
78976106 416 case P_Shadow:
417 return Float_t(fShadow);
78976106 418 case P_Fill:
419 return Float_t(fFill);
78976106 420 case P_Seen:
421 return Float_t(fSeen);
78976106 422 case P_Clip:
423 return Float_t(fClip);
78976106 424 case P_ClipXmin:
425 return fClipXmin;
78976106 426 case P_ClipXmax:
427 return fClipXmax;
78976106 428 case P_ClipYmin:
429 return fClipYmin;
78976106 430 case P_ClipYmax:
431 return fClipYmax;
78976106 432 case P_ClipZmin:
433 return fClipZmin;
78976106 434 case P_ClipZmax:
435 return fClipZmax;
78976106 436 default:
437 return 0.;
438 }
439 return 0.;
440}
441
442
443ClassImp(AliGuiGeomMain)
444
445enum ETestCommandIdentifiers {
446 M_FILE_OPEN,
447 M_FILE_SAVE,
448 M_FILE_SAVEAS,
449 M_FILE_EXIT,
450
451 M_TEST_DLG,
452
453 M_HELP_CONTENTS,
454 M_HELP_SEARCH,
455 M_HELP_ABOUT,
456
457
458 VId1,
459 HId1,
460 VId2,
461 HId2,
462
463 VSId1,
464 HSId1,
465 VSId2,
466 HSId2
467};
468
469
470Int_t mb_button_id[9] = { kMBYes, kMBNo, kMBOk, kMBApply,
471 kMBRetry, kMBIgnore, kMBCancel,
472 kMBClose, kMBDismiss };
473
474EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion,
475 kMBIconExclamation, kMBIconAsterisk };
476
477const char *filetypes[] = { "All files", "*",
478 "ROOT files", "*.root",
479 "ROOT macros", "*.C",
480 0, 0 };
481
482
483
484
485TGListTreeItem* AliGuiGeomMain::
486AddItem(TObject * obj, TGListTreeItem *parent, const char* name, const TGPicture *open, const TGPicture *closed)
487{
488 return fLt->AddItem(parent, name, obj, open, closed);
489}
490
491AliGuiGeomMain::AliGuiGeomMain(const TGWindow *p, UInt_t w, UInt_t h)
492 : TGMainFrame(p, w, h)
493{
494 fDialog=0;
495
496 // Create test main frame. A TGMainFrame is a top level window.
497 // Create menubar and popup menus. The hint objects are used to place
498 // and group the different menu widgets with respect to eachother.
499 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
500 0, 0, 1, 1);
501 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
502 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
503
504 fMenuFile = new TGPopupMenu(gClient->GetRoot());
505 fMenuFile->AddEntry("&Open...", M_FILE_OPEN);
506 fMenuFile->AddEntry("&Save", M_FILE_SAVE);
507 fMenuFile->AddEntry("S&ave as...", M_FILE_SAVEAS);
508 fMenuFile->AddEntry("&Close", -1);
509 fMenuFile->AddSeparator();
510 fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
511
512 fMenuFile->DisableEntry(M_FILE_SAVEAS);
513 fMenuFile->DisableEntry(M_FILE_OPEN);
514 fMenuFile->DisableEntry(M_FILE_SAVE);
515
516
517
518 fMenuTest = new TGPopupMenu(this);
519 fMenuTest->AddLabel("Draw Control");
520 fMenuTest->AddSeparator();
521 fMenuTest->AddEntry("&Control Panel ...", M_TEST_DLG);
522 fMenuTest->AddSeparator();
523 fMenuTest->Associate(this);
524
525
526 fMenuHelp = new TGPopupMenu(gClient->GetRoot());
527 fMenuHelp->AddEntry("&Contents", M_HELP_CONTENTS);
528 fMenuHelp->AddEntry("&Search...", M_HELP_SEARCH);
529 fMenuHelp->AddSeparator();
530 fMenuHelp->AddEntry("&About", M_HELP_ABOUT);
531
532 fMenuFile->DisableEntry(M_HELP_CONTENTS);
533 fMenuFile->DisableEntry(M_HELP_SEARCH);
534 fMenuFile->DisableEntry(M_HELP_ABOUT);
535 // Menu button messages are handled by the main frame (i.e. "this")
536 // ProcessMessage() method.
537 fMenuFile->Associate(this);
538 fMenuTest->Associate(this);
539 fMenuHelp->Associate(this);
540
541 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
542 fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
543 fMenuBar->AddPopup("&Draw Control", fMenuTest, fMenuBarItemLayout);
544 fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
545
546 AddFrame(fMenuBar, fMenuBarLayout);
547 // Create TreeList
548 // Create TGCanvas and a canvas container which uses a tile layout manager
549
550 fCanvasWindow = new TGCanvas(this, 400, 240);
551 fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame,
552 fgWhitePixel);
553 fLt->Associate(this);
554 fCanvasWindow->SetContainer(fLt);
555
556
557 TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
558 AddFrame(fCanvasWindow, lo);
559
560
561
562 SetWindowName("AliRoot Geometry Browser");
563
564 MapSubwindows();
565
566 // we need to use GetDefault...() to initialize the layout algorithm...
567 Resize(GetDefaultSize());
568 //Resize(400, 200);
569
570 MapWindow();
571}
572
573AliGuiGeomMain::~AliGuiGeomMain()
574{
575 // Delete all created widgets.
576
577 delete fContainer;
578 delete fCanvasWindow;
579
580 delete fMenuBarLayout;
581 delete fMenuBarItemLayout;
582 delete fMenuBarHelpLayout;
583
584 delete fMenuFile;
585 delete fMenuTest;
586 delete fMenuHelp;
587}
588
589void AliGuiGeomMain::Update()
590{
591 if (fDialog) {
592 fDialog->Update();
593 }
594}
595
596void AliGuiGeomMain::CloseWindow()
597{
598 // Got close message for this MainFrame. Calls parent CloseWindow()
599 // (which destroys the window) and terminate the application.
600 // The close message is generated by the window manager when its close
601 // window menu item is selected.
602
603 TGMainFrame::CloseWindow();
604 gApplication->Terminate(0);
605}
606
607Bool_t AliGuiGeomMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
608{
609 // Handle messages send to the AliGuiGeomMain object. E.g. all menu button messages.
610 switch (GET_MSG(msg)) {
611 case kC_LISTTREE:
612 switch (GET_SUBMSG(msg)) {
613 case kCT_ITEMCLICK:
614 TGListTreeItem *item;
615 if (parm1 == kButton1) {
616 if ((item = fLt->GetSelected()))
617 {
618 gCurrentVolume=((AliDrawVolume *) item->GetUserData());
619 Update();
620 }
621 }
622
623 if (parm1 == kButton2) {
624 TGListTreeItem *item;
625 if ((item = fLt->GetSelected()))
626 {
627 ((AliDrawVolume *) item->GetUserData())->DrawSpec();
628 gCurrentVolume=((AliDrawVolume *) item->GetUserData());
629 Update();
630 }
631 }
632
633 if (parm1 == kButton3) {
634 TGListTreeItem *item;
635 if ((item = fLt->GetSelected()))
636 {
637 ((AliDrawVolume *) item->GetUserData())->Draw();
638 gCurrentVolume=((AliDrawVolume *) item->GetUserData());
639 Update();
640 }
641 }
642
643
644 break;
645 case kCT_ITEMDBLCLICK:
646 if (parm1 == kButton1) {
647 if (fLt->GetSelected() != 0) {
648 gClient->NeedRedraw(fLt);
649 }
650 }
651 break;
652 default:
653 break;
654 }
655 break;
656 case kC_COMMAND:
657 switch (GET_SUBMSG(msg)) {
658
659 case kCM_BUTTON:
660 break;
661
662 case kCM_MENUSELECT:
663 break;
664
665 case kCM_MENU:
666 switch (parm1) {
667
668 case M_FILE_OPEN:
669 {
670 TGFileInfo fi;
671 fi.fFileTypes = (char **)filetypes;
672 new TGFileDialog(gClient->GetRoot(), this, kFDOpen,&fi);
673 }
674 break;
675
676 case M_TEST_DLG:
677 fDialog = new AliGuiGeomDialog
678 (gClient->GetRoot(), this, 400, 200);
679 break;
680
681 case M_FILE_SAVE:
682 printf("M_FILE_SAVE\n");
683 break;
684
685 case M_FILE_EXIT:
686 CloseWindow(); // this also terminates theApp
687 break;
688 default:
689 break;
690 }
691 default:
692 break;
693 }
694 default:
695 break;
696 }
697 return kTRUE;
698}
699
700//ClassImp(AliGuiGeomDialog)
701
702AliGuiGeomDialog::AliGuiGeomDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
703 UInt_t h, UInt_t options)
704 : TGTransientFrame(p, main, w, h, options)
705{
706 // Create a dialog window. A dialog window pops up with respect to its
707 // "main" window.
708
709 fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
710
711 fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
712 fOkButton->Associate(this);
713 fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
714 fCancelButton->Associate(this);
715
716 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
717 2, 2, 2, 2);
718 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
719
720 fFrame1->AddFrame(fOkButton, fL1);
721 fFrame1->AddFrame(fCancelButton, fL1);
722
723 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
724 AddFrame(fFrame1, fL2);
725
726 //--------- create Tab widget and some composite frames for Tab testing
727
728 fTab = new TGTab(this, 300, 300);
729 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
730//
731// Tab1: Sliders
732//
733 TGCompositeFrame *tf = fTab->AddTab("Draw");
734 fF1 = new AliGUISliders(tf, this, 60, 20);
735 tf->AddFrame(fF1,fL3);
736
737//
738// Tab2: Drawing Options
739//
740 tf = fTab->AddTab("Options");
741 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
742 200, 2, 2, 2);
743 fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
744
745 fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "Shadow", 86), fL3);
746 fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Hide ", 87), fL3);
747 fF2->AddFrame(fChk3 = new TGCheckButton(fF2, "Clip ", 88), fL3);
748
749 fF2->AddFrame(fLabel1 = new TGLabel(fF2, "Fill"),fL3);
750
751 fCombo = new TGComboBox(fF2, 89);
752 fF2->AddFrame(fCombo, fL3);
753
754 tf->AddFrame(fF2, fL3);
755
756 int i;
757 for (i = 0; i < 8; i++) {
758 char tmp[20];
759
760 sprintf(tmp, "%i", i+1);
761 fCombo->AddEntry(tmp, i+1);
762 }
763 fCombo->Select(1);
764 fCombo->Resize(50, 20);
765 fCombo->Associate(this);
766
767 fChk1->Associate(this);
768 fChk2->Associate(this);
769 fChk3->Associate(this);
770//
771// Tab2: Seen Option
772//
773 tf = fTab->AddTab("Seen");
774 fF3 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
775 fF3->AddFrame(fLabel2 = new TGLabel(fF3, "Seen"),fL3);
776 fCombo2 = new TGComboBox(fF3, 90);
777 fF3->AddFrame(fCombo2, fL3);
778 tf->AddFrame(fF3, fL3);
779
780 for (i = 0; i < 4; i++) {
781 char tmp[20];
782
783 sprintf(tmp, "%i", i-2);
784 fCombo2->AddEntry(tmp, i+1);
785 }
786 fCombo2->Select(4);
787 fCombo2->Resize(50, 20);
788 fCombo2->Associate(this);
789//
790// Tab4: Clip Box
791//
792 tf = fTab->AddTab("ClipBox");
793 //--- layout for buttons: top align, equally expand horizontally
794 fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
795
796 //--- layout for the frame: place at bottom, right aligned
797 fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
798//
799// Frames
800//
801// Slider1
802 fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
803
804 fHSframe1 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
805
806 fTbh11 = new TGTextBuffer(10);
807 fTeh11 = new TGTextEntry(fHSframe1, fTbh11,1);
808 fTbh11->AddText(0, " 0");
809 fTeh11->Associate(this);
810
811 fTbh12 = new TGTextBuffer(10);
812 fTeh12 = new TGTextEntry(fHSframe1, fTbh12,1);
813 fTbh12->AddText(0, "2000");
814 fTeh12->Associate(this);
815
816 fDslider1 = new TGDoubleHSlider(fHSframe1, 400, kSlider1 | kScaleBoth, 1);
817 fDslider1->Associate(this);
818 fDslider1->SetRange(-2000, 2000);
819 fDslider1->SetPosition(0, 2000);
820
821 fSLabel1 = new TGLabel(fHSframe1, "xmin-xmax");
822
823 fHSframe1->AddFrame(fSLabel1, fBfly1);
824 fHSframe1->AddFrame(fTeh11, fBfly1);
825 fHSframe1->AddFrame(fTeh12, fBfly1);
826 fHSframe1->AddFrame(fDslider1, fBfly1);
827
828 fF4->AddFrame(fHSframe1, fBly);
829
830//
831 fHSframe2 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
832
833 fTbh21 = new TGTextBuffer(10);
834 fTeh21 = new TGTextEntry(fHSframe2, fTbh21,1);
835 fTbh21->AddText(0, " 0");
836 fTeh21->Associate(this);
837
838 fTbh22 = new TGTextBuffer(10);
839 fTeh22 = new TGTextEntry(fHSframe2, fTbh22,1);
840 fTbh22->AddText(0, "2000");
841 fTeh22->Associate(this);
842
843 fDslider2 = new TGDoubleHSlider(fHSframe2, 400, kSlider1 | kScaleBoth, 2);
844 fDslider2->Associate(this);
845 fDslider2->SetRange(-2000, 2000);
846 fDslider2->SetPosition(0, 2000);
847
848 fSLabel2 = new TGLabel(fHSframe2, "ymin-ymax");
849
850 fHSframe2->AddFrame(fSLabel2, fBfly1);
851 fHSframe2->AddFrame(fTeh21, fBfly1);
852 fHSframe2->AddFrame(fTeh22, fBfly1);
853 fHSframe2->AddFrame(fDslider2, fBfly1);
854
855 fF4->AddFrame(fHSframe2, fBly);
856
857//
858 fHSframe3 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
859
860 fTbh31 = new TGTextBuffer(10);
861 fTeh31 = new TGTextEntry(fHSframe3, fTbh31,1);
862 fTbh31->AddText(0, " 0");
863 fTeh31->Associate(this);
864
865 fTbh32 = new TGTextBuffer(10);
866 fTeh32 = new TGTextEntry(fHSframe3, fTbh32,1);
867 fTbh32->AddText(0, "2000");
868 fTeh32->Associate(this);
869
870 fDslider3 = new TGDoubleHSlider(fHSframe3, 400, kSlider1 | kScaleBoth, 3);
871 fDslider3->Associate(this);
872 fDslider3->SetRange(-2000, 2000);
873 fDslider3->SetPosition(0, 2000);
874
875 fSLabel3 = new TGLabel(fHSframe3, "zmin-zmax");
876
877 fHSframe3->AddFrame(fSLabel3, fBfly1);
878 fHSframe3->AddFrame(fTeh31, fBfly1);
879 fHSframe3->AddFrame(fTeh32, fBfly1);
880 fHSframe3->AddFrame(fDslider3, fBfly1);
881
882 fF4->AddFrame(fHSframe3, fBly);
883
884
885
886
887
888 tf->AddFrame(fF4, fL3);
889
890
891//
892//
893 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
894 kLHintsExpandY, 2, 2, 5, 1);
895 AddFrame(fTab, fL5);
896
897 MapSubwindows();
898 Resize(GetDefaultSize());
899
900 // position relative to the parent's window
901 Window_t wdum;
902 int ax, ay;
903 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
904 (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
905 (((TGFrame *) main)->GetHeight() - fHeight) >> 1,
906 ax, ay, wdum);
907 Move(ax, ay);
908
909 SetWindowName("Dialog");
910
911 MapWindow();
912 //gClient->WaitFor(this); // otherwise canvas contextmenu does not work
913}
914
915AliGuiGeomDialog::~AliGuiGeomDialog()
916{
917 // Delete test dialog widgets.
918
919 delete fOkButton;
920 delete fCancelButton;
921 delete fFrame1;
922 delete fChk1; delete fChk2;
923 delete fF1; delete fF2; delete fF3; delete fF4;
924 delete fCombo;
925 delete fTab;
926 delete fL3; delete fL4;
927 delete fL1; delete fL2;
928 delete fBly; delete fBfly1;
929 delete fTbh11; delete fTbh12; delete fTbh21; delete fTbh22;
930 delete fTbh31; delete fTbh32; delete fTeh11; delete fTeh12;
931 delete fTeh21; delete fTeh22; delete fTeh31; delete fTeh32;
932 delete fDslider1; delete fDslider2; delete fDslider3;
933 delete fSLabel1; delete fSLabel2; delete fSLabel3;
934}
935
936void AliGuiGeomDialog::Update()
937{
938 Float_t param;
939// Update Sliders
940 if (fF1) {
941 fF1->Update();
942 }
943// Seen
944 if (fCombo2) {
945 param=gCurrentVolume->GetParam(P_Seen);
946 fCombo2->Select(Int_t(param)+3);
947 }
948// Hide, Shadow, Clip
949 if (fChk1) {
950 if (Int_t(gCurrentVolume->GetParam(P_Shadow))) {
951 fChk1->SetState(kButtonDown);
952 } else {
953 fChk1->SetState(kButtonUp);
954 }
955 }
956
957 if (fChk2) {
958 if (Int_t(gCurrentVolume->GetParam(P_Hide))) {
959 fChk2->SetState(kButtonDown);
960 } else {
961 fChk2->SetState(kButtonUp);
962 }
963 }
964
965 if (fChk3) {
966 if (Int_t(gCurrentVolume->GetParam(P_Clip))) {
967 fChk3->SetState(kButtonDown);
968 } else {
969 fChk3->SetState(kButtonUp);
970 }
971 }
972
973}
974
975void AliGuiGeomDialog::CloseWindow()
976{
977 // Called when window is closed via the window manager.
978 delete this;
979}
980
981Bool_t AliGuiGeomDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
982{
983 // Process messages coming from widgets associated with the dialog.
984 char buf[10];
985 Float_t min,max;
986 switch (GET_MSG(msg)) {
987 case kC_HSLIDER:
988 switch (GET_SUBMSG(msg)) {
989 case kSL_POS:
990 switch (Int_t(parm1)) {
991 case 1:
992 min=fDslider1->GetMinPosition();
993 max=fDslider1->GetMaxPosition();
994 sprintf(buf, "%6.2f", min);
995 fTbh11->Clear();
996 fTbh11->AddText(0, buf);
997 sprintf(buf, "%6.2f", max);
998 fTbh12->Clear();
999 fTbh12->AddText(0, buf);
1000 gClient->NeedRedraw(fTeh11);
1001 gClient->NeedRedraw(fTeh12);
1002 gCurrentVolume->SetParam(P_ClipXmin,min);
1003 gCurrentVolume->SetParam(P_ClipXmax,max);
1004 break;
1005 case 2:
1006 min=fDslider2->GetMinPosition();
1007 max=fDslider2->GetMaxPosition();
1008 sprintf(buf, "%6.2f", min);
1009 fTbh21->Clear();
1010 fTbh21->AddText(0, buf);
1011 sprintf(buf, "%6.2f", max);
1012 fTbh22->Clear();
1013 fTbh22->AddText(0, buf);
1014 gClient->NeedRedraw(fTeh21);
1015 gClient->NeedRedraw(fTeh22);
1016 gCurrentVolume->SetParam(P_ClipYmin,min);
1017 gCurrentVolume->SetParam(P_ClipYmax,max);
1018 break;
1019 case 3:
1020 min=fDslider3->GetMinPosition();
1021 max=fDslider3->GetMaxPosition();
1022 sprintf(buf, "%6.2f", min);
1023 fTbh31->Clear();
1024 fTbh31->AddText(0, buf);
1025 sprintf(buf, "%6.2f", max);
1026 fTbh32->Clear();
1027 fTbh32->AddText(0, buf);
1028 gClient->NeedRedraw(fTeh31);
1029 gClient->NeedRedraw(fTeh32);
1030 gCurrentVolume->SetParam(P_ClipZmin,min);
1031 gCurrentVolume->SetParam(P_ClipZmax,max);
1032 break;
1033 default:
1034 break;
1035 }
1036 }
1037 break;
1038 case kC_COMMAND:
1039 switch (GET_SUBMSG(msg)) {
1040 case kCM_BUTTON:
1041 switch(parm1) {
1042 case 1:
1043 case 2:
1044 printf("\nTerminating dialog: %s pressed\n",
1045 (parm1 == 1) ? "OK" : "Cancel");
1046 CloseWindow();
1047 break;
1048 }
1049 break;
1050 case kCM_COMBOBOX:
1051 switch(parm1) {
1052 case 89:
1053 gCurrentVolume->SetParam(P_Fill, Float_t(parm2));
1054 gCurrentVolume->Draw();
1055 break;
1056 case 90:
1057 gCurrentVolume->SetParam(P_Seen, Float_t(parm2-3));
1058 gCurrentVolume->Draw();
1059 break;
1060 }
1061 break;
1062 case kCM_CHECKBUTTON:
1063 switch (parm1) {
1064 case 86:
1065 if (Int_t(gCurrentVolume->GetParam(P_Shadow))) {
1066 gCurrentVolume->SetParam(P_Shadow, 0.);
1067 } else {
1068 gCurrentVolume->SetParam(P_Shadow, 1.);
1069 }
1070 gCurrentVolume->Draw();
1071 break;
1072 case 87:
1073 if (Int_t(gCurrentVolume->GetParam(P_Hide))) {
1074 gCurrentVolume->SetParam(P_Hide, 0.);
1075 } else {
1076 gCurrentVolume->SetParam(P_Hide, 1.);
1077 }
1078 gCurrentVolume->Draw();
1079 break;
1080 case 88:
1081 if (Int_t(gCurrentVolume->GetParam(P_Clip))) {
1082 gCurrentVolume->SetParam(P_Clip, 0.);
1083 } else {
1084 gCurrentVolume->SetParam(P_Clip, 1.);
1085 }
1086 gCurrentVolume->Draw();
1087 break;
1088
1089 default:
1090 break;
1091 }
1092 break;
1093 case kCM_TAB:
1094 break;
1095 default:
1096 break;
1097 }
1098 break;
1099 default:
1100 break;
1101 }
1102 return kTRUE;
1103}
1104
1105//ClassImp(AliGUISliders)
1106
1107static Text_t* LabelText[7] =
1108{"Theta ", "Phi ", "Psi ", "U ", "V ", "UScale", "VScale"};
1109static Int_t IRangeMin[7] = { 0, 0, 0, 0, 0, 0, 0};
1110static Int_t IRangeMax[7] = {36000, 36000, 36000, 2000, 2000, 10, 10};
1111static Int_t DefaultPos[7] = { 3000, 4000, 0, 1000, 1000, 1, 1};
1112
f70a166f 1113AliGUISliders::AliGUISliders(const TGWindow *p, const TGWindow *,
78976106 1114 UInt_t w, UInt_t h) :
1115 TGCompositeFrame(p, w, h,kVerticalFrame)
1116{
1117 ChangeOptions((GetOptions() & ~kHorizontalFrame) | kVerticalFrame);
1118 //--- layout for buttons: top align, equally expand horizontally
1119 fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
1120
1121 //--- layout for the frame: place at bottom, right aligned
1122 fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
1123//
1124// Frames
1125
1126 for (Int_t i=0; i<7; i++) {
1127 Int_t idT=i+1;
1128 Int_t idS=i+8;
1129 fHframe[i] = new TGHorizontalFrame(this, 400, 100, kFixedWidth);
1130 fTbh[i] = new TGTextBuffer(10);
1131 fTeh[i] = new TGTextEntry(fHframe[i], fTbh[i],idT);
1132 char buf[10];
1133 sprintf(buf, "%6.2f", Float_t(DefaultPos[i])/100);
1134 fTbh[i]->AddText(0, buf);
1135 fTeh[i]->Associate(this);
1136
1137 fHslider[i] = new TGHSlider(fHframe[i], 400, kSlider1 | kScaleBoth, idS);
1138 fHslider[i]->Associate(this);
1139 fHslider[i]->SetRange(IRangeMin[i], IRangeMax[i]);
1140 fHslider[i]->SetPosition(DefaultPos[i]);
1141
1142 fLabel[i] = new TGLabel(fHframe[i], LabelText[i]);
1143
1144
1145 fHframe[i]->AddFrame(fLabel[i], fBfly1);
1146 fHframe[i]->AddFrame(fTeh[i], fBfly1);
1147 fHframe[i]->AddFrame(fHslider[i], fBfly1);
1148
1149 AddFrame(fHframe[i], fBly);
1150 }
1151}
1152
1153AliGUISliders::~AliGUISliders()
1154{
1155 delete fBfly1; delete fBly;
1156 // Delete dialog.
1157 for (Int_t i=1; i<7; i++) {
1158 delete fHframe[i];
1159 delete fHslider[i];
1160 delete fTeh[i];
1161 delete fTbh[i];
1162 }
1163}
1164
1165void AliGUISliders::Update()
1166{
1167 char buf[10];
1168
1169 for (Int_t i=0; i<7; i++) {
1170 Float_t param = gCurrentVolume->GetParam(i);
1171//
1172 fHslider[i]->SetPosition(Int_t(param*100.));
1173 gClient->NeedRedraw(fHslider[i]);
1174//
1175 sprintf(buf, "%6.2f", param);
1176 fTbh[i]->Clear();
1177 fTbh[i]->AddText(0, buf);
1178 gClient->NeedRedraw(fTeh[i]);
1179//
1180 }
1181
1182
1183}
1184
1185void AliGUISliders::CloseWindow()
1186{
1187 // Called when window is closed via the window manager.
1188
1189 delete this;
1190}
1191
1192Bool_t AliGUISliders::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
1193{
1194 // Process slider messages.
1195
1196 char buf[10];
1197
1198 switch (GET_MSG(msg)) {
1199 case kC_TEXTENTRY:
1200 switch (GET_SUBMSG(msg)) {
1201 case kTE_TEXTCHANGED:
1202 Int_t idT=Int_t(parm1)-1;
f70a166f 1203 fHslider[idT]->SetPosition((Int_t)atof(fTbh[idT]->GetString())*100);
78976106 1204 gClient->NeedRedraw(fHslider[idT]);
1205 gCurrentVolume->SetParam(idT,atof(fTbh[idT]->GetString()));
1206 gCurrentVolume->Draw();
1207 }
1208 break;
1209 case kC_HSLIDER:
1210 switch (GET_SUBMSG(msg)) {
1211 case kSL_POS:
1212 sprintf(buf, "%6.2f", Float_t(parm2)/100);
1213 Int_t idS=Int_t(parm1)-8;
1214 fTbh[idS]->Clear();
1215 fTbh[idS]->AddText(0, buf);
1216 gClient->NeedRedraw(fTeh[idS]);
1217 gCurrentVolume->SetParam(idS, Float_t(parm2)/100.);
1218 gCurrentVolume->Draw();
1219 }
1220 break;
1221 }
1222 return kTRUE;
1223}
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241