]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1489 Multi-rotation problem if there is a reference to copied objects
authornds <nds@opencascade.com>
Thu, 19 May 2016 09:05:05 +0000 (12:05 +0300)
committernds <nds@opencascade.com>
Thu, 19 May 2016 09:05:05 +0000 (12:05 +0300)
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchPlugin/SketchPlugin_MultiRotation.cpp
src/SketchPlugin/SketchPlugin_MultiTranslation.cpp
src/SketchPlugin/SketchPlugin_Projection.cpp

index 18380c7ec0c5975a7ab859427132475a529a7742..29031a04b253e4abfd27ecf604f623e5fa52bbe8 100644 (file)
@@ -19,6 +19,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAPI_Ax2.h>
 #include <GeomAPI_Circ2d.h>
@@ -751,10 +752,12 @@ void SketchPlugin_Arc::tangencyArcConstraints()
     // Remove all obtained constraints which use current arc, because
     // there is no information which of them were used to build tangency arc.
     DocumentPtr aDoc = sketch()->document();
+    std::set<FeaturePtr> aFeaturesToBeRemoved;
     for (aCIt = aCoincidence.begin(); aCIt != aCoincidence.end(); ++aCIt)
-      aDoc->removeFeature(*aCIt);
+      aFeaturesToBeRemoved.insert(*aCIt);
     for (aTIt = aTangency.begin(); aTIt != aTangency.end(); ++aTIt)
-      aDoc->removeFeature(*aTIt);
+      aFeaturesToBeRemoved.insert(*aTIt);
+    ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
     // Send events to update the sub-features by the solver.
     if (isDeleteFlushed)
       Events_Loop::loop()->setFlushed(aDeleteEvent, true);
index e17a704c5b5238d08f313cc0766a8eb9e39ec147..2161806ebd3a21c805f4d2661645e482e216cda1 100755 (executable)
@@ -13,6 +13,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
 
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
@@ -70,6 +71,7 @@ void SketchPlugin_ConstraintMirror::execute()
   std::list<ObjectPtr>::iterator anInitIter = anInitialList.begin();
   std::list<ObjectPtr>::iterator aMirrorIter = aMirroredList.begin();
   std::vector<bool>::iterator aUsedIter = isUsed.begin();
+  std::set<FeaturePtr> aFeaturesToBeRemoved;
   for (; aUsedIter != isUsed.end(); aUsedIter++) {
     if (!(*aUsedIter)) {
       aRefListOfShapes->remove(*anInitIter);
@@ -81,7 +83,7 @@ void SketchPlugin_ConstraintMirror::execute()
         DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
         FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
         if (aFeature)
-          aDoc->removeFeature(aFeature);
+          aFeaturesToBeRemoved.insert(aFeature);
       }
     }
     if (anInitIter != anInitialList.end())
@@ -89,6 +91,7 @@ void SketchPlugin_ConstraintMirror::execute()
     if (aMirrorIter != aMirroredList.end())
       aMirrorIter++;
   }
+  ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
 
   static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
 
index 4737cd1724dcd34bec5e059d89bd7e2958ec1e09..0ef30f7a166309271f9a23516f049997c243bbea 100755 (executable)
@@ -121,7 +121,6 @@ void SketchPlugin_MultiRotation::execute()
         FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
         if (aFeature)
           aFeaturesToBeRemoved.insert(aFeature);
-          //aDoc->removeFeature(aFeature);
       }
     } else {
       for (int i = 0; i <= aNbCopies && aTargetIter != aTargetList.end(); i++)
@@ -165,7 +164,6 @@ void SketchPlugin_MultiRotation::execute()
             FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
             if (aFeature)
               aFeaturesToBeRemoved.insert(aFeature);
-              //aDoc->removeFeature(aFeature);
           }
           ind++;
         }
@@ -350,7 +348,6 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
           FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
           if (aFeature)
             aFeaturesToBeRemoved.insert(aFeature);
-            //aDoc->removeFeature(aFeature);
         }
       }
       ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
index 5e0a93098924892d5c215b3c6db5ddcbfa16b9a6..d6e1d5dd22b50b5b679a11c9ca4ed4cdf4459d22 100755 (executable)
@@ -19,6 +19,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
 
 #include <SketchPlugin_SketchEntity.h>
 #include <SketcherPrs_Factory.h>
@@ -104,6 +105,7 @@ void SketchPlugin_MultiTranslation::execute()
   std::list<ObjectPtr>::iterator anInitIter = anInitialList.begin();
   std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
   std::vector<bool>::iterator aUsedIter = isUsed.begin();
+  std::set<FeaturePtr> aFeaturesToBeRemoved;
   for (; aUsedIter != isUsed.end(); aUsedIter++) {
     if (!(*aUsedIter)) {
       aRefListOfShapes->remove(*anInitIter);
@@ -116,7 +118,7 @@ void SketchPlugin_MultiTranslation::execute()
         DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
         FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
         if (aFeature)
-          aDoc->removeFeature(aFeature);
+          aFeaturesToBeRemoved.insert(aFeature);
       }
     } else {
       for (int i = 0; i <= aNbCopies && aTargetIter != aTargetList.end(); i++)
@@ -125,6 +127,7 @@ void SketchPlugin_MultiTranslation::execute()
     if (anInitIter != anInitialList.end())
       anInitIter++;
   }
+  ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
   // change number of copies
   if (aCurrentNbCopies != 0 && aNbCopies != aCurrentNbCopies) {
     bool isAdd = aNbCopies > aCurrentNbCopies;
index 36df5bb1e27395b970d297e6ac7a5d35bc548026..eaf073c8b7702a9caeda15e061116fb724df09ee 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);
     }