Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
compound.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of EVE compound objects - class TEveCompound.
4 ///
5 /// \image html eve_compound.png
6 /// \macro_code
7 ///
8 /// \author Matevz Tadel
9 
10 TEveLine* random_line(TRandom& rnd, Int_t n, Float_t delta)
11 {
12  auto line = new TEveLine;
13  line->SetMainColor(kGreen);
14 
15  Float_t x = 0, y = 0, z = 0;
16  for (Int_t i=0; i<n; ++i) {
17  line->SetNextPoint(x, y, z);
18  x += rnd.Uniform(0, delta);
19  y += rnd.Uniform(0, delta);
20  z += rnd.Uniform(0, delta);
21  }
22 
23  return line;
24 }
25 
26 void compound()
27 {
28  TEveManager::Create();
29 
30  auto ml = new TEveLine;
31  ml->SetMainColor(kRed);
32  ml->SetLineStyle(2);
33  ml->SetLineWidth(3);
34  gEve->InsertVizDBEntry("BigLine", ml);
35 
36  auto cmp = new TEveCompound;
37  cmp->SetMainColor(kGreen);
38  gEve->AddElement(cmp);
39 
40  TRandom rnd(0);
41 
42  cmp->OpenCompound();
43 
44  cmp->AddElement(random_line(rnd, 20, 10));
45  cmp->AddElement(random_line(rnd, 20, 10));
46 
47  auto line = random_line(rnd, 20, 12);
48  line->ApplyVizTag("BigLine");
49  cmp->AddElement(line);
50 
51  cmp->CloseCompound();
52 
53  // Projected view
54  auto viewer = gEve->SpawnNewViewer("Projected");
55  auto scene = gEve->SpawnNewScene("Projected Event");
56  viewer->AddScene(scene);
57  {
58  auto v = viewer->GetGLViewer();
59  v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
60  }
61 
62  // projections
63  auto mng = new TEveProjectionManager(TEveProjection::kPT_RPhi);
64  scene->AddElement(mng);
65  auto axes = new TEveProjectionAxes(mng);
66  scene->AddElement(axes);
67  gEve->AddToListTree(axes, kTRUE);
68  gEve->AddToListTree(mng, kTRUE);
69 
70  mng->ImportElements(cmp);
71 
72  gEve->Redraw3D(kTRUE);
73 }