41 ClassImp(TEvePointSet);
46 TEvePointSet::TEvePointSet(Int_t n_points, ETreeVarType_e tv_type) :
48 TPointSet3D(n_points),
49 TEvePointSelectorConsumer(tv_type),
58 SetMainColorPtr(&fMarkerColor);
67 TEvePointSet::TEvePointSet(
const char* name, Int_t n_points, ETreeVarType_e tv_type) :
69 TPointSet3D(n_points),
70 TEvePointSelectorConsumer(tv_type),
80 SetMainColorPtr(&fMarkerColor);
89 TEvePointSet::TEvePointSet(
const TEvePointSet& e) :
92 TEvePointSelectorConsumer(e),
97 fIntIds (e.fIntIds ? new TArrayI(*e.fIntIds) : 0),
98 fIntIdsPerPoint (e.fIntIdsPerPoint)
105 TEvePointSet::~TEvePointSet()
113 void TEvePointSet::ClonePoints(
const TEvePointSet& e)
120 const Int_t nn = 3 * e.fN;
121 fP =
new Float_t [nn];
122 for (Int_t i = 0; i < nn; i++) fP[i] = e.fP[i];
126 fLastPoint = e.fLastPoint;
133 fIntIds = e.fIntIds ?
new TArrayI(*e.fIntIds) : 0;
134 fIntIdsPerPoint = e.fIntIdsPerPoint;
140 const TGPicture* TEvePointSet::GetListTreeIcon(Bool_t)
142 return TEveElement::fgListTreeIcons[3];
150 void TEvePointSet::Reset(Int_t n_points, Int_t n_int_ids)
152 delete [] fP; fP = 0;
155 fP =
new Float_t [3*fN];
156 memset(fP, 0, 3*fN*
sizeof(Float_t));
160 delete fIntIds; fIntIds = 0;
161 fIntIdsPerPoint = n_int_ids;
162 if (fIntIdsPerPoint > 0) fIntIds =
new TArrayI(fIntIdsPerPoint*fN);
172 Int_t TEvePointSet::GrowFor(Int_t n_points)
174 Int_t old_size = Size();
175 Int_t new_size = old_size + n_points;
176 SetPoint(new_size - 1, 0, 0, 0);
178 fIntIds->Set(fIntIdsPerPoint * new_size);
186 inline void TEvePointSet::AssertIntIdsSize()
188 Int_t exp_size = GetN()*fIntIdsPerPoint;
189 if (fIntIds->GetSize() < exp_size)
190 fIntIds->Set(exp_size);
199 Int_t* TEvePointSet::GetPointIntIds(Int_t p)
const
202 return fIntIds->GetArray() + p*fIntIdsPerPoint;
212 Int_t TEvePointSet::GetPointIntId(Int_t p, Int_t i)
const
215 return * (fIntIds->GetArray() + p*fIntIdsPerPoint + i);
223 void TEvePointSet::SetPointIntIds(Int_t* ids)
225 SetPointIntIds(fLastPoint, ids);
231 void TEvePointSet::SetPointIntIds(Int_t n, Int_t* ids)
233 if (!fIntIds)
return;
235 Int_t* x = fIntIds->GetArray() + n*fIntIdsPerPoint;
236 for (Int_t i=0; i<fIntIdsPerPoint; ++i)
243 void TEvePointSet::SetMarkerStyle(Style_t mstyle)
245 static const TEveException eh(
"TEvePointSet::SetMarkerStyle ");
247 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
248 while (pi != fProjectedList.end())
250 TEvePointSet* pt =
dynamic_cast<TEvePointSet*
>(*pi);
253 pt->SetMarkerStyle(mstyle);
258 TAttMarker::SetMarkerStyle(mstyle);
264 void TEvePointSet::SetMarkerSize(Size_t msize)
266 static const TEveException eh(
"TEvePointSet::SetMarkerSize ");
268 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
269 while (pi != fProjectedList.end())
271 TEvePointSet* pt =
dynamic_cast<TEvePointSet*
>(*pi);
274 pt->SetMarkerSize(msize);
279 TAttMarker::SetMarkerSize(msize);
285 void TEvePointSet::Paint(Option_t*)
295 void TEvePointSet::InitFill(Int_t subIdNum)
298 fIntIdsPerPoint = subIdNum;
300 fIntIds =
new TArrayI(fIntIdsPerPoint*GetN());
302 fIntIds->Set(fIntIdsPerPoint*GetN());
304 delete fIntIds; fIntIds = 0;
314 void TEvePointSet::TakeAction(TEvePointSelector* sel)
316 static const TEveException eh(
"TEvePointSet::TakeAction ");
319 throw(eh +
"selector is <null>.");
321 Int_t n = sel->GetNfill();
322 Int_t beg = GrowFor(n);
327 Double_t *vx = sel->GetV1(), *vy = sel->GetV2(), *vz = sel->GetV3();
328 Float_t *p = fP + 3*beg;
333 p[0] = *vx; p[1] = *vy; p[2] = *vz;
340 p[0] = *vx * TMath::Cos(*vy); p[1] = *vx * TMath::Sin(*vy); p[2] = *vz;
346 throw(eh +
"unknown tree variable type.");
350 Double_t** subarr =
new Double_t* [fIntIdsPerPoint];
351 for (Int_t i=0; i<fIntIdsPerPoint; ++i) {
352 subarr[i] = sel->GetVal(sel->GetDimension() - fIntIdsPerPoint + i);
353 if (subarr[i] == 0) {
355 throw(eh +
"sub-id array not available.");
358 Int_t* ids = fIntIds->GetArray() + fIntIdsPerPoint*beg;
361 for (Int_t i=0; i<fIntIdsPerPoint; ++i) {
362 ids[i] = TMath::Nint(*subarr[i]);
365 ids += fIntIdsPerPoint;
374 void TEvePointSet::CopyVizParams(
const TEveElement* el)
376 const TEvePointSet* m =
dynamic_cast<const TEvePointSet*
>(el);
379 TAttMarker::operator=(*m);
380 fOption = m->fOption;
383 TEveElement::CopyVizParams(el);
389 void TEvePointSet::WriteVizParams(std::ostream& out,
const TString& var)
391 TEveElement::WriteVizParams(out, var);
393 TAttMarker::SaveMarkerAttributes(out, var);
399 TClass* TEvePointSet::ProjectedClass(
const TEveProjection*)
const
401 return TEvePointSetProjected::Class();
408 void TEvePointSet::PointSelected(Int_t
id)
410 Emit(
"PointSelected(Int_t)",
id);
411 TPointSet3D::PointSelected(
id);
434 ClassImp(TEvePointSetArray);
439 TEvePointSetArray::TEvePointSetArray(
const char* name,
444 fBins(0), fDefPointSetCapacity(128), fNBins(0), fLastBin(-1),
445 fMin(0), fCurMin(0), fMax(0), fCurMax(0),
450 SetMainColorPtr(&fMarkerColor);
457 TEvePointSetArray::~TEvePointSetArray()
460 delete [] fBins; fBins = 0;
466 void TEvePointSetArray::RemoveElementLocal(TEveElement* el)
468 for (Int_t i=0; i<fNBins; ++i) {
469 if (fBins[i] == el) {
479 void TEvePointSetArray::RemoveElementsLocal()
481 delete [] fBins; fBins = 0; fLastBin = -1;
487 void TEvePointSetArray::SetMarkerColor(Color_t tcolor)
489 static const TEveException eh(
"TEvePointSetArray::SetMarkerColor ");
491 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
492 TAttMarker* m =
dynamic_cast<TAttMarker*
>((*i)->GetObject(eh));
493 if (m && m->GetMarkerColor() == fMarkerColor)
494 m->SetMarkerColor(tcolor);
496 TAttMarker::SetMarkerColor(tcolor);
502 void TEvePointSetArray::SetMarkerStyle(Style_t mstyle)
504 static const TEveException eh(
"TEvePointSetArray::SetMarkerStyle ");
506 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
507 TAttMarker* m =
dynamic_cast<TAttMarker*
>((*i)->GetObject(eh));
508 if (m && m->GetMarkerStyle() == fMarkerStyle)
509 m->SetMarkerStyle(mstyle);
511 TAttMarker::SetMarkerStyle(mstyle);
517 void TEvePointSetArray::SetMarkerSize(Size_t msize)
519 static const TEveException eh(
"TEvePointSetArray::SetMarkerSize ");
521 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
522 TAttMarker* m =
dynamic_cast<TAttMarker*
>((*i)->GetObject(eh));
523 if (m && m->GetMarkerSize() == fMarkerSize)
524 m->SetMarkerSize(msize);
526 TAttMarker::SetMarkerSize(msize);
534 void TEvePointSetArray::TakeAction(TEvePointSelector* sel)
536 static const TEveException eh(
"TEvePointSetArray::TakeAction ");
539 throw eh +
"selector is <null>.";
541 Int_t n = sel->GetNfill();
545 Double_t *vx = sel->GetV1(), *vy = sel->GetV2(), *vz = sel->GetV3();
546 Double_t *qq = sel->GetV4();
549 throw eh +
"requires 4-d varexp.";
557 Fill(*vx, *vy, *vz, *qq);
558 ++vx; ++vy; ++vz; ++qq;
566 Fill(*vx * TMath::Cos(*vy), *vx * TMath::Sin(*vy), *vz, *qq);
567 ++vx; ++vy; ++vz; ++qq;
573 throw eh +
"unknown tree variable type.";
583 Int_t TEvePointSetArray::Size(Bool_t under, Bool_t over)
const
586 const Int_t min = under ? 0 : 1;
587 const Int_t max = over ? fNBins : fNBins - 1;
588 for (Int_t i = min; i < max; ++i)
591 size += fBins[i]->Size();
601 void TEvePointSetArray::InitBins(
const char* quant_name,
602 Int_t nbins, Double_t min, Double_t max)
604 static const TEveException eh(
"TEvePointSetArray::InitBins ");
606 if (nbins < 1)
throw eh +
"nbins < 1.";
607 if (min > max)
throw eh +
"min > max.";
611 fQuantName = quant_name;
614 fMin = fCurMin = min;
615 fMax = fCurMax = max;
616 fBinWidth = (fMax - fMin)/(fNBins - 2);
618 fBins =
new TEvePointSet* [fNBins];
620 for (Int_t i = 0; i < fNBins; ++i)
622 fBins[i] =
new TEvePointSet
623 (Form(
"Slice %d [%4.3lf, %4.3lf]", i, fMin + (i-1)*fBinWidth, fMin + i*fBinWidth),
624 fDefPointSetCapacity);
625 fBins[i]->SetMarkerColor(fMarkerColor);
626 fBins[i]->SetMarkerStyle(fMarkerStyle);
627 fBins[i]->SetMarkerSize(fMarkerSize);
628 AddElement(fBins[i]);
631 fBins[0]->SetName(
"Underflow");
632 fBins[0]->SetRnrSelf(kFALSE);
634 fBins[fNBins-1]->SetName(
"Overflow");
635 fBins[fNBins-1]->SetRnrSelf(kFALSE);
644 Bool_t TEvePointSetArray::Fill(Double_t x, Double_t y, Double_t z, Double_t quant)
646 fLastBin = TMath::FloorNint((quant - fMin)/fBinWidth) + 1;
652 else if (fLastBin > fNBins - 1)
654 fLastBin = fNBins - 1;
657 if (fBins[fLastBin] != 0)
659 fBins[fLastBin]->SetNextPoint(x, y, z);
671 void TEvePointSetArray::SetPointId(TObject*
id)
674 fBins[fLastBin]->SetPointId(
id);
682 void TEvePointSetArray::CloseBins()
684 for (Int_t i=0; i<fNBins; ++i)
688 fBins[i]->SetTitle(Form(
"N=%d", fBins[i]->Size()));
689 fBins[i]->ComputeBBox();
698 void TEvePointSetArray::SetOwnIds(Bool_t o)
700 for (Int_t i=0; i<fNBins; ++i)
703 fBins[i]->SetOwnIds(o);
712 void TEvePointSetArray::SetRange(Double_t min, Double_t max)
714 using namespace TMath;
716 fCurMin = min; fCurMax = max;
717 Int_t low_b = Max(0, FloorNint((min-fMin)/fBinWidth)) + 1;
718 Int_t high_b = Min(fNBins-2, CeilNint ((max-fMin)/fBinWidth));
720 for (Int_t i = 1; i < fNBins - 1; ++i)
723 fBins[i]->SetRnrSelf(i>=low_b && i<=high_b);
731 ClassImp(TEvePointSetProjected);
736 TEvePointSetProjected::TEvePointSetProjected() :
746 void TEvePointSetProjected::SetProjection(TEveProjectionManager* proj,
747 TEveProjectable* model)
749 TEveProjected::SetProjection(proj, model);
750 CopyVizParams(dynamic_cast<TEveElement*>(model));
756 void TEvePointSetProjected::SetDepthLocal(Float_t d)
758 SetDepthCommon(d,
this, fBBox);
761 Float_t *p = GetP() + 2;
762 for (Int_t i = 0; i < n; ++i, p+=3)
770 void TEvePointSetProjected::UpdateProjection()
772 TEveProjection &proj = * fManager->GetProjection();
773 TEvePointSet &ps = *
dynamic_cast<TEvePointSet*
>(fProjectable);
774 TEveTrans *tr = ps.PtrMainTrans(kFALSE);
779 Float_t *o = ps.GetP(), *p = GetP();
780 for (Int_t i = 0; i < n; ++i, o+=3, p+=3)
782 proj.ProjectPointfv(tr, o, p, fDepth);
790 void TEvePointSetProjected::PointSelected(Int_t
id)
792 TEvePointSet *ps =
dynamic_cast<TEvePointSet*
>(fProjectable);
793 ps->PointSelected(
id);