X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=84cbda90551f8c23f60403aa6ea4cfa55bd591c9;hb=4bd5b3938f3aba070cd4a79b8e6ffd625dcdbe81;hp=533efe7bffa9180fe642f509c1a3b810331dd765;hpb=60dfa3359d9982f72d6359fede8520280bfaa6db;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 533efe7bf..84cbda905 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1139,8 +1139,14 @@ void XGUI_Workshop::moveObjects() aMgr->startOperation(aDescription.toStdString()); QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); - DocumentPtr anActiveDocument = aMgr->activeDocument(); + // It is necessary to clear selection in order to avoid selection changed event during + // moving and negative consequences connected with processing of already moved items + mySelector->clearSelection(); + // check whether the object can be moved. There should not be parts which are not loaded + if (!XGUI_Tools::canRemoveOrRename(myMainWindow, anObjects)) + return; + DocumentPtr anActiveDocument = aMgr->activeDocument(); FeaturePtr aCurrentFeature = anActiveDocument->currentFeature(true); foreach (ObjectPtr aObject, anObjects) { if (!myModule->canApplyAction(aObject, anActionId)) @@ -1280,6 +1286,32 @@ bool hasResults(QObjectPtrList theObjects, const std::set& theTypes return isFoundResultType; } +//************************************************************** +// Returns the list of all features for theDocument and all features of +// all nested parts. +std::list allFeatures(const DocumentPtr& theDocument) +{ + std::list aResultList; + std::list anAllFeatures = theDocument->allFeatures(); + foreach (const FeaturePtr& aFeature, anAllFeatures) { + // The order of appending features of the part and the part itself is important + + // Append features from a part feature + foreach (const ResultPtr& aResult, aFeature->results()) { + ResultPartPtr aResultPart = + std::dynamic_pointer_cast(aResult); + if (aResultPart.get() && aResultPart->partDoc().get()) { + // Recursion + std::list anAllFeatures = allFeatures(aResultPart->partDoc()); + aResultList.insert(aResultList.end(), anAllFeatures.begin(), anAllFeatures.end()); + } + } + + aResultList.push_back(aFeature); + } + return aResultList; +} + //************************************************************** // Returns the list of features placed between theObject and the current feature // in the same document. Excludes theObject, includes the current feature. @@ -1287,14 +1319,14 @@ std::list toCurrentFeatures(const ObjectPtr& theObject) { std::list aResult; DocumentPtr aDocument = theObject->document(); - std::list anAllFeatures = aDocument->allFeatures(); + std::list anAllFeatures = allFeatures(aDocument); // find the object iterator std::list::iterator aObjectIt = std::find(anAllFeatures.begin(), anAllFeatures.end(), theObject); - if (aObjectIt == anAllFeatures.end()) + if (aObjectIt == anAllFeatures.end()) return aResult; // find the current feature iterator std::list::iterator aCurrentIt = std::find(anAllFeatures.begin(), anAllFeatures.end(), aDocument->currentFeature(true)); - if (aCurrentIt == anAllFeatures.end()) + if (aCurrentIt == anAllFeatures.end()) return aResult; // check the right order if (std::distance(aObjectIt, anAllFeatures.end()) <= std::distance(aCurrentIt, anAllFeatures.end()))