Salome HOME
Issue #1664 In the Sketcher, add the function Split a segment
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Projection.cpp
index 5cccf4c2bad3ed7b5be4c778e7eb6fe502da12a5..85dade4280451efbcb8cefba8724157a992674d5 100644 (file)
@@ -18,6 +18,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_Edge.h>
@@ -107,7 +108,10 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
         (anEdge->isCircle() && aProjection->getKind() != SketchPlugin_Circle::ID()) ||
         (anEdge->isArc() && aProjection->getKind() != SketchPlugin_Arc::ID())) {
       DocumentPtr aDoc = sketch()->document();
-      aDoc->removeFeature(aProjection);
+
+      std::set<FeaturePtr> aFeaturesToBeRemoved;
+      aFeaturesToBeRemoved.insert(aProjection);
+      ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
       aProjection = FeaturePtr();
       aRefAttr->setObject(aProjection);
     }
@@ -183,6 +187,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     aCenterPnt->setValue(aCenterInSketch);
   }
 
+  aProjection->boolean(COPY_ID())->setValue(true);
   aProjection->execute();
   aRefAttr->setObject(aProjection);
 
@@ -193,7 +198,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
   }
 
   if (theID == EXTERNAL_FEATURE_ID()) {
-    selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->context()->shape());
+    selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->value());
 
     if (aResult) {
       aResult->setShape(aProjection->lastResult()->shape());