return isUpdated;
}
-void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
+bool SketchSolver_Group::moveFeature(FeaturePtr theFeature)
{
BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
// Then, create temporary Fixed constraint
SolverConstraintPtr aConstraint = aBuilder->createMovementConstraint(theFeature);
if (!aConstraint)
- return;
+ return false;
aConstraint->process(myStorage, getId(), getWorkplaneId());
if (aConstraint->error().empty())
setTemporary(aConstraint);
aFixedRadius->remove();
}
}
+ return true;
}
// ============================================================================
/** \brief Updates the data corresponding the specified feature moved in GUI.
* Additional Fixed constraints are created.
* \param[in] theFeature the feature to be updated
+ * \return \c true, if the feature is moved
*/
- void moveFeature(FeaturePtr theFeature);
+ bool moveFeature(FeaturePtr theFeature);
/** \brief Verifies the feature attributes are used in this group
* \param[in] theFeature constraint or any other object for verification of interaction
for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
std::shared_ptr<SketchPlugin_Feature> aSFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
- if (aSFeature) {
- moveEntity(aSFeature);
+ if (aSFeature && moveEntity(aSFeature)) {
+ // Want to avoid recalculation of DoF too frequently.
+ // So, set the flag when the feature is really moved.
hasProperFeature = true;
}
}
// Function: moveEntity
// Purpose: update element moved on the sketch, which is used by constraints
// ============================================================================
-void SketchSolver_Manager::moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature)
+bool SketchSolver_Manager::moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature)
{
bool isMoved = false;
std::list<SketchSolver_Group*>::iterator aGroupIt = myGroups.begin();
for (; aGroupIt != myGroups.end(); aGroupIt++)
- if (!(*aGroupIt)->isEmpty() && (*aGroupIt)->isInteract(theFeature)) {
- (*aGroupIt)->moveFeature(theFeature);
- isMoved = true;
- }
+ if (!(*aGroupIt)->isEmpty() && (*aGroupIt)->isInteract(theFeature))
+ isMoved = (*aGroupIt)->moveFeature(theFeature) || isMoved;
if (!isMoved && theFeature->getKind() == SketchPlugin_Arc::ID()) {
// Workaround to move arc.
// If the arc has not been constrained, we will push it into empty group and apply movement.
for (aGroupIt = myGroups.begin(); aGroupIt != myGroups.end(); aGroupIt++)
if ((*aGroupIt)->isEmpty())
- (*aGroupIt)->moveFeature(theFeature);
+ isMoved = (*aGroupIt)->moveFeature(theFeature) || isMoved;
}
+ return isMoved;
}
// ============================================================================
/** \brief Updates entity which is moved in GUI
* \param[in] theFeature entity to be updated
+ * \return \c true, if the entity has been moved
*/
- void moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
+ bool moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
/** \brief Goes through the list of groups and solve the constraints
* \param[in] theGroups list of groups to be resolved (if empty list, all groups are resolved)