- /*boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(CIRCLE_ATTR_CENTER));
- boost::shared_ptr<GeomAPI_Pnt2d> aCoordPoint(new GeomAPI_Pnt2d(theX, theY));
- double aRadius = aCoordPoint->distance(aPoint->pnt());
- PartSet_Tools::setFeatureValue(feature(), aRadius, CIRCLE_ATTR_RADIUS);
-
- aMode = SM_DonePoint;*/
- }
+ boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ FeaturePtr aFeature;
+ if (anAttr) {
+ aFeature = anAttr->feature();
+ if (aFeature->getKind() != SKETCH_LINE_KIND) {
+ aFeature = FeaturePtr();
+ }
+ }
+ boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+ (new GeomAPI_Pnt2d(theX, theY));
+ boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
+ boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
+ double aDistance = aPoint->distance(aResult);
+
+ double aStartX, aStartY;
+ PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
+
+ if (aFeatureLin->crossed(aPoint) < 0)
+ aDistance = -aDistance;
+
+ AttributeDoublePtr aFlyoutAttr =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+ aFlyoutAttr->setValue(aDistance);
+
+ aMode = SM_DonePoint;
+ }