From da5fa4cbcdc886470f579b3868271d67fa324f88 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 1 Sep 2004 10:18:46 +0000 Subject: [PATCH] Added bool paramter to MatrixManipulator::setHomePosition(,,,bool) to allow the autocomputehomeposition to be controlled. --- include/osgGA/KeySwitchMatrixManipulator | 2 +- include/osgGA/MatrixManipulator | 13 ++++++++++--- src/osgGA/KeySwitchMatrixManipulator.cpp | 12 +++++------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/osgGA/KeySwitchMatrixManipulator b/include/osgGA/KeySwitchMatrixManipulator index b76f587e8..30ca17b5c 100644 --- a/include/osgGA/KeySwitchMatrixManipulator +++ b/include/osgGA/KeySwitchMatrixManipulator @@ -109,7 +109,7 @@ public: virtual osg::Node* getNode() { return _current->getNode(); } - virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up); + virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition=false); virtual void setAutoComputeHomePosition(bool flag); diff --git a/include/osgGA/MatrixManipulator b/include/osgGA/MatrixManipulator index 8683ecd46..a09b69f4b 100644 --- a/include/osgGA/MatrixManipulator +++ b/include/osgGA/MatrixManipulator @@ -114,24 +114,30 @@ public: /** Return node if attached.*/ virtual osg::Node* getNode() { return NULL; } - virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up) + /** Manually set the home position, and set the automatic compute of home position. */ + virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition=false) { + setAutoComputeHomePosition(autoComputeHomePosition); _homeEye = eye; _homeCenter = center; _homeUp = up; } + /** Get the mnaully set home position. */ virtual void getHomePosition(osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up) { eye = _homeEye; center = _homeCenter; up = _homeUp; } - + + /** Set whether the automatic compute of the home position is enabled.*/ virtual void setAutoComputeHomePosition(bool flag) { _autoComputeHomePosition = flag; } + /** Get whether the automatic compute of the home position is enabled.*/ bool getAutoComputeHomePosition() const { return _autoComputeHomePosition; } + /** Compute the home position.*/ virtual void computeHomePosition() { if(getNode()) @@ -140,7 +146,8 @@ public: setHomePosition(boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f), boundingSphere._center, - osg::Vec3(0.0f,0.0f,1.0f)); + osg::Vec3(0.0f,0.0f,1.0f), + _autoComputeHomePosition); } } diff --git a/src/osgGA/KeySwitchMatrixManipulator.cpp b/src/osgGA/KeySwitchMatrixManipulator.cpp index d9d644f44..cb103a9bb 100644 --- a/src/osgGA/KeySwitchMatrixManipulator.cpp +++ b/src/osgGA/KeySwitchMatrixManipulator.cpp @@ -10,8 +10,7 @@ void KeySwitchMatrixManipulator::addMatrixManipulator(int key, std::string name, _manips[key]=std::make_pair(name,osg::ref_ptr(cm)); if(!_current.valid()){ _current=cm; - _current->setAutoComputeHomePosition(_autoComputeHomePosition); - _current->setHomePosition(_homeEye,_homeCenter,_homeUp); + _current->setHomePosition(_homeEye,_homeCenter,_homeUp,_autoComputeHomePosition); _current->setNode(0); _current->setCoordinateFrameCallback(getCoordinateFrameCallback()); _current->setByMatrix(getMatrix()); @@ -36,8 +35,7 @@ void KeySwitchMatrixManipulator::selectMatrixManipulator(unsigned int num) if (itr!=_manips.end()) { - itr->second.second->setAutoComputeHomePosition(_autoComputeHomePosition); - itr->second.second->setHomePosition(_homeEye,_homeCenter,_homeUp); + itr->second.second->setHomePosition(_homeEye,_homeCenter,_homeUp,_autoComputeHomePosition); if (_current.valid()) { @@ -66,14 +64,14 @@ void KeySwitchMatrixManipulator::setNode(osg::Node* node) } } -void KeySwitchMatrixManipulator::setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up) +void KeySwitchMatrixManipulator::setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition) { - MatrixManipulator::setHomePosition(eye, center, up); + MatrixManipulator::setHomePosition(eye, center, up, autoComputeHomePosition); for(KeyManipMap::iterator itr=_manips.begin(); itr!=_manips.end(); ++itr) { - itr->second.second->setHomePosition(eye, center, up); + itr->second.second->setHomePosition(eye, center, up, autoComputeHomePosition); } }