]>
Commit | Line | Data |
---|---|---|
a524cc6b | 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$ | |
18 | Revision 1.2 2001/07/09 11:48:47 morsch | |
19 | Use AliG3Volume, AliG3Medium, AliG3Material | |
20 | ||
21 | Revision 1.1 2000/07/13 16:19:10 fca | |
22 | Mainly coding conventions + some small bug fixes | |
23 | ||
24 | Revision 1.8 2000/07/12 08:56:32 fca | |
25 | Coding convention correction and warning removal | |
26 | ||
27 | Revision 1.7 2000/06/28 21:27:45 morsch | |
28 | Most coding rule violations corrected. | |
29 | Still to do: Split the file (on file per class) ? Avoid the global variables. | |
30 | Copy constructors and assignment operators (dummy ?) | |
31 | ||
32 | Revision 1.6 2000/04/14 11:07:46 morsch | |
33 | Correct volume to medium assignment in case several media are asigned to the | |
34 | same material. | |
35 | ||
36 | Revision 1.5 2000/03/20 15:11:03 fca | |
37 | Mods to make the code compile on HP | |
38 | ||
39 | Revision 1.4 2000/01/18 16:12:08 morsch | |
40 | Bug in calculation of number of volume divisions and number of positionings corrected | |
41 | Browser for Material and Media properties added | |
42 | ||
43 | Revision 1.3 1999/11/14 14:31:14 fca | |
44 | Correct small error and remove compilation warnings on HP | |
45 | ||
46 | Revision 1.2 1999/11/10 16:53:35 fca | |
47 | The new geometry viewer from A.Morsch | |
48 | ||
49 | */ | |
50 | ||
51 | #include <stdlib.h> | |
52 | ||
53 | #include "AliGUISliders.h" | |
54 | #include "AliG3Volume.h" | |
55 | ||
56 | static Text_t* kLabelText[7] = | |
57 | {"Theta ", "Phi ", "Psi ", "U ", "V ", "UScale", "VScale"}; | |
58 | static Int_t IRangeMin[7] = { 0, 0, 0, 0, 0, 0, 0}; | |
59 | static Int_t IRangeMax[7] = {36000, 36000, 36000, 2000, 2000, 10, 10}; | |
60 | static Int_t DefaultPos[7] = { 3000, 4000, 0, 1000, 1000, 1, 1}; | |
61 | ||
62 | AliGUISliders::AliGUISliders(const TGWindow *p, const TGWindow *, | |
63 | UInt_t w, UInt_t h) : | |
64 | TGCompositeFrame(p, w, h,kVerticalFrame) | |
65 | { | |
66 | // Constructor | |
67 | ChangeOptions((GetOptions() & ~kHorizontalFrame) | kVerticalFrame); | |
68 | //--- layout for buttons: top align, equally expand horizontally | |
69 | fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5); | |
70 | ||
71 | //--- layout for the frame: place at bottom, right aligned | |
72 | fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX ); | |
73 | // | |
74 | // Frames | |
75 | ||
76 | for (Int_t i=0; i<7; i++) { | |
77 | Int_t idT=i+1; | |
78 | Int_t idS=i+8; | |
79 | fHframe[i] = new TGHorizontalFrame(this, 400, 100, kFixedWidth); | |
80 | fTbh[i] = new TGTextBuffer(10); | |
81 | fTeh[i] = new TGTextEntry(fHframe[i], fTbh[i],idT); | |
82 | char buf[10]; | |
83 | sprintf(buf, "%6.2f", Float_t(DefaultPos[i])/100); | |
84 | fTbh[i]->AddText(0, buf); | |
85 | fTeh[i]->Associate(this); | |
86 | ||
87 | fHslider[i] = new TGHSlider(fHframe[i], 400, kSlider1 | kScaleBoth, idS); | |
88 | fHslider[i]->Associate(this); | |
89 | fHslider[i]->SetRange(IRangeMin[i], IRangeMax[i]); | |
90 | fHslider[i]->SetPosition(DefaultPos[i]); | |
91 | ||
92 | fLabel[i] = new TGLabel(fHframe[i], kLabelText[i]); | |
93 | ||
94 | ||
95 | fHframe[i]->AddFrame(fLabel[i], fBfly1); | |
96 | fHframe[i]->AddFrame(fTeh[i], fBfly1); | |
97 | fHframe[i]->AddFrame(fHslider[i], fBfly1); | |
98 | AddFrame(fHframe[i], fBly); | |
99 | } | |
100 | } | |
101 | ||
102 | AliGUISliders::~AliGUISliders() | |
103 | { | |
104 | // Destructor | |
105 | delete fBfly1; delete fBly; | |
106 | // Delete dialog. | |
107 | for (Int_t i=1; i<7; i++) { | |
108 | delete fHframe[i]; | |
109 | delete fHslider[i]; | |
110 | delete fTeh[i]; | |
111 | delete fTbh[i]; | |
112 | } | |
113 | } | |
114 | ||
115 | void AliGUISliders::Update() | |
116 | { | |
117 | // Update sliders | |
118 | char buf[10]; | |
119 | ||
120 | for (Int_t i=0; i<7; i++) { | |
121 | Float_t param = gCurrentVolume->GetParam(i); | |
122 | // | |
123 | fHslider[i]->SetPosition(Int_t(param*100.)); | |
124 | gClient->NeedRedraw(fHslider[i]); | |
125 | // | |
126 | sprintf(buf, "%6.2f", param); | |
127 | fTbh[i]->Clear(); | |
128 | fTbh[i]->AddText(0, buf); | |
129 | gClient->NeedRedraw(fTeh[i]); | |
130 | // | |
131 | } | |
132 | ||
133 | ||
134 | } | |
135 | ||
136 | void AliGUISliders::CloseWindow() | |
137 | { | |
138 | // Called when window is closed via the window manager. | |
139 | ||
140 | delete this; | |
141 | } | |
142 | ||
143 | Bool_t AliGUISliders::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) | |
144 | { | |
145 | // Process slider messages. | |
146 | ||
147 | char buf[10]; | |
148 | ||
149 | switch (GET_MSG(msg)) { | |
150 | case kC_TEXTENTRY: | |
151 | switch (GET_SUBMSG(msg)) { | |
152 | case kTE_TEXTCHANGED: | |
153 | Int_t idT=Int_t(parm1)-1; | |
154 | fHslider[idT]->SetPosition((Int_t)atof(fTbh[idT]->GetString())*100); | |
155 | gClient->NeedRedraw(fHslider[idT]); | |
156 | gCurrentVolume->SetParam(idT,atof(fTbh[idT]->GetString())); | |
157 | gCurrentVolume->Draw(); | |
158 | } | |
159 | break; | |
160 | case kC_HSLIDER: | |
161 | switch (GET_SUBMSG(msg)) { | |
162 | case kSL_POS: | |
163 | sprintf(buf, "%6.2f", Float_t(parm2)/100); | |
164 | Int_t idS=Int_t(parm1)-8; | |
165 | fTbh[idS]->Clear(); | |
166 | fTbh[idS]->AddText(0, buf); | |
167 | gClient->NeedRedraw(fTeh[idS]); | |
168 | gCurrentVolume->SetParam(idS, Float_t(parm2)/100.); | |
169 | gCurrentVolume->Draw(); | |
170 | } | |
171 | break; | |
172 | } | |
173 | return kTRUE; | |
174 | } | |
175 |