20 using namespace ROOT::Experimental;
25 REveStraightLineSet::REveStraightLineSet(
const std::string& n,
const std::string& t):
28 fLinePlex (sizeof(Line_t), 4),
29 fMarkerPlex (sizeof(Marker_t), 8),
30 fOwnLinesIds (kFALSE),
31 fOwnMarkersIds (kFALSE),
40 fMainColorPtr = &fLineColor;
49 REveStraightLineSet::Line_t*
50 REveStraightLineSet::AddLine(Float_t x1, Float_t y1, Float_t z1,
51 Float_t x2, Float_t y2, Float_t z2)
53 fLastLine =
new (fLinePlex.NewAtom()) Line_t(x1, y1, z1, x2, y2, z2);
54 fLastLine->fId = fLinePlex.Size() - 1;
61 REveStraightLineSet::Line_t*
62 REveStraightLineSet::AddLine(
const REveVector& p1,
const REveVector& p2)
64 return AddLine(p1.fX, p1.fY, p1.fZ, p2.fX, p2.fY, p2.fZ);
71 REveStraightLineSet::SetLine(
int idx,
72 Float_t x1, Float_t y1, Float_t z1,
73 Float_t x2, Float_t y2, Float_t z2)
75 Line_t* l = (Line_t*) fLinePlex.Atom(idx);
77 l->fV1[0] = x1; l->fV1[1] = y1; l->fV1[2] = z1;
78 l->fV2[0] = x2; l->fV2[1] = y2; l->fV2[2] = z2;
85 REveStraightLineSet::SetLine(
int idx,
const REveVector& p1,
const REveVector& p2)
87 SetLine(idx, p1.fX, p1.fY, p1.fZ, p2.fX, p2.fY, p2.fZ);
93 REveStraightLineSet::Marker_t*
94 REveStraightLineSet::AddMarker(Float_t x, Float_t y, Float_t z, Int_t line_id)
96 Marker_t* marker =
new (fMarkerPlex.NewAtom()) Marker_t(x, y, z, line_id);
103 REveStraightLineSet::Marker_t*
104 REveStraightLineSet::AddMarker(
const REveVector& p, Int_t line_id)
106 return AddMarker(p.fX, p.fY, p.fZ, line_id);
112 REveStraightLineSet::Marker_t*
113 REveStraightLineSet::AddMarker(Int_t line_id, Float_t pos)
115 Line_t& l = * (Line_t*) fLinePlex.Atom(line_id);
116 return AddMarker(l.fV1[0] + (l.fV2[0] - l.fV1[0])*pos,
117 l.fV1[1] + (l.fV2[1] - l.fV1[1])*pos,
118 l.fV1[2] + (l.fV2[2] - l.fV1[2])*pos,
125 void REveStraightLineSet::CopyVizParams(
const REveElement* el)
127 const REveStraightLineSet* m =
dynamic_cast<const REveStraightLineSet*
>(el);
130 TAttLine::operator=(*m);
131 TAttMarker::operator=(*m);
132 fRnrMarkers = m->fRnrMarkers;
133 fRnrLines = m->fRnrLines;
134 fDepthTest = m->fDepthTest;
137 REveElement::CopyVizParams(el);
143 void REveStraightLineSet::WriteVizParams(std::ostream& out,
const TString& var)
145 REveElement::WriteVizParams(out, var);
147 TString t =
" " + var +
"->";
148 TAttMarker::SaveMarkerAttributes(out, var);
149 TAttLine ::SaveLineAttributes (out, var);
150 out << t <<
"SetRnrMarkers(" << ToString(fRnrMarkers) <<
");\n";
151 out << t <<
"SetRnrLines(" << ToString(fRnrLines) <<
");\n";
152 out << t <<
"SetDepthTest(" << ToString(fDepthTest) <<
");\n";
158 Int_t REveStraightLineSet::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
160 Int_t ret = REveElement::WriteCoreJson(j, rnr_offset);
162 j[
"fLinePlexSize"] = fLinePlex.Size();
163 j[
"fMarkerPlexSize"] = fMarkerPlex.Size();
164 j[
"fLineWidth"] = fLineWidth;
165 j[
"fLineStyle"] = fLineStyle;
166 j[
"fMarkerSize"] = fMarkerSize;
167 j[
"fMarkerStyle"] = fMarkerStyle;
168 j[
"fSecondarySelect"] =
false;
176 void REveStraightLineSet::BuildRenderData()
178 int nVertices = fLinePlex.Size() * 2 + fMarkerPlex.Size();
179 fRenderData = std::make_unique<REveRenderData>(
"makeStraightLineSet", 3 * nVertices, 0, nVertices);
182 REveChunkManager::iterator li(fLinePlex);
185 Line_t *l = (Line_t*) li();
187 fRenderData->PushV(l->fV1[0], l->fV1[1],l->fV1[2]);
188 fRenderData->PushV(l->fV2[0], l->fV2[1],l->fV2[2]);
189 fRenderData->PushI(l->fId);
193 REveChunkManager::iterator mi(fMarkerPlex);
196 Marker_t *m = (Marker_t*) mi();
197 fRenderData->PushV(m->fV[0], m->fV[1], m->fV[2]);
198 fRenderData->PushI(m->fLineId);
201 REveElement::BuildRenderData();
210 TClass* REveStraightLineSet::ProjectedClass(
const REveProjection*)
const
212 return TClass::GetClass<REveStraightLineSetProjected>();
219 void REveStraightLineSet::ComputeBBox()
221 if (fLinePlex.Size() == 0 && fMarkerPlex.Size() == 0) {
228 REveChunkManager::iterator li(fLinePlex);
230 BBoxCheckPoint(((Line_t*)li())->fV1);
231 BBoxCheckPoint(((Line_t*)li())->fV2);
234 REveChunkManager::iterator mi(fMarkerPlex);
237 BBoxCheckPoint(((Marker_t*)mi())->fV);
247 ClassImp(REveStraightLineSetProjected);
252 REveStraightLineSetProjected::REveStraightLineSetProjected() :
253 REveStraightLineSet(), REveProjected ()
260 void REveStraightLineSetProjected::SetProjection(REveProjectionManager* mng,
261 REveProjectable* model)
263 REveProjected::SetProjection(mng, model);
265 CopyVizParams(dynamic_cast<REveElement*>(model));
271 void REveStraightLineSetProjected::SetDepthLocal(Float_t d)
273 SetDepthCommon(d,
this, fBBox);
275 REveChunkManager::iterator li(fLinePlex);
278 REveStraightLineSet::Line_t& l = * (REveStraightLineSet::Line_t*) li();
283 REveChunkManager::iterator mi(fMarkerPlex);
286 Marker_t& m = * (Marker_t*) mi();
295 void REveStraightLineSetProjected::UpdateProjection()
297 REveProjection& proj = * fManager->GetProjection();
298 REveStraightLineSet& orig = *
dynamic_cast<REveStraightLineSet*
>(fProjectable);
300 REveTrans *trans = orig.PtrMainTrans(kFALSE);
305 Int_t num_lines = orig.GetLinePlex().Size();
306 if (proj.HasSeveralSubSpaces())
307 num_lines += TMath::Max(1, num_lines/10);
308 fLinePlex.Reset(
sizeof(Line_t), num_lines);
310 REveChunkManager::iterator li(orig.GetLinePlex());
313 Line_t *l = (Line_t*) li();
315 proj.ProjectPointfv(trans, l->fV1, p1, fDepth);
316 proj.ProjectPointfv(trans, l->fV2, p2, fDepth);
318 if (proj.AcceptSegment(p1, p2, 0.1f))
320 AddLine(p1, p2)->fId = l->fId;
324 REveVector bp1(l->fV1), bp2(l->fV2);
326 trans->MultiplyIP(bp1);
327 trans->MultiplyIP(bp2);
329 proj.BisectBreakPoint(bp1, bp2, kTRUE, fDepth);
331 AddLine(p1, bp1)->fId = l->fId;
332 AddLine(bp2, p2)->fId = l->fId;
335 if (proj.HasSeveralSubSpaces())
339 fMarkerPlex.Reset(
sizeof(Marker_t), orig.GetMarkerPlex().Size());
340 REveChunkManager::iterator mi(orig.GetMarkerPlex());
344 Marker_t &m = * (Marker_t*) mi();
346 proj.ProjectPointfv(trans, m.fV, pp, fDepth);
347 AddMarker(pp, m.fLineId);