Improved support GUIEventHandler's being node event callbacks.

This commit is contained in:
Robert Osfield 2005-02-25 23:02:23 +00:00
parent 4fa830315d
commit ce68304f90
3 changed files with 13 additions and 10 deletions

View File

@ -72,6 +72,9 @@ public:
virtual CompositeGUIEventHandler* getComposite() { return 0; } virtual CompositeGUIEventHandler* getComposite() { return 0; }
/** Handle events, return true if handled, false otherwise. */ /** Handle events, return true if handled, false otherwise. */
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*) { return handle(ea,aa); }
/** deprecated, Handle events, return true if handled, false otherwise. */
virtual bool handle(const GUIEventAdapter&,GUIActionAdapter&) { return false; } virtual bool handle(const GUIEventAdapter&,GUIActionAdapter&) { return false; }
/** Accept visits from GUIEventHandler visitors */ /** Accept visits from GUIEventHandler visitors */
@ -98,7 +101,7 @@ public:
virtual CompositeGUIEventHandler* getComposite() { return this; } virtual CompositeGUIEventHandler* getComposite() { return this; }
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& aa); virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv);
virtual void accept(GUIEventHandlerVisitor& v) { v.visit(*this); } virtual void accept(GUIEventHandlerVisitor& v) { v.visit(*this); }

View File

@ -26,13 +26,13 @@ void GUIEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
itr != ev->getEventList().end(); itr != ev->getEventList().end();
++itr) ++itr)
{ {
handle(*(*itr), *(ev->getActionAdapter())); handle(*(*itr), *(ev->getActionAdapter()), node, nv);
} }
} }
traverse(node,nv); traverse(node,nv);
} }
void GUIEventHandler::event(osg::NodeVisitor* nv, osg::Drawable* /*drawable*/) void GUIEventHandler::event(osg::NodeVisitor* nv, osg::Drawable* drawable)
{ {
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv); osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
if (ev && ev->getActionAdapter() && !ev->getEventList().empty()) if (ev && ev->getActionAdapter() && !ev->getEventList().empty())
@ -41,7 +41,7 @@ void GUIEventHandler::event(osg::NodeVisitor* nv, osg::Drawable* /*drawable*/)
itr != ev->getEventList().end(); itr != ev->getEventList().end();
++itr) ++itr)
{ {
handle(*(*itr), *(ev->getActionAdapter())); handle(*(*itr), *(ev->getActionAdapter()), drawable, nv);
} }
} }
} }
@ -56,7 +56,7 @@ void CompositeGUIEventHandler::getUsage(osg::ApplicationUsage& usage) const
} }
} }
bool CompositeGUIEventHandler::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa) bool CompositeGUIEventHandler::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
{ {
bool result=false; bool result=false;
@ -64,7 +64,7 @@ bool CompositeGUIEventHandler::handle(const GUIEventAdapter& ea,GUIActionAdapter
itr!=_children.end(); itr!=_children.end();
++itr) ++itr)
{ {
result |= (*itr)->handle(ea,aa); result |= (*itr)->handle(ea, aa, object, nv);
} }
return result; return result;
} }

View File

@ -652,9 +652,9 @@ void Viewer::update()
handler_itr!=_eventHandlerList.end() && !handled; handler_itr!=_eventHandlerList.end() && !handled;
++handler_itr) ++handler_itr)
{ {
handled = (*handler_itr)->handle(*(*event_itr),*this); handled = (*handler_itr)->handle(*(*event_itr),*this,0,0);
} }
if (!handled && _eventVisitor.valid()) if (_eventVisitor.valid())
{ {
_eventVisitor->reset(); _eventVisitor->reset();
_eventVisitor->addEvent(event_itr->get()); _eventVisitor->addEvent(event_itr->get());
@ -854,7 +854,7 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osg::No
bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask) bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
{ {
return computeIntersections(x,y,cameraNum,getSceneData(),hits,traversalMask); return computeIntersections(x,y,cameraNum,getTopMostSceneData(),hits,traversalMask);
} }
bool Viewer::computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask) bool Viewer::computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
@ -870,7 +870,7 @@ bool Viewer::computeIntersections(float x,float y,osg::Node *node,osgUtil::Inter
bool Viewer::computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask) bool Viewer::computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
{ {
return computeIntersections(x,y,getSceneData(),hits,traversalMask); return computeIntersections(x,y,getTopMostSceneData(),hits,traversalMask);
} }
void Viewer::selectCameraManipulator(unsigned int no) void Viewer::selectCameraManipulator(unsigned int no)