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