]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant3/AliGuiGeomDialog.cxx
Removal of useless dependencies via forward declarations
[u/mrichter/AliRoot.git] / TGeant3 / AliGuiGeomDialog.cxx
CommitLineData
ef42d733 1/* *************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
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 **************************************************************************/
15
16/*
17$Log$
18Revision 1.8 2000/07/12 08:56:32 fca
19Coding convention correction and warning removal
20
21Revision 1.7 2000/06/28 21:27:45 morsch
22Most coding rule violations corrected.
23Still to do: Split the file (on file per class) ? Avoid the global variables.
24Copy constructors and assignment operators (dummy ?)
25
26Revision 1.6 2000/04/14 11:07:46 morsch
27Correct volume to medium assignment in case several media are asigned to the
28same material.
29
30Revision 1.5 2000/03/20 15:11:03 fca
31Mods to make the code compile on HP
32
33Revision 1.4 2000/01/18 16:12:08 morsch
34Bug in calculation of number of volume divisions and number of positionings corrected
35Browser for Material and Media properties added
36
37Revision 1.3 1999/11/14 14:31:14 fca
38Correct small error and remove compilation warnings on HP
39
40Revision 1.2 1999/11/10 16:53:35 fca
41The new geometry viewer from A.Morsch
42
43*/
44
45#include "TGButton.h"
46#include "TGTab.h"
47#include "TGComboBox.h"
48#include "TGDoubleSlider.h"
49
50#include "AliGuiGeomDialog.h"
51#include "AliGUISliders.h"
52#include "AliDrawVolume.h"
53
54AliGuiGeomDialog::AliGuiGeomDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
55 UInt_t h, UInt_t options)
56 : TGTransientFrame(p, main, w, h, options)
57{
58 // Create a dialog window. A dialog window pops up with respect to its
59 // "main" window.
60
61 fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
62
63 fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
64 fOkButton->Associate(this);
65 fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
66 fCancelButton->Associate(this);
67
68 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
69 2, 2, 2, 2);
70 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
71
72 fFrame1->AddFrame(fOkButton, fL1);
73 fFrame1->AddFrame(fCancelButton, fL1);
74
75 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
76 AddFrame(fFrame1, fL2);
77
78 //--------- create Tab widget and some composite frames for Tab testing
79
80 fTab = new TGTab(this, 300, 300);
81 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
82//
83// Tab1: Sliders
84//
85 TGCompositeFrame *tf = fTab->AddTab("Draw");
86 fF1 = new AliGUISliders(tf, this, 60, 20);
87 tf->AddFrame(fF1,fL3);
88
89//
90// Tab2: Drawing Options
91//
92 tf = fTab->AddTab("Options");
93 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
94 200, 2, 2, 2);
95 fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
96
97 fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "Shadow", 86), fL3);
98 fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Hide ", 87), fL3);
99 fF2->AddFrame(fChk3 = new TGCheckButton(fF2, "Clip ", 88), fL3);
100
101 fF2->AddFrame(fLabel1 = new TGLabel(fF2, "Fill"),fL3);
102
103 fCombo = new TGComboBox(fF2, 89);
104 fF2->AddFrame(fCombo, fL3);
105
106 tf->AddFrame(fF2, fL3);
107
108 int i;
109 for (i = 0; i < 8; i++) {
110 char tmp[20];
111
112 sprintf(tmp, "%i", i+1);
113 fCombo->AddEntry(tmp, i+1);
114 }
115 fCombo->Select(1);
116 fCombo->Resize(50, 20);
117 fCombo->Associate(this);
118
119 fChk1->Associate(this);
120 fChk2->Associate(this);
121 fChk3->Associate(this);
122//
123// Tab3: Seen Option
124//
125 tf = fTab->AddTab("Seen");
126 fF3 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
127 fF3->AddFrame(fLabel2 = new TGLabel(fF3, "Seen"),fL3);
128 fCombo2 = new TGComboBox(fF3, 90);
129 fF3->AddFrame(fCombo2, fL3);
130 tf->AddFrame(fF3, fL3);
131
132 for (i = 0; i < 4; i++) {
133 char tmp[20];
134
135 sprintf(tmp, "%i", i-2);
136 fCombo2->AddEntry(tmp, i+1);
137 }
138 fCombo2->Select(4);
139 fCombo2->Resize(50, 20);
140 fCombo2->Associate(this);
141//
142// Tab4: Clip Box
143//
144 tf = fTab->AddTab("ClipBox");
145 //--- layout for buttons: top align, equally expand horizontally
146 fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
147
148 //--- layout for the frame: place at bottom, right aligned
149 fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
150//
151// Frames
152//
153// Slider1
154 fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
155
156 fHSframe1 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
157
158 fTbh11 = new TGTextBuffer(10);
159 fTeh11 = new TGTextEntry(fHSframe1, fTbh11,1);
160 fTbh11->AddText(0, " 0");
161 fTeh11->Associate(this);
162
163 fTbh12 = new TGTextBuffer(10);
164 fTeh12 = new TGTextEntry(fHSframe1, fTbh12,1);
165 fTbh12->AddText(0, "2000");
166 fTeh12->Associate(this);
167
168 fDslider1 = new TGDoubleHSlider(fHSframe1, 400, kSlider1 | kScaleBoth, 1);
169 fDslider1->Associate(this);
170 fDslider1->SetRange(-2000, 2000);
171 fDslider1->SetPosition(0, 2000);
172
173 fSLabel1 = new TGLabel(fHSframe1, "xmin-xmax");
174
175 fHSframe1->AddFrame(fSLabel1, fBfly1);
176 fHSframe1->AddFrame(fTeh11, fBfly1);
177 fHSframe1->AddFrame(fTeh12, fBfly1);
178 fHSframe1->AddFrame(fDslider1, fBfly1);
179
180 fF4->AddFrame(fHSframe1, fBly);
181
182//
183 fHSframe2 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
184
185 fTbh21 = new TGTextBuffer(10);
186 fTeh21 = new TGTextEntry(fHSframe2, fTbh21,1);
187 fTbh21->AddText(0, " 0");
188 fTeh21->Associate(this);
189
190 fTbh22 = new TGTextBuffer(10);
191 fTeh22 = new TGTextEntry(fHSframe2, fTbh22,1);
192 fTbh22->AddText(0, "2000");
193 fTeh22->Associate(this);
194
195 fDslider2 = new TGDoubleHSlider(fHSframe2, 400, kSlider1 | kScaleBoth, 2);
196 fDslider2->Associate(this);
197 fDslider2->SetRange(-2000, 2000);
198 fDslider2->SetPosition(0, 2000);
199
200 fSLabel2 = new TGLabel(fHSframe2, "ymin-ymax");
201
202 fHSframe2->AddFrame(fSLabel2, fBfly1);
203 fHSframe2->AddFrame(fTeh21, fBfly1);
204 fHSframe2->AddFrame(fTeh22, fBfly1);
205 fHSframe2->AddFrame(fDslider2, fBfly1);
206
207 fF4->AddFrame(fHSframe2, fBly);
208
209//
210 fHSframe3 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
211
212 fTbh31 = new TGTextBuffer(10);
213 fTeh31 = new TGTextEntry(fHSframe3, fTbh31,1);
214 fTbh31->AddText(0, " 0");
215 fTeh31->Associate(this);
216
217 fTbh32 = new TGTextBuffer(10);
218 fTeh32 = new TGTextEntry(fHSframe3, fTbh32,1);
219 fTbh32->AddText(0, "2000");
220 fTeh32->Associate(this);
221
222 fDslider3 = new TGDoubleHSlider(fHSframe3, 400, kSlider1 | kScaleBoth, 3);
223 fDslider3->Associate(this);
224 fDslider3->SetRange(-2000, 2000);
225 fDslider3->SetPosition(0, 2000);
226
227 fSLabel3 = new TGLabel(fHSframe3, "zmin-zmax");
228
229 fHSframe3->AddFrame(fSLabel3, fBfly1);
230 fHSframe3->AddFrame(fTeh31, fBfly1);
231 fHSframe3->AddFrame(fTeh32, fBfly1);
232 fHSframe3->AddFrame(fDslider3, fBfly1);
233
234 fF4->AddFrame(fHSframe3, fBly);
235 tf->AddFrame(fF4, fL3);
236//
237//
238 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
239 kLHintsExpandY, 2, 2, 5, 1);
240 AddFrame(fTab, fL5);
241
242 MapSubwindows();
243 Resize(GetDefaultSize());
244
245 // position relative to the parent's window
246 Window_t wdum;
247 int ax, ay;
248 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
249 (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
250 (((TGFrame *) main)->GetHeight() - fHeight) >> 1,
251 ax, ay, wdum);
252 Move(ax, ay);
253
254 SetWindowName("Dialog");
255
256 MapWindow();
257 //gClient->WaitFor(this); // otherwise canvas contextmenu does not work
258}
259
260AliGuiGeomDialog::~AliGuiGeomDialog()
261{
262 // Delete test dialog widgets.
263
264 delete fOkButton;
265 delete fCancelButton;
266 delete fFrame1;
267 delete fChk1; delete fChk2;
268 delete fF1; delete fF2; delete fF3; delete fF4;
269 delete fCombo;
270 delete fTab;
271 delete fL3; delete fL4;
272 delete fL1; delete fL2;
273 delete fBly; delete fBfly1;
274 delete fTbh11; delete fTbh12; delete fTbh21; delete fTbh22;
275 delete fTbh31; delete fTbh32; delete fTeh11; delete fTeh12;
276 delete fTeh21; delete fTeh22; delete fTeh31; delete fTeh32;
277 delete fDslider1; delete fDslider2; delete fDslider3;
278 delete fSLabel1; delete fSLabel2; delete fSLabel3;
279}
280
281void AliGuiGeomDialog::Update()
282{
283// Update widgets
284
285 Float_t param;
286// Update Sliders
287 if (fF1) {
288 fF1->Update();
289 }
290// Seen
291 if (fCombo2) {
292 param=gCurrentVolume->GetParam(kSeen);
293 fCombo2->Select(Int_t(param)+3);
294 }
295// Hide, Shadow, Clip
296 if (fChk1) {
297 if (Int_t(gCurrentVolume->GetParam(kShadow))) {
298 fChk1->SetState(kButtonDown);
299 } else {
300 fChk1->SetState(kButtonUp);
301 }
302 }
303
304 if (fChk2) {
305 if (Int_t(gCurrentVolume->GetParam(kHide))) {
306 fChk2->SetState(kButtonDown);
307 } else {
308 fChk2->SetState(kButtonUp);
309 }
310 }
311
312 if (fChk3) {
313 if (Int_t(gCurrentVolume->GetParam(kClip))) {
314 fChk3->SetState(kButtonDown);
315 } else {
316 fChk3->SetState(kButtonUp);
317 }
318 }
319
320}
321
322void AliGuiGeomDialog::CloseWindow()
323{
324 // Called when window is closed via the window manager.
325 delete this;
326}
327
328Bool_t AliGuiGeomDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
329{
330 // Process messages coming from widgets associated with the dialog.
331 char buf[10];
332 Float_t min,max;
333 switch (GET_MSG(msg)) {
334 case kC_HSLIDER:
335 switch (GET_SUBMSG(msg)) {
336 case kSL_POS:
337 switch (Int_t(parm1)) {
338 case 1:
339 min=fDslider1->GetMinPosition();
340 max=fDslider1->GetMaxPosition();
341 sprintf(buf, "%6.2f", min);
342 fTbh11->Clear();
343 fTbh11->AddText(0, buf);
344 sprintf(buf, "%6.2f", max);
345 fTbh12->Clear();
346 fTbh12->AddText(0, buf);
347 gClient->NeedRedraw(fTeh11);
348 gClient->NeedRedraw(fTeh12);
349 gCurrentVolume->SetParam(kClipXmin,min);
350 gCurrentVolume->SetParam(kClipXmax,max);
351 break;
352 case 2:
353 min=fDslider2->GetMinPosition();
354 max=fDslider2->GetMaxPosition();
355 sprintf(buf, "%6.2f", min);
356 fTbh21->Clear();
357 fTbh21->AddText(0, buf);
358 sprintf(buf, "%6.2f", max);
359 fTbh22->Clear();
360 fTbh22->AddText(0, buf);
361 gClient->NeedRedraw(fTeh21);
362 gClient->NeedRedraw(fTeh22);
363 gCurrentVolume->SetParam(kClipYmin,min);
364 gCurrentVolume->SetParam(kClipYmax,max);
365 break;
366 case 3:
367 min=fDslider3->GetMinPosition();
368 max=fDslider3->GetMaxPosition();
369 sprintf(buf, "%6.2f", min);
370 fTbh31->Clear();
371 fTbh31->AddText(0, buf);
372 sprintf(buf, "%6.2f", max);
373 fTbh32->Clear();
374 fTbh32->AddText(0, buf);
375 gClient->NeedRedraw(fTeh31);
376 gClient->NeedRedraw(fTeh32);
377 gCurrentVolume->SetParam(kClipZmin,min);
378 gCurrentVolume->SetParam(kClipZmax,max);
379 break;
380 default:
381 break;
382 }
383 }
384 break;
385 case kC_COMMAND:
386 switch (GET_SUBMSG(msg)) {
387 case kCM_BUTTON:
388 switch(parm1) {
389 case 1:
390 case 2:
391 printf("\nTerminating dialog: %s pressed\n",
392 (parm1 == 1) ? "OK" : "Cancel");
393 CloseWindow();
394 break;
395 }
396 break;
397 case kCM_COMBOBOX:
398 switch(parm1) {
399 case 89:
400 gCurrentVolume->SetParam(kFill, Float_t(parm2));
401 gCurrentVolume->Draw();
402 break;
403 case 90:
404 gCurrentVolume->SetParam(kSeen, Float_t(parm2-3));
405 gCurrentVolume->Draw();
406 break;
407 }
408 break;
409 case kCM_CHECKBUTTON:
410 switch (parm1) {
411 case 86:
412 if (Int_t(gCurrentVolume->GetParam(kShadow))) {
413 gCurrentVolume->SetParam(kShadow, 0.);
414 } else {
415 gCurrentVolume->SetParam(kShadow, 1.);
416 }
417 gCurrentVolume->Draw();
418 break;
419 case 87:
420 if (Int_t(gCurrentVolume->GetParam(kHide))) {
421 gCurrentVolume->SetParam(kHide, 0.);
422 } else {
423 gCurrentVolume->SetParam(kHide, 1.);
424 }
425 gCurrentVolume->Draw();
426 break;
427 case 88:
428 if (Int_t(gCurrentVolume->GetParam(kClip))) {
429 gCurrentVolume->SetParam(kClip, 0.);
430 } else {
431 gCurrentVolume->SetParam(kClip, 1.);
432 }
433 gCurrentVolume->Draw();
434 break;
435
436 default:
437 break;
438 }
439 break;
440 case kCM_TAB:
441 break;
442 default:
443 break;
444 }
445 break;
446 default:
447 break;
448 }
449 return kTRUE;
450}
451