root/OpenSceneGraph/trunk/include/osg/Switch @ 13041

Revision 13041, 2.9 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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
19namespace osg {
20
21/** Switch is a Group node that allows switching between children.
22  * Typical uses would be for objects which might need to be rendered
23  * differently at different times, for instance a switch could be used
24  * to represent the different states of a traffic light.
25*/
26class OSG_EXPORT Switch : public Group
27{
28    public :
29
30
31        Switch();
32
33        /** Copy constructor using CopyOp to manage deep vs shallow copy. */
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
40        META_Node(osg, Switch);
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
67        /** Set all the children off (false), and set the new default child
68          * value to off (false). */
69        bool setAllChildrenOff();
70
71        /** Set all the children on (true), and set the new default child
72          * value to on (true). */
73        bool setAllChildrenOn();
74
75        /** Set a single child on, switch off all other children. */
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.
92        bool        _newChildDefaultValue;
93        ValueList   _values;
94};
95
96}
97
98#endif
Note: See TracBrowser for help on using the browser.