X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchPlugin%2FSketchPlugin_ConstraintLength.cpp;h=ff8a480b46ea314aad8fe37a1e8d0a78d7a5e0a8;hb=e2d663d27bdf897cebc9e5f0468214d531a57e3d;hp=e7ed5411ccb608c54e03e606d0b20b994ed4c0dd;hpb=3da12847434e80669f608d589074a181df87da4e;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index e7ed5411c..ff8a480b4 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -45,7 +45,9 @@ void SketchPlugin_ConstraintLength::execute() boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); - aValueAttr->setValue(aLenght); + if(!aValueAttr->isInitialized()) { + aValueAttr->setValue(aLenght); + } } } @@ -75,10 +77,17 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou boost::shared_ptr aPoint1 = sketch()->to3D(aStartPoint->x(), aStartPoint->y()); boost::shared_ptr aPoint2 = sketch()->to3D(anEndPoint->x(), anEndPoint->y()); - boost::shared_ptr aFlyoutPnt = - aFlyOutAttr->isInitialized() ? - sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : boost::shared_ptr(); - + boost::shared_ptr aFlyoutPnt = boost::shared_ptr(); + if (aFlyOutAttr->isInitialized()) { + aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()); + } else { + boost::shared_ptr aLine = + boost::shared_ptr(new GeomAPI_Lin2d(aStartPoint->pnt(), anEndPoint->pnt())); + double aDist = aPoint1->distance(aPoint2)/5.; + boost::shared_ptr aFPnt = aLine->shiftedLocation(aDist); + aFlyOutAttr->setValue(aFPnt); + aFlyoutPnt = sketch()->to3D(aFPnt->x(), aFPnt->y()); + } // value calculation boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); @@ -101,8 +110,8 @@ void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint->move(theDeltaX, theDeltaY); }