ATLAS Offline Software
Loading...
Searching...
No Matches
VolumeHandle.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef VOLUMEHANDLE_H
6#define VOLUMEHANDLE_H
7
8#include <vector>
9
11#include <QString>
12
13//Only initialises child classes on demand. And even then their SoNodes are not initialised until they must be shown.
15class SoMaterial;
16class SoSeparator;
17class GeoMaterial;
18#include <Inventor/C/errors/debugerror.h>
19#include <Inventor/SbMatrix.h>
20
22public:
23
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
28 inline bool isInMuonChamber() const;//Muon chamber volume or muon chamber offspring
29 inline bool isMuonChamber() const;//Muon chamber volume (top-level volume)
30 inline void setMuonChamberDirty(bool);//Don't call unless isMuonChamber()
31 inline bool muonChamberDirty() const;//if is a muon chamber volume which is dirty
33
35 const MuonChamberState& mcs = NONMUONCHAMBER, const SbMatrix& accumTrans = SbMatrix() );
36
37 virtual ~VolumeHandle();//lots of stuff to do here!
38 //Used (recursively) upon deletion (never delete before children are deleted).
39 void initialiseChildren();
40 inline bool childrenAreInitialised() const; //Always check this before getting the child list iterators
41 unsigned nChildren() const;//Works even before children are initialised
42
43 SoMaterial * material();
44
45 //Information for printout:
46 QString getName() const;
47 int copyNumber() const;//Returns -1 if doesnt have a valid copy number (because volume is not replicated), -2 in case of error.
48 quint32 hashID() const;//For vp1 persistification
49
50 GeoPVConstLink geoPVConstLink() const;
51 const GeoMaterial * geoMaterial() const;
52 std::string getNameStdString() const;
53
54 bool hasName(const std::string&) const;
55
56 const SbMatrix& getGlobalTransformToVolume() const;//Transform from world to this volume.
57 SbMatrix getLocalTransformToVolume() const;//Transform from mother (=world for treetops) to this volume.
58
59 bool isPositiveZ() const;//Uses getGlobalTransformToVolume to figure out whether Z of the transformation.
60
62 // Navigation: //
64 typedef std::vector<VolumeHandle *> VolumeHandleList;
65 typedef VolumeHandleList::iterator VolumeHandleListItr;
66 typedef VolumeHandleList::const_iterator VolumeHandleListConstItr;
67
68 inline VolumeHandle * parent();//returns 0 if toplevel.
69 inline VolumeHandle * topLevelParent();//goes up through parents and returns the toplevel one (returns itself if toplevel).
70 inline VolumeHandleListItr childrenBegin();//Dont use if not childrenAreInitialised().
71 inline VolumeHandleListItr childrenEnd();//Dont use if not childrenAreInitialised()
72 inline VolumeHandle * child(int index) const;//Will crash if out of range!
73 inline int childNumber() const;
74
75 // void zoomToVolume(SoCamera*, SoSeparator * root);
76 // void ensureVisibleInTreeWidget();
77
78 inline VP1GeoFlags::VOLSTATE state() const;
80 void reset();//Set state of volume and all daughters to contracted
81 bool isAttached() const;
83
84 bool isEther() const;
85 void expandMothersRecursivelyToNonEther();//expands the tree down to volumes that are either not ether or without children
86
87 bool isInitialisedAndHasNonStandardShape() const;//True if the 3D shape of this volume can not be represented by standard VRML nodes.
88
89 SoSeparator * nodeSoSeparator() const;//Returns pointer to 3D representation of volume (null if not built yet).
90 void ensureBuildNodeSep();
91
92 //Convenience:
93 // void zap();
94 // void ensureVisible();
95 // void expandAllChildren(unsigned limit = 50);
96
97 // void ensureVisibleInTreeWidget();
98 // double mass() const;
99 // int copyNumber() const;
100 // ...
101 // Get SoNodes, pvconstlink, ...
102
103 void updateLabels();
104
105 QByteArray getPersistifiableState() const;
106 void applyPersistifiableState(QByteArray);
107
108 // Which subsystem I'm in?
110
111 // For labels
112 virtual QString getDescriptiveName() const;
113 virtual QString muonChamberT0(unsigned int=0) const;
114
115public:
116 class Imp;//For once this is declared public. This is to avoid
117 //problems with datastream operators.
118private:
119
120 // Illegal to copy/assign a VolumeHandle:
123
125
126 //Here for inline methods:
127 const int m_childNumber;//0 if the first child of parent, 1 if the second, etc.
128 const unsigned m_nchildren;//cached for efficiency.
130
134 //Some of these could be moved to private implementation with some care:
135 bool haveParentsNotExpanded() const;
136 void attachAllContractedChildren();//also checks children of expanded children (recursively).
137 void detachAllContractedChildren();//also checks children of expanded children (recursively).
138};
139
141// INLINES //
143
145inline VolumeHandle * VolumeHandle::topLevelParent() { return m_parent ? m_parent->topLevelParent() : this; }
146inline bool VolumeHandle::childrenAreInitialised() const { return m_children.size()==m_nchildren; }
149inline unsigned VolumeHandle::nChildren() const { return m_nchildren; }
150inline VolumeHandle * VolumeHandle::child(int index) const { return m_children.at(index); }
151inline int VolumeHandle::childNumber() const { return m_childNumber; }
162inline QString VolumeHandle::getDescriptiveName() const {
163 QString name = getName();
164 name.remove("_Station");
165 return name;
166}
167
168inline QString VolumeHandle::muonChamberT0(unsigned int ) const {
169 return QString();
170}
171
172
173#endif
void setState(const VP1GeoFlags::VOLSTATE &state)
bool hasName(const std::string &) const
VolumeHandle(VolumeHandleSharedData *, VolumeHandle *parent, const GeoPVConstLink &, int childNumber, const MuonChamberState &mcs=NONMUONCHAMBER, const SbMatrix &accumTrans=SbMatrix())
bool isMuonChamber() const
bool childrenAreInitialised() const
virtual ~VolumeHandle()
VolumeHandleList::const_iterator VolumeHandleListConstItr
bool isPositiveZ() const
const SbMatrix & getGlobalTransformToVolume() const
std::string getNameStdString() const
void attachAllContractedChildren()
VP1GeoFlags::VOLSTATE state() const
const GeoMaterial * geoMaterial() const
VolumeHandle & operator=(const VolumeHandle &)
void initialiseChildren()
QString getName() const
void ensureBuildNodeSep()
VolumeHandleListItr childrenBegin()
MuonChamberState m_muonChamberState
void applyPersistifiableState(QByteArray)
SbMatrix getLocalTransformToVolume() const
SoMaterial * material()
virtual QString muonChamberT0(unsigned int=0) const
VolumeHandleListItr childrenEnd()
VolumeHandle * topLevelParent()
bool isEther() const
VolumeHandle(const VolumeHandle &)
void contractDaughtersRecursively()
VP1GeoFlags::VOLSTATE m_state
bool isAttached() const
SoSeparator * nodeSoSeparator() const
std::vector< VolumeHandle * > VolumeHandleList
bool muonChamberDirty() const
GeoPVConstLink geoPVConstLink() const
bool haveParentsNotExpanded() const
bool isInitialisedAndHasNonStandardShape() const
int copyNumber() const
void detachAllContractedChildren()
bool isInMuonChamber() const
MuonChamberState muonChamberState() const
VolumeHandle * m_parent
void setMuonChamberDirty(bool)
virtual QString getDescriptiveName() const
VolumeHandleList m_children
void expandMothersRecursivelyToNonEther()
VolumeHandleList::iterator VolumeHandleListItr
const unsigned m_nchildren
const int m_childNumber
VP1GeoFlags::SubSystemFlag subsystem() const
quint32 hashID() const
VolumeHandle * parent()
int childNumber() const
QByteArray getPersistifiableState() const
VolumeHandle * child(int index) const
unsigned nChildren() const
Definition index.py:1