+ std::list<ConstraintWrapperPtr>::iterator aWIt = aWrapper.begin();
+
+ // Check if attributes of constraint are changed, rebuild constraint
+ std::set<AttributePtr> anAttributes;
+ std::set<AttributePtr>::iterator aFoundAttr;
+ std::set<FeaturePtr> aFeatures;
+ std::set<FeaturePtr>::iterator aFoundFeat;
+ for (int anEntIndex = 0; anEntIndex < 4; ++anEntIndex) {
+ AttributePtr anAttr =
+ myBaseConstraint->attribute(SketchPlugin_Constraint::ATTRIBUTE(anEntIndex));
+ if (!anAttr)
+ continue;
+
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttr);
+ if (aRefAttr) {
+ if (aRefAttr->isObject()) {
+ FeaturePtr aFeat = ModelAPI_Feature::feature(aRefAttr->object());
+ if (myBaseConstraint->getKind() != SketchPlugin_ConstraintLength::ID())
+ aFeatures.insert(aFeat);
+ else {
+ // Workaround for the Length constraint: add points of line, not line itself
+ anAttributes.insert(aFeat->attribute(SketchPlugin_Line::START_ID()));
+ anAttributes.insert(aFeat->attribute(SketchPlugin_Line::END_ID()));
+ }
+ } else
+ anAttributes.insert(aRefAttr->attr());
+ } else
+ anAttributes.insert(anAttr);
+ }
+ bool hasNewAttr = !(anAttributes.empty() && aFeatures.empty());
+ for (; hasNewAttr && aWIt != aWrapper.end(); ++ aWIt) {
+ const std::list<EntityWrapperPtr>& aSubs = (*aWIt)->entities();
+ std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
+ for (; hasNewAttr && aSIt != aSubs.end(); ++aSIt) {
+ if ((*aSIt)->baseAttribute()) {
+ aFoundAttr = anAttributes.find((*aSIt)->baseAttribute());
+ if (aFoundAttr != anAttributes.end())
+ anAttributes.erase(aFoundAttr);
+ } else {
+ aFoundFeat = aFeatures.find((*aSIt)->baseFeature());
+ if (aFoundFeat != aFeatures.end())
+ aFeatures.erase(aFoundFeat);
+ }
+ hasNewAttr = !(anAttributes.empty() && aFeatures.empty());
+ }
+ }
+ if (hasNewAttr) {
+ remove();
+ process();
+ return;
+ }
+