27 using namespace ROOT::Experimental;
28 namespace REX = ROOT::Experimental;
50 REvePointSet::REvePointSet(
const std::string& name,
const std::string& title, Int_t n_points) :
51 REveElement(name, title),
57 SetMainColorPtr(&fMarkerColor);
68 REvePointSet::REvePointSet(
const REvePointSet& e) :
79 REvePointSet::~REvePointSet()
86 void REvePointSet::ClonePoints(
const REvePointSet& e)
89 fCapacity = e.fCapacity;
97 void REvePointSet::Reset(Int_t n_points)
99 fPoints.resize(n_points);
100 fCapacity = n_points;
112 Int_t REvePointSet::GrowFor(Int_t n_points)
114 assert(n_points >= 0);
116 Int_t old_size = fCapacity;
117 Int_t new_size = old_size + n_points;
119 fPoints.resize(new_size);
120 fCapacity = new_size;
125 int REvePointSet::SetNextPoint(
float x,
float y,
float z)
127 return SetPoint(fSize, x, y, z);
130 int REvePointSet::SetPoint(
int n,
float x,
float y,
float z)
134 fCapacity = std::max(n + 1, 2*fCapacity);
135 fPoints.resize(fCapacity);
137 fPoints[n].Set(x, y, z);
148 void REvePointSet::SetMarkerStyle(Style_t mstyle)
150 for (
auto &pi: fProjectedList)
152 REvePointSet* pt =
dynamic_cast<REvePointSet *
>(pi);
155 pt->SetMarkerStyle(mstyle);
159 TAttMarker::SetMarkerStyle(mstyle);
165 void REvePointSet::SetMarkerSize(Size_t msize)
167 for (
auto &pi: fProjectedList)
169 REvePointSet* pt =
dynamic_cast<REvePointSet *
>(pi);
172 pt->SetMarkerSize(msize);
176 TAttMarker::SetMarkerSize(msize);
183 void REvePointSet::CopyVizParams(
const REveElement* el)
185 const REvePointSet* m =
dynamic_cast<const REvePointSet*
>(el);
188 TAttMarker::operator=(*m);
191 REveElement::CopyVizParams(el);
197 void REvePointSet::WriteVizParams(std::ostream& out,
const TString& var)
199 REveElement::WriteVizParams(out, var);
201 TAttMarker::SaveMarkerAttributes(out, var);
207 TClass* REvePointSet::ProjectedClass(
const REveProjection*)
const
209 return TClass::GetClass<REvePointSetProjected>();
213 Int_t REvePointSet::WriteCoreJson(nlohmann::json& j, Int_t rnr_offset)
215 Int_t ret = REveElement::WriteCoreJson(j, rnr_offset);
217 j[
"fMarkerSize"] = GetMarkerSize();
218 j[
"fMarkerColor"] = GetMarkerColor();
226 void REvePointSet::BuildRenderData()
230 fRenderData = std::make_unique<REveRenderData>(
"makeHit", 3*fSize);
231 fRenderData->PushV(&fPoints[0].fX, 3*fSize);
238 void REvePointSet::ComputeBBox()
242 for (
auto &p : fPoints)
244 BBoxCheckPoint(p.fX, p.fY, p.fZ);
255 void REvePointSet::PointSelected(Int_t )
287 REvePointSetArray::REvePointSetArray(
const std::string& name,
288 const std::string& title) :
289 REveElement(name, title),
291 fBins(nullptr), fDefPointSetCapacity(128), fNBins(0), fLastBin(-1),
292 fMin(0), fCurMin(0), fMax(0), fCurMax(0),
296 SetMainColorPtr(&fMarkerColor);
303 REvePointSetArray::~REvePointSetArray()
306 delete [] fBins; fBins =
nullptr;
312 void REvePointSetArray::RemoveElementLocal(REveElement* el)
314 for (Int_t i=0; i<fNBins; ++i) {
315 if (fBins[i] == el) {
325 void REvePointSetArray::RemoveElementsLocal()
327 delete [] fBins; fBins =
nullptr; fLastBin = -1;
333 void REvePointSetArray::SetMarkerColor(Color_t tcolor)
335 for (
auto & el : fChildren)
337 TAttMarker* m =
dynamic_cast<TAttMarker*
>(el);
338 if (m && m->GetMarkerColor() == fMarkerColor)
339 m->SetMarkerColor(tcolor);
341 TAttMarker::SetMarkerColor(tcolor);
347 void REvePointSetArray::SetMarkerStyle(Style_t mstyle)
349 for (
auto & el : fChildren)
351 TAttMarker* m =
dynamic_cast<TAttMarker*
>(el);
352 if (m && m->GetMarkerStyle() == fMarkerStyle)
353 m->SetMarkerStyle(mstyle);
355 TAttMarker::SetMarkerStyle(mstyle);
361 void REvePointSetArray::SetMarkerSize(Size_t msize)
363 for (
auto & el : fChildren)
365 TAttMarker* m =
dynamic_cast<TAttMarker*
>(el);
366 if (m && m->GetMarkerSize() == fMarkerSize)
367 m->SetMarkerSize(msize);
369 TAttMarker::SetMarkerSize(msize);
377 Int_t REvePointSetArray::Size(Bool_t under, Bool_t over)
const
380 const Int_t min = under ? 0 : 1;
381 const Int_t max = over ? fNBins : fNBins - 1;
382 for (Int_t i = min; i < max; ++i)
385 size += fBins[i]->GetSize();
395 void REvePointSetArray::InitBins(
const std::string& quant_name,
396 Int_t nbins, Double_t min, Double_t max)
398 static const REveException eh(
"REvePointSetArray::InitBins ");
400 if (nbins < 1)
throw eh +
"nbins < 1.";
401 if (min > max)
throw eh +
"min > max.";
405 fQuantName = quant_name;
408 fMin = fCurMin = min;
409 fMax = fCurMax = max;
410 fBinWidth = (fMax - fMin)/(fNBins - 2);
412 fBins =
new REvePointSet* [fNBins];
414 for (Int_t i = 0; i < fNBins; ++i)
416 fBins[i] =
new REvePointSet
417 (Form(
"Slice %d [%4.3lf, %4.3lf]", i, fMin + (i-1)*fBinWidth, fMin + i*fBinWidth),
419 fDefPointSetCapacity);
420 fBins[i]->SetMarkerColor(fMarkerColor);
421 fBins[i]->SetMarkerStyle(fMarkerStyle);
422 fBins[i]->SetMarkerSize(fMarkerSize);
423 AddElement(fBins[i]);
426 fBins[0]->SetName(
"Underflow");
427 fBins[0]->SetRnrSelf(kFALSE);
429 fBins[fNBins-1]->SetName(
"Overflow");
430 fBins[fNBins-1]->SetRnrSelf(kFALSE);
439 Bool_t REvePointSetArray::Fill(Double_t x, Double_t y, Double_t z, Double_t quant)
441 fLastBin = TMath::FloorNint((quant - fMin)/fBinWidth) + 1;
447 else if (fLastBin > fNBins - 1)
449 fLastBin = fNBins - 1;
452 if (fBins[fLastBin] != 0)
454 fBins[fLastBin]->SetNextPoint(x, y, z);
468 void REvePointSetArray::CloseBins()
470 for (Int_t i=0; i<fNBins; ++i)
474 fBins[i]->SetTitle(Form(
"N=%d", fBins[i]->GetSize()));
475 fBins[i]->ComputeBBox();
486 void REvePointSetArray::SetRange(Double_t min, Double_t max)
488 using namespace TMath;
490 fCurMin = min; fCurMax = max;
491 Int_t low_b = Max(0, FloorNint((min-fMin)/fBinWidth)) + 1;
492 Int_t high_b = Min(fNBins-2, CeilNint ((max-fMin)/fBinWidth));
494 for (Int_t i = 1; i < fNBins - 1; ++i)
497 fBins[i]->SetRnrSelf(i>=low_b && i<=high_b);
509 REvePointSetProjected::REvePointSetProjected() :
519 void REvePointSetProjected::SetProjection(REveProjectionManager* proj,
520 REveProjectable* model)
522 REveProjected::SetProjection(proj, model);
523 CopyVizParams(dynamic_cast<REveElement*>(model));
529 void REvePointSetProjected::SetDepthLocal(Float_t d)
531 SetDepthCommon(d,
this, fBBox);
536 Float_t *p = & fPoints[0].fZ;
537 for (Int_t i = 0; i < n; ++i, p+=3)
545 void REvePointSetProjected::UpdateProjection()
547 REveProjection &proj = * fManager->GetProjection();
548 REvePointSet &ps = *
dynamic_cast<REvePointSet*
>(fProjectable);
549 REveTrans *tr = ps.PtrMainTrans(kFALSE);
553 Int_t n = ps.GetSize();
556 const Float_t *o = & ps.RefPoint(0).fX;
557 Float_t *p = & fPoints[0].fX;
558 for (Int_t i = 0; i < n; ++i, o+=3, p+=3)
560 proj.ProjectPointfv(tr, o, p, fDepth);
568 void REvePointSetProjected::PointSelected(Int_t
id)
570 REvePointSet *ps =
dynamic_cast<REvePointSet*
>(fProjectable);
571 ps->PointSelected(
id);