From 8da5ddb2feeb29c481a51530a435be524bf720e9 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 18 Nov 2015 15:37:59 +0300 Subject: [PATCH 1/1] #1095 line does not stop on arc end --- src/PartSet/PartSet_WidgetPoint2d.cpp | 17 ++++++++++++++--- src/PartSet/PartSet_WidgetPoint2d.h | 9 +++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 7f44ef948..6e78ed9d7 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -370,7 +370,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous else { if (getPoint2d(aView, aShape, aX, aY)) setPoint(aX, aY); - bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch); + bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY); setConstraintWith(aObject); if (!anOrphanPoint) emit vertexSelected(); @@ -386,7 +386,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous setPoint(aX, aY); } else { - bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch); + bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY); // do not set a coincidence constraint in the attribute if the feature contains a point // with the same coordinates. It is important for line creation in order to do not set // the same constraints for the same points, oterwise the result line has zero length. @@ -520,7 +520,8 @@ bool PartSet_WidgetPoint2D::processEnter() } bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature, - const CompositeFeaturePtr& theSketch) + const CompositeFeaturePtr& theSketch, + double theX, double theY) { bool anOrphanPoint = false; if (theFeature.get()) { @@ -537,6 +538,16 @@ bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature, aPointAttr = std::dynamic_pointer_cast( theFeature->attribute(SketchPlugin_Arc::CENTER_ID())); + /// check that the geometry point with the given coordinates is the checked point + /// e.g. in arc the (x,y) point can not coicide to the center point and it automatically + /// means that this point is not an orphant one. + if (aPointAttr.get()) { + std::shared_ptr aCheckedPoint = std::shared_ptr( + new GeomAPI_Pnt2d(theX, theY)); + if (!aCheckedPoint->isEqual(aPointAttr->pnt())) + return anOrphanPoint; + } + if (aPointAttr.get()) { std::shared_ptr aPoint = aPointAttr->pnt(); FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index 9a54efa4b..c1b0d0576 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -148,11 +148,16 @@ protected: void setConstraintWith(const ObjectPtr& theObject); /// Returns if the feature is an orphan point, circle or an arc. Returns true if it - /// has no a coincident to other lines. In Circle and arc only center points are processed. + /// has no a coincident to other lines. It processes point, circle and arc features + /// In circle an arc features, only centers are processed, for other points, it returns + /// that the point is not an orphan. /// \param theFeature a checked feature /// \param theSketch a sketch + /// \param theX an X coordinate of the point + /// \param theY an Y coordinate of the point /// \return boolean result - static bool isOrphanPoint(const FeaturePtr& theFeature, const CompositeFeaturePtr& theSketch); + static bool isOrphanPoint(const FeaturePtr& theFeature, const CompositeFeaturePtr& theSketch, + double theX, double theY); protected: ModuleBase_IWorkshop* myWorkshop; ///< workshop -- 2.39.2