1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.2 1999/11/10 16:53:35 fca
19 The new geometry viewer from A.Morsch
25 * Written by Andreas Morsch
29 * For questions critics and suggestions to this part of the code
30 * contact andreas.morsch@cern.ch
32 **************************************************************************/
39 #include <TApplication.h>
40 #include <TVirtualX.h>
41 #include <TGListBox.h>
42 #include <TGListTree.h>
48 #include <TGTextEntry.h>
52 #include <TGComboBox.h>
55 #include <TGDoubleSlider.h>
56 #include <TGFileDialog.h>
57 #include <TRootEmbeddedCanvas.h>
64 #include <TGPicture.h>
66 #include "TGeant3GUI.h"
68 static AliDrawVolume * gCurrentVolume = new AliDrawVolume("NULL");
70 ClassImp(AliGeant3GeometryGUI)
72 AliGeant3GeometryGUI::AliGeant3GeometryGUI()
74 fPanel = new AliGuiGeomMain(gClient->GetRoot(), 500, 500);
76 fVolumes = new TClonesArray("AliDrawVolume",100);
77 TGeant3 *geant3 = (TGeant3*) gMC;
80 fGclink=geant3->Gclink();
82 void AliGeant3GeometryGUI::Streamer(TBuffer &)
87 void AliGeant3GeometryGUI::ReadGeometryTree()
90 char /* *namec, */ *tmp;
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");
96 AliDrawVolume *volume;
100 Int_t newlevel=nlevel;
102 volume = new AliDrawVolume("ALIC");
103 volume->SetIdVolume(((TGeant3*)gMC)->VolId("ALIC"));
104 volume->SetIdCopy(0);
105 volume->SetItem(NULL);
106 (*fVolumes)[0]=volume;
109 for (Int_t i=nst; i<nlevel; i++)
111 TGListTreeItem *itemi, *item2;
112 Int_t ivol=TMath::Abs(Volume(i)->GetIdVolume());
114 Int_t nch = NChildren(ivol);
115 // namec= ((TGeant3*)gMC)->VolName(ivol);
116 strcpy(namec,((TGeant3*)gMC)->VolName(ivol));
118 printf("\n %s has %d children \n ", namec, nch);
120 printf("\n %s has %d divisions \n ", namec, -nch);
123 strncpy(vname,namec, 4);
125 Int_t icopy = Volume(i)->GetIdCopy();
127 sprintf(namec,"%s*%3dPos",namec,icopy);
128 } else if (icopy <0) {
129 sprintf(namec,"%s*%3dDiv",namec,-icopy);
132 itemi=Volume(i)->GetItem();
139 item2 = fPanel->AddItem(new AliDrawVolume(vname),
140 itemi, namec, OpenFolder, Folder);
142 item2 = fPanel->AddItem(new AliDrawVolume(vname),
143 itemi, namec, Document, Document);
147 Int_t icvol=Child(ivol,1);
148 // namec= ((TGeant3*)gMC)->VolName(-icvol);
149 strcpy(namec,((TGeant3*)gMC)->VolName(-icvol));
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);
161 for (Int_t j=0; j<nch; j++)
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++) {
168 Volume(newlevel-k-1)->GetIdVolume())
170 Volume(newlevel-k-1)->AddCopy();
175 // namec=((TGeant3*)gMC)->VolName(icvol);
176 strcpy(namec,((TGeant3*)gMC)->VolName(icvol));
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);
197 Int_t AliGeant3GeometryGUI::NChildren(Int_t idvol)
199 Int_t jvo = fZlq[fGclink->jvolum-idvol];
200 Int_t nin = Int_t(fZq[jvo+3]);
204 Int_t AliGeant3GeometryGUI::Child(Int_t idvol, Int_t idc)
206 Int_t jvo = fZlq[fGclink->jvolum-idvol];
208 Int_t jin = fZlq[jvo-nin];
209 Int_t numb = Int_t (fZq[jin +3]);
211 return -Int_t(fZq[jin+2]);
213 return Int_t(fZq[jin+2]);
218 ClassImp(AliDrawVolume)
219 enum AliDrawParamId {
241 AliDrawVolume::AliDrawVolume(char* name)
264 char* AliDrawVolume::Name()
270 void AliDrawVolume::Streamer(TBuffer &)
277 void AliDrawVolume::Draw(Option_t *)
279 gMC->Gsatt(fName,"seen", fSeen);
282 gMC->Gdopt("hide", "on");
284 gMC->Gdopt("hide", "off");
288 gMC->Gdopt("shad", "on");
289 gMC->Gsatt("*", "fill", fFill);
291 gMC->Gdopt("shad", "off");
294 gMC->SetClipBox(".");
296 gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
298 gMC->SetClipBox(".");
302 gMC->Gdraw(fName, fTheta, fPhi, fPsi, fU, fV, fUscale, fVscale);
303 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
304 if (higz) higz->Update();
307 void AliDrawVolume::DrawSpec()
309 gMC->Gsatt(fName,"seen", fSeen);
312 gMC->Gdopt("hide", "on");
314 gMC->Gdopt("hide", "off");
318 gMC->Gdopt("shad", "on");
319 gMC->Gsatt("*", "fill", fFill);
321 gMC->Gdopt("shad", "off");
324 gMC->SetClipBox(".");
326 gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
328 gMC->SetClipBox(".");
332 ((TGeant3*) gMC)->DrawOneSpec(fName);
333 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
334 if (higz) higz->Update();
337 void AliDrawVolume::SetParam(Int_t ip, Float_t param)
365 fShadow=Int_t(param);
397 Float_t AliDrawVolume::GetParam(Int_t ip)
415 return Float_t(fHide);
417 return Float_t(fShadow);
419 return Float_t(fFill);
421 return Float_t(fSeen);
423 return Float_t(fClip);
443 ClassImp(AliGuiGeomMain)
445 enum ETestCommandIdentifiers {
470 Int_t mb_button_id[9] = { kMBYes, kMBNo, kMBOk, kMBApply,
471 kMBRetry, kMBIgnore, kMBCancel,
472 kMBClose, kMBDismiss };
474 EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion,
475 kMBIconExclamation, kMBIconAsterisk };
477 const char *filetypes[] = { "All files", "*",
478 "ROOT files", "*.root",
479 "ROOT macros", "*.C",
485 TGListTreeItem* AliGuiGeomMain::
486 AddItem(TObject * obj, TGListTreeItem *parent, const char* name, const TGPicture *open, const TGPicture *closed)
488 return fLt->AddItem(parent, name, obj, open, closed);
491 AliGuiGeomMain::AliGuiGeomMain(const TGWindow *p, UInt_t w, UInt_t h)
492 : TGMainFrame(p, w, h)
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,
501 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
502 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
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);
512 fMenuFile->DisableEntry(M_FILE_SAVEAS);
513 fMenuFile->DisableEntry(M_FILE_OPEN);
514 fMenuFile->DisableEntry(M_FILE_SAVE);
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);
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);
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);
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);
546 AddFrame(fMenuBar, fMenuBarLayout);
548 // Create TGCanvas and a canvas container which uses a tile layout manager
550 fCanvasWindow = new TGCanvas(this, 400, 240);
551 fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame,
553 fLt->Associate(this);
554 fCanvasWindow->SetContainer(fLt);
557 TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
558 AddFrame(fCanvasWindow, lo);
562 SetWindowName("AliRoot Geometry Browser");
566 // we need to use GetDefault...() to initialize the layout algorithm...
567 Resize(GetDefaultSize());
573 AliGuiGeomMain::~AliGuiGeomMain()
575 // Delete all created widgets.
578 delete fCanvasWindow;
580 delete fMenuBarLayout;
581 delete fMenuBarItemLayout;
582 delete fMenuBarHelpLayout;
589 void AliGuiGeomMain::Update()
596 void AliGuiGeomMain::CloseWindow()
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.
603 TGMainFrame::CloseWindow();
604 gApplication->Terminate(0);
607 Bool_t AliGuiGeomMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
609 // Handle messages send to the AliGuiGeomMain object. E.g. all menu button messages.
610 switch (GET_MSG(msg)) {
612 switch (GET_SUBMSG(msg)) {
614 TGListTreeItem *item;
615 if (parm1 == kButton1) {
616 if ((item = fLt->GetSelected()))
618 gCurrentVolume=((AliDrawVolume *) item->GetUserData());
623 if (parm1 == kButton2) {
624 TGListTreeItem *item;
625 if ((item = fLt->GetSelected()))
627 ((AliDrawVolume *) item->GetUserData())->DrawSpec();
628 gCurrentVolume=((AliDrawVolume *) item->GetUserData());
633 if (parm1 == kButton3) {
634 TGListTreeItem *item;
635 if ((item = fLt->GetSelected()))
637 ((AliDrawVolume *) item->GetUserData())->Draw();
638 gCurrentVolume=((AliDrawVolume *) item->GetUserData());
645 case kCT_ITEMDBLCLICK:
646 if (parm1 == kButton1) {
647 if (fLt->GetSelected() != 0) {
648 gClient->NeedRedraw(fLt);
657 switch (GET_SUBMSG(msg)) {
671 fi.fFileTypes = (char **)filetypes;
672 new TGFileDialog(gClient->GetRoot(), this, kFDOpen,&fi);
677 fDialog = new AliGuiGeomDialog
678 (gClient->GetRoot(), this, 400, 200);
682 printf("M_FILE_SAVE\n");
686 CloseWindow(); // this also terminates theApp
700 //ClassImp(AliGuiGeomDialog)
702 AliGuiGeomDialog::AliGuiGeomDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
703 UInt_t h, UInt_t options)
704 : TGTransientFrame(p, main, w, h, options)
706 // Create a dialog window. A dialog window pops up with respect to its
709 fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
711 fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
712 fOkButton->Associate(this);
713 fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
714 fCancelButton->Associate(this);
716 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
718 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
720 fFrame1->AddFrame(fOkButton, fL1);
721 fFrame1->AddFrame(fCancelButton, fL1);
723 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
724 AddFrame(fFrame1, fL2);
726 //--------- create Tab widget and some composite frames for Tab testing
728 fTab = new TGTab(this, 300, 300);
729 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
733 TGCompositeFrame *tf = fTab->AddTab("Draw");
734 fF1 = new AliGUISliders(tf, this, 60, 20);
735 tf->AddFrame(fF1,fL3);
738 // Tab2: Drawing Options
740 tf = fTab->AddTab("Options");
741 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
743 fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
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);
749 fF2->AddFrame(fLabel1 = new TGLabel(fF2, "Fill"),fL3);
751 fCombo = new TGComboBox(fF2, 89);
752 fF2->AddFrame(fCombo, fL3);
754 tf->AddFrame(fF2, fL3);
757 for (i = 0; i < 8; i++) {
760 sprintf(tmp, "%i", i+1);
761 fCombo->AddEntry(tmp, i+1);
764 fCombo->Resize(50, 20);
765 fCombo->Associate(this);
767 fChk1->Associate(this);
768 fChk2->Associate(this);
769 fChk3->Associate(this);
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);
780 for (i = 0; i < 4; i++) {
783 sprintf(tmp, "%i", i-2);
784 fCombo2->AddEntry(tmp, i+1);
787 fCombo2->Resize(50, 20);
788 fCombo2->Associate(this);
792 tf = fTab->AddTab("ClipBox");
793 //--- layout for buttons: top align, equally expand horizontally
794 fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
796 //--- layout for the frame: place at bottom, right aligned
797 fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
802 fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
804 fHSframe1 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
806 fTbh11 = new TGTextBuffer(10);
807 fTeh11 = new TGTextEntry(fHSframe1, fTbh11,1);
808 fTbh11->AddText(0, " 0");
809 fTeh11->Associate(this);
811 fTbh12 = new TGTextBuffer(10);
812 fTeh12 = new TGTextEntry(fHSframe1, fTbh12,1);
813 fTbh12->AddText(0, "2000");
814 fTeh12->Associate(this);
816 fDslider1 = new TGDoubleHSlider(fHSframe1, 400, kSlider1 | kScaleBoth, 1);
817 fDslider1->Associate(this);
818 fDslider1->SetRange(-2000, 2000);
819 fDslider1->SetPosition(0, 2000);
821 fSLabel1 = new TGLabel(fHSframe1, "xmin-xmax");
823 fHSframe1->AddFrame(fSLabel1, fBfly1);
824 fHSframe1->AddFrame(fTeh11, fBfly1);
825 fHSframe1->AddFrame(fTeh12, fBfly1);
826 fHSframe1->AddFrame(fDslider1, fBfly1);
828 fF4->AddFrame(fHSframe1, fBly);
831 fHSframe2 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
833 fTbh21 = new TGTextBuffer(10);
834 fTeh21 = new TGTextEntry(fHSframe2, fTbh21,1);
835 fTbh21->AddText(0, " 0");
836 fTeh21->Associate(this);
838 fTbh22 = new TGTextBuffer(10);
839 fTeh22 = new TGTextEntry(fHSframe2, fTbh22,1);
840 fTbh22->AddText(0, "2000");
841 fTeh22->Associate(this);
843 fDslider2 = new TGDoubleHSlider(fHSframe2, 400, kSlider1 | kScaleBoth, 2);
844 fDslider2->Associate(this);
845 fDslider2->SetRange(-2000, 2000);
846 fDslider2->SetPosition(0, 2000);
848 fSLabel2 = new TGLabel(fHSframe2, "ymin-ymax");
850 fHSframe2->AddFrame(fSLabel2, fBfly1);
851 fHSframe2->AddFrame(fTeh21, fBfly1);
852 fHSframe2->AddFrame(fTeh22, fBfly1);
853 fHSframe2->AddFrame(fDslider2, fBfly1);
855 fF4->AddFrame(fHSframe2, fBly);
858 fHSframe3 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
860 fTbh31 = new TGTextBuffer(10);
861 fTeh31 = new TGTextEntry(fHSframe3, fTbh31,1);
862 fTbh31->AddText(0, " 0");
863 fTeh31->Associate(this);
865 fTbh32 = new TGTextBuffer(10);
866 fTeh32 = new TGTextEntry(fHSframe3, fTbh32,1);
867 fTbh32->AddText(0, "2000");
868 fTeh32->Associate(this);
870 fDslider3 = new TGDoubleHSlider(fHSframe3, 400, kSlider1 | kScaleBoth, 3);
871 fDslider3->Associate(this);
872 fDslider3->SetRange(-2000, 2000);
873 fDslider3->SetPosition(0, 2000);
875 fSLabel3 = new TGLabel(fHSframe3, "zmin-zmax");
877 fHSframe3->AddFrame(fSLabel3, fBfly1);
878 fHSframe3->AddFrame(fTeh31, fBfly1);
879 fHSframe3->AddFrame(fTeh32, fBfly1);
880 fHSframe3->AddFrame(fDslider3, fBfly1);
882 fF4->AddFrame(fHSframe3, fBly);
888 tf->AddFrame(fF4, fL3);
893 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
894 kLHintsExpandY, 2, 2, 5, 1);
898 Resize(GetDefaultSize());
900 // position relative to the parent's window
903 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
904 (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
905 (((TGFrame *) main)->GetHeight() - fHeight) >> 1,
909 SetWindowName("Dialog");
912 //gClient->WaitFor(this); // otherwise canvas contextmenu does not work
915 AliGuiGeomDialog::~AliGuiGeomDialog()
917 // Delete test dialog widgets.
920 delete fCancelButton;
922 delete fChk1; delete fChk2;
923 delete fF1; delete fF2; delete fF3; delete fF4;
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;
936 void AliGuiGeomDialog::Update()
945 param=gCurrentVolume->GetParam(P_Seen);
946 fCombo2->Select(Int_t(param)+3);
948 // Hide, Shadow, Clip
950 if (Int_t(gCurrentVolume->GetParam(P_Shadow))) {
951 fChk1->SetState(kButtonDown);
953 fChk1->SetState(kButtonUp);
958 if (Int_t(gCurrentVolume->GetParam(P_Hide))) {
959 fChk2->SetState(kButtonDown);
961 fChk2->SetState(kButtonUp);
966 if (Int_t(gCurrentVolume->GetParam(P_Clip))) {
967 fChk3->SetState(kButtonDown);
969 fChk3->SetState(kButtonUp);
975 void AliGuiGeomDialog::CloseWindow()
977 // Called when window is closed via the window manager.
981 Bool_t AliGuiGeomDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
983 // Process messages coming from widgets associated with the dialog.
986 switch (GET_MSG(msg)) {
988 switch (GET_SUBMSG(msg)) {
990 switch (Int_t(parm1)) {
992 min=fDslider1->GetMinPosition();
993 max=fDslider1->GetMaxPosition();
994 sprintf(buf, "%6.2f", min);
996 fTbh11->AddText(0, buf);
997 sprintf(buf, "%6.2f", max);
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);
1006 min=fDslider2->GetMinPosition();
1007 max=fDslider2->GetMaxPosition();
1008 sprintf(buf, "%6.2f", min);
1010 fTbh21->AddText(0, buf);
1011 sprintf(buf, "%6.2f", max);
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);
1020 min=fDslider3->GetMinPosition();
1021 max=fDslider3->GetMaxPosition();
1022 sprintf(buf, "%6.2f", min);
1024 fTbh31->AddText(0, buf);
1025 sprintf(buf, "%6.2f", max);
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);
1039 switch (GET_SUBMSG(msg)) {
1044 printf("\nTerminating dialog: %s pressed\n",
1045 (parm1 == 1) ? "OK" : "Cancel");
1053 gCurrentVolume->SetParam(P_Fill, Float_t(parm2));
1054 gCurrentVolume->Draw();
1057 gCurrentVolume->SetParam(P_Seen, Float_t(parm2-3));
1058 gCurrentVolume->Draw();
1062 case kCM_CHECKBUTTON:
1065 if (Int_t(gCurrentVolume->GetParam(P_Shadow))) {
1066 gCurrentVolume->SetParam(P_Shadow, 0.);
1068 gCurrentVolume->SetParam(P_Shadow, 1.);
1070 gCurrentVolume->Draw();
1073 if (Int_t(gCurrentVolume->GetParam(P_Hide))) {
1074 gCurrentVolume->SetParam(P_Hide, 0.);
1076 gCurrentVolume->SetParam(P_Hide, 1.);
1078 gCurrentVolume->Draw();
1081 if (Int_t(gCurrentVolume->GetParam(P_Clip))) {
1082 gCurrentVolume->SetParam(P_Clip, 0.);
1084 gCurrentVolume->SetParam(P_Clip, 1.);
1086 gCurrentVolume->Draw();
1105 //ClassImp(AliGUISliders)
1107 static Text_t* LabelText[7] =
1108 {"Theta ", "Phi ", "Psi ", "U ", "V ", "UScale", "VScale"};
1109 static Int_t IRangeMin[7] = { 0, 0, 0, 0, 0, 0, 0};
1110 static Int_t IRangeMax[7] = {36000, 36000, 36000, 2000, 2000, 10, 10};
1111 static Int_t DefaultPos[7] = { 3000, 4000, 0, 1000, 1000, 1, 1};
1113 AliGUISliders::AliGUISliders(const TGWindow *p, const TGWindow *,
1114 UInt_t w, UInt_t h) :
1115 TGCompositeFrame(p, w, h,kVerticalFrame)
1117 ChangeOptions((GetOptions() & ~kHorizontalFrame) | kVerticalFrame);
1118 //--- layout for buttons: top align, equally expand horizontally
1119 fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
1121 //--- layout for the frame: place at bottom, right aligned
1122 fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
1126 for (Int_t i=0; i<7; i++) {
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);
1133 sprintf(buf, "%6.2f", Float_t(DefaultPos[i])/100);
1134 fTbh[i]->AddText(0, buf);
1135 fTeh[i]->Associate(this);
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]);
1142 fLabel[i] = new TGLabel(fHframe[i], LabelText[i]);
1145 fHframe[i]->AddFrame(fLabel[i], fBfly1);
1146 fHframe[i]->AddFrame(fTeh[i], fBfly1);
1147 fHframe[i]->AddFrame(fHslider[i], fBfly1);
1149 AddFrame(fHframe[i], fBly);
1153 AliGUISliders::~AliGUISliders()
1155 delete fBfly1; delete fBly;
1157 for (Int_t i=1; i<7; i++) {
1165 void AliGUISliders::Update()
1169 for (Int_t i=0; i<7; i++) {
1170 Float_t param = gCurrentVolume->GetParam(i);
1172 fHslider[i]->SetPosition(Int_t(param*100.));
1173 gClient->NeedRedraw(fHslider[i]);
1175 sprintf(buf, "%6.2f", param);
1177 fTbh[i]->AddText(0, buf);
1178 gClient->NeedRedraw(fTeh[i]);
1185 void AliGUISliders::CloseWindow()
1187 // Called when window is closed via the window manager.
1192 Bool_t AliGUISliders::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
1194 // Process slider messages.
1198 switch (GET_MSG(msg)) {
1200 switch (GET_SUBMSG(msg)) {
1201 case kTE_TEXTCHANGED:
1202 Int_t idT=Int_t(parm1)-1;
1203 fHslider[idT]->SetPosition((Int_t)atof(fTbh[idT]->GetString())*100);
1204 gClient->NeedRedraw(fHslider[idT]);
1205 gCurrentVolume->SetParam(idT,atof(fTbh[idT]->GetString()));
1206 gCurrentVolume->Draw();
1210 switch (GET_SUBMSG(msg)) {
1212 sprintf(buf, "%6.2f", Float_t(parm2)/100);
1213 Int_t idS=Int_t(parm1)-8;
1215 fTbh[idS]->AddText(0, buf);
1216 gClient->NeedRedraw(fTeh[idS]);
1217 gCurrentVolume->SetParam(idS, Float_t(parm2)/100.);
1218 gCurrentVolume->Draw();