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