Logo ROOT   6.14/05
Reference Guide
compound.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of EVE compound objects - class TEveCompound.
4 ///
5 /// \image html eve_compound.png
6 /// \macro_code
7 ///
8 /// \author Matevz Tadel
9 
10 TEveLine* random_line(TRandom& rnd, Int_t n, Float_t delta)
11 {
12  TEveLine* line = new TEveLine;
13  line->SetMainColor(kGreen);
14 
15  Float_t x = 0, y = 0, z = 0;
16  for (Int_t i=0; i<n; ++i)
17  {
18  line->SetNextPoint(x, y, z);
19  x += rnd.Uniform(0, delta);
20  y += rnd.Uniform(0, delta);
21  z += rnd.Uniform(0, delta);
22  }
23 
24  return line;
25 }
26 
27 void compound()
28 {
30 
31  TEveLine* ml = new TEveLine;
32  ml->SetMainColor(kRed);
33  ml->SetLineStyle(2);
34  ml->SetLineWidth(3);
35  gEve->InsertVizDBEntry("BigLine", ml);
36 
37  TEveCompound* cmp = new TEveCompound;
38  cmp->SetMainColor(kGreen);
39  gEve->AddElement(cmp);
40 
41  TRandom rnd(0);
42 
43  cmp->OpenCompound();
44 
45  cmp->AddElement(random_line(rnd, 20, 10));
46  cmp->AddElement(random_line(rnd, 20, 10));
47 
48  TEveLine* line = random_line(rnd, 20, 12);
49  line->ApplyVizTag("BigLine");
50  cmp->AddElement(line);
51 
52  cmp->CloseCompound();
53 
54  // Projected view
55  TEveViewer *viewer = gEve->SpawnNewViewer("Projected");
56  TEveScene *scene = gEve->SpawnNewScene("Projected Event");
57  viewer->AddScene(scene);
58  {
59  TGLViewer* v = viewer->GetGLViewer();
61  }
62 
63  // projections
65  scene->AddElement(mng);
66  TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
67  scene->AddElement(axes);
68  gEve->AddToListTree(axes, kTRUE);
69  gEve->AddToListTree(mng, kTRUE);
70 
71  mng->ImportElements(cmp);
72 
74 }
Eve representation of TGLScene.
Definition: TEveScene.h:26
TLine * line
float Float_t
Definition: RtypesCore.h:53
Definition: Rtypes.h:59
An arbitrary polyline with fixed line and marker attributes.
Definition: TEveLine.h:24
virtual void AddElement(TEveElement *el)
Call base-class implementation.
int Int_t
Definition: RtypesCore.h:41
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:59
Axes for non-linear projections.
virtual void SetLineStyle(Style_t lstyle)
Set line-style of the line.
Definition: TEveLine.cxx:86
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
Description of TEveCompound.
Definition: TEveCompound.h:23
Double_t x[n]
Definition: legend1.C:17
virtual TEveElement * ImportElements(TEveElement *el, TEveElement *ext_list=0)
Recursively import elements and apply projection to the newly imported objects.
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Manager class for steering of projections and managing projected objects.
virtual void SetMainColor(Color_t color)
SetMainColor for the compound.
SVector< double, 2 > v
Definition: Dict.h:5
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void SetLineWidth(Width_t lwidth)
Set line-style of the line.
Definition: TEveLine.cxx:106
TEveViewer * SpawnNewViewer(const char *name, const char *title="", Bool_t embed=kTRUE)
Create a new GL viewer.
void CloseCompound()
Definition: TEveCompound.h:38
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.
virtual Int_t SetNextPoint(Double_t x, Double_t y, Double_t z)
Set point following LastPoint to x, y, z.
TGLViewer * GetGLViewer() const
Definition: TEveViewer.h:51
Double_t y[n]
Definition: legend1.C:17
void SetCurrentCamera(ECameraType camera)
Set current active camera - &#39;cameraType&#39; one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1794
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:627
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Bool_t ApplyVizTag(const TString &tag, const TString &fallback_tag="")
Set the VizTag, find model-element from the VizDB and copy visualization-parameters from it...
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
Bool_t InsertVizDBEntry(const TString &tag, TEveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
void OpenCompound()
Definition: TEveCompound.h:37
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
Eve representation of TGLViewer.
Definition: TEveViewer.h:30
virtual void AddScene(TEveScene *scene)
Add &#39;scene&#39; to the list of scenes.
Definition: TEveViewer.cxx:261