- std::shared_ptr<GeomAPI_Pnt> aPoint1, aPoint2;
- std::shared_ptr<GeomDataAPI_Point2D> aStartPoint, anEndPoint;
- if (!getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint))
- return thePrevious; // not possible to show length because points are not defined
-
- AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
- if (!aFlyOutAttribute->isInitialized()) {
- if (!compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()))
- return thePrevious; // not possible to show length because points are not defined
- }
- std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFlyOutAttribute);
- std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y());
- // value calculation
- // TODO: has to be calculated on definition of reference object
- double aDistance = aPoint1->distance(aPoint2);
- std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- double aValue = aDistance;
- if (aValueAttr->isInitialized())
- aValue = aValueAttr->value();
- else
- aValueAttr->setValue(aValue);
- // End TODO
-
- AISObjectPtr anAIS = thePrevious;
- if (!anAIS)
- anAIS = AISObjectPtr(new GeomAPI_AISObject);
- std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
- anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);