3 #include "TPCSectorVizEditor.h"
4 #include <Alieve/TPCSectorViz.h>
6 #include <TVirtualPad.h>
11 #include <TGNumberEntry.h>
12 #include <TGColorSelect.h>
14 #include <TGDoubleSlider.h>
17 using namespace Alieve;
19 //______________________________________________________________________
23 ClassImp(TPCSectorVizEditor)
25 TPCSectorVizEditor::TPCSectorVizEditor(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("TPCSectorViz");
33 TGHorizontalFrame* f = new TGHorizontalFrame(this);
34 TGLabel *l = new TGLabel(f, "SectorID:");
35 f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
37 fSectorID = new TGNumberEntry(f, 0., 6, -1,
38 TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
39 TGNumberFormat::kNELLimitMinMax, 0, 35);
41 fSectorID->GetNumberEntry()->SetToolTipText("0-17 +z plate 18-35 -z plate");
42 f->AddFrame(fSectorID, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
43 fSectorID->Associate(this);
44 fSectorID->Connect("ValueSet(Long_t)",
45 "Alieve::TPCSectorVizEditor", this, "DoSectorID()");
47 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
50 TGHorizontalFrame* f = new TGHorizontalFrame(this);
52 fRnrInn = new TGCheckButton(f, "Inner");
53 f->AddFrame(fRnrInn, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
54 fRnrInn->Connect("Toggled(Bool_t)","Alieve::TPCSectorVizEditor", this, "DoRnrInn()");
56 fRnrOut1 = new TGCheckButton(f, "Outer 1");
57 f->AddFrame(fRnrOut1, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
58 fRnrOut1->Connect("Toggled(Bool_t)","Alieve::TPCSectorVizEditor", this, "DoRnrOut1()");
60 fRnrOut2 = new TGCheckButton(f, "Outer 2");
61 f->AddFrame(fRnrOut2, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
62 fRnrOut2->Connect("Toggled(Bool_t)","Alieve::TPCSectorVizEditor", this, "DoRnrOut2()");
64 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
67 TGHorizontalFrame* f = new TGHorizontalFrame(this);
68 fThresholdLabel = new TGLabel(f, "Threshold [XXX]:");
69 f->AddFrame(fThresholdLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
71 fThreshold = new TGHSlider(f, 150);
72 fThreshold->SetRange(0,149);
73 fThreshold->Associate(this);
74 f->AddFrame(fThreshold, new TGLayoutHints(kLHintsLeft, 0, 5));
75 fThreshold->Connect("PositionChanged(Int_t)",
76 "Alieve::TPCSectorVizEditor", this, "DoThreshold()");
77 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
80 TGHorizontalFrame* f = new TGHorizontalFrame(this);
81 fMaxValLabel = new TGLabel(f, "MaxValue [XXX]:");
82 f->AddFrame(fMaxValLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
83 fMaxVal = new TGHSlider(f, 150);
84 fMaxVal->SetRange(0,299);
85 fMaxVal->Associate(this);
86 f->AddFrame(fMaxVal, new TGLayoutHints(kLHintsLeft, 0, 5));
87 fMaxVal->Connect("PositionChanged(Int_t)",
88 "Alieve::TPCSectorVizEditor", this, "DoMaxVal()");
89 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
92 TGVerticalFrame* vf = new TGVerticalFrame(this);
94 TGHorizontalFrame* f = new TGHorizontalFrame(vf);
96 TGLabel *l = new TGLabel(f, "Time Range:");
97 f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
99 fMinTime = new TGNumberEntry(f, 0., 6, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
100 TGNumberFormat::kNELLimitMinMax, 0, 1023);
101 fMinTime->GetNumberEntry()->SetToolTipText("MinTime");
102 f->AddFrame(fMinTime, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
103 fMinTime->Associate(this);
104 fMinTime->Connect("ValueSet(Long_t)", "Alieve::TPCSectorVizEditor", this, "DoMinTime()");
106 fMaxTime = new TGNumberEntry(f, 0., 6, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
107 TGNumberFormat::kNELLimitMinMax, 0, 1023);
108 fMaxTime->GetNumberEntry()->SetToolTipText("MaxTime");
109 f->AddFrame(fMaxTime, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
110 fMaxTime->Associate(this);
111 fMaxTime->Connect("ValueSet(Long_t)", "Alieve::TPCSectorVizEditor", this, "DoMaxTime()");
113 vf->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
115 fTime = new TGDoubleHSlider(vf);
116 fTime->SetRange(0, 1023);
117 fTime->Resize(250, 20);
118 vf->AddFrame(fTime);//, new TGLayoutHints(kLHintsLeft, 0, 5));
119 fTime->Connect("PositionChanged()", "Alieve::TPCSectorVizEditor",
122 AddFrame(vf, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
125 // Register the editor.
126 TClass *cl = TPCSectorViz::Class();
127 TGedElement *ge = new TGedElement;
128 ge->fGedFrame = this;
130 cl->GetEditorList()->Add(ge);
133 TPCSectorVizEditor::~TPCSectorVizEditor()
136 /**************************************************************************/
138 void TPCSectorVizEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t /*event*/)
143 if (!obj || !obj->InheritsFrom(TPCSectorViz::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
151 fM = dynamic_cast<TPCSectorViz*>(fModel);
153 fSectorID->SetNumber(fM->fSectorID);
154 fRnrInn->SetState(fM->fRnrInn ? kButtonDown : kButtonUp);
155 fRnrOut1->SetState(fM->fRnrOut1 ? kButtonDown : kButtonUp);
156 fRnrOut2->SetState(fM->fRnrOut2 ? kButtonDown : kButtonUp);
157 fThresholdLabel->SetText(Form("Threshold [%3d]:", fM->fThreshold));
158 fThreshold->SetPosition(fM->fThreshold);
160 fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
161 fMaxVal->SetPosition(fM->fMaxVal);
162 fMinTime->SetNumber(fM->fMinTime);
163 fMaxTime->SetNumber(fM->fMaxTime);
164 fTime->SetPosition(fM->fMinTime, fM->fMaxTime);
169 /**************************************************************************/
171 void TPCSectorVizEditor::DoSectorID()
173 fM->SetSectorID((Int_t) fSectorID->GetNumber());
177 /**************************************************************************/
179 void TPCSectorVizEditor::DoRnrInn()
181 fM->SetRnrInn(fRnrInn->IsOn());
185 void TPCSectorVizEditor::DoRnrOut1()
187 fM->SetRnrOut1(fRnrOut1->IsOn());
191 void TPCSectorVizEditor::DoRnrOut2()
193 fM->SetRnrOut2(fRnrOut2->IsOn());
197 /**************************************************************************/
199 void TPCSectorVizEditor::DoThreshold()
201 fM->SetThreshold((Short_t) fThreshold->GetPosition());
202 fThresholdLabel->SetText(Form("Threshold [%3d]:", fM->fThreshold));
206 void TPCSectorVizEditor::DoMaxVal()
208 fM->SetMaxVal((Int_t) fMaxVal->GetPosition());
209 fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
213 /**************************************************************************/
215 void TPCSectorVizEditor::DoMinTime()
217 Int_t minTime = (Int_t) fMinTime->GetNumber();
218 if(minTime > fM->fMaxTime) {
219 minTime = fM->fMaxTime;
220 fMinTime->SetNumber(minTime);
222 fM->SetMinTime(minTime);
223 fTime->SetPosition(minTime, fM->fMaxTime);
227 void TPCSectorVizEditor::DoMaxTime()
229 Int_t maxTime = (Int_t) fMaxTime->GetNumber();
230 if(maxTime < fM->fMinTime) {
231 maxTime = fM->fMinTime;
232 fMaxTime->SetNumber(maxTime);
234 fM->SetMaxTime(maxTime);
235 fTime->SetPosition(fM->fMinTime, maxTime);
239 void TPCSectorVizEditor::DoTime()
241 Int_t min = (Int_t) TMath::Nint(fTime->GetMinPosition());
242 Int_t max = (Int_t) TMath::Nint(fTime->GetMaxPosition());
245 fMinTime->SetNumber(min);
246 fMaxTime->SetNumber(max);