std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
std::set<ObjectPtr> aFeatures = anUpdateMsg->objects();
+ // Shows the message has at least one feature applicable for solver
+ bool hasProperFeature = false;
+
bool isMovedEvt = theMessage->eventID()
== Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
if (isMovedEvt) {
for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
std::shared_ptr<SketchPlugin_Feature> aSFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
- if (aSFeature)
+ if (aSFeature) {
moveEntity(aSFeature);
+ hasProperFeature = true;
+ }
}
} else {
std::set<ObjectPtr>::iterator aFeatIter;
if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) {
std::shared_ptr<ModelAPI_CompositeFeature> aSketch = std::dynamic_pointer_cast<
ModelAPI_CompositeFeature>(aFeature);
- changeWorkplane(aSketch);
+ hasProperFeature = changeWorkplane(aSketch) || hasProperFeature;
}
}
// then get anything but not the sketch
aComplexConstraints.insert(aFeature);
continue;
}
- changeConstraintOrEntity(aFeature);
+ hasProperFeature = changeConstraintOrEntity(aFeature) || hasProperFeature;
}
// processing remain constraints
aFeatIter = aComplexConstraints.begin();
std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
if (!aFeature)
continue;
- changeConstraintOrEntity(aFeature);
+ hasProperFeature = changeConstraintOrEntity(aFeature) || hasProperFeature;
}
}
// Solve the set of constraints
- resolveConstraints(isMovedEvt); // send update for movement in any case
+ if (hasProperFeature)
+ resolveConstraints(isMovedEvt); // send update for movement in any case
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_ResultConstruction.h>
+#include <GeomDataAPI_Point2D.h>
void SketchSolver_FeatureStorage::changeConstraint(ConstraintPtr theConstraint)
{
return; // no such attribute
anAttrIter->second.erase(theFeature);
+ if (!anAttrIter->second.empty())
+ return;
+
+ // Check there is no features containing such attribute
+ MapFeatureConstraint::iterator aFeatIter = myFeatures.begin();
+ for (; aFeatIter != myFeatures.end(); aFeatIter++) {
+ DataPtr aData = aFeatIter->first->data();
+ if (!aData || !aData->isValid())
+ continue;
+ std::list<AttributePtr> anAttrList = aData->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<AttributePtr>::iterator anAtIt = anAttrList.begin();
+ for (; anAtIt != anAttrList.end(); anAtIt++) {
+ std::shared_ptr<GeomDataAPI_Point2D> aPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anAtIt);
+ if (aPoint == theAttribute)
+ anAttrIter->second.insert(aFeatIter->first);
+ }
+ }
if (anAttrIter->second.empty())
myAttributes.erase(anAttrIter);
}