MultiSwitch
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_MULTISWITCH
#define OSG_MULTISWITCH 1
#include <osg/Group>
#include <osgSim/Export>
namespace osgSim {
class OSGSIM_EXPORT MultiSwitch : public osg::Group
{
public :
MultiSwitch();
MultiSwitch(const MultiSwitch&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Node(osgSim, MultiSwitch);
virtual void traverse(osg::NodeVisitor& nv);
void setNewChildDefaultValue(bool value) { _newChildDefaultValue = value; }
bool getNewChildDefaultValue() const { return _newChildDefaultValue; }
virtual bool addChild( osg::Node *child );
virtual bool insertChild( unsigned int index, osg::Node *child );
virtual bool removeChild( osg::Node *child );
void setValue(unsigned int switchSet, unsigned int pos,bool value);
bool getValue(unsigned int switchSet, unsigned int pos) const;
void setChildValue(const osg::Node* child,unsigned int switchSet, bool value);
bool getChildValue(const osg::Node* child,unsigned int switchSet) const;
bool setAllChildrenOff(unsigned int switchSet);
bool setAllChildrenOn(unsigned int switchSet);
bool setSingleChildOn(unsigned int switchSet, unsigned int pos);
void setActiveSwitchSet(unsigned int switchSet) { _activeSwitchSet = switchSet; }
unsigned int getActiveSwitchSet() const { return _activeSwitchSet; }
typedef std::vector<bool> ValueList;
typedef std::vector<ValueList> SwitchSetList;
typedef std::vector<std::string> SwitchSetNameList;
void setSwitchSetList(const SwitchSetList& switchSetList);
const SwitchSetList& getSwitchSetList() const { return _values; }
void setValueList(unsigned int switchSet, const ValueList& values);
const ValueList& getValueList(unsigned int switchSet) const { return _values[switchSet]; }
void setValueName(unsigned int switchSet, const std::string& name);
const std::string& getValueName(unsigned int switchSet) const { return _valueNames[switchSet]; }
protected :
virtual ~MultiSwitch() {}
void expandToEncompassSwitchSet(unsigned int switchSet);
// this is effectively a list of bit mask.
bool _newChildDefaultValue;
unsigned int _activeSwitchSet;
SwitchSetList _values;
SwitchSetNameList _valueNames;
};
}
#endif
Group
osgSim::MultiSwitch::insertChild
virtual bool insertChild(unsigned int index, osg::Node *child)
osgSim::MultiSwitch::addChild
virtual bool addChild(osg::Node *child)
osgSim::MultiSwitch::_activeSwitchSet
unsigned int _activeSwitchSet
Definition MultiSwitch:100
osgSim::MultiSwitch::setSingleChildOn
bool setSingleChildOn(unsigned int switchSet, unsigned int pos)
osgSim::MultiSwitch::setNewChildDefaultValue
void setNewChildDefaultValue(bool value)
Definition MultiSwitch:39
osgSim::MultiSwitch::getValueList
const ValueList & getValueList(unsigned int switchSet) const
Definition MultiSwitch:86
osgSim::MultiSwitch::_values
SwitchSetList _values
Definition MultiSwitch:101
osgSim::MultiSwitch::removeChild
virtual bool removeChild(osg::Node *child)
osgSim::MultiSwitch::traverse
virtual void traverse(osg::NodeVisitor &nv)
osgSim::MultiSwitch::setValueList
void setValueList(unsigned int switchSet, const ValueList &values)
osgSim::MultiSwitch::_valueNames
SwitchSetNameList _valueNames
Definition MultiSwitch:102
osgSim::MultiSwitch::setSwitchSetList
void setSwitchSetList(const SwitchSetList &switchSetList)
osgSim::MultiSwitch::ValueList
std::vector< bool > ValueList
Definition MultiSwitch:72
osgSim::MultiSwitch::getNewChildDefaultValue
bool getNewChildDefaultValue() const
Definition MultiSwitch:41
osgSim::MultiSwitch::getValue
bool getValue(unsigned int switchSet, unsigned int pos) const
osgSim::MultiSwitch::setActiveSwitchSet
void setActiveSwitchSet(unsigned int switchSet)
Definition MultiSwitch:67
osgSim::MultiSwitch::getSwitchSetList
const SwitchSetList & getSwitchSetList() const
Definition MultiSwitch:80
osgSim::MultiSwitch::SwitchSetList
std::vector< ValueList > SwitchSetList
Definition MultiSwitch:73
osgSim::MultiSwitch::SwitchSetNameList
std::vector< std::string > SwitchSetNameList
Definition MultiSwitch:74
osgSim::MultiSwitch::setValueName
void setValueName(unsigned int switchSet, const std::string &name)
osgSim::MultiSwitch::getChildValue
bool getChildValue(const osg::Node *child, unsigned int switchSet) const
osgSim::MultiSwitch::~MultiSwitch
virtual ~MultiSwitch()
Definition MultiSwitch:94
osgSim::MultiSwitch::expandToEncompassSwitchSet
void expandToEncompassSwitchSet(unsigned int switchSet)
osgSim::MultiSwitch::META_Node
META_Node(osgSim, MultiSwitch)
osgSim::MultiSwitch::_newChildDefaultValue
bool _newChildDefaultValue
Definition MultiSwitch:99
osgSim::MultiSwitch::MultiSwitch
MultiSwitch(const MultiSwitch &, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgSim::MultiSwitch::setAllChildrenOff
bool setAllChildrenOff(unsigned int switchSet)
osgSim::MultiSwitch::getActiveSwitchSet
unsigned int getActiveSwitchSet() const
Definition MultiSwitch:70
osgSim::MultiSwitch::getValueName
const std::string & getValueName(unsigned int switchSet) const
Definition MultiSwitch:90
osgSim::MultiSwitch::MultiSwitch
MultiSwitch()
osgSim::MultiSwitch::setAllChildrenOn
bool setAllChildrenOn(unsigned int switchSet)
osgSim::MultiSwitch::setValue
void setValue(unsigned int switchSet, unsigned int pos, bool value)
osgSim::MultiSwitch::setChildValue
void setChildValue(const osg::Node *child, unsigned int switchSet, bool value)
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Group
Definition Group:29
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node
Definition Node:72
osgSim
Definition BlinkSequence:27
Export
OSGSIM_EXPORT
#define OSGSIM_EXPORT
Definition osgSim/Export:38