ATLAS Offline Software
VP1CylindricalGrid.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 VP1CylindricalGrid //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: July 2008 //
12 // //
14 
16 #include "VP1GuideLineSystems/VP1Floor.h"//for calcPars... static method
18 
19 #include <Inventor/nodes/SoSeparator.h>
20 #include <Inventor/nodes/SoVertexProperty.h>
21 #include <Inventor/nodes/SoLineSet.h>
22 #include <Inventor/nodes/SoTranslation.h>
23 #include <Inventor/nodes/SoPackedColor.h>
24 #include <Inventor/SbColor4f.h>
25 
26 #ifdef BUILDVP1LIGHT
27  #include "CLHEP/Units/SystemOfUnits.h"
28  #define SYSTEM_OF_UNITS CLHEP
29 #else
30  #include "GaudiKernel/SystemOfUnits.h"
31  #define SYSTEM_OF_UNITS Gaudi::Units
32 #endif
33 
34 //____________________________________________________________________
36 public:
38  SoSeparator * attachsep);
40  SoSeparator * attachSep;
41 
42  bool shown;
43  SbColor4f colourAndTransp;
44  double extent;
45  double spacing;
46 
47  SoSeparator * sep;
48  SoPackedColor * circlecol;
49 
50  void rebuild3DObjects();
51  void updateColour();
52 };
53 
54 //____________________________________________________________________
56  IVP1System * sys,QObject * parent)
57  : QObject(parent), VP1HelperClassBase(sys,"VP1CylindricalGrid"), m_d(new Imp(this,attachsep))
58 {
59 }
60 
61 //____________________________________________________________________
63 {
64  setShown(false);
65  if (m_d->sep)
66  m_d->sep->unref();
67  if (m_d->circlecol)
68  m_d->circlecol->unref();
69  m_d->attachSep->unref();
70  delete m_d;
71 }
72 
73 //____________________________________________________________________
75  : theclass(tc), attachSep(as), shown(false),
76  colourAndTransp(SbColor4f(1,1,1,1)),extent(10), spacing(1),
77  sep(0), circlecol(0)
78 {
79  attachSep->ref();
80 }
81 
82 //____________________________________________________________________
84 {
85  theclass->messageVerbose("(Re)building 3D objects");
86 
87  if (sep) {
88  sep->removeAllChildren();
89  } else {
90  sep = new SoSeparator;
91  sep->ref();
92  }
93 
94  const bool save = sep->enableNotify(false);
95 
96  int nmax; double distmax;
97  if (!VP1Floor::calcParsFromExtentAndSpacing( theclass, extent, spacing, 20/*max lines*/, nmax, distmax )) {
98  nmax = 10;
99  distmax = 10*SYSTEM_OF_UNITS::m;
100  theclass->message("ERROR: Problems calculating nmax/distmax.");
101  }
102 
103  if (!circlecol) {
104  circlecol = new SoPackedColor();
105  circlecol->ref();
106  }
107 
108  //Add circles:
109  sep->addChild(circlecol);
110 
111  for (int ir=1;ir<=nmax;++ir) {
112  SoNode * circle = VP1QtInventorUtils::createCircle(ir*spacing);
113  SoSeparator * s = new SoSeparator;
114  SoTranslation *t1= new SoTranslation();
115  t1->translation.setValue(0.0,0.0,-distmax-spacing);
116  s->addChild(t1);
117  for (int iz = -nmax; iz<=nmax; ++iz) {
118  SoTranslation *t2= new SoTranslation();
119  t2->translation.setValue(0.0,0.0,spacing);
120  s->addChild(t2);
121  s->addChild(circle);
122  }
123  sep->addChild(s);
124  }
125 
126  //Add lines:
127 
128  SoVertexProperty * grid_cylindrical_vertices = new SoVertexProperty();
129 
130  int ivert(0);
131  int nsublines(0);
132  static const double invsqrttwo = 1.0/sqrt(2.0);
133  for (int ir=1;ir<=nmax;++ir) {
134  double r = ir*spacing;
135  double r2 = r*invsqrttwo;
136  grid_cylindrical_vertices->vertex.set1Value(ivert++,r,0,-distmax);
137  grid_cylindrical_vertices->vertex.set1Value(ivert++,r,0,+distmax);
138  grid_cylindrical_vertices->vertex.set1Value(ivert++,0,r,-distmax);
139  grid_cylindrical_vertices->vertex.set1Value(ivert++,0,r,+distmax);
140  grid_cylindrical_vertices->vertex.set1Value(ivert++,-r,0,-distmax);
141  grid_cylindrical_vertices->vertex.set1Value(ivert++,-r,0,+distmax);
142  grid_cylindrical_vertices->vertex.set1Value(ivert++,0,-r,-distmax);
143  grid_cylindrical_vertices->vertex.set1Value(ivert++,0,-r,+distmax);
144  grid_cylindrical_vertices->vertex.set1Value(ivert++,r2,r2,-distmax);
145  grid_cylindrical_vertices->vertex.set1Value(ivert++,r2,r2,+distmax);
146  grid_cylindrical_vertices->vertex.set1Value(ivert++,r2,-r2,-distmax);
147  grid_cylindrical_vertices->vertex.set1Value(ivert++,r2,-r2,+distmax);
148  grid_cylindrical_vertices->vertex.set1Value(ivert++,-r2,r2,-distmax);
149  grid_cylindrical_vertices->vertex.set1Value(ivert++,-r2,r2,+distmax);
150  grid_cylindrical_vertices->vertex.set1Value(ivert++,-r2,-r2,-distmax);
151  grid_cylindrical_vertices->vertex.set1Value(ivert++,-r2,-r2,+distmax);
152  nsublines+=8;
153  }
154 
155  grid_cylindrical_vertices->materialBinding=SoMaterialBinding::OVERALL;
156  grid_cylindrical_vertices->normalBinding=SoNormalBinding::OVERALL;
157  SoLineSet * line = new SoLineSet();
158  line->numVertices.enableNotify(FALSE);
159  line->numVertices.setNum(nsublines);
160  for (int i=0;i<nsublines;++i)
161  line->numVertices.set1Value(i,2);
162  line->vertexProperty = grid_cylindrical_vertices;
163  line->numVertices.enableNotify(TRUE);
164  line->numVertices.touch();
165 
166  sep->addChild(line);
167  updateColour();
168 
169  if (save) {
170  sep->enableNotify(true);
171  sep->touch();
172  }
173 
174 }
175 
176 //____________________________________________________________________
178 {
179  theclass->messageVerbose("Updating packed colour");
180  if (circlecol)
181  circlecol->orderedRGBA = colourAndTransp.getPackedValue();
182  if (!sep||sep->getNumChildren()<1)
183  return;
184  SoNode * n = sep->getChild(0);
185  if (!n||n->getTypeId()!=SoLineSet::getClassTypeId())
186  return;
187  SoLineSet * line = static_cast<SoLineSet*>(n);
188  SoVertexProperty * vertices = static_cast<SoVertexProperty *>(line->vertexProperty.getValue());
189  if (vertices)
190  vertices->orderedRGBA = colourAndTransp.getPackedValue();
191 }
192 
193 //____________________________________________________________________
195 {
196  messageVerbose("Signal received: setShown("+str(b)+")");
197  if (m_d->shown==b)
198  return;
199  m_d->shown=b;
200  if (m_d->shown) {
202  if (m_d->attachSep->findChild(m_d->sep)<0)
203  m_d->attachSep->addChild(m_d->sep);
204  } else {
205  if (m_d->sep&&m_d->attachSep->findChild(m_d->sep)>=0)
206  m_d->attachSep->removeChild(m_d->sep);
207  }
208 }
209 
210 //____________________________________________________________________
212 {
213  messageVerbose("Signal received in setColourAndTransp slot.");
214  if (m_d->colourAndTransp==ct)
215  return;
217  if (m_d->shown)
218  m_d->updateColour();
219 }
220 
221 //____________________________________________________________________
222 void VP1CylindricalGrid::setExtent(const double& e)
223 {
224  messageVerbose("Signal received: setExtent("+str(e)+")");
225  if (m_d->extent==e)
226  return;
227  m_d->extent=e;
228  if (m_d->shown)
230 }
231 
232 //____________________________________________________________________
234 {
235  messageVerbose("Signal received: setSpacing("+str(s)+")");
236  if (m_d->spacing==s)
237  return;
238  m_d->spacing=s;
239  if (m_d->shown)
241 }
beamspotman.r
def r
Definition: beamspotman.py:676
VP1CylindricalGrid::setSpacing
void setSpacing(const double &)
Definition: VP1CylindricalGrid.cxx:233
checkFileSG.line
line
Definition: checkFileSG.py:75
VP1CylindricalGrid::Imp::circlecol
SoPackedColor * circlecol
Definition: VP1CylindricalGrid.cxx:48
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
VP1CylindricalGrid
Definition: VP1CylindricalGrid.h:26
VP1CylindricalGrid::Imp::Imp
Imp(VP1CylindricalGrid *, SoSeparator *attachsep)
Definition: VP1CylindricalGrid.cxx:74
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
VP1CylindricalGrid::Imp::colourAndTransp
SbColor4f colourAndTransp
Definition: VP1CylindricalGrid.cxx:43
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
VP1CylindricalGrid::setShown
void setShown(bool)
Definition: VP1CylindricalGrid.cxx:194
VP1CylindricalGrid::setColourAndTransp
void setColourAndTransp(const SbColor4f &)
Definition: VP1CylindricalGrid.cxx:211
VP1CylindricalGrid::Imp::extent
double extent
Definition: VP1CylindricalGrid.cxx:44
VP1CylindricalGrid::Imp::rebuild3DObjects
void rebuild3DObjects()
Definition: VP1CylindricalGrid.cxx:83
VP1CylindricalGrid::VP1CylindricalGrid
VP1CylindricalGrid(SoSeparator *attachsep, IVP1System *sys, QObject *parent=0)
Definition: VP1CylindricalGrid.cxx:55
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1CylindricalGrid::~VP1CylindricalGrid
virtual ~VP1CylindricalGrid()
Definition: VP1CylindricalGrid.cxx:62
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1QtInventorUtils::createCircle
static SoNode * createCircle(const double &radius)
Definition: VP1QtInventorUtils.cxx:1280
VP1QtInventorUtils.h
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
IVP1System
Definition: IVP1System.h:36
VP1CylindricalGrid::Imp::shown
bool shown
Definition: VP1CylindricalGrid.cxx:42
VP1CylindricalGrid::m_d
Imp * m_d
Definition: VP1CylindricalGrid.h:44
lumiFormat.i
int i
Definition: lumiFormat.py:92
VP1CylindricalGrid::setExtent
void setExtent(const double &)
Definition: VP1CylindricalGrid.cxx:222
beamspotman.n
n
Definition: beamspotman.py:731
VP1Floor.h
VP1CylindricalGrid::Imp::attachSep
SoSeparator * attachSep
Definition: VP1CylindricalGrid.cxx:40
VP1CylindricalGrid::Imp
Definition: VP1CylindricalGrid.cxx:35
test_pyathena.parent
parent
Definition: test_pyathena.py:15
python.Constants.TRUE
bool TRUE
for job options legacy (TODO: get rid of these!) ----------------------—
Definition: Control/AthenaCommon/python/Constants.py:22
VP1Floor::calcParsFromExtentAndSpacing
static bool calcParsFromExtentAndSpacing(VP1HelperClassBase *, const double &extent, const double &spacing, const int &nmaxlimit, int &nmax, double &distmax)
Definition: VP1Floor.cxx:30
SCT_ConditionsData::OVERALL
@ OVERALL
Definition: SCT_ConditionsParameters.h:24
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
calibdata.ct
ct
Definition: calibdata.py:418
VP1CylindricalGrid.h
VP1CylindricalGrid::Imp::theclass
VP1CylindricalGrid * theclass
Definition: VP1CylindricalGrid.cxx:39
grepfile.sep
sep
Definition: grepfile.py:38
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1CylindricalGrid::Imp::sep
SoSeparator * sep
Definition: VP1CylindricalGrid.cxx:47
VP1CylindricalGrid::Imp::updateColour
void updateColour()
Definition: VP1CylindricalGrid.cxx:177
python.Constants.FALSE
bool FALSE
Definition: Control/AthenaCommon/python/Constants.py:23
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
VP1CylindricalGrid::Imp::spacing
double spacing
Definition: VP1CylindricalGrid.cxx:45
nmax
const int nmax(200)