Salome HOME
Issue #1708: Export - Apply is enabled when no objects is selected
[modules/shaper.git] / src / PartSet / PartSet_ExternalObjectsMgr.cpp
index 54608476b671021210654dc4ff9ca73fe3a3b1fc..c636f5b3bfd019bd861be5616dff6ed49de9d399 100755 (executable)
@@ -47,6 +47,16 @@ ObjectPtr PartSet_ExternalObjectsMgr::externalObject(const ObjectPtr& theSelecte
 {
   ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(
                                   theShape->impl<TopoDS_Shape>(), theSelectedObject, theSketch);
+  FeaturePtr aFeature = ModelAPI_Feature::feature(aSelectedObject);
+  if (aFeature.get()) {
+    std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+                            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+    /// some sketch entities should be never shown, e.g. projection feature
+    /// such external features should not be used in selection
+    if (aSketchFeature.get() && !aSketchFeature->canBeDisplayed())
+      return ObjectPtr();
+  }
+
   if (!aSelectedObject.get()) {
     // Processing of external (non-sketch) object
     aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
@@ -78,14 +88,8 @@ void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject
     if (aFeature.get() != NULL) {
       QObjectPtrList anObjects;
       anObjects.append(aFeature);
-      // the external feature should be removed with all references, sketch feature should be ignored
-      std::set<FeaturePtr> anIgnoredFeatures;
-      // the current feature should be ignored, because it can use the external feature in the
-      // attributes and, therefore have a references to it. So, the delete functionality tries
-      // to delete this feature. Test case is creation of a constraint on external point,
-      // use in this control after an external point, the point of the sketch.
-      anIgnoredFeatures.insert(theFeature);
-      workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures);
+      // the external feature should be removed with all references, composite sketch feature will be ignored
+      workshop(theWorkshop)->deleteFeatures(anObjects);
     }
   }
 }