From 62c955fa19a1674e50d9ab911c3f6db9841654c6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 20 Nov 2003 12:03:51 +0000 Subject: [PATCH] Added the missing insertChild(index,child) and insertChild(index,child,value) into osg::Switch. --- include/osg/Switch | 4 ++++ src/osg/Switch.cpp | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/osg/Switch b/include/osg/Switch index 55ebc8c7d..e7d18e45f 100644 --- a/include/osg/Switch +++ b/include/osg/Switch @@ -45,6 +45,10 @@ class SG_EXPORT Switch : public Group virtual bool addChild( Node *child, bool value ); + virtual bool insertChild( unsigned int index, Node *child ); + + virtual bool insertChild( unsigned int index, Node *child, bool value ); + virtual bool removeChild( Node *child ); void setValue(unsigned int pos,bool value); diff --git a/src/osg/Switch.cpp b/src/osg/Switch.cpp index d2d7a724a..036013b5d 100644 --- a/src/osg/Switch.cpp +++ b/src/osg/Switch.cpp @@ -63,6 +63,29 @@ bool Switch::addChild( Node *child, bool value ) return false; } +bool Switch::insertChild( unsigned int index, Node *child ) +{ + return insertChild(index,child,_newChildDefaultValue); +} + +bool Switch::insertChild( unsigned int index, Node *child, bool value ) +{ + if (Group::insertChild(index,child)) + { + if (index>=_values.size()) + { + _values.push_back(value); + } + else + { + _values.insert(_values.begin()+index, value); + } + + return true; + } + return false; +} + bool Switch::removeChild( Node *child ) { // find the child's position.