From 534d572ea8a684ad663a52261cd35bf983f29adf Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 13 Aug 2019 12:13:47 +0300 Subject: [PATCH] =?utf8?q?Task=203.6:=20=E2=80=9CMove=20to=20the=20end?= =?utf8?q?=E2=80=9D=20when=20several=20Group=20features=20are=20selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/XGUI/XGUI_ContextMenuMgr.cpp | 4 +++- src/XGUI/XGUI_Workshop.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index a24747d5c..b1fadf671 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -347,6 +347,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHADING_CMD")->setEnabled(true); action("WIREFRAME_CMD")->setEnabled(true); } + if (hasFeature && myWorkshop->canMoveFeature()) + action("MOVE_CMD")->setEnabled(true); } // end multi-selection // Check folder management commands state if only features are selected @@ -765,7 +767,7 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const aActions.append(action("ADD_OUT_FOLDER_BEFORE_CMD")); aActions.append(action("ADD_OUT_FOLDER_AFTER_CMD")); aActions.append(mySeparator3); - //aActions.append(action("MOVE_CMD")); + aActions.append(action("MOVE_CMD")); aActions.append(action("COLOR_CMD")); aActions.append(action("DEFLECTION_CMD")); aActions.append(action("TRANSPARENCY_CMD")); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index d10ccc612..deddb444f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -2011,6 +2011,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()) @@ -2032,9 +2036,13 @@ void XGUI_Workshop::moveObjects() if (!XGUI_Tools::canRemoveOrRename(desktop(), aFeatures)) return; + // Sort features by index in document + std::list aFList(aFeatures.begin(), aFeatures.end()); + aFList.sort(compareFeature); + DocumentPtr anActiveDocument = aMgr->activeDocument(); FeaturePtr aCurrentFeature = anActiveDocument->currentFeature(true); - std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + std::list::const_iterator anIt = aFList.begin(), aLast = aFList.end(); for (; anIt != aLast; anIt++) { FeaturePtr aFeature = *anIt; if (!aFeature.get() || !myModule->canApplyAction(aFeature, anActionId)) -- 2.39.2