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();
// when sketch operation is active
std::set<FeaturePtr> anIgnoredFeatures;
anIgnoredFeatures.insert(mySketchMgr->activeSketch());
- aWorkshop->deleteFeatures(aSelectedObj, anIgnoredFeatures);
+ aWorkshop->deleteFeatures(aSketchObjects, anIgnoredFeatures);
// 5. stop operation
aWorkshop->displayer()->updateViewer();
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<GeomAPI_Pln>& thePln)
{
/// 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