From Romain Charbit, "added a getConnectedSelections(Dragger&) method, so we can get which selections are connected to a dragger without make our own multimap, copying the existing _draggerSelectionMap (which is protected with no accessors) ."

This commit is contained in:
Robert Osfield 2009-04-10 09:56:04 +00:00
parent 95db1ec208
commit c7b981f0d6
2 changed files with 24 additions and 0 deletions

View File

@ -47,6 +47,9 @@ class OSGMANIPULATOR_EXPORT CommandManager : public osg::Referenced
/** Add all selections connected to the dragger to the command. */ /** Add all selections connected to the dragger to the command. */
void addSelectionsToCommand(MotionCommand& command, Dragger& dragger); void addSelectionsToCommand(MotionCommand& command, Dragger& dragger);
/** Returns the selections connected to the dragger */
std::list< osg::ref_ptr<Selection> > getConnectedSelections(Dragger& dragger);
protected: protected:
virtual ~CommandManager(); virtual ~CommandManager();

View File

@ -122,3 +122,24 @@ void CommandManager::addSelectionsToCommand(MotionCommand& command, Dragger& dra
} }
} }
} }
std::list< osg::ref_ptr<Selection> > CommandManager::getConnectedSelections(Dragger& dragger)
{
std::list< osg::ref_ptr<Selection> > selections = std::list< osg::ref_ptr<Selection> >();
//Test if the dragger is in the list
if (_draggerSelectionMap.count(&dragger) > 0)
{
//Get the iterator range on key 'dragger'
std::pair<DraggerSelectionMap::iterator,DraggerSelectionMap::iterator> draggerRange = _draggerSelectionMap.equal_range(&dragger);
for (DraggerSelectionMap::iterator selectionsIterator = draggerRange.first;
selectionsIterator != draggerRange.second;
++selectionsIterator)
{
//Push in the list all selections connected with the dragger
selections.push_back((*selectionsIterator).second);
}
}
return selections;
}