Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TEveStraightLineSet.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveStraightLineSet.h"
13
15
16/** \class TEveStraightLineSet
17\ingroup TEve
18Set of straight lines with optional markers along the lines.
19*/
20
21
22////////////////////////////////////////////////////////////////////////////////
23/// Constructor.
24
25TEveStraightLineSet::TEveStraightLineSet(const char* n, const char* t):
26 TEveElement (),
27 TNamed (n, t),
28
29 fLinePlex (sizeof(Line_t), 4),
30 fMarkerPlex (sizeof(Marker_t), 8),
36 fLastLine (nullptr)
37{
40
42 fLineColor = 4;
43 fMarkerColor = 2;
44 fMarkerStyle = 20;
45}
46
47////////////////////////////////////////////////////////////////////////////////
48/// Add a line.
49
52 Float_t x2, Float_t y2, Float_t z2)
53{
54 fLastLine = new (fLinePlex.NewAtom()) Line_t(x1, y1, z1, x2, y2, z2);
55 fLastLine->fId = fLinePlex.Size() - 1;
56 return fLastLine;
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Add a line.
61
64{
65 return AddLine(p1.fX, p1.fY, p1.fZ, p2.fX, p2.fY, p2.fZ);
66}
67
68////////////////////////////////////////////////////////////////////////////////
69/// Set line vertices with given index.
70
71void
73 Float_t x1, Float_t y1, Float_t z1,
74 Float_t x2, Float_t y2, Float_t z2)
75{
76 Line_t* l = (Line_t*) fLinePlex.Atom(idx);
77
78 l->fV1[0] = x1; l->fV1[1] = y1; l->fV1[2] = z1;
79 l->fV2[0] = x2; l->fV2[1] = y2; l->fV2[2] = z2;
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Set line vertices with given index.
84
85void
87{
88 SetLine(idx, p1.fX, p1.fY, p1.fZ, p2.fX, p2.fY, p2.fZ);
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Add a marker with given position.
93
96{
97 Marker_t* marker = new (fMarkerPlex.NewAtom()) Marker_t(x, y, z, line_id);
98 return marker;
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Add a marker with given position.
103
106{
107 return AddMarker(p.fX, p.fY, p.fZ, line_id);
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Add a marker for line with given index on relative position pos.
112
115{
116 Line_t& l = * (Line_t*) fLinePlex.Atom(line_id);
117 return AddMarker(l.fV1[0] + (l.fV2[0] - l.fV1[0])*pos,
118 l.fV1[1] + (l.fV2[1] - l.fV1[1])*pos,
119 l.fV1[2] + (l.fV2[2] - l.fV1[2])*pos,
120 line_id);
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Copy visualization parameters from element el.
125
127{
128 const TEveStraightLineSet* m = dynamic_cast<const TEveStraightLineSet*>(el);
129 if (m)
130 {
131 TAttLine::operator=(*m);
132 TAttMarker::operator=(*m);
133 fRnrMarkers = m->fRnrMarkers;
134 fRnrLines = m->fRnrLines;
135 fDepthTest = m->fDepthTest;
136 }
137
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Write visualization parameters.
143
144void TEveStraightLineSet::WriteVizParams(std::ostream& out, const TString& var)
145{
147
148 TString t = " " + var + "->";
150 TAttLine ::SaveLineAttributes (out, var);
151 out << t << "SetRnrMarkers(" << ToString(fRnrMarkers) << ");\n";
152 out << t << "SetRnrLines(" << ToString(fRnrLines) << ");\n";
153 out << t << "SetDepthTest(" << ToString(fDepthTest) << ");\n";
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Return class of projected object.
158/// Virtual from TEveProjectable.
159
164
165////////////////////////////////////////////////////////////////////////////////
166/// Compute bounding-box.
167/// Virtual from TAttBBox.
168
170{
171 if (fLinePlex.Size() == 0 && fMarkerPlex.Size() == 0) {
172 BBoxZero();
173 return;
174 }
175
176 BBoxInit();
177
179 while (li.next()) {
180 BBoxCheckPoint(((Line_t*)li())->fV1);
181 BBoxCheckPoint(((Line_t*)li())->fV2);
182 }
183
185 while (mi.next())
186 {
187 BBoxCheckPoint(((Marker_t*)mi())->fV);
188 }
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Paint the line-set.
193
198
199/** \class TEveStraightLineSetProjected
200\ingroup TEve
201Projected replica of a TEveStraightLineSet.
202*/
203
204
205////////////////////////////////////////////////////////////////////////////////
206/// Constructor.
207
212
213////////////////////////////////////////////////////////////////////////////////
214/// Set projection manager and model object.
215
223
224////////////////////////////////////////////////////////////////////////////////
225/// Set depth (z-coordinate) of the projected points.
226
228{
229 SetDepthCommon(d, this, fBBox);
230
232 while (li.next())
233 {
235 l.fV1[2] = fDepth;
236 l.fV2[2] = fDepth;
237 }
238
240 while (mi.next())
241 {
242 Marker_t& m = * (Marker_t*) mi();
243 m.fV[2] = fDepth;
244 }
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Callback that actually performs the projection.
249/// Called when projection parameters have been updated.
250
252{
253 TEveProjection& proj = * fManager->GetProjection();
254 TEveStraightLineSet& orig = * dynamic_cast<TEveStraightLineSet*>(fProjectable);
255
256 TEveTrans *trans = orig.PtrMainTrans(kFALSE);
257
258 BBoxClear();
259
260 // Lines
261 Int_t num_lines = orig.GetLinePlex().Size();
262 if (proj.HasSeveralSubSpaces())
263 num_lines += TMath::Max(1, num_lines/10);
264 fLinePlex.Reset(sizeof(Line_t), num_lines);
265 TEveVector p1, p2;
267 while (li.next())
268 {
269 Line_t *l = (Line_t*) li();
270
271 proj.ProjectPointfv(trans, l->fV1, p1, fDepth);
272 proj.ProjectPointfv(trans, l->fV2, p2, fDepth);
273
274 if (proj.AcceptSegment(p1, p2, 0.1f))
275 {
276 AddLine(p1, p2)->fId = l->fId;
277 }
278 else
279 {
280 TEveVector bp1(l->fV1), bp2(l->fV2);
281 if (trans) {
282 trans->MultiplyIP(bp1);
283 trans->MultiplyIP(bp2);
284 }
285 proj.BisectBreakPoint(bp1, bp2, kTRUE, fDepth);
286
287 AddLine(p1, bp1)->fId = l->fId;
288 AddLine(bp2, p2)->fId = l->fId;
289 }
290 }
291 if (proj.HasSeveralSubSpaces())
292 fLinePlex.Refit();
293
294 // Markers
295 fMarkerPlex.Reset(sizeof(Marker_t), orig.GetMarkerPlex().Size());
297 TEveVector pp;
298 while (mi.next())
299 {
300 Marker_t &m = * (Marker_t*) mi();
301
302 proj.ProjectPointfv(trans, m.fV, pp, fDepth);
303 AddMarker(pp, m.fLineId);
304 }
305}
#define d(i)
Definition RSha256.hxx:102
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
short Marker_t
Marker number (short).
Definition RtypesCore.h:97
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
TEveVectorT< Float_t > TEveVector
Definition TEveVector.h:123
void BBoxClear()
Remove BBox information.
Definition TAttBBox.cxx:53
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
Definition TAttBBox.h:69
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
Definition TAttBBox.cxx:41
void BBoxInit(Float_t infinity=1e6)
Allocate and prepare for incremental filling.
Definition TAttBBox.cxx:28
Float_t * fBBox
! Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition TAttBBox.h:20
Color_t fLineColor
Line color.
Definition TAttLine.h:24
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:24
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:25
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
Int_t Size() const
virtual TEveTrans * PtrMainTrans(Bool_t create=kTRUE)
Return pointer to main transformation.
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix.
Color_t * fMainColorPtr
Definition TEveElement.h:99
TEveElement()
Default constructor.
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
static const char * ToString(Bool_t b)
Convert Bool_t to string - kTRUE or kFALSE.
virtual void WriteVizParams(std::ostream &out, const TString &var)
Write-out visual parameters for this object.
virtual void PaintStandard(TObject *id)
Paint object – a generic implementation for EVE elements.
Bool_t fPickable
TEveProjectable(const TEveProjectable &)
TEveProjectable * fProjectable
TEveProjectionManager * fManager
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable object.
TEveProjected(const TEveProjected &)
void SetDepthCommon(Float_t d, TEveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
Manager class for steering of projections and managing projected objects.
Base-class for non-linear projections.
virtual void BisectBreakPoint(TEveVector &vL, TEveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
virtual Bool_t HasSeveralSubSpaces() const
virtual Bool_t AcceptSegment(TEveVector &, TEveVector &, Float_t) const
void UpdateProjection() override
Callback that actually performs the projection.
void SetDepthLocal(Float_t d) override
Set depth (z-coordinate) of the projected points.
void SetProjection(TEveProjectionManager *mng, TEveProjectable *model) override
Set projection manager and model object.
TEveStraightLineSet(const TEveStraightLineSet &)
TClass * ProjectedClass(const TEveProjection *p) const override
Return class of projected object.
void WriteVizParams(std::ostream &out, const TString &var) override
Write visualization parameters.
void CopyVizParams(const TEveElement *el) override
Copy visualization parameters from element el.
void ComputeBBox() override
Compute bounding-box.
TEveChunkManager & GetMarkerPlex()
Marker_t * AddMarker(Float_t x, Float_t y, Float_t z, Int_t line_id=-1)
Add a marker with given position.
Line_t * AddLine(Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2)
Add a line.
TEveChunkManager fLinePlex
TEveChunkManager & GetLinePlex()
void Paint(Option_t *option="") override
Paint the line-set.
void SetLine(int idx, Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2)
Set line vertices with given index.
TEveChunkManager fMarkerPlex
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
TNamed()
Definition TNamed.h:38
Basic string class.
Definition TString.h:138
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Bool_t next()
Go to next atom.
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4