+ double aX, aY;
+ if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
+ // do not create a constraint to the point, which already used by the feature
+ // if the feature contains the point, focus is not switched
+ setPoint(aX, aY);
+ }
+ else {
+ if (getPoint2d(aView, aShape, aX, aY))
+ setPoint(aX, aY);
+ else
+ setValueState(Stored); // in case of edge selection, Apply state should also be updated
+ bool anOrphanPoint = aShape.ShapeType() == TopAbs_VERTEX ||
+ isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
+ if (anExternal) {
+ // we should not stop reentrant operation on external objects because
+ anOrphanPoint = true;
+ // they are not participate in the contour creation excepting external vertices
+ if (aShape.ShapeType() == TopAbs_VERTEX) {
+ FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject);
+ if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) {
+ anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY);
+ }
+ }
+ else {
+ // point is taken from mouse event and set in attribute.
+ // It should be done before setting
+ // coinident constraint to the external line. If a point is created, it should be
+ // in the mouse clicked point
+ gp_Pnt aPoint =
+ PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
+ double aX, anY;
+ PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY);
+ setPoint(aX, anY);
+ }
+ }
+ if (aFixedObject.get())
+ setConstraintWith(aFixedObject);
+ // fignal updated should be flushed in order to visualize possible created
+ // external objects e.g. selection of trihedron axis when input end arc point
+ updateObject(feature());
+
+ if (!anOrphanPoint)
+ emit vertexSelected(); // it stops the reentrant operation
+
+ emit focusOutWidget(this);
+ }
+ }
+ if (!anExternal) {
+ double aX, aY;
+ bool isProcessed = false;
+ if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
+ // when the point is selected, the coordinates of the point should be set into the attribute
+ // if the feature contains the point, focus is not switched
+ setPoint(aX, aY);
+ }
+ else {
+ 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.
+ bool isAuxiliaryFeature = false;
+ if (getPoint2d(aView, aShape, aX, aY)) {
+ setPoint(aX, aY);
+ feature()->execute();
+ PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
+ }
+ else if (aShape.ShapeType() == TopAbs_EDGE) {
+ // point is taken from mouse event and set in attribute. It should be done before setting
+ // coinident constraint to the external line. If a point is created, it should be in
+ // the mouse clicked point
+ gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
+ PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
+ setPoint(aX, aY);
+ setConstraintWith(aObject);
+ setValueState(Stored); // in case of edge selection, Apply state should also be updated
+ isAuxiliaryFeature = PartSet_Tools::isAuxiliarySketchEntity(aObject);
+ }
+ // 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());
+ if (!anOrphanPoint && !anExternal && !isAuxiliaryFeature)
+ emit vertexSelected();
+ emit focusOutWidget(this);