]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The correction, to do not create a line by click in the viewer if the second click...
authornds <nds@opencascade.com>
Mon, 31 Aug 2015 16:34:46 +0000 (19:34 +0300)
committernds <nds@opencascade.com>
Mon, 31 Aug 2015 16:35:28 +0000 (19:35 +0300)
src/GeomValidators/GeomValidators_Different.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp

index dcad93164ad65ecc2a69534b01aaf1b44aef0fd8..85921c0d43a67620fc8800a9eff5e50397c9621c 100644 (file)
@@ -7,11 +7,14 @@
 #include <GeomValidators_Different.h>
 
 #include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Pnt2d.h>
 
 #include <algorithm>
 #include <map>
 #include <list>
 
+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)
index afa03ce055134516a11a457d5440f597601525ee..e339b8cda9bea21623b53ca72d1704f485e29b07 100755 (executable)
@@ -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<XGUI_ModuleConnector*>(workshop());
+      XGUI_Workshop* aWorkshop = aConnector->workshop();
+      XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
+      if (anOpMgr->isApplyEnabled())
+        anOperation->commit();
+      else
+        anOperation->abort();
     }
   }
 }
index b65b07095c578401be16febd6f9663ecbe3488f5..4add87d9dd6feb2f44507fd05002d2c0ce473aea 100644 (file)
@@ -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;