if (aValueAttr) {
std::list<ConstraintWrapperPtr>::iterator aWIt = aWrapper.begin();
for (; aWIt != aWrapper.end(); ++aWIt)
- (*aWIt)->setValue(aValueAttr->value());
+ if (fabs((*aWIt)->value() - aValueAttr->value()) > tolerance) {
+ (*aWIt)->setValue(aValueAttr->value());
+ myStorage->setNeedToResolve(true);
+ }
}
myStorage->addConstraint(myBaseConstraint, aWrapper);
}
myType = TYPE(myBaseConstraint);
- myStorage->update(aMirLineAttr, myGroupID);
+ myStorage->update(aMirLineAttr/*, myGroupID*/);
theMirrorLine = myStorage->entity(aMirLineAttr);
// Create SolveSpace entity for all features
if (!aFeature)
continue;
- myStorage->update(aFeature, myGroupID);
+ myStorage->update(aFeature/*, myGroupID*/);
aList->push_back(myStorage->entity(aFeature));
}
}
int aNbCoinc = 0;
std::list<EntityWrapperPtr>::const_iterator anIt1, anIt2;
for (anIt1 = aStartIt1; anIt1 != aPoints1.end(); ++anIt1) {
+ if ((*anIt1)->type() != ENTITY_POINT)
+ continue;
std::shared_ptr<GeomAPI_Pnt2d> aPt1 = aBuilder->point(*anIt1);
for (anIt2 = aStartIt2; anIt2 != aPoints2.end(); ++anIt2) {
+ if ((*anIt2)->type() != ENTITY_POINT)
+ continue;
std::shared_ptr<GeomAPI_Pnt2d> aPt2 = aBuilder->point(*anIt2);
if (aPt1->distance(aPt2) < tolerance)
++aNbCoinc;
myChangedConstraints.clear();
}
+static void updateMultiConstraints(ConstraintConstraintMap& theConstraints, FeaturePtr theFeature)
+{
+ ConstraintConstraintMap::iterator aCIt = theConstraints.begin();
+ for (; aCIt != theConstraints.end(); ++aCIt) {
+ if ((aCIt->second->getType() == CONSTRAINT_MULTI_ROTATION ||
+ aCIt->second->getType() == CONSTRAINT_MULTI_TRANSLATION)
+ && aCIt->second->isUsed(theFeature))
+ std::dynamic_pointer_cast<SketchSolver_ConstraintMulti>(aCIt->second)->update(true);
+ }
+}
+
bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
{
if (!checkFeatureValidity(theFeature))
myStorage->blockEvents(true);
myStorage->refresh(true);
- return myStorage->update(theFeature);
+ bool isUpdated = myStorage->update(theFeature);
+
+ updateMultiConstraints(myConstraints, theFeature);
+ return isUpdated;
}
void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
myStorage->blockEvents(true);
myStorage->refresh(true);
- // Secondly, search attributes of the feature in the list of the Multi constraints and update them
- ConstraintConstraintMap::iterator aCIt = myConstraints.begin();
- for (; aCIt != myConstraints.end(); ++aCIt) {
- if ((aCIt->second->getType() == CONSTRAINT_MULTI_ROTATION ||
- aCIt->second->getType() == CONSTRAINT_MULTI_TRANSLATION)
- && aCIt->second->isUsed(theFeature))
- std::dynamic_pointer_cast<SketchSolver_ConstraintMulti>(aCIt->second)->update(true);
- }
-
- // Then, create temporary rigid constraint
+ // Then, create temporary Fixed constraint
SolverConstraintPtr aConstraint = aBuilder->createMovementConstraint(theFeature);
if (!aConstraint)
return;
aConstraint->process(myStorage, getId(), getWorkplaneId());
if (aConstraint->error().empty())
setTemporary(aConstraint);
+
+ // Secondly, search attributes of the feature in the list of the Multi constraints and update them
+ updateMultiConstraints(myConstraints, theFeature);
}
// ============================================================================
#include <GeomDataAPI_Point2D.h>
#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
++anIt;
}
}
- if (!isFullyRemoved)
- myConstraintMap[theConstraint] = aConstrList;
+ if (!isFullyRemoved) {
+ // revert removed constraint
+ addConstraint(theConstraint, aConstrList);
+ }
return isFullyRemoved;
}
bool SketchSolver_Storage::isUsed(FeaturePtr theFeature) const
{
+ if (myFeatureMap.find(theFeature) != myFeatureMap.end())
+ return true;
+ // check constraints
std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
aCIt = myConstraintMap.begin();
std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
anAttribute = aRefAttr->attr();
}
+ if (myAttributeMap.find(theAttribute) != myAttributeMap.end())
+ return true;
+ // check in constraints
std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
aCIt = myConstraintMap.begin();
std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
for (aCWIt = aCIt->second.begin(); aCWIt != aCIt->second.end(); ++aCWIt)
if (::isUsed(*aCWIt, anAttribute))
return true;
+ // check in features
+ std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIt = myFeatureMap.begin();
+ for (; aFIt != myFeatureMap.end(); ++aFIt)
+ if (::isUsed(aFIt->second, anAttribute))
+ return true;
return false;
}
return true;
// feature is not removed, revert operation
myFeatureMap[theFeature] = anEntity;
+ update(anEntity);
return false;
}
return true;
// attribute is not removed, revert operation
myAttributeMap[theAttribute] = anEntity;
+ update(anEntity);
return false;
}
if (!theAttribute)
return false;
+ AttributeRefListPtr aRefList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+ if (aRefList) {
+ std::list<ObjectPtr> anObjects = aRefList->list();
+ std::list<ObjectPtr>::iterator anObjIt = anObjects.begin();
+ for (; anObjIt != anObjects.end(); ++anObjIt) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*anObjIt);
+ if (isInteract(aFeature))
+ return true;
+ }
+ return false;
+ }
+
AttributeRefAttrPtr aRefAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
if (!aRefAttr)
std::list<EntityWrapperPtr>::const_iterator anIt1 = theEntity1->subEntities().begin();
std::list<EntityWrapperPtr>::const_iterator anIt2 = theEntity2->subEntities().begin();
if ((*anIt2)->group() == theGroupID) // mirrored point is not fixed
- makeMirrorPoints(theEntity1->subEntities().front(),
- theEntity2->subEntities().front(), theMirrorLine);
+ makeMirrorPoints(*anIt1, *anIt2, theMirrorLine);
// Workaround to avoid problems in SolveSpace.
// The symmetry of two arcs will be done using symmetry of three points on these arcs: