Salome HOME
Issue #2077: mirror constraint is destroyed
authorazv <azv@opencascade.com>
Fri, 31 Mar 2017 12:00:32 +0000 (15:00 +0300)
committerazv <azv@opencascade.com>
Fri, 31 Mar 2017 12:00:32 +0000 (15:00 +0300)
Prohibit to move copied entities.
Fix error with incorrect blocking of attribute changed event.

src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintMirror.cpp

index 721efb4a12d4d154c91e29584ed297c57911546d..3ee49eccf2e09f3f39e2243df1549732afffd675 100644 (file)
@@ -8,6 +8,7 @@
 #include <PlaneGCSSolver_PointWrapper.h>
 
 #include <GeomDataAPI_Point2D.h>
+#include <SketchPlugin_SketchEntity.h>
 
 #include <cmath>
 
@@ -125,6 +126,14 @@ void SketchSolver_ConstraintFixed::getAttributes(
     std::vector<EntityWrapperPtr>& theAttributes)
 {
   if (myBaseFeature) {
+    // if the feature is copy, do not move it
+    std::shared_ptr<SketchPlugin_SketchEntity> aSketchFeature =
+        std::dynamic_pointer_cast<SketchPlugin_SketchEntity>(myBaseFeature);
+    if (aSketchFeature && aSketchFeature->isCopy()) {
+      myStorage->setNeedToResolve(true);
+      return;
+    }
+
     // The feature is fixed.
     EntityWrapperPtr aSolverEntity = getChangedEntity(myBaseFeature, myStorage);
     myStorage->update(myBaseFeature);
index b338983cadae47a19e8c0c6a78a4e8934452f601..80cb647d874e80cae6625eab771336bb4a49107a 100644 (file)
@@ -86,8 +86,7 @@ void SketchSolver_ConstraintMirror::process()
 void SketchSolver_ConstraintMirror::update()
 {
   cleanErrorMsg();
-  remove();
-  process();
+  adjustConstraint();
 }
 
 void SketchSolver_ConstraintMirror::adjustConstraint()
@@ -132,6 +131,16 @@ void SketchSolver_ConstraintMirror::blockEvents(bool isBlocked)
   for (; anIt != myFeatures.end(); ++anIt)
     (*anIt)->data()->blockSendAttributeUpdated(isBlocked);
 
+  AttributeRefListPtr aMirroredRefList =
+      myBaseConstraint->reflist(SketchPlugin_Constraint::ENTITY_C());
+  std::list<ObjectPtr> aMirroredList = aMirroredRefList->list();
+  std::list<ObjectPtr>::iterator aMIt = aMirroredList.begin();
+  for (; aMIt != aMirroredList.end(); ++aMIt) {
+    FeaturePtr aMirrored = ModelAPI_Feature::feature(*aMIt);
+    aMirrored->data()->blockSendAttributeUpdated(isBlocked);
+  }
+
+
   SketchSolver_Constraint::blockEvents(isBlocked);
 }