From: dbv Date: Mon, 29 Feb 2016 10:18:31 +0000 (+0300) Subject: Issue #1330: Clear results in fillet creation if radius changed X-Git-Tag: V_2.2.0~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2cd6cc19a693497d1f003c164269721bb0bfed4;p=modules%2Fshaper.git Issue #1330: Clear results in fillet creation if radius changed --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index b66cbc0c3..0576e0654 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -496,42 +496,7 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) myRadiusChangedInCode = false; } - // Clear auxiliary flag on initial objects. - for(std::map::iterator aPointsIter = myPointFeaturesMap.begin(); - aPointsIter != myPointFeaturesMap.end();) { - const FilletFeatures& aFilletFeatures = aPointsIter->second; - std::list::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::iterator aPointsIter = myPointFeaturesMap.begin(); - aPointsIter != myPointFeaturesMap.end();) { - // Remove all produced constraints. - const FilletFeatures& aFilletFeatures = aPointsIter->second; - std::list::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::iterator aPointsIter = myPointFeaturesMap.begin(); + aPointsIter != myPointFeaturesMap.end();) { + const FilletFeatures& aFilletFeatures = aPointsIter->second; + std::list::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::iterator aPointsIter = myPointFeaturesMap.begin(); + aPointsIter != myPointFeaturesMap.end();) { + // Remove all produced constraints. + const FilletFeatures& aFilletFeatures = aPointsIter->second; + std::list::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, diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.h b/src/SketchPlugin/SketchPlugin_ConstraintFillet.h index dd3edf3cc..bd8a51888 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.h @@ -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 myNewPoints; ///< set of new points std::map myPointFeaturesMap; ///< map of point and features for fillet