X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_ConstraintDistancePrs.cpp;h=661061efd2da5e47baa6aba2c3459ec541d0c244;hb=1f2a62003cac25a91d8517f3af1940c774f10433;hp=809ea8c3c7f3ca0fb26d96d74e5e2d2b444b77f6;hpb=d727f40573f7a71044fea24b6af43b419ac19e51;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.cpp b/src/PartSet/PartSet_ConstraintDistancePrs.cpp index 809ea8c3c..661061efd 100644 --- a/src/PartSet/PartSet_ConstraintDistancePrs.cpp +++ b/src/PartSet/PartSet_ConstraintDistancePrs.cpp @@ -87,25 +87,11 @@ PartSet_SelectionMode PartSet_ConstraintDistancePrs::setPoint(double theX, doubl switch (theMode) { case SM_LastPoint: { - boost::shared_ptr aPoint_A = getFeaturePoint(feature(), - CONSTRAINT_ATTR_ENTITY_A); - boost::shared_ptr aPoint_B = getFeaturePoint(feature(), - CONSTRAINT_ATTR_ENTITY_B); - - boost::shared_ptr aPoint = boost::shared_ptr - (new GeomAPI_Pnt2d(theX, theY)); - boost::shared_ptr aFeatureLin = boost::shared_ptr - (new GeomAPI_Lin2d(aPoint_A->x(), aPoint_A->y(), - aPoint_B->x(), aPoint_B->y())); - boost::shared_ptr aResult = aFeatureLin->project(aPoint); - double aDistance = aPoint->distance(aResult); - - if (!aFeatureLin->isRight(aPoint)) - aDistance = -aDistance; - - AttributeDoublePtr aFlyoutAttr = boost::dynamic_pointer_cast - (feature()->data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE)); - aFlyoutAttr->setValue(aDistance); + boost::shared_ptr aFlyOutAttr = + boost::dynamic_pointer_cast(feature()->data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT)); + aFlyOutAttr->setValue(boost::shared_ptr(new GeomAPI_Pnt2d(theX, theY))); + + boost::shared_ptr aFlyOutPnt = aFlyOutAttr->pnt(); aMode = SM_DonePoint; } @@ -131,14 +117,21 @@ Handle(AIS_InteractiveObject) PartSet_ConstraintDistancePrs::createPresentation( if (!aPoint_A || !aPoint_B) return anAIS; + // fly out calculation boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr aFlyoutAttr = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE)); - double aFlyout = aFlyoutAttr->value(); + boost::shared_ptr aFlyOutAttr = + boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT)); + boost::shared_ptr aFlyOutPnt = aFlyOutAttr->pnt(); - boost::shared_ptr aValueAttr = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_VALUE)); - double aValue = aValueAttr->value(); + boost::shared_ptr aFeatureLin = boost::shared_ptr + (new GeomAPI_Lin2d(aPoint_A->x(), aPoint_A->y(), + aPoint_B->x(), aPoint_B->y())); + boost::shared_ptr aResult = aFeatureLin->project(aFlyOutPnt); + double aDistance = aFlyOutPnt->distance(aResult); + + if (!aFeatureLin->isRight(aFlyOutPnt)) + aDistance = -aDistance; + double aFlyout = aDistance; gp_Pnt aPoint1, aPoint2; PartSet_Tools::convertTo3D(aPoint_A->x(), aPoint_A->y(), theSketch, aPoint1); @@ -152,6 +145,14 @@ Handle(AIS_InteractiveObject) PartSet_ConstraintDistancePrs::createPresentation( aP2 = aPoint1; } + // value calculation + boost::shared_ptr aValueAttr = + boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_VALUE)); + double aValue = aValueAttr->value(); + if (aValue == 0) { // TODO! the default value + aValue = aP1.Distance(aP2); + } + if (anAIS.IsNull()) { Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension(aP1, aP2, aPlane); @@ -206,16 +207,6 @@ PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::stri return SM_FirstPoint; } -void PartSet_ConstraintDistancePrs::move(double theDeltaX, double theDeltaY) -{ -} - -double PartSet_ConstraintDistancePrs::distanceToPoint(FeaturePtr theFeature, - double theX, double theY) -{ - return 0; -} - boost::shared_ptr PartSet_ConstraintDistancePrs::findPoint(FeaturePtr theFeature, double theX, double theY) {