ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Systems
VP1GuideLineSystems
src
VP1Floor.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Implementation of class VP1Floor //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: July 2008 //
12
// //
14
15
#include "
VP1GuideLineSystems/VP1Floor.h
"
16
#include <Inventor/nodes/SoSeparator.h>
17
#include <Inventor/nodes/SoVertexProperty.h>
18
#include <Inventor/nodes/SoLineSet.h>
19
#include <Inventor/SbColor4f.h>
20
21
#ifdef BUILDVP1LIGHT
22
#include "CLHEP/Units/SystemOfUnits.h"
23
#define SYSTEM_OF_UNITS CLHEP
24
#else
25
#include "GaudiKernel/SystemOfUnits.h"
26
#define SYSTEM_OF_UNITS Gaudi::Units
27
#endif
28
29
//____________________________________________________________________
30
bool
VP1Floor::calcParsFromExtentAndSpacing
(
const
VP1HelperClassBase
*helper,
const
double
& extent,
const
double
& spacing,
const
int
& nmaxlimit,
int
&
nmax
,
double
& distmax )
31
{
32
if
(extent<0.0||spacing<=0.0)
33
return
false
;
34
nmax
=
static_cast<
int
>
(extent/spacing+0.5);
35
if
(
nmax
<1)
36
nmax
=1;
37
if
(
nmax
>nmaxlimit) {
38
helper->message(
"Too many lines requested. All will not be shown."
);
39
nmax
=nmaxlimit;
40
}
41
distmax =
nmax
*spacing;
42
return
true
;
43
}
44
45
//____________________________________________________________________
46
class
VP1Floor::Imp
{
47
public
:
48
Imp
(
VP1Floor
*,
49
SoSeparator * attachsep);
50
VP1Floor
*
theclass
;
51
SoSeparator *
attachSep
;
52
53
bool
shown
;
54
SbColor4f
colourAndTransp
;
55
double
extent
;
56
double
spacing
;
57
double
vertpos
;
58
59
SoSeparator *
sep
;
60
61
void
rebuild3DObjects
();
62
void
updateColour
();
63
};
64
65
//____________________________________________________________________
66
VP1Floor::VP1Floor
(SoSeparator * attachsep,
67
IVP1System
* sys,QObject * parent)
68
: QObject(parent),
VP1HelperClassBase
(sys,
"VP1Floor"
),
m_d
(new
Imp
(this,attachsep))
69
{
70
}
71
72
//____________________________________________________________________
73
VP1Floor::~VP1Floor
()
74
{
75
setShown
(
false
);
76
if
(
m_d
->sep)
77
m_d
->sep->unref();
78
m_d
->attachSep->unref();
79
delete
m_d
;
80
}
81
82
//____________________________________________________________________
83
VP1Floor::Imp::Imp
(
VP1Floor
*
tc
,SoSeparator * as)
84
:
theclass
(
tc
),
attachSep
(as),
shown
(false),
85
colourAndTransp
(SbColor4f(1,1,1,1)),
extent
(10),
spacing
(1),
vertpos
(0),
sep
(0)
86
{
87
attachSep
->ref();
88
}
89
90
//____________________________________________________________________
91
void
VP1Floor::Imp::rebuild3DObjects
()
92
{
93
theclass
->messageVerbose(
"(Re)building 3D objects"
);
94
95
if
(
sep
) {
96
sep
->removeAllChildren();
97
}
else
{
98
sep
=
new
SoSeparator;
99
sep
->ref();
100
}
101
102
const
bool
save =
sep
->enableNotify(
false
);
103
104
int
nmax
;
double
distmax;
105
if
(!
calcParsFromExtentAndSpacing
(
theclass
,
extent
,
spacing
,
VP1Floor::nMax
(),
nmax
, distmax )) {
106
nmax
= 10;
107
distmax = 10*SYSTEM_OF_UNITS::m;
108
theclass
->message(
"ERROR: Problems calculating nmax/distmax."
);
109
}
110
111
SoVertexProperty * floor_vertices =
new
SoVertexProperty();
112
int
ivert(0);
113
int
nsublines(0);
114
for
(
int
ix = -
nmax
; ix<=
nmax
; ++ix) {
115
double
x
= ix*
spacing
;
116
floor_vertices->vertex.set1Value(ivert++,
x
,
vertpos
,-distmax);
117
floor_vertices->vertex.set1Value(ivert++,
x
,
vertpos
,+distmax);
118
++nsublines;
119
}
120
for
(
int
iz = -
nmax
; iz<=
nmax
; ++iz) {
121
double
z
= iz*
spacing
;
122
floor_vertices->vertex.set1Value(ivert++,-distmax,
vertpos
,
z
);
123
floor_vertices->vertex.set1Value(ivert++,+distmax,
vertpos
,
z
);
124
++nsublines;
125
}
126
127
floor_vertices->materialBinding=SoMaterialBinding::OVERALL;
128
floor_vertices->normalBinding=SoNormalBinding::OVERALL;
129
SoLineSet * line =
new
SoLineSet();
130
line->numVertices.enableNotify(FALSE);
131
line->numVertices.setNum(nsublines);
132
for
(
int
i=0;i<nsublines;++i)
133
line->numVertices.set1Value(i,2);
134
line->vertexProperty = floor_vertices;
135
line->numVertices.enableNotify(TRUE);
136
line->numVertices.touch();
137
138
sep
->addChild(line);
139
updateColour
();
140
141
if
(save) {
142
sep
->enableNotify(
true
);
143
sep
->touch();
144
}
145
146
}
147
148
//____________________________________________________________________
149
void
VP1Floor::Imp::updateColour
()
150
{
151
theclass
->messageVerbose(
"Updating packed colour"
);
152
if
(!
sep
||
sep
->getNumChildren()<1)
153
return
;
154
SoNode * n =
sep
->getChild(0);
155
if
(!n||n->getTypeId()!=SoLineSet::getClassTypeId())
156
return
;
157
SoLineSet * line =
static_cast<
SoLineSet*
>
(n);
158
SoVertexProperty * vertices =
static_cast<
SoVertexProperty *
>
(line->vertexProperty.getValue());
159
if
(!vertices)
160
return
;
161
vertices->orderedRGBA =
colourAndTransp
.getPackedValue();
162
}
163
164
//____________________________________________________________________
165
void
VP1Floor::setShown
(
bool
b)
166
{
167
messageVerbose
(
"Signal received: setShown("
+
str
(b)+
")"
);
168
if
(
m_d
->shown==b)
169
return
;
170
m_d
->shown=b;
171
if
(
m_d
->shown) {
172
m_d
->rebuild3DObjects();
173
if
(
m_d
->attachSep->findChild(
m_d
->sep)<0)
174
m_d
->attachSep->addChild(
m_d
->sep);
175
}
else
{
176
if
(
m_d
->sep&&
m_d
->attachSep->findChild(
m_d
->sep)>=0)
177
m_d
->attachSep->removeChild(
m_d
->sep);
178
}
179
}
180
181
//____________________________________________________________________
182
void
VP1Floor::setColourAndTransp
(
const
SbColor4f&ct)
183
{
184
messageVerbose
(
"Signal received in setColourAndTransp slot."
);
185
if
(
m_d
->colourAndTransp==ct)
186
return
;
187
m_d
->colourAndTransp=ct;
188
if
(
m_d
->shown)
189
m_d
->updateColour();
190
}
191
192
//____________________________________________________________________
193
void
VP1Floor::setExtent
(
const
double
& e)
194
{
195
messageVerbose
(
"Signal received: setExtent("
+
str
(e)+
")"
);
196
if
(
m_d
->extent==e)
197
return
;
198
m_d
->extent=e;
199
if
(
m_d
->shown)
200
m_d
->rebuild3DObjects();
201
}
202
203
//____________________________________________________________________
204
void
VP1Floor::setSpacing
(
const
double
&s)
205
{
206
messageVerbose
(
"Signal received: setSpacing("
+
str
(s)+
")"
);
207
if
(
m_d
->spacing==s)
208
return
;
209
m_d
->spacing=s;
210
if
(
m_d
->shown)
211
m_d
->rebuild3DObjects();
212
}
213
214
//____________________________________________________________________
215
void
VP1Floor::setVerticalPosition
(
const
double
&p)
216
{
217
messageVerbose
(
"Signal received: setVerticalPosition("
+
str
(p)+
")"
);
218
if
(
m_d
->vertpos==p)
219
return
;
220
m_d
->vertpos=p;
221
if
(
m_d
->shown)
222
m_d
->rebuild3DObjects();
223
}
tc
static Double_t tc
Definition
LArPhysWaveHECTool.cxx:38
nmax
const int nmax(200)
x
#define x
z
#define z
VP1Floor.h
IVP1System
Definition
IVP1System.h:36
VP1Floor::Imp
Definition
VP1Floor.cxx:46
VP1Floor::Imp::vertpos
double vertpos
Definition
VP1Floor.cxx:57
VP1Floor::Imp::shown
bool shown
Definition
VP1Floor.cxx:53
VP1Floor::Imp::rebuild3DObjects
void rebuild3DObjects()
Definition
VP1Floor.cxx:91
VP1Floor::Imp::theclass
VP1Floor * theclass
Definition
VP1Floor.cxx:50
VP1Floor::Imp::spacing
double spacing
Definition
VP1Floor.cxx:56
VP1Floor::Imp::Imp
Imp(VP1Floor *, SoSeparator *attachsep)
Definition
VP1Floor.cxx:83
VP1Floor::Imp::colourAndTransp
SbColor4f colourAndTransp
Definition
VP1Floor.cxx:54
VP1Floor::Imp::updateColour
void updateColour()
Definition
VP1Floor.cxx:149
VP1Floor::Imp::extent
double extent
Definition
VP1Floor.cxx:55
VP1Floor::Imp::attachSep
SoSeparator * attachSep
Definition
VP1Floor.cxx:51
VP1Floor::Imp::sep
SoSeparator * sep
Definition
VP1Floor.cxx:59
VP1Floor::setVerticalPosition
void setVerticalPosition(const double &)
Definition
VP1Floor.cxx:215
VP1Floor::VP1Floor
VP1Floor(SoSeparator *attachsep, IVP1System *sys, QObject *parent=0)
Definition
VP1Floor.cxx:66
VP1Floor::setExtent
void setExtent(const double &)
Definition
VP1Floor.cxx:193
VP1Floor::calcParsFromExtentAndSpacing
static bool calcParsFromExtentAndSpacing(const VP1HelperClassBase *, const double &extent, const double &spacing, const int &nmaxlimit, int &nmax, double &distmax)
Definition
VP1Floor.cxx:30
VP1Floor::~VP1Floor
virtual ~VP1Floor()
Definition
VP1Floor.cxx:73
VP1Floor::setShown
void setShown(bool)
Definition
VP1Floor.cxx:165
VP1Floor::nMax
static int nMax()
Definition
VP1Floor.h:33
VP1Floor::setSpacing
void setSpacing(const double &)
Definition
VP1Floor.cxx:204
VP1Floor::setColourAndTransp
void setColourAndTransp(const SbColor4f &)
Definition
VP1Floor.cxx:182
VP1Floor::m_d
Imp * m_d
Definition
VP1Floor.h:51
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