From: azv Date: Mon, 5 Dec 2016 09:11:23 +0000 (+0300) Subject: Correct processing parameter given as a value of angle in Python script (issue #1899) X-Git-Tag: V_2.6.0~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd9d4bb5ec157cf7a6f8118d197d5a4c85706d83;p=modules%2Fshaper.git Correct processing parameter given as a value of angle in Python script (issue #1899) Change processing of the Angle constraint when parameter is given as its value. --- diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index ffbf1bca9..930828a68 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -492,7 +492,7 @@ std::shared_ptr SketchAPI_Sketch::setAngle( fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT, aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID())); // fill the value before llines to avoid calculation of angle value by the Angle feature - fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); + fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); aFeature->execute(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp index e363ba32b..9743e6511 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp @@ -149,9 +149,9 @@ void SketchPlugin_ConstraintAngle::attributeChanged(const std::string& theID) myFlyoutUpdate = false; } else if (theID == SketchPlugin_ConstraintAngle::TYPE_ID()) { - std::shared_ptr aValueAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); double anAngle = calculateAngle(); + std::shared_ptr aValueAttr = std::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::VALUE())); aValueAttr->setValue(anAngle); } else if (theID == SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()) { @@ -190,11 +190,14 @@ double SketchPlugin_ConstraintAngle::calculateAngle() } double anAngle = anAng->angleDegree(); std::shared_ptr aValueAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::VALUE())); + ModelAPI_AttributeDouble>(data()->attribute(VALUE())); + std::shared_ptr anAngleValueAttr = std::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(ANGLE_VALUE_ID())); if (!aValueAttr->isInitialized()) aValueAttr->setValue(anAngle); /// an angle value should be corrected by the current angle type - anAngle = getAngleForType(anAngle); + anAngle = getAngleForType(anAngleValueAttr->text().empty() ? + anAngle : anAngleValueAttr->value()); boolean(ANGLE_REVERSED_FIRST_LINE_ID())->setValue(anAng->isReversed(0)); boolean(ANGLE_REVERSED_SECOND_LINE_ID())->setValue(anAng->isReversed(1)); return anAngle; diff --git a/src/SketchSolver/SketchSolver_ConstraintAngle.cpp b/src/SketchSolver/SketchSolver_ConstraintAngle.cpp index 7a6a4ac0f..f4207163b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintAngle.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintAngle.cpp @@ -8,6 +8,10 @@ #include #include +#include + +#include + #include void SketchSolver_ConstraintAngle::getAttributes( @@ -16,6 +20,7 @@ void SketchSolver_ConstraintAngle::getAttributes( SketchSolver_Constraint::getAttributes(theValue, theAttributes); myAngle = theValue; + myType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value(); } @@ -30,4 +35,10 @@ void SketchSolver_ConstraintAngle::adjustConstraint() myAngle = aConstraint->value(); aBuilder->adjustConstraint(aConstraint); myStorage->addConstraint(myBaseConstraint, aConstraint); + + int aType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value(); + if (aType != myType) { + myType = aType; + myStorage->setNeedToResolve(true); + } } diff --git a/src/SketchSolver/SketchSolver_ConstraintAngle.h b/src/SketchSolver/SketchSolver_ConstraintAngle.h index 3e979aa6d..cff6937c3 100644 --- a/src/SketchSolver/SketchSolver_ConstraintAngle.h +++ b/src/SketchSolver/SketchSolver_ConstraintAngle.h @@ -33,6 +33,7 @@ protected: private: double myAngle; + int myType; }; #endif