Open Inventor Reference
|
Abstract base class for all actions. More...
#include <Inventor/actions/SoAction.h>
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. | |
SbBool | 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, SbBool 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. | |
SoNode * | getNodeAppliedTo () const |
These returns a pointer to the node, path, or path list the action is being applied to. | |
SoPath * | getPathAppliedTo () const |
const SoPathList * | getPathListAppliedTo () const |
A single path list may be split into several, one for each different head node. | |
const SoPathList * | getOriginalPathListAppliedTo () const |
SbBool | 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. | |
SbBool | hasTerminated () const |
Returns TRUE if the traversal has reached a termination condition. | |
const SoPath * | getCurPath () |
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. | |
SoState * | getState () 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 SoNode * | getCurPathTail () |
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 () |
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 SoEnabledElementsList & | getEnabledElements () 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 (SbBool flag) |
Allows subclass instance to indicate that traversal has reached a termination condition. | |
virtual SbBool | shouldCompactPathLists () const |
This method is used when applying an action to an SoPathList. | |
Protected Attributes | |
SoState * | state |
Traversal state. | |
SoActionMethodList * | traversalMethods |
The list of what to do when. | |
Static Protected Attributes | |
static SoEnabledElementsList * | enabledElements |
Holds list of enabled elements for the SoAction class. | |
static SoActionMethodList * | methods |
... and the methods | |
Friends | |
class | SoDB |
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.
Definition at line 179 of file SoAction.h.
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.
enum SoAction::PathCode |
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.
virtual SoAction::~SoAction | ( | ) | [virtual] |
SoAction::SoAction | ( | ) | [protected] |
virtual void SoAction::apply | ( | SoNode * | node | ) | [virtual] |
Reimplemented in SoBoxHighlightRenderAction, and SoLineHighlightRenderAction.
virtual void SoAction::apply | ( | SoPath * | path | ) | [virtual] |
Reimplemented in SoBoxHighlightRenderAction, and SoLineHighlightRenderAction.
virtual void SoAction::apply | ( | const SoPathList & | pathList, |
SbBool | 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.
virtual void SoAction::beginTraversal | ( | SoNode * | node | ) | [protected, virtual] |
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.
static SoType SoAction::getClassTypeId | ( | ) | [inline, static] |
Definition at line 187 of file SoAction.h.
const SoPath* SoAction::getCurPath | ( | ) |
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.
virtual SoNode* SoAction::getCurPathTail | ( | ) | [virtual] |
Reimplemented in SoCallbackAction.
virtual const SoEnabledElementsList& SoAction::getEnabledElements | ( | ) | const [protected, virtual] |
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.
const SoPathList* SoAction::getOriginalPathListAppliedTo | ( | ) | const [inline] |
Definition at line 264 of file SoAction.h.
SoPath* SoAction::getPathAppliedTo | ( | ) | const [inline] |
Definition at line 257 of file SoAction.h.
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.
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.
SoState* SoAction::getState | ( | ) | const [inline] |
Definition at line 295 of file SoAction.h.
Referenced by SoBundle::SoBundle().
virtual SoType SoAction::getTypeId | ( | ) | const [pure virtual] |
AppliedCode SoAction::getWhatAppliedTo | ( | ) | const [inline] |
Definition at line 251 of file SoAction.h.
SbBool SoAction::hasTerminated | ( | ) | const [inline] |
Definition at line 287 of file SoAction.h.
Referenced by SoGLRenderAction::abortNow(), SoSearchAction::isFound(), and SoHandleEventAction::isHandled().
static void SoAction::initClass | ( | ) | [static] |
static void SoAction::initClasses | ( | ) | [static] |
virtual void SoAction::invalidateState | ( | ) | [virtual] |
This is typically unnecessary in most applications.
Reimplemented in SoGLRenderAction.
SbBool SoAction::isLastPathListAppliedTo | ( | ) | const [inline] |
Definition at line 266 of file SoAction.h.
Otherwise, it returns FALSE. For example,
actionPtr->isOfType(SoGetMatrixAction::getClassTypeId())
returns TRUE if actionPtr
is an instance of SoGetMatrixAction or one of its subclasses.
void SoAction::popCurPath | ( | ) | [inline] |
Definition at line 327 of file SoAction.h.
void SoAction::popCurPath | ( | PathCode | prevPathCode | ) |
void SoAction::popPushCurPath | ( | int | childIndex | ) | [inline] |
Definition at line 325 of file SoAction.h.
void SoAction::pushCurPath | ( | ) | [inline] |
Definition at line 323 of file SoAction.h.
void SoAction::pushCurPath | ( | int | childIndex | ) |
void SoAction::setTerminated | ( | SbBool | flag | ) | [inline, protected] |
Definition at line 344 of file SoAction.h.
Referenced by SoSearchAction::setFound(), and SoHandleEventAction::setHandled().
virtual SbBool SoAction::shouldCompactPathLists | ( | ) | const [protected, virtual] |
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.
void SoAction::traverse | ( | SoNode * | node | ) |
void SoAction::usePathCode | ( | int & | numIndices, |
const int *& | indices | ||
) |
friend class SoDB [friend] |
Definition at line 425 of file SoAction.h.
SoEnabledElementsList* SoAction::enabledElements [static, protected] |
Definition at line 364 of file SoAction.h.
SoActionMethodList* SoAction::methods [static, protected] |
Definition at line 367 of file SoAction.h.
SoState* SoAction::state [protected] |
Definition at line 357 of file SoAction.h.
SoActionMethodList* SoAction::traversalMethods [protected] |
Subclasses set this pointer to their per-class instance in their constructors.
Definition at line 361 of file SoAction.h.