Change the KeySwitchMatrixManipulator so that it two sets of getMatrixManipulator

methods, two that takes an index,two that takes a key value.  Updated the ViewEventHandler
so the it now uses the getMatrixManipulatorWithIndex() method to avoid previous ambiguity.
This commit is contained in:
Robert Osfield 2005-11-14 11:00:36 +00:00
parent 5de633f71b
commit 9d8fd69fa9
4 changed files with 43 additions and 11 deletions

View File

@ -68,11 +68,17 @@ public:
const MatrixManipulator* getCurrentMatrixManipulator() const { return _current.get(); }
/** Get manipulator assigned to a specified index.*/
MatrixManipulator* getMatrixManipulatorWithIndex(unsigned int key);
/** Get const manipulator assigned to a specified index.*/
const MatrixManipulator* getMatrixManipulatorWithIndex(unsigned int key) const;
/** Get manipulator assigned to a specified key.*/
MatrixManipulator* getMatrixManipulator(unsigned int key);
MatrixManipulator* getMatrixManipulatorWithKey(unsigned int key);
/** Get const manipulator assigned to a specified key.*/
const MatrixManipulator* getMatrixManipulator(unsigned int key) const;
const MatrixManipulator* getMatrixManipulatorWithKey(unsigned int key) const;
// Overrides from MatrixManipulator...

View File

@ -118,16 +118,40 @@ void KeySwitchMatrixManipulator::setCoordinateFrameCallback(CoordinateFrameCallb
}
}
MatrixManipulator* KeySwitchMatrixManipulator::getMatrixManipulator(unsigned int num)
MatrixManipulator* KeySwitchMatrixManipulator::getMatrixManipulatorWithIndex(unsigned int index)
{
KeyManipMap::iterator itr = _manips.find(num);
unsigned i=0;
for(KeyManipMap::iterator itr = _manips.begin();
itr != _manips.end();
++itr, ++i)
{
if (i==index) return itr->second.second.get();
}
return 0;
}
const MatrixManipulator* KeySwitchMatrixManipulator::getMatrixManipulatorWithIndex(unsigned int index) const
{
unsigned i=0;
for(KeyManipMap::const_iterator itr = _manips.begin();
itr != _manips.end();
++itr, ++i)
{
if (i==index) return itr->second.second.get();
}
return 0;
}
MatrixManipulator* KeySwitchMatrixManipulator::getMatrixManipulatorWithKey(unsigned int key)
{
KeyManipMap::iterator itr = _manips.find(key);
if (itr!=_manips.end()) return itr->second.second.get();
else return 0;
}
const MatrixManipulator* KeySwitchMatrixManipulator::getMatrixManipulator(unsigned int num) const
const MatrixManipulator* KeySwitchMatrixManipulator::getMatrixManipulatorWithKey(unsigned int key) const
{
KeyManipMap::const_iterator itr = _manips.find(num);
KeyManipMap::const_iterator itr = _manips.find(key);
if (itr!=_manips.end()) return itr->second.second.get();
else return 0;
}

View File

@ -1080,9 +1080,10 @@ bool ViewerEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActio
osgGA::KeySwitchMatrixManipulator* kscm = viewer->getKeySwitchMatrixManipulator();
if (kscm)
{
for(apmNo=0;apmNo<kscm->getNumMatrixManipulators() && apm==0;++apmNo)
for(apmNo=0;apmNo<kscm->getNumMatrixManipulators();++apmNo)
{
apm = dynamic_cast<osgGA::AnimationPathManipulator*>(kscm->getMatrixManipulator(apmNo));
apm = dynamic_cast<osgGA::AnimationPathManipulator*>(kscm->getMatrixManipulatorWithIndex(apmNo));
if (apm) break;
}
}

View File

@ -43,8 +43,10 @@ BEGIN_OBJECT_REFLECTOR(osgGA::KeySwitchMatrixManipulator)
I_Method0(const osgGA::KeySwitchMatrixManipulator::KeyManipMap &, getKeyManipMap);
I_Method0(osgGA::MatrixManipulator *, getCurrentMatrixManipulator);
I_Method0(const osgGA::MatrixManipulator *, getCurrentMatrixManipulator);
I_Method1(osgGA::MatrixManipulator *, getMatrixManipulator, IN, unsigned int, key);
I_Method1(const osgGA::MatrixManipulator *, getMatrixManipulator, IN, unsigned int, key);
I_Method1(osgGA::MatrixManipulator *, getMatrixManipulatorWithIndex, IN, unsigned int, key);
I_Method1(const osgGA::MatrixManipulator *, getMatrixManipulatorWithIndex, IN, unsigned int, key);
I_Method1(osgGA::MatrixManipulator *, getMatrixManipulatorWithKey, IN, unsigned int, key);
I_Method1(const osgGA::MatrixManipulator *, getMatrixManipulatorWithKey, IN, unsigned int, key);
I_Method1(void, setMinimumDistance, IN, float, minimumDistance);
I_Method1(void, setCoordinateFrameCallback, IN, osgGA::MatrixManipulator::CoordinateFrameCallback *, cb);
I_Method1(void, setByMatrix, IN, const osg::Matrixd &, matrix);
@ -73,7 +75,6 @@ BEGIN_OBJECT_REFLECTOR(osgGA::KeySwitchMatrixManipulator)
I_ReadOnlyProperty(osg::Matrixd, InverseMatrix);
I_ReadOnlyProperty(osgGA::KeySwitchMatrixManipulator::KeyManipMap &, KeyManipMap);
I_ReadOnlyProperty(osg::Matrixd, Matrix);
I_ArrayProperty_G(osgGA::MatrixManipulator *, MatrixManipulator, MatrixManipulators, unsigned int, void);
I_WriteOnlyProperty(float, MinimumDistance);
I_Property(osg::Node *, Node);
END_REFLECTOR