From c7b981f0d627761b0d3c03f6af5ada7b571df30b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 10 Apr 2009 09:56:04 +0000 Subject: [PATCH] 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) ." --- include/osgManipulator/CommandManager | 3 +++ src/osgManipulator/CommandManager.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/osgManipulator/CommandManager b/include/osgManipulator/CommandManager index 2230eeec1..898fa3a75 100644 --- a/include/osgManipulator/CommandManager +++ b/include/osgManipulator/CommandManager @@ -47,6 +47,9 @@ class OSGMANIPULATOR_EXPORT CommandManager : public osg::Referenced /** Add all selections connected to the dragger to the command. */ void addSelectionsToCommand(MotionCommand& command, Dragger& dragger); + /** Returns the selections connected to the dragger */ + std::list< osg::ref_ptr > getConnectedSelections(Dragger& dragger); + protected: virtual ~CommandManager(); diff --git a/src/osgManipulator/CommandManager.cpp b/src/osgManipulator/CommandManager.cpp index b71b271b8..45b38350a 100644 --- a/src/osgManipulator/CommandManager.cpp +++ b/src/osgManipulator/CommandManager.cpp @@ -122,3 +122,24 @@ void CommandManager::addSelectionsToCommand(MotionCommand& command, Dragger& dra } } } + + +std::list< osg::ref_ptr > CommandManager::getConnectedSelections(Dragger& dragger) +{ + std::list< osg::ref_ptr > selections = std::list< osg::ref_ptr >(); + + //Test if the dragger is in the list + if (_draggerSelectionMap.count(&dragger) > 0) + { + //Get the iterator range on key 'dragger' + std::pair 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; +}