Project
Loading...
Searching...
No Matches
MultiView.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
17
22
23#include <TBrowser.h>
24#include <TEveBrowser.h>
25#include <TEveManager.h>
26#include <TEveProjectionAxes.h>
27#include <TEveProjectionManager.h>
28#include <TEveWindowManager.h>
29
30#include <fairlogger/Logger.h>
31
32using namespace std;
33
34namespace o2
35{
36namespace event_visualisation
37{
38
39MultiView* MultiView::sInstance = nullptr;
40
41MultiView::MultiView()
42{
43 // set scene names and descriptions
44 mSceneNames[Scene3dGeom] = "3D Geometry Scene";
45 mSceneNames[SceneRphiGeom] = "R-Phi Geometry Scene";
46 mSceneNames[SceneZYGeom] = "Z-Y Geometry Scene";
47 mSceneNames[Scene3dEvent] = "3D Event Scene";
48 mSceneNames[SceneRphiEvent] = "R-Phi Event Scene";
49 mSceneNames[SceneZYEvent] = "Z-Y Event Scene";
50
51 mSceneDescriptions[Scene3dGeom] = "Scene holding 3D geometry.";
52 mSceneDescriptions[SceneRphiGeom] = "Scene holding projected geometry for the R-Phi view.";
53 mSceneDescriptions[SceneZYGeom] = "Scene holding projected geometry for the Z-Y view.";
54 mSceneDescriptions[Scene3dEvent] = "Scene holding 3D event.";
55 mSceneDescriptions[SceneRphiEvent] = "Scene holding projected event for the R-Phi view.";
56 mSceneDescriptions[SceneZYEvent] = "Scene holding projected event for the Z-Y view.";
57
58 // spawn scenes
59 mScenes[Scene3dGeom] = gEve->GetGlobalScene();
60 mScenes[Scene3dGeom]->SetNameTitle(mSceneNames[Scene3dGeom].c_str(), mSceneDescriptions[Scene3dGeom].c_str());
61
62 mScenes[Scene3dEvent] = gEve->GetEventScene();
63 mScenes[Scene3dEvent]->SetNameTitle(mSceneNames[Scene3dEvent].c_str(), mSceneDescriptions[Scene3dEvent].c_str());
64
65 for (int i = SceneRphiGeom; i < NumberOfScenes; ++i) {
66 mScenes[i] = gEve->SpawnNewScene(mSceneNames[i].c_str(), mSceneDescriptions[i].c_str());
67 }
68
69 // remove window manager from the list
70 gEve->GetWindowManager()->RemoveFromListTree(gEve->GetListTree(), nullptr);
71
72 // Projection managers
73 mProjections[ProjectionRphi] = new TEveProjectionManager();
74 mProjections[ProjectionZY] = new TEveProjectionManager();
75
76 mProjections[ProjectionRphi]->SetProjection(TEveProjection::kPT_RPhi);
77 mProjections[ProjectionZY]->SetProjection(TEveProjection::kPT_ZY);
78
79 // open scenes
80 gEve->GetScenes()->FindListTreeItem(gEve->GetListTree())->SetOpen(true);
81
82 // add axes
83 const bool showAxes = ConfigurationManager::getAxesShow();
84
85 if (showAxes) {
86 for (int i = 0; i < NumberOfProjections; ++i) {
87 TEveProjectionAxes axes(mProjections[static_cast<EProjections>(i)]);
88 axes.SetMainColor(kWhite);
89 axes.SetTitle("R-Phi");
90 axes.SetTitleSize(0.05);
91 axes.SetTitleFont(102);
92 axes.SetLabelSize(0.025);
93 axes.SetLabelFont(102);
94 mScenes[getSceneOfProjection(static_cast<EProjections>(i))]->AddElement(&axes);
95 }
96 }
97 setupMultiview();
98 sInstance = this;
99}
100
101MultiView::~MultiView()
102{
104}
105
107{
108 if (!sInstance) {
109 new MultiView();
110 }
111 return sInstance;
112}
113
114void MultiView::setupMultiview()
115{
116 // Split window in packs for 3D and projections, create viewers and add scenes to them
117 TEveWindowSlot* slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
118 TEveWindowPack* pack = slot->MakePack();
119
120 pack->SetElementName("Multi View");
121 pack->SetHorizontal();
122 pack->SetShowTitleBar(kFALSE);
123 pack->NewSlotWithWeight(2)->MakeCurrent(); // new slot is created from pack
124
125 mViews[View3d] = gEve->SpawnNewViewer("3D View", "");
126 mViews[View3d]->AddScene(mScenes[Scene3dGeom]);
127 mViews[View3d]->AddScene(mScenes[Scene3dEvent]);
128
129 pack = pack->NewSlot()->MakePack();
130 pack->SetNameTitle("2D Views", "");
131 pack->SetShowTitleBar(kFALSE);
132 pack->NewSlot()->MakeCurrent();
133 mViews[ViewRphi] = gEve->SpawnNewViewer("R-Phi View", "");
134 mViews[ViewRphi]->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
135 mViews[ViewRphi]->AddScene(mScenes[SceneRphiGeom]);
136 mViews[ViewRphi]->AddScene(mScenes[SceneRphiEvent]);
137
138 pack->NewSlot()->MakeCurrent();
139 mViews[ViewZY] = gEve->SpawnNewViewer("Z-Y View", "");
140 mViews[ViewZY]->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
141 mViews[ViewZY]->AddScene(mScenes[SceneZYGeom]);
142 mViews[ViewZY]->AddScene(mScenes[SceneZYEvent]);
143
144 mAnnotationTop = std::make_unique<TGLAnnotation>(mViews[View3d]->GetGLViewer(), "", 0, 1.0);
145 mAnnotationTop->SetState(TGLOverlayElement::kDisabled); // make the annotation non-interactive
146 mAnnotationTop->SetUseColorSet(false); // make the colors individually changeable
147 mAnnotationTop->SetTextColor(0); // default color white
148 mAnnotationTop->SetTextSize(0.05f);
149
150 mAnnotationBottom = std::make_unique<TGLAnnotation>(mViews[View3d]->GetGLViewer(), "", 0, 0.07);
151 mAnnotationBottom->SetState(TGLOverlayElement::kDisabled);
152 mAnnotationBottom->SetUseColorSet(false);
153 mAnnotationBottom->SetTextColor(0);
154 mAnnotationBottom->SetTextSize(0.03f);
155}
156
157MultiView::EScenes MultiView::getSceneOfProjection(EProjections projection)
158{
159 if (projection == ProjectionRphi) {
160 return SceneRphiGeom;
161 } else if (projection == ProjectionZY) {
162 return SceneZYGeom;
163 }
164 return NumberOfScenes;
165}
166
167TEveGeoShape* MultiView::getDetectorGeometry(const std::string& detectorName)
168{
169 for (const auto& geom : mDetectors) {
170 if (geom->GetElementName() == detectorName) {
171 return geom;
172 }
173 }
174
175 return nullptr;
176}
177
178void MultiView::drawGeometryForDetector(string detectorName, bool threeD, bool rPhi, bool zy)
179{
180 auto& geometryManager = GeometryManager::getInstance();
181 TEveGeoShape* shape = geometryManager.getGeometryForDetector(detectorName);
182 registerGeometry(shape, threeD, rPhi, zy);
183 mDetectors.push_back(shape);
184}
185
186void MultiView::registerGeometry(TEveGeoShape* geom, bool threeD, bool rPhi, bool zy)
187{
188 if (!geom) {
189 LOGF(error, "MultiView::registerGeometry -- geometry is NULL!");
190 exit(-1);
191 }
192 TEveProjectionManager* projection;
193
194 if (threeD) {
195 gEve->AddElement(geom, getScene(Scene3dGeom));
196 }
197 if (rPhi) {
198 projection = getProjection(ProjectionRphi);
199 projection->SetCurrentDepth(-10);
200 projection->ImportElements(geom, getScene(SceneRphiGeom));
201 projection->SetCurrentDepth(0);
202 }
203 if (zy) {
204 projection = getProjection(ProjectionZY);
205 projection->SetCurrentDepth(-10);
206 projection->ImportElements(geom, getScene(SceneZYGeom));
207 projection->SetCurrentDepth(0);
208 }
209}
210
212{
213 // for (unsigned int i = 0; i < mGeomVector.size(); ++i) {
214 // if (mGeomVector[i]) {
215 // mGeomVector[i]->DestroyElements();
216 // gEve->RemoveElement(mGeomVector[i], getScene(Scene3dGeom));
217 // mGeomVector[i] = nullptr;
218 // }
219 // }
220 getScene(Scene3dGeom)->DestroyElements();
221 getScene(SceneRphiGeom)->DestroyElements();
222 getScene(SceneZYGeom)->DestroyElements();
223 mDetectors.clear();
224}
225
226void MultiView::registerElements(TEveElementList* elements[], TEveElementList* phiElements[])
227{
228 for (auto dataType = 0; dataType < EVisualisationDataType::NdataTypes; ++dataType) {
229 TEveElement* event = elements[dataType];
230 gEve->GetCurrentEvent()->AddElement(event);
232 }
233 for (auto dataType = 0; dataType < EVisualisationDataType::NdataTypes; ++dataType) {
234 TEveElement* event = phiElements[dataType];
236 }
237}
238
240{
241 // version which do not remove MFT, MID, MCH in Rphi view
242 gEve->GetCurrentEvent()->AddElement(event);
245}
246
248{
249 if (gEve->GetCurrentEvent()) {
250 gEve->GetCurrentEvent()->RemoveElements();
251 }
252 getScene(SceneRphiEvent)->DestroyElements();
253 getScene(SceneZYEvent)->DestroyElements();
254}
255
257{
258 gEve->Redraw3D();
259}
260
261} // namespace event_visualisation
262} // namespace o2
int32_t i
static GeometryManager & getInstance()
Returns an instance of GeometryManager.
@ SceneZYEvent
Z-Y scene of event.
Definition MultiView.h:57
@ SceneZYGeom
Z-Y scene of geometry.
Definition MultiView.h:55
@ SceneRphiGeom
R-Phi scene of geometry.
Definition MultiView.h:54
@ SceneRphiEvent
R-Phi scene of event.
Definition MultiView.h:56
@ NumberOfScenes
Total number of scenes.
Definition MultiView.h:58
@ Scene3dGeom
3D scene of geometry
Definition MultiView.h:52
@ Scene3dEvent
3D scene of event
Definition MultiView.h:53
static MultiView * getInstance()
Returns an instance of the MultiView.
void drawGeometryForDetector(std::string detectorName, bool threeD=true, bool rPhi=true, bool zy=true)
void registerElements(TEveElementList *elements[], TEveElementList *phiElements[])
Registers an elements to be drawn.
void destroyAllEvents()
Removes all shapes representing current event.
@ NumberOfProjections
Total number of projections.
Definition MultiView.h:63
@ ProjectionRphi
R-Phi projection.
Definition MultiView.h:61
TEveProjectionManager * getProjection(EProjections projection)
Returns pointer to specific projection manager.
Definition MultiView.h:74
TEveGeoShape * getDetectorGeometry(const std::string &detectorName)
void registerElement(TEveElement *event)
Registers an element to be drawn.
TEveScene * getScene(EScenes scene)
Returns pointer to specific scene.
Definition MultiView.h:72
void registerGeometry(TEveGeoShape *geom, bool threeD=true, bool rPhi=true, bool zy=true)
Registers geometry to be drawn in appropriate views.
void destroyAllGeometries()
Removes all geometries.
struct _cl_event * event
Definition glcorearb.h:2982
@ NdataTypes
number of supported data types
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.