#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:
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)
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();
}
}
}
}
}
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;