Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 {
12  TEveManager::Create();
13 
14  TRandom r(0);
15  Float_t s = 100;
16 
17  auto ls = new TEveStraightLineSet();
18 
19  for (Int_t i = 0; i<nlines; i++) {
20  ls->AddLine( r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s),
21  r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
22  // add random number of markers
23  Int_t nm = Int_t(nmarkers* r.Rndm());
24  for (Int_t m = 0; m < nm; m++) ls->AddMarker(i, r.Rndm());
25  }
26 
27  ls->SetMarkerSize(1.5);
28  ls->SetMarkerStyle(4);
29 
30  gEve->AddElement(ls);
31  gEve->Redraw3D();
32 
33  return ls;
34 }
35 
36 TEveStraightLineSet* lineset_2d(Int_t nlines = 40, Int_t nmarkers = 4)
37 {
38  TEveManager::Create();
39 
40  TRandom r(0);
41  Float_t s = 100;
42 
43  auto ls = new TEveStraightLineSet();
44 
45  for (Int_t i = 0; i<nlines; i++) {
46  ls->AddLine( r.Uniform(-s,s), r.Uniform(-s,s), 0,
47  r.Uniform(-s,s), r.Uniform(-s,s), 0);
48  // add random number of markers
49  Int_t nm = Int_t(nmarkers* r.Rndm());
50  for (Int_t m = 0; m < nm; m++) ls->AddMarker(i, r.Rndm());
51  }
52 
53  ls->SetMarkerSize(1.5);
54  ls->SetMarkerStyle(4);
55 
56  gEve->AddElement(ls);
57  gEve->Redraw3D();
58 
59  return ls;
60 }