ATLAS Offline Software
Loading...
Searching...
No Matches
VolumeHandle Class Reference

#include <VolumeHandle.h>

Inheritance diagram for VolumeHandle:
Collaboration diagram for VolumeHandle:

Classes

class  Imp

Public Types

enum  MuonChamberState { NONMUONCHAMBER , MUONCHAMBERCHILD , MUONCHAMBER , MUONCHAMBER_DIRTY }
typedef std::vector< VolumeHandle * > VolumeHandleList
typedef VolumeHandleList::iterator VolumeHandleListItr
typedef VolumeHandleList::const_iterator VolumeHandleListConstItr

Public Member Functions

bool isInMuonChamber () const
bool isMuonChamber () const
void setMuonChamberDirty (bool)
bool muonChamberDirty () const
MuonChamberState muonChamberState () const
 VolumeHandle (VolumeHandleSharedData *, VolumeHandle *parent, const GeoPVConstLink &, int childNumber, const MuonChamberState &mcs=NONMUONCHAMBER, const SbMatrix &accumTrans=SbMatrix())
virtual ~VolumeHandle ()
void initialiseChildren ()
bool childrenAreInitialised () const
unsigned nChildren () const
SoMaterial * material ()
QString getName () const
QString getNameTag () const
QString getDisplayName () const
int copyNumber () const
quint32 hashID () const
GeoPVConstLink geoPVConstLink () const
const GeoMaterial * geoMaterial () const
std::string getNameStdString () const
bool hasName (const std::string &) const
const SbMatrix & getGlobalTransformToVolume () const
SbMatrix getLocalTransformToVolume () const
bool isPositiveZ () const
VolumeHandle * parent ()
VolumeHandle * topLevelParent ()
VolumeHandleListItr childrenBegin ()
VolumeHandleListItr childrenEnd ()
VolumeHandle * child (int index) const
int childNumber () const
VP1GeoFlags::VOLSTATE state () const
void setState (const VP1GeoFlags::VOLSTATE &state, bool autoExpandEther=true)
void reset ()
bool isAttached () const
void contractDaughtersRecursively ()
bool isEther () const
void expandMothersRecursivelyToNonEther ()
bool isInitialisedAndHasNonStandardShape () const
SoSeparator * nodeSoSeparator () const
void ensureBuildNodeSep ()
void updateLabels ()
QByteArray getPersistifiableState () const
void applyPersistifiableState (QByteArray)
VP1GeoFlags::SubSystemFlag subsystem () const
virtual QString getDescriptiveName () const
virtual QString muonChamberT0 (unsigned int=0) const

Private Member Functions

 VolumeHandle (const VolumeHandle &)
VolumeHandle & operator= (const VolumeHandle &)
bool haveParentsNotExpanded () const
void attachAllContractedChildren ()
void detachAllContractedChildren ()

Private Attributes

Imp * m_d
const int m_childNumber
const unsigned m_nchildren
MuonChamberState m_muonChamberState
VolumeHandle * m_parent
VolumeHandleList m_children
VP1GeoFlags::VOLSTATE m_state

Detailed Description

Definition at line 21 of file VolumeHandle.h.

Member Typedef Documentation

◆ VolumeHandleList

Definition at line 66 of file VolumeHandle.h.

◆ VolumeHandleListConstItr

typedef VolumeHandleList::const_iterator VolumeHandle::VolumeHandleListConstItr

Definition at line 68 of file VolumeHandle.h.

◆ VolumeHandleListItr

typedef VolumeHandleList::iterator VolumeHandle::VolumeHandleListItr

Definition at line 67 of file VolumeHandle.h.

Member Enumeration Documentation

◆ MuonChamberState

Enumerator
NONMUONCHAMBER 
MUONCHAMBERCHILD 
MUONCHAMBER 
MUONCHAMBER_DIRTY 

Definition at line 24 of file VolumeHandle.h.

24 { NONMUONCHAMBER,//Default
25 MUONCHAMBERCHILD,//Top-level parent is muon chamber
26 MUONCHAMBER,//Muon chamber, adjusted to event data
27 MUONCHAMBER_DIRTY };//Muon chamber, not adjusted to event data

Constructor & Destructor Documentation

◆ VolumeHandle() [1/2]

VolumeHandle::VolumeHandle ( VolumeHandleSharedData * cd,
VolumeHandle * parent,
const GeoPVConstLink & pV,
int childNumber,
const MuonChamberState & mcs = NONMUONCHAMBER,
const SbMatrix & accumTrans = SbMatrix() )

Definition at line 96 of file VolumeHandle.cxx.

97 : m_d(new Imp(cd,pV,accumTrans)), m_childNumber(childNumber), m_nchildren(childNumber>=0?pV->getNChildVols():0), m_muonChamberState(mcs), m_parent(parent),
99{
100 // std::cout<<"VolumeHandle ctor for "<<this<<" with parent="<<parent<<" and GeoPVConstLink @"<<&pV<<std::endl;
101 //commondata might be 0 in the special case where VolumeHandle is
102 //used as a base class for other reasons inside
103 //VolumeTreeModel. Just make sure we dont crash in that case.
104 if (cd) {
105 cd->ref();
107 m_d->attach(this);
108 }
109}
MuonChamberState m_muonChamberState
VP1GeoFlags::VOLSTATE m_state
bool haveParentsNotExpanded() const
VolumeHandle * m_parent
const unsigned m_nchildren
const int m_childNumber
VolumeHandle * parent()
int childNumber() const

◆ ~VolumeHandle()

VolumeHandle::~VolumeHandle ( )
virtual

Definition at line 112 of file VolumeHandle.cxx.

113{
114 if (m_d->commondata) {
116 m_d->commondata->removeZappedVolumesFromGui(this);
118 VolumeHandleListItr it, itE = m_children.end();
119 for (it = m_children.begin(); it!=itE; ++it)
120 delete *it;
121 m_children.clear();
122 }
123 if (m_d->material)
124 m_d->material->unref();
125 if (m_d->nodesep)
126 m_d->nodesep->unref();
127 if (m_d->label_sep)
128 m_d->label_sep->unref();
129 m_d->commondata->unref();
130 }
131 delete m_d;
132}
bool childrenAreInitialised() const
VolumeHandleList m_children
void setState(const VP1GeoFlags::VOLSTATE &state, bool autoExpandEther=true)
VolumeHandleList::iterator VolumeHandleListItr

◆ VolumeHandle() [2/2]

VolumeHandle::VolumeHandle ( const VolumeHandle & )
private

Member Function Documentation

◆ applyPersistifiableState()

void VolumeHandle::applyPersistifiableState ( QByteArray ba)

Definition at line 650 of file VolumeHandle.cxx.

651{
652 QBuffer buffer(&ba);
653 buffer.open(QIODevice::ReadOnly);
654 QDataStream state(&buffer);
655 qint32 version;
656 state >> version;
657 if (version!=0)
658 return;//We ignore wrong versions silently here.
659 qint32 st;
660 state >> st;
662 if (st == 2)
663 newstate = VP1GeoFlags::ZAPPED;
664 else if (st == 1)
665 newstate = VP1GeoFlags::EXPANDED;
666
667 Imp::VolState vs;
668 state >> vs;
669 buffer.close();
670
671 if (newstate==VP1GeoFlags::EXPANDED) {
673 m_d->applyChildStates(vs,this);
674 }
675 setState(newstate);
676}
VP1GeoFlags::VOLSTATE state() const

◆ attachAllContractedChildren()

void VolumeHandle::attachAllContractedChildren ( )
private

Definition at line 505 of file VolumeHandle.cxx.

505 {
506
507 if (!m_nchildren)
508 return;
511
512 VolumeHandleListItr childItrE = m_children.end();
513 for (VolumeHandleListItr childItr = m_children.begin(); childItr!=childItrE; ++childItr) {
514 if ((*childItr)->state()==VP1GeoFlags::CONTRACTED)
515 (*childItr)->m_d->attach(*childItr);
516 else if ((*childItr)->state()==VP1GeoFlags::EXPANDED)
517 (*childItr)->attachAllContractedChildren();
518 }
519}
void initialiseChildren()

◆ child()

VolumeHandle * VolumeHandle::child ( int index) const
inline

Definition at line 153 of file VolumeHandle.h.

153{ return m_children.at(index); }

◆ childNumber()

int VolumeHandle::childNumber ( ) const
inline

Definition at line 154 of file VolumeHandle.h.

154{ return m_childNumber; }

◆ childrenAreInitialised()

bool VolumeHandle::childrenAreInitialised ( ) const
inline

Definition at line 149 of file VolumeHandle.h.

149{ return m_children.size()==m_nchildren; }

◆ childrenBegin()

VolumeHandle::VolumeHandleListItr VolumeHandle::childrenBegin ( )
inline

Definition at line 150 of file VolumeHandle.h.

150{ return m_children.begin(); }

◆ childrenEnd()

VolumeHandle::VolumeHandleListItr VolumeHandle::childrenEnd ( )
inline

Definition at line 151 of file VolumeHandle.h.

151{ return m_children.end(); }

◆ contractDaughtersRecursively()

void VolumeHandle::contractDaughtersRecursively ( )

Definition at line 486 of file VolumeHandle.cxx.

487{
489 return;//Fine to abort since children starts in contracted state
490 //if initialised at a later time.
491 VolumeHandleListItr childItrE = m_children.end();
492 for (VolumeHandleListItr childItr = m_children.begin(); childItr!=childItrE; ++childItr) {
493 (*childItr)->setState(VP1GeoFlags::CONTRACTED);
494 (*childItr)->contractDaughtersRecursively();
495 }
496}

◆ copyNumber()

int VolumeHandle::copyNumber ( ) const

Definition at line 538 of file VolumeHandle.cxx.

539{
540 GeoPVConstLink parent_pV;
541 if (m_parent) {
542 parent_pV = m_parent->geoPVConstLink();
543 } else {
544 parent_pV = m_d->commondata->geoPVConstLinkOfTreeTopsMother();
545 if (parent_pV==m_d->pV) {
546 //To follow historical behaviour, we always assume that
547 //tree-tops (in the GeoModel sense) have a copy number of 0.
548 return 0;
549 }
550 }
551 GeoVolumeCursor av(parent_pV);
552 int i(0);//We need to check the childNumber since volumes in a replica have same volume link
553 while (!av.atEnd()) {
554 if (m_childNumber==i&&m_d->pV==av.getVolume()) {
555 std::optional<int> Qint = av.getId();
556 return Qint ? *Qint : -1;//-1 for "Invalid"
557 }
558 av.next();
559 ++i;
560 }
561 return -2;//error
562}

◆ detachAllContractedChildren()

void VolumeHandle::detachAllContractedChildren ( )
private

Definition at line 522 of file VolumeHandle.cxx.

522 {
523 if (!m_nchildren)
524 return;
526 return;//Since children not initialised won't have been attached!
527
528 VolumeHandleListItr childItrE = m_children.end();
529 for (VolumeHandleListItr childItr = m_children.begin(); childItr!=childItrE; ++childItr) {
530 if ((*childItr)->state()==VP1GeoFlags::CONTRACTED)
531 (*childItr)->m_d->detach();
532 else if ((*childItr)->state()==VP1GeoFlags::EXPANDED)
533 (*childItr)->detachAllContractedChildren();
534 }
535}

◆ ensureBuildNodeSep()

void VolumeHandle::ensureBuildNodeSep ( )

Definition at line 278 of file VolumeHandle.cxx.

279{
280 VP1Msg::messageDebug("VolumeHandle::ensureBuildNodeSep()");
281 if (m_d->nodesep && m_d->label_sep)
282 return;
283
284 m_d->label_sep = new SoSeparator;
285 m_d->label_sep->ref();
286
287 m_d->nodesep = new SoSeparator;//FIXME: rendercaching??
288 // m_d->nodesep->renderCaching.setValue(SoSeparator::ON);
289 // m_d->nodesep->boundingBoxCaching.setValue(SoSeparator::ON);
290 m_d->nodesep->ref();//Since we are keeping it around irrespective of whether it is attached or not.
291
292 //Transform:
293 m_d->nodesep->addChild(VP1LinAlgUtils::toSoTransform(m_d->accumTrans));
294
295 //VP1Msg::messageDebug("calling toShapeNode()...");
296 SoNode * shape = m_d->commondata->toShapeNode(m_d->pV);//NB: Ignore contained transformation of GeoShapeShifts.
297 if (!shape) {
298 m_d->nodesep->removeAllChildren();
299 std::cout << "Geomsys/VolumeHandle Error: Null shape!!!"<<std::endl;
300 return;
301 }
302
303 //What phi sector do we belong in?
304 int iphi = m_d->commondata->phiSectorManager()->getVolumeType(m_d->accumTrans, shape);
305
306 if (iphi >= -1 ) {
307 //VP1Msg::messageDebug("Cylinders [iphi >= -1]...");
308 //Substitute shapes that are essentially cylinders with such. This
309 //can be done safely since this tube won't need
310 //phi-slicing and is done to gain render performance.
311 if ( m_d->pV->getLogVol()->getShape()->typeID()==GeoTube::getClassTypeID() )
312 {
313 //VP1Msg::messageDebug("GeoTube...");
314 const GeoTube * geotube = static_cast<const GeoTube*>(m_d->pV->getLogVol()->getShape());
315 if (geotube->getRMin()==0.0)
316 shape = m_d->commondata->getSoCylinderOrientedLikeGeoTube(geotube->getRMax(),geotube->getZHalfLength());
317 }
318 else if ( m_d->pV->getLogVol()->getShape()->typeID()==GeoTubs::getClassTypeID() )
319 {
320 //VP1Msg::messageDebug("GeoTubs...");
321 const GeoTubs * geotubs = static_cast<const GeoTubs*>(m_d->pV->getLogVol()->getShape());
322 if (geotubs->getRMin()==0.0 && geotubs->getDPhi() >= 2*M_PI-1.0e-6)
323 shape = m_d->commondata->getSoCylinderOrientedLikeGeoTube(geotubs->getRMax(),geotubs->getZHalfLength());
324 }
325 }
326
327 //In the case of a GeoShapeShift we add its contained transformation here:
328 //Fixme: Remember to use this extra transformation for phisector cuts also!
329 if (m_d->pV->getLogVol()->getShape()->typeID()==GeoShapeShift::getClassTypeID())
330 m_d->nodesep->addChild(VP1LinAlgUtils::toSoTransform(Amg::EigenTransformToCLHEP(dynamic_cast<const GeoShapeShift*>(m_d->pV->getLogVol()->getShape())->getX())));
331
332 //Add shape child(ren) and get the separator (helper) where we attach the nodesep when volume is visible:
333 if (iphi >= -1) {
334 m_d->nodesep->addChild(shape);
335 m_d->attachsepHelper = m_d->commondata->phiSectorManager()->getSepHelperForNode(m_d->commondata->subSystemFlag(), iphi);
336 m_d->attachlabelSepHelper = m_d->commondata->phiSectorManager()->getLabelSepHelperForNode(m_d->commondata->subSystemFlag(), iphi);
337 } else {
338 SoSwitch * sw = new SoSwitch;
339 sw->addChild(shape);
340 SoSeparator * sep_slicedvols = new SoSeparator;
341 sw->addChild(sep_slicedvols);
342 sw->whichChild = 0;
343 m_d->nodesep->addChild(sw);
344 m_d->attachsepHelper = m_d->commondata->phiSectorManager()->registerVolumeAroundZAxis( m_d->commondata->subSystemFlag(), sw, m_d->accumTrans );
345 //FIXME - what about labels?
346 }
347
348 //Register shape to volume handle connection (for user interactions):
349 //NB: "shape" might be shared between several volumes, so we use the separator above for the actual link!
350 //(this must be done last as it also sets outline defaults)
351 m_d->commondata->registerNodeSepForVolumeHandle(m_d->nodesep,this);
352
353 //VP1Msg::messageDebug("VolumeHandle::ensureBuildNodeSep() - DONE.");
354}
#define M_PI
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.

◆ expandMothersRecursivelyToNonEther()

void VolumeHandle::expandMothersRecursivelyToNonEther ( )

Definition at line 612 of file VolumeHandle.cxx.

612 {
613 //std::cout<<"VolumeHandle::expandMothersRecursivelyToNonEther() for "<<this->getNameStdString() << " [" <<this<< "]" << " - n. children: " << nChildren() << std::endl;
614
615 if (!nChildren()||!isEther()) {
616 //VP1Msg::messageDebug("====> no children or not 'Ether' material. Skipping & returning.");
617 return;
618 }
619
622 VolumeHandleListItr childItrE = m_children.end();
623 for (VolumeHandleListItr childItr = m_children.begin(); childItr!=childItrE; ++childItr) {
624 //std::cout << "\t-->expanding child " << (*childItr)->getNameStdString() << " - " << (*childItr) << std::endl ;
625 (*childItr)->expandMothersRecursivelyToNonEther();
626 }
628 //std::cout<<"VolumeHandle::expandMothersRecursivelyToNonEther() for "<<this->getNameStdString() << " [" <<this<< "]" <<" DONE.\n\n"<<std::endl;
629
630}
bool isEther() const
unsigned nChildren() const

◆ geoMaterial()

const GeoMaterial * VolumeHandle::geoMaterial ( ) const

Definition at line 590 of file VolumeHandle.cxx.

590 {
591 return geoPVConstLink()->getLogVol()->getMaterial();
592}
GeoPVConstLink geoPVConstLink() const

◆ geoPVConstLink()

GeoPVConstLink VolumeHandle::geoPVConstLink ( ) const

Definition at line 163 of file VolumeHandle.cxx.

164{
165 return m_d->pV;
166}

◆ getDescriptiveName()

QString VolumeHandle::getDescriptiveName ( ) const
inlinevirtual

Reimplemented in MuonVolumeHandle.

Definition at line 165 of file VolumeHandle.h.

165 {
166 QString name = getName();
167 name.remove("_Station");
168 return name;
169}
QString getName() const

◆ getDisplayName()

QString VolumeHandle::getDisplayName ( ) const

Definition at line 214 of file VolumeHandle.cxx.

215{
216 const QString logicalName = getName();
217 const QString nameTag = getNameTag();
218
219 if (!nameTag.isEmpty() && nameTag != logicalName)
220 return nameTag + " (" + logicalName + ")";
221
222 return logicalName;
223}
QString getNameTag() const

◆ getGlobalTransformToVolume()

const SbMatrix & VolumeHandle::getGlobalTransformToVolume ( ) const

Definition at line 572 of file VolumeHandle.cxx.

572 {
573 return m_d->accumTrans;
574}

◆ getLocalTransformToVolume()

SbMatrix VolumeHandle::getLocalTransformToVolume ( ) const

Definition at line 577 of file VolumeHandle.cxx.

577 {
578 if (!m_parent)
579 return m_d->accumTrans;
580 return m_parent->getGlobalTransformToVolume().inverse().multRight(m_d->accumTrans);
581}

◆ getName()

QString VolumeHandle::getName ( ) const

Definition at line 169 of file VolumeHandle.cxx.

170{
171 return m_d->pV->getLogVol()->getName().c_str();
172}

◆ getNameStdString()

std::string VolumeHandle::getNameStdString ( ) const

Definition at line 175 of file VolumeHandle.cxx.

176{
177 return m_d->pV->getLogVol()->getName();
178}

◆ getNameTag()

QString VolumeHandle::getNameTag ( ) const

Definition at line 188 of file VolumeHandle.cxx.

189{
190 GeoPVConstLink parent_pV;
191
192 if (m_parent) {
193 parent_pV = m_parent->geoPVConstLink();
194 } else {
195 parent_pV = m_d->commondata->geoPVConstLinkOfTreeTopsMother();
196 }
197
198 GeoVolumeCursor av(parent_pV);
199 int i = 0;
200
201 while (!av.atEnd()) {
202 if (m_childNumber == i && m_d->pV == av.getVolume()) {
203 return QString::fromStdString(av.getName());
204 }
205 av.next();
206 ++i;
207 }
208
209 return QString();
210}

◆ getPersistifiableState()

QByteArray VolumeHandle::getPersistifiableState ( ) const

Definition at line 633 of file VolumeHandle.cxx.

634{
635 QByteArray ba;
636 QBuffer buffer(&ba);
637 buffer.open(QIODevice::WriteOnly);
638
639 QDataStream out(&buffer);
640 out << (qint32)0;//version
642 out << Imp::getChildStates(this);
643
644 buffer.close();
645 return ba;
646
647}
static VolState getChildStates(const VolumeHandle *theclass)

◆ hashID()

quint32 VolumeHandle::hashID ( ) const

Definition at line 565 of file VolumeHandle.cxx.

566{
567 // return qHash( QPair<QString,quint32>(getName(),copyNumber()));//NOT UNIQUE!!
568 return qHash( QPair<QString,quint32>(getName(),childNumber()));
569}

◆ hasName()

bool VolumeHandle::hasName ( const std::string & n) const

Definition at line 181 of file VolumeHandle.cxx.

182{
183 return m_d->pV->getLogVol()->getName() == n;
184}

◆ haveParentsNotExpanded()

bool VolumeHandle::haveParentsNotExpanded ( ) const
private

Definition at line 499 of file VolumeHandle.cxx.

500{
501 return m_parent ? ( m_parent->state()==VP1GeoFlags::EXPANDED ? m_parent->haveParentsNotExpanded() : true ) : false;
502}

◆ initialiseChildren()

void VolumeHandle::initialiseChildren ( )

Definition at line 135 of file VolumeHandle.cxx.

136{
138 return;
139
140 assert(m_nchildren);
141
142 //Loop over children:
143 m_children.reserve(m_nchildren);
144 unsigned ichild(0);
145 GeoVolumeCursor av(m_d->pV);
146 while (!av.atEnd()) {
147
148 //Add transformation between parent and child to find the complete transformation of the child:
149 SbMatrix matr;
151 matr.multRight(m_d->accumTrans);
152 m_children.push_back(new VolumeHandle(m_d->commondata,this,av.getVolume(),ichild++,(isInMuonChamber()?MUONCHAMBERCHILD:NONMUONCHAMBER),matr));
153 //std::cout << "initialised: " << av.getName() << " - " << m_children.back()->getName().toStdString() << " - " << m_children.back() << std::endl;
154
155 av.next();
156 }
157
158 assert(ichild==m_nchildren&&m_children.size()==m_nchildren);
159
160}
static void transformToMatrix(SoTransform *xf, SbMatrix &result)
VolumeHandle(VolumeHandleSharedData *, VolumeHandle *parent, const GeoPVConstLink &, int childNumber, const MuonChamberState &mcs=NONMUONCHAMBER, const SbMatrix &accumTrans=SbMatrix())
bool isInMuonChamber() const

◆ isAttached()

bool VolumeHandle::isAttached ( ) const

Definition at line 584 of file VolumeHandle.cxx.

585{
586 return m_d->isattached;
587}

◆ isEther()

bool VolumeHandle::isEther ( ) const

Definition at line 595 of file VolumeHandle.cxx.

596{
597 // NOTE:
598 // * the special::Ether is the old 'special' material used for assembly volumes in Pixel
599 // * the special::HyperUranium is the new 'special' material assigned by GeoModelXML
600 // to the 'AssemblyLV' volumes created out of assembly volumes; those are the ones that are
601 // used, for example, in ITkStrip
602 const QString materialName = QString(geoMaterial()->getName().c_str());
603 if (getName() == "AssemblyLV") {
604 VP1Msg::messageDebug("AssemblyLV material: " + materialName);
605 }
606 return !isMuonChamber() &&
607 (materialName.endsWith("Ether") ||
608 materialName.endsWith("HyperUranium"));
609}
bool isMuonChamber() const
const GeoMaterial * geoMaterial() const

◆ isInitialisedAndHasNonStandardShape()

bool VolumeHandle::isInitialisedAndHasNonStandardShape ( ) const

Definition at line 750 of file VolumeHandle.cxx.

751{
753 return m_d->nodesep ? Imp::hasNonStandardShapeChildren(m_d->nodesep) : false;
754}
static void initAllCustomClasses()
static bool hasNonStandardShapeChildren(const SoGroup *g)

◆ isInMuonChamber()

bool VolumeHandle::isInMuonChamber ( ) const
inline

Definition at line 156 of file VolumeHandle.h.

◆ isMuonChamber()

bool VolumeHandle::isMuonChamber ( ) const
inline

Definition at line 157 of file VolumeHandle.h.

◆ isPositiveZ()

bool VolumeHandle::isPositiveZ ( ) const

Definition at line 757 of file VolumeHandle.cxx.

758{
759 SbVec3f dir;
760 m_d->accumTrans.multDirMatrix(SbVec3f(0,0,1),dir);
761 float x,y,z;
762 dir.getValue(x,y,z);
763 return z>0;
764}
#define y
#define x
#define z

◆ material()

SoMaterial * VolumeHandle::material ( )

Definition at line 227 of file VolumeHandle.cxx.

228{
229 if (m_d->material)
230 return m_d->material;
231
232 //First see if the "databases" of volumes/material know about this volume:
233
234 SoMaterial * mat = m_d->commondata->volVisAttributes()->get(m_d->pV->getLogVol()->getName());
235 if (mat) {
236 m_d->material = mat;
237 m_d->material->ref();
238 return m_d->material;
239 }
240 mat = m_d->commondata->matVisAttributes()->get(m_d->pV->getLogVol()->getMaterial()->getName());
241 if (mat) {
242 m_d->material = mat;
243 m_d->material->ref();
244 return m_d->material;
245 }
246
247 //Apparently not. We now have two ways of finding a material: We can
248 //take a system dependent fallback material, or we can take the
249 //material of the parent.
250
251 mat = m_d->commondata->fallBackTopLevelMaterial();
252 if (mat) {
253 m_d->material = mat;
254 m_d->material->ref();
255 return m_d->material;
256 }
257
258 if (m_parent) {
259 m_d->material = m_parent->material();
260 assert(m_d->material);
261 m_d->material->ref();
262 return m_d->material;
263 }
264
265 m_d->material = m_d->commondata->matVisAttributes()->get("DEFAULT");
266 assert(m_d->material);
267 m_d->material->ref();
268 return m_d->material;
269}

◆ muonChamberDirty()

bool VolumeHandle::muonChamberDirty ( ) const
inline

Definition at line 160 of file VolumeHandle.h.

◆ muonChamberState()

VolumeHandle::MuonChamberState VolumeHandle::muonChamberState ( ) const
inline

Definition at line 158 of file VolumeHandle.h.

158{ return m_muonChamberState; }

◆ muonChamberT0()

QString VolumeHandle::muonChamberT0 ( unsigned int = 0) const
inlinevirtual
Parameters
-i

Reimplemented in MuonVolumeHandle.

Definition at line 171 of file VolumeHandle.h.

171 {
172 return QString();
173}

◆ nChildren()

unsigned VolumeHandle::nChildren ( ) const
inline

Definition at line 152 of file VolumeHandle.h.

152{ return m_nchildren; }

◆ nodeSoSeparator()

SoSeparator * VolumeHandle::nodeSoSeparator ( ) const

Definition at line 272 of file VolumeHandle.cxx.

273{
274 return m_d->nodesep;
275}

◆ operator=()

VolumeHandle & VolumeHandle::operator= ( const VolumeHandle & )
private

◆ parent()

VolumeHandle * VolumeHandle::parent ( )
inline

Definition at line 147 of file VolumeHandle.h.

147{ return m_parent; }

◆ reset()

void VolumeHandle::reset ( )
inline

Definition at line 161 of file VolumeHandle.h.

◆ setMuonChamberDirty()

void VolumeHandle::setMuonChamberDirty ( bool b)
inline

◆ setState()

void VolumeHandle::setState ( const VP1GeoFlags::VOLSTATE & state,
bool autoExpandEther = true )

Definition at line 391 of file VolumeHandle.cxx.

392{
393 if (m_state==state)
394 return;
395
396 // Mark muon chamber as dirty.
397 if (isInMuonChamber()) {
401 }
402
403 // Update state flag and presence in GUI lists:
405 m_state = state;
406 if (oldstate==VP1GeoFlags::ZAPPED)
407 m_d->commondata->removeZappedVolumesFromGui(this);
408 else if (state==VP1GeoFlags::ZAPPED)
409 m_d->commondata->addZappedVolumeToGui(this);
410
411 if (!autoExpandEther) {
413 return;
415 m_d->attach(this);
417 } else if (state==VP1GeoFlags::EXPANDED) {
418 if (oldstate==VP1GeoFlags::CONTRACTED)
419 m_d->detach();
421 } else {
422 assert(state==VP1GeoFlags::ZAPPED);
423 if (oldstate==VP1GeoFlags::CONTRACTED)
424 m_d->detach();
425 else
427 }
428 return;
429 }
430
431 // Visibility updates. Ether volumes are automatically expanded so that
432 // the first non-ether descendants become visible.
433
435 for (auto d=childrenBegin(); d!=childrenEnd(); d++) {
436 if ((*d)->isEther())
437 (*d)->setState(VP1GeoFlags::CONTRACTED);
438 }
439
440 if (!isEther()) {
441 m_d->attach(this);
443 } else {
444 bool otherThanEther = false;
445 VolumeHandle *p = parent();
446 while (p) {
447 if (!p->isEther()) {
448 otherThanEther = true;
449 break;
450 }
451 p = p->parent();
452 }
453
454 if (!otherThanEther)
455 return;
456
457 m_d->attach(this);
459
460 p = parent();
461 if (p)
462 p->setState(VP1GeoFlags::CONTRACTED);
463 }
464 } else if (state==VP1GeoFlags::EXPANDED) {
465 if (oldstate==VP1GeoFlags::CONTRACTED)
466 m_d->detach();
467
469
470 for (auto d=childrenBegin(); d!=childrenEnd(); d++) {
471 if ((*d)->isEther())
472 (*d)->setState(VP1GeoFlags::EXPANDED);
473 }
474 } else {
475 assert(state==VP1GeoFlags::ZAPPED);
476
477 if (oldstate==VP1GeoFlags::CONTRACTED)
478 m_d->detach();
479 else
481 }
482}
void attachAllContractedChildren()
VolumeHandleListItr childrenBegin()
VolumeHandleListItr childrenEnd()
VolumeHandle * topLevelParent()
void detachAllContractedChildren()

◆ state()

VP1GeoFlags::VOLSTATE VolumeHandle::state ( ) const
inline

Definition at line 155 of file VolumeHandle.h.

155{ return m_state; }

◆ subsystem()

VP1GeoFlags::SubSystemFlag VolumeHandle::subsystem ( ) const

Definition at line 679 of file VolumeHandle.cxx.

680{
681 return m_d->commondata->subSystemFlag();
682}

◆ topLevelParent()

VolumeHandle * VolumeHandle::topLevelParent ( )
inline

Definition at line 148 of file VolumeHandle.h.

148{ return m_parent ? m_parent->topLevelParent() : this; }

◆ updateLabels()

void VolumeHandle::updateLabels ( )

Definition at line 766 of file VolumeHandle.cxx.

766 {
767 int labels = m_d->commondata->controller()->labels();
768 QList<int> offsets = m_d->commondata->controller()->labelPosOffset();
769
770 m_d->attachlabelSepHelper->largeChangesBegin();
771
772 if ( m_d->labels != labels || m_d->labelsPosOffsets != offsets){
773 m_d->labels = labels;
774 m_d->labelsPosOffsets = offsets;
775 m_d->label_sep->removeAllChildren ();
776
777 SoText2 *labelText = new SoText2;
778 labelText->ref();
779 QStringList text;
780 if (labels&0x1){
781 QString name = getDescriptiveName();
782 text << name;
783 }
784
785 // only one label selected - must be better way to do this!
786 bool singleLabel = (labels&0x2 && !(labels&0x4) && !(labels&0x8))
787 || (labels&0x4 && !(labels&0x2) && !(labels&0x8))
788 || (labels&0x8 && !(labels&0x2) && !(labels&0x4));
789 if (isInMuonChamber() && labels&0xE){
790 for (unsigned int i=0; i<3 ;++i){
791 // Check to see which label we use.
792 unsigned int mask=1<<(i+1);
793 if (!(labels&mask)) continue; // bits 1,2,3 are used for labels
794
795 QString output;
796 if ( singleLabel ) {
797 output+="t0=";
798 } else {
799 if (i==0) output+="Moore t0=";
800 if (i==1) output+="Mboy t0=";
801 if (i==2) output+="<unknown>=";
802 }
803 output += muonChamberT0(i);
804 text << output;
805 }
806 }
807
808 unsigned int row=0;
809 for(const QString& str : text){
810 QByteArray array = str.toLatin1();
811 labelText->string.set1Value(row++,array.data());
812 }
813
814 SoTransform *labelTranslate = VP1LinAlgUtils::toSoTransform(m_d->accumTrans);
815 assert(labelTranslate!=0);
816 float offScale=10.0;
817 float labx,laby,labz;
818 labelTranslate->translation.getValue().getValue(labx,laby,labz);
819// std::cout <<getNameStdString()<<" offsets (x,y,z)=("<<offsets[0]<<","<<offsets[1]<<","<<offsets[2]<<")"<<std::endl;
820
821 labelTranslate->translation.setValue(labx+(offsets[0]*offScale),laby+(offsets[1]*offScale),labz+(offsets[2]*offScale));
822
823 m_d->label_sep->addChild(labelTranslate);
824 m_d->label_sep->addChild(labelText);
825 }
826
827 m_d->attachlabelSepHelper->largeChangesEnd();
828}
virtual QString muonChamberT0(unsigned int=0) const
virtual QString getDescriptiveName() const
row
Appending html table to final .html summary file.
output
Definition merge.py:16

Member Data Documentation

◆ m_childNumber

const int VolumeHandle::m_childNumber
private

Definition at line 130 of file VolumeHandle.h.

◆ m_children

VolumeHandleList VolumeHandle::m_children
private

Definition at line 135 of file VolumeHandle.h.

◆ m_d

Imp* VolumeHandle::m_d
private

Definition at line 127 of file VolumeHandle.h.

◆ m_muonChamberState

MuonChamberState VolumeHandle::m_muonChamberState
private

Definition at line 132 of file VolumeHandle.h.

◆ m_nchildren

const unsigned VolumeHandle::m_nchildren
private

Definition at line 131 of file VolumeHandle.h.

◆ m_parent

VolumeHandle* VolumeHandle::m_parent
private

Definition at line 134 of file VolumeHandle.h.

◆ m_state

VP1GeoFlags::VOLSTATE VolumeHandle::m_state
private

Definition at line 136 of file VolumeHandle.h.


The documentation for this class was generated from the following files: