ATLAS Offline Software
VolumeHandleSharedData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 #include "GeoModelKernel/GeoVPhysVol.h"
11 #include "GeoModelKernel/GeoShapeShift.h"
12 
14 #include "VP1HEPVis/nodes/SoTubs.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 //____________________________________________________________________
26 public:
28  std::map<const GeoLogVol *, SoShape *> logvol2shape;
29  std::map<double, SoNode *> id2shape;
31  std::map<SoSeparator*,VolumeHandle*>* sonodesep2volhandle = nullptr;
32  GeoPVConstLink motherpV;
35  SoMaterial * topMaterial = nullptr;
39  int ref = 0;
40 };
41 
42 //____________________________________________________________________
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;
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;
59  m_d->zappedvolumelistmodel = zappedvolumelistmodel;
60 }
61 
62 //____________________________________________________________________
64 {
66  for (it=m_d->logvol2shape.begin();it!=itE;++it) {
67  if (it->second)
68  it->second->unref();
69  }
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 //____________________________________________________________________
80 {
81  ++(m_d->ref);
82 }
83 
84 //____________________________________________________________________
86 {
87  --(m_d->ref);
88  if (!m_d->ref)
89  delete this;
90 }
91 
92 //____________________________________________________________________
94 {
95  return m_d->matVisAttributes;
96 }
97 
98 //____________________________________________________________________
100 {
101  return m_d->volVisAttributes;
102 }
103 
104 //____________________________________________________________________
106 {
107  return m_d->topMaterial;
108 }
109 
110 //____________________________________________________________________
112 {
113  return m_d->subsysflag;
114 }
115 
116 //____________________________________________________________________
118 {
119  return m_d->phisectormanager;
120 }
121 
122 //____________________________________________________________________
124 {
125  return m_d->controller;
126 }
127 
128 //_____________________________________________________________________________________
130 {
131  assert(m_d->sonodesep2volhandle->find(n)==m_d->sonodesep2volhandle->end());
132  (*(m_d->sonodesep2volhandle))[n]=vh;
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);
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;
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 //____________________________________________________________________
214 {
215  return m_d->motherpV;
216 }
217 
218 //____________________________________________________________________
220 {
222 }
223 
224 //____________________________________________________________________
226 {
228 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VolumeHandleSharedData::fallBackTopLevelMaterial
SoMaterial * fallBackTopLevelMaterial() const
Definition: VolumeHandleSharedData.cxx:105
ZappedVolumeListModel::removeFromZappedVolumes
void removeFromZappedVolumes(VolumeHandle *)
Definition: ZappedVolumeListModel.h:68
VolumeHandleSharedData::Imp::motherpV
GeoPVConstLink motherpV
Definition: VolumeHandleSharedData.cxx:32
GeoSysController.h
VP1GeoTreeView
Definition: VP1GeoTreeView.h:22
VolumeHandleSharedData::m_d
Imp * m_d
Definition: VolumeHandleSharedData.h:62
VolumeHandleSharedData::Imp::visaction
SoVisualizeAction visaction
Definition: VolumeHandleSharedData.cxx:30
SoPcons
SoPcons - Inventor version of the G4Cons Geant Geometry entity.
Definition: SoPcons.h:42
SoTubs
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition: SoTubs.h:52
VolVisAttributes
Definition: VisAttributes.h:71
SoVisualizeAction.h
GeoSysController
Definition: GeoSysController.h:29
SoTessellated::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoTessellated.h:31
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SoVisualizeAction::reset
void reset()
Definition: SoVisualizeAction.h:50
M_PI
#define M_PI
Definition: ActiveFraction.h:11
VolumeHandleSharedData::Imp::matVisAttributes
MatVisAttributes * matVisAttributes
Definition: VolumeHandleSharedData.cxx:36
VolumeHandleSharedData::volVisAttributes
VolVisAttributes * volVisAttributes() const
Definition: VolumeHandleSharedData.cxx:99
VolumeHandleSharedData::Imp::phisectormanager
PhiSectorManager * phisectormanager
Definition: VolumeHandleSharedData.cxx:33
VolumeHandleSharedData::Imp::controller
GeoSysController * controller
Definition: VolumeHandleSharedData.cxx:27
VolumeHandleSharedData.h
VolumeHandleSharedData::Imp::subsysflag
VP1GeoFlags::SubSystemFlag subsysflag
Definition: VolumeHandleSharedData.cxx:34
TruthTest.itE
itE
Definition: TruthTest.py:25
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
VolumeHandleSharedData::unref
void unref()
Definition: VolumeHandleSharedData.cxx:85
VolumeHandleSharedData::phiSectorManager
PhiSectorManager * phiSectorManager() const
Definition: VolumeHandleSharedData.cxx:117
ZappedVolumeListModel.h
SoPcons.h
VolumeHandleSharedData::Imp::id2shape
std::map< double, SoNode * > id2shape
Definition: VolumeHandleSharedData.cxx:29
SoTessellated
Definition: SoTessellated.h:24
SoVisualizeAction::getShape
SoShape * getShape()
Definition: SoVisualizeAction.h:49
GeoSysController::showVolumeOutLines
bool showVolumeOutLines() const
Definition: GeoSysController.cxx:462
VolumeHandleSharedData::~VolumeHandleSharedData
~VolumeHandleSharedData()
Definition: VolumeHandleSharedData.cxx:63
VolumeHandleSharedData::registerNodeSepForVolumeHandle
void registerNodeSepForVolumeHandle(SoSeparator *, VolumeHandle *)
Definition: VolumeHandleSharedData.cxx:129
lumiFormat.i
int i
Definition: lumiFormat.py:85
SoVisualizeAction
Definition: SoVisualizeAction.h:19
SoTessellated.h
beamspotman.n
n
Definition: beamspotman.py:731
VolumeHandleSharedData::Imp
Definition: VolumeHandleSharedData.cxx:25
master.flag
bool flag
Definition: master.py:29
VolumeHandleSharedData::Imp::logvol2shape
std::map< const GeoLogVol *, SoShape * > logvol2shape
Definition: VolumeHandleSharedData.cxx:28
hist_file_dump.f
f
Definition: hist_file_dump.py:135
VolumeHandleSharedData::geoPVConstLinkOfTreeTopsMother
GeoPVConstLink geoPVConstLinkOfTreeTopsMother() const
Definition: VolumeHandleSharedData.cxx:213
VolumeHandleSharedData::Imp::ref
int ref
Definition: VolumeHandleSharedData.cxx:39
SoTubs::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoTubs.h:89
SoPcons::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoPcons.h:83
VolumeHandle
Definition: VolumeHandle.h:21
VolumeHandleSharedData::Imp::zappedvolumelistmodel
ZappedVolumeListModel * zappedvolumelistmodel
Definition: VolumeHandleSharedData.cxx:38
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
VolumeHandleSharedData::ref
void ref()
Definition: VolumeHandleSharedData.cxx:79
VolumeHandleSharedData::subSystemFlag
VP1GeoFlags::SubSystemFlag subSystemFlag() const
Definition: VolumeHandleSharedData.cxx:111
VolumeHandleSharedData::Imp::volVisAttributes
VolVisAttributes * volVisAttributes
Definition: VolumeHandleSharedData.cxx:37
VolumeHandleSharedData::removeZappedVolumesFromGui
void removeZappedVolumesFromGui(VolumeHandle *)
Definition: VolumeHandleSharedData.cxx:225
VolumeHandleSharedData::setShowVolumeOutlines
static void setShowVolumeOutlines(SoGroup *nodesep, bool showvol)
Definition: VolumeHandleSharedData.cxx:137
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
MatVisAttributes
Definition: VisAttributes.h:64
ZappedVolumeListModel::addToZappedVolumes
void addToZappedVolumes(VolumeHandle *)
Definition: ZappedVolumeListModel.h:61
VolumeHandleSharedData::addZappedVolumeToGui
void addZappedVolumeToGui(VolumeHandle *)
Definition: VolumeHandleSharedData.cxx:219
ZappedVolumeListModel
Definition: ZappedVolumeListModel.h:15
SoGenericBox
Definition: SoGenericBox.h:26
SoTubs.h
VolumeHandleSharedData::Imp::topMaterial
SoMaterial * topMaterial
Definition: VolumeHandleSharedData.cxx:35
PhiSectorManager
Definition: PhiSectorManager.h:30
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::controller
GeoSysController * controller() const
Definition: VolumeHandleSharedData.cxx:123
VolumeHandleSharedData::toShapeNode
SoNode * toShapeNode(const GeoPVConstLink &pV)
Definition: VolumeHandleSharedData.cxx:163
VP1GeoFlags::SubSystemFlag
SubSystemFlag
Definition: VP1GeoFlags.h:30
VolumeHandleSharedData::getSoCylinderOrientedLikeGeoTube
SoNode * getSoCylinderOrientedLikeGeoTube(const double &radius, const double &halfLength)
Definition: VolumeHandleSharedData.cxx:191
SoGenericBox.h
VolumeHandleSharedData::matVisAttributes
MatVisAttributes * matVisAttributes() const
Definition: VolumeHandleSharedData.cxx:93
VolumeHandleSharedData::Imp::sonodesep2volhandle
std::map< SoSeparator *, VolumeHandle * > * sonodesep2volhandle
Definition: VolumeHandleSharedData.cxx:31