]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1330: Clear results in fillet creation if radius changed
authordbv <dbv@opencascade.com>
Mon, 29 Feb 2016 10:18:31 +0000 (13:18 +0300)
committerdbv <dbv@opencascade.com>
Mon, 29 Feb 2016 10:18:31 +0000 (13:18 +0300)
src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp
src/SketchPlugin/SketchPlugin_ConstraintFillet.h

index b66cbc0c3ba20a40e42cbf15164ad81ac7ba9d57..0576e0654bf3ce3ec316b9a4219bcb4d0eae4dc5 100644 (file)
@@ -496,42 +496,7 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID)
         myRadiusChangedInCode = false;
       }
 
-      // Clear auxiliary flag on initial objects.
-      for(std::map<AttributePtr, FilletFeatures>::iterator aPointsIter = myPointFeaturesMap.begin();
-          aPointsIter != myPointFeaturesMap.end();) {
-        const FilletFeatures& aFilletFeatures = aPointsIter->second;
-        std::list<FeaturePtr>::const_iterator aFeatureIt;
-        for(aFeatureIt = aFilletFeatures.baseEdges.cbegin();
-            aFeatureIt != aFilletFeatures.baseEdges.cend();
-            ++aFeatureIt) {
-          (*aFeatureIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(false);
-        }
-        ++aPointsIter;
-      }
-
-      // And remove all produced features.
-      DocumentPtr aDoc = sketch()->document();
-      for(std::map<AttributePtr, FilletFeatures>::iterator aPointsIter = myPointFeaturesMap.begin();
-          aPointsIter != myPointFeaturesMap.end();) {
-        // Remove all produced constraints.
-        const FilletFeatures& aFilletFeatures = aPointsIter->second;
-        std::list<FeaturePtr>::const_iterator aFeatureIt;
-        for(aFeatureIt = aFilletFeatures.resultConstraints.cbegin();
-            aFeatureIt != aFilletFeatures.resultConstraints.cend();
-            ++aFeatureIt) {
-          aDoc->removeFeature(*aFeatureIt);
-        }
-
-        // Remove all result edges.
-        for(aFeatureIt = aFilletFeatures.resultEdges.cbegin();
-            aFeatureIt != aFilletFeatures.resultEdges.cend();
-            ++aFeatureIt) {
-          aDoc->removeFeature(*aFeatureIt);
-        }
-
-        // Remove point from map.
-        myPointFeaturesMap.erase(aPointsIter++);
-      }
+      clearResults();
 
       return;
     }
@@ -698,6 +663,10 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID)
       }
     }
 
+    if(abs(aPrevRadius - aMinimumRadius) > tolerance) {
+      clearResults(); // if radius changed clear all results;
+    }
+
     // Set new default radius if it was not changed by user.
     if(!myRadiusChangedByUser) {
       myRadiusChangedInCode = true;
@@ -730,6 +699,46 @@ bool SketchPlugin_ConstraintFillet::isMacro() const
   return true;
 }
 
+void SketchPlugin_ConstraintFillet::clearResults()
+{
+  // Clear auxiliary flag on initial objects.
+  for(std::map<AttributePtr, FilletFeatures>::iterator aPointsIter = myPointFeaturesMap.begin();
+      aPointsIter != myPointFeaturesMap.end();) {
+    const FilletFeatures& aFilletFeatures = aPointsIter->second;
+    std::list<FeaturePtr>::const_iterator aFeatureIt;
+    for(aFeatureIt = aFilletFeatures.baseEdges.cbegin();
+        aFeatureIt != aFilletFeatures.baseEdges.cend();
+        ++aFeatureIt) {
+      (*aFeatureIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(false);
+    }
+    ++aPointsIter;
+  }
+
+  // And remove all produced features.
+  DocumentPtr aDoc = sketch()->document();
+  for(std::map<AttributePtr, FilletFeatures>::iterator aPointsIter = myPointFeaturesMap.begin();
+      aPointsIter != myPointFeaturesMap.end();) {
+    // Remove all produced constraints.
+    const FilletFeatures& aFilletFeatures = aPointsIter->second;
+    std::list<FeaturePtr>::const_iterator aFeatureIt;
+    for(aFeatureIt = aFilletFeatures.resultConstraints.cbegin();
+        aFeatureIt != aFilletFeatures.resultConstraints.cend();
+        ++aFeatureIt) {
+      aDoc->removeFeature(*aFeatureIt);
+    }
+
+    // Remove all result edges.
+    for(aFeatureIt = aFilletFeatures.resultEdges.cbegin();
+        aFeatureIt != aFilletFeatures.resultEdges.cend();
+        ++aFeatureIt) {
+      aDoc->removeFeature(*aFeatureIt);
+    }
+
+    // Remove point from map.
+    myPointFeaturesMap.erase(aPointsIter++);
+  }
+};
+
 
 // =========   Auxiliary functions   =================
 void recalculateAttributes(FeaturePtr theNewArc,  const std::string& theNewArcAttribute,
index dd3edf3cc6008bb83bfb2cf90f942130d5eeb930..bd8a518882c0ea2a0be1956fb971da2d9d6957e2 100644 (file)
@@ -69,6 +69,10 @@ class SketchPlugin_ConstraintFillet : public SketchPlugin_ConstraintBase
     return myPointFeaturesMap;
   };
 
+private:
+  /// \ Removes all produced features and restore base edges.
+  void clearResults();
+
 private:
   std::set<AttributePtr> myNewPoints; ///< set of new points
   std::map<AttributePtr, FilletFeatures> myPointFeaturesMap; ///< map of point and features for fillet