OpenSceneGraph 3.6.5
MultiSwitch
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
20namespace osgSim {
21
26{
27 public :
28
29
31
34
36
37 virtual void traverse(osg::NodeVisitor& nv);
38
39 void setNewChildDefaultValue(bool value) { _newChildDefaultValue = value; }
40
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;
103};
104
105}
106
107#endif
The osgSim library is a NodeKit that extends the core scene graph to support nodes and drawables that...
Definition BlinkSequence:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
General group node which maintains a list of children.
Definition Group:29
Base class for all internal nodes in the scene graph.
Definition Node:72
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
virtual bool insertChild(unsigned int index, osg::Node *child)
Insert Node to Group at specific location.
virtual bool addChild(osg::Node *child)
Add Node to Group.
unsigned int _activeSwitchSet
Definition MultiSwitch:100
bool setSingleChildOn(unsigned int switchSet, unsigned int pos)
Set a single child to be on, MultiSwitch off all other children.
void setNewChildDefaultValue(bool value)
Definition MultiSwitch:39
const ValueList & getValueList(unsigned int switchSet) const
Get the a single set of different values for a particular switch set.
Definition MultiSwitch:86
SwitchSetList _values
Definition MultiSwitch:101
virtual bool removeChild(osg::Node *child)
Remove Node from Group.
virtual void traverse(osg::NodeVisitor &nv)
Traverse downwards : calls children's accept method with NodeVisitor.
void setValueList(unsigned int switchSet, const ValueList &values)
Set the a single set of different values for a particular switch set.
SwitchSetNameList _valueNames
Definition MultiSwitch:102
void setSwitchSetList(const SwitchSetList &switchSetList)
Set the compile set of different values.
std::vector< bool > ValueList
Definition MultiSwitch:72
bool getNewChildDefaultValue() const
Definition MultiSwitch:41
bool getValue(unsigned int switchSet, unsigned int pos) const
void setActiveSwitchSet(unsigned int switchSet)
Set which of the available switch set lists to use.
Definition MultiSwitch:67
const SwitchSetList & getSwitchSetList() const
Get the compile set of different values.
Definition MultiSwitch:80
std::vector< ValueList > SwitchSetList
Definition MultiSwitch:73
std::vector< std::string > SwitchSetNameList
Definition MultiSwitch:74
void setValueName(unsigned int switchSet, const std::string &name)
bool getChildValue(const osg::Node *child, unsigned int switchSet) const
virtual ~MultiSwitch()
Definition MultiSwitch:94
void expandToEncompassSwitchSet(unsigned int switchSet)
META_Node(osgSim, MultiSwitch)
bool _newChildDefaultValue
Definition MultiSwitch:99
MultiSwitch(const MultiSwitch &, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
bool setAllChildrenOff(unsigned int switchSet)
Set all the children off (false), and set the new default child value to off (false).
unsigned int getActiveSwitchSet() const
Get which of the available switch set lists to use.
Definition MultiSwitch:70
const std::string & getValueName(unsigned int switchSet) const
Definition MultiSwitch:90
bool setAllChildrenOn(unsigned int switchSet)
Set all the children on (true), and set the new default child value to on (true).
void setValue(unsigned int switchSet, unsigned int pos, bool value)
void setChildValue(const osg::Node *child, unsigned int switchSet, bool value)
#define OSGSIM_EXPORT
Definition Export:38

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.