]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/XGUI/XGUI_Workshop.cpp
Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into CEA_2019
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index df5c48cb13c153a11760d59bac5b59329ef848f6..d5e5bf833fefc51da14c82b6e8e3083e6d626c9c 100644 (file)
@@ -2017,6 +2017,10 @@ void XGUI_Workshop::cleanHistory()
 }
 
 //**************************************************************
+bool compareFeature(const FeaturePtr& theF1, const FeaturePtr& theF2) {
+  DocumentPtr aDoc = theF1->document();
+  return aDoc->index(theF1) < aDoc->index(theF2);
+}
 void XGUI_Workshop::moveObjects()
 {
   if (!abortAllOperations())
@@ -2038,9 +2042,13 @@ void XGUI_Workshop::moveObjects()
   if (!XGUI_Tools::canRemoveOrRename(desktop(), aFeatures))
     return;
 
+  // Sort features by index in document
+  std::list<FeaturePtr> aFList(aFeatures.begin(), aFeatures.end());
+  aFList.sort(compareFeature);
+
   DocumentPtr anActiveDocument = aMgr->activeDocument();
   FeaturePtr aCurrentFeature = anActiveDocument->currentFeature(true);
-  std::set<FeaturePtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+  std::list<FeaturePtr>::const_iterator anIt = aFList.begin(), aLast = aFList.end();
   for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = *anIt;
     if (!aFeature.get() || !myModule->canApplyAction(aFeature, anActionId))