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 QString getNameTag() const;
48 QString getDisplayName() const;
49 int copyNumber() const;//Returns -1 if doesnt have a valid copy number (because volume is not replicated), -2 in case of error.
50 quint32 hashID() const;//For vp1 persistification
51
52 GeoPVConstLink geoPVConstLink() const;
53 const GeoMaterial * geoMaterial() const;
54 std::string getNameStdString() const;
55
56 bool hasName(const std::string&) const;
57
58 const SbMatrix& getGlobalTransformToVolume() const;//Transform from world to this volume.
59 SbMatrix getLocalTransformToVolume() const;//Transform from mother (=world for treetops) to this volume.
60
61 bool isPositiveZ() const;//Uses getGlobalTransformToVolume to figure out whether Z of the transformation.
62
64 // Navigation: //
66 typedef std::vector<VolumeHandle *> VolumeHandleList;
67 typedef VolumeHandleList::iterator VolumeHandleListItr;
68 typedef VolumeHandleList::const_iterator VolumeHandleListConstItr;
69
70 inline VolumeHandle * parent();//returns 0 if toplevel.
71 inline VolumeHandle * topLevelParent();//goes up through parents and returns the toplevel one (returns itself if toplevel).
72 inline VolumeHandleListItr childrenBegin();//Dont use if not childrenAreInitialised().
73 inline VolumeHandleListItr childrenEnd();//Dont use if not childrenAreInitialised()
74 inline VolumeHandle * child(int index) const;//Will crash if out of range!
75 inline int childNumber() const;
76
77 // void zoomToVolume(SoCamera*, SoSeparator * root);
78 // void ensureVisibleInTreeWidget();
79
80 inline VP1GeoFlags::VOLSTATE state() const;
81 // Selection filters disable ether propagation to preserve explicit child states.
82 void setState( const VP1GeoFlags::VOLSTATE& state, bool autoExpandEther = true );
83 void reset();//Set state of volume and all daughters to contracted
84 bool isAttached() const;
86
87 bool isEther() const;
88 void expandMothersRecursivelyToNonEther();//expands the tree down to volumes that are either not ether or without children
89
90 bool isInitialisedAndHasNonStandardShape() const;//True if the 3D shape of this volume can not be represented by standard VRML nodes.
91
92 SoSeparator * nodeSoSeparator() const;//Returns pointer to 3D representation of volume (null if not built yet).
93 void ensureBuildNodeSep();
94
95 //Convenience:
96 // void zap();
97 // void ensureVisible();
98 // void expandAllChildren(unsigned limit = 50);
99
100 // void ensureVisibleInTreeWidget();
101 // double mass() const;
102 // int copyNumber() const;
103 // ...
104 // Get SoNodes, pvconstlink, ...
105
106 void updateLabels();
107
108 QByteArray getPersistifiableState() const;
109 void applyPersistifiableState(QByteArray);
110
111 // Which subsystem I'm in?
113
114 // For labels
115 virtual QString getDescriptiveName() const;
116 virtual QString muonChamberT0(unsigned int=0) const;
117
118public:
119 class Imp;//For once this is declared public. This is to avoid
120 //problems with datastream operators.
121private:
122
123 // Illegal to copy/assign a VolumeHandle:
126
128
129 //Here for inline methods:
130 const int m_childNumber;//0 if the first child of parent, 1 if the second, etc.
131 const unsigned m_nchildren;//cached for efficiency.
133
137 //Some of these could be moved to private implementation with some care:
138 bool haveParentsNotExpanded() const;
139 void attachAllContractedChildren();//also checks children of expanded children (recursively).
140 void detachAllContractedChildren();//also checks children of expanded children (recursively).
141};
142
144// INLINES //
146
148inline VolumeHandle * VolumeHandle::topLevelParent() { return m_parent ? m_parent->topLevelParent() : this; }
149inline bool VolumeHandle::childrenAreInitialised() const { return m_children.size()==m_nchildren; }
152inline unsigned VolumeHandle::nChildren() const { return m_nchildren; }
153inline VolumeHandle * VolumeHandle::child(int index) const { return m_children.at(index); }
154inline int VolumeHandle::childNumber() const { return m_childNumber; }
165inline QString VolumeHandle::getDescriptiveName() const {
166 QString name = getName();
167 name.remove("_Station");
168 return name;
169}
170
171inline QString VolumeHandle::muonChamberT0(unsigned int ) const {
172 return QString();
173}
174
175
176#endif
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
QString getDisplayName() 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()
void setState(const VP1GeoFlags::VOLSTATE &state, bool autoExpandEther=true)
VolumeHandleList::iterator VolumeHandleListItr
const unsigned m_nchildren
const int m_childNumber
VP1GeoFlags::SubSystemFlag subsystem() const
quint32 hashID() const
VolumeHandle * parent()
int childNumber() const
QString getNameTag() const
QByteArray getPersistifiableState() const
VolumeHandle * child(int index) const
unsigned nChildren() const
Definition index.py:1