16 #include <Inventor/nodes/SoSeparator.h>
17 #include <Inventor/nodes/SoVertexProperty.h>
18 #include <Inventor/nodes/SoLineSet.h>
19 #include <Inventor/SbColor4f.h>
22 #include "CLHEP/Units/SystemOfUnits.h"
23 #define SYSTEM_OF_UNITS CLHEP
25 #include "GaudiKernel/SystemOfUnits.h"
26 #define SYSTEM_OF_UNITS Gaudi::Units
32 if (extent<0.0||spacing<=0.0)
34 nmax=
static_cast<int>(extent/spacing+0.5);
38 helper->message(
"Too many lines requested. All will not be shown.");
41 distmax =
nmax*spacing;
49 SoSeparator * attachsep);
84 : theclass(tc), attachSep(as), shown(false),
85 colourAndTransp(SbColor4f(1,1,1,1)),extent(10), spacing(1), vertpos(0),
sep(0)
93 theclass->messageVerbose(
"(Re)building 3D objects");
96 sep->removeAllChildren();
98 sep =
new SoSeparator;
102 const bool save =
sep->enableNotify(
false);
104 int nmax;
double distmax;
108 theclass->message(
"ERROR: Problems calculating nmax/distmax.");
111 SoVertexProperty * floor_vertices =
new SoVertexProperty();
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);
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);
129 SoLineSet *
line =
new SoLineSet();
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();
142 sep->enableNotify(
true);
151 theclass->messageVerbose(
"Updating packed colour");
152 if (!
sep||
sep->getNumChildren()<1)
154 SoNode *
n =
sep->getChild(0);
155 if (!
n||
n->getTypeId()!=SoLineSet::getClassTypeId())
157 SoLineSet *
line =
static_cast<SoLineSet*
>(
n);
158 SoVertexProperty * vertices =
static_cast<SoVertexProperty *
>(
line->vertexProperty.getValue());
161 vertices->orderedRGBA = colourAndTransp.getPackedValue();