X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_FeatureLinePrs.cpp;h=4aa747a997ce4208246531c72af5c9cd6f21c996;hb=7abdb925235d8208608a26fe85eeb599dfa56653;hp=bc7e2d14433cc953f5594d6a0f3dfe1563527da6;hpb=6a74c9552a6deed91fa0f00eb4d1996d788b6bd3;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_FeatureLinePrs.cpp b/src/PartSet/PartSet_FeatureLinePrs.cpp index bc7e2d144..4aa747a99 100644 --- a/src/PartSet/PartSet_FeatureLinePrs.cpp +++ b/src/PartSet/PartSet_FeatureLinePrs.cpp @@ -35,24 +35,6 @@ std::string PartSet_FeatureLinePrs::getKind() return SKETCH_LINE_KIND; } -void PartSet_FeatureLinePrs::initFeature(FeaturePtr theFeature) -{ - if (feature() && theFeature) - { - // use the last point of the previous feature as the first of the new one - boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr anInitPoint = boost::dynamic_pointer_cast - (aData->attribute(LINE_ATTR_END)); - PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START); - PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END); - - aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(LINE_ATTR_START)); - PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint); - } -} - PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY, const PartSet_SelectionMode& theMode) { @@ -76,6 +58,27 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY, return aMode; } +PartSet_SelectionMode PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) +{ + PartSet_SelectionMode aMode = theMode; + if (feature() && theFeature && theMode == SM_FirstPoint) + { + // use the last point of the previous feature as the first of the new one + boost::shared_ptr aData = theFeature->data(); + boost::shared_ptr anInitPoint = boost::dynamic_pointer_cast + (aData->attribute(LINE_ATTR_END)); + PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START); + PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END); + + aData = feature()->data(); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast + (aData->attribute(LINE_ATTR_START)); + PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint); + aMode = SM_SecondPoint; + } + return aMode; +} + std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const { std::string aAttribute; @@ -104,21 +107,6 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::getNextMode(const std::string& the return aMode; } -void PartSet_FeatureLinePrs::move(double theDeltaX, double theDeltaY) -{ - boost::shared_ptr aData = feature()->data(); - if (!aData->isValid()) - return; - - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_START)); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); - - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_END)); - aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); -} - void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature, const PartSet_SelectionMode& theMode, const gp_Pnt& thePoint, Handle(V3d_View) theView, @@ -160,33 +148,6 @@ void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature, } } -double PartSet_FeatureLinePrs::distanceToPoint(FeaturePtr theFeature, - double theX, double theY) -{ - double aDelta = 0; - if (!theFeature || theFeature->getKind() != getKind()) - return aDelta; - - boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_START)); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_END)); - - GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y()); - boost::shared_ptr aPoint = boost::shared_ptr(new GeomAPI_Pnt2d(theX, theY)); - - if (false/*projection*/) { // TODO: if it has not been necessary, remove this block - boost::shared_ptr aResult = aLin2d.project(aPoint); - aDelta = aResult->distance(aPoint); - } - else { // distance - aDelta = aLin2d.distance(aPoint); - } - - return aDelta; -} - boost::shared_ptr PartSet_FeatureLinePrs::findPoint(FeaturePtr theFeature, double theX, double theY) {