OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Switch.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_SWITCH
15 #define OSG_SWITCH 1
16 
17 #include <osg/Group>
18 
19 namespace osg {
20 
26 class OSG_EXPORT Switch : public Group
27 {
28  public :
29 
30 
31  Switch();
32 
34  Switch(const Switch&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
35 
36  virtual Switch* asSwitch() { return this; }
37  virtual const Switch* asSwitch() const { return this; }
38 
39 
41 
42  virtual void traverse(NodeVisitor& nv);
43 
44  void setNewChildDefaultValue(bool value) { _newChildDefaultValue = value; }
45 
46  bool getNewChildDefaultValue() const { return _newChildDefaultValue; }
47 
48  virtual bool addChild( Node *child );
49 
50  virtual bool addChild( Node *child, bool value );
51 
52  virtual bool insertChild( unsigned int index, Node *child );
53 
54  virtual bool insertChild( unsigned int index, Node *child, bool value );
55 
56  virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
57 
58 
59  void setValue(unsigned int pos,bool value);
60 
61  bool getValue(unsigned int pos) const;
62 
63  void setChildValue(const Node* child,bool value);
64 
65  bool getChildValue(const Node* child) const;
66 
69  bool setAllChildrenOff();
70 
73  bool setAllChildrenOn();
74 
76  bool setSingleChildOn(unsigned int pos);
77 
78 
79  typedef std::vector<bool> ValueList;
80 
81  void setValueList(const ValueList& values) { _values=values; }
82 
83  const ValueList& getValueList() const { return _values; }
84 
85  virtual BoundingSphere computeBound() const;
86 
87  protected :
88 
89  virtual ~Switch() {}
90 
91  // This is effectively a bit mask.
93  ValueList _values;
94 };
95 
96 }
97 
98 #endif
#define OSG_EXPORT
Definition: Export.h:43
std::vector< bool > ValueList
Definition: Switch.h:79
void setNewChildDefaultValue(bool value)
Definition: Switch.h:44
virtual const Switch * asSwitch() const
Definition: Switch.h:37
#define META_Node(library, name)
Definition: Node.h:59
ValueList _values
Definition: Switch.h:93
bool _newChildDefaultValue
Definition: Switch.h:92
void setValueList(const ValueList &values)
Definition: Switch.h:81
const ValueList & getValueList() const
Definition: Switch.h:83
virtual Switch * asSwitch()
Definition: Switch.h:36
bool getNewChildDefaultValue() const
Definition: Switch.h:46
virtual ~Switch()
Definition: Switch.h:89
Definition: Node.h:71
Definition: AlphaFunc.h:19