ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1GuideLineSystems
src
VP1EtaCone.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 VP1EtaCone //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: April 2008 //
12
// //
14
15
#include "
VP1GuideLineSystems/VP1EtaCone.h
"
16
17
#include <Inventor/C/errors/debugerror.h>
18
#include <Inventor/nodes/SoMaterial.h>
19
#include <Inventor/nodes/SoCone.h>
20
#include <Inventor/nodes/SoSeparator.h>
21
#include <Inventor/nodes/SoTranslation.h>
22
#include <Inventor/nodes/SoRotationXYZ.h>
23
24
#ifdef BUILDVP1LIGHT
25
#include "CLHEP/Units/SystemOfUnits.h"
26
#define SYSTEM_OF_UNITS CLHEP
27
#else
28
#include "GaudiKernel/SystemOfUnits.h"
29
#define SYSTEM_OF_UNITS Gaudi::Units
30
#endif
31
32
//____________________________________________________________________
33
class
VP1EtaCone::Imp
{
34
public
:
35
Imp
(
VP1EtaCone
*,
36
SoMaterial * mat,
37
SoSeparator * attachsep);
38
VP1EtaCone
*
theclass
;
39
SoMaterial *
material
;
40
SoSeparator *
attachSep
;
41
42
bool
shown
;
43
double
etaval
;
44
double
extent
;
45
46
SoSeparator *
sep
;
47
SoCone *
cone1
;
48
SoTranslation *
trans1
;
49
SoCone *
innercone1
;
50
SoTranslation *
innertrans1
;
51
SoCone *
cone2
;
52
SoTranslation *
trans2
;
53
SoCone *
innercone2
;
54
SoTranslation *
innertrans2
;
55
56
void
updateFields
();
57
void
ensureInit3DObjects
();
58
};
59
60
//____________________________________________________________________
61
VP1EtaCone::VP1EtaCone
(SoMaterial * mat,SoSeparator * attachsep,
62
IVP1System
* sys,QObject * parent)
63
: QObject(parent),
VP1HelperClassBase
(sys,
"VP1EtaCone"
),
m_d
(new
Imp
(this,mat,attachsep))
64
{
65
}
66
67
//____________________________________________________________________
68
VP1EtaCone::~VP1EtaCone
()
69
{
70
setShown
(
false
);
71
if
(
m_d
->sep)
72
m_d
->sep->unref();
73
m_d
->material->unref();
74
m_d
->attachSep->unref();
75
delete
m_d
;
76
}
77
78
//____________________________________________________________________
79
VP1EtaCone::Imp::Imp
(
VP1EtaCone
*
tc
,SoMaterial * mat,SoSeparator * as)
80
:
theclass
(
tc
),
material
(mat),
attachSep
(as),
shown
(false),
81
etaval
(1),
extent
(1),
sep
(0),
82
cone1
(0),
trans1
(0),
innercone1
(0),
innertrans1
(0),
83
cone2
(0),
trans2
(0),
innercone2
(0),
innertrans2
(0)
84
{
85
material
->ref();
86
attachSep
->ref();
87
}
88
89
//____________________________________________________________________
90
void
VP1EtaCone::Imp::ensureInit3DObjects
()
91
{
92
if
(
sep
)
93
return
;
94
theclass
->messageVerbose(
"Building 3D objects"
);
95
sep
=
new
SoSeparator;
96
sep
->ref();
97
sep
->addChild(
material
);
98
99
SoSeparator * sepfirst =
new
SoSeparator;
100
SoSeparator * sepsecond =
new
SoSeparator;
101
102
for
(
int
i = 0;i<2;++i){
103
SoRotationXYZ * xf =
new
SoRotationXYZ();
104
xf->axis=SoRotationXYZ::X;
105
xf->angle = i==0 ? 90.0*SYSTEM_OF_UNITS::deg : -90*SYSTEM_OF_UNITS::deg;
106
SoTranslation * xl =
new
SoTranslation();
107
SoCone * cone =
new
SoCone();
108
SoTranslation * innerxl =
new
SoTranslation();
109
SoCone * innercone =
new
SoCone();
110
111
if
(i==0) {
112
cone1
= cone;
113
trans1
= xl;
114
innercone1
= innercone;
115
innertrans1
= innerxl;
116
}
else
{
117
cone2
= cone;
118
trans2
= xl;
119
innercone2
= innercone;
120
innertrans2
= innerxl;
121
}
122
123
cone->removePart(SoCone::BOTTOM);
124
innercone->removePart(SoCone::BOTTOM);
125
126
SoSeparator * s(i==0?sepfirst:sepsecond);
127
s->addChild(xf);
128
s->addChild(xl);
129
s->addChild(cone);
130
s->addChild(innerxl);
131
s->addChild(innercone);
132
sep
->addChild(s);
133
}
134
}
135
136
//____________________________________________________________________
137
void
VP1EtaCone::Imp::updateFields
()
138
{
139
ensureInit3DObjects
();
140
theclass
->messageVerbose(
"Updating fields"
);
141
142
double
theta
= 2*atan(exp(-fabs(
etaval
)));
143
double
tanfact = tan(
theta
);
144
bool
etaconeextentisz = (
extent
<0);
145
double
absextent = fabs(
extent
);
146
double
coneHeight,bottomRadius;
147
if
(etaconeextentisz) {
148
coneHeight = absextent;
149
bottomRadius = coneHeight*tanfact;
150
}
else
{
151
bottomRadius = absextent;
152
coneHeight=bottomRadius/tanfact;
153
}
154
155
theclass
->messageVerbose(
"etaval = "
+
str
(
etaval
));
156
theclass
->messageVerbose(
"extent = "
+
str
(
extent
));
157
theclass
->messageVerbose(
"absextent = "
+
str
(absextent));
158
theclass
->messageVerbose(
"tanfact = "
+
str
(tanfact));
159
theclass
->messageVerbose(
"bottomRadius = "
+
str
(bottomRadius));
160
theclass
->messageVerbose(
"coneHeight = "
+
str
(coneHeight));
161
162
cone1
->bottomRadius = bottomRadius;
163
cone1
->height = coneHeight;
164
cone2
->bottomRadius = bottomRadius;
165
cone2
->height = coneHeight;
166
trans1
->translation.setValue(0, -coneHeight/2, 0);
167
trans2
->translation.setValue(0, -coneHeight/2, 0);
168
169
innercone1
->bottomRadius = bottomRadius;
170
innercone1
->height = -coneHeight;
171
innercone2
->bottomRadius = bottomRadius;
172
innercone2
->height = -coneHeight;
173
//To avoid render flicker from the overlapping cones, we move the inner cone slightly away from origo:
174
const
double
epsilon = 0.50*SYSTEM_OF_UNITS::mm;
175
innertrans1
->translation.setValue(0, coneHeight/2+1.001*coneHeight/2+epsilon, 0);
176
innertrans2
->translation.setValue(0, coneHeight/2+1.001*coneHeight/2+epsilon, 0);
177
178
}
179
180
//____________________________________________________________________
181
void
VP1EtaCone::setShown
(
bool
b)
182
{
183
messageVerbose
(
"Signal received: setShown("
+
str
(b)+
")"
);
184
if
(
m_d
->shown==b)
185
return
;
186
m_d
->shown=b;
187
if
(
m_d
->shown) {
188
m_d
->updateFields();
189
if
(
m_d
->attachSep->findChild(
m_d
->sep)<0)
190
m_d
->attachSep->addChild(
m_d
->sep);
191
}
else
{
192
if
(
m_d
->sep&&
m_d
->attachSep->findChild(
m_d
->sep)>=0)
193
m_d
->attachSep->removeChild(
m_d
->sep);
194
}
195
}
196
197
//____________________________________________________________________
198
void
VP1EtaCone::setExtent
(
const
double
&p)
199
{
200
messageVerbose
(
"Signal received: setExtent("
+
str
(p)+
")"
);
201
if
(
m_d
->extent==p)
202
return
;
203
m_d
->extent=p;
204
if
(
m_d
->shown)
205
m_d
->updateFields();
206
}
207
208
//____________________________________________________________________
209
void
VP1EtaCone::setEtaValue
(
const
double
&p)
210
{
211
messageVerbose
(
"Signal received: setEtaValue("
+
str
(p)+
")"
);
212
if
(
m_d
->etaval==p)
213
return
;
214
m_d
->etaval=p;
215
if
(
m_d
->shown)
216
m_d
->updateFields();
217
}
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
tc
static Double_t tc
Definition
LArPhysWaveHECTool.cxx:38
VP1EtaCone.h
IVP1System
Definition
IVP1System.h:36
VP1EtaCone::Imp
Definition
VP1EtaCone.cxx:33
VP1EtaCone::Imp::attachSep
SoSeparator * attachSep
Definition
VP1EtaCone.cxx:40
VP1EtaCone::Imp::innercone1
SoCone * innercone1
Definition
VP1EtaCone.cxx:49
VP1EtaCone::Imp::trans2
SoTranslation * trans2
Definition
VP1EtaCone.cxx:52
VP1EtaCone::Imp::material
SoMaterial * material
Definition
VP1EtaCone.cxx:39
VP1EtaCone::Imp::sep
SoSeparator * sep
Definition
VP1EtaCone.cxx:46
VP1EtaCone::Imp::shown
bool shown
Definition
VP1EtaCone.cxx:42
VP1EtaCone::Imp::extent
double extent
Definition
VP1EtaCone.cxx:44
VP1EtaCone::Imp::trans1
SoTranslation * trans1
Definition
VP1EtaCone.cxx:48
VP1EtaCone::Imp::updateFields
void updateFields()
Definition
VP1EtaCone.cxx:137
VP1EtaCone::Imp::ensureInit3DObjects
void ensureInit3DObjects()
Definition
VP1EtaCone.cxx:90
VP1EtaCone::Imp::cone2
SoCone * cone2
Definition
VP1EtaCone.cxx:51
VP1EtaCone::Imp::innertrans1
SoTranslation * innertrans1
Definition
VP1EtaCone.cxx:50
VP1EtaCone::Imp::Imp
Imp(VP1EtaCone *, SoMaterial *mat, SoSeparator *attachsep)
Definition
VP1EtaCone.cxx:79
VP1EtaCone::Imp::innercone2
SoCone * innercone2
Definition
VP1EtaCone.cxx:53
VP1EtaCone::Imp::innertrans2
SoTranslation * innertrans2
Definition
VP1EtaCone.cxx:54
VP1EtaCone::Imp::etaval
double etaval
Definition
VP1EtaCone.cxx:43
VP1EtaCone::Imp::cone1
SoCone * cone1
Definition
VP1EtaCone.cxx:47
VP1EtaCone::Imp::theclass
VP1EtaCone * theclass
Definition
VP1EtaCone.cxx:38
VP1EtaCone::setEtaValue
void setEtaValue(const double &)
Definition
VP1EtaCone.cxx:209
VP1EtaCone::m_d
Imp * m_d
Definition
VP1EtaCone.h:49
VP1EtaCone::VP1EtaCone
VP1EtaCone(SoMaterial *mat, SoSeparator *attachsep, IVP1System *sys, QObject *parent=0)
Definition
VP1EtaCone.cxx:61
VP1EtaCone::setShown
void setShown(bool)
Definition
VP1EtaCone.cxx:181
VP1EtaCone::~VP1EtaCone
virtual ~VP1EtaCone()
Definition
VP1EtaCone.cxx:68
VP1EtaCone::setExtent
void setExtent(const double &)
Definition
VP1EtaCone.cxx:198
VP1HelperClassBase::VP1HelperClassBase
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
Definition
VP1HelperClassBase.cxx:28
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition
VP1HelperClassBase.cxx:78
str
Definition
BTagTrackIpAccessor.cxx:11
Generated on
for ATLAS Offline Software by
1.17.0