Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoAction Class Reference

The SoAction class is the base class for all traversal actions. More...

#include <Inventor/actions/SoAction.h>

Inheritance diagram for SoAction::

SoCallbackAction SoGetBoundingBoxAction SoGetMatrixAction SoGetPrimitiveCountAction SoGLRenderAction SoHandleEventAction SoPickAction SoSearchAction SoWriteAction List of all members.

Public Types

enum  AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }
enum  PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }

Public Methods

virtual ~SoAction ()
virtual SoType getTypeId (void) const=0
virtual SbBool isOfType (SoType type) const
virtual void apply (SoNode *root)
virtual void apply (SoPath *path)
virtual void apply (const SoPathList &pathlist, SbBool obeysrules=FALSE)
virtual void invalidateState (void)
AppliedCode getWhatAppliedTo (void) const
SoNodegetNodeAppliedTo (void) const
SoPathgetPathAppliedTo (void) const
const SoPathListgetPathListAppliedTo (void) const
const SoPathListgetOriginalPathListAppliedTo (void) const
SbBool isLastPathListAppliedTo (void) const
PathCode getPathCode (int &numindices, const int *&indices)
void traverse (SoNode *const node)
SbBool hasTerminated (void) const
const SoPathgetCurPath (void)
SoStategetState (void) const
PathCode getCurPathCode (void) const
virtual SoNodegetCurPathTail (void)
void usePathCode (int &numindices, const int *&indices)
void pushCurPath (const int childindex, SoNode *node=NULL)
void popCurPath (const PathCode prevpathcode)
void pushCurPath (void)
void popPushCurPath (const int childindex, SoNode *node=NULL)
void popCurPath (void)
void switchToPathTraversal (SoPath *path)
void switchToNodeTraversal (SoNode *node)

Static Public Methods

void initClass (void)
void initClasses (void)
SoType getClassTypeId (void)
void nullAction (SoAction *action, SoNode *node)

Protected Methods

 SoAction (void)
virtual void beginTraversal (SoNode *node)
virtual void endTraversal (SoNode *node)
void setTerminated (const SbBool flag)
virtual const SoEnabledElementsListgetEnabledElements (void) const
virtual SbBool shouldCompactPathList (void) const

Static Protected Methods

SoEnabledElementsListgetClassEnabledElements (void)
SoActionMethodListgetClassActionMethods (void)

Protected Attributes

SoStatestate
SoActionMethodListtraversalMethods

Detailed Description

The SoAction class is the base class for all traversal actions.

Applying actions is the basic mechanism in Coin for executing various operations on scene graphs or paths within scene graphs, including search operations, rendering, interaction through picking, etc.

The basic operation is to instantiate an action, set it up with miscellaneous parameters if necessary, then "apply it" to the root node of the scenegraph (or sub-graph of a scenegraph). The action then traverses the scenegraph from the root node, depth-first and left-to-right, applying it's specific processing at the nodes where it is applicable.

   int write_scenegraph(const char * filename, SoNode * root)
   {
     SoOutput output;
     if (output.openFile(filename)) return 0;
     SoWriteAction wa(&output);
     wa.apply(root);
     return 1;
   }

See the various built-in actions for further information (ie the subclasses of this class), or look at the example code applications of the Coin library to see how actions are generally used.

For extending the Coin library with your own action classes, we strongly recommend that you make yourself acquainted with the excellent «The Inventor Toolmaker» book (ISBN 0-201-62493-1), which describes the tasks involved in detail. Reading the sourcecode of the built-in action classes in Coin should also provide very helpful.


Member Enumeration Documentation

enum SoAction::AppliedCode
 

Enumerated values for what the action was applied to.

enum SoAction::PathCode
 

Enumerated values for how the action is applied to a scene graph.


Constructor & Destructor Documentation

SoAction::~SoAction void [virtual]
 

Destructor, free resources.

SoAction::SoAction void [protected]
 

Default constructor, does all necessary toplevel initialization.


Member Function Documentation

void SoAction::initClass void [static]
 

Initializes the run-time type system for this class, and sets up the enabled elements and action method list.

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

void SoAction::initClasses void [static]
 

Initialize all the SoAction subclasses. Automatically called from SoAction::initClass().

SoType SoAction::getClassTypeId void [static]
 

Returns the run-time type object associated with instances of this class.

SoType SoAction::getTypeId void const [pure virtual]
 

Returns the type identification of an action derived from a class inheriting SoAction. This is used for run-time type checking and "downward" casting.

Usage example:

  void bar(SoAction * action)
  {
    if (action->getTypeId() == SoGLRenderAction::getClassTypeId()) {
      // safe downward cast, know the type
      SoGLRenderAction * glrender = (SoGLRenderAction *)action;
    }
    return; // ignore if not renderaction
  }

For application programmers wanting to extend the library with new actions: this method needs to be overloaded in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through Inventor/nodes/SoSubAction.h: SO_ACTION_SOURCE, SO_ACTION_INIT_CLASS and SO_ACTION_CONSTRUCTOR.

For more information on writing Coin extensions, see the SoAction class documentation.

SbBool SoAction::isOfType SoType type const [virtual]
 

Returns TRUE if the type of this object is either of the same type or a subclass of type.

void SoAction::apply SoNode * node [virtual]
 

Applies the action to the scene graph rooted at root.

Note that you should not apply an action to a node with a zero reference count. The behavior in that case is undefined.

Reimplemented in SoBoxHighlightRenderAction, and SoLineHighlightRenderAction.

void SoAction::apply SoPath * path [virtual]
 

Applies the action to the parts of the graph defined by path.

Reimplemented in SoBoxHighlightRenderAction, and SoLineHighlightRenderAction.

void SoAction::apply const SoPathList & pathlist,
SbBool obeysrules = FALSE
[virtual]
 

Applies action to the graphs defined by pathlist. If obeysrules is set to TRUE, pathlist must obey the following four conditions (which is the case for path lists returned from search actions for non-group nodes and path lists returned from picking actions):

All paths must start at the same head node. All paths must be sorted in traversal order. The paths must be unique. No path can continue through the end point of another path.

Reimplemented in SoBoxHighlightRenderAction, and SoLineHighlightRenderAction.

void SoAction::invalidateState void [virtual]
 

Invalidates the state, forcing it to be recreated at the next apply() invocation.

Reimplemented in SoGLRenderAction.

void SoAction::nullAction SoAction * action,
SoNode * node
[static]
 

This method is used for filling up the lookup tables with void methods.

SoAction::AppliedCode SoAction::getWhatAppliedTo void const
 

Returns a code indicating what (node, path, or pathlist) the action instance is being applied to.

SoNode * SoAction::getNodeAppliedTo void const
 

Returns a pointer to the node the action is being applied to.

If action is not being applied to a node (but a path or a pathlist), the method returns NULL.

SoPath * SoAction::getPathAppliedTo void const
 

Returns the pointer to the path the action is being applied to. The path is managed by the action instance and should not be destroyed or modified by the caller.

If action is not being applied to a path (but a node or a pathlist), the method returns NULL.

const SoPathList * SoAction::getPathListAppliedTo void const
 

Returns the pointer to the path list the action is currently being applied to. The path list is managed by the action instance and should not be destroyed or modified by the caller.

If action is not being applied to a path list (but a node or a path), the method returns NULL.

The returned pathlist pointer need not be equal to the list apply() was called with, as the action may have reorganized the path list for efficiency reasons.

See also:
void SoAction::apply(const SoPathList &, SbBool)

const SoPathList * SoAction::getOriginalPathListAppliedTo void const
 

Returns a pointer to the original path list the action is being applied to.

If the action is not being applied to a path list (but a node or a path), the method returns NULL.

SbBool SoAction::isLastPathListAppliedTo void const
 

This method is not supported in Coin. It should probably have been private in OIV.

SoAction::PathCode SoAction::getPathCode int & numindices,
const int *& indices
 

Returns a code that indicates where the current node lies with respect to the path(s) the action is being applied to. The arguments indices and numindices are only set if the method returns IN_PATH.

void SoAction::traverse SoNode *const node
 

Traverses a scene graph rooted at node, invoking the action methods of the nodes in the graph.

SbBool SoAction::hasTerminated void const
 

Returns TRUE if the action was prematurely terminated.

Note that the termination flag will be FALSE if the action simply completed its run over the scene graph in the "ordinary" fashion, i.e. was not explicitly aborted from any of the nodes in the graph.

See also:
setTerminated()

const SoPath * SoAction::getCurPath void
 

Returns a pointer to the path generated during traversal, from the root of the traversed graph to the current node.

SoState * SoAction::getState void const
 

Returns a pointer to the state of the action instance. The state contains the current set of elements used during traversal.

SoAction::PathCode SoAction::getCurPathCode void const [inline]
 

Returns the current traversal path code.

SoNode * SoAction::getCurPathTail void [virtual]
 

For internal use only.

Reimplemented in SoCallbackAction.

void SoAction::usePathCode int & numindices,
const int *& indices
 

For internal use only.

void SoAction::pushCurPath const int childindex,
SoNode * node = NULL
 

Get ready to traverse the childindex'th child. Use this method if the path code might change as a result of this.

This method is very internal. Do not use unless you know what you're doing.

void SoAction::popCurPath const PathCode prevpathcode [inline]
 

Pops the current path, and sets the path code to prevpathcode.

This method is very internal. Do not use unless you know what you're doing.

void SoAction::pushCurPath void
 

Pushes a NULL node onto the current path. Use this before traversing all children when you know that the path code will not change while traversing children.

This method is very internal. Do not use unless you know what you're doing.

void SoAction::popPushCurPath const int childindex,
SoNode * node = NULL
 

Get ready to traverse the childindex'th child. Use this method if you know the path code will not change as a result of this.

This method is very internal. Do not use unless you know what you're doing.

void SoAction::popCurPath void
 

Pops of the last child in the current path. Use this if you know the path code hasn't changed since the current path was pushed.

This method is very internal. Do not use unless you know what you're doing.

void SoAction::switchToPathTraversal SoPath * path
 

Store our state, traverse the given path, restore our state and continue traversal.

void SoAction::switchToNodeTraversal SoNode * node
 

Store our state, traverse the subgraph rooted at the given node, restore our state and continue traversal.

void SoAction::beginTraversal SoNode * node [protected, virtual]
 

This virtual method is called from SoAction::apply(), and is the entry point for the actual scenegraph traversal.

It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting SoAction.

Default method just calls traverse(), which any overridden implementation of the method must do too (or call SoAction::beginTraversal()) to trigger the scenegraph traversal.

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

void SoAction::endTraversal SoNode * node [protected, virtual]
 

This virtual method can be overloaded to execute code after the scene graph traversal. Default method does nothing.

Reimplemented in SoGLRenderAction.

void SoAction::setTerminated const SbBool flag [protected]
 

Set the termination flag.

Typically set to TRUE from nodes upon special conditions being met during scene graph traversal -- like the correct node being found when doing SoSearchAction traversal or when grabbing the event from an SoHandleEventAction.

See also:
hasTerminated()

const SoEnabledElementsList & SoAction::getEnabledElements void const [protected, virtual]
 

Returns a list of the elements used by action instances of this class upon traversal operations.

SbBool SoAction::shouldCompactPathList void const [protected, virtual]
 

For internal use only.

SoEnabledElementsList * SoAction::getClassEnabledElements void [static, protected]
 

For internal use only.

SoActionMethodList * SoAction::getClassActionMethods void [static, protected]
 

For internal use only.


Member Data Documentation

SoAction::state [protected]
 

Pointer to the traversal state instance of the action.

SoAction::traversalMethods [protected]
 

Stores the list of "nodetype to actionmethod" mappings for the particular action instance.


The documentation for this class was generated from the following files:
Generated at Tue Mar 5 03:31:21 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001