Updated the Switch, Sequence and Group classes so that they all used a

similar style removeChild() mechansim.

Made the old style osg::Switch::setValue() method deprecated.
This commit is contained in:
Robert Osfield
2002-12-07 21:18:12 +00:00
parent b63827c5d9
commit 109f6f22fe
11 changed files with 292 additions and 226 deletions

View File

@@ -36,9 +36,11 @@ class SG_EXPORT Geode : public Node
/** Remove Drawable from Geode.
* Equivalent to setDrawabke(getDrawableIndex(orignChild),node),
* see docs for setNode for futher details on implementation.*/
virtual bool removeDrawable( Drawable *drawable );
/** Remove drawable(s) from the specified position in Geode's drawable list.*/
virtual bool removeDrawable(unsigned int i,unsigned int numDrawablesToRemove=1);
/** Replace specified Drawable with another Drawable.
* Equivalent to setDrawable(getDrawableIndex(orignChild),node),
* see docs for setDrawable for futher details on implementation.*/
@@ -77,36 +79,6 @@ class SG_EXPORT Geode : public Node
return false;
}
/** return the iterator position for specified Drawable.
* return _drawables.end() if gset not is contained in Geode.
*/
inline DrawableList::iterator findDrawable(const Drawable* gset)
{
for (DrawableList::iterator itr=_drawables.begin();
itr!=_drawables.end();
++itr)
{
if (itr->get()==gset) return itr;
}
return _drawables.end();
}
/** return the const_iterator position for specified Drawable.
* return _drawables.end() if gset not is contained in Geode.
*/
inline DrawableList::const_iterator findDrawable(const Drawable* gset) const
{
for (DrawableList::const_iterator itr=_drawables.begin();
itr!=_drawables.end();
++itr)
{
if (itr->get()==gset) return itr;
}
return _drawables.end();
}
/** Get the index number of drawable, return a value between
* 0 and _drawables.size()-1 if found, if not found then
* return _drawables.size().*/

View File

@@ -128,16 +128,16 @@ class SG_EXPORT Geometry : public Drawable
PrimitiveSet* getPrimitiveSet(unsigned int pos) { return _primitives[pos].get(); }
const PrimitiveSet* getPrimitiveSet(unsigned int pos) const { return _primitives[pos].get(); }
/** Add a primtive set to the geometry.*/
/** Add a primitive set to the geometry.*/
bool addPrimitiveSet(PrimitiveSet* primitiveset);
/** Set a primtive set to the specified position in geometry's primtive set list.*/
/** Set a primitive set to the specified position in geometry's primitive set list.*/
bool setPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset);
/** Insert a primtive set to the specified position in geometry's primtive set list.*/
/** Insert a primitive set to the specified position in geometry's primitive set list.*/
bool insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset);
/** Remove primtive set(s) from the specified position in geometry's primtive set list.*/
/** Remove primitive set(s) from the specified position in geometry's primitive set list.*/
bool removePrimitiveSet(unsigned int i,unsigned int numElementsToRemove=1);
/** Get the index number of a primitive set, return a value between
@@ -148,7 +148,7 @@ class SG_EXPORT Geometry : public Drawable
/** return true if OpenGL fast paths will be used with drawing this Geometry.
* Fast paths use vertex arrays, and glDrawArrays/glDrawElements. Slow paths
* use glBegin()/glVertex.../glEnd(). Use of per primtive bindings or per vertex indexed
* use glBegin()/glVertex.../glEnd(). Use of per primitive bindings or per vertex indexed
* arrays will drop the rendering path off the fast path.*/
bool areFastPathsUsed() const;
@@ -178,7 +178,7 @@ class SG_EXPORT Geometry : public Drawable
/** return true, osg::Geometry does support accept(PrimitiveFunctor&) .*/
virtual bool supports(PrimitiveFunctor&) const { return true; }
/** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
/** accept a PrimitiveFunctor and call its methods to tell it about the interal primitives that this Drawable has.*/
virtual void accept(PrimitiveFunctor& pf) const;
protected:

View File

@@ -49,6 +49,8 @@ class SG_EXPORT Group : public Node
*/
virtual bool removeChild( Node *child );
virtual bool removeChild(unsigned int pos,unsigned int numChildrenToRemove=1);
/** Replace specified Node with another Node.
* Equivalent to setChild(getChildIndex(orignChild),node),
* see docs for setChild for futher details on implementation.*/
@@ -87,35 +89,6 @@ class SG_EXPORT Group : public Node
return false;
}
/** return the iterator position for specified Node.
* return _children.end() if node is not contained in Group.
*/
inline ChildList::iterator findNode( const Node* node )
{
for (ChildList::iterator itr=_children.begin();
itr!=_children.end();
++itr)
{
if (itr->get()==node) return itr;
}
return _children.end();
}
/** return the const_iterator position for specified Node.
* return _children.end() if node is not contained in Group.
*/
inline ChildList::const_iterator findNode( const Node* node ) const
{
for (ChildList::const_iterator itr=_children.begin();
itr!=_children.end();
++itr)
{
if (itr->get()==node) return itr;
}
return _children.end();
}
/** Get the index number of child, return a value between
* 0 and _children.size()-1 if found, if not found then
* return _children.size().*/

View File

@@ -14,7 +14,7 @@ namespace osg {
/** Sequence is a Group node which allows automatic, time based
switching between children.
*/
class SG_EXPORT Sequence : public Switch
class SG_EXPORT Sequence : public Group
{
public :
@@ -26,6 +26,10 @@ public :
META_Node(osg, Sequence);
virtual void traverse(NodeVisitor& nv);
void setValue(int value) { _value = value; }
int getValue() const { return _value; }
/** Set time in seconds for child */
void setTime(int frame, float t);
@@ -80,6 +84,8 @@ protected :
virtual ~Sequence() {}
int _value;
float _last;
std::vector<float> _frameTime;

View File

@@ -40,12 +40,22 @@ class SG_EXPORT Switch : public Group
void setValue(unsigned int pos,bool value);
void setValue(const Node* child,bool value);
bool getValue(unsigned int pos) const;
bool getValue(const Node* child) const;
void setChildValue(const Node* child,bool value);
bool getChildValue(const Node* child) const;
/** Set all the children off (false), and set the new default child value to off (false).*/
bool setAllChildrenOff();
/** Set all the children on (true), and set the new default child value to on (true).*/
bool setAllChildrenOn();
/** Set a single child to be on, switch off all other children.*/
bool setSingleChildOn(unsigned int pos);
#ifdef USE_DEPRECTATED_API
/**
* Special values for the Switch. Use these if you want to
* turn on/off all child nodes.
@@ -69,6 +79,8 @@ class SG_EXPORT Switch : public Group
void setValue(int value);
int getValue() const;
#endif
typedef std::vector<bool> ValueList;