Open Inventor Reference
SoPath Class Reference

Path that points to a list of hierarchical nodes. More...

#include <Inventor/SoPath.h>

Inheritance diagram for SoPath:
SoBase SoFullPath SoNodeKitPath SoTempPath

Public Member Functions

 SoPath ()
 Constructs an empty path.
 
 SoPath (int approxLength)
 Constructs a path with a hint to length (number of nodes in chain).
 
 SoPath (SoNode *node)
 Constructs a path and sets the head node to the given node.
 
void setHead (SoNode *node)
 Sets head node (first node in chain).
 
void append (int childIndex)
 Adds node to end of chain; the node is the childIndex'th child of the current tail node.
 
void append (SoNode *childNode)
 Adds node to end of chain; uses the first occurrence of childNode as child of current tail node.
 
void append (const SoPath *fromPath)
 Adds all nodes in fromPath's chain to end of chain; the head node of fromPath must be the same as or a child of the current tail node.
 
void push (int childIndex)
 These allow a path to be treated as a stack; they push a node at the end of the chain and pop the last node off.
 
void pop ()
 These allow a path to be treated as a stack; they push a node at the end of the chain and pop the last node off.
 
SoNodegetHead () const
 These return the first and last nodes in a path chain.
 
SoNodegetTail () const
 These return the first and last nodes in a path chain.
 
SoNodegetNode (int i) const
 Returns a pointer to the i'th node in the chain.
 
SoNodegetNodeFromTail (int i) const
 Returns a pointer to the i'th node.
 
int getIndex (int i) const
 Return the index of the i'th node (within its parent) in the chain.
 
int getIndexFromTail (int i) const
 Return the index of the i'th node (within its parent) in the chain, counting backward from the tail node.
 
int getLength () const
 Returns length of path chain (number of nodes).
 
void truncate (int start)
 Truncates the path chain, removing all nodes from index start on.
 
bool containsNode (const SoNode *node) const
 Returns TRUE if the node is found anywhere in the path chain.
 
bool containsPath (const SoPath *path) const
 Returns TRUE if the nodes in the chain in the passed path are contained (in consecutive order) in this path chain.
 
int findFork (const SoPath *path) const
 If the two paths have different head nodes, this returns -1.
 
SoPathcopy (int startFromNodeIndex=0, int numNodes=0) const
 Creates and returns a new path that is a copy of some or all of this path.
 
virtual SoType getTypeId () const
 Returns type identifier for path instance.
 
void insertIndex (SoNode *parent, int newIndex)
 This is called when a node in the path chain has a child added.
 
void removeIndex (SoNode *parent, int oldIndex)
 This is called when a node in the path chain has a child removed.
 
void replaceIndex (SoNode *parent, int index, SoNode *newChild)
 This is called when a node in the path chain replaces a child.
 
virtual void write (SoWriteAction *writeAction) const
 Writes path using given write action.
 
bool isRelevantNotification (SoNotList *list) const
 Returns TRUE if the given notification list involves a change to a node that affects the path.
 
- Public Member Functions inherited from SoBase
void ref () const
 Adds and removes a reference to an instance.
 
void unref () const
 
void unrefNoDelete () const
 
void touch ()
 Marks an instance as modified, simulating a change to it.
 
virtual SoType getTypeId () const =0
 Returns the type identifier for a specific instance.
 
bool isOfType (SoType type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
virtual void startNotify ()
 Initiates notification from an instance.
 
virtual void notify (SoNotList *list)
 Propagates modification notification through an instance.
 
void addAuditor (void *auditor, SoNotRec::Type type)
 Adds/removes an auditor to/from list.
 
void removeAuditor (void *auditor, SoNotRec::Type type)
 
const SoAuditorListgetAuditors ()
 Returns auditor list– used by SoField and SoEngineOutput to trace forward connections.
 
int getRefCount () const
 Returns current reference count.
 
virtual void addWriteReference (SoOutput *out, bool isFromField=FALSE)
 Adds a reference to the instance when writing.
 
bool shouldWrite ()
 Returns TRUE if the instance should be written, based on the write-reference info already accumulated.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns type identifier for SoPath class.
 
static SoPathgetByName (const SbName &name)
 
static int getByName (const SbName &name, SoPathList &list)
 These methods lookup and return paths with a given name.
 
static void initClass ()
 Initializes path class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
static void initClass ()
 Setup type information.
 
static void incrementCurrentWriteCounter ()
 Increments the current write counter at the start of a write operation.
 
static void decrementCurrentWriteCounter ()
 Decrements the current write counter after a write operation, in some rare cases.
 
static void addName (SoBase *, const char *)
 Internal methods used to maintain the global name dictionary.
 
static void removeName (SoBase *, const char *)
 
static SoBasegetNamedBase (const SbName &, SoType)
 Helper routines used to get stuff out of nameDict.
 
static int getNamedBases (const SbName &, SoBaseList &, SoType)
 
static bool read (SoInput *in, SoBase *&base, SoType expectedType)
 Reads one instance of some subclass of SoBase.
 
static void setInstancePrefix (const SbString &c)
 This defaults to "+" and is used when naming nodes that are DEF's and USE'd.
 

Protected Member Functions

void auditPath (bool flag)
 Allows internal SoTempPath subclass to forego auditor overhead.
 
 ~SoPath ()
 
- Protected Member Functions inherited from SoBase
 SoBase ()
 Constructor is protected - this is an abstract class.
 
virtual ~SoBase ()
 Virtual destructor so that subclasses are deleted properly.
 
virtual void destroy ()
 Actually deletes an instance.
 
bool hasMultipleWriteRefs () const
 Returns TRUE if the instance has multiple write references.
 
bool writeHeader (SoOutput *out, bool isGroup, bool isEngine) const
 Writes a header (name, open brace) or footer (close brace) to file defined by SoOutput.
 
void writeFooter (SoOutput *out) const
 
virtual const char * getFileFormatName () const
 Unknown nodes and engines write a different name for themselves than their typeId; this virtual method lets them do that (by default the typeId name is returned)
 
virtual bool readInstance (SoInput *in, unsigned short flags)=0
 Reads stuff into instance of subclass.
 

Friends

class SoFullPath
 
class SoTempPath
 
class SoAction
 
INVENTOR_API bool operator== (const SoPath &p1, const SoPath &p2)
 Comparison operator: returns TRUE if all nodes in paths are identical.
 

Additional Inherited Members

- Static Public Attributes inherited from SoBase
static bool traceRefs
 Turns on/off reference count tracing (for debugging)
 
- Protected Types inherited from SoBase
enum  BaseFlags { IS_ENGINE = 1 , IS_GROUP = 2 }
 This set of enums is used when reading and writing the base. More...
 
- Static Protected Member Functions inherited from SoBase
static uint32_t getCurrentWriteCounter ()
 Returns current write counter.
 

Detailed Description

A path represents a scene graph or subgraph. It contains a list of pointers to nodes forming a chain from some root to some descendent. Each node in the chain is a child of the previous node. Paths are used to refer to some object in a scene graph precisely and unambiguously, even if there are many instances of the object. Therefore, paths are returned by both the SoRayPickAction and SoSearchAction.

When an action is applied to a path, only the nodes in the subgraph defined by the path are traversed. These include: the nodes in the path chain, all nodes (if any) below the last node in the path, and all nodes whose effects are inherited by any of these nodes.

SoPath attempts to maintain consistency of paths even when the structure of the scene graph changes. For example, removing a child from its parent when both are in a path chain cuts the path chain at that point, leaving the top part intact. Removing the node to the left of a node in a path adjusts the index for that node. Replacing a child of a node when both the parent and the child are in the chain replaces the child in the chain with the new child, truncating the path below the new child.

Note that only public children of nodes are accessible from an SoPath. Nodes like node kits that limit access to their children may provide other ways to get more information, such as by using the SoNodeKitPath class.

See Also
SoNode, SoRayPickAction, SoSearchAction, SoNodeKitPath

Definition at line 109 of file SoPath.h.

Constructor & Destructor Documentation

◆ SoPath() [1/3]

SoPath::SoPath ( )

◆ SoPath() [2/3]

SoPath::SoPath ( int  approxLength)

◆ SoPath() [3/3]

SoPath::SoPath ( SoNode node)

◆ ~SoPath()

SoPath::~SoPath ( )
protected

Member Function Documentation

◆ append() [1/3]

void SoPath::append ( const SoPath fromPath)

◆ append() [2/3]

void SoPath::append ( int  childIndex)

◆ append() [3/3]

void SoPath::append ( SoNode childNode)

If the path is empty, this is equivalent to setHead(childNode).

◆ auditPath()

void SoPath::auditPath ( bool  flag)
inlineprotected

Definition at line 251 of file SoPath.h.

◆ containsNode()

bool SoPath::containsNode ( const SoNode node) const

◆ containsPath()

bool SoPath::containsPath ( const SoPath path) const

◆ copy()

SoPath * SoPath::copy ( int  startFromNodeIndex = 0,
int  numNodes = 0 
) const

Copying starts at the given index (default is 0, which is the head node). A numNodes of 0 (the default) means copy all nodes from the starting index to the end. Returns NULL on error.

◆ findFork()

int SoPath::findFork ( const SoPath path) const

Otherwise, it returns the path chain index of the last node (starting at the head) that is the same for both paths.

◆ getByName() [1/2]

static SoPath * SoPath::getByName ( const SbName name)
static

◆ getByName() [2/2]

static int SoPath::getByName ( const SbName name,
SoPathList list 
)
static

Paths are named by calling their setName() method (defined by the SoBase class). The first form returns the last path that was given that name, either by setName() or by reading in a named path from a file. If there is no path with the given name, NULL will be returned. The second form appends all paths with the given name to the given path list and returns the number of paths that were added. If there are no paths with the given name, zero will be returned and nothing will be added to the list.

◆ getClassTypeId()

static SoType SoPath::getClassTypeId ( )
inlinestatic

Definition at line 207 of file SoPath.h.

◆ getHead()

SoNode * SoPath::getHead ( ) const
inline

Definition at line 149 of file SoPath.h.

◆ getIndex()

int SoPath::getIndex ( int  i) const
inline

Definition at line 164 of file SoPath.h.

◆ getIndexFromTail()

int SoPath::getIndexFromTail ( int  i) const
inline

Passing 0 for i returns the tail node's index.

Definition at line 169 of file SoPath.h.

◆ getLength()

int SoPath::getLength ( ) const

◆ getNode()

SoNode * SoPath::getNode ( int  i) const
inline

Calling getNode(0) is equivalent to calling getHead().

Definition at line 155 of file SoPath.h.

◆ getNodeFromTail()

SoNode * SoPath::getNodeFromTail ( int  i) const
inline

Passing 0 for i returns the tail node.

Definition at line 159 of file SoPath.h.

◆ getTail()

SoNode * SoPath::getTail ( ) const
inline

Definition at line 151 of file SoPath.h.

◆ getTypeId()

virtual SoType SoPath::getTypeId ( ) const
virtual

Implements SoBase.

◆ initClass()

static void SoPath::initClass ( )
static

◆ insertIndex()

void SoPath::insertIndex ( SoNode parent,
int  newIndex 
)

The passed index is the index of the new child

◆ isRelevantNotification()

bool SoPath::isRelevantNotification ( SoNotList list) const

It is assumed that the last (most recent) node in the list is the head node of the path.

◆ pop()

void SoPath::pop ( )
inline

Definition at line 146 of file SoPath.h.

◆ push()

void SoPath::push ( int  childIndex)
inline

Definition at line 143 of file SoPath.h.

◆ removeIndex()

void SoPath::removeIndex ( SoNode parent,
int  oldIndex 
)

The passed index is the index of the child to be removed

◆ replaceIndex()

void SoPath::replaceIndex ( SoNode parent,
int  index,
SoNode newChild 
)

The passed index is the index of the child to be removed

◆ setHead()

void SoPath::setHead ( SoNode node)

The head node must be set before the append() or push() methods may be called.

◆ truncate()

void SoPath::truncate ( int  start)

Calling truncate(0) empties the path entirely.

◆ write()

virtual void SoPath::write ( SoWriteAction writeAction) const
virtual

Friends And Related Symbol Documentation

◆ operator==

INVENTOR_API bool operator== ( const SoPath p1,
const SoPath p2 
)
friend

◆ SoAction

friend class SoAction
friend

Definition at line 281 of file SoPath.h.

◆ SoFullPath

friend class SoFullPath
friend

Definition at line 279 of file SoPath.h.

◆ SoTempPath

friend class SoTempPath
friend

Definition at line 280 of file SoPath.h.


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