Group
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_GROUP
#define OSG_GROUP 1
#include <osg/Node>
#include <osg/NodeVisitor>
namespace osg {
typedef std::vector< ref_ptr<Node> > NodeList;
class OSG_EXPORT Group : public Node
{
public :
Group();
Group(const Group&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Node(osg, Group);
virtual Group* asGroup() { return this; }
virtual const Group* asGroup() const { return this; }
virtual void traverse(NodeVisitor& nv);
virtual bool addChild( Node *child );
template<class T> bool addChild( const ref_ptr<T>& child ) { return addChild(child.get()); }
virtual bool insertChild( unsigned int index, Node *child );
template<class T> bool insertChild( unsigned int index, const ref_ptr<T>& child ) { return insertChild(index, child.get()); }
virtual bool removeChild( Node *child );
template<class T> bool removeChild( const ref_ptr<T>& child ) { return removeChild(child.get()); }
inline bool removeChild( unsigned int pos, unsigned int numChildrenToRemove=1 )
{
if (pos<_children.size()) return removeChildren(pos,numChildrenToRemove);
else return false;
}
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
virtual bool replaceChild( Node *origChild, Node* newChild );
template<class T, class R> bool replaceChild( const ref_ptr<T>& origChild, const ref_ptr<R>& newChild ) { return replaceChild( origChild.get(), newChild.get()); }
virtual unsigned int getNumChildren() const;
virtual bool setChild( unsigned int i, Node* node );
inline Node* getChild( unsigned int i ) { return _children[i].get(); }
inline const Node* getChild( unsigned int i ) const { return _children[i].get(); }
inline bool containsNode( const Node* node ) const
{
for (NodeList::const_iterator itr=_children.begin();
itr!=_children.end();
++itr)
{
if (itr->get()==node) return true;
}
return false;
}
template<class T> bool containsNode(const ref_ptr<T>& node) const { return containsNode(node.get()); }
inline unsigned int getChildIndex( const Node* node ) const
{
for (unsigned int childNum=0;childNum<_children.size();++childNum)
{
if (_children[childNum]==node) return childNum;
}
return static_cast<unsigned int>(_children.size()); // node not found.
}
virtual void setThreadSafeRefUnref(bool threadSafe);
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
virtual BoundingSphere computeBound() const;
protected:
virtual ~Group();
virtual void childRemoved(unsigned int /*pos*/, unsigned int /*numChildrenToRemove*/) {}
virtual void childInserted(unsigned int /*pos*/) {}
NodeList _children;
};
}
#endif
NodeVisitor
Node
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Group::computeBound
virtual BoundingSphere computeBound() const
osg::Group::childInserted
virtual void childInserted(unsigned int)
Definition Group:168
osg::Group::getChild
Node * getChild(unsigned int i)
Definition Group:117
osg::Group::childRemoved
virtual void childRemoved(unsigned int, unsigned int)
Definition Group:167
osg::Group::traverse
virtual void traverse(NodeVisitor &nv)
osg::Group::asGroup
virtual const Group * asGroup() const
Definition Group:41
osg::Group::removeChildren
virtual bool removeChildren(unsigned int pos, unsigned int numChildrenToRemove)
osg::Group::removeChild
bool removeChild(const ref_ptr< T > &child)
Definition Group:74
osg::Group::setChild
virtual bool setChild(unsigned int i, Node *node)
osg::Group::replaceChild
virtual bool replaceChild(Node *origChild, Node *newChild)
osg::Group::META_Node
META_Node(osg, Group)
osg::Group::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osg::Group::getNumChildren
virtual unsigned int getNumChildren() const
osg::Group::insertChild
bool insertChild(unsigned int index, const ref_ptr< T > &child)
Definition Group:62
osg::Group::getChild
const Node * getChild(unsigned int i) const
Definition Group:120
osg::Group::Group
Group(const Group &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::Group::setThreadSafeRefUnref
virtual void setThreadSafeRefUnref(bool threadSafe)
osg::Group::~Group
virtual ~Group()
osg::Group::insertChild
virtual bool insertChild(unsigned int index, Node *child)
osg::Group::replaceChild
bool replaceChild(const ref_ptr< T > &origChild, const ref_ptr< R > &newChild)
Definition Group:100
osg::Group::addChild
virtual bool addChild(Node *child)
osg::Group::removeChild
bool removeChild(unsigned int pos, unsigned int numChildrenToRemove=1)
Definition Group:84
osg::Group::asGroup
virtual Group * asGroup()
Definition Group:40
osg::Group::getChildIndex
unsigned int getChildIndex(const Node *node) const
Definition Group:141
osg::Group::Group
Group()
osg::Group::containsNode
bool containsNode(const ref_ptr< T > &node) const
Definition Group:135
osg::Group::_children
NodeList _children
Definition Group:170
osg::Group::removeChild
virtual bool removeChild(Node *child)
osg::Group::releaseGLObjects
virtual void releaseGLObjects(osg::State *=0) const
osg::Group::containsNode
bool containsNode(const Node *node) const
Definition Group:123
osg::Group::addChild
bool addChild(const ref_ptr< T > &child)
Definition Group:53
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node::Node
Node()
osg::State
Definition State:80
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osg
Definition AlphaFunc:19
osg::NodeList
std::vector< ref_ptr< Node > > NodeList
Definition Group:22
osg::BoundingSphere
BoundingSphered BoundingSphere
Definition BoundingSphere:314
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39