Added asSwitch and asGeode convinience methods to Node
This commit is contained in:
parent
45160a2129
commit
6b3704ce09
@ -38,6 +38,8 @@ class OSG_EXPORT Geode : public Node
|
|||||||
|
|
||||||
META_Node(osg, Geode);
|
META_Node(osg, Geode);
|
||||||
|
|
||||||
|
virtual Geode* asGeode() { return this; }
|
||||||
|
virtual const Geode* asGeode() const { return this; }
|
||||||
|
|
||||||
/** Add a \c Drawable to the \c Geode.
|
/** Add a \c Drawable to the \c Geode.
|
||||||
* If \c drawable is not \c NULL and is not contained in the \c Geode
|
* If \c drawable is not \c NULL and is not contained in the \c Geode
|
||||||
|
@ -29,6 +29,8 @@ class NodeVisitor;
|
|||||||
class Group;
|
class Group;
|
||||||
class Transform;
|
class Transform;
|
||||||
class Node;
|
class Node;
|
||||||
|
class Switch;
|
||||||
|
class Geode;
|
||||||
|
|
||||||
/** A vector of Nodes pointers which is used to describe the path from a root node to a descendant.*/
|
/** A vector of Nodes pointers which is used to describe the path from a root node to a descendant.*/
|
||||||
typedef std::vector< Node* > NodePath;
|
typedef std::vector< Node* > NodePath;
|
||||||
@ -96,6 +98,22 @@ class OSG_EXPORT Node : public Object
|
|||||||
* Equivalent to dynamic_cast<const Transform*>(this).*/
|
* Equivalent to dynamic_cast<const Transform*>(this).*/
|
||||||
virtual const Transform* asTransform() const { return 0; }
|
virtual const Transform* asTransform() const { return 0; }
|
||||||
|
|
||||||
|
/** Convert 'this' into a Switch pointer if Node is a Switch, otherwise return 0.
|
||||||
|
* Equivalent to dynamic_cast<Switch*>(this).*/
|
||||||
|
virtual Switch* asSwitch() { return 0; }
|
||||||
|
|
||||||
|
/** convert 'const this' into a const Switch pointer if Node is a Switch, otherwise return 0.
|
||||||
|
* Equivalent to dynamic_cast<const Switch*>(this).*/
|
||||||
|
virtual const Switch* asSwitch() const { return 0; }
|
||||||
|
|
||||||
|
/** Convert 'this' into a Geode pointer if Node is a Geode, otherwise return 0.
|
||||||
|
* Equivalent to dynamic_cast<Geode*>(this).*/
|
||||||
|
virtual Geode* asGeode() { return 0; }
|
||||||
|
|
||||||
|
/** convert 'const this' into a const Geode pointer if Node is a Geode, otherwise return 0.
|
||||||
|
* Equivalent to dynamic_cast<const Geode*>(this).*/
|
||||||
|
virtual const Geode* asGeode() const { return 0; }
|
||||||
|
|
||||||
/** Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.*/
|
/** Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.*/
|
||||||
virtual void accept(NodeVisitor& nv);
|
virtual void accept(NodeVisitor& nv);
|
||||||
/** Traverse upwards : calls parents' accept method with NodeVisitor.*/
|
/** Traverse upwards : calls parents' accept method with NodeVisitor.*/
|
||||||
|
@ -33,6 +33,10 @@ class OSG_EXPORT Switch : public Group
|
|||||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||||
Switch(const Switch&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
Switch(const Switch&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||||
|
|
||||||
|
virtual Switch* asSwitch() { return this; }
|
||||||
|
virtual const Switch* asSwitch() const { return this; }
|
||||||
|
|
||||||
|
|
||||||
META_Node(osg, Switch);
|
META_Node(osg, Switch);
|
||||||
|
|
||||||
virtual void traverse(NodeVisitor& nv);
|
virtual void traverse(NodeVisitor& nv);
|
||||||
|
Loading…
Reference in New Issue
Block a user