Comment-out Paint() also in the header file.
[u/mrichter/AliRoot.git] / EVE / macros / MultiView.C
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
25 class MultiView
26 {
27 public:
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       ImportGeomRPhi(fGeomGentleRPhi);
140       ImportGeomRhoZ(fGeomGentleRhoZ);
141    }
142
143    void InitGeomGentleTrd(TEveGeoShape* gtrd)
144    {
145       fGeomGentleTrd = gtrd;
146       ImportGeomRPhi(fGeomGentleTrd);
147       ImportGeomRhoZ(fGeomGentleTrd);
148    }
149
150    void InitGeomGentleMuon(TEveGeoShape* gmuon, Bool_t showRPhi, Bool_t showRhoZ)
151    {
152       fGeomGentleMuon = gmuon;
153       if (showRPhi) ImportGeomRPhi(fGeomGentleMuon);
154       if (showRhoZ) ImportGeomRhoZ(fGeomGentleMuon);
155    }
156
157    //-------------------------------------------------------------------------
158
159    void SetDepth(Float_t d)
160    {
161       fRPhiMgr->SetCurrentDepth(d);
162       fRhoZMgr->SetCurrentDepth(d);
163    }
164
165    //-------------------------------------------------------------------------
166
167    void ImportGeomRPhi(TEveElement* el)
168    { 
169       fRPhiMgr->ImportElements(el, fRPhiGeomScene);
170    }
171
172    void ImportGeomRhoZ(TEveElement* el)
173    { 
174       fRhoZMgr->ImportElements(el, fRhoZGeomScene);
175    }
176
177    void ImportEventRPhi(TEveElement* el)
178    { 
179       fRPhiMgr->ImportElements(el, fRPhiEventScene);
180    }
181
182    void ImportEventRhoZ(TEveElement* el)
183    { 
184       fRhoZMgr->ImportElements(el, fRhoZEventScene);
185    }
186
187    void DestroyEventRPhi()
188    {
189       fRPhiEventScene->DestroyElements();
190    }
191
192    void DestroyEventRhoZ()
193    {
194       fRhoZEventScene->DestroyElements();
195    }
196
197    void SetCenterRPhi(Double_t x, Double_t y, Double_t z)
198    {
199       fRPhiMgr->SetCenter(x, y, z);
200    }
201
202    void SetCenterRhoZ(Double_t x, Double_t y, Double_t z)
203    {
204       fRhoZMgr->SetCenter(x, y, z);
205    }
206 };
207
208 MultiView *gMultiView = 0;