From: azv Date: Thu, 9 Apr 2015 05:49:19 +0000 (+0300) Subject: Fix undo-redo problems on Fillet construction X-Git-Tag: V_1.1.0~52^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0d245288551534bd4327b2be5709a46e7debd28d;p=modules%2Fshaper.git Fix undo-redo problems on Fillet construction --- diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index d6094199f..79616858f 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -114,9 +114,7 @@ void SketchSolver_ConstraintManager::processEvent( std::dynamic_pointer_cast(*aFeatIter); if (!aFeature) continue; - if (aFeature->getKind() == SketchPlugin_ConstraintFillet::ID() || - aFeature->getKind() == SketchPlugin_ConstraintMirror::ID() || - aFeature->getKind() == SketchPlugin_ConstraintTangent::ID()) { + if (SketchSolver_Group::isComplexConstraint(aFeature)) { aComplexConstraints.insert(aFeature); continue; } diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index b51828ba9..ca39f6e2d 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -413,9 +414,18 @@ void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup) if (!myFeatureStorage) myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage); + std::vector aComplexConstraints; ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin(); + // append simple constraints for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++) - changeConstraint(aConstrIter->first); + if (isComplexConstraint(aConstrIter->first)) + aComplexConstraints.push_back(aConstrIter->first); + else + changeConstraint(aConstrIter->first); + // append complex constraints + std::vector::iterator aComplexIter = aComplexConstraints.begin(); + for (; aComplexIter != aComplexConstraints.end(); aComplexIter++) + changeConstraint(*aComplexIter); } // ============================================================================ @@ -539,3 +549,16 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint) if (aCIter != myConstraints.end()) myConstraints.erase(aCIter); } + +// ============================================================================ +// Function: isComplexConstraint +// Class: SketchSolver_Group +// Purpose: verifies the constraint is complex, i.e. it needs another constraints to be created before +// ============================================================================ +bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint) +{ + return theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID() || + theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID() || + theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID(); +} + diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index 30d675c63..534d48051 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -70,6 +70,9 @@ class SketchSolver_Group return mySketch->data() && mySketch->data()->isValid(); } + /// \brief Verifies the constraint is complex, i.e. it needs another constraints to be created before + static bool isComplexConstraint(FeaturePtr theConstraint); + /** \brief Adds or updates a constraint in the group * \param[in] theConstraint constraint to be changed * \return \c true if the constraint added or updated successfully