Open Inventor Reference
SoAction Class Referenceabstract

Abstract base class for all actions. More...

#include <Inventor/actions/SoAction.h>

Inheritance diagram for SoAction:
SoCallbackAction SoGLRenderAction SoGetBoundingBoxAction SoGetMatrixAction SoHandleEventAction SoPickAction SoSearchAction SoWriteAction

Public Types

enum  AppliedCode { NODE , PATH , PATH_LIST }
 This enum is used to determine what the action is being applied to. More...
 
enum  PathCode { NO_PATH , IN_PATH , BELOW_PATH , OFF_PATH }
 This enum may be used during traversal of nodes to indicate where the node is with respect to the path being traversed. More...
 

Public Member Functions

virtual ~SoAction ()
 Destructor.
 
virtual SoType getTypeId () const =0
 Returns the type identifier for a specific instance.
 
bool isOfType (SoType type) const
 Returns TRUE if this instance is of the type specified in type or is derived from that type.
 
virtual void apply (SoNode *node)
 
virtual void apply (SoPath *path)
 
virtual void apply (const SoPathList &pathList, bool obeysRules=FALSE)
 Initiates an action on the graph defined either by a node, path, or list of paths.
 
virtual void invalidateState ()
 Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied.
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to.
 
SoNodegetNodeAppliedTo () const
 These returns a pointer to the node, path, or path list the action is being applied to.
 
SoPathgetPathAppliedTo () const
 
const SoPathListgetPathListAppliedTo () const
 A single path list may be split into several, one for each different head node.
 
const SoPathListgetOriginalPathListAppliedTo () const
 
bool isLastPathListAppliedTo () const
 
PathCode getPathCode (int &numIndices, const int *&indices)
 Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to.
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node.
 
bool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition.
 
const SoPathgetCurPath ()
 Returns a pointer to the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed.
 
SoStategetState () const
 Get the state from the action.
 
PathCode getCurPathCode () const
 These methods maintain the current path accumulated so far during traversal.
 
void pushCurPath (int childIndex)
 
void popCurPath (PathCode prevPathCode)
 
virtual SoNodegetCurPathTail ()
 This is virtual, so that SoCallbackAction can use current node.
 
void usePathCode (int &numIndices, const int *&indices)
 called by inline getPathCode:
 
void pushCurPath ()
 Optimized versions of push/pop when we know path codes won't change:
 
void popPushCurPath (int childIndex)
 
void popCurPath ()
 
const SoLightweightPathgetCurrentLightweightPath () const
 Returns the current "light" path.
 
void setCurrentLightweightPath (const SoLightweightPath &path)
 Sets the current "light" path.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static void nullAction (SoAction *, SoNode *)
 Null action method that can be stored in lookup table when desired.
 
static void initClass ()
 
static void initClasses ()
 Initialize ALL Inventor action classes.
 

Protected Member Functions

 SoAction ()
 Constructor.
 
virtual const SoEnabledElementsListgetEnabledElements () const
 Returns the list of enabled elements for a given action subclass.
 
virtual void beginTraversal (SoNode *node)
 Begins traversal of an action at the given node.
 
void setTerminated (bool flag)
 Allows subclass instance to indicate that traversal has reached a termination condition.
 
virtual bool shouldCompactPathLists () const
 This method is used when applying an action to an SoPathList.
 

Protected Attributes

SoStatestate
 Traversal state.
 
SoActionMethodListtraversalMethods
 The list of what to do when.
 

Static Protected Attributes

static SoEnabledElementsListenabledElements
 Holds list of enabled elements for the SoAction class.
 
static SoActionMethodListmethods
 ... and the methods
 

Friends

class SoDB
 

Detailed Description

SoAction is the abstract base class for all actions. Classes derived from SoAction define operations to be applied at each node encountered during traversal of a scene graph. The function that gets called to implement the action for a particular node type is determined by a lookup table in the global database.

See Also
SoNode, SoPath, SoPathList, SoCallbackAction, SoGLRenderAction, SoGetBoundingBoxAction, SoGetMatrixAction, SoHandleEventAction, SoPickAction, SoRayPickAction, SoSearchAction, SoWriteAction

Definition at line 179 of file SoAction.h.

Member Enumeration Documentation

◆ AppliedCode

Enumerator
NODE 

Applied to graph rooted by a node.

PATH 

Applied to graph defined by a path.

PATH_LIST 

Applied to graphs defined by list of paths.

Definition at line 235 of file SoAction.h.

◆ PathCode

Enumerator
NO_PATH 

Not traversing a path.

IN_PATH 

In middle of path chain (not tail node)

BELOW_PATH 

Tail node of path or below tail node.

OFF_PATH 

None of the above (Probably to the left)

Definition at line 243 of file SoAction.h.

Constructor & Destructor Documentation

◆ ~SoAction()

virtual SoAction::~SoAction ( )
virtual

◆ SoAction()

SoAction::SoAction ( )
protected

Member Function Documentation

◆ apply() [1/3]

virtual void SoAction::apply ( const SoPathList pathList,
bool  obeysRules = FALSE 
)
virtual

TRUE can be passed for the obeysRules flag if the given path list has the following 4 properties:

1 - All paths have the same head node
2 - Paths are sorted in traversal order
3 - If one path ends at node A, no other path
continues through A
4 - No two paths are the same

These rules will be obeyed by path lists returned by picking and by searches for non-group nodes.

Reimplemented in SoBoxHighlightRenderAction, and SoLineHighlightRenderAction.

◆ apply() [2/3]

virtual void SoAction::apply ( SoNode node)
virtual

◆ apply() [3/3]

virtual void SoAction::apply ( SoPath path)
virtual

◆ beginTraversal()

virtual void SoAction::beginTraversal ( SoNode node)
protectedvirtual

The default method just calls traverse(node). This is virtual to allow subclasses to do extra work before or after traversing the node.

Reimplemented in SoCallbackAction, SoGetBoundingBoxAction, SoGetMatrixAction, SoGLRenderAction, SoHandleEventAction, SoPickAction, SoRayPickAction, SoSearchAction, and SoWriteAction.

◆ getClassTypeId()

static SoType SoAction::getClassTypeId ( )
inlinestatic

Definition at line 187 of file SoAction.h.

◆ getCurPath()

const SoPath * SoAction::getCurPath ( )

◆ getCurPathCode()

PathCode SoAction::getCurPathCode ( ) const
inline

The action needs to know whether this path is a subset of the path being applied to; it saves this info in the onPath variable. Before a node is pushed onto the current path, call getOnPath() to determine the current setting. The value of this flag should be passed in to popCurPath() so the onPath variable can be restored.

Definition at line 310 of file SoAction.h.

◆ getCurPathTail()

virtual SoNode * SoAction::getCurPathTail ( )
virtual

Reimplemented in SoCallbackAction.

◆ getCurrentLightweightPath()

const SoLightweightPath & SoAction::getCurrentLightweightPath ( ) const
inline

MeVis extension which was needed for some rendering scenarios where the intermediate path needs to be stored and restored.

Definition at line 332 of file SoAction.h.

◆ getEnabledElements()

virtual const SoEnabledElementsList & SoAction::getEnabledElements ( ) const
protectedvirtual

◆ getNodeAppliedTo()

SoNode * SoAction::getNodeAppliedTo ( ) const
inline

Each returns NULL if the action is not being applied to the appropriate class.

Definition at line 256 of file SoAction.h.

◆ getOriginalPathListAppliedTo()

const SoPathList * SoAction::getOriginalPathListAppliedTo ( ) const
inline

Definition at line 264 of file SoAction.h.

◆ getPathAppliedTo()

SoPath * SoAction::getPathAppliedTo ( ) const
inline

Definition at line 257 of file SoAction.h.

◆ getPathCode()

PathCode SoAction::getPathCode ( int &  numIndices,
const int *&  indices 
)
inline

If this returns IN_PATH, indices is set to point to an array of indices corresponding to the children that continue the paths and numIndices is set to the number of such children.

Definition at line 275 of file SoAction.h.

◆ getPathListAppliedTo()

const SoPathList * SoAction::getPathListAppliedTo ( ) const
inline

These methods allow subclasses to determine the current path list, the original path list, and whether the current list is the last one from the original

Definition at line 262 of file SoAction.h.

◆ getState()

SoState * SoAction::getState ( ) const
inline

Definition at line 295 of file SoAction.h.

Referenced by SoBundle::SoBundle().

◆ getTypeId()

virtual SoType SoAction::getTypeId ( ) const
pure virtual

◆ getWhatAppliedTo()

AppliedCode SoAction::getWhatAppliedTo ( ) const
inline

Definition at line 251 of file SoAction.h.

◆ hasTerminated()

bool SoAction::hasTerminated ( ) const
inline

◆ initClass()

static void SoAction::initClass ( )
static

◆ initClasses()

static void SoAction::initClasses ( )
static

◆ invalidateState()

virtual void SoAction::invalidateState ( )
virtual

This is typically unnecessary in most applications.

Reimplemented in SoGLRenderAction.

◆ isLastPathListAppliedTo()

bool SoAction::isLastPathListAppliedTo ( ) const
inline

Definition at line 266 of file SoAction.h.

◆ isOfType()

bool SoAction::isOfType ( SoType  type) const

Otherwise, it returns FALSE. For example,

actionPtr->isOfType(SoGetMatrixAction::getClassTypeId())
static SoType getClassTypeId()
Returns the type identifier for this class.
Definition SoAction.h:187

returns TRUE if actionPtr is an instance of SoGetMatrixAction or one of its subclasses.

◆ nullAction()

static void SoAction::nullAction ( SoAction ,
SoNode  
)
static

◆ popCurPath() [1/2]

void SoAction::popCurPath ( )
inline

Definition at line 327 of file SoAction.h.

◆ popCurPath() [2/2]

void SoAction::popCurPath ( PathCode  prevPathCode)

◆ popPushCurPath()

void SoAction::popPushCurPath ( int  childIndex)
inline

Definition at line 325 of file SoAction.h.

◆ pushCurPath() [1/2]

void SoAction::pushCurPath ( )
inline

Definition at line 323 of file SoAction.h.

◆ pushCurPath() [2/2]

void SoAction::pushCurPath ( int  childIndex)

◆ setCurrentLightweightPath()

void SoAction::setCurrentLightweightPath ( const SoLightweightPath path)
inline

MeVis extension which was needed for some rendering scenarios where the intermediate path needs to be stored and restored.

Definition at line 337 of file SoAction.h.

◆ setTerminated()

void SoAction::setTerminated ( bool  flag)
inlineprotected

Definition at line 353 of file SoAction.h.

Referenced by SoSearchAction::setFound(), and SoHandleEventAction::setHandled().

◆ shouldCompactPathLists()

virtual bool SoAction::shouldCompactPathLists ( ) const
protectedvirtual

It returns TRUE if the action should create a compact version of the path list before applying itself to it. The default method returns TRUE, since the compact version is more efficient. Some actions may choose to return FALSE; for example, the SoWriteAction applies itself to each path separately, so it doesn't need the extra overhead of compacting the list.

Reimplemented in SoWriteAction.

◆ traverse()

void SoAction::traverse ( SoNode node)

◆ usePathCode()

void SoAction::usePathCode ( int &  numIndices,
const int *&  indices 
)

Friends And Related Symbol Documentation

◆ SoDB

friend class SoDB
friend

Definition at line 434 of file SoAction.h.

Member Data Documentation

◆ enabledElements

SoEnabledElementsList* SoAction::enabledElements
staticprotected

Definition at line 373 of file SoAction.h.

◆ methods

SoActionMethodList* SoAction::methods
staticprotected

Definition at line 376 of file SoAction.h.

◆ state

SoState* SoAction::state
protected

Definition at line 366 of file SoAction.h.

◆ traversalMethods

SoActionMethodList* SoAction::traversalMethods
protected

Subclasses set this pointer to their per-class instance in their constructors.

Definition at line 370 of file SoAction.h.


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