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
22
23////////////////////////////////////////////////////////////////////////////////
24/// Constructor.
25
26TEveStraightLineSet::TEveStraightLineSet(const char* n, const char* t):
27 TEveElement (),
28 TNamed (n, t),
29
30 fLinePlex (sizeof(Line_t), 4),
31 fMarkerPlex (sizeof(Marker_t), 8),
32 fOwnLinesIds (kFALSE),
33 fOwnMarkersIds (kFALSE),
34 fRnrMarkers (kTRUE),
35 fRnrLines (kTRUE),
36 fDepthTest (kTRUE),
37 fLastLine (0)
38{
41
43 fLineColor = 4;
44 fMarkerColor = 2;
45 fMarkerStyle = 20;
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// Add a line.
50
54{
55 fLastLine = new (fLinePlex.NewAtom()) Line_t(x1, y1, z1, x2, y2, z2);
56 fLastLine->fId = fLinePlex.Size() - 1;
57 return fLastLine;
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Add a line.
62
65{
66 return AddLine(p1.fX, p1.fY, p1.fZ, p2.fX, p2.fY, p2.fZ);
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Set line vertices with given index.
71
72void
76{
77 Line_t* l = (Line_t*) fLinePlex.Atom(idx);
78
79 l->fV1[0] = x1; l->fV1[1] = y1; l->fV1[2] = z1;
80 l->fV2[0] = x2; l->fV2[1] = y2; l->fV2[2] = z2;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Set line vertices with given index.
85
86void
88{
89 SetLine(idx, p1.fX, p1.fY, p1.fZ, p2.fX, p2.fY, p2.fZ);
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Add a marker with given position.
94
97{
98 Marker_t* marker = new (fMarkerPlex.NewAtom()) Marker_t(x, y, z, line_id);
99 return marker;
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Add a marker with given position.
104
107{
108 return AddMarker(p.fX, p.fY, p.fZ, line_id);
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Add a marker for line with given index on relative position pos.
113
116{
117 Line_t& l = * (Line_t*) fLinePlex.Atom(line_id);
118 return AddMarker(l.fV1[0] + (l.fV2[0] - l.fV1[0])*pos,
119 l.fV1[1] + (l.fV2[1] - l.fV1[1])*pos,
120 l.fV1[2] + (l.fV2[2] - l.fV1[2])*pos,
121 line_id);
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Copy visualization parameters from element el.
126
128{
129 const TEveStraightLineSet* m = dynamic_cast<const TEveStraightLineSet*>(el);
130 if (m)
131 {
132 TAttLine::operator=(*m);
133 TAttMarker::operator=(*m);
134 fRnrMarkers = m->fRnrMarkers;
135 fRnrLines = m->fRnrLines;
136 fDepthTest = m->fDepthTest;
137 }
138
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Write visualization parameters.
144
145void TEveStraightLineSet::WriteVizParams(std::ostream& out, const TString& var)
146{
148
149 TString t = " " + var + "->";
151 TAttLine ::SaveLineAttributes (out, var);
152 out << t << "SetRnrMarkers(" << ToString(fRnrMarkers) << ");\n";
153 out << t << "SetRnrLines(" << ToString(fRnrLines) << ");\n";
154 out << t << "SetDepthTest(" << ToString(fDepthTest) << ");\n";
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Return class of projected object.
159/// Virtual from TEveProjectable.
160
162{
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// Compute bounding-box.
168/// Virtual from TAttBBox.
169
171{
172 if (fLinePlex.Size() == 0 && fMarkerPlex.Size() == 0) {
173 BBoxZero();
174 return;
175 }
176
177 BBoxInit();
178
180 while (li.next()) {
181 BBoxCheckPoint(((Line_t*)li())->fV1);
182 BBoxCheckPoint(((Line_t*)li())->fV2);
183 }
184
186 while (mi.next())
187 {
188 BBoxCheckPoint(((Marker_t*)mi())->fV);
189 }
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Paint the line-set.
194
196{
197 PaintStandard(this);
198}
199
200/** \class TEveStraightLineSetProjected
201\ingroup TEve
202Projected replica of a TEveStraightLineSet.
203*/
204
206
207////////////////////////////////////////////////////////////////////////////////
208/// Constructor.
209
212{
213}
214
215////////////////////////////////////////////////////////////////////////////////
216/// Set projection manager and model object.
217
219 TEveProjectable* model)
220{
222
223 CopyVizParams(dynamic_cast<TEveElement*>(model));
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Set depth (z-coordinate) of the projected points.
228
230{
231 SetDepthCommon(d, this, fBBox);
232
234 while (li.next())
235 {
237 l.fV1[2] = fDepth;
238 l.fV2[2] = fDepth;
239 }
240
242 while (mi.next())
243 {
244 Marker_t& m = * (Marker_t*) mi();
245 m.fV[2] = fDepth;
246 }
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Callback that actually performs the projection.
251/// Called when projection parameters have been updated.
252
254{
256 TEveStraightLineSet& orig = * dynamic_cast<TEveStraightLineSet*>(fProjectable);
257
258 TEveTrans *trans = orig.PtrMainTrans(kFALSE);
259
260 BBoxClear();
261
262 // Lines
263 Int_t num_lines = orig.GetLinePlex().Size();
264 if (proj.HasSeveralSubSpaces())
265 num_lines += TMath::Max(1, num_lines/10);
266 fLinePlex.Reset(sizeof(Line_t), num_lines);
267 TEveVector p1, p2;
269 while (li.next())
270 {
271 Line_t *l = (Line_t*) li();
272
273 proj.ProjectPointfv(trans, l->fV1, p1, fDepth);
274 proj.ProjectPointfv(trans, l->fV2, p2, fDepth);
275
276 if (proj.AcceptSegment(p1, p2, 0.1f))
277 {
278 AddLine(p1, p2)->fId = l->fId;
279 }
280 else
281 {
282 TEveVector bp1(l->fV1), bp2(l->fV2);
283 if (trans) {
284 trans->MultiplyIP(bp1);
285 trans->MultiplyIP(bp2);
286 }
287 proj.BisectBreakPoint(bp1, bp2, kTRUE, fDepth);
288
289 AddLine(p1, bp1)->fId = l->fId;
290 AddLine(bp2, p2)->fId = l->fId;
291 }
292 }
293 if (proj.HasSeveralSubSpaces())
295
296 // Markers
297 fMarkerPlex.Reset(sizeof(Marker_t), orig.GetMarkerPlex().Size());
299 TEveVector pp;
300 while (mi.next())
301 {
302 Marker_t &m = * (Marker_t*) mi();
303
304 proj.ProjectPointfv(trans, m.fV, pp, fDepth);
305 AddMarker(pp, m.fLineId);
306 }
307}
#define d(i)
Definition RSha256.hxx:102
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
void BBoxClear()
Remove BBox information.
Definition TAttBBox.cxx:54
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:42
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition TAttBBox.cxx:29
Float_t * fBBox
Definition TAttBBox.h:20
Color_t fLineColor
Line color.
Definition TAttLine.h:21
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:22
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:23
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Char_t * Atom(Int_t idx) const
void Reset(Int_t atom_size, Int_t chunk_size)
Empty the container and reset it with given atom and chunk sizes.
void Refit()
Refit the container so that all current data fits into a single chunk.
Int_t Size() const
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
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
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
Abstract base-class for non-linear projectable objects.
Abstract base class for classes that hold results of a non-linear projection transformation.
TEveProjectable * fProjectable
TEveProjectionManager * fManager
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable object.
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.
TEveProjection * GetProjection()
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
Projected replica of a TEveStraightLineSet.
virtual void SetDepthLocal(Float_t d)
Set depth (z-coordinate) of the projected points.
virtual void UpdateProjection()
Callback that actually performs the projection.
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Set projection manager and model object.
Set of straight lines with optional markers along the lines.
TEveStraightLineSet(const TEveStraightLineSet &)
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
virtual void Paint(Option_t *option="")
Paint the line-set.
TEveChunkManager & GetMarkerPlex()
virtual TClass * ProjectedClass(const TEveProjection *p) const
Return class of projected object.
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
virtual void ComputeBBox()
Compute bounding-box.
TEveChunkManager & GetLinePlex()
virtual void WriteVizParams(std::ostream &out, const TString &var)
Write visualization parameters.
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.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Basic string class.
Definition TString.h:139
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:250
Bool_t next()
Go to next atom.
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4