Salome HOME
Code cleanup in SketchPlugin and SketchSolver.
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MultiRotation.cpp
index 3e99827d8888f6609260001986ac089a2aaca179..b44a26517e61bb46c4455b915b5f3b9baa1dc1e3 100755 (executable)
@@ -213,18 +213,24 @@ AISObjectPtr SketchPlugin_MultiRotation::getAISObject(AISObjectPtr thePrevious)
 
 void SketchPlugin_MultiRotation::erase()
 {
+  static Events_Loop* aLoop = Events_Loop::loop();
+  static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
   // Set copy attribute to false on all copied features.
+  AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+      data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   AttributeRefListPtr aRefListOfRotated = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
       data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
 
-  if(aRefListOfRotated.get()) {
-    static Events_Loop* aLoop = Events_Loop::loop();
-    static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-
-    std::list<ObjectPtr> aTargetList = aRefListOfRotated->list();
-    for(std::list<ObjectPtr>::const_iterator aTargetIt = aTargetList.cbegin(); aTargetIt != aTargetList.cend(); aTargetIt++) {
-      if((*aTargetIt).get()) {
-        ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(*aTargetIt);
+  if(aRefListOfShapes.get() && aRefListOfRotated.get()) {
+    for(int anIndex = 0; anIndex < aRefListOfRotated->size(); anIndex++) {
+      ObjectPtr anObject = aRefListOfRotated->object(anIndex);
+      if(aRefListOfShapes->isInList(anObject)) {
+        // Don't modify attribute of original features, just skip.
+        continue;
+      }
+      if(anObject.get()) {
+        ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
         if(aRes.get()) {
           FeaturePtr aFeature = aRes->document()->feature(aRes);
           if(aFeature.get()) {