ATLAS Offline Software
Loading...
Searching...
No Matches
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//____________________________________________________________________
27public:
28 Imp() : sep(0),isAttached(false) {}
33 SoSeparator * sep;//First child is transform, second - if present - is node.
35
36 bool hasShape() const
37 {
38 return sep&&sep->getNumChildren()>1;
39 }
40
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)
60 m_d->ensureDetach3DObjects(this);
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);
76 m_d->ensureAttach3DObjects(this);
77 } else {
78 m_d->ensureDetach3DObjects(this);
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;
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
141 if (sep && sh)
142 sh->addNode(sep);
143}
144
145//____________________________________________________________________
147{
148 if (!isAttached)
149 return;
150 isAttached = false;
151
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{
168 m_d->ensureInitSepAndTransform(this);
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}
#define y
#define x
#define z
VP1ExtraSepLayerHelper * sepHelper() const
void updateVolumeOutlines(SoGroup *)
void registerTransformAndHandle(SoTransform *, VP1RawDataHandleBase *)
void ensureAttach3DObjects(VP1RawDataHandleBase *theclass)
void rebuild3DObjects(VP1RawDataHandleBase *)
void ensureInitSepAndTransform(VP1RawDataHandleBase *theclass)
void ensureDetach3DObjects(VP1RawDataHandleBase *theclass)
VP1RawDataCommonData * common() const
virtual SoNode * buildShape()=0
virtual SoTransform * buildTransform()=0
virtual Amg::Vector3D center()
VP1RawDataHandleBase(VP1RawDataCollBase *)
static QString unsignedToHex(unsigned)
VP1RawDataCollBase * coll() const
VP1RawDataCollBase * m_coll
Eigen::Matrix< double, 3, 1 > Vector3D