X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Arc.cpp;h=7d285d079dd1cfa00f5c3494330be7ef428054cf;hb=c7a5ff20294ae8270bfb9120b8887f0c9959d658;hp=22898f95ee77310535f117643b59137e85b2299d;hpb=25fa530187db0a4f9f5662b3bb064853846d76ed;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 22898f95e..7d285d079 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -29,12 +29,6 @@ const double paramTolerance = 1.e-4; const double PI =3.141592653589793238463; -static const std::string& INVERSED_ID() -{ - static const std::string MY_INVERSED_ID("InversedArc"); - return MY_INVERSED_ID; -} - SketchPlugin_Arc::SketchPlugin_Arc() : SketchPlugin_SketchEntity() { @@ -272,33 +266,33 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt())); std::shared_ptr aProjection = aCircleForArc->project(anEndAttr->pnt()); if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance) { - // issue #855: trying to update only not-updated coordinate if it is possible - /* - if (abs(myXEndBefore - anEndAttr->x()) < 1.e-10) { // keep Y unchanged - double aVy = aCenterAttr->y() - anEndAttr->y(); - double aVy2 = aVy * aVy; - double aR2 = aCircleForArc->radius() * aCircleForArc->radius(); - if (aVy2 <= aR2) { - double aDX = sqrt(aR2 - aVy * aVy); - if (anEndAttr->x() > aCenterAttr->x()) - aProjection->setX(aCenterAttr->x() + aDX); - else - aProjection->setX(aCenterAttr->x() - aDX); - aProjection->setY(anEndAttr->y()); - } - } else if (abs(myYEndBefore - anEndAttr->y()) < 1.e-10) { // keep X unchanged - double aVx = aCenterAttr->x() - anEndAttr->x(); - double aVx2 = aVx * aVx; - double aR2 = aCircleForArc->radius() * aCircleForArc->radius(); - if (aVx2 <= aR2) { - double aDY = sqrt(aR2 - aVx * aVx); - if (anEndAttr->y() > aCenterAttr->y()) - aProjection->setY(aCenterAttr->y() + aDY); - else - aProjection->setY(aCenterAttr->y() - aDY); - aProjection->setX(anEndAttr->x()); + if (!isStable()) { // issue #855: trying to update only not-updated coordinate if it is possible + if (fabs(myXEndBefore - anEndAttr->x()) < 1.e-10) { // keep Y unchanged + double aVy = aCenterAttr->y() - anEndAttr->y(); + double aVy2 = aVy * aVy; + double aR2 = aCircleForArc->radius() * aCircleForArc->radius(); + if (aVy2 <= aR2) { + double aDX = sqrt(aR2 - aVy * aVy); + if (anEndAttr->x() > aCenterAttr->x()) + aProjection->setX(aCenterAttr->x() + aDX); + else + aProjection->setX(aCenterAttr->x() - aDX); + aProjection->setY(anEndAttr->y()); + } + } else if (fabs(myYEndBefore - anEndAttr->y()) < 1.e-10) { // keep X unchanged + double aVx = aCenterAttr->x() - anEndAttr->x(); + double aVx2 = aVx * aVx; + double aR2 = aCircleForArc->radius() * aCircleForArc->radius(); + if (aVx2 <= aR2) { + double aDY = sqrt(aR2 - aVx * aVx); + if (anEndAttr->y() > aCenterAttr->y()) + aProjection->setY(aCenterAttr->y() + aDY); + else + aProjection->setY(aCenterAttr->y() - aDY); + aProjection->setX(anEndAttr->x()); + } } - }*/ + } anEndAttr->setValue(aProjection); } @@ -325,3 +319,14 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) myEndUpdate = false; } } + +void SketchPlugin_Arc::setReversed(bool isReversed) +{ + std::dynamic_pointer_cast(attribute(INVERSED_ID()))->setValue(isReversed); + myParamBefore = 0.0; +} + +bool SketchPlugin_Arc::isReversed() +{ + return std::dynamic_pointer_cast(attribute(INVERSED_ID()))->value(); +}