]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
Salome HOME
Improve updating "Multi" constraints
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Storage.cpp
index 69b62e970495f766f060e2f8efe5567b2860e54d..547eaef012e1db5fe8705836828045dee92a934e 100644 (file)
@@ -358,7 +358,7 @@ void PlaneGCSSolver_Storage::removeParameters(const GCS::SET_pD& theParams)
 }
 
 // indicates attribute containing in the external feature
-bool isExternalAttribute(const AttributePtr& theAttribute)
+static bool isExternalAttribute(const AttributePtr& theAttribute)
 {
   if (!theAttribute)
     return false;
@@ -367,10 +367,19 @@ bool isExternalAttribute(const AttributePtr& theAttribute)
   return aSketchFeature.get() && aSketchFeature->isExternal();
 }
 
+static void addOwnerToSet(const AttributePtr& theAttribute, std::set<FeaturePtr>& theFeatures)
+{
+  FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
+  if (anOwner)
+    theFeatures.insert(anOwner);
+}
+
 void PlaneGCSSolver_Storage::refresh() const
 {
   const double aTol = 1000. * tolerance; // tolerance to prevent frequent updates
 
+  std::set<FeaturePtr> anUpdatedFeatures;
+
   std::map<AttributePtr, EntityWrapperPtr>::const_iterator anIt = myAttributeMap.begin();
   for (; anIt != myAttributeMap.end(); ++anIt) {
     // the external feature always should keep the up to date values, so,
@@ -385,17 +394,26 @@ void PlaneGCSSolver_Storage::refresh() const
           std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anIt->second);
       GCSPointPtr aGCSPoint = aPointWrapper->point();
       if (fabs(aPoint2D->x() - (*aGCSPoint->x)) > aTol ||
-          fabs(aPoint2D->y() - (*aGCSPoint->y)) > aTol)
+          fabs(aPoint2D->y() - (*aGCSPoint->y)) > aTol) {
         aPoint2D->setValue(*aGCSPoint->x, *aGCSPoint->y);
+        addOwnerToSet(anIt->first, anUpdatedFeatures);
+      }
       continue;
     }
     AttributeDoublePtr aScalar = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anIt->first);
     if (aScalar) {
       ScalarWrapperPtr aScalarWrapper =
           std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(anIt->second);
-      if (fabs(aScalar->value() - aScalarWrapper->value()) > aTol)
+      if (fabs(aScalar->value() - aScalarWrapper->value()) > aTol) {
         aScalar->setValue(aScalarWrapper->value());
+        addOwnerToSet(anIt->first, anUpdatedFeatures);
+      }
       continue;
     }
   }
+
+  // notify listeners about features update
+  std::set<FeaturePtr>::const_iterator aFIt = anUpdatedFeatures.begin();
+  for (; aFIt != anUpdatedFeatures.end(); ++aFIt)
+    notify(*aFIt);
 }