ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1GeometrySystems
src
VolumeHandleSharedData.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
VP1GeometrySystems/VolumeHandleSharedData.h
"
6
#include "
VP1GeometrySystems/ZappedVolumeListModel.h
"
7
#include "
VP1GeometrySystems/GeoSysController.h
"
8
#include "
VP1Utils/SoVisualizeAction.h
"
9
10
#include "GeoModelKernel/GeoVPhysVol.h"
11
#include "GeoModelKernel/GeoShapeShift.h"
12
13
#include "
VP1HEPVis/nodes/SoGenericBox.h
"
14
#include "
VP1HEPVis/nodes/SoTubs.h
"
15
#include "
VP1HEPVis/nodes/SoPcons.h
"
16
#include "
VP1HEPVis/nodes/SoTessellated.h
"
17
18
#include <Inventor/nodes/SoCylinder.h>
19
#include <Inventor/nodes/SoRotationXYZ.h>
20
#include <Inventor/nodes/SoSeparator.h>
21
22
#include <map>
23
24
//____________________________________________________________________
25
class
VolumeHandleSharedData::Imp
{
26
public
:
27
GeoSysController
*
controller
=
nullptr
;
28
std::map<const GeoLogVol *, SoShape *>
logvol2shape
;
29
std::map<double, SoNode *>
id2shape
;
30
SoVisualizeAction
visaction
;
31
std::map<SoSeparator*,VolumeHandle*>*
sonodesep2volhandle
=
nullptr
;
32
GeoPVConstLink
motherpV
;
33
PhiSectorManager
*
phisectormanager
=
nullptr
;
34
VP1GeoFlags::SubSystemFlag
subsysflag
{};
35
SoMaterial *
topMaterial
=
nullptr
;
36
MatVisAttributes
*
matVisAttributes
=
nullptr
;
37
VolVisAttributes
*
volVisAttributes
=
nullptr
;
38
ZappedVolumeListModel
*
zappedvolumelistmodel
=
nullptr
;
39
int
ref
= 0;
40
};
41
42
//____________________________________________________________________
43
VolumeHandleSharedData::VolumeHandleSharedData
(
GeoSysController
*
controller
,
44
VP1GeoFlags::SubSystemFlag
flag,std::map<SoSeparator*,VolumeHandle*>* sonodesep2volhandle,
45
const
GeoPVConstLink& motherpV,
PhiSectorManager
*psm, SoMaterial * topMaterial,
46
MatVisAttributes
*
matVisAttributes
,
VolVisAttributes
*
volVisAttributes
,
47
ZappedVolumeListModel
* zappedvolumelistmodel,
VP1GeoTreeView
* volbrowser, SoSeparator*
textSep
)
48
:
m_d
(new
Imp
),
m_volumebrowser
(volbrowser),
m_textSep
(
textSep
)
49
{
50
m_d
->ref = 0;
51
m_d
->controller=
controller
;
52
m_d
->sonodesep2volhandle = sonodesep2volhandle;
53
m_d
->motherpV = motherpV;
54
m_d
->phisectormanager = psm;
55
m_d
->subsysflag = flag;
56
m_d
->topMaterial = topMaterial;
57
m_d
->matVisAttributes =
matVisAttributes
;
58
m_d
->volVisAttributes =
volVisAttributes
;
59
m_d
->zappedvolumelistmodel = zappedvolumelistmodel;
60
}
61
62
//____________________________________________________________________
63
VolumeHandleSharedData::~VolumeHandleSharedData
()
64
{
65
std::map<const GeoLogVol *, SoShape *>::iterator it, itE =
m_d
->logvol2shape.end();
66
for
(it=
m_d
->logvol2shape.begin();it!=itE;++it) {
67
if
(it->second)
68
it->second->unref();
69
}
70
std::map<double, SoNode *>::iterator it2, it2E =
m_d
->id2shape.end();
71
for
(it2=
m_d
->id2shape.begin();it2!=it2E;++it2) {
72
if
(it2->second)
73
it2->second->unref();
74
}
75
delete
m_d
;
m_d
=0;
76
}
77
78
//____________________________________________________________________
79
void
VolumeHandleSharedData::ref
()
80
{
81
++(
m_d
->ref);
82
}
83
84
//____________________________________________________________________
85
void
VolumeHandleSharedData::unref
()
86
{
87
--(
m_d
->ref);
88
if
(!
m_d
->ref)
89
delete
this
;
90
}
91
92
//____________________________________________________________________
93
MatVisAttributes
*
VolumeHandleSharedData::matVisAttributes
()
const
94
{
95
return
m_d
->matVisAttributes;
96
}
97
98
//____________________________________________________________________
99
VolVisAttributes
*
VolumeHandleSharedData::volVisAttributes
()
const
100
{
101
return
m_d
->volVisAttributes;
102
}
103
104
//____________________________________________________________________
105
SoMaterial *
VolumeHandleSharedData::fallBackTopLevelMaterial
()
const
106
{
107
return
m_d
->topMaterial;
108
}
109
110
//____________________________________________________________________
111
VP1GeoFlags::SubSystemFlag
VolumeHandleSharedData::subSystemFlag
()
const
112
{
113
return
m_d
->subsysflag;
114
}
115
116
//____________________________________________________________________
117
PhiSectorManager
*
VolumeHandleSharedData::phiSectorManager
()
const
118
{
119
return
m_d
->phisectormanager;
120
}
121
122
//____________________________________________________________________
123
GeoSysController
*
VolumeHandleSharedData::controller
()
const
124
{
125
return
m_d
->controller;
126
}
127
128
//_____________________________________________________________________________________
129
void
VolumeHandleSharedData::registerNodeSepForVolumeHandle
(SoSeparator*n,
VolumeHandle
*vh)
130
{
131
assert(
m_d
->sonodesep2volhandle->find(n)==
m_d
->sonodesep2volhandle->end());
132
(*(
m_d
->sonodesep2volhandle))[n]=vh;
133
setShowVolumeOutlines
(n,
m_d
->controller->showVolumeOutLines());
134
}
135
136
//_____________________________________________________________________________________
137
void
VolumeHandleSharedData::setShowVolumeOutlines
(SoGroup*nodegroup,
bool
showvol)
138
{
139
for
(
int
i = 0; i<nodegroup->getNumChildren();++i) {
140
SoNode * n = nodegroup->getChild(i);
141
if
(n->getTypeId().isDerivedFrom(SoGenericBox::getClassTypeId())) {
142
if
(
static_cast<
SoGenericBox
*
>
(n)->drawEdgeLines.getValue()!=showvol)
143
static_cast<
SoGenericBox
*
>
(n)->drawEdgeLines.setValue(showvol);
144
}
else
if
(n->getTypeId().isDerivedFrom(SoTubs::getClassTypeId())) {
145
if
(
static_cast<
SoTubs
*
>
(n)->drawEdgeLines.getValue()!=showvol){
146
static_cast<
SoTubs
*
>
(n)->drawEdgeLines.setValue(showvol);
147
}
148
}
else
if
(n->getTypeId().isDerivedFrom(SoPcons::getClassTypeId())) {
149
if
(
static_cast<
SoPcons
*
>
(n)->drawEdgeLines.getValue()!=showvol){
150
static_cast<
SoPcons
*
>
(n)->drawEdgeLines.setValue(showvol);
151
}
152
}
else
if
(n->getTypeId().isDerivedFrom(SoTessellated::getClassTypeId())) {
153
if
(
static_cast<
SoTessellated
*
>
(n)->drawEdgeLines.getValue()!=showvol){
154
static_cast<
SoTessellated
*
>
(n)->drawEdgeLines.setValue(showvol);
155
}
156
}
else
if
(n->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) {
157
setShowVolumeOutlines
(
static_cast<
SoGroup*
>
(n),showvol);
158
}
159
}
160
}
161
162
//_____________________________________________________________________________________
163
SoNode *
VolumeHandleSharedData::toShapeNode
(
const
GeoPVConstLink& pV)
164
{
165
const
GeoLogVol * logVolume = pV->getLogVol();
166
167
// if shape already stored for this volume, return that
168
SoShape * shape (0);
169
std::map<const GeoLogVol *, SoShape *>::iterator itShape =
m_d
->logvol2shape.find(logVolume);
170
if
(itShape!=
m_d
->logvol2shape.end()) {
171
return
itShape->second;
172
}
173
174
const
GeoShape * geoshape = logVolume->getShape();
175
176
m_d
->visaction.reset();
177
if
(geoshape->typeID()==GeoShapeShift::getClassTypeID()) {
178
dynamic_cast<
const
GeoShapeShift*
>
(geoshape)->getOp()->exec(&(
m_d
->visaction));
179
//NB: the transformation part of the GeoShapeShift will be applied elsewhere
180
}
else
{
181
geoshape->exec(&(
m_d
->visaction));
182
}
183
shape =
m_d
->visaction.getShape();
184
if
(shape)
185
shape->ref();
186
m_d
->logvol2shape[logVolume] = shape;
187
return
shape;
188
}
189
190
//____________________________________________________________________
191
SoNode *
VolumeHandleSharedData::getSoCylinderOrientedLikeGeoTube
(
const
double
& radius,
const
double
& halfLength)
192
{
193
double
id
= radius - 9999.0*halfLength;
194
std::map<double, SoNode *>::iterator it =
m_d
->id2shape.find(
id
);
195
if
(it!=
m_d
->id2shape.end())
196
return
it->second;
197
198
SoGroup * group =
new
SoGroup;
199
SoRotationXYZ * rot =
new
SoRotationXYZ;
200
rot->axis.setValue(SoRotationXYZ::X);
201
rot->angle.setValue(
M_PI
*0.5f);
202
group->addChild(rot);
203
SoCylinder * cyl =
new
SoCylinder;
204
cyl->radius.setValue(radius);
205
cyl->height.setValue(2.0*halfLength);
206
group->addChild(cyl);
207
group->ref();
208
m_d
->id2shape[id]=group;
209
return
group;
210
}
211
212
//____________________________________________________________________
213
GeoPVConstLink
VolumeHandleSharedData::geoPVConstLinkOfTreeTopsMother
()
const
214
{
215
return
m_d
->motherpV;
216
}
217
218
//____________________________________________________________________
219
void
VolumeHandleSharedData::addZappedVolumeToGui
(
VolumeHandle
* handle )
220
{
221
m_d
->zappedvolumelistmodel->addToZappedVolumes(handle);
222
}
223
224
//____________________________________________________________________
225
void
VolumeHandleSharedData::removeZappedVolumesFromGui
(
VolumeHandle
* handle )
226
{
227
m_d
->zappedvolumelistmodel->removeFromZappedVolumes(handle);
228
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
GeoSysController.h
SoGenericBox.h
SoPcons.h
SoTessellated.h
SoTubs.h
SoVisualizeAction.h
VolumeHandleSharedData.h
ZappedVolumeListModel.h
GeoSysController
Definition
GeoSysController.h:29
MatVisAttributes
Definition
VisAttributes.h:64
PhiSectorManager
Definition
PhiSectorManager.h:30
SoGenericBox
Definition
SoGenericBox.h:26
SoPcons
SoPcons - Inventor version of the G4Cons Geant Geometry entity.
Definition
SoPcons.h:42
SoTessellated
Definition
SoTessellated.h:24
SoTubs
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition
SoTubs.h:52
SoVisualizeAction
Definition
SoVisualizeAction.h:19
VP1GeoFlags::SubSystemFlag
SubSystemFlag
Definition
VP1GeoFlags.h:30
VP1GeoTreeView
Definition
VP1GeoTreeView.h:22
VolVisAttributes
Definition
VisAttributes.h:71
VolumeHandleSharedData::Imp
Definition
VolumeHandleSharedData.cxx:25
VolumeHandleSharedData::Imp::phisectormanager
PhiSectorManager * phisectormanager
Definition
VolumeHandleSharedData.cxx:33
VolumeHandleSharedData::Imp::ref
int ref
Definition
VolumeHandleSharedData.cxx:39
VolumeHandleSharedData::Imp::controller
GeoSysController * controller
Definition
VolumeHandleSharedData.cxx:27
VolumeHandleSharedData::Imp::visaction
SoVisualizeAction visaction
Definition
VolumeHandleSharedData.cxx:30
VolumeHandleSharedData::Imp::motherpV
GeoPVConstLink motherpV
Definition
VolumeHandleSharedData.cxx:32
VolumeHandleSharedData::Imp::logvol2shape
std::map< const GeoLogVol *, SoShape * > logvol2shape
Definition
VolumeHandleSharedData.cxx:28
VolumeHandleSharedData::Imp::id2shape
std::map< double, SoNode * > id2shape
Definition
VolumeHandleSharedData.cxx:29
VolumeHandleSharedData::Imp::zappedvolumelistmodel
ZappedVolumeListModel * zappedvolumelistmodel
Definition
VolumeHandleSharedData.cxx:38
VolumeHandleSharedData::Imp::sonodesep2volhandle
std::map< SoSeparator *, VolumeHandle * > * sonodesep2volhandle
Definition
VolumeHandleSharedData.cxx:31
VolumeHandleSharedData::Imp::volVisAttributes
VolVisAttributes * volVisAttributes
Definition
VolumeHandleSharedData.cxx:37
VolumeHandleSharedData::Imp::matVisAttributes
MatVisAttributes * matVisAttributes
Definition
VolumeHandleSharedData.cxx:36
VolumeHandleSharedData::Imp::subsysflag
VP1GeoFlags::SubSystemFlag subsysflag
Definition
VolumeHandleSharedData.cxx:34
VolumeHandleSharedData::Imp::topMaterial
SoMaterial * topMaterial
Definition
VolumeHandleSharedData.cxx:35
VolumeHandleSharedData::ref
void ref()
Definition
VolumeHandleSharedData.cxx:79
VolumeHandleSharedData::VolumeHandleSharedData
VolumeHandleSharedData(GeoSysController *controller, VP1GeoFlags::SubSystemFlag, std::map< SoSeparator *, VolumeHandle * > *sonodesep2volhandle, const GeoPVConstLink &motherpV, PhiSectorManager *, SoMaterial *topMaterial, MatVisAttributes *, VolVisAttributes *, ZappedVolumeListModel *, VP1GeoTreeView *, SoSeparator *)
Definition
VolumeHandleSharedData.cxx:43
VolumeHandleSharedData::textSep
SoSeparator * textSep() const
Definition
VolumeHandleSharedData.h:43
VolumeHandleSharedData::m_textSep
SoSeparator * m_textSep
base text sep
Definition
VolumeHandleSharedData.h:67
VolumeHandleSharedData::m_volumebrowser
VP1GeoTreeView * m_volumebrowser
Definition
VolumeHandleSharedData.h:66
VolumeHandleSharedData::geoPVConstLinkOfTreeTopsMother
GeoPVConstLink geoPVConstLinkOfTreeTopsMother() const
Definition
VolumeHandleSharedData.cxx:213
VolumeHandleSharedData::phiSectorManager
PhiSectorManager * phiSectorManager() const
Definition
VolumeHandleSharedData.cxx:117
VolumeHandleSharedData::unref
void unref()
Definition
VolumeHandleSharedData.cxx:85
VolumeHandleSharedData::controller
GeoSysController * controller() const
Definition
VolumeHandleSharedData.cxx:123
VolumeHandleSharedData::m_d
Imp * m_d
Definition
VolumeHandleSharedData.h:63
VolumeHandleSharedData::registerNodeSepForVolumeHandle
void registerNodeSepForVolumeHandle(SoSeparator *, VolumeHandle *)
Definition
VolumeHandleSharedData.cxx:129
VolumeHandleSharedData::getSoCylinderOrientedLikeGeoTube
SoNode * getSoCylinderOrientedLikeGeoTube(const double &radius, const double &halfLength)
Definition
VolumeHandleSharedData.cxx:191
VolumeHandleSharedData::setShowVolumeOutlines
static void setShowVolumeOutlines(SoGroup *nodesep, bool showvol)
Definition
VolumeHandleSharedData.cxx:137
VolumeHandleSharedData::volVisAttributes
VolVisAttributes * volVisAttributes() const
Definition
VolumeHandleSharedData.cxx:99
VolumeHandleSharedData::subSystemFlag
VP1GeoFlags::SubSystemFlag subSystemFlag() const
Definition
VolumeHandleSharedData.cxx:111
VolumeHandleSharedData::removeZappedVolumesFromGui
void removeZappedVolumesFromGui(VolumeHandle *)
Definition
VolumeHandleSharedData.cxx:225
VolumeHandleSharedData::addZappedVolumeToGui
void addZappedVolumeToGui(VolumeHandle *)
Definition
VolumeHandleSharedData.cxx:219
VolumeHandleSharedData::fallBackTopLevelMaterial
SoMaterial * fallBackTopLevelMaterial() const
Definition
VolumeHandleSharedData.cxx:105
VolumeHandleSharedData::matVisAttributes
MatVisAttributes * matVisAttributes() const
Definition
VolumeHandleSharedData.cxx:93
VolumeHandleSharedData::toShapeNode
SoNode * toShapeNode(const GeoPVConstLink &pV)
Definition
VolumeHandleSharedData.cxx:163
VolumeHandleSharedData::~VolumeHandleSharedData
~VolumeHandleSharedData()
Definition
VolumeHandleSharedData.cxx:63
VolumeHandle
Definition
VolumeHandle.h:21
ZappedVolumeListModel
Definition
ZappedVolumeListModel.h:15
Generated on
for ATLAS Offline Software by
1.17.0