From 977e475670e22bc48846d3719cc8c4d08cfaa7d6 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 31 Aug 2015 19:34:46 +0300 Subject: [PATCH] The correction, to do not create a line by click in the viewer if the second click happens in the area of the first point. The first point has a coincidence to the previous point(sketch contour). --- src/GeomValidators/GeomValidators_Different.cpp | 6 ++++-- src/PartSet/PartSet_Module.cpp | 8 +++++++- src/PartSet/PartSet_WidgetPoint2d.cpp | 15 ++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/GeomValidators/GeomValidators_Different.cpp b/src/GeomValidators/GeomValidators_Different.cpp index dcad93164..85921c0d4 100644 --- a/src/GeomValidators/GeomValidators_Different.cpp +++ b/src/GeomValidators/GeomValidators_Different.cpp @@ -7,11 +7,14 @@ #include #include +#include #include #include #include +const double tolerance = 1e-7; + //================================================================================================= /* Help To extend GeomValidators_Different validator with new attribute types: @@ -22,8 +25,7 @@ To extend GeomValidators_Different validator with new attribute types: bool isEqual(const AttributePoint2DPtr& theLeft, const AttributePoint2DPtr& theRight) { - return theLeft->x() == theRight->x() && - theLeft->y() == theRight->y(); + return theLeft->pnt()->distance(theRight->pnt()) < tolerance; } bool isEqualAttributes(const AttributePtr& theLeft, const AttributePtr& theRight) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index afa03ce05..e339b8cda 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -523,7 +523,13 @@ void PartSet_Module::onNoMoreWidgets() if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) { if (myRestartingMode != RM_Forbided) myRestartingMode = RM_LastFeatureUsed; - anOperation->commit(); + XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); + if (anOpMgr->isApplyEnabled()) + anOperation->commit(); + else + anOperation->abort(); } } } diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index b65b07095..4add87d9d 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -325,13 +325,22 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous } } double aX, aY; + bool isProcessed = false; if (getPoint2d(aView, aShape, aX, aY)) { PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY); - emit vertexSelected(); - emit focusOutWidget(this); - return; + isProcessed = true; } else if (aShape.ShapeType() == TopAbs_EDGE) { setConstraintWith(aObject); + isProcessed = true; + } + if (isProcessed) { + // it is important to perform updateObject() in order to the current value is + // processed by Sketch Solver. Test case: line is created from a previous point + // to some distance, but in the area of the highlighting of the point. Constraint + // coincidence is created, after the solver is performed, the distance between the + // points of the line becomes less than the tolerance. Validator of the line returns + // false, the line will be aborted, but sketch stays valid. + updateObject(feature()); emit vertexSelected(); emit focusOutWidget(this); return; -- 2.39.2