Salome HOME
#1095 line does not stop on arc end
authornds <nds@opencascade.com>
Wed, 18 Nov 2015 12:37:59 +0000 (15:37 +0300)
committernds <nds@opencascade.com>
Wed, 18 Nov 2015 12:38:24 +0000 (15:38 +0300)
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 7f44ef9489f8faf0c7e72fffcd0c2a49bfed42df..6e78ed9d7c39d8c7c5b4403415b7c5e5b1e6a1f6 100644 (file)
@@ -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<GeomDataAPI_Point2D>(
                                        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<GeomAPI_Pnt2d> aCheckedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
+                                                    new GeomAPI_Pnt2d(theX, theY));
+      if (!aCheckedPoint->isEqual(aPointAttr->pnt()))
+        return anOrphanPoint;
+    }
+
     if (aPointAttr.get()) {
       std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
       FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint);
index 9a54efa4b14075d1837a79361d29260632fa5008..c1b0d0576c8609c9c6232e55b580bf81eb42d7ad 100755 (executable)
@@ -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