Added methods getCameraManipulatorNameList() and selectCameraManipulatorByName().

This commit is contained in:
Don BURNS 2005-03-11 17:48:01 +00:00
parent e001d4ddd6
commit 21c1d64b1c
2 changed files with 36 additions and 0 deletions

View File

@ -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<std::string> &nameList );
bool selectCameraManipulatorByName( const std::string &name );
void setRecordingAnimationPath(bool on) { _recordingAnimationPath = on; }

View File

@ -880,6 +880,40 @@ void Viewer::selectCameraManipulator(unsigned int no)
if (_keyswitchManipulator.valid()) _keyswitchManipulator->selectMatrixManipulator(no);
}
void Viewer::getCameraManipulatorNameList( std::list<std::string> &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"<<std::endl;