3 #include "TPCSector2DEditor.h"
4 #include <Alieve/TPCSector2D.h>
6 #include <TVirtualPad.h>
11 #include <TGNumberEntry.h>
12 #include <TGColorSelect.h>
14 #include <TGDoubleSlider.h>
17 using namespace Alieve;
19 //______________________________________________________________________
23 ClassImp(TPCSector2DEditor)
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)
30 MakeTitle("TPCSector2D");
32 //!!! create the widgets here ...
34 // Register the editor.
35 // TClass *cl = TPCSector2D::Class();
36 // TGedElement *ge = new TGedElement;
37 // ge->fGedFrame = this;
39 // cl->GetEditorList()->Add(ge);
41 fUseTexture = new TGCheckButton(this, "UseTexture");
42 AddFrame(fUseTexture, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
44 ("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoUseTexture()");
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));
51 fSectorID = new TGNumberEntry(f, 0., 6, -1,
52 TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
53 TGNumberFormat::kNELLimitMinMax, 0, 35);
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()");
61 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
64 TGHorizontalFrame* f = new TGHorizontalFrame(this);
66 fRnrInn = new TGCheckButton(f, "Inner");
67 f->AddFrame(fRnrInn, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
68 fRnrInn->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoRnrInn()");
70 fRnrOut1 = new TGCheckButton(f, "Outer 1");
71 f->AddFrame(fRnrOut1, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
72 fRnrOut1->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoRnrOut1()");
74 fRnrOut2 = new TGCheckButton(f, "Outer 2");
75 f->AddFrame(fRnrOut2, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
76 fRnrOut2->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoRnrOut2()");
78 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
81 TGHorizontalFrame* f = new TGHorizontalFrame(this);
82 fThresholdLabel = new TGLabel(f, "Threshold [XXX]:");
83 f->AddFrame(fThresholdLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
85 fThreshold = new TGHSlider(f, 150);
86 fThreshold->SetRange(0,149);
87 fThreshold->Associate(this);
88 f->AddFrame(fThreshold, new TGLayoutHints(kLHintsLeft, 0, 5));
89 fThreshold->Connect("PositionChanged(Int_t)",
90 "Alieve::TPCSector2DEditor", this, "DoThreshold()");
91 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
94 TGHorizontalFrame* f = new TGHorizontalFrame(this);
95 fMaxValLabel = new TGLabel(f, "MaxValue [XXX]:");
96 f->AddFrame(fMaxValLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
97 fMaxVal = new TGHSlider(f, 150);
98 fMaxVal->SetRange(0,299);
99 fMaxVal->Associate(this);
100 f->AddFrame(fMaxVal, new TGLayoutHints(kLHintsLeft, 0, 5));
101 fMaxVal->Connect("PositionChanged(Int_t)",
102 "Alieve::TPCSector2DEditor", this, "DoMaxVal()");
103 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
106 TGHorizontalFrame* f = new TGHorizontalFrame(this);
107 fShowMax = new TGCheckButton(f, "ShowMax");
108 f->AddFrame(fShowMax, new TGLayoutHints(kLHintsLeft, 3, 16, 1, 0));
109 fShowMax->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoShowMax()");
110 fAverage = new TGCheckButton(f, "Average");
111 f->AddFrame(fAverage, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
112 fAverage->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoAverage()");
113 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
117 TGVerticalFrame* vf = new TGVerticalFrame(this);
119 TGHorizontalFrame* f = new TGHorizontalFrame(vf);
121 TGLabel *l = new TGLabel(f, "Time Range:");
122 f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
124 fMinTime = new TGNumberEntry(f, 0., 6, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
125 TGNumberFormat::kNELLimitMinMax, 0, 1023);
126 fMinTime->GetNumberEntry()->SetToolTipText("MinTime");
127 f->AddFrame(fMinTime, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
128 fMinTime->Associate(this);
129 fMinTime->Connect("ValueSet(Long_t)", "Alieve::TPCSector2DEditor", this, "DoMinTime()");
131 fMaxTime = new TGNumberEntry(f, 0., 6, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
132 TGNumberFormat::kNELLimitMinMax, 0, 1023);
133 fMaxTime->GetNumberEntry()->SetToolTipText("MaxTime");
134 f->AddFrame(fMaxTime, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
135 fMaxTime->Associate(this);
136 fMaxTime->Connect("ValueSet(Long_t)", "Alieve::TPCSector2DEditor", this, "DoMaxTime()");
138 vf->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
140 fTime = new TGDoubleHSlider(vf);
141 fTime->SetRange(0, 1023);
142 fTime->Resize(250, 20);
143 vf->AddFrame(fTime);//, new TGLayoutHints(kLHintsLeft, 0, 5));
144 fTime->Connect("PositionChanged()", "Alieve::TPCSector2DEditor",
147 AddFrame(vf, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
149 // What is this crap?
150 TClass *cl = TPCSector2DEditor::Class();
151 TGedElement *ge = new TGedElement;
152 ge->fGedFrame = this;
154 cl->GetEditorList()->Add(ge);
157 TPCSector2DEditor::~TPCSector2DEditor()
160 /**************************************************************************/
162 void TPCSector2DEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
167 if (!obj || !obj->InheritsFrom(TPCSector2D::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
175 fM = dynamic_cast<TPCSector2D*>(fModel);
177 fUseTexture->SetState(fM->fUseTexture ? kButtonDown : kButtonUp);
178 fSectorID->SetNumber(fM->fSectorID);
179 fRnrInn->SetState(fM->fRnrInn ? kButtonDown : kButtonUp);
180 fRnrOut1->SetState(fM->fRnrOut1 ? kButtonDown : kButtonUp);
181 fRnrOut2->SetState(fM->fRnrOut2 ? kButtonDown : kButtonUp);
182 fThresholdLabel->SetText(Form("Threshold [%3d]:", fM->fThreshold));
183 fThreshold->SetPosition(fM->fThreshold);
185 fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
186 fMaxVal->SetPosition(fM->fMaxVal);
187 fMinTime->SetNumber(fM->fMinTime);
188 fMaxTime->SetNumber(fM->fMaxTime);
189 fTime->SetPosition(fM->fMinTime, fM->fMaxTime);
191 fShowMax->SetState(fM->fShowMax ? kButtonDown : kButtonUp);
197 /**************************************************************************/
199 void TPCSector2DEditor::DoUseTexture()
201 fM->fUseTexture = fUseTexture->IsOn();
205 void TPCSector2DEditor::DoSectorID()
207 fM->SetSectorID((Int_t) fSectorID->GetNumber());
211 void TPCSector2DEditor::DoRnrInn()
213 fM->SetRnrInn(fRnrInn->IsOn());
217 void TPCSector2DEditor::DoRnrOut1()
219 fM->SetRnrOut1(fRnrOut1->IsOn());
223 void TPCSector2DEditor::DoRnrOut2()
225 fM->SetRnrOut2(fRnrOut2->IsOn());
230 void TPCSector2DEditor::DoThreshold()
232 fM->SetThreshold((Short_t) fThreshold->GetPosition());
233 fThresholdLabel->SetText(Form("Threshold [%3d]:", fM->fThreshold));
237 void TPCSector2DEditor::DoMaxVal()
239 fM->SetMaxVal((Int_t) fMaxVal->GetPosition());
240 fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
244 void TPCSector2DEditor::DoShowMax()
246 fM->SetShowMax(fShowMax->IsOn());
251 void TPCSector2DEditor::DoAverage()
253 fM->SetAverage(fAverage->IsOn());
257 void TPCSector2DEditor::SetupAverage()
260 fAverage->SetEnabled(kFALSE);
262 fAverage->SetEnabled(kTRUE);
263 fAverage->SetState(fM->fAverage ? kButtonDown : kButtonUp);
267 void TPCSector2DEditor::DoMinTime()
269 Int_t minTime = (Int_t) fMinTime->GetNumber();
270 if(minTime > fM->fMaxTime) {
271 minTime = fM->fMaxTime;
272 fMinTime->SetNumber(minTime);
274 fM->SetMinTime(minTime);
275 fTime->SetPosition(minTime, fM->fMaxTime);
279 void TPCSector2DEditor::DoMaxTime()
281 Int_t maxTime = (Int_t) fMaxTime->GetNumber();
282 if(maxTime < fM->fMinTime) {
283 maxTime = fM->fMinTime;
284 fMaxTime->SetNumber(maxTime);
286 fM->SetMaxTime(maxTime);
287 fTime->SetPosition(fM->fMinTime, maxTime);
291 void TPCSector2DEditor::DoTime()
293 Int_t min = (Int_t) TMath::Nint(fTime->GetMinPosition());
294 Int_t max = (Int_t) TMath::Nint(fTime->GetMaxPosition());
297 fMinTime->SetNumber(min);
298 fMaxTime->SetNumber(max);