Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
MultiView.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Multi-view (3d, rphi, rhoz) service class using EVE Window Manager.
4 ///
5 /// \macro_code
6 ///
7 /// \author Matevz Tadel
8 
9 #include <TEveManager.h>
10 
11 #include <TEveViewer.h>
12 #include <TGLViewer.h>
13 
14 #include <TEveScene.h>
15 
16 #include <TEveProjectionManager.h>
17 #include <TEveProjectionAxes.h>
18 
19 #include <TEveBrowser.h>
20 #include <TEveWindow.h>
21 
22 // MultiView
23 //
24 // Structure encapsulating standard views: 3D, r-phi and rho-z.
25 // Includes scenes and projection managers.
26 //
27 // Should be used in compiled mode.
28 
29 struct MultiView
30 {
31  TEveProjectionManager *fRPhiMgr;
32  TEveProjectionManager *fRhoZMgr;
33 
34  TEveViewer *f3DView;
35  TEveViewer *fRPhiView;
36  TEveViewer *fRhoZView;
37 
38  TEveScene *fRPhiGeomScene;
39  TEveScene *fRhoZGeomScene;
40  TEveScene *fRPhiEventScene;
41  TEveScene *fRhoZEventScene;
42 
43  //---------------------------------------------------------------------------
44 
45  MultiView()
46  {
47  // Constructor --- creates required scenes, projection managers
48  // and GL viewers.
49 
50  // Scenes
51  //========
52 
53  fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",
54  "Scene holding projected geometry for the RPhi view.");
55  fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",
56  "Scene holding projected geometry for the RhoZ view.");
57  fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
58  "Scene holding projected event-data for the RPhi view.");
59  fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
60  "Scene holding projected event-data for the RhoZ view.");
61 
62 
63  // Projection managers
64  //=====================
65 
66  fRPhiMgr = new TEveProjectionManager(TEveProjection::kPT_RPhi);
67  gEve->AddToListTree(fRPhiMgr, kFALSE);
68  {
69  TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
70  a->SetMainColor(kWhite);
71  a->SetTitle("R-Phi");
72  a->SetTitleSize(0.05);
73  a->SetTitleFont(102);
74  a->SetLabelSize(0.025);
75  a->SetLabelFont(102);
76  fRPhiGeomScene->AddElement(a);
77  }
78 
79  fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
80  gEve->AddToListTree(fRhoZMgr, kFALSE);
81  {
82  TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
83  a->SetMainColor(kWhite);
84  a->SetTitle("Rho-Z");
85  a->SetTitleSize(0.05);
86  a->SetTitleFont(102);
87  a->SetLabelSize(0.025);
88  a->SetLabelFont(102);
89  fRhoZGeomScene->AddElement(a);
90  }
91 
92 
93  // Viewers
94  //=========
95 
96  TEveWindowSlot *slot = 0;
97  TEveWindowPack *pack = 0;
98 
99  slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
100  pack = slot->MakePack();
101  pack->SetElementName("Multi View");
102  pack->SetHorizontal();
103  pack->SetShowTitleBar(kFALSE);
104  pack->NewSlot()->MakeCurrent();
105  f3DView = gEve->SpawnNewViewer("3D View", "");
106  f3DView->AddScene(gEve->GetGlobalScene());
107  f3DView->AddScene(gEve->GetEventScene());
108 
109  pack = pack->NewSlot()->MakePack();
110  pack->SetShowTitleBar(kFALSE);
111  pack->NewSlot()->MakeCurrent();
112  fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
113  fRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
114  fRPhiView->AddScene(fRPhiGeomScene);
115  fRPhiView->AddScene(fRPhiEventScene);
116 
117  pack->NewSlot()->MakeCurrent();
118  fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
119  fRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
120  fRhoZView->AddScene(fRhoZGeomScene);
121  fRhoZView->AddScene(fRhoZEventScene);
122  }
123 
124  //---------------------------------------------------------------------------
125 
126  void SetDepth(Float_t d)
127  {
128  // Set current depth on all projection managers.
129 
130  fRPhiMgr->SetCurrentDepth(d);
131  fRhoZMgr->SetCurrentDepth(d);
132  }
133 
134  //---------------------------------------------------------------------------
135 
136  void ImportGeomRPhi(TEveElement* el)
137  {
138  fRPhiMgr->ImportElements(el, fRPhiGeomScene);
139  }
140 
141  void ImportGeomRhoZ(TEveElement* el)
142  {
143  fRhoZMgr->ImportElements(el, fRhoZGeomScene);
144  }
145 
146  void ImportEventRPhi(TEveElement* el)
147  {
148  fRPhiMgr->ImportElements(el, fRPhiEventScene);
149  }
150 
151  void ImportEventRhoZ(TEveElement* el)
152  {
153  fRhoZMgr->ImportElements(el, fRhoZEventScene);
154  }
155 
156  //---------------------------------------------------------------------------
157 
158  void DestroyEventRPhi()
159  {
160  fRPhiEventScene->DestroyElements();
161  }
162 
163  void DestroyEventRhoZ()
164  {
165  fRhoZEventScene->DestroyElements();
166  }
167 };