Coin
4.0.3
Coin3D core library
|
The SoState class manages the Coin scene graph traversal state data. More...
#include <Inventor/misc/SoState.h>
Public Member Functions | |
SoState (SoAction *action, const SoTypeList &enabledelements) | |
~SoState (void) | |
SoAction * | getAction (void) const |
const SoElement * | getConstElement (const int stackindex) const |
int | getDepth (void) const |
SoElement * | getElement (const int stackindex) |
SoElement * | getElementNoPush (const int stackindex) const |
SbBool | isCacheOpen (void) const |
SbBool | isElementEnabled (const int stackindex) const |
void | pop (void) |
void | print (FILE *const file=stdout) const |
void | push (void) |
void | setCacheOpen (const SbBool flag) |
The SoState class manages the Coin scene graph traversal state data.
The SoState class is used by actions derived from the SoAction class. It manages the scene graph state as stacks of elements (i.e. 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".
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.
SoState::~SoState | ( | void | ) |
The destructor.
Note that when destruction happens, lagging events caused by lazy evaluation won't be performed.
This method returns the pointer to the action instance given to the constructor.
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-effects 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().
int SoState::getDepth | ( | void | ) | const |
This method returns the current depth of the state stack.
The depth is "virtual", not necessarily physical.
This method returns a modifiable 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.
|
inline |
Returns whether a cache is open.
|
inline |
This method returns TRUE if the element with the given element stack index is enabled, and FALSE otherwise.
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.
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.