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.1 2000/07/13 16:19:10 fca
19 Mainly coding conventions + some small bug fixes
21 Revision 1.8 2000/07/12 08:56:32 fca
22 Coding convention correction and warning removal
24 Revision 1.7 2000/06/28 21:27:45 morsch
25 Most coding rule violations corrected.
26 Still to do: Split the file (on file per class) ? Avoid the global variables.
27 Copy constructors and assignment operators (dummy ?)
29 Revision 1.6 2000/04/14 11:07:46 morsch
30 Correct volume to medium assignment in case several media are asigned to the
33 Revision 1.5 2000/03/20 15:11:03 fca
34 Mods to make the code compile on HP
36 Revision 1.4 2000/01/18 16:12:08 morsch
37 Bug in calculation of number of volume divisions and number of positionings corrected
38 Browser for Material and Media properties added
40 Revision 1.3 1999/11/14 14:31:14 fca
41 Correct small error and remove compilation warnings on HP
43 Revision 1.2 1999/11/10 16:53:35 fca
44 The new geometry viewer from A.Morsch
50 #include "TGComboBox.h"
51 #include "TGDoubleSlider.h"
53 #include "AliGuiGeomDialog.h"
54 #include "AliGUISliders.h"
55 #include "AliG3Volume.h"
57 AliGuiGeomDialog::AliGuiGeomDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
58 UInt_t h, UInt_t options)
59 : TGTransientFrame(p, main, w, h, options)
61 // Create a dialog window. A dialog window pops up with respect to its
64 fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
66 fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
67 fOkButton->Associate(this);
68 fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
69 fCancelButton->Associate(this);
71 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
73 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
75 fFrame1->AddFrame(fOkButton, fL1);
76 fFrame1->AddFrame(fCancelButton, fL1);
78 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
79 AddFrame(fFrame1, fL2);
81 //--------- create Tab widget and some composite frames for Tab testing
83 fTab = new TGTab(this, 300, 300);
84 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
88 TGCompositeFrame *tf = fTab->AddTab("Draw");
89 fF1 = new AliGUISliders(tf, this, 60, 20);
90 tf->AddFrame(fF1,fL3);
93 // Tab2: Drawing Options
95 tf = fTab->AddTab("Options");
96 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
98 fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
100 fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "Shadow", 86), fL3);
101 fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Hide ", 87), fL3);
102 fF2->AddFrame(fChk3 = new TGCheckButton(fF2, "Clip ", 88), fL3);
104 fF2->AddFrame(fLabel1 = new TGLabel(fF2, "Fill"),fL3);
106 fCombo = new TGComboBox(fF2, 89);
107 fF2->AddFrame(fCombo, fL3);
109 tf->AddFrame(fF2, fL3);
112 for (i = 0; i < 8; i++) {
115 sprintf(tmp, "%i", i+1);
116 fCombo->AddEntry(tmp, i+1);
119 fCombo->Resize(50, 20);
120 fCombo->Associate(this);
122 fChk1->Associate(this);
123 fChk2->Associate(this);
124 fChk3->Associate(this);
128 tf = fTab->AddTab("Seen");
129 fF3 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
130 fF3->AddFrame(fLabel2 = new TGLabel(fF3, "Seen"),fL3);
131 fCombo2 = new TGComboBox(fF3, 90);
132 fF3->AddFrame(fCombo2, fL3);
133 tf->AddFrame(fF3, fL3);
135 for (i = 0; i < 4; i++) {
138 sprintf(tmp, "%i", i-2);
139 fCombo2->AddEntry(tmp, i+1);
142 fCombo2->Resize(50, 20);
143 fCombo2->Associate(this);
147 tf = fTab->AddTab("ClipBox");
148 //--- layout for buttons: top align, equally expand horizontally
149 fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
151 //--- layout for the frame: place at bottom, right aligned
152 fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
157 fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
159 fHSframe1 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
161 fTbh11 = new TGTextBuffer(10);
162 fTeh11 = new TGTextEntry(fHSframe1, fTbh11,1);
163 fTbh11->AddText(0, " 0");
164 fTeh11->Associate(this);
166 fTbh12 = new TGTextBuffer(10);
167 fTeh12 = new TGTextEntry(fHSframe1, fTbh12,1);
168 fTbh12->AddText(0, "2000");
169 fTeh12->Associate(this);
171 fDslider1 = new TGDoubleHSlider(fHSframe1, 400, kSlider1 | kScaleBoth, 1);
172 fDslider1->Associate(this);
173 fDslider1->SetRange(-2000, 2000);
174 fDslider1->SetPosition(0, 2000);
176 fSLabel1 = new TGLabel(fHSframe1, "xmin-xmax");
178 fHSframe1->AddFrame(fSLabel1, fBfly1);
179 fHSframe1->AddFrame(fTeh11, fBfly1);
180 fHSframe1->AddFrame(fTeh12, fBfly1);
181 fHSframe1->AddFrame(fDslider1, fBfly1);
183 fF4->AddFrame(fHSframe1, fBly);
186 fHSframe2 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
188 fTbh21 = new TGTextBuffer(10);
189 fTeh21 = new TGTextEntry(fHSframe2, fTbh21,1);
190 fTbh21->AddText(0, " 0");
191 fTeh21->Associate(this);
193 fTbh22 = new TGTextBuffer(10);
194 fTeh22 = new TGTextEntry(fHSframe2, fTbh22,1);
195 fTbh22->AddText(0, "2000");
196 fTeh22->Associate(this);
198 fDslider2 = new TGDoubleHSlider(fHSframe2, 400, kSlider1 | kScaleBoth, 2);
199 fDslider2->Associate(this);
200 fDslider2->SetRange(-2000, 2000);
201 fDslider2->SetPosition(0, 2000);
203 fSLabel2 = new TGLabel(fHSframe2, "ymin-ymax");
205 fHSframe2->AddFrame(fSLabel2, fBfly1);
206 fHSframe2->AddFrame(fTeh21, fBfly1);
207 fHSframe2->AddFrame(fTeh22, fBfly1);
208 fHSframe2->AddFrame(fDslider2, fBfly1);
210 fF4->AddFrame(fHSframe2, fBly);
213 fHSframe3 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
215 fTbh31 = new TGTextBuffer(10);
216 fTeh31 = new TGTextEntry(fHSframe3, fTbh31,1);
217 fTbh31->AddText(0, " 0");
218 fTeh31->Associate(this);
220 fTbh32 = new TGTextBuffer(10);
221 fTeh32 = new TGTextEntry(fHSframe3, fTbh32,1);
222 fTbh32->AddText(0, "2000");
223 fTeh32->Associate(this);
225 fDslider3 = new TGDoubleHSlider(fHSframe3, 400, kSlider1 | kScaleBoth, 3);
226 fDslider3->Associate(this);
227 fDslider3->SetRange(-2000, 2000);
228 fDslider3->SetPosition(0, 2000);
230 fSLabel3 = new TGLabel(fHSframe3, "zmin-zmax");
232 fHSframe3->AddFrame(fSLabel3, fBfly1);
233 fHSframe3->AddFrame(fTeh31, fBfly1);
234 fHSframe3->AddFrame(fTeh32, fBfly1);
235 fHSframe3->AddFrame(fDslider3, fBfly1);
237 fF4->AddFrame(fHSframe3, fBly);
238 tf->AddFrame(fF4, fL3);
241 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
242 kLHintsExpandY, 2, 2, 5, 1);
246 Resize(GetDefaultSize());
248 // position relative to the parent's window
251 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
252 (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
253 (((TGFrame *) main)->GetHeight() - fHeight) >> 1,
257 SetWindowName("Dialog");
260 //gClient->WaitFor(this); // otherwise canvas contextmenu does not work
263 AliGuiGeomDialog::~AliGuiGeomDialog()
265 // Delete test dialog widgets.
268 delete fCancelButton;
270 delete fChk1; delete fChk2;
271 delete fF1; delete fF2; delete fF3; delete fF4;
274 delete fL3; delete fL4;
275 delete fL1; delete fL2;
276 delete fBly; delete fBfly1;
277 delete fTbh11; delete fTbh12; delete fTbh21; delete fTbh22;
278 delete fTbh31; delete fTbh32; delete fTeh11; delete fTeh12;
279 delete fTeh21; delete fTeh22; delete fTeh31; delete fTeh32;
280 delete fDslider1; delete fDslider2; delete fDslider3;
281 delete fSLabel1; delete fSLabel2; delete fSLabel3;
284 void AliGuiGeomDialog::Update()
295 param=gCurrentVolume->GetParam(kSeen);
296 fCombo2->Select(Int_t(param)+3);
298 // Hide, Shadow, Clip
300 if (Int_t(gCurrentVolume->GetParam(kShadow))) {
301 fChk1->SetState(kButtonDown);
303 fChk1->SetState(kButtonUp);
308 if (Int_t(gCurrentVolume->GetParam(kHide))) {
309 fChk2->SetState(kButtonDown);
311 fChk2->SetState(kButtonUp);
316 if (Int_t(gCurrentVolume->GetParam(kClip))) {
317 fChk3->SetState(kButtonDown);
319 fChk3->SetState(kButtonUp);
325 void AliGuiGeomDialog::CloseWindow()
327 // Called when window is closed via the window manager.
331 Bool_t AliGuiGeomDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
333 // Process messages coming from widgets associated with the dialog.
336 switch (GET_MSG(msg)) {
338 switch (GET_SUBMSG(msg)) {
340 switch (Int_t(parm1)) {
342 min=fDslider1->GetMinPosition();
343 max=fDslider1->GetMaxPosition();
344 sprintf(buf, "%6.2f", min);
346 fTbh11->AddText(0, buf);
347 sprintf(buf, "%6.2f", max);
349 fTbh12->AddText(0, buf);
350 gClient->NeedRedraw(fTeh11);
351 gClient->NeedRedraw(fTeh12);
352 gCurrentVolume->SetParam(kClipXmin,min);
353 gCurrentVolume->SetParam(kClipXmax,max);
356 min=fDslider2->GetMinPosition();
357 max=fDslider2->GetMaxPosition();
358 sprintf(buf, "%6.2f", min);
360 fTbh21->AddText(0, buf);
361 sprintf(buf, "%6.2f", max);
363 fTbh22->AddText(0, buf);
364 gClient->NeedRedraw(fTeh21);
365 gClient->NeedRedraw(fTeh22);
366 gCurrentVolume->SetParam(kClipYmin,min);
367 gCurrentVolume->SetParam(kClipYmax,max);
370 min=fDslider3->GetMinPosition();
371 max=fDslider3->GetMaxPosition();
372 sprintf(buf, "%6.2f", min);
374 fTbh31->AddText(0, buf);
375 sprintf(buf, "%6.2f", max);
377 fTbh32->AddText(0, buf);
378 gClient->NeedRedraw(fTeh31);
379 gClient->NeedRedraw(fTeh32);
380 gCurrentVolume->SetParam(kClipZmin,min);
381 gCurrentVolume->SetParam(kClipZmax,max);
389 switch (GET_SUBMSG(msg)) {
394 printf("\nTerminating dialog: %s pressed\n",
395 (parm1 == 1) ? "OK" : "Cancel");
403 gCurrentVolume->SetParam(kFill, Float_t(parm2));
404 gCurrentVolume->Draw();
407 gCurrentVolume->SetParam(kSeen, Float_t(parm2-3));
408 gCurrentVolume->Draw();
412 case kCM_CHECKBUTTON:
415 if (Int_t(gCurrentVolume->GetParam(kShadow))) {
416 gCurrentVolume->SetParam(kShadow, 0.);
418 gCurrentVolume->SetParam(kShadow, 1.);
420 gCurrentVolume->Draw();
423 if (Int_t(gCurrentVolume->GetParam(kHide))) {
424 gCurrentVolume->SetParam(kHide, 0.);
426 gCurrentVolume->SetParam(kHide, 1.);
428 gCurrentVolume->Draw();
431 if (Int_t(gCurrentVolume->GetParam(kClip))) {
432 gCurrentVolume->SetParam(kClip, 0.);
434 gCurrentVolume->SetParam(kClip, 1.);
436 gCurrentVolume->Draw();