ATLAS Offline Software
VP1CoordinateAxes.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 VP1CoordinateAxes //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: April 2008 //
12 // //
14 
16 #include "VP1Base/VP1QtUtils.h"
17 #include <Inventor/C/errors/debugerror.h>
18 #include <Inventor/nodes/SoMaterial.h>
19 #include <Inventor/nodes/SoSeparator.h>
20 #include <Inventor/nodes/SoCylinder.h>
21 #include <Inventor/nodes/SoCone.h>
22 #include <Inventor/nodes/SoTranslation.h>
23 #include <Inventor/nodes/SoRotationXYZ.h>
24 #include <Inventor/nodes/SoSphere.h>
25 
26 //____________________________________________________________________
28 public:
30  SoMaterial * xmat,
31  SoMaterial * ymat,
32  SoMaterial * zmat,
33  SoSeparator * attachsep);
35  SoMaterial * materialXAxis;
36  SoMaterial * materialYAxis;
37  SoMaterial * materialZAxis;
38  SoSeparator * attachSep;
39 
40  bool shown;
41  SbVec3f origo;
42  double axislength;//negative means show negative parts
43  double relaxisthick;
44 
45  SoSeparator * sep;
46  SoTranslation * overall_translation;
47  SoSphere * alternative_Sphere;
48  SoSeparator * singleaxis_sep;
49  SoCylinder * singleaxis_cyl;
50  SoCone * singleaxis_cone;
51  SoTranslation * singleaxis_cyltranslation;
52  SoTranslation * singleaxis_conetranslation;
53 
54  void updateFields();
55  void ensureInit3DObjects();
56 };
57 
58 //____________________________________________________________________
59 VP1CoordinateAxes::VP1CoordinateAxes(SoMaterial * xmat,SoMaterial * ymat,SoMaterial * zmat,
60  SoSeparator * attachsep,
61  IVP1System * sys,QObject * parent)
62  : QObject(parent), VP1HelperClassBase(sys,"VP1CoordinateAxes"), m_d(new Imp(this,xmat,ymat,zmat,attachsep))
63 {
64 }
65 
66 //____________________________________________________________________
68 {
69  setShown(false);
70  if (m_d->sep)
71  m_d->sep->unref();
72  if (m_d->singleaxis_sep)
73  m_d->singleaxis_sep->unref();
74  m_d->materialXAxis->unref();
75  m_d->materialYAxis->unref();
76  m_d->materialZAxis->unref();
77  m_d->attachSep->unref();
78  delete m_d;
79 }
80 
81 //____________________________________________________________________
82 VP1CoordinateAxes::Imp::Imp(VP1CoordinateAxes *tc,SoMaterial * xmat,SoMaterial * ymat,SoMaterial * zmat,SoSeparator * as)
83  : theclass(tc), materialXAxis(xmat), materialYAxis(ymat), materialZAxis(zmat), attachSep(as), shown(false),
84  origo(SbVec3f(0,0,0)), axislength(1), relaxisthick(0.1),
85  sep(0), overall_translation(0), alternative_Sphere(0), singleaxis_sep(0), singleaxis_cyl(0),
86  singleaxis_cone(0), singleaxis_cyltranslation(0), singleaxis_conetranslation(0)
87 {
88  materialXAxis->ref();
89  materialYAxis->ref();
90  materialZAxis->ref();
91  attachSep->ref();
92 }
93 
94 //____________________________________________________________________
96 {
97  if (sep)
98  return;
99  theclass->messageVerbose("Building 3D objects");
100  sep = new SoSeparator; sep->ref();
101 
102  singleaxis_sep = new SoSeparator; singleaxis_sep->ref();
103  singleaxis_cyltranslation = new SoTranslation; singleaxis_sep->addChild(singleaxis_cyltranslation);
104  singleaxis_cyl = new SoCylinder; singleaxis_sep->addChild(singleaxis_cyl);
105  singleaxis_conetranslation = new SoTranslation; singleaxis_sep->addChild(singleaxis_conetranslation);
106  singleaxis_cone = new SoCone; singleaxis_sep->addChild(singleaxis_cone);
107 
108  overall_translation = new SoTranslation;
109 
110  sep->addChild(overall_translation);
111 
112  #if defined BUILDVP1LIGHT
113  const bool alternativeRep = VP1QtUtils::expertSettingIsOn("general","ExpertSettings/VP1_GUIDES_SPHERE_INSTEAD_OF_COORDAXES");
114  #else
115  const bool alternativeRep = VP1QtUtils::environmentVariableIsOn("VP1_GUIDES_SPHERE_INSTEAD_OF_COORDAXES");
116  #endif
117 
118  if (alternativeRep) {
119  sep->addChild(materialXAxis);
120  alternative_Sphere = new SoSphere;
121  sep->addChild(alternative_Sphere);
122  return;
123  }
124 
125 
126  sep->addChild(materialYAxis);
127  sep->addChild(singleaxis_sep);//Single-axis points towards y by default.
128 
129  SoRotationXYZ * rotx = new SoRotationXYZ;
130  rotx->axis.setValue(SoRotationXYZ::Z);
131  rotx->angle.setValue(-0.5*M_PI);
132  sep->addChild(rotx);
133 
134  sep->addChild(materialXAxis);
135  sep->addChild(singleaxis_sep);//Single-axis points towards y by default.
136 
137 
138  SoRotationXYZ * rotz = new SoRotationXYZ;
139  rotz->axis.setValue(SoRotationXYZ::X);
140  rotz->angle.setValue(0.5*M_PI);
141  sep->addChild(rotz);
142 
143  sep->addChild(materialZAxis);
144  sep->addChild(singleaxis_sep);//Single-axis points towards y by default.
145 
146  singleaxis_cyl->parts.setValue(SoCylinder::SIDES|SoCylinder::BOTTOM);
147 }
148 
149 //____________________________________________________________________
151 {
152  ensureInit3DObjects();
153  theclass->messageVerbose("Updating fields");
154 
155  const bool save = sep->enableNotify(false);
156 
157  const double cylradius = relaxisthick*fabs(axislength);
158  const double coneradius = 1.5*cylradius;
159  const double coneheight = 2.0*coneradius;
160  overall_translation->translation.setValue(origo);
161 
162  if (alternative_Sphere) {
163  alternative_Sphere->radius.setValue(fabs(axislength));
164  } else {
165  singleaxis_cyltranslation->translation.setValue(0.0,(axislength<0?0.0:0.5*fabs(axislength))-0.5*coneheight,0.0);
166  singleaxis_cyl->radius.setValue(cylradius);
167  singleaxis_cyl->height.setValue( (axislength<0 ? 2.0 : 1.0) * fabs(axislength) - coneheight );
168  singleaxis_conetranslation->translation.setValue(0.0,(axislength<0?1.0:0.5)*fabs(axislength),0.0);
169  singleaxis_cone->bottomRadius.setValue(coneradius);
170  singleaxis_cone->height.setValue(coneheight);
171  }
172 
173  if (save) {
174  sep->enableNotify(true);
175  sep->touch();
176  }
177 }
178 
179 //____________________________________________________________________
181 {
182  messageVerbose("Signal received: setShown("+str(b)+")");
183  if (m_d->shown==b)
184  return;
185  m_d->shown=b;
186  if (m_d->shown) {
187  m_d->updateFields();
188  if (m_d->attachSep->findChild(m_d->sep)<0)
189  m_d->attachSep->addChild(m_d->sep);
190  } else {
191  if (m_d->sep&&m_d->attachSep->findChild(m_d->sep)>=0)
192  m_d->attachSep->removeChild(m_d->sep);
193  }
194 }
195 
196 //____________________________________________________________________
197 void VP1CoordinateAxes::setPosition(const SbVec3f& o)
198 {
199  messageVerbose("Signal received: setPosition("+str(o)+")");
200  if (m_d->origo==o)
201  return;
202  m_d->origo=o;
203  if (m_d->shown)
204  m_d->updateFields();
205 }
206 
207 
208 //____________________________________________________________________
209 void VP1CoordinateAxes::setLength(const double&l)
210 {
211  messageVerbose("Signal received: setLength("+str(l)+")");
212  if (m_d->axislength==l)
213  return;
214  m_d->axislength=l;
215  if (m_d->shown)
216  m_d->updateFields();
217 }
218 
219 //____________________________________________________________________
221 {
222  messageVerbose("Signal received: setRelativeAxisThickness("+str(t)+")");
223  if (m_d->relaxisthick==t)
224  return;
225  m_d->relaxisthick=t;
226  if (m_d->shown)
227  m_d->updateFields();
228 }
VP1CoordinateAxes::Imp::axislength
double axislength
Definition: VP1CoordinateAxes.cxx:42
VP1CoordinateAxes::VP1CoordinateAxes
VP1CoordinateAxes(SoMaterial *xmat, SoMaterial *ymat, SoMaterial *zmat, SoSeparator *attachsep, IVP1System *sys, QObject *parent=0)
Definition: VP1CoordinateAxes.cxx:59
NSWL1::SIDES
const std::vector< size_t > SIDES
Definition: tdr_compat_enum.h:20
VP1CoordinateAxes::Imp::singleaxis_cyltranslation
SoTranslation * singleaxis_cyltranslation
Definition: VP1CoordinateAxes.cxx:51
VP1CoordinateAxes::Imp
Definition: VP1CoordinateAxes.cxx:27
VP1CoordinateAxes::m_d
Imp * m_d
Definition: VP1CoordinateAxes.h:45
VP1CoordinateAxes.h
VP1CoordinateAxes::setShown
void setShown(bool)
Definition: VP1CoordinateAxes.cxx:180
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
VP1CoordinateAxes::setLength
void setLength(const double &)
Definition: VP1CoordinateAxes.cxx:209
VP1CoordinateAxes::setPosition
void setPosition(const SbVec3f &)
Definition: VP1CoordinateAxes.cxx:197
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1QtUtils.h
VP1CoordinateAxes::Imp::updateFields
void updateFields()
Definition: VP1CoordinateAxes.cxx:150
M_PI
#define M_PI
Definition: ActiveFraction.h:11
VP1CoordinateAxes::Imp::overall_translation
SoTranslation * overall_translation
Definition: VP1CoordinateAxes.cxx:46
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1CoordinateAxes::Imp::theclass
VP1CoordinateAxes * theclass
Definition: VP1CoordinateAxes.cxx:34
VP1CoordinateAxes::Imp::relaxisthick
double relaxisthick
Definition: VP1CoordinateAxes.cxx:43
VP1CoordinateAxes::Imp::materialXAxis
SoMaterial * materialXAxis
Definition: VP1CoordinateAxes.cxx:35
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
IVP1System
Definition: IVP1System.h:36
VP1CoordinateAxes::Imp::singleaxis_cyl
SoCylinder * singleaxis_cyl
Definition: VP1CoordinateAxes.cxx:49
VP1CoordinateAxes::Imp::sep
SoSeparator * sep
Definition: VP1CoordinateAxes.cxx:45
VP1CoordinateAxes::Imp::singleaxis_cone
SoCone * singleaxis_cone
Definition: VP1CoordinateAxes.cxx:50
VP1QtUtils::environmentVariableIsOn
static bool environmentVariableIsOn(const QString &name)
Definition: VP1QtUtils.cxx:127
VP1CoordinateAxes::Imp::attachSep
SoSeparator * attachSep
Definition: VP1CoordinateAxes.cxx:38
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1CoordinateAxes
Definition: VP1CoordinateAxes.h:26
VP1QtUtils::expertSettingIsOn
static bool expertSettingIsOn(const QString &type, const QString &name)
Definition: VP1QtUtils.cxx:60
VP1CoordinateAxes::Imp::alternative_Sphere
SoSphere * alternative_Sphere
Definition: VP1CoordinateAxes.cxx:47
VP1CoordinateAxes::Imp::singleaxis_conetranslation
SoTranslation * singleaxis_conetranslation
Definition: VP1CoordinateAxes.cxx:52
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
VP1CoordinateAxes::Imp::ensureInit3DObjects
void ensureInit3DObjects()
Definition: VP1CoordinateAxes.cxx:95
grepfile.sep
sep
Definition: grepfile.py:38
VP1CoordinateAxes::Imp::singleaxis_sep
SoSeparator * singleaxis_sep
Definition: VP1CoordinateAxes.cxx:48
VP1CoordinateAxes::~VP1CoordinateAxes
virtual ~VP1CoordinateAxes()
Definition: VP1CoordinateAxes.cxx:67
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1CoordinateAxes::setRelativeAxisThickness
void setRelativeAxisThickness(const double &)
Definition: VP1CoordinateAxes.cxx:220
VP1CoordinateAxes::Imp::shown
bool shown
Definition: VP1CoordinateAxes.cxx:40
VP1CoordinateAxes::Imp::Imp
Imp(VP1CoordinateAxes *, SoMaterial *xmat, SoMaterial *ymat, SoMaterial *zmat, SoSeparator *attachsep)
Definition: VP1CoordinateAxes.cxx:82
VP1CoordinateAxes::Imp::materialZAxis
SoMaterial * materialZAxis
Definition: VP1CoordinateAxes.cxx:37
VP1CoordinateAxes::Imp::origo
SbVec3f origo
Definition: VP1CoordinateAxes.cxx:41
VP1CoordinateAxes::Imp::materialYAxis
SoMaterial * materialYAxis
Definition: VP1CoordinateAxes.cxx:36