From 6c271afeda4e8cd5286607ca85c500b65e0d54ad Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 3 Mar 2016 16:20:14 +0300 Subject: [PATCH] Rectangle correction to have coincidence with point/line selected for the first point of the rectangle. --- src/PartSet/PartSet_WidgetPoint2d.cpp | 12 +++++++++--- src/PartSet/PartSet_WidgetPoint2d.h | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 14294830c..49940a310 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -384,7 +384,7 @@ bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, return false; } -void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject) +bool PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject) { std::shared_ptr aFeaturePoint; if (feature()->isMacro()) { @@ -403,7 +403,7 @@ void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject) aFeaturePoint = std::dynamic_pointer_cast(aThisAttr); } if (!aFeaturePoint.get()) - return; + return false; // Create point-edge coincedence FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID()); @@ -420,6 +420,8 @@ void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject) // we need to flush created signal in order to coincidence is processed by solver Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + + return true; } void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) @@ -505,7 +507,11 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY); } else if (aShape.ShapeType() == TopAbs_EDGE) { - setConstraintWith(aObject); + if (!setConstraintWith(aObject)) { + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); + PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY); + setPoint(aX, aY); + } setValueState(Stored); // in case of edge selection, Apply state should also be updated FeaturePtr anObjectFeature = ModelAPI_Feature::feature(aObject); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index d4271e558..4395b6eb2 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -164,7 +164,8 @@ protected: /// Create a coincidence constraint between the attribute and the parameter object /// \theObject a result object - void setConstraintWith(const ObjectPtr& theObject); + /// \return true if succed + bool 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. It processes point, circle and arc features -- 2.39.2