From: azv Date: Thu, 2 Apr 2015 13:45:56 +0000 (+0300) Subject: Implemented possibility to update fillet radius X-Git-Tag: V_1.1.0~57^2~25^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b9ebbecd53069819346c44e888de034bb2b31d7;p=modules%2Fshaper.git Implemented possibility to update fillet radius --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index 79cac01e7..e51c22129 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -30,6 +30,8 @@ #include #include +static const std::string PREVIOUS_VALUE("FilletPreviousRadius"); + /// \brief Attract specified point on theNewArc to the attribute of theFeature static void recalculateAttributes(FeaturePtr theNewArc, const std::string& theNewArcAttribute, FeaturePtr theFeature, const std::string& theFeatureAttribute); @@ -45,8 +47,11 @@ void SketchPlugin_ConstraintFillet::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId()); + data()->addAttribute(PREVIOUS_VALUE, ModelAPI_AttributeDouble::typeId()); // initialize attribute not applicable for user data()->attribute(SketchPlugin_Constraint::ENTITY_C())->setInitialized(); + data()->attribute(PREVIOUS_VALUE)->setInitialized(); + std::dynamic_pointer_cast(data()->attribute(PREVIOUS_VALUE))->setValue(0.0); } void SketchPlugin_ConstraintFillet::execute() @@ -87,9 +92,17 @@ void SketchPlugin_ConstraintFillet::execute() FeaturePtr aFeature = aRC ? aRC->document()->feature(aRC) : std::dynamic_pointer_cast(aRefAttr->object()); if (aFeature == aFilletArcFeature) { - AttributeDoublePtr aRadius = std::dynamic_pointer_cast( - aSubFeature->attribute(SketchPlugin_Constraint::VALUE())); - aRadius->setValue(aFilletRadius); + // Update radius constraint only if the value is changed in fillet's attribute + double aPrevRadius = std::dynamic_pointer_cast( + aData->attribute(PREVIOUS_VALUE))->value(); + if (aFilletRadius != aPrevRadius) { + AttributeDoublePtr aRadius = std::dynamic_pointer_cast( + aSubFeature->attribute(SketchPlugin_Constraint::VALUE())); + aRadius->setValue(aFilletRadius); + std::dynamic_pointer_cast( + aData->attribute(PREVIOUS_VALUE))->setValue(aFilletRadius); + } + break; } } return;