OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MultiSwitch.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_MULTISWITCH
15 #define OSG_MULTISWITCH 1
16 
17 #include <osg/Group>
18 #include <osgSim/Export>
19 
20 namespace osgSim {
21 
26 {
27  public :
28 
29 
30  MultiSwitch();
31 
34 
36 
37  virtual void traverse(osg::NodeVisitor& nv);
38 
39  void setNewChildDefaultValue(bool value) { _newChildDefaultValue = value; }
40 
41  bool getNewChildDefaultValue() const { return _newChildDefaultValue; }
42 
43  virtual bool addChild( osg::Node *child );
44 
45  virtual bool insertChild( unsigned int index, osg::Node *child );
46 
47  virtual bool removeChild( osg::Node *child );
48 
49  void setValue(unsigned int switchSet, unsigned int pos,bool value);
50 
51  bool getValue(unsigned int switchSet, unsigned int pos) const;
52 
53  void setChildValue(const osg::Node* child,unsigned int switchSet, bool value);
54 
55  bool getChildValue(const osg::Node* child,unsigned int switchSet) const;
56 
58  bool setAllChildrenOff(unsigned int switchSet);
59 
61  bool setAllChildrenOn(unsigned int switchSet);
62 
64  bool setSingleChildOn(unsigned int switchSet, unsigned int pos);
65 
67  void setActiveSwitchSet(unsigned int switchSet) { _activeSwitchSet = switchSet; }
68 
70  unsigned int getActiveSwitchSet() const { return _activeSwitchSet; }
71 
72  typedef std::vector<bool> ValueList;
73  typedef std::vector<ValueList> SwitchSetList;
74  typedef std::vector<std::string> SwitchSetNameList;
75 
77  void setSwitchSetList(const SwitchSetList& switchSetList);
78 
80  const SwitchSetList& getSwitchSetList() const { return _values; }
81 
83  void setValueList(unsigned int switchSet, const ValueList& values);
84 
86  const ValueList& getValueList(unsigned int switchSet) const { return _values[switchSet]; }
87 
88  void setValueName(unsigned int switchSet, const std::string& name);
89 
90  const std::string& getValueName(unsigned int switchSet) const { return _valueNames[switchSet]; }
91 
92  protected :
93 
94  virtual ~MultiSwitch() {}
95 
96  void expandToEncompassSwitchSet(unsigned int switchSet);
97 
98  // this is effectively a list of bit mask.
100  unsigned int _activeSwitchSet;
101  SwitchSetList _values;
102  SwitchSetNameList _valueNames;
103 };
104 
105 }
106 
107 #endif
#define OSGSIM_EXPORT
Definition: Export.h:38
unsigned int getActiveSwitchSet() const
Definition: MultiSwitch.h:70
std::vector< std::string > SwitchSetNameList
Definition: MultiSwitch.h:74
virtual ~MultiSwitch()
Definition: MultiSwitch.h:94
std::vector< bool > ValueList
Definition: MultiSwitch.h:72
#define META_Node(library, name)
Definition: Node.h:59
const SwitchSetList & getSwitchSetList() const
Definition: MultiSwitch.h:80
const std::string & getValueName(unsigned int switchSet) const
Definition: MultiSwitch.h:90
void setActiveSwitchSet(unsigned int switchSet)
Definition: MultiSwitch.h:67
unsigned int _activeSwitchSet
Definition: MultiSwitch.h:100
void setNewChildDefaultValue(bool value)
Definition: MultiSwitch.h:39
const ValueList & getValueList(unsigned int switchSet) const
Definition: MultiSwitch.h:86
bool getNewChildDefaultValue() const
Definition: MultiSwitch.h:41
Definition: Node.h:71
SwitchSetNameList _valueNames
Definition: MultiSwitch.h:102
SwitchSetList _values
Definition: MultiSwitch.h:101
std::vector< ValueList > SwitchSetList
Definition: MultiSwitch.h:73