ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
projection_prescale.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstates usage pre-scaling for automatic 2D projections.
4 ///
5 /// \image html eve_projection_prescale.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_prescale()
14 {
17 
18  TEveViewer *pev = gEve->SpawnNewViewer("Projections");
19 
20  // camera
21  TEveScene* s = gEve->SpawnNewScene("Projected Geom");
22  pev->AddScene(s);
23 
24  TGLViewer* pgv = pev->GetGLViewer();
27  cam.SetZoomMinMax(0.2, 20);
28 
29  // projections
31  {
33  TEveProjection* p = mng->GetProjection();
34  p->AddPreScaleEntry(0, 0, 4); // r scale 4 from 0
35  p->AddPreScaleEntry(0, 45, 1); // r scale 1 from 45
36  p->AddPreScaleEntry(0, 310, 0.5);
38  }
39  {
41  TEveProjection* p = mng->GetProjection();
42  // Increase silicon tracker
43  p->AddPreScaleEntry(0, 0, 4); // rho scale 4 from 0
44  p->AddPreScaleEntry(1, 0, 4); // z scale 4 from 0
45  // Normal for TPC
46  p->AddPreScaleEntry(0, 45, 1); // rho scale 1 from 45
47  p->AddPreScaleEntry(1, 110, 1); // z scale 1 from 110
48  // Reduce the rest
49  p->AddPreScaleEntry(0, 310, 0.5);
50  p->AddPreScaleEntry(1, 250, 0.5);
52  }
54  s->AddElement(mng);
55 
56  TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
57  s->AddElement(axes);
58  gEve->AddToListTree(axes, kTRUE);
59  gEve->AddToListTree(mng, kTRUE);
60 
61  // Simple geometry
62  TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
63  if (!geom)
64  return;
65 
66  TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
68  geom->Close();
69  delete geom;
70  gEve->AddGlobalElement(gsre);
71  mng->ImportElements(gsre);
72 
73  TEveLine* line = new TEveLine;
74  line->SetMainColor(kGreen);
75  for (Int_t i=0; i<160; ++i)
76  line->SetNextPoint(120*sin(0.2*i), 120*cos(0.2*i), 80-i);
77  gEve->AddElement(line);
78  mng->ImportElements(line);
79  line->SetRnrSelf(kFALSE);
80 
81 
82  //-------------------------------------------------------------------------
83  // Scaled 3D "projection"
84  //-------------------------------------------------------------------------
85 
86  TEveViewer *sev = gEve->SpawnNewViewer("Scaled 3D");
87  TEveProjectionManager* smng =
89  TEveProjection* sp = smng->GetProjection();
90  sp->SetUsePreScale(kTRUE);
91  sp->AddPreScaleEntry(2, 0, 1);
92  sp->AddPreScaleEntry(2, 100, 0.2);
93 
94  TEveScene* ss = gEve->SpawnNewScene("Scaled Geom");
95  sev->AddScene(ss);
96  ss->AddElement(smng);
97 
98  smng->ImportElements(gsre);
99 
100  //-------------------------------------------------------------------------
101 
102  gEve->GetBrowser()->GetTabRight()->SetTab(1);
103 
104  gEve->Redraw3D(kTRUE);
105 }
Globally positioned TGeoShape with rendering attributes and an optional list of daughter shape-extrac...
Eve representation of TGLScene.
Definition: TEveScene.h:26
An arbitrary polyline with fixed line and marker attributes.
Definition: TEveLine.h:24
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=0)
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
Definition: Rtypes.h:61
Axes for non-linear projections.
void SetUsePreScale(Bool_t x)
double cos(double)
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3851
TGLViewer * GetGLViewer() const
Definition: TEveViewer.h:51
virtual TEveElement * ImportElements(TEveElement *el, TEveElement *ext_list=0)
Recursively import elements and apply projection to the newly imported objects.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Base-class for non-linear projections.
double sin(double)
Manager class for steering of projections and managing projected objects.
void SetZoomMinMax(Double_t min, Double_t max)
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition: TGTab.cxx:507
TGLCamera & CurrentCamera() const
Definition: TGLViewer.h:267
TEveViewer * SpawnNewViewer(const char *name, const char *title="", Bool_t embed=kTRUE)
Create a new GL viewer.
virtual Bool_t SetRnrSelf(Bool_t rnr)
Set render state of this element, i.e.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
virtual void AddElement(TEveElement *el)
Add el to the list of children.
virtual void SetMainColor(Color_t color)
Set main color of the element.
TEveProjection * GetProjection()
virtual Int_t SetNextPoint(Double_t x, Double_t y, Double_t z)
Set point following LastPoint to x, y, z.
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1779
Orthographic projection camera.
void SetProjection(TEveProjection::EPType_e type)
Set projection type and distortion.
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4371
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
Definition: TEveGeoShape.h:23
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
const Bool_t kTRUE
Definition: Rtypes.h:91
static TEveGeoShape * ImportShapeExtract(TEveGeoShapeExtract *gse, TEveElement *parent=0)
Import a shape extract 'gse' under element 'parent'.
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
Eve representation of TGLViewer.
Definition: TEveViewer.h:30
void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale)
Add new scaling range for given coordinate.
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898
virtual void AddScene(TEveScene *scene)
Add 'scene' to the list of scenes.
Definition: TEveViewer.cxx:261