}
// indicates attribute containing in the external feature
-bool isExternalAttribute(const AttributePtr& theAttribute)
+static bool isExternalAttribute(const AttributePtr& theAttribute)
{
if (!theAttribute)
return false;
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,
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);
}