17 inline Float_t sqr(Float_t x) {
return x*x; }
27 Bool_t TEveLine::fgDefaultSmooth = kFALSE;
32 TEveLine::TEveLine(Int_t n_points, ETreeVarType_e tv_type) :
33 TEvePointSet(
"Line", n_points, tv_type),
36 fSmooth (fgDefaultSmooth)
38 fMainColorPtr = &fLineColor;
39 fMarkerColor = kGreen;
45 TEveLine::TEveLine(
const char* name, Int_t n_points, ETreeVarType_e tv_type) :
46 TEvePointSet(name, n_points, tv_type),
49 fSmooth (fgDefaultSmooth)
51 fMainColorPtr = &fLineColor;
52 fMarkerColor = kGreen;
58 const TGPicture* TEveLine::GetListTreeIcon(Bool_t)
60 return fgListTreeIcons[8];
66 void TEveLine::SetMarkerColor(Color_t col)
68 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
69 while (pi != fProjectedList.end())
71 TEveLine* l =
dynamic_cast<TEveLine*
>(*pi);
72 if (l && fMarkerColor == l->GetMarkerColor())
74 l->SetMarkerColor(col);
79 TAttMarker::SetMarkerColor(col);
86 void TEveLine::SetLineStyle(Style_t lstyle)
88 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
89 while (pi != fProjectedList.end())
91 TEveLine* pt =
dynamic_cast<TEveLine*
>(*pi);
94 pt->SetLineStyle(lstyle);
99 TAttLine::SetLineStyle(lstyle);
106 void TEveLine::SetLineWidth(Width_t lwidth)
108 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
109 while (pi != fProjectedList.end())
111 TEveLine* pt =
dynamic_cast<TEveLine*
>(*pi);
114 pt->SetLineWidth(lwidth);
119 TAttLine::SetLineWidth(lwidth);
125 void TEveLine::SetRnrLine(Bool_t r)
128 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
129 while (pi != fProjectedList.end())
131 TEveLine* l =
dynamic_cast<TEveLine*
>(*pi);
144 void TEveLine::SetRnrPoints(Bool_t r)
147 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
148 while (pi != fProjectedList.end())
150 TEveLine* l =
dynamic_cast<TEveLine*
>(*pi);
163 void TEveLine::SetSmooth(Bool_t r)
166 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
167 while (pi != fProjectedList.end())
169 TEveLine* l =
dynamic_cast<TEveLine*
>(*pi);
183 void TEveLine::ReduceSegmentLengths(Float_t max)
185 const Float_t max2 = max*max;
191 std::vector<TEveVector> q;
195 for (Int_t i = 1; i < s; ++i)
197 a = b; b.Set(&p[3*i]); d = b - a;
198 Float_t m2 = d.Mag2();
201 Float_t f = TMath::Sqrt(m2) / max;
202 Int_t n = TMath::FloorNint(f);
204 for (Int_t j = 0; j < n; ++j)
215 for (std::vector<TEveVector>::iterator i = q.begin(); i != q.end(); ++i)
216 SetNextPoint(i->fX, i->fY, i->fZ);
222 Float_t TEveLine::CalculateLineLength()
const
228 for (Int_t i = 1; i < s; ++i, p += 3)
230 sum += TMath::Sqrt(sqr(p[3] - p[0]) + sqr(p[4] - p[1]) + sqr(p[5] - p[2]));
239 TEveVector TEveLine::GetLineStart()
const
242 GetPoint(0, v.fX, v.fY, v.fZ);
250 TEveVector TEveLine::GetLineEnd()
const
253 GetPoint(fLastPoint, v.fX, v.fY, v.fZ);
260 void TEveLine::CopyVizParams(
const TEveElement* el)
262 const TEveLine* m =
dynamic_cast<const TEveLine*
>(el);
265 TAttLine::operator=(*m);
266 fRnrLine = m->fRnrLine;
267 fRnrPoints = m->fRnrPoints;
268 fSmooth = m->fSmooth;
271 TEvePointSet::CopyVizParams(el);
277 void TEveLine::WriteVizParams(std::ostream& out,
const TString& var)
279 TEvePointSet::WriteVizParams(out, var);
281 TString t =
" " + var +
"->";
282 TAttLine::SaveLineAttributes(out, var);
283 out << t <<
"SetRnrLine(" << ToString(fRnrLine) <<
");\n";
284 out << t <<
"SetRnrPoints(" << ToString(fRnrPoints) <<
");\n";
285 out << t <<
"SetSmooth(" << ToString(fSmooth) <<
");\n";
291 TClass* TEveLine::ProjectedClass(
const TEveProjection*)
const
293 return TEveLineProjected::Class();
300 Bool_t TEveLine::GetDefaultSmooth()
302 return fgDefaultSmooth;
309 void TEveLine::SetDefaultSmooth(Bool_t r)
319 ClassImp(TEveLineProjected);
324 TEveLineProjected::TEveLineProjected() :
334 void TEveLineProjected::SetProjection(TEveProjectionManager* mng,
335 TEveProjectable* model)
337 TEveProjected::SetProjection(mng, model);
338 CopyVizParams(dynamic_cast<TEveElement*>(model));
344 void TEveLineProjected::SetDepthLocal(Float_t d)
346 SetDepthCommon(d,
this, fBBox);
349 Float_t *p = GetP() + 2;
350 for (Int_t i = 0; i < n; ++i, p+=3)
358 void TEveLineProjected::UpdateProjection()
360 TEveProjection& proj = * fManager->GetProjection();
361 TEveLine & als = *
dynamic_cast<TEveLine*
>(fProjectable);
362 TEveTrans *tr = als.PtrMainTrans(kFALSE);
364 Int_t n = als.Size();
367 Float_t *o = als.GetP(), *p = GetP();
368 for (Int_t i = 0; i < n; ++i, o+=3, p+=3)
370 proj.ProjectPointfv(tr, o, p, fDepth);