* EVE/macros/alieve_online.C
[u/mrichter/AliRoot.git] / EVE / macros / MultiView.C
CommitLineData
3545fba9 1// Multi-view (3d, rphi, rhoz) service class using EVE Window Manager.
2// Author: Matevz Tadel 2009
3
4#include <TEveManager.h>
5
6#include <TEveViewer.h>
7#include <TGLViewer.h>
8
9#include <TEveScene.h>
10#include <TEveGeoShape.h>
11
12#include <TEveProjectionManager.h>
13#include <TEveProjectionAxes.h>
14
15#include <TEveBrowser.h>
16#include <TEveWindow.h>
17
18// MultiView
19//
20// Structure encapsulating standard views: 3D, r-phi and rho-z.
21// Includes scenes and projection managers.
22//
23// Should be used in compiled mode.
24
25class MultiView
26{
27public:
28 TEveProjectionManager *fRPhiMgr;
29 TEveProjectionManager *fRhoZMgr;
30
31 TEveViewer *f3DView;
32 TEveViewer *fRPhiView;
33 TEveViewer *fRhoZView;
34
35 TEveScene *fRPhiGeomScene;
36 TEveScene *fRhoZGeomScene;
37 TEveScene *fRPhiEventScene;
38 TEveScene *fRhoZEventScene;
39
40 TEveGeoShape *fGeomGentle;
41 TEveGeoShape *fGeomGentleRPhi;
42 TEveGeoShape *fGeomGentleRhoZ;
43 TEveGeoShape *fGeomGentleTrd;
44 TEveGeoShape *fGeomGentleMuon;
45
46 //-------------------------------------------------------------------------
47
48 MultiView() :
49 fGeomGentle(0), fGeomGentleRPhi(0), fGeomGentleRhoZ(0),
50 fGeomGentleTrd(0), fGeomGentleMuon(0)
51 {
52 // Constructor --- creates required scenes, projection managers
53 // and GL viewers.
54
55 // Scenes
56 //========
57
58 fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",
59 "Scene holding projected geometry for the RPhi view.");
60 fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",
61 "Scene holding projected geometry for the RhoZ view.");
62 fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
63 "Scene holding projected event-data for the RPhi view.");
64 fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
65 "Scene holding projected event-data for the RhoZ view.");
66
67
68 // Projection managers
69 //=====================
70
71 fRPhiMgr = new TEveProjectionManager();
72 fRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);
73 gEve->AddToListTree(fRPhiMgr, kFALSE);
74 {
75 TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
76 a->SetMainColor(kWhite);
77 a->SetTitle("R-Phi");
78 a->SetTitleSize(0.05);
79 a->SetTitleFont(102);
80 a->SetLabelSize(0.025);
81 a->SetLabelFont(102);
82 fRPhiGeomScene->AddElement(a);
83 }
84
85 fRhoZMgr = new TEveProjectionManager();
86 fRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);
87 gEve->AddToListTree(fRhoZMgr, kFALSE);
88 {
89 TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
90 a->SetMainColor(kWhite);
91 a->SetTitle("Rho-Z");
92 a->SetTitleSize(0.05);
93 a->SetTitleFont(102);
94 a->SetLabelSize(0.025);
95 a->SetLabelFont(102);
96 fRhoZGeomScene->AddElement(a);
97 }
98
99
100 // Viewers
101 //=========
102
103 TEveWindowSlot *slot = 0;
104 TEveWindowPack *pack = 0;
105
106 slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
107 pack = slot->MakePack();
108 pack->SetElementName("Multi View");
109 pack->SetHorizontal();
110 pack->SetShowTitleBar(kFALSE);
111 pack->NewSlot()->MakeCurrent();
112 f3DView = gEve->SpawnNewViewer("3D View", "");
113 f3DView->AddScene(gEve->GetGlobalScene());
114 f3DView->AddScene(gEve->GetEventScene());
115
116 pack = pack->NewSlot()->MakePack();
117 pack->SetShowTitleBar(kFALSE);
118 pack->NewSlot()->MakeCurrent();
119 fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
120 fRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
121 fRPhiView->AddScene(fRPhiGeomScene);
122 fRPhiView->AddScene(fRPhiEventScene);
123
124 pack->NewSlot()->MakeCurrent();
125 fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
126 fRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
127 fRhoZView->AddScene(fRhoZGeomScene);
128 fRhoZView->AddScene(fRhoZEventScene);
129 }
130
131 //-------------------------------------------------------------------------
132
133 void InitGeomGentle(TEveGeoShape* g3d, TEveGeoShape* grphi, TEveGeoShape* grhoz)
134 {
135 fGeomGentle = g3d;
136 fGeomGentleRPhi = grphi; fGeomGentleRPhi->IncDenyDestroy();
137 fGeomGentleRhoZ = grhoz; fGeomGentleRhoZ->IncDenyDestroy();
138
139 fRPhiMgr->SetCurrentDepth(-10);
140 ImportGeomRPhi(fGeomGentleRPhi);
141 fRPhiMgr->SetCurrentDepth(0);
142
143 fRhoZMgr->SetCurrentDepth(-10);
144 ImportGeomRhoZ(fGeomGentleRhoZ);
145 fRhoZMgr->SetCurrentDepth(0);
146 }
147
148 void InitGeomGentleTrd(TEveGeoShape* gtrd)
149 {
150 fGeomGentleTrd = gtrd;
151 ImportGeomRPhi(fGeomGentleTrd);
152 ImportGeomRhoZ(fGeomGentleTrd);
153 }
154
155 void InitGeomGentleMuon(TEveGeoShape* gmuon, Bool_t showRPhi, Bool_t showRhoZ)
156 {
157 fGeomGentleMuon = gmuon;
158 if (showRPhi) ImportGeomRPhi(fGeomGentleMuon);
159 if (showRhoZ) ImportGeomRhoZ(fGeomGentleMuon);
160 }
161
162 //-------------------------------------------------------------------------
163
164 void ImportGeomRPhi(TEveElement* el)
165 {
166 fRPhiMgr->ImportElements(el, fRPhiGeomScene);
167 }
168
169 void ImportGeomRhoZ(TEveElement* el)
170 {
171 fRhoZMgr->ImportElements(el, fRhoZGeomScene);
172 }
173
174 void ImportEventRPhi(TEveElement* el)
175 {
176 fRPhiMgr->ImportElements(el, fRPhiEventScene);
177 }
178
179 void ImportEventRhoZ(TEveElement* el)
180 {
181 fRhoZMgr->ImportElements(el, fRhoZEventScene);
182 }
183
184 void DestroyEventRPhi()
185 {
186 fRPhiEventScene->DestroyElements();
187 }
188
189 void DestroyEventRhoZ()
190 {
191 fRhoZEventScene->DestroyElements();
192 }
193
194 void SetCenterRPhi(Double_t x, Double_t y, Double_t z)
195 {
196 fRPhiMgr->SetCenter(x, y, z);
197 }
198
199 void SetCenterRhoZ(Double_t x, Double_t y, Double_t z)
200 {
201 fRhoZMgr->SetCenter(x, y, z);
202 }
203};
204
205MultiView *gMultiView = 0;