From: vsv Date: Fri, 24 Nov 2017 15:08:54 +0000 (+0300) Subject: Insert feature to a folder command call X-Git-Tag: V_2.10.0RC~123^2~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=522de85838d486d65b81e8a96333b37dd47916e0;p=modules%2Fshaper.git Insert feature to a folder command call --- diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 387df6660..7556e1042 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1416,9 +1416,9 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) } else if (theId == "INSERT_FOLDER_CMD") { insertFeatureFolder(); } else if (theId == "ADD_TO_FOLDER_BEFORE_CMD") { - insertToFolderBefore(); + insertToFolder(true); } else if (theId == "ADD_TO_FOLDER_AFTER_CMD") { - insertToFolderAfter(); + insertToFolder(false); } else if (theId == "SELECT_RESULT_CMD") { //setViewerSelectionMode(-1); //IMP: an attempt to use result selection with other selection modes @@ -2448,16 +2448,31 @@ void XGUI_Workshop::insertFeatureFolder() aMgr->finishOperation(); } -void XGUI_Workshop::insertToFolderBefore() + +void XGUI_Workshop::insertToFolder(bool isBefore) { QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); if (aObjects.isEmpty()) return; -} -void XGUI_Workshop::insertToFolderAfter() -{ - QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); - if (aObjects.isEmpty()) + std::list aFeatures; + foreach(ObjectPtr aObj, aObjects) { + FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); + if (aFeature.get()) + aFeatures.push_back(aFeature); + } + if (aFeatures.empty()) + return; + + SessionPtr aMgr = ModelAPI_Session::get(); + DocumentPtr aDoc = aMgr->activeDocument(); + + FolderPtr aFolder = isBefore? aDoc->findFolderAbove(aFeatures): + aDoc->findFolderBelow(aFeatures); + if (!aFolder.get()) return; + + aMgr->startOperation(); + aDoc->moveToFolder(aFeatures, aFolder); + aMgr->finishOperation(); } diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 5b6f3bb5a..b5d181f2e 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -451,11 +451,8 @@ private: /// Insert folder object before currently selected feature void insertFeatureFolder(); - /// Insert an object to a folder above - void insertToFolderBefore(); - - /// Insert an object to a folder below - void insertToFolderAfter(); + /// Insert an object to a folder above or below + void insertToFolder(bool isBefore); private slots: /// SLOT, that is called after the operation is started. Update workshop state according to