Coin Logo http://www.sim.no
http://www.coin3d.org

SoState Class Reference
[General classes]

The SoState class manages the Coin scenegraph traversal state data.

The SoState class is used by actions derived from the SoAction class. It manages the scenegraph state as stacks of elements (ie instances of classes derived from SoElement). More...

#include <Inventor/misc/SoState.h>

List of all members.

Public Member Functions

 SoState (SoAction *action, const SoTypeList &enabledelements)
 ~SoState (void)
SoActiongetAction (void) const
SoElementgetElement (const int stackindex)
const SoElementgetConstElement (const int stackindex) const
void push (void)
void pop (void)
void print (FILE *const file=stdout) const
SbBool isElementEnabled (const int stackindex) const
int getDepth (void) const
void setCacheOpen (const SbBool flag)
SbBool isCacheOpen (void) const
SoElementgetElementNoPush (const int stackindex) const


Detailed Description

The SoState class manages the Coin scenegraph traversal state data.

The SoState class is used by actions derived from the SoAction class. It manages the scenegraph state as stacks of elements (ie instances of classes derived from SoElement).

For more information on the inner workings of traversal states in Coin, we recommend the book «The Inventor Toolmaker» (ISBN 0-201-62493-1), also available at SGI's online library. Search for "Toolmaker".


Constructor & Destructor Documentation

SoState::SoState ( SoAction theAction,
const SoTypeList enabledelements 
)

The constructor. The theAction argument is the action object the state is part of, and the enabledElements argument is an SoTypeList of the elements that are enabled for this action.

The constructor pushes a default element onto the indexes of all the enabled element stacks. SoElement::push() is not called on the initial elements in the SoState stacks, but SoElement::init() is.

References SoType::canCreateInstance(), SoType::createInstance(), SbPList::getLength(), SoElement::getNumStackIndices(), SoElement::getStackIndex(), SoElement::init(), SoType::isBad(), and SoElement::setDepth().

SoState::~SoState ( void   ) 

The destructor.

Note that when destruction happens, lagging events caused by lazy evaluation won't be performed.

References SoElement::nextup.


Member Function Documentation

SoAction * SoState::getAction ( void   )  const

This method returns the pointer to the action instance given to the constructor.

SoElement * SoState::getElement ( const int  stackindex  ) 

This method returns a modifyable instance of the element on the top of the stack with the given stackindex. Because of lazy programming, this function may need to do some work, so SoState::getConstElement() should be used instead whenever possible.

References SoType::createInstance(), SoElement::getDepth(), SoType::getName(), SbName::getString(), SoElement::getTypeId(), isElementEnabled(), SoElement::nextdown, SoElement::nextup, SoDebugError::postInfo(), SoElement::push(), and SoElement::setDepth().

Referenced by SoElement::getElement().

const SoElement * SoState::getConstElement ( const int  stackIndex  )  const [inline]

This method returns a pointer to the top element of the given element stack. The element is read-only and must not be changed under any circumstances or strange side-effect will occur.

Note that this function will assert if the element with the given stack identity value is not presently on the state stack. To check whether or not an element is present in the stack, use SoState::isElementEnabled().

References isElementEnabled().

Referenced by SoElement::getConstElement().

void SoState::push ( void   ) 

This method pushes the state one level down. This saves the state so it can be changed and later restored to this state by calling SoState::pop().

The push and pop mechanism is performed lazily for efficiency reasons (avoids a lot of memory allocation and copying). Only when a state element is actually going to be changed, that element will be pushed for real.

Referenced by SoSeparator::audioRender(), SoVRMLGroup::audioRender(), SoShape::beginSolidShape(), SoRayPickAction::beginTraversal(), SoPickAction::beginTraversal(), SoHandleEventAction::beginTraversal(), SoVRMLTransform::callback(), SoSeparator::callback(), SoGeoSeparator::callback(), SoDragger::callback(), SoVRMLGroup::callback(), SoVRMLTransform::doAction(), SoSeparator::doAction(), SoMultipleCopy::doAction(), SoArray::doAction(), SoVRMLShape::doAction(), SoVRMLGroup::doAction(), SoVRMLBillboard::doAction(), SoVRMLVertexShape::generateAndReadLockNormalCache(), SoVertexShape::generateAndReadLockNormalCache(), SoTriangleStripSet::generatePrimitives(), SoQuadMesh::generatePrimitives(), SoPointSet::generatePrimitives(), SoLineSet::generatePrimitives(), SoIndexedTriangleStripSet::generatePrimitives(), SoIndexedFaceSet::generatePrimitives(), SoImage::generatePrimitives(), SoFaceSet::generatePrimitives(), SoVRMLIndexedLineSet::generatePrimitives(), SoVRMLIndexedFaceSet::generatePrimitives(), SoVRMLExtrusion::generatePrimitives(), SoVRMLTransform::getBoundingBox(), SoSeparator::getBoundingBox(), SoLevelOfDetail::getBoundingBox(), SoGeoSeparator::getBoundingBox(), SoArray::getBoundingBox(), SoVRMLShape::getBoundingBox(), SoVRMLGroup::getBoundingBox(), SoVRMLBillboard::getBoundingBox(), SoVRMLTransform::getMatrix(), SoSeparator::getMatrix(), SoVRMLTransform::getPrimitiveCount(), SoMarkerSet::getPrimitiveCount(), SoGeoSeparator::getPrimitiveCount(), SoDragger::getPrimitiveCount(), SoVRMLGroup::getPrimitiveCount(), SoWWWInline::GLRender(), SoTriangleStripSet::GLRender(), SoText2::GLRender(), SoShape::GLRender(), SoQuadMesh::GLRender(), SoPointSet::GLRender(), SoNurbsCurve::GLRender(), SoMarkerSet::GLRender(), SoLineSet::GLRender(), SoIndexedTriangleStripSet::GLRender(), SoIndexedNurbsCurve::GLRender(), SoIndexedLineSet::GLRender(), SoIndexedFaceSet::GLRender(), SoFaceSet::GLRender(), SoDragger::GLRender(), SoVRMLShape::GLRender(), SoVRMLInline::GLRender(), SoVRMLIndexedLineSet::GLRender(), SoVRMLIndexedFaceSet::GLRender(), SoVRMLExtrusion::GLRender(), SoVRMLElevationGrid::GLRender(), SoVRMLCollision::GLRender(), SoVRMLBackground::GLRender(), SoVRMLTransform::GLRenderBelowPath(), SoSeparator::GLRenderBelowPath(), SoLocateHighlight::GLRenderBelowPath(), SoGeoSeparator::GLRenderBelowPath(), SoExtSelection::GLRenderBelowPath(), SoVRMLGroup::GLRenderBelowPath(), SoVRMLBillboard::GLRenderBelowPath(), SoVRMLTransform::GLRenderInPath(), SoSeparator::GLRenderInPath(), SoLocateHighlight::GLRenderInPath(), SoGeoSeparator::GLRenderInPath(), SoVRMLGroup::GLRenderInPath(), SoVRMLBillboard::GLRenderInPath(), SoVRMLAnchor::handleEvent(), SoVRMLTransform::rayPick(), SoNurbsSurface::rayPick(), SoNurbsCurve::rayPick(), SoIndexedNurbsSurface::rayPick(), SoIndexedNurbsCurve::rayPick(), SoGeoSeparator::rayPick(), SoDragger::rayPick(), SoMultipleCopy::search(), SoArray::search(), SoVertexShape::setNormalCache(), and SoShape::shouldGLRender().

void SoState::pop ( void   ) 

This method pops the state to restore it to a previous state. Pops are performed eagerly but the code is very tight so there is no reason to worry about efficiency.

References SoElement::nextdown, and SoElement::pop().

Referenced by SoSeparator::audioRender(), SoVRMLGroup::audioRender(), SoRayPickAction::beginTraversal(), SoPickAction::beginTraversal(), SoHandleEventAction::beginTraversal(), SoVRMLTransform::callback(), SoSeparator::callback(), SoGeoSeparator::callback(), SoDragger::callback(), SoVRMLGroup::callback(), SoVRMLTransform::doAction(), SoSeparator::doAction(), SoMultipleCopy::doAction(), SoArray::doAction(), SoVRMLShape::doAction(), SoVRMLGroup::doAction(), SoVRMLBillboard::doAction(), SoShape::endSolidShape(), SoVRMLVertexShape::generateAndReadLockNormalCache(), SoVertexShape::generateAndReadLockNormalCache(), SoTriangleStripSet::generatePrimitives(), SoQuadMesh::generatePrimitives(), SoPointSet::generatePrimitives(), SoLineSet::generatePrimitives(), SoIndexedTriangleStripSet::generatePrimitives(), SoIndexedFaceSet::generatePrimitives(), SoImage::generatePrimitives(), SoFaceSet::generatePrimitives(), SoVRMLIndexedLineSet::generatePrimitives(), SoVRMLIndexedFaceSet::generatePrimitives(), SoVRMLExtrusion::generatePrimitives(), SoVRMLTransform::getBoundingBox(), SoSeparator::getBoundingBox(), SoLevelOfDetail::getBoundingBox(), SoGeoSeparator::getBoundingBox(), SoArray::getBoundingBox(), SoVRMLShape::getBoundingBox(), SoVRMLGroup::getBoundingBox(), SoVRMLBillboard::getBoundingBox(), SoVRMLTransform::getMatrix(), SoSeparator::getMatrix(), SoVRMLTransform::getPrimitiveCount(), SoMarkerSet::getPrimitiveCount(), SoGeoSeparator::getPrimitiveCount(), SoDragger::getPrimitiveCount(), SoVRMLGroup::getPrimitiveCount(), SoWWWInline::GLRender(), SoTriangleStripSet::GLRender(), SoText2::GLRender(), SoShape::GLRender(), SoQuadMesh::GLRender(), SoPointSet::GLRender(), SoNurbsCurve::GLRender(), SoMarkerSet::GLRender(), SoLineSet::GLRender(), SoIndexedTriangleStripSet::GLRender(), SoIndexedNurbsCurve::GLRender(), SoIndexedLineSet::GLRender(), SoIndexedFaceSet::GLRender(), SoFaceSet::GLRender(), SoDragger::GLRender(), SoVRMLShape::GLRender(), SoVRMLInline::GLRender(), SoVRMLIndexedLineSet::GLRender(), SoVRMLIndexedFaceSet::GLRender(), SoVRMLExtrusion::GLRender(), SoVRMLElevationGrid::GLRender(), SoVRMLCollision::GLRender(), SoVRMLBackground::GLRender(), SoVRMLTransform::GLRenderBelowPath(), SoSeparator::GLRenderBelowPath(), SoLocateHighlight::GLRenderBelowPath(), SoGeoSeparator::GLRenderBelowPath(), SoExtSelection::GLRenderBelowPath(), SoVRMLGroup::GLRenderBelowPath(), SoVRMLBillboard::GLRenderBelowPath(), SoVRMLTransform::GLRenderInPath(), SoSeparator::GLRenderInPath(), SoLocateHighlight::GLRenderInPath(), SoGeoSeparator::GLRenderInPath(), SoVRMLGroup::GLRenderInPath(), SoVRMLBillboard::GLRenderInPath(), SoVRMLAnchor::handleEvent(), SoVRMLTransform::rayPick(), SoNurbsSurface::rayPick(), SoNurbsCurve::rayPick(), SoIndexedNurbsSurface::rayPick(), SoIndexedNurbsCurve::rayPick(), SoGeoSeparator::rayPick(), SoDragger::rayPick(), SoMultipleCopy::search(), SoArray::search(), SoVertexShape::setNormalCache(), and SoShape::shouldGLRender().

void SoState::print ( FILE *const   file = stdout  )  const

This method is just for debugging purposes.

References SoType::getName(), SbName::getString(), and SoElement::getTypeId().

SbBool SoState::isElementEnabled ( const int  stackindex  )  const [inline]

int SoState::getDepth ( void   )  const

This method returns the current depth of the state stack.

The depth is "virtual", not necessarily physical.

void SoState::setCacheOpen ( const SbBool  open  ) 

Controls whether a cache is open.

SbBool SoState::isCacheOpen ( void   )  const [inline]


The documentation for this class was generated from the following files:

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Feb 23 16:34:01 2009 for Coin by Doxygen. 1.5.8