Added friend PointSetArrayEditor.
[u/mrichter/AliRoot.git] / EVE / Reve / TrackEditors.cxx
CommitLineData
5a5a1232 1// $Header$
2
3#include "TrackEditors.h"
4#include <Reve/Track.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 <TGDoubleSlider.h>
14
15using namespace Reve;
16
17//______________________________________________________________________
18// TrackListEditor
19//
20
21ClassImp(TrackListEditor)
22
23TrackListEditor::TrackListEditor(const TGWindow *p, Int_t id, Int_t width, Int_t height,
24 UInt_t options, Pixel_t back) :
25 TGedFrame(p, id, width, height, options | kVerticalFrame, back)
26{
27 fTC = 0;
28 MakeTitle("TrackList");
29
30 // --- Limits
31
32 {
33 TGHorizontalFrame* f = new TGHorizontalFrame(this);
34 TGLabel *l = new TGLabel(f, "Max R:");
35 f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 25, 2, 1, 1));
36 fMaxR = new TGNumberEntry(f, 0., 6, -1,
37 TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
38 TGNumberFormat::kNELLimitMinMax, 0.1, 2000.0);
39 fMaxR->GetNumberEntry()->SetToolTipText("Maximum radius to which the tracks will be drawn.");
40 f->AddFrame(fMaxR, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
41 fMaxR->Associate(f);
42 fMaxR->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoMaxR()");
43 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
44 }
45
46 {
47 TGHorizontalFrame* f = new TGHorizontalFrame(this);
48 TGLabel *l = new TGLabel(f, "Max Z:");
49 f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 24, 2, 1, 1));
50 fMaxZ = new TGNumberEntry(f, 0., 6, -1,
51 TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
52 TGNumberFormat::kNELLimitMinMax, 0.1, 2000.0);
53 fMaxZ->GetNumberEntry()->SetToolTipText("Maximum z-coordinate to which the tracks will be drawn.");
54 f->AddFrame(fMaxZ, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
55 fMaxZ->Associate(f);
56 fMaxZ->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoMaxZ()");
57 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
58 }
59
60 {
61 TGHorizontalFrame* f = new TGHorizontalFrame(this);
62 TGLabel *l = new TGLabel(f, "Max Orbits:");
63 f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 0, 2, 1, 1));
64 fMaxOrbits = new TGNumberEntry(f, 0., 6, -1,
65 TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
66 TGNumberFormat::kNELLimitMinMax, 0.1, 100.0);
67 fMaxOrbits->GetNumberEntry()->SetToolTipText("Maximal angular path of tracks' orbits (1 ~ 2Pi).");
68 f->AddFrame(fMaxOrbits, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
69 fMaxOrbits->Associate(f);
70 fMaxOrbits->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoMaxOrbits()");
71 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
72 }
73
74 {
75 TGHorizontalFrame* f = new TGHorizontalFrame(this);
76 TGLabel *l = new TGLabel(f, "Min Angle:");
77 f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 3, 2, 1, 1));
78 fMinAng = new TGNumberEntry(f, 0., 6, -1,
79 TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
80 TGNumberFormat::kNELLimitMinMax, 1, 180.0);
81 fMinAng->GetNumberEntry()->SetToolTipText("Minimal angular step between two helix points.");
82 f->AddFrame(fMinAng, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
83 fMinAng->Associate(f);
84 fMinAng->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoMinAng()");
85 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
86 }
87
88 {
89 TGHorizontalFrame* f = new TGHorizontalFrame(this);
90 TGLabel *l = new TGLabel(f, "Delta:");
91 f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 32, 2, 1, 1));
92 fDelta = new TGNumberEntry(f, 0., 6, -1,
93 TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
94 TGNumberFormat::kNELLimitMinMax, 0.001, 100.0);
95 fDelta->GetNumberEntry()->SetToolTipText("Maximal error at the mid-point of the line connecting to helix points.");
96 f->AddFrame(fDelta, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
97 fDelta->Associate(f);
98 fDelta->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoDelta()");
99 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
100 }
101
102 // --- Rendering control
103
104 fRnrTracks = new TGCheckButton(this, "Render tracks");
105 AddFrame(fRnrTracks, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
106 fRnrTracks->Connect
107 ("Toggled(Bool_t)",
108 "Reve::TrackListEditor", this, "DoRnrTracks()");
109
110 fRnrMarkers = new TGCheckButton(this, "Render markers");
111 AddFrame(fRnrMarkers, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
112 fRnrMarkers->Connect
113 ("Toggled(Bool_t)",
114 "Reve::TrackListEditor", this, "DoRnrMarkers()");
115
116 // --- Kinematics fitting
117
118 fFitDaughters = new TGCheckButton(this, "Fit daughters");
119 AddFrame(fFitDaughters, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
120 fFitDaughters->Connect("Toggled(Bool_t)","Reve::TrackListEditor", this, "DoFitDaughters()");
121
122 fFitDecay = new TGCheckButton(this, "Fit decay");
123 AddFrame(fFitDecay, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
124 fFitDecay->Connect("Toggled(Bool_t)","Reve::TrackListEditor", this, "DoFitDecay()");
125
126 // --- Selectors
127
128 TGDoubleHSlider* hs = new TGDoubleHSlider(this);
129 hs->SetRange(0.1, 10);
130 hs->SetPosition(0.1, 10);
131 hs->Resize(260, 20);
132 AddFrame(hs, new TGLayoutHints(kLHintsLeft, 0, 5));
133 hs->Connect("PositionChanged()", "Reve::TrackListEditor",
134 this, "DoPtScroll()");
135
136
137 // Register the editor.
138 TClass *cl = TrackList::Class();
139 TGedElement *ge = new TGedElement;
140 ge->fGedFrame = this;
141 ge->fCanvas = 0;
142 cl->GetEditorList()->Add(ge);
143}
144
145TrackListEditor::~TrackListEditor()
146{}
147
148/**************************************************************************/
149
150void TrackListEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
151{
152 fModel = 0;
153 fPad = 0;
154
155 if (!obj || !obj->InheritsFrom(TrackList::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
156 SetActive(kFALSE);
157 return;
158 }
159
160 fModel = obj;
161 fPad = pad;
162
163 fTC = dynamic_cast<TrackList*>(fModel);
164
165 fMaxR->SetNumber(fTC->GetMaxR());
166 fMaxZ->SetNumber(fTC->GetMaxZ());
167 fMaxOrbits->SetNumber(fTC->GetMaxOrbs());
168 fMinAng->SetNumber(fTC->GetMinAng());
169 fDelta->SetNumber(fTC->GetDelta());
170
171 fRnrTracks->SetState(fTC->GetRnrTracks() ? kButtonDown : kButtonUp);
172 fRnrMarkers->SetState(fTC->GetRnrMarkers() ? kButtonDown : kButtonUp);
173
174 fFitDaughters->SetState(fTC->GetFitDaughters() ? kButtonDown : kButtonUp);
175 fFitDecay->SetState(fTC->GetFitDecay() ? kButtonDown : kButtonUp);
176
177 SetActive();
178}
179
180/**************************************************************************/
181
182void TrackListEditor::DoMaxR()
183{
184 Double_t maxr = fMaxR->GetNumber();
185 fTC->SetMaxR(maxr);
186 Update();
187}
188
189void TrackListEditor::DoMaxZ()
190{
191 fTC->SetMaxZ(fMaxZ->GetNumber());
192 Update();
193}
194
195void TrackListEditor::DoMaxOrbits()
196{
197 fTC->SetMaxOrbs(fMaxOrbits->GetNumber());
198 Update();
199}
200
201void TrackListEditor::DoMinAng()
202{
203 fTC->SetMinAng(fMinAng->GetNumber());
204 Update();
205}
206
207void TrackListEditor::DoDelta()
208{
209 fTC->SetDelta(fDelta->GetNumber());
210 Update();
211}
212
213/**************************************************************************/
214
215void TrackListEditor::DoRnrTracks()
216{
217 fTC->SetRnrTracks(fRnrTracks->IsOn());
218 Update();
219}
220
221void TrackListEditor::DoRnrMarkers()
222{
223 fTC->SetRnrMarkers(fRnrMarkers->IsOn());
224 Update();
225}
226
227/**************************************************************************/
228
229void TrackListEditor::DoFitDaughters()
230{
231 fTC->SetFitDaughters(fFitDaughters->IsOn());
232 Update();
233}
234
235void TrackListEditor::DoFitDecay()
236{
237 fTC->SetFitDecay(fFitDecay->IsOn());
238 Update();
239}
240
241/**************************************************************************/
242
243void TrackListEditor::DoPtScroll()
244{
245 TGDoubleHSlider* hs = (TGDoubleHSlider*)gTQSender;
246
247 Double_t min = hs->GetMinPosition(), max = hs->GetMaxPosition();
248 printf("Track pt range: min=%f max=%f\n", min, max);
249 fTC->SelectByPt(min, max);
250}