Salome HOME
First part of the test correction for improvement: 2D points selection in multi-trans...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Sketch.cpp
index 2a5dd0944780f0c7e21decd6617dd180b335de41..a63344e58fda66b21299919bd574339b87b9fcad 100644 (file)
@@ -9,12 +9,9 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
 
-#include <GeomAPI_AISObject.h>
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_PlanarEdges.h>
 
-#include <GeomAlgoAPI_FaceBuilder.h>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 
@@ -148,9 +145,15 @@ void SketchPlugin_Sketch::removeFeature(std::shared_ptr<ModelAPI_Feature> theFea
 {
   if (!data()->isValid()) // sketch is already removed (case on undo of sketch), sync is not needed
     return;
-  // to keep the persistent sub-elements indexing, do not remove elements from list,
-  // but substitute by nulls
-  reflist(SketchPlugin_Sketch::FEATURES_ID())->substitute(theFeature, ObjectPtr());
+  AttributeRefListPtr aList = reflist(SketchPlugin_Sketch::FEATURES_ID());
+  // if the object is last, remove it from the list (needed to skip empty transaction on edit of sketch feature)
+  if (aList->object(aList->size(true) - 1, true) == theFeature) {
+    aList->remove(theFeature);
+  } else {
+    // to keep the persistent sub-elements indexing, do not remove elements from list,
+    // but substitute by nulls
+    aList->substitute(theFeature, ObjectPtr());
+  }
 }
 
 int SketchPlugin_Sketch::numberOfSubs(bool forTree) const
@@ -304,7 +307,7 @@ FeaturePtr SketchPlugin_Sketch::addUniqueNamedCopiedFeature(FeaturePtr theFeatur
   // as a name for the feature, the generated unique name is set
   aNewFeature->data()->setName(aUniqueFeatureName);
   // text expressions could block setValue of some attributes
-  clearExpressions(aNewFeature);
+  SketchPlugin_Tools::clearExpressions(aNewFeature);
 
   return aNewFeature;
 }
@@ -322,3 +325,9 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the
 
   return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
 }
+
+void SketchPlugin_Sketch::exchangeIDs(
+  std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
+{
+  reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2);
+}