Open Inventor Reference
SoState Class Reference

An SoState collects and holds state while traversing a scene graph. More...

#include <Inventor/misc/SoState.h>

Public Member Functions

 SoState (SoAction *action, const SoTypeList &enabledElements)
 Constructor. More...
 
 ~SoState ()
 Destructor. More...
 
SoActiongetAction () const
 Returns the action instance the state is part of. More...
 
SoElementgetElement (int stackIndex)
 Returns a writable instance of the element on the top of the stack with the given index. More...
 
const SoElementgetConstElement (int stackIndex) const
 Returns the top (read-only) instance of the given element stack. More...
 
void push ()
 Pushes (saves) the current state until a pop() restores it. More...
 
void pop ()
 Pops the state, restoring the state to just before the last push(). More...
 
void print (FILE *fp)
 Prints state to file (for debugging) More...
 
bool isElementEnabled (int stackIndex) const
 Returns TRUE if element with given stack index is enabled in state. More...
 
int getDepth () const
 Returns current depth of state. More...
 
void setCacheOpen (bool flag)
 Sets/returns flag that indicates whether a cache is open. More...
 
bool isCacheOpen () const
 
SoElementgetElementNoPush (int stackIndex) const
 Internal-only, dangerous method that returns a writeable element without checking for state depth and doing a push. More...
 

Detailed Description

A state is composed of a variety of elements, each of which holds some specific information, such as coordinates or diffuse color of the surface material.

Each element is stored in its own stack so that save and restore can be implemented as push and pop. These stack operations are performed lazily, so that pushing of a value occurs only when the value would be overwritten, for efficiency.

Definition at line 82 of file SoState.h.

Constructor & Destructor Documentation

◆ SoState()

SoState::SoState ( SoAction action,
const SoTypeList enabledElements 
)

Takes pointer to action instance this state is part of and a list of type-ids of elements that are enabled.

◆ ~SoState()

SoState::~SoState ( )

Member Function Documentation

◆ getAction()

SoAction* SoState::getAction ( ) const
inline

Definition at line 93 of file SoState.h.

◆ getConstElement()

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

Definition at line 100 of file SoState.h.

Referenced by SoElement::getConstElement(), and SoGLLazyElement::getInstance().

◆ getDepth()

int SoState::getDepth ( ) const
inline

Definition at line 123 of file SoState.h.

◆ getElement()

SoElement* SoState::getElement ( int  stackIndex)

◆ getElementNoPush()

SoElement* SoState::getElementNoPush ( int  stackIndex) const
inline

Be very careful and consider the caching implications before using this method!

Definition at line 135 of file SoState.h.

Referenced by SoCacheElement::getCurrentCache(), SoLazyElement::getInstance(), SoGLCacheContextElement::resetAutoCacheBits(), SoGLCacheContextElement::setAutoCacheBits(), and SoGLCacheContextElement::shouldAutoCache().

◆ isCacheOpen()

◆ isElementEnabled()

bool SoState::isElementEnabled ( int  stackIndex) const
inline

Definition at line 119 of file SoState.h.

◆ pop()

void SoState::pop ( )

◆ print()

void SoState::print ( FILE *  fp)

◆ push()

void SoState::push ( )
inline

The push is done lazily: this just increments the depth in the state. When an element is accessed with getElement() and its depth is less than the current depth, it is then pushed individually.

Definition at line 108 of file SoState.h.

◆ setCacheOpen()

void SoState::setCacheOpen ( bool  flag)
inline

This flag lets us optimize element capturing; we don't need to try to capture elements if the flag is FALSE.

Definition at line 128 of file SoState.h.


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