ATLAS Offline Software
Static Public Member Functions | List of all members
VP1HEPVisUtils::Imp Class Reference
Collaboration diagram for VP1HEPVisUtils::Imp:

Static Public Member Functions

template<class T >
static SoNode * convertToAlternateRep (SoNode *)
 
template<class T >
static void clearAlternateRep (SoNode *)
 
template<class T >
static void updateAlternateRepIfNull (SoNode *)
 
static bool isGroup (SoNode *n)
 
static bool isNonCustomTree (SoGroup *g)
 
static SoGroup * convertToStandardGroupNode (SoGroup *g, bool transferChildren)
 
static SoGroup * convertToStandardScene (SoGroup *g)
 
static void updateAllNullAlternativeReps (SoGroup *g)
 

Detailed Description

Definition at line 42 of file VP1HEPVisUtils.cxx.

Member Function Documentation

◆ clearAlternateRep()

template<class T >
void VP1HEPVisUtils::Imp::clearAlternateRep ( SoNode *  n)
static

Definition at line 219 of file VP1HEPVisUtils.cxx.

220 {
221  T * t = static_cast<T*>(n);
222  if (t&&t->alternateRep.getValue())
223  t->clearAlternateRep();
224 }

◆ convertToAlternateRep()

template<class T >
SoNode * VP1HEPVisUtils::Imp::convertToAlternateRep ( SoNode *  n)
static

Definition at line 193 of file VP1HEPVisUtils.cxx.

194 {
195  if (!n)
196  return 0;
197  T * t = static_cast<T*>(n);
198  SoNode * n_alt = t->alternateRep.getValue();
199  if (n_alt) {
200  //Don't clear the alternateRep, since it was there before.
201  } else {
202  t->generateAlternateRep();
203  n_alt = t->alternateRep.getValue();
204  if (n_alt) {
205  //Clear the alternateRep, since it was not there before.
206  n_alt->ref();
207  t->clearAlternateRep();
208  n_alt->unrefNoDelete();
209  } else {
210  return 0;
211  }
212  }
213  n_alt->setName(n->getName());
214  return n_alt;
215 }

◆ convertToStandardGroupNode()

SoGroup * VP1HEPVisUtils::Imp::convertToStandardGroupNode ( SoGroup *  g,
bool  transferChildren 
)
static

Definition at line 83 of file VP1HEPVisUtils.cxx.

84 {
85  //Create new non-custom node and transfer relevant fields:
86  SoGroup * newgroup(0);
87  if ( g->getTypeId().isDerivedFrom(SoSeparator::getClassTypeId()) &&
88  ! g->getTypeId().isDerivedFrom(SoSelection::getClassTypeId()) ) {
89  SoSeparator * sep = new SoSeparator;
90  SoSeparator * origsep = static_cast<SoSeparator*>(g);
91  sep->renderCaching.setValue(origsep->renderCaching.getValue());
92  sep->boundingBoxCaching.setValue(origsep->boundingBoxCaching.getValue());
93  sep->renderCulling.setValue(origsep->renderCulling.getValue());
94  sep->pickCulling.setValue(origsep->pickCulling.getValue());
95  newgroup = sep;
96  } else if ( g->getTypeId().isDerivedFrom(SoSelection::getClassTypeId()) ) {
97  SoSelection * sel = new SoSelection;
98  SoSelection * origsel = static_cast<SoSelection*>(g);
99  sel->renderCaching.setValue(origsel->renderCaching.getValue());
100  sel->boundingBoxCaching.setValue(origsel->boundingBoxCaching.getValue());
101  sel->renderCulling.setValue(origsel->renderCulling.getValue());
102  sel->pickCulling.setValue(origsel->pickCulling.getValue());
103  sel->policy.setValue(origsel->policy.getValue());
104  newgroup = sel;
105  } else if ( g->getTypeId().isDerivedFrom(SoSwitch::getClassTypeId()) ) {
106  SoSwitch *sw = new SoSwitch;
107  sw->whichChild.setValue(static_cast<SoSwitch*>(g)->whichChild.getValue());
108  newgroup = sw;
109  } else {
110  //Everything else is just treated like a group (we could add more specialisations):
111  newgroup = new SoGroup;
112  }
113 
114  //Transfer name:
115  newgroup->setName(g->getName());
116 
117  //Transfer children:
118  if (transferChildren)
119  for (int i = 0; i<g->getNumChildren();++i)
120  newgroup->addChild(g->getChild(i));
121 
122  return newgroup;
123 }

◆ convertToStandardScene()

SoGroup * VP1HEPVisUtils::Imp::convertToStandardScene ( SoGroup *  g)
static

Definition at line 126 of file VP1HEPVisUtils.cxx.

127 {
128  if (Imp::isNonCustomTree(g))
129  return g;
130 
131  //We have to change something underneath, so we must get a new (and non-custom) group node:
132  SoGroup * thegroup = convertToStandardGroupNode(g,false/*don't transfer children*/);
133  if (!thegroup)
134  std::cout <<"BAAAAAAAAAD!"<<std::endl;
135  for (int i = 0; i<g->getNumChildren();++i) {
136  SoNode * n = g->getChild(i);
137  if (isGroup(n)) {
138  SoGroup * standard = convertToStandardScene(static_cast<SoGroup*>(n));
139  if (standard)
140  thegroup->addChild(standard);
141  else
142  std::cout <<"BAD 1"<<std::endl;
143  } else {
144  SoNode * ntoadd = isCustomNode(n)?convertCustomNodeToAlternateRep(n):n;
145  if (ntoadd)
146  thegroup->addChild(isCustomNode(n)?convertCustomNodeToAlternateRep(n):n);
147  else
148  std::cout <<"BAD 2"<<std::endl;
149  }
150  }
151 
152  return thegroup;
153 }

◆ isGroup()

bool VP1HEPVisUtils::Imp::isGroup ( SoNode *  n)
static

Definition at line 261 of file VP1HEPVisUtils.cxx.

262 {
263  return n->getTypeId().isDerivedFrom(SoGroup::getClassTypeId());
264 }

◆ isNonCustomTree()

bool VP1HEPVisUtils::Imp::isNonCustomTree ( SoGroup *  g)
static

Definition at line 61 of file VP1HEPVisUtils.cxx.

62 {
63  if (!g)
64  return true;//well...
65 
66  if (isCustomNode(g))
67  return false;
68 
69  for (int i = 0; i<g->getNumChildren();++i) {
70  SoNode * n = g->getChild(i);
71  if ( Imp::isGroup(n) ) {
72  if (!isNonCustomTree(static_cast<SoGroup*>(n)))
73  return false;
74  } else {
75  if (isCustomNode(n))
76  return false;
77  }
78  }
79  return true;
80 }

◆ updateAllNullAlternativeReps()

void VP1HEPVisUtils::Imp::updateAllNullAlternativeReps ( SoGroup *  g)
static

Definition at line 267 of file VP1HEPVisUtils.cxx.

268 {
269  for (int i = 0; i<g->getNumChildren();++i) {
270  SoNode * n = g->getChild(i);
271  if ( Imp::isGroup(n) ) {
272  updateAllNullAlternativeReps(static_cast<SoGroup*>(n));
273  } else if (VP1HEPVisUtils::isCustomNode(n)) {
274  if ( n->getTypeId().isDerivedFrom(SoCons::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoCons>(n);
275  if ( n->getTypeId().isDerivedFrom(SoLAr::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoLAr>(n);
276  //NOT IMPLEMENTED if ( n->getTypeId().isDerivedFrom(SoPcons::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoPcons>(n);
277  if ( n->getTypeId().isDerivedFrom(SoPcons::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoPcons>(n);
278  if ( n->getTypeId().isDerivedFrom(SoGenericBox::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoGenericBox>(n);
279  if ( n->getTypeId().isDerivedFrom(SoTubs::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoTubs>(n);
280  if ( n->getTypeId().isDerivedFrom(SoPolyhedron::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoPolyhedron>(n);
281  if ( n->getTypeId().isDerivedFrom(SoTessellated::getClassTypeId()) ) return Imp::updateAlternateRepIfNull<SoTessellated>(n);
282  }
283  }
284 }

◆ updateAlternateRepIfNull()

template<class T >
void VP1HEPVisUtils::Imp::updateAlternateRepIfNull ( SoNode *  n)
static

Definition at line 228 of file VP1HEPVisUtils.cxx.

229 {
230  T * t = static_cast<T*>(n);
231  if (t&&!t->alternateRep.getValue()) {
232  t->generateAlternateRep();
233  t->clearAlternateRep();
234  }
235 }

The documentation for this class was generated from the following file:
VP1HEPVisUtils::Imp::convertToStandardScene
static SoGroup * convertToStandardScene(SoGroup *g)
Definition: VP1HEPVisUtils.cxx:126
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1HEPVisUtils::Imp::isNonCustomTree
static bool isNonCustomTree(SoGroup *g)
Definition: VP1HEPVisUtils.cxx:61
VP1HEPVisUtils::isCustomNode
static bool isCustomNode(SoNode *)
Definition: VP1HEPVisUtils.cxx:183
VP1HEPVisUtils::Imp::updateAllNullAlternativeReps
static void updateAllNullAlternativeReps(SoGroup *g)
Definition: VP1HEPVisUtils.cxx:267
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:731
sel
sel
Definition: SUSYToolsTester.cxx:92
grepfile.sep
sep
Definition: grepfile.py:38
VP1HEPVisUtils::Imp::isGroup
static bool isGroup(SoNode *n)
Definition: VP1HEPVisUtils.cxx:261
VP1HEPVisUtils::Imp::convertToStandardGroupNode
static SoGroup * convertToStandardGroupNode(SoGroup *g, bool transferChildren)
Definition: VP1HEPVisUtils.cxx:83
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
VP1HEPVisUtils::convertCustomNodeToAlternateRep
static SoNode * convertCustomNodeToAlternateRep(SoNode *)
Definition: VP1HEPVisUtils.cxx:238