]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix undo-redo problems on Fillet construction
authorazv <azv@opencascade.com>
Thu, 9 Apr 2015 05:49:19 +0000 (08:49 +0300)
committerazv <azv@opencascade.com>
Thu, 9 Apr 2015 05:49:19 +0000 (08:49 +0300)
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h

index d6094199f576d0f12f44be87a050c514606b2051..79616858f5a292c628dc9dbe717d8fad6785bc96 100644 (file)
@@ -114,9 +114,7 @@ void SketchSolver_ConstraintManager::processEvent(
           std::dynamic_pointer_cast<SketchPlugin_Feature>(*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;
         }
index b51828ba9d0eb78e560f1d934f11f9801a4642a3..ca39f6e2dd8dec896a863b41ff1b2b6922e46c7e 100644 (file)
@@ -30,6 +30,7 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintMirror.h>
 #include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_Feature.h>
 
 #include <SketchPlugin_Arc.h>
@@ -413,9 +414,18 @@ void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup)
   if (!myFeatureStorage)
     myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
 
+  std::vector<ConstraintPtr> 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<ConstraintPtr>::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();
+}
+
index 30d675c636c949733e4c03f39736eef051b32631..534d48051b4ee4dac9185f58af6fdc0717ebfa0a 100644 (file)
@@ -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