ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1RawDataSystems
src
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
15
#include "
VP1RawDataSystems/VP1RawDataHandleBase.h
"
16
#include "
VP1RawDataSystems/VP1RawDataCommonData.h
"
17
#include "
VP1Base/VP1ExtraSepLayerHelper.h
"
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
//____________________________________________________________________
26
class
VP1RawDataHandleBase::Imp
{
27
public
:
28
Imp
() :
sep
(0),
isAttached
(false) {}
29
void
rebuild3DObjects
(
VP1RawDataHandleBase
*);
30
void
ensureAttach3DObjects
(
VP1RawDataHandleBase
*theclass);
31
void
ensureDetach3DObjects
(
VP1RawDataHandleBase
*theclass);
32
void
ensureInitSepAndTransform
(
VP1RawDataHandleBase
*theclass);
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
//____________________________________________________________________
50
VP1RawDataHandleBase::VP1RawDataHandleBase
(
VP1RawDataCollBase
*
coll
)
51
:
m_d
(new
Imp
),
m_coll
(
coll
),
m_visible
(false)
//,m_currentmaterial(0)
52
{
53
54
}
55
56
//____________________________________________________________________
57
VP1RawDataHandleBase::~VP1RawDataHandleBase
()
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
//____________________________________________________________________
68
void
VP1RawDataHandleBase::setVisible
(
bool
vis)
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
//____________________________________________________________________
83
void
VP1RawDataHandleBase::update3DObjects
()
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
//____________________________________________________________________
94
void
VP1RawDataHandleBase::Imp::ensureInitSepAndTransform
(
VP1RawDataHandleBase
*theclass)
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
//____________________________________________________________________
107
void
VP1RawDataHandleBase::Imp::rebuild3DObjects
(
VP1RawDataHandleBase
*theclass)
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
//____________________________________________________________________
134
void
VP1RawDataHandleBase::Imp::ensureAttach3DObjects
(
VP1RawDataHandleBase
*theclass)
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
//____________________________________________________________________
146
void
VP1RawDataHandleBase::Imp::ensureDetach3DObjects
(
VP1RawDataHandleBase
*theclass)
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
//____________________________________________________________________
158
QString
VP1RawDataHandleBase::unsignedToHex
(
unsigned
i)
159
{
160
std::ostringstream s;
161
s <<
"0x"
<< std::hex << i;
162
return
QString(s.str().c_str()).toUpper();
163
}
164
165
//____________________________________________________________________
166
Amg::Vector3D
VP1RawDataHandleBase::center
()
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
//____________________________________________________________________
180
void
VP1RawDataHandleBase::updateShownOutlines
()
181
{
182
if
(!
m_d
->sep)
183
return
;
184
common
()->
updateVolumeOutlines
(
m_d
->sep);
185
}
y
#define y
x
#define x
z
#define z
VP1ExtraSepLayerHelper.h
VP1RawDataCommonData.h
VP1RawDataHandleBase.h
VP1ExtraSepLayerHelper
Definition
VP1ExtraSepLayerHelper.h:22
VP1RawDataCollBase
Definition
VP1RawDataCollBase.h:29
VP1RawDataCollBase::sepHelper
VP1ExtraSepLayerHelper * sepHelper() const
Definition
VP1RawDataCollBase.cxx:70
VP1RawDataCommonData::updateVolumeOutlines
void updateVolumeOutlines(SoGroup *)
Definition
VP1RawDataCommonData.cxx:91
VP1RawDataCommonData::registerTransformAndHandle
void registerTransformAndHandle(SoTransform *, VP1RawDataHandleBase *)
Definition
VP1RawDataCommonData.cxx:54
VP1RawDataHandleBase::Imp
Definition
VP1RawDataHandleBase.cxx:26
VP1RawDataHandleBase::Imp::isAttached
bool isAttached
Definition
VP1RawDataHandleBase.cxx:34
VP1RawDataHandleBase::Imp::sep
SoSeparator * sep
Definition
VP1RawDataHandleBase.cxx:33
VP1RawDataHandleBase::Imp::ensureAttach3DObjects
void ensureAttach3DObjects(VP1RawDataHandleBase *theclass)
Definition
VP1RawDataHandleBase.cxx:134
VP1RawDataHandleBase::Imp::rebuild3DObjects
void rebuild3DObjects(VP1RawDataHandleBase *)
Definition
VP1RawDataHandleBase.cxx:107
VP1RawDataHandleBase::Imp::hasShape
bool hasShape() const
Definition
VP1RawDataHandleBase.cxx:36
VP1RawDataHandleBase::Imp::ensureInitSepAndTransform
void ensureInitSepAndTransform(VP1RawDataHandleBase *theclass)
Definition
VP1RawDataHandleBase.cxx:94
VP1RawDataHandleBase::Imp::Imp
Imp()
Definition
VP1RawDataHandleBase.cxx:28
VP1RawDataHandleBase::Imp::clearShape
void clearShape()
Definition
VP1RawDataHandleBase.cxx:41
VP1RawDataHandleBase::Imp::ensureDetach3DObjects
void ensureDetach3DObjects(VP1RawDataHandleBase *theclass)
Definition
VP1RawDataHandleBase.cxx:146
VP1RawDataHandleBase::~VP1RawDataHandleBase
virtual ~VP1RawDataHandleBase()
Definition
VP1RawDataHandleBase.cxx:57
VP1RawDataHandleBase::common
VP1RawDataCommonData * common() const
Definition
VP1RawDataHandleBase.h:41
VP1RawDataHandleBase::buildShape
virtual SoNode * buildShape()=0
VP1RawDataHandleBase::buildTransform
virtual SoTransform * buildTransform()=0
VP1RawDataHandleBase::center
virtual Amg::Vector3D center()
Definition
VP1RawDataHandleBase.cxx:166
VP1RawDataHandleBase::VP1RawDataHandleBase
VP1RawDataHandleBase(VP1RawDataCollBase *)
Definition
VP1RawDataHandleBase.cxx:50
VP1RawDataHandleBase::setVisible
void setVisible(bool)
Definition
VP1RawDataHandleBase.cxx:68
VP1RawDataHandleBase::update3DObjects
void update3DObjects()
Definition
VP1RawDataHandleBase.cxx:83
VP1RawDataHandleBase::unsignedToHex
static QString unsignedToHex(unsigned)
Definition
VP1RawDataHandleBase.cxx:158
VP1RawDataHandleBase::m_visible
bool m_visible
Definition
VP1RawDataHandleBase.h:71
VP1RawDataHandleBase::m_d
Imp * m_d
Definition
VP1RawDataHandleBase.h:68
VP1RawDataHandleBase::updateShownOutlines
void updateShownOutlines()
Definition
VP1RawDataHandleBase.cxx:180
VP1RawDataHandleBase::coll
VP1RawDataCollBase * coll() const
Definition
VP1RawDataHandleBase.h:40
VP1RawDataHandleBase::m_coll
VP1RawDataCollBase * m_coll
Definition
VP1RawDataHandleBase.h:70
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
RCU::Shell
Definition
ShellExec.cxx:25
Generated on
for ATLAS Offline Software by
1.17.0