From 21c1d64b1cf81d7db2f3a36effaa949e54e8d86b Mon Sep 17 00:00:00 2001 From: Don BURNS Date: Fri, 11 Mar 2005 17:48:01 +0000 Subject: [PATCH] Added methods getCameraManipulatorNameList() and selectCameraManipulatorByName(). --- include/osgProducer/Viewer | 2 ++ src/osgProducer/Viewer.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/osgProducer/Viewer b/include/osgProducer/Viewer index 29beea82b..0b06ca34b 100644 --- a/include/osgProducer/Viewer +++ b/include/osgProducer/Viewer @@ -274,6 +274,8 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction unsigned int addCameraManipulator(osgGA::MatrixManipulator* cm); void selectCameraManipulator(unsigned int no); + void getCameraManipulatorNameList( std::list &nameList ); + bool selectCameraManipulatorByName( const std::string &name ); void setRecordingAnimationPath(bool on) { _recordingAnimationPath = on; } diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 1e40aa6c6..6cc0442eb 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -880,6 +880,40 @@ void Viewer::selectCameraManipulator(unsigned int no) if (_keyswitchManipulator.valid()) _keyswitchManipulator->selectMatrixManipulator(no); } +void Viewer::getCameraManipulatorNameList( std::list &nameList ) +{ + osgGA::KeySwitchMatrixManipulator *ksm = getKeySwitchMatrixManipulator(); + osgGA::KeySwitchMatrixManipulator::KeyManipMap &kmmap = ksm->getKeyManipMap(); + osgGA::KeySwitchMatrixManipulator::KeyManipMap::iterator p; + for( p = kmmap.begin(); p != kmmap.end(); p++ ) + { + osgGA::KeySwitchMatrixManipulator::NamedManipulator nm = (*p).second; + nameList.push_back( nm.first ); + } +} + +bool Viewer::selectCameraManipulatorByName( const std::string &name ) +{ + unsigned int num = 0xFFFF; + osgGA::KeySwitchMatrixManipulator *ksm = getKeySwitchMatrixManipulator(); + osgGA::KeySwitchMatrixManipulator::KeyManipMap &kmmap = ksm->getKeyManipMap(); + osgGA::KeySwitchMatrixManipulator::KeyManipMap::iterator p; + for( p = kmmap.begin(); p != kmmap.end(); p++ ) + { + int key = (*p).first; + osgGA::KeySwitchMatrixManipulator::NamedManipulator nm = (*p).second; + if( nm.first == name ) + num = key - '1'; + } + + if( num == 0xFFFF ) + return false; + + selectCameraManipulator(num); + return true; +} + + void Viewer::requestRedraw() { //osg::notify(osg::INFO)<<"Viewer::requestRedraw() called"<