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 = "http://root.cern/files/alice_ESDgeometry.root";
11
12void projection()
13{
16
17 // camera
18 auto s = gEve->SpawnNewScene("Projected Event");
19 gEve->GetDefaultViewer()->AddScene(s);
20 auto v = gEve->GetDefaultGLViewer();
21 v->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
22 TGLOrthoCamera &cam = (TGLOrthoCamera &)v->CurrentCamera();
23 cam.SetZoomMinMax(0.2, 20);
24
25 // projections
27 s->AddElement(mng);
28 auto axes = new TEveProjectionAxes(mng);
29 axes->SetTitle("TEveProjections demo");
30 s->AddElement(axes);
31 gEve->AddToListTree(axes, kTRUE);
32 gEve->AddToListTree(mng, kTRUE);
33
34 // Simple geometry
35 auto geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
36 if (!geom)
37 return;
38
39 auto gse = (TEveGeoShapeExtract *)geom->Get("Gentle");
40 auto gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
41 geom->Close();
42 delete geom;
43 gsre->SetPickableRecursively(kTRUE);
44 gEve->AddGlobalElement(gsre);
45 gEve->GetGlobalScene()->SetRnrState(kFALSE);
46 mng->ImportElements(gsre);
47
48 auto line = new TEveLine;
49 line->SetMainColor(kGreen);
50 for (Int_t i = 0; i < 160; ++i)
51 line->SetNextPoint(120 * sin(0.2 * i), 120 * cos(0.2 * i), 80 - i);
52 gEve->AddElement(line);
53 mng->ImportElements(line);
54 line->SetRnrSelf(kFALSE);
55
56 gEve->Redraw3D(kTRUE);
57}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kGreen
Definition Rtypes.h:67
externTEveManager * gEve
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:3787
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:4328
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:1848
RVec< PromoteType< T > > sin(const RVec< T > &v)
Definition RVec.hxx:1847