From: nds Date: Wed, 15 Apr 2015 17:54:48 +0000 (+0300) Subject: "Delete" in sketch operation active should not delete objects from other sketches. X-Git-Tag: V_1.1.0~23^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=31379b80748394ea42c8e9761cb4b3eb63af8a6d;p=modules%2Fshaper.git "Delete" in sketch operation active should not delete objects from other sketches. Undo/Redo does not work correctly after this delete. The objects from another sketch are visualized as objects of the current sketch. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a38f41b65..33df27091 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -485,6 +485,20 @@ bool PartSet_Module::deleteObjects() if (aSelectedObj.count() == 0) return false; + // avoid delete of the objects, which are not belong to the current sketch + // in order to do not delete results of other sketches + QObjectPtrList aSketchObjects; + QObjectPtrList::const_iterator anIt = aSelectedObj.begin(), aLast = aSelectedObj.end(); + for ( ; anIt != aLast; anIt++) { + ObjectPtr anObject = *anIt; + if (mySketchMgr->isObjectOfSketch(anObject)) + aSketchObjects.append(anObject); + } + // if the selection contains only local selected presentations from other sketches, + // the Delete operation should not be done at all + if (aSketchObjects.size() == 0) + return true; + // the active nested sketch operation should be aborted unconditionally if (isNestedOp) anOperation->abort(); @@ -499,7 +513,7 @@ bool PartSet_Module::deleteObjects() // when sketch operation is active std::set anIgnoredFeatures; anIgnoredFeatures.insert(mySketchMgr->activeSketch()); - aWorkshop->deleteFeatures(aSelectedObj, anIgnoredFeatures); + aWorkshop->deleteFeatures(aSketchObjects, anIgnoredFeatures); // 5. stop operation aWorkshop->displayer()->updateViewer(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 2ed91dd5e..cb1250a76 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -851,6 +851,20 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const return aCanDisplay; } +bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const +{ + bool isFoundObject = false; + + FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject); + if (anObjectFeature.get()) { + int aSize = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) { + FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i); + isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature; + } + } + return isFoundObject; +} void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& thePln) { diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index ef2bf9c48..e1762376b 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -142,6 +142,11 @@ public: /// Returns state of constraints showing flag bool isConstraintsShown() const { return myIsConstraintsShown; } + /// Returns true if the object is a current sketch sub feature of a result of the feature + /// \param theObject an object + /// \return boolean value + bool isObjectOfSketch(const ObjectPtr& theObject) const; + /// Saves the current selection in the viewer into an internal container /// It obtains the selected attributes. The highlighted objects can be processes as the selected ones /// \param theHighlightedUse a boolean flag