]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2077: mirror constraint is destroyed
authorazv <azv@opencascade.com>
Mon, 3 Apr 2017 05:26:55 +0000 (08:26 +0300)
committerazv <azv@opencascade.com>
Mon, 3 Apr 2017 09:53:52 +0000 (12:53 +0300)
Notify listeners about feature update only if at least one attribute is changed

src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/SketchSolver_ConstraintMirror.cpp

index 547eaef012e1db5fe8705836828045dee92a934e..96235587d0bd0f2b4bd96d4c01f8bcba4131ce79 100644 (file)
@@ -151,10 +151,11 @@ static bool isCopyInMulti(std::shared_ptr<SketchPlugin_Feature> theFeature)
 
 bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
 {
+  bool sendNotify = false;
   bool isUpdated = false;
   EntityWrapperPtr aRelated = entity(theFeature);
   if (aRelated) // send signal to subscribers
-    notify(theFeature);
+    sendNotify = true;
   else { // Feature is not exist, create it
     std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
         std::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
@@ -193,6 +194,10 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
         (*anAttrIt)->attributeType() == ModelAPI_AttributeDouble::typeId())
       isUpdated = update(*anAttrIt) || isUpdated;
 
+  // send notification to listeners due to at least one attribute is changed
+  if (sendNotify && isUpdated)
+    notify(theFeature);
+
   // update arc
   if (aRelated && aRelated->type() == ENTITY_ARC) {
     /// TODO: this code should be shared with FeatureBuilder somehow
index 80cb647d874e80cae6625eab771336bb4a49107a..89bc973b27c7fe1402683af303393bbd05b806d8 100644 (file)
@@ -62,6 +62,13 @@ void SketchSolver_ConstraintMirror::getAttributes(
       myFeatures.insert(aFeature);
     }
   }
+  // add mirrored features to the list
+  aList = aMirroredRefList->list();
+  for (anIt = aList.begin(); anIt != aList.end(); ++anIt) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+    if (aFeature)
+      myFeatures.insert(aFeature);
+  }
 }
 
 void SketchSolver_ConstraintMirror::process()
@@ -86,7 +93,8 @@ void SketchSolver_ConstraintMirror::process()
 void SketchSolver_ConstraintMirror::update()
 {
   cleanErrorMsg();
-  adjustConstraint();
+  remove();
+  process();
 }
 
 void SketchSolver_ConstraintMirror::adjustConstraint()
@@ -131,16 +139,6 @@ 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);
 }