projection.C

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: projection.C 37560 2010-12-13 12:28:23Z matevz $
00002 // Author: Matevz Tadel
00003 
00004 // Demonstates usage of automatic 2D projections - class TEveProjectionManager.
00005 
00006 const char* esd_geom_file_name =
00007    "http://root.cern.ch/files/alice_ESDgeometry.root";
00008 
00009 void projection()
00010 {
00011    TFile::SetCacheFileDir(".");
00012    TEveManager::Create();
00013 
00014    // camera
00015    TEveScene* s = gEve->SpawnNewScene("Projected Event");
00016    gEve->GetDefaultViewer()->AddScene(s);
00017    TGLViewer* v = gEve->GetDefaultGLViewer();
00018    v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00019    TGLOrthoCamera* cam = (TGLOrthoCamera*) v->CurrentCamera();
00020    cam->SetZoomMinMax(0.2, 20);
00021 
00022    // projections
00023    TEveProjectionManager* mng =
00024       new TEveProjectionManager(TEveProjection::kPT_RPhi);
00025    s->AddElement(mng);
00026    TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
00027    axes->SetTitle("TEveProjections demo");
00028    s->AddElement(axes);
00029    gEve->AddToListTree(axes, kTRUE);
00030    gEve->AddToListTree(mng, kTRUE);
00031 
00032    // Simple geometry
00033    TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
00034    if (!geom)
00035       return;
00036 
00037    TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
00038    TEveGeoShape* gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
00039    geom->Close();
00040    delete geom;
00041    gEve->AddGlobalElement(gsre);
00042    gEve->GetGlobalScene()->SetRnrState(kFALSE);
00043    mng->ImportElements(gsre);
00044 
00045    TEveLine* line = new TEveLine;
00046    line->SetMainColor(kGreen);
00047    for (Int_t i=0; i<160; ++i)
00048       line->SetNextPoint(120*sin(0.2*i), 120*cos(0.2*i), 80-i);
00049    gEve->AddElement(line);
00050    mng->ImportElements(line);
00051    line->SetRnrSelf(kFALSE);
00052 
00053    gEve->Redraw3D(kTRUE);
00054 }

Generated on Tue Jul 5 15:43:51 2011 for ROOT_528-00b_version by  doxygen 1.5.1