ROOT logo
// @(#)root/eve:$Id: projection_test.C 26876 2008-12-12 14:45:40Z matevz $
// Author: Matevz Tadel

// Demonstates usage of automatic 2D projections - class TEveProjectionManager.

const char* esd_geom_file_name = "http://root.cern.ch/files/alice_ESDgeometry.root";

void projection_test()
{
   TFile::SetCacheFileDir(".");
   TEveManager::Create();

   // camera
   TEveScene* s = gEve->SpawnNewScene("Projected Event");
   gEve->GetDefaultViewer()->AddScene(s);
   TGLViewer* v = gEve->GetDefaultGLViewer();
   v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
   TGLOrthoCamera* cam = (TGLOrthoCamera*) v->CurrentCamera();
   cam->SetZoomMinMax(0.2, 20);

   // projections
   TEveProjectionManager* mng = new TEveProjectionManager();
   s->AddElement(mng);
   TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
   axes->SetTitle("TEveProjections demo");
   s->AddElement(axes);
   gEve->AddToListTree(axes, kTRUE);
   gEve->AddToListTree(mng, kTRUE);

   // Simple geometry
   TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
   if (!geom)
      return;

   TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
   TEveGeoShape* gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
   geom->Close();
   delete geom;
   gEve->AddGlobalElement(gsre);
   gEve->GetGlobalScene()->SetRnrState(kFALSE);
   mng->ImportElements(gsre);

   TEveLine* line = new TEveLine;
   line->SetMainColor(kGreen);
   for (Int_t i=0; i<160; ++i)
      line->SetNextPoint(120*sin(0.2*i), 120*cos(0.2*i), 80-i);
   gEve->AddElement(line);
   mng->ImportElements(line);
   line->SetRnrSelf(kFALSE);

   gEve->Redraw3D(kTRUE);
}
 projection_test.C:1
 projection_test.C:2
 projection_test.C:3
 projection_test.C:4
 projection_test.C:5
 projection_test.C:6
 projection_test.C:7
 projection_test.C:8
 projection_test.C:9
 projection_test.C:10
 projection_test.C:11
 projection_test.C:12
 projection_test.C:13
 projection_test.C:14
 projection_test.C:15
 projection_test.C:16
 projection_test.C:17
 projection_test.C:18
 projection_test.C:19
 projection_test.C:20
 projection_test.C:21
 projection_test.C:22
 projection_test.C:23
 projection_test.C:24
 projection_test.C:25
 projection_test.C:26
 projection_test.C:27
 projection_test.C:28
 projection_test.C:29
 projection_test.C:30
 projection_test.C:31
 projection_test.C:32
 projection_test.C:33
 projection_test.C:34
 projection_test.C:35
 projection_test.C:36
 projection_test.C:37
 projection_test.C:38
 projection_test.C:39
 projection_test.C:40
 projection_test.C:41
 projection_test.C:42
 projection_test.C:43
 projection_test.C:44
 projection_test.C:45
 projection_test.C:46
 projection_test.C:47
 projection_test.C:48
 projection_test.C:49
 projection_test.C:50
 projection_test.C:51
 projection_test.C:52
 projection_test.C:53
thumb