Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
10const char* esd_geom_file_name =
11 "http://root.cern/files/alice_ESDgeometry.root";
12
13void projection()
14{
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
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}
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
@ kGreen
Definition Rtypes.h:66
R__EXTERN TEveManager * gEve
Int_t i
Globally positioned TGeoShape with rendering attributes and an optional list of daughter shape-extrac...
static TEveGeoShape * ImportShapeExtract(TEveGeoShapeExtract *gse, TEveElement *parent=nullptr)
Import a shape extract 'gse' under element 'parent'.
An arbitrary polyline with fixed line and marker attributes.
Definition TEveLine.h:26
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Axes for non-linear projections.
Manager class for steering of projections and managing projected objects.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4110
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4647
Orthographic projection camera.
void SetZoomMinMax(Double_t min, Double_t max)
@ kCameraOrthoXOY
Definition TGLViewer.h:62
TLine * line
RVec< PromoteType< T > > cos(const RVec< T > &v)
Definition RVec.hxx:1853
RVec< PromoteType< T > > sin(const RVec< T > &v)
Definition RVec.hxx:1852