ATLAS Offline Software
VP1Floor.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 VP1Floor //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: July 2008 //
12 // //
14 
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( 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 //____________________________________________________________________
47 public:
48  Imp(VP1Floor *,
49  SoSeparator * attachsep);
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 //____________________________________________________________________
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 //____________________________________________________________________
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 //____________________________________________________________________
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 //____________________________________________________________________
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) {
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;
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)
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)
212 }
213 
214 //____________________________________________________________________
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)
223 }
VP1Floor::m_d
Imp * m_d
Definition: VP1Floor.h:50
VP1Floor::setColourAndTransp
void setColourAndTransp(const SbColor4f &)
Definition: VP1Floor.cxx:182
checkFileSG.line
line
Definition: checkFileSG.py:75
VP1Floor::Imp::theclass
VP1Floor * theclass
Definition: VP1Floor.cxx:50
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
VP1Floor::Imp
Definition: VP1Floor.cxx:46
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
VP1Floor::Imp::extent
double extent
Definition: VP1Floor.cxx:55
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1Floor::nMax
static int nMax()
Definition: VP1Floor.h:33
VP1Floor::VP1Floor
VP1Floor(SoSeparator *attachsep, IVP1System *sys, QObject *parent=0)
Definition: VP1Floor.cxx:66
VP1Floor::Imp::spacing
double spacing
Definition: VP1Floor.cxx:56
x
#define x
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1Floor::Imp::Imp
Imp(VP1Floor *, SoSeparator *attachsep)
Definition: VP1Floor.cxx:83
VP1Floor::Imp::sep
SoSeparator * sep
Definition: VP1Floor.cxx:59
VP1Floor::setVerticalPosition
void setVerticalPosition(const double &)
Definition: VP1Floor.cxx:215
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
IVP1System
Definition: IVP1System.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
beamspotman.n
n
Definition: beamspotman.py:731
VP1Floor.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1Floor::Imp::vertpos
double vertpos
Definition: VP1Floor.cxx:57
python.Constants.TRUE
bool TRUE
for job options legacy (TODO: get rid of these!) ----------------------—
Definition: Control/AthenaCommon/python/Constants.py:22
VP1Floor::Imp::colourAndTransp
SbColor4f colourAndTransp
Definition: VP1Floor.cxx:54
VP1Floor::calcParsFromExtentAndSpacing
static bool calcParsFromExtentAndSpacing(VP1HelperClassBase *, const double &extent, const double &spacing, const int &nmaxlimit, int &nmax, double &distmax)
Definition: VP1Floor.cxx:30
VP1Floor
Definition: VP1Floor.h:26
SCT_ConditionsData::OVERALL
@ OVERALL
Definition: SCT_ConditionsParameters.h:24
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
VP1Floor::Imp::rebuild3DObjects
void rebuild3DObjects()
Definition: VP1Floor.cxx:91
calibdata.ct
ct
Definition: calibdata.py:418
grepfile.sep
sep
Definition: grepfile.py:38
VP1Floor::~VP1Floor
virtual ~VP1Floor()
Definition: VP1Floor.cxx:73
VP1Floor::setSpacing
void setSpacing(const double &)
Definition: VP1Floor.cxx:204
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1Floor::Imp::shown
bool shown
Definition: VP1Floor.cxx:53
VP1Floor::Imp::attachSep
SoSeparator * attachSep
Definition: VP1Floor.cxx:51
python.Constants.FALSE
bool FALSE
Definition: Control/AthenaCommon/python/Constants.py:23
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
VP1Floor::Imp::updateColour
void updateColour()
Definition: VP1Floor.cxx:149
VP1Floor::setExtent
void setExtent(const double &)
Definition: VP1Floor.cxx:193
VP1Floor::setShown
void setShown(bool)
Definition: VP1Floor.cxx:165
nmax
const int nmax(200)