Skip to content

Commit

Permalink
+ Make sure to keep order of selected objects in getSelectionEx()
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 12, 2013
1 parent 782cae1 commit c020bab
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/Gui/Selection.cpp
Expand Up @@ -337,25 +337,9 @@ bool SelectionSingleton::hasSelection(const char* doc) const
return false;
}

//std::vector<SelectionObject> SelectionSingleton::getSelectionEx(const char* pDocName) const
//{
// return getSelectionEx(pDocName,App::DocumentObject::getClassTypeId());
//}
//
//std::vector<SelectionObject> SelectionSingleton::getSelectionEx(const char* pDocName,const char* typeName) const
//{
// // search the type
// Base::Type typeId;
// if(typeName)
// typeId = Base::Type::fromName(typeName);
// else
// typeId = App::DocumentObject::getClassTypeId();
// return getSelectionEx(pDocName,typeId);
//}
std::vector<SelectionObject> SelectionSingleton::getSelectionEx(const char* pDocName, Base::Type typeId) const
{
std::vector<SelectionObject> temp;

std::map<App::DocumentObject*,SelectionObject> SortMap;

// check the type
Expand Down Expand Up @@ -398,8 +382,14 @@ std::vector<SelectionObject> SelectionSingleton::getSelectionEx(const char* pDoc
}
}

for (std::map<App::DocumentObject*,SelectionObject>::const_iterator It = SortMap.begin();It != SortMap.end();++It)
temp.push_back(It->second);
// The map looses the order thus we have to go again through the list and pick up the SelectionObject from the map
for (std::list<_SelObj>::const_iterator It = _SelList.begin();It != _SelList.end();++It) {
std::map<App::DocumentObject*,SelectionObject>::iterator Jt = SortMap.find(It->pObject);
if (Jt != SortMap.end()) {
temp.push_back(Jt->second);
SortMap.erase(Jt);
}
}

return temp;
}
Expand Down

0 comments on commit c020bab

Please sign in to comment.