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