Changeset 13041 for OpenSceneGraph/trunk/include/osgGA/EventVisitor
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgGA/EventVisitor (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgGA/EventVisitor
r9377 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 35 35 * Basic EventVisitor implementation for animating a scene. 36 36 * This visitor traverses the scene graph, calling each nodes appCallback if 37 * it exists. 37 * it exists. 38 38 */ 39 39 class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor … … 43 43 EventVisitor(); 44 44 virtual ~EventVisitor(); 45 45 46 46 META_NodeVisitor("osgGA","EventVisitor") 47 47 48 48 void setActionAdapter(osgGA::GUIActionAdapter* actionAdapter) { _actionAdapter=actionAdapter; } 49 49 50 50 osgGA::GUIActionAdapter* getActionAdapter() { return _actionAdapter; } 51 51 … … 54 54 55 55 typedef std::list< osg::ref_ptr<GUIEventAdapter> > EventList; 56 56 57 57 void addEvent(GUIEventAdapter* event); 58 58 void removeEvent(GUIEventAdapter* event); 59 59 60 60 void setEventHandled(bool handled) { _handled = handled; } 61 61 bool getEventHandled() const { return _handled; } 62 62 63 63 64 64 void setEvents(const EventQueue::Events& events) { _events = events; } 65 65 EventQueue::Events& getEvents() { return _events; } 66 66 const EventQueue::Events& getEvents() const { return _events; } 67 67 68 68 public: 69 69 70 70 virtual void reset(); 71 71 72 72 /** During traversal each type of node calls its callbacks and its children traversed. */ 73 73 virtual void apply(osg::Node& node) { handle_callbacks_and_traverse(node); } 74 74 75 75 virtual void apply(osg::Geode& node) { handle_geode_callbacks(node); } 76 76 virtual void apply(osg::Billboard& node) { handle_geode_callbacks(node); } 77 77 78 78 virtual void apply(osg::LightSource& node) { handle_callbacks_and_traverse(node); } 79 79 80 80 virtual void apply(osg::Group& node) { handle_callbacks_and_traverse(node); } 81 81 virtual void apply(osg::Transform& node) { handle_callbacks_and_traverse(node); } … … 90 90 /** Prevent unwanted copy operator.*/ 91 91 EventVisitor& operator = (const EventVisitor&) { return *this; } 92 92 93 93 inline void handle_callbacks(osg::StateSet* stateset) 94 94 { … … 114 114 osg::NodeCallback* callback = node.getEventCallback(); 115 115 if (callback) (*callback)(&node,this); 116 /*else if (node.getNumChildrenRequiringEventTraversal()>0)*/ 116 /*else if (node.getNumChildrenRequiringEventTraversal()>0)*/ 117 117 traverseGeode(node); 118 118 } 119 119 120 120 inline void traverseGeode(osg::Geode& geode) 121 121 { 122 122 traverse((osg::Node&)geode); 123 123 124 124 // Call the app callbacks on the drawables. 125 125 for(unsigned int i=0;i<geode.getNumDrawables();++i) … … 131 131 } 132 132 } 133 133 134 134 osgGA::GUIActionAdapter* _actionAdapter; 135 135 136 136 osg::ref_ptr<GUIEventAdapter> _accumulateEventState; 137 137 138 138 bool _handled; 139 139 EventQueue::Events _events; 140 140 141 141 }; 142 142
