]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/TPCSector2DEditor.cxx
added new class to Makefile
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSector2DEditor.cxx
1 // $Header$
2
3 #include "TPCSector2DEditor.h"
4 #include <Alieve/TPCSector2D.h>
5
6 #include <TVirtualPad.h>
7 #include <TColor.h>
8
9 #include <TGLabel.h>
10 #include <TGButton.h>
11 #include <TGNumberEntry.h>
12 #include <TGColorSelect.h>
13 #include <TGSlider.h>
14 #include <TGDoubleSlider.h>
15
16 using namespace Reve;
17 using namespace Alieve;
18
19 //______________________________________________________________________
20 // TPCSector2DEditor
21 //
22
23 ClassImp(TPCSector2DEditor)
24
25 TPCSector2DEditor::TPCSector2DEditor(const TGWindow *p, Int_t id, Int_t width, Int_t height,
26                                    UInt_t options, Pixel_t back) :
27   TGedFrame(p, id, width, height, options | kVerticalFrame, back)
28 {
29   fM = 0;
30   MakeTitle("TPCSector2D");
31
32   //!!! create the widgets here ...
33
34   // Register the editor.
35   // TClass *cl = TPCSector2D::Class();
36   //  TGedElement *ge = new TGedElement;
37   // ge->fGedFrame = this;
38   //  ge->fCanvas = 0;
39   //  cl->GetEditorList()->Add(ge);
40
41   fUseTexture = new TGCheckButton(this, "UseTexture");
42   AddFrame(fUseTexture, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
43   fUseTexture->Connect
44     ("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoUseTexture()");
45
46   {
47     TGHorizontalFrame* f = new TGHorizontalFrame(this);
48     TGLabel *l = new TGLabel(f, "SectorID:");
49     f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
50
51     fSectorID = new TGNumberEntry(f, 0., 6, -1, 
52                                    TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
53                                    TGNumberFormat::kNELLimitMinMax, 0, 35);
54
55     fSectorID->GetNumberEntry()->SetToolTipText("0-17 +z plate 18-35 -z plate");
56     f->AddFrame(fSectorID, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
57     fSectorID->Associate(this);
58     fSectorID->Connect("ValueSet(Long_t)",
59                         "Alieve::TPCSector2DEditor", this, "DoSectorID()");                 
60
61     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));  
62   }
63   {
64     TGHorizontalFrame* f = new TGHorizontalFrame(this);
65     fThresholdLabel = new TGLabel(f, "threshold [XXX]:");
66     f->AddFrame(fThresholdLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
67
68     fthreshold = new TGHSlider(f, 150);
69     fthreshold->SetRange(0,149);
70     fthreshold->Associate(this);
71     f->AddFrame(fthreshold, new TGLayoutHints(kLHintsLeft, 0, 5));
72     fthreshold->Connect("PositionChanged(Int_t)",
73                        "Alieve::TPCSector2DEditor", this, "Dothreshold()");
74     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
75   }
76   {
77     TGHorizontalFrame* f = new TGHorizontalFrame(this);
78     fMaxValLabel = new TGLabel(f, "MaxValue [XXX]:");
79     f->AddFrame(fMaxValLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
80     fMaxVal = new TGHSlider(f, 150);
81     fMaxVal->SetRange(0,299);
82     fMaxVal->Associate(this);
83     f->AddFrame(fMaxVal, new TGLayoutHints(kLHintsLeft, 0, 5));
84     fMaxVal->Connect("PositionChanged(Int_t)",
85                      "Alieve::TPCSector2DEditor", this, "DoMaxVal()");
86     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
87   }
88   fShowMax = new TGCheckButton(this, "ShowMax");
89   AddFrame(fShowMax, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
90   fShowMax->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoShowMax()");
91
92   {
93     TGHorizontalFrame* f = new TGHorizontalFrame(this);
94     TGLabel *l = new TGLabel(f, "Time Range:");
95     f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
96
97     fTime = new TGDoubleHSlider(f);
98     fTime->SetRange(0, 500);
99     fTime->Resize(160, 20);
100     f->AddFrame(fTime);//, new TGLayoutHints(kLHintsLeft, 0, 5));
101     fTime->Connect("PositionChanged()", "Alieve::TPCSector2DEditor",
102                    this, "DoTime()");
103     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
104   }
105   // What is this crap?
106   TClass *cl = TPCSector2DEditor::Class();
107   TGedElement *ge = new TGedElement;
108   ge->fGedFrame = this;
109   ge->fCanvas = 0;
110   cl->GetEditorList()->Add(ge);
111 }
112
113 TPCSector2DEditor::~TPCSector2DEditor()
114 {}
115
116 /**************************************************************************/
117
118 void TPCSector2DEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
119 {
120   fModel = 0;
121   fPad   = 0;
122
123   if (!obj || !obj->InheritsFrom(TPCSector2D::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
124     SetActive(kFALSE);
125     return;
126   }
127
128   fModel = obj;
129   fPad   = pad;
130
131   fM = dynamic_cast<TPCSector2D*>(fModel);
132
133   fUseTexture->SetState(fM->fUseTexture ? kButtonDown : kButtonUp);
134   fSectorID->SetNumber(fM->fSectorID);
135   fThresholdLabel->SetText(Form("threshold [%3d]:", fM->fthreshold));
136   fthreshold->SetPosition(fM->fthreshold);
137
138   fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
139   fMaxVal->SetPosition(fM->fMaxVal);
140   fTime->SetPosition(fM->fMinTime, fM->fMaxTime);
141
142   fShowMax->SetState(fM->fShowMax ? kButtonDown : kButtonUp);
143
144   SetActive();
145 }
146
147 /**************************************************************************/
148
149 void TPCSector2DEditor::DoUseTexture()
150 {
151   fM->fUseTexture = fUseTexture->IsOn();
152   Update();
153 }
154
155 void TPCSector2DEditor::DoSectorID()
156 {
157   fM->SetSectorID((Int_t) fSectorID->GetNumber());
158   Update();
159 }
160
161 void TPCSector2DEditor::Dothreshold()
162 {
163   fM->Setthreshold((Short_t) fthreshold->GetPosition());
164   fThresholdLabel->SetText(Form("threshold [%3d]:", fM->fthreshold));
165   Update();
166 }
167
168 void TPCSector2DEditor::DoMaxVal()
169 {
170   fM->SetMaxVal((Int_t) fMaxVal->GetPosition());
171   fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
172   Update();
173 }
174
175 void TPCSector2DEditor::DoShowMax()
176 {
177   fM->SetShowMax(fShowMax->IsOn());
178   Update();
179 }
180
181 void TPCSector2DEditor::DoTime()
182
183   Double_t min = fTime->GetMinPosition(), max = fTime->GetMaxPosition();
184   printf("hslidor min=%f max=%f\n", min, max);
185   fM->SetMinTime((Int_t) min);
186   fM->SetMaxTime((Int_t) max);
187   Update();
188 }