#include <Iguana/Inventor/interface/IgSoGridPlane.h>
Public Member Functions | |
IgSoGridPlane (void) | |
void | updateScale (void) |
Static Public Member Functions | |
static void | initClass (void) |
Public Attributes | |
SoSFColor | color |
SoSFColor | labelColor |
SoSFBool | manip |
SoSFBool | on |
SoSFPlane | plane |
SoSFFloat | spacing |
SoSFFloat | xLen |
SoSFFloat | xOrigin |
SoSFFloat | zLen |
SoSFFloat | zOrigin |
Protected Member Functions | |
~IgSoGridPlane (void) | |
Private Member Functions | |
void | addScale (void) |
void | attachSensors (void) |
void | setLabelMove (SoSeparator *labelGroup, SbVec3f step) |
void | setLabelText (SoSeparator *labelGroup, float position, bool right=false) |
SO_NODE_HEADER (IgSoGridPlane) | |
Static Private Member Functions | |
static void | colorSensorCB (void *me, SoSensor *data) |
static void | labelColorSensorCB (void *me, SoSensor *data) |
static void | manipSensorCB (void *me, SoSensor *data) |
This callback is called whenever the `manip' field is turned on or off value. | |
static void | mplaneSensorCB (void *me, SoSensor *data) |
static void | onSensorCB (void *me, SoSensor *data) |
This callback is called whenever the `on' field changes value. | |
static void | planeSensorCB (void *me, SoSensor *data) |
This callback is called whenever the `plane' or `m_plane->plane' field change value. | |
static void | spacingSensorCB (void *me, SoSensor *data) |
static void | xLenSensorCB (void *me, SoSensor *data) |
static void | xOriginSensorCB (void *me, SoSensor *data) |
static void | zLenSensorCB (void *me, SoSensor *data) |
static void | zOriginSensorCB (void *me, SoSensor *data) |
Private Attributes | |
SoFieldSensor * | m_colorSensor |
SoGroup * | m_gridPlane |
SoFieldSensor * | m_labelColorSensor |
IgSoPlaneManip * | m_manip |
SoFieldSensor * | m_manipSensor |
SoFieldSensor * | m_mplaneSensor |
SoFieldSensor * | m_onSensor |
IgSoGridPlaneMap * | m_plane |
SoFieldSensor * | m_planeSensor |
SoLevelOfDetail * | m_scale |
SoFieldSensor * | m_scaleSensor |
SoShapeHints * | m_shapeHints |
SoFieldSensor * | m_spacingSensor |
SoFieldSensor * | m_xLenSensor |
SoFieldSensor * | m_xOriginSensor |
SoFieldSensor * | m_zLenSensor |
SoFieldSensor * | m_zOriginSensor |
Definition at line 33 of file IgSoGridPlane.h.
IgSoGridPlane::IgSoGridPlane | ( | void | ) |
Definition at line 38 of file IgSoGridPlane.cc.
References addScale(), attachSensors(), color, f, FALSE, labelColor, m_gridPlane, m_plane, m_shapeHints, manip, on, plane, IgSoGridPlaneMap::setCaller(), spacing, xLen, xOrigin, zLen, and zOrigin.
00039 : m_plane (new IgSoGridPlaneMap), 00040 m_shapeHints (new SoShapeHints), 00041 m_planeSensor (0), 00042 m_xOriginSensor (0), 00043 m_zOriginSensor (0), 00044 m_xLenSensor (0), 00045 m_zLenSensor (0), 00046 m_spacingSensor (0), 00047 m_onSensor (0), 00048 m_colorSensor (0), 00049 m_labelColorSensor (0), 00050 m_manip (0), 00051 m_manipSensor (0), 00052 m_mplaneSensor (0), 00053 m_scaleSensor (0), 00054 m_scale (0), 00055 m_gridPlane (0) 00056 { 00057 SO_NODE_CONSTRUCTOR (IgSoGridPlane); 00058 SO_NODE_ADD_FIELD (plane, (SbPlane (SbVec3f (0.0, 1.0, 0.0), 0.0))); 00059 SO_NODE_ADD_FIELD (xOrigin, (0.0f)); 00060 SO_NODE_ADD_FIELD (zOrigin, (0.0f)); 00061 SO_NODE_ADD_FIELD (xLen, (7.0f)); 00062 SO_NODE_ADD_FIELD (zLen, (16.0f)); 00063 SO_NODE_ADD_FIELD (spacing, (1000.0f)); 00064 SO_NODE_ADD_FIELD (on, (FALSE)); 00065 SO_NODE_ADD_FIELD (color, (SbVec3f (1,1,1))); 00066 SO_NODE_ADD_FIELD (labelColor, (SbVec3f (1,1,1))); 00067 SO_NODE_ADD_FIELD (manip, (FALSE)); 00068 00069 // the reason we are setting the caller is that we need a way to get the 00070 // most recent values for the scale without disturbing the order of the 00071 // rendered elements, as soon as a value changes which is important to 00072 // the scale, we set a flag on the GridPlaneMap which then calls the 00073 // updateScale method in this class 00074 m_plane->setCaller (this); 00075 // reset previous transformations 00076 addChild (new SoResetTransform); 00077 00078 m_gridPlane = new SoGroup; 00079 m_gridPlane->setName ("Grid_Plane_Composite"); 00080 addChild (m_gridPlane); 00081 00082 m_shapeHints->ref(); 00083 m_shapeHints->setName ("Shape_Hints"); 00084 m_gridPlane->addChild (m_shapeHints); 00085 00086 m_plane->setName ("GridPlaneMap"); 00087 m_gridPlane->addChild (m_plane); 00088 addScale (); 00089 00090 attachSensors (); 00091 }
IgSoGridPlane::~IgSoGridPlane | ( | void | ) | [protected] |
Definition at line 248 of file IgSoGridPlane.cc.
References m_colorSensor, m_gridPlane, m_labelColorSensor, m_manipSensor, m_onSensor, m_planeSensor, m_scale, m_shapeHints, m_spacingSensor, m_xLenSensor, m_xOriginSensor, m_zLenSensor, and m_zOriginSensor.
00249 { 00250 m_shapeHints->unref (); 00251 m_scale->unref (); 00252 m_gridPlane->removeAllChildren (); 00253 removeChild (m_gridPlane); 00254 00255 delete m_onSensor; 00256 delete m_planeSensor; 00257 delete m_xOriginSensor; 00258 delete m_zOriginSensor; 00259 delete m_xLenSensor; 00260 delete m_zLenSensor; 00261 delete m_spacingSensor; 00262 delete m_colorSensor; 00263 delete m_labelColorSensor; 00264 delete m_manipSensor; 00265 }
Definition at line 94 of file IgSoGridPlane.cc.
References m_gridPlane, m_scale, and on.
Referenced by IgSoGridPlane().
00095 { 00096 const bool hasChildren = m_gridPlane->getNumChildren () == 2; 00097 assert (hasChildren && "check the scene graph elements!"); 00098 00099 if (hasChildren) 00100 { 00101 // using 'ref ()' because we dont want the scale to be deleted, 00102 // when the grid is turned off 00103 m_scale = new SoLevelOfDetail; 00104 m_scale->screenArea.set1Value (0, 5000); 00105 m_scale->setName ("Grid_Scale"); 00106 m_scale->ref (); 00107 00108 // add different levels of complexity: until now only 2 00109 SoSeparator* complexLabels = new SoSeparator; 00110 SoSeparator* noLabels = new SoSeparator; 00111 m_scale->addChild (complexLabels); 00112 m_scale->addChild (noLabels); 00113 00114 if (on.getValue ()) 00115 { 00116 m_gridPlane->addChild (m_scale); 00117 } 00118 } 00119 }
Definition at line 222 of file IgSoGridPlane.cc.
References color, colorSensorCB(), labelColor, labelColorSensorCB(), m_colorSensor, m_labelColorSensor, m_manipSensor, m_mplaneSensor, m_onSensor, m_planeSensor, m_spacingSensor, m_xLenSensor, m_xOriginSensor, m_zLenSensor, m_zOriginSensor, manip, manipSensorCB(), on, onSensorCB(), plane, planeSensorCB(), spacing, spacingSensorCB(), xLen, xLenSensorCB(), xOrigin, xOriginSensorCB(), zLen, zLenSensorCB(), zOrigin, and zOriginSensorCB().
Referenced by IgSoGridPlane().
00223 { 00224 m_planeSensor = new SoFieldSensor (&planeSensorCB, this); 00225 m_xOriginSensor = new SoFieldSensor (&xOriginSensorCB, this); 00226 m_zOriginSensor = new SoFieldSensor (&zOriginSensorCB, this); 00227 m_xLenSensor = new SoFieldSensor (&xLenSensorCB, this); 00228 m_zLenSensor = new SoFieldSensor (&zLenSensorCB, this); 00229 m_spacingSensor = new SoFieldSensor (&spacingSensorCB, this); 00230 m_onSensor = new SoFieldSensor (&onSensorCB, this); 00231 m_colorSensor = new SoFieldSensor (&colorSensorCB, this); 00232 m_labelColorSensor = new SoFieldSensor (&labelColorSensorCB, this); 00233 m_manipSensor = new SoFieldSensor (&manipSensorCB, this); 00234 m_mplaneSensor = new SoFieldSensor (&planeSensorCB, this); 00235 00236 m_planeSensor->attach (&plane); 00237 m_xOriginSensor->attach (&xOrigin); 00238 m_zOriginSensor->attach (&zOrigin); 00239 m_xLenSensor->attach (&xLen); 00240 m_zLenSensor->attach (&zLen); 00241 m_spacingSensor->attach (&spacing); 00242 m_onSensor->attach (&on); 00243 m_colorSensor->attach (&color); 00244 m_labelColorSensor->attach (&labelColor); 00245 m_manipSensor->attach (&manip); 00246 }
Definition at line 313 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00314 { 00315 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00316 00317 self->m_plane->color = self->color; 00318 }
Definition at line 33 of file IgSoGridPlane.cc.
Referenced by initNodes(), and initShapes().
00034 { 00035 SO_NODE_INIT_CLASS (IgSoGridPlane, SoGroup, "Group"); 00036 }
Definition at line 321 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00322 { 00323 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00324 00325 self->updateScale (); 00326 }
This callback is called whenever the `manip' field is turned on or off value.
Definition at line 368 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00369 { // Hide or show the grid plane manipulators 00370 00371 IgSoGridPlane *self = static_cast<IgSoGridPlane *> (me); 00372 const bool isOn = self->manip.getValue (); 00373 00374 // check if the manipulator is activated 00375 if (isOn) 00376 { 00377 // if the manipulator doesnt exist yet, create it, activate its plane 00378 // adjust its plane to the current plane orientation, attach it to a 00379 // sensor and add it to the scene graph 00380 if (!self->m_manip) 00381 { 00382 self->m_manip = new IgSoPlaneManip; 00383 self->m_manip->manip = isOn; 00384 self->m_manip->plane = self->plane; 00385 self->m_mplaneSensor->attach (&self->m_manip->plane); 00386 self->m_gridPlane->addChild (self->m_manip); 00387 } 00388 } 00389 else 00390 { 00391 // since the manipulator is turned off, we remove it from the 00392 // scene graph and set it to zero 00393 if (self->m_manip) 00394 { 00395 self->m_gridPlane->removeChild (self->m_manip); 00396 self->m_manip = 0; 00397 } 00398 } 00399 self->m_plane->refreshScale = true; 00400 }
This callback is called whenever the `on' field changes value.
Definition at line 331 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00332 { 00333 // activate or deactivate the grid plane 00334 IgSoGridPlane *self = static_cast<IgSoGridPlane *> (me); 00335 00336 const bool foundHints = (self->m_gridPlane->findChild (self->m_shapeHints) != -1); 00337 const bool foundScale = (self->m_gridPlane->findChild (self->m_scale) != -1); 00338 00339 if (self->on.getValue ()) 00340 { 00341 if (!foundHints) 00342 { 00343 // 'm_scale' is added in 'updateScale ()' 00344 self->m_gridPlane->addChild (self->m_shapeHints); 00345 } 00346 00347 if (!foundScale) 00348 { 00349 self->m_gridPlane->addChild (self->m_scale); 00350 } 00351 } 00352 else 00353 { 00354 if (foundHints && foundScale) 00355 { 00356 self->m_gridPlane->removeChild (self->m_shapeHints); 00357 self->m_gridPlane->removeChild (self->m_scale); 00358 } 00359 } 00360 self->m_plane->on = self->on; 00361 self->m_plane->refreshScale = true; 00362 }
This callback is called whenever the `plane' or `m_plane->plane' field change value.
Definition at line 406 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00407 { 00408 IgSoGridPlane *self = static_cast<IgSoGridPlane *> (me); 00409 00410 // disable the sensors for both planes in order to avoid an infinite 00411 // chain of callbacks 00412 self->m_mplaneSensor->detach (); 00413 self->m_planeSensor->detach(); 00414 00415 // if the manipulator is turned on, we use the manipulators plane 00416 // otherwise the standard plane 00417 if (self->manip.getValue ()) 00418 { 00419 self->m_plane->plane = self->m_manip->plane; 00420 self->plane = self->m_manip->plane; 00421 } 00422 else 00423 { 00424 // no need to update the manipulator's plane because it 00425 // doesn't exist 00426 self->m_plane->plane = self->plane; 00427 } 00428 00429 // enable the sensors again 00430 self->m_planeSensor->attach (&self->plane); 00431 self->m_mplaneSensor->attach (&self->m_plane->plane); 00432 00433 // only attach the manipulator if it is active (i.e. not null) 00434 if (self->m_manip) 00435 { 00436 self->m_mplaneSensor->attach (&self->m_manip->plane); 00437 } 00438 self->m_plane->refreshScale = true; 00439 }
void IgSoGridPlane::setLabelMove | ( | SoSeparator * | labelGroup, | |
SbVec3f | step | |||
) | [private] |
Definition at line 197 of file IgSoGridPlane.cc.
Referenced by updateScale().
00198 { 00199 SoTranslation* move = new SoTranslation; 00200 move->translation = step; 00201 labelGroup->addChild (move); 00202 }
void IgSoGridPlane::setLabelText | ( | SoSeparator * | labelGroup, | |
float | position, | |||
bool | right = false | |||
) | [private] |
Definition at line 205 of file IgSoGridPlane.cc.
Referenced by updateScale().
00206 { 00207 char textLabel[20]; 00208 SoText2* text = new SoText2; 00209 unsigned nbr = sprintf (textLabel, "%.2f", position); 00210 textLabel[nbr+1] = textLabel[nbr]; 00211 textLabel[nbr] = 'm'; 00212 text->string = textLabel; 00213 00214 if (right) 00215 { 00216 text->justification = SoText2::RIGHT; 00217 } 00218 labelGroup->addChild (text); 00219 }
IgSoGridPlane::SO_NODE_HEADER | ( | IgSoGridPlane | ) | [private] |
Definition at line 304 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00305 { 00306 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00307 00308 self->m_plane->spacing = self->spacing; 00309 self->m_plane->refreshScale = true; 00310 }
Definition at line 122 of file IgSoGridPlane.cc.
References c, f, i, labelColor, IgSoGridPlaneMap::labelSpot, m_plane, m_scale, on, setLabelMove(), setLabelText(), spacing, cmsRelvalreportInput::step, xLen, and zLen.
Referenced by IgSoGridPlaneMap::GLRender().
00123 { 00124 // is called by gridplanemap 00125 if (on.getValue ()) 00126 { 00127 assert (m_scale); 00128 const float stepLength = spacing.getValue () / 1000.0f; 00129 const float xLength = ceil (xLen.getValue () / stepLength) * stepLength; 00130 const float zLength = ceil (zLen.getValue () / stepLength) * stepLength; 00131 00132 SoSeparator* labelGroup = static_cast<SoSeparator*> (m_scale->getChild (0)); 00133 labelGroup->removeAllChildren (); 00134 00135 SbVec3f xDir = m_plane->labelSpot[1] - m_plane->labelSpot[0]; 00136 xDir.normalize (); 00137 SbVec3f zDir = m_plane->labelSpot[2] - m_plane->labelSpot[0]; 00138 zDir.normalize (); 00139 00140 // if the color is any other than white, change it 00141 const SbColor c = labelColor.getValue (); 00142 if (c[0] * c[1] * c[2] < 1.0f) 00143 { 00144 SoMaterial* labelColor = new SoMaterial; 00145 labelColor->diffuseColor.setValue (c[0], c[1], c[2]); 00146 labelGroup->addChild (labelColor); 00147 } 00148 // set 0 00149 setLabelMove (labelGroup, m_plane->labelSpot[0]); 00150 setLabelText (labelGroup, 0, true); 00151 // set lower right 00152 setLabelMove (labelGroup, m_plane->labelSpot[1] - m_plane->labelSpot[0]); 00153 setLabelText (labelGroup, xLength, true); 00154 // set upper left 00155 setLabelMove (labelGroup, m_plane->labelSpot[2] - m_plane->labelSpot[1]); 00156 setLabelText (labelGroup, zLength); 00157 // back to center 00158 setLabelMove (labelGroup, m_plane->labelSpot[0] - m_plane->labelSpot[2]); 00159 00160 const float tenStepLengths = stepLength * 10; 00161 SbVec3f step = xDir * tenStepLengths; 00162 00163 float length = xLength; 00164 float stepSum = tenStepLengths; 00165 SbVec3f movedSteps (0.f, 0.f, 0.f); 00166 bool changed = false; 00167 00168 // steps inbetween 00169 for (unsigned i = 0; i < 2; i++) 00170 { 00171 while (stepSum < length) 00172 { 00173 setLabelMove (labelGroup, step); 00174 movedSteps += step; 00175 00176 setLabelText (labelGroup, stepSum, (i == 0)); 00177 stepSum += tenStepLengths; 00178 } 00179 00180 // change direction 00181 if (!changed) 00182 { 00183 if (movedSteps.length () > 0) 00184 { 00185 setLabelMove (labelGroup, -movedSteps); 00186 } 00187 step = zDir * tenStepLengths; 00188 stepSum = tenStepLengths; 00189 length = zLength; 00190 changed = true; 00191 } 00192 } 00193 } 00194 }
Definition at line 286 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00287 { 00288 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00289 00290 self->m_plane->xLen = self->xLen; 00291 self->m_plane->refreshScale = true; 00292 }
Definition at line 268 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00269 { 00270 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00271 00272 self->m_plane->xOrigin = self->xOrigin; 00273 self->m_plane->refreshScale = true; 00274 }
Definition at line 295 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00296 { 00297 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00298 00299 self->m_plane->zLen = self->zLen; 00300 self->m_plane->refreshScale = true; 00301 }
Definition at line 277 of file IgSoGridPlane.cc.
Referenced by attachSensors().
00278 { 00279 IgSoGridPlane* self = static_cast<IgSoGridPlane *> (me); 00280 00281 self->m_plane->zOrigin = self->zOrigin; 00282 self->m_plane->refreshScale = true; 00283 }
SoSFColor IgSoGridPlane::color |
Definition at line 44 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), and Ig3DGridCategory::makeGrid().
SoSFColor IgSoGridPlane::labelColor |
Definition at line 45 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), Ig3DGridCategory::makeGrid(), and updateScale().
SoFieldSensor* IgSoGridPlane::m_colorSensor [private] |
SoGroup* IgSoGridPlane::m_gridPlane [private] |
Definition at line 89 of file IgSoGridPlane.h.
Referenced by addScale(), IgSoGridPlane(), and ~IgSoGridPlane().
SoFieldSensor* IgSoGridPlane::m_labelColorSensor [private] |
IgSoPlaneManip* IgSoGridPlane::m_manip [private] |
Definition at line 84 of file IgSoGridPlane.h.
SoFieldSensor* IgSoGridPlane::m_manipSensor [private] |
SoFieldSensor* IgSoGridPlane::m_mplaneSensor [private] |
SoFieldSensor* IgSoGridPlane::m_onSensor [private] |
IgSoGridPlaneMap* IgSoGridPlane::m_plane [private] |
SoFieldSensor* IgSoGridPlane::m_planeSensor [private] |
SoLevelOfDetail* IgSoGridPlane::m_scale [private] |
Definition at line 88 of file IgSoGridPlane.h.
Referenced by addScale(), updateScale(), and ~IgSoGridPlane().
SoFieldSensor* IgSoGridPlane::m_scaleSensor [private] |
Definition at line 87 of file IgSoGridPlane.h.
SoShapeHints* IgSoGridPlane::m_shapeHints [private] |
SoFieldSensor* IgSoGridPlane::m_spacingSensor [private] |
SoFieldSensor* IgSoGridPlane::m_xLenSensor [private] |
SoFieldSensor* IgSoGridPlane::m_xOriginSensor [private] |
SoFieldSensor* IgSoGridPlane::m_zLenSensor [private] |
SoFieldSensor* IgSoGridPlane::m_zOriginSensor [private] |
SoSFBool IgSoGridPlane::manip |
Definition at line 46 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), and IgSoGridPlane().
SoSFBool IgSoGridPlane::on |
Definition at line 37 of file IgSoGridPlane.h.
Referenced by addScale(), Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), Ig3DBaseBrowser::drawGrid(), IgSoGridPlane(), Ig3DGridCategory::makeGrid(), and updateScale().
SoSFPlane IgSoGridPlane::plane |
Definition at line 38 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), and Ig3DGridCategory::makeGrid().
SoSFFloat IgSoGridPlane::spacing |
Definition at line 43 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), Ig3DGridCategory::makeGrid(), and updateScale().
SoSFFloat IgSoGridPlane::xLen |
Definition at line 41 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), Ig3DGridCategory::makeGrid(), and updateScale().
SoSFFloat IgSoGridPlane::xOrigin |
Definition at line 39 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), and Ig3DGridCategory::makeGrid().
SoSFFloat IgSoGridPlane::zLen |
Definition at line 42 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), Ig3DGridCategory::makeGrid(), and updateScale().
SoSFFloat IgSoGridPlane::zOrigin |
Definition at line 40 of file IgSoGridPlane.h.
Referenced by Ig3DGridCategory::attach(), attachSensors(), Ig3DGridCategory::buildGridTree(), IgSoGridPlane(), and Ig3DGridCategory::makeGrid().