DD4hep  1.31.0
Detector Description Toolkit for High Energy Physics
MultiView.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 //==========================================================================
11 
12 #ifndef UTILITYAPPS_SRC_MULTIVIEW_H
13 #define UTILITYAPPS_SRC_MULTIVIEW_H
14 
15 #include <TEveManager.h>
16 #include <TEveViewer.h>
17 #include <TGLViewer.h>
18 
19 #include <TEveScene.h>
20 
21 #include <TEveProjectionManager.h>
22 #include <TEveProjectionAxes.h>
23 
24 #include <TEveBrowser.h>
25 #include <TEveWindow.h>
26 
40 class MultiView {
41 public:
42 
43  TEveProjectionManager *fRPhiMgr;
44  TEveProjectionManager *fRhoZMgr;
45 
46  TEveViewer *f3DView;
47  TEveViewer *fRPhiView;
48  TEveViewer *fRhoZView;
49 
50  TEveScene *fRPhiGeomScene;
51  TEveScene *fRhoZGeomScene;
52  TEveScene *fRPhiEventScene;
53  TEveScene *fRhoZEventScene;
54 
55  //---------------------------------------------------------------------------
56 
57  static MultiView* instance() {
58  static MultiView mw ;
59  return &mw ;
60  }
61 
63 
64  // Constructor --- creates required scenes, projection managers
65  // and GL viewers.
66 
67  // Scenes
68  //========
69 
70  fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",
71  "Scene holding projected geometry for the RPhi view.");
72  fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",
73  "Scene holding projected geometry for the RhoZ view.");
74  fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
75  "Scene holding projected event-data for the RPhi view.");
76  fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
77  "Scene holding projected event-data for the RhoZ view.");
78 
79 
80  // Projection managers
81  //=====================
82 
83  fRPhiMgr = new TEveProjectionManager(TEveProjection::kPT_RPhi);
84  gEve->AddToListTree(fRPhiMgr, kFALSE);
85  {
86  TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
87  a->SetMainColor(kWhite);
88  a->SetTitle("R-Phi");
89  a->SetTitleSize(0.05);
90  a->SetTitleFont(102);
91  a->SetLabelSize(0.025);
92  a->SetLabelFont(102);
93  fRPhiGeomScene->AddElement(a);
94  }
95 
96  fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
97  gEve->AddToListTree(fRhoZMgr, kFALSE);
98  {
99  TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
100  a->SetMainColor(kWhite);
101  a->SetTitle("Rho-Z");
102  a->SetTitleSize(0.05);
103  a->SetTitleFont(102);
104  a->SetLabelSize(0.025);
105  a->SetLabelFont(102);
106  fRhoZGeomScene->AddElement(a);
107  }
108 
109 
110  // Viewers
111  //=========
112 
113  TEveWindowSlot *slot = 0;
114  TEveWindowPack *pack = 0;
115 
116  slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
117  pack = slot->MakePack();
118  pack->SetElementName("Multi View");
119  pack->SetHorizontal();
120  pack->SetShowTitleBar(kFALSE);
121  pack->NewSlot()->MakeCurrent();
122  f3DView = gEve->SpawnNewViewer("3D View", "");
123  f3DView->AddScene(gEve->GetGlobalScene());
124  f3DView->AddScene(gEve->GetEventScene());
125 
126  pack = pack->NewSlot()->MakePack();
127  pack->SetShowTitleBar(kFALSE);
128  pack->NewSlot()->MakeCurrent();
129  fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
130  fRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
131  fRPhiView->AddScene(fRPhiGeomScene);
132  fRPhiView->AddScene(fRPhiEventScene);
133 
134  pack->NewSlot()->MakeCurrent();
135  fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
136  fRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
137  fRhoZView->AddScene(fRhoZGeomScene);
138  fRhoZView->AddScene(fRhoZEventScene);
139 
140 
141  //fg: set white background:
142  f3DView->GetGLViewer()->ColorSet().Background().SetColor(kWhite);
143  fRPhiView->GetGLViewer()->ColorSet().Background().SetColor(kWhite);
144  fRhoZView->GetGLViewer()->ColorSet().Background().SetColor(kWhite);
145  }
146 
147  //---------------------------------------------------------------------------
148 
149  void SetDepth(Float_t d)
150  {
151  // Set current depth on all projection managers.
152 
153  fRPhiMgr->SetCurrentDepth(d);
154  fRhoZMgr->SetCurrentDepth(d);
155  }
156 
157  //---------------------------------------------------------------------------
158 
159  void ImportGeomRPhi(TEveElement* el)
160  {
161  fRPhiMgr->ImportElements(el, fRPhiGeomScene);
162  }
163 
164  void ImportGeomRhoZ(TEveElement* el)
165  {
166  fRhoZMgr->ImportElements(el, fRhoZGeomScene);
167  }
168 
169  void ImportEventRPhi(TEveElement* el)
170  {
171  fRPhiMgr->ImportElements(el, fRPhiEventScene);
172  }
173 
174  void ImportEventRhoZ(TEveElement* el)
175  {
176  fRhoZMgr->ImportElements(el, fRhoZEventScene);
177  }
178 
179 
180  void ImportEvent(TEveElement* el)
181  {
182  gEve->AddElement( el ) ;
183  fRPhiMgr->ImportElements(el, fRPhiEventScene);
184  fRhoZMgr->ImportElements(el, fRhoZEventScene);
185  }
186 
187  //---------------------------------------------------------------------------
188 
190  {
191  fRPhiEventScene->DestroyElements();
192  }
193 
195  {
196  fRhoZEventScene->DestroyElements();
197  }
198 
199 private:
200  MultiView(const MultiView& /* x */)
201  : fRPhiMgr(0), fRhoZMgr(0), f3DView(0), fRPhiView(0), fRhoZView(0),
203  {
204  }
205  MultiView& operator=(const MultiView& /* x */) {
206  fRPhiMgr = 0;
207  fRhoZMgr = 0;
208  f3DView = 0;
209  fRPhiView = 0;
210  fRhoZView = 0;
211  fRPhiGeomScene = 0;
212  fRhoZGeomScene = 0;
213  fRPhiEventScene = 0;
214  fRhoZEventScene = 0;
215  return *this;
216  }
217 };
218 
219 //=====================================================================================
220 
221 
222 
223 #endif
224 
225 
MultiView::fRhoZEventScene
TEveScene * fRhoZEventScene
Definition: MultiView.h:53
MultiView::fRhoZView
TEveViewer * fRhoZView
Definition: MultiView.h:48
MultiView::ImportGeomRhoZ
void ImportGeomRhoZ(TEveElement *el)
Definition: MultiView.h:164
MultiView::DestroyEventRhoZ
void DestroyEventRhoZ()
Definition: MultiView.h:194
MultiView::ImportEventRPhi
void ImportEventRPhi(TEveElement *el)
Definition: MultiView.h:169
MultiView::fRPhiEventScene
TEveScene * fRPhiEventScene
Definition: MultiView.h:52
MultiView
Definition: MultiView.h:40
MultiView::DestroyEventRPhi
void DestroyEventRPhi()
Definition: MultiView.h:189
MultiView::ImportEventRhoZ
void ImportEventRhoZ(TEveElement *el)
Definition: MultiView.h:174
MultiView::fRhoZGeomScene
TEveScene * fRhoZGeomScene
Definition: MultiView.h:51
MultiView::SetDepth
void SetDepth(Float_t d)
Definition: MultiView.h:149
MultiView::fRPhiView
TEveViewer * fRPhiView
Definition: MultiView.h:47
MultiView::MultiView
MultiView()
Definition: MultiView.h:62
MultiView::ImportGeomRPhi
void ImportGeomRPhi(TEveElement *el)
Definition: MultiView.h:159
slot
View TEveWindowSlot * slot
Definition: MultiView.cpp:28
MultiView::instance
static MultiView * instance()
Definition: MultiView.h:57
MultiView::fRPhiGeomScene
TEveScene * fRPhiGeomScene
Definition: MultiView.h:50
MultiView::MultiView
MultiView(const MultiView &)
Definition: MultiView.h:200
MultiView::f3DView
TEveViewer * f3DView
Definition: MultiView.h:46
MultiView::fRhoZMgr
TEveProjectionManager * fRhoZMgr
Definition: MultiView.h:44
MultiView::operator=
MultiView & operator=(const MultiView &)
Definition: MultiView.h:205
MultiView::ImportEvent
void ImportEvent(TEveElement *el)
Definition: MultiView.h:180
MultiView::fRPhiMgr
TEveProjectionManager * fRPhiMgr
Definition: MultiView.h:43