bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
{
return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND ||
- theId == SKETCH_CIRCLE_KIND /*||
- theId == SKETCH_ARC_KIND*/ ||
+ theId == SKETCH_CIRCLE_KIND ||
+ theId == SKETCH_ARC_KIND ||
- theId == SKETCH_CONSTRAINT_DISTANCE_KIND /*||
+ theId == SKETCH_CONSTRAINT_DISTANCE_KIND ||
theId == SKETCH_CONSTRAINT_LENGTH_KIND ||
- theId == SKETCH_CONSTRAINT_RADIUS_KIND ||
+ theId == SKETCH_CONSTRAINT_RADIUS_KIND /*||
theId == SKETCH_CONSTRAINT_PARALLEL_KIND ||
theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND*/;
}
void SketchPlugin_ConstraintLength::initAttributes()
{
data()->addAttribute(CONSTRAINT_ATTR_VALUE, ModelAPI_AttributeDouble::type());
- //data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type());
- data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type());
data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
}
if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
return thePrevious;
- //boost::shared_ptr<ModelAPI_AttributeDouble> aFlyoutAttr =
- // boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
- //double aFlyout = aFlyoutAttr->value();
- boost::shared_ptr<ModelAPI_AttributeDouble> aFlyoutAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
- double aFlyout = aFlyoutAttr->value();
-
+ // fly out calculation
+ boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+ boost::shared_ptr<GeomAPI_Pnt2d> aFlyOutPnt = aFlyOutAttr->pnt();
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_START));
+ boost::shared_ptr<GeomDataAPI_Point2D> anEndPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_END));
+
+ boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = boost::shared_ptr<GeomAPI_Lin2d>
+ (new GeomAPI_Lin2d(aStartPoint->x(), aStartPoint->y(),
+ anEndPoint->x(), anEndPoint->y()));
+ boost::shared_ptr<GeomAPI_Pnt2d> aProjectedPoint = aFeatureLin->project(aFlyOutPnt);
+ double aDistance = aFlyOutPnt->distance(aProjectedPoint);
+ if (!aFeatureLin->isRight(aFlyOutPnt))
+ aDistance = -aDistance;
+ double aFlyout = aDistance;
+
+ // value
boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_VALUE));
double aValue = aValueAttr->value();