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