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