Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
projection.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of automatic 2D projections - class TEveProjectionManager.
4 ///
5 /// \image html eve_projection.png
6 /// \macro_code
7 ///
8 /// \author Matevz Tadel
9 
10 const char* esd_geom_file_name =
11  "http://root.cern.ch/files/alice_ESDgeometry.root";
12 
13 void projection()
14 {
15  TFile::SetCacheFileDir(".");
16  TEveManager::Create();
17 
18  // camera
19  auto s = gEve->SpawnNewScene("Projected Event");
20  gEve->GetDefaultViewer()->AddScene(s);
21  auto v = gEve->GetDefaultGLViewer();
22  v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
23  TGLOrthoCamera& cam = (TGLOrthoCamera&) v->CurrentCamera();
24  cam.SetZoomMinMax(0.2, 20);
25 
26  // projections
27  auto mng = new TEveProjectionManager(TEveProjection::kPT_RPhi);
28  s->AddElement(mng);
29  auto axes = new TEveProjectionAxes(mng);
30  axes->SetTitle("TEveProjections demo");
31  s->AddElement(axes);
32  gEve->AddToListTree(axes, kTRUE);
33  gEve->AddToListTree(mng, kTRUE);
34 
35  // Simple geometry
36  auto geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
37  if (!geom)
38  return;
39 
40  auto gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
41  auto gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
42  geom->Close();
43  delete geom;
44  gsre->SetPickableRecursively(kTRUE);
45  gEve->AddGlobalElement(gsre);
46  gEve->GetGlobalScene()->SetRnrState(kFALSE);
47  mng->ImportElements(gsre);
48 
49  auto line = new TEveLine;
50  line->SetMainColor(kGreen);
51  for (Int_t i=0; i<160; ++i)
52  line->SetNextPoint(120*sin(0.2*i), 120*cos(0.2*i), 80-i);
53  gEve->AddElement(line);
54  mng->ImportElements(line);
55  line->SetRnrSelf(kFALSE);
56 
57  gEve->Redraw3D(kTRUE);
58 }