Logo ROOT   6.14/05
Reference Guide
lineset.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of class TEveStraightLineSet.
4 ///
5 /// \image html eve_lineset.png
6 /// \macro_code
7 ///
8 /// \author Matevz Tadel
9 
10 TEveStraightLineSet* lineset(Int_t nlines = 40, Int_t nmarkers = 4)
11 {
13 
14  TRandom r(0);
15  Float_t s = 100;
16 
18 
19  for(Int_t i = 0; i<nlines; i++)
20  {
21  ls->AddLine( r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s),
22  r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
23  // add random number of markers
24  Int_t nm = Int_t(nmarkers* r.Rndm());
25  for(Int_t m = 0; m < nm; m++) {
26  ls->AddMarker(i, r.Rndm());
27  }
28  }
29 
30  ls->SetMarkerSize(1.5);
31  ls->SetMarkerStyle(4);
32 
33  gEve->AddElement(ls);
34  gEve->Redraw3D();
35 
36  return ls;
37 }
38 
39 TEveStraightLineSet* lineset_2d(Int_t nlines = 40, Int_t nmarkers = 4)
40 {
42 
43  TRandom r(0);
44  Float_t s = 100;
45 
47 
48  for(Int_t i = 0; i<nlines; i++)
49  {
50  ls->AddLine( r.Uniform(-s,s), r.Uniform(-s,s), 0,
51  r.Uniform(-s,s), r.Uniform(-s,s), 0);
52  // add random number of markers
53  Int_t nm = Int_t(nmarkers* r.Rndm());
54  for(Int_t m = 0; m < nm; m++) {
55  ls->AddMarker(i, r.Rndm());
56  }
57  }
58 
59  ls->SetMarkerSize(1.5);
60  ls->SetMarkerStyle(4);
61 
62  gEve->AddElement(ls);
63  gEve->Redraw3D();
64 
65  return ls;
66 }
auto * m
Definition: textangle.C:8
float Float_t
Definition: RtypesCore.h:53
int Int_t
Definition: RtypesCore.h:41
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
def lineset(nlines=40, nmarkers=4)
Definition: lineset.py:7
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
ROOT::R::TRInterface & r
Definition: Object.C:4
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
static constexpr double nm
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
static constexpr double s
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.
Set of straight lines with optional markers along the lines.