ATLAS Offline Software
VP1RawDataHandleBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class VP1RawDataHandleBase //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: April 2008 //
12 // //
14 
18 
19 #include <Inventor/nodes/SoSeparator.h>
20 #include <Inventor/nodes/SoTransform.h>
21 #include <Inventor/nodes/SoMaterial.h>
22 
23 #include <sstream>
24 
25 //____________________________________________________________________
27 public:
28  Imp() : sep(0),isAttached(false) {}
33  SoSeparator * sep;//First child is transform, second - if present - is node.
34  bool isAttached;
35 
36  bool hasShape() const
37  {
38  return sep&&sep->getNumChildren()>1;
39  }
40 
41  void clearShape()
42  {
43  if (hasShape()) {
44  sep->removeChild(1);
45  }
46  }
47 };
48 
49 //____________________________________________________________________
51  : m_d(new Imp), m_coll(coll), m_visible(false)//,m_currentmaterial(0)
52 {
53 
54 }
55 
56 //____________________________________________________________________
58 {
59  if (m_visible)
61  m_d->clearShape();
62  if (m_d->sep)
63  m_d->sep->unref();
64  delete m_d;
65 }
66 
67 //____________________________________________________________________
69 {
70  if (vis==m_visible)
71  return;
72  m_visible=vis;
73  if (vis) {
74  if (!m_d->hasShape())
75  m_d->rebuild3DObjects(this);
77  } else {
79  }
80 }
81 
82 //____________________________________________________________________
84 {
85  if (m_visible) {
86  m_d->rebuild3DObjects(this);
87  } else {
88  //Simply clear the present 3D objects. They will only be recreated if/when the handle becomes visible again.
89  m_d->clearShape();
90  }
91 }
92 
93 //____________________________________________________________________
95 {
96  if (sep)
97  return;
98  sep = new SoSeparator;
99  sep->ref();
100  SoTransform * transform = theclass->buildTransform();
101  sep->addChild(transform);
102  theclass->common()->registerTransformAndHandle(transform,theclass);
103 
104 }
105 
106 //____________________________________________________________________
108 {
109  if (!sep) {
110  if (!theclass->m_visible)
111  return;
112  ensureInitSepAndTransform(theclass);
113  ensureAttach3DObjects(theclass);
114  }
115 
116  bool save(false);
117  if (theclass->m_visible)
118  save = sep->enableNotify(false);
119 
120  clearShape();
121 
122  SoNode * shape = theclass->buildShape();
123  sep->addChild(shape);
124 
125  theclass->updateShownOutlines();
126 
127  if (save) {
128  sep->enableNotify(true);
129  sep->touch();
130  }
131 }
132 
133 //____________________________________________________________________
135 {
136  if (isAttached)
137  return;
138  isAttached = true;
139 
140  VP1ExtraSepLayerHelper * sh(theclass->m_coll->sepHelper());
141  if (sep && sh)
142  sh->addNode(sep);
143 }
144 
145 //____________________________________________________________________
147 {
148  if (!isAttached)
149  return;
150  isAttached = false;
151 
152  VP1ExtraSepLayerHelper * sh(theclass->m_coll->sepHelper());
153  if (sep && sh)
154  sh->removeNode(sep);
155 }
156 
157 //____________________________________________________________________
159 {
160  std::ostringstream s;
161  s << "0x" << std::hex << i;
162  return QString(s.str().c_str()).toUpper();
163 }
164 
165 //____________________________________________________________________
167 {
169  assert(m_d->sep
170  && m_d->sep->getNumChildren()>0
171  && m_d->sep->getChild(0)->getTypeId().isDerivedFrom(SoTransform::getClassTypeId()));
172 
173  float x,y,z;
174  static_cast<SoTransform*>(m_d->sep->getChild(0))->translation.getValue().getValue(x,y,z);
175  //NB: We assume that the center part of the transform is zero
176  return Amg::Vector3D(x,y,z);
177 }
178 
179 //____________________________________________________________________
181 {
182  if (!m_d->sep)
183  return;
185 }
VP1RawDataHandleBase::unsignedToHex
static QString unsignedToHex(unsigned)
Definition: VP1RawDataHandleBase.cxx:158
VP1RawDataHandleBase::m_coll
VP1RawDataCollBase * m_coll
Definition: VP1RawDataHandleBase.h:70
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1RawDataHandleBase
Definition: VP1RawDataHandleBase.h:34
VP1RawDataHandleBase::Imp::ensureInitSepAndTransform
void ensureInitSepAndTransform(VP1RawDataHandleBase *theclass)
Definition: VP1RawDataHandleBase.cxx:94
VP1RawDataHandleBase::buildShape
virtual SoNode * buildShape()=0
VP1ExtraSepLayerHelper.h
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1RawDataCollBase
Definition: VP1RawDataCollBase.h:29
VP1RawDataHandleBase::Imp::ensureAttach3DObjects
void ensureAttach3DObjects(VP1RawDataHandleBase *theclass)
Definition: VP1RawDataHandleBase.cxx:134
VP1RawDataHandleBase::~VP1RawDataHandleBase
virtual ~VP1RawDataHandleBase()
Definition: VP1RawDataHandleBase.cxx:57
VP1RawDataCommonData::registerTransformAndHandle
void registerTransformAndHandle(SoTransform *, VP1RawDataHandleBase *)
Definition: VP1RawDataCommonData.cxx:54
x
#define x
VP1RawDataHandleBase::VP1RawDataHandleBase
VP1RawDataHandleBase(VP1RawDataCollBase *)
Definition: VP1RawDataHandleBase.cxx:50
VP1RawDataHandleBase::Imp::hasShape
bool hasShape() const
Definition: VP1RawDataHandleBase.cxx:36
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
VP1RawDataHandleBase::Imp::Imp
Imp()
Definition: VP1RawDataHandleBase.cxx:28
VP1ExtraSepLayerHelper
Definition: VP1ExtraSepLayerHelper.h:22
FullCPAlgorithmsTest_eljob.sh
sh
Definition: FullCPAlgorithmsTest_eljob.py:98
VP1RawDataHandleBase::buildTransform
virtual SoTransform * buildTransform()=0
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
RCU::Shell
Definition: ShellExec.cxx:28
VP1RawDataCommonData::updateVolumeOutlines
void updateVolumeOutlines(SoGroup *)
Definition: VP1RawDataCommonData.cxx:91
VP1RawDataHandleBase::update3DObjects
void update3DObjects()
Definition: VP1RawDataHandleBase.cxx:83
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
VP1RawDataHandleBase::Imp::sep
SoSeparator * sep
Definition: VP1RawDataHandleBase.cxx:33
VP1RawDataHandleBase::Imp
Definition: VP1RawDataHandleBase.cxx:26
VP1RawDataHandleBase::Imp::rebuild3DObjects
void rebuild3DObjects(VP1RawDataHandleBase *)
Definition: VP1RawDataHandleBase.cxx:107
grepfile.sep
sep
Definition: grepfile.py:38
VP1RawDataCommonData.h
VP1RawDataHandleBase::setVisible
void setVisible(bool)
Definition: VP1RawDataHandleBase.cxx:68
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
VP1RawDataHandleBase::updateShownOutlines
void updateShownOutlines()
Definition: VP1RawDataHandleBase.cxx:180
y
#define y
VP1RawDataHandleBase::m_d
Imp * m_d
Definition: VP1RawDataHandleBase.h:67
VP1RawDataHandleBase::center
virtual Amg::Vector3D center()
Definition: VP1RawDataHandleBase.cxx:166
VP1RawDataCollBase::sepHelper
VP1ExtraSepLayerHelper * sepHelper() const
Definition: VP1RawDataCollBase.cxx:70
VP1RawDataHandleBase.h
VP1RawDataHandleBase::Imp::ensureDetach3DObjects
void ensureDetach3DObjects(VP1RawDataHandleBase *theclass)
Definition: VP1RawDataHandleBase.cxx:146
VP1RawDataHandleBase::m_visible
bool m_visible
Definition: VP1RawDataHandleBase.h:71
VP1RawDataHandleBase::Imp::isAttached
bool isAttached
Definition: VP1RawDataHandleBase.cxx:34
VP1RawDataHandleBase::Imp::clearShape
void clearShape()
Definition: VP1RawDataHandleBase.cxx:41
VP1RawDataHandleBase::common
VP1RawDataCommonData * common() const
Definition: VP1RawDataHandleBase.h:41