ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
VP1ExtraSepLayerHelper Class Reference

#include <VP1ExtraSepLayerHelper.h>

Collaboration diagram for VP1ExtraSepLayerHelper:

Classes

class  Imp
 

Public Member Functions

 VP1ExtraSepLayerHelper (SoSeparator *topsep, int numberOfNodesPerExtraSep=32)
 
 ~VP1ExtraSepLayerHelper ()
 
SoSeparator * topSeparator () const
 
int numberOfNodesPerExtraSep () const
 
void addNode (SoNode *)
 
void removeNode (SoNode *)
 
void largeChangesBegin ()
 
void largeChangesEnd ()
 
void addNodeUnderMaterial (SoNode *, SoMaterial *)
 
void removeNodeUnderMaterial (SoNode *, SoMaterial *)
 
void moveNodeToNewMaterial (SoNode *, SoMaterial *oldmat, SoMaterial *newmat)
 

Private Member Functions

 VP1ExtraSepLayerHelper (const VP1ExtraSepLayerHelper &)
 
VP1ExtraSepLayerHelperoperator= (const VP1ExtraSepLayerHelper &)
 

Private Attributes

Impm_d
 

Detailed Description

Definition at line 22 of file VP1ExtraSepLayerHelper.h.

Constructor & Destructor Documentation

◆ VP1ExtraSepLayerHelper() [1/2]

VP1ExtraSepLayerHelper::VP1ExtraSepLayerHelper ( SoSeparator *  topsep,
int  numberOfNodesPerExtraSep = 32 
)

Definition at line 33 of file VP1ExtraSepLayerHelper.cxx.

34 : m_d(new Imp(topsep,numberOfNodesPerExtraSep))
35 {
36  m_d->topsep->ref();
37 }

◆ ~VP1ExtraSepLayerHelper()

VP1ExtraSepLayerHelper::~VP1ExtraSepLayerHelper ( )

Definition at line 40 of file VP1ExtraSepLayerHelper.cxx.

41 {
42  std::map<SoMaterial*,std::pair<SoSeparator*,VP1ExtraSepLayerHelper*> >::iterator it, itE = m_d->mat2sepandhelper.end();
43  for (it = m_d->mat2sepandhelper.begin();it!=itE;++it) {
44  delete it->second.second;
45  it->second.first->unref();
46  }
47  m_d->topsep->removeAllChildren();
48  m_d->topsep->unref();
49  delete m_d; m_d=0;
50 }

◆ VP1ExtraSepLayerHelper() [2/2]

VP1ExtraSepLayerHelper::VP1ExtraSepLayerHelper ( const VP1ExtraSepLayerHelper )
private

Member Function Documentation

◆ addNode()

void VP1ExtraSepLayerHelper::addNode ( SoNode *  node)

Definition at line 54 of file VP1ExtraSepLayerHelper.cxx.

55 {
56  assert(m_d->nodes2extrasep.find(node)==m_d->nodes2extrasep.end());
57  if (VP1Msg::verbose()) {
58  if (m_d->nodes2extrasep.find(node)!=m_d->nodes2extrasep.end())
59  VP1Msg::message("VP1ExtraSepLayerHelper::addNode ERROR: Node already added!");
60  }
61 
62  if (m_d->topsep->getNumChildren()==0) {
63  SoSeparator * sep = new SoSeparator;
64  if (VP1Msg::verbose())
65  sep->setName("SepHelperInternalSep");
66  sep->renderCaching.setValue(SoSeparator::ON);
67  sep->boundingBoxCaching.setValue(SoSeparator::ON);
68  sep->addChild(node);
69  m_d->topsep->addChild(sep);
71  return;
72  }
73 
74  //Try to retrieve the last of the extra separators, and see if it still has room:
75  assert(m_d->topsep->getChild(m_d->topsep->getNumChildren()-1)->getTypeId().isDerivedFrom(SoSeparator::getClassTypeId()));
76  SoSeparator * lastsep = static_cast<SoSeparator*>(m_d->topsep->getChild(m_d->topsep->getNumChildren()-1));
77  if (lastsep->getNumChildren()<m_d->limitpersep) {
78  lastsep->addChild(node);
79  m_d->nodes2extrasep[node]=lastsep;
80  return;
81  }
82 
83  //Add a new sep and return.
84  SoSeparator * sep = new SoSeparator;
85  if (VP1Msg::verbose())
86  sep->setName("SepHelperInternalSep");
87  sep->renderCaching.setValue(SoSeparator::ON);
88  sep->boundingBoxCaching.setValue(SoSeparator::ON);
89  sep->addChild(node);
90  m_d->topsep->addChild(sep);
92 }

◆ addNodeUnderMaterial()

void VP1ExtraSepLayerHelper::addNodeUnderMaterial ( SoNode *  node,
SoMaterial *  mat 
)

Definition at line 190 of file VP1ExtraSepLayerHelper.cxx.

191 {
192  VP1Msg::messageVerbose("VP1ExtraSepLayerHelper::addNodeUnderMaterial()");
193 
194  std::map<SoMaterial*,std::pair<SoSeparator*,VP1ExtraSepLayerHelper*> >::iterator it = m_d->mat2sepandhelper.find(mat);
195  if (it==m_d->mat2sepandhelper.end()) {
196 
197  SoSeparator * matsep = new SoSeparator;
198  if (VP1Msg::verbose())
199  matsep->setName("SepHelperInternalSep_MatSep");
200  matsep->ref();
201  matsep->addChild(mat);
202  SoSeparator * sep = new SoSeparator;
203  if (VP1Msg::verbose())
204  sep->setName("SepHelperInternalSep_InternalSepHelperTop");
205  matsep->addChild(sep);
207  m_d->mat2sepandhelper[mat] = std::pair<SoSeparator*,VP1ExtraSepLayerHelper*>(matsep,mathelper);
208  mathelper->addNode(node);
209  addNode(matsep);
210  } else {
211  it->second.second->addNode(node);
212  }
213 }

◆ largeChangesBegin()

void VP1ExtraSepLayerHelper::largeChangesBegin ( )

Definition at line 135 of file VP1ExtraSepLayerHelper.cxx.

136 {
137  ++(m_d->largechangessave);
138  m_d->topsep->enableNotify(false);
139  //We "sterilise" the extra separators and the extra sep helpers
140  //also.
141 
142  //Thus, we disable notifications on all children of topsep, and we
143  //call largeChangesBegin on all internal sephelpers.
144 
145  int n = m_d->topsep->getNumChildren();
146  for (int i = 0; i < n; ++i)
147  m_d->topsep->getChild(i)->enableNotify(false);
148 
149  std::map<SoMaterial*,std::pair<SoSeparator*,VP1ExtraSepLayerHelper*> >::iterator it, itE = m_d->mat2sepandhelper.end();
150  for (it = m_d->mat2sepandhelper.begin(); it!=itE;++it)
151  it->second.second->largeChangesBegin();
152 
153 }

◆ largeChangesEnd()

void VP1ExtraSepLayerHelper::largeChangesEnd ( )

Definition at line 156 of file VP1ExtraSepLayerHelper.cxx.

157 {
158  if (m_d->largechangessave<=0)
159  return;
160  if (--(m_d->largechangessave)!=0)
161  return;
162 
163  std::map<SoMaterial*,std::pair<SoSeparator*,VP1ExtraSepLayerHelper*> >::iterator it, itE = m_d->mat2sepandhelper.end();
164  for (it = m_d->mat2sepandhelper.begin(); it!=itE;++it)
165  it->second.second->largeChangesEnd();
166 
167  int n = m_d->topsep->getNumChildren();
168  for (int i = 0; i < n; ++i) {
169  m_d->topsep->getChild(i)->enableNotify(true);
170  m_d->topsep->getChild(i)->touch();
171  }
172 
173  m_d->topsep->enableNotify(true);
174  m_d->topsep->touch();
175 }

◆ moveNodeToNewMaterial()

void VP1ExtraSepLayerHelper::moveNodeToNewMaterial ( SoNode *  node,
SoMaterial *  oldmat,
SoMaterial *  newmat 
)

Definition at line 231 of file VP1ExtraSepLayerHelper.cxx.

232 {
233  addNodeUnderMaterial(node,newmat);
235 }

◆ numberOfNodesPerExtraSep()

int VP1ExtraSepLayerHelper::numberOfNodesPerExtraSep ( ) const

Definition at line 184 of file VP1ExtraSepLayerHelper.cxx.

185 {
186  return m_d->limitpersep;
187 }

◆ operator=()

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

◆ removeNode()

void VP1ExtraSepLayerHelper::removeNode ( SoNode *  node)

Definition at line 95 of file VP1ExtraSepLayerHelper.cxx.

96 {
97  assert(m_d->nodes2extrasep.find(node)!=m_d->nodes2extrasep.end());
98  if (VP1Msg::verbose()) {
99  if (m_d->nodes2extrasep.find(node)==m_d->nodes2extrasep.end())
100  VP1Msg::message("VP1ExtraSepLayerHelper::removeNode ERROR: Node not added previously!");
101  }
102 
103  //Find extrasep and lastsep:
104  SoSeparator * extrasep = m_d->nodes2extrasep[node];
105  assert(extrasep->findChild(node)>-1);
106  assert(m_d->topsep->getChild(m_d->topsep->getNumChildren()-1)->getTypeId()==SoSeparator::getClassTypeId());
107  SoSeparator * lastsep = static_cast<SoSeparator*>(m_d->topsep->getChild(m_d->topsep->getNumChildren()-1));
108  assert(lastsep->getNumChildren()>0);
109 
110  //First, remove the node:
111  node->ref();
112  extrasep->removeChild(node);
113  node->unref();
114  m_d->nodes2extrasep.erase(m_d->nodes2extrasep.find(node));
115 
116  //Do we need to move a node from the last separator into the separator?
117  if (lastsep!=extrasep&&lastsep->getNumChildren()>0) {
118  SoNode * othernode = lastsep->getChild(lastsep->getNumChildren()-1);
119  othernode->ref();
120  lastsep->removeChild(othernode);
121  extrasep->addChild(othernode);
122  othernode->unref();
123  m_d->nodes2extrasep[othernode] = extrasep;
124  }
125 
126  //Do we need to remove the last separator?
127  if (lastsep->getNumChildren()==0) {
128  lastsep->ref();
129  m_d->topsep->removeChild(lastsep);
130  lastsep->unref();
131  }
132 }

◆ removeNodeUnderMaterial()

void VP1ExtraSepLayerHelper::removeNodeUnderMaterial ( SoNode *  node,
SoMaterial *  mat 
)

Definition at line 216 of file VP1ExtraSepLayerHelper.cxx.

217 {
218  std::map<SoMaterial*,std::pair<SoSeparator*,VP1ExtraSepLayerHelper*> >::iterator it = m_d->mat2sepandhelper.find(mat);
219  if (it==m_d->mat2sepandhelper.end())
220  return;
221  it->second.second->removeNode(node);
222  if (it->second.second->topSeparator()->getNumChildren()==0) {
223  //No more use for this material apparently:
224  removeNode(it->second.first);
225  it->second.first->unref();
226  m_d->mat2sepandhelper.erase(it);
227  }
228 }

◆ topSeparator()

SoSeparator * VP1ExtraSepLayerHelper::topSeparator ( ) const

Definition at line 178 of file VP1ExtraSepLayerHelper.cxx.

179 {
180  return m_d->topsep;
181 }

Member Data Documentation

◆ m_d

Imp* VP1ExtraSepLayerHelper::m_d
private

Definition at line 55 of file VP1ExtraSepLayerHelper.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VP1ExtraSepLayerHelper::numberOfNodesPerExtraSep
int numberOfNodesPerExtraSep() const
Definition: VP1ExtraSepLayerHelper.cxx:184
VP1ExtraSepLayerHelper::Imp::nodes2extrasep
std::map< SoNode *, SoSeparator * > nodes2extrasep
Definition: VP1ExtraSepLayerHelper.cxx:22
VP1ExtraSepLayerHelper::removeNode
void removeNode(SoNode *)
Definition: VP1ExtraSepLayerHelper.cxx:95
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
VP1ExtraSepLayerHelper::Imp::mat2sepandhelper
std::map< SoMaterial *, std::pair< SoSeparator *, VP1ExtraSepLayerHelper * > > mat2sepandhelper
Definition: VP1ExtraSepLayerHelper.cxx:28
VP1ExtraSepLayerHelper::addNodeUnderMaterial
void addNodeUnderMaterial(SoNode *, SoMaterial *)
Definition: VP1ExtraSepLayerHelper.cxx:190
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1ExtraSepLayerHelper::removeNodeUnderMaterial
void removeNodeUnderMaterial(SoNode *, SoMaterial *)
Definition: VP1ExtraSepLayerHelper.cxx:216
VP1ExtraSepLayerHelper::Imp::limitpersep
const int limitpersep
Definition: VP1ExtraSepLayerHelper.cxx:21
TruthTest.itE
itE
Definition: TruthTest.py:25
VP1ExtraSepLayerHelper::VP1ExtraSepLayerHelper
VP1ExtraSepLayerHelper(SoSeparator *topsep, int numberOfNodesPerExtraSep=32)
Definition: VP1ExtraSepLayerHelper.cxx:33
VP1ExtraSepLayerHelper::Imp::topsep
SoSeparator * topsep
Definition: VP1ExtraSepLayerHelper.cxx:20
VP1ExtraSepLayerHelper
Definition: VP1ExtraSepLayerHelper.h:22
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
PyPoolBrowser.node
node
Definition: PyPoolBrowser.py:131
grepfile.sep
sep
Definition: grepfile.py:38
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
VP1ExtraSepLayerHelper::m_d
Imp * m_d
Definition: VP1ExtraSepLayerHelper.h:54
VP1ExtraSepLayerHelper::addNode
void addNode(SoNode *)
Definition: VP1ExtraSepLayerHelper.cxx:54
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
node
Definition: memory_hooks-stdcmalloc.h:74
VP1ExtraSepLayerHelper::Imp::largechangessave
int largechangessave
Definition: VP1ExtraSepLayerHelper.cxx:25