diff --git a/include/osgGA/CameraManipulator b/include/osgGA/CameraManipulator index 74092a833..3e4d99831 100644 --- a/include/osgGA/CameraManipulator +++ b/include/osgGA/CameraManipulator @@ -143,6 +143,9 @@ class OSGGA_EXPORT CameraManipulator : public GUIEventHandler /** Compute the home position.*/ virtual void computeHomePosition(const osg::Camera *camera = NULL, bool useBoundingBox = false); + /** finish any active manipulator animations.*/ + virtual void finishAnimation() {} + /** Move the camera to the default position. May be ignored by manipulators if home functionality is not appropriate. diff --git a/include/osgGA/Event b/include/osgGA/Event index 06ad8c2cd..7ebb9bdea 100644 --- a/include/osgGA/Event +++ b/include/osgGA/Event @@ -35,6 +35,14 @@ public: virtual GUIEventAdapter* asGUIEventAdapter() { return 0; } virtual const GUIEventAdapter* asGUIEventAdapter() const { return 0; } + + /** Set whether this event has been handled by an event handler or not.*/ + void setHandled(bool handled) const { _handled = handled; } + + /** Get whether this event has been handled by an event handler or not.*/ + bool getHandled() const { return _handled; } + + /** set time in seconds of event. */ void setTime(double time) { _time = time; } @@ -44,7 +52,8 @@ public: protected: virtual ~Event() {} - double _time; + mutable bool _handled; + double _time; }; } diff --git a/include/osgGA/GUIEventAdapter b/include/osgGA/GUIEventAdapter index aa7689c88..ca3241e03 100644 --- a/include/osgGA/GUIEventAdapter +++ b/include/osgGA/GUIEventAdapter @@ -459,12 +459,6 @@ public: static osg::ref_ptr& getAccumulatedEventState(); - /** Set whether this event has been handled by an event handler or not.*/ - void setHandled(bool handled) const { _handled = handled; } - - /** Get whether this event has been handled by an event handler or not.*/ - bool getHandled() const { return _handled; } - /** set the event type. */ void setEventType(EventType Type) { _eventType = Type; } @@ -705,7 +699,6 @@ public: /** Force users to create on heap, so that multiple referencing is safe.*/ virtual ~GUIEventAdapter(); - mutable bool _handled; EventType _eventType; osg::observer_ptr _context; diff --git a/include/osgGA/KeySwitchMatrixManipulator b/include/osgGA/KeySwitchMatrixManipulator index 78367a79a..f67a5e04a 100644 --- a/include/osgGA/KeySwitchMatrixManipulator +++ b/include/osgGA/KeySwitchMatrixManipulator @@ -115,6 +115,8 @@ class OSGGA_EXPORT KeySwitchMatrixManipulator : public CameraManipulator virtual void computeHomePosition(); + virtual void finishAnimation(); + virtual void home(const GUIEventAdapter& ee,GUIActionAdapter& aa); virtual void init(const GUIEventAdapter& ee,GUIActionAdapter& aa) { if (_current.valid()) _current->init(ee,aa); } diff --git a/src/osgGA/Event.cpp b/src/osgGA/Event.cpp index 2e11326e1..55303c5c3 100644 --- a/src/osgGA/Event.cpp +++ b/src/osgGA/Event.cpp @@ -16,10 +16,12 @@ using namespace osgGA; Event::Event(): + _handled(false), _time(0.0) {} Event::Event(const Event& rhs, const osg::CopyOp& copyop): osg::Object(rhs, copyop), + _handled(rhs._handled), _time(rhs._time) {} diff --git a/src/osgGA/GUIEventAdapter.cpp b/src/osgGA/GUIEventAdapter.cpp index 6c461c501..eff04cbc3 100644 --- a/src/osgGA/GUIEventAdapter.cpp +++ b/src/osgGA/GUIEventAdapter.cpp @@ -23,7 +23,6 @@ osg::ref_ptr& GUIEventAdapter::getAccumulatedEventState() } GUIEventAdapter::GUIEventAdapter(): - _handled(false), _eventType(NONE), _windowX(0), _windowY(0), @@ -48,7 +47,6 @@ GUIEventAdapter::GUIEventAdapter(): GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs,const osg::CopyOp& copyop): osgGA::Event(rhs,copyop), - _handled(rhs._handled), _eventType(rhs._eventType), _context(rhs._context), _windowX(rhs._windowX), diff --git a/src/osgGA/KeySwitchMatrixManipulator.cpp b/src/osgGA/KeySwitchMatrixManipulator.cpp index cf08daaf3..ee11f281d 100644 --- a/src/osgGA/KeySwitchMatrixManipulator.cpp +++ b/src/osgGA/KeySwitchMatrixManipulator.cpp @@ -98,6 +98,18 @@ void KeySwitchMatrixManipulator::computeHomePosition() } } +void KeySwitchMatrixManipulator::finishAnimation() +{ + OSG_NOTICE<<"KeySwitchMatrixManipulator::finishAnimation()"<second.second->finishAnimation(); + } +} + + void KeySwitchMatrixManipulator::home(const GUIEventAdapter& ee,GUIActionAdapter& aa) { // call home for all child manipulators @@ -178,7 +190,7 @@ bool KeySwitchMatrixManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapt { CameraManipulator* selectedManipulator = it->second.second.get(); if (selectedManipulator!=_current) - { + { OSG_INFO<<"Switching to manipulator: "<second.first<getNode() ) { @@ -186,7 +198,7 @@ bool KeySwitchMatrixManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapt } selectedManipulator->setByMatrix(_current->getMatrix()); selectedManipulator->init(ea,aa); - + _current = selectedManipulator; } handled = true; diff --git a/src/osgGA/StandardManipulator.cpp b/src/osgGA/StandardManipulator.cpp index 105fb8a04..b7dfc0516 100644 --- a/src/osgGA/StandardManipulator.cpp +++ b/src/osgGA/StandardManipulator.cpp @@ -154,6 +154,8 @@ bool StandardManipulator::isAnimating() const /// Finishes the animation by performing a step that moves it to its final position. void StandardManipulator::finishAnimation() { + _thrown = false; + if( !isAnimating() ) return;