- if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
- !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
- ObjectPtr aFeature = aRef->object();
- if (aFeature) {
- // set length value
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_START));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_END));
-
- double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_VALUE));
- aValueAttr->setValue(aLenght);
+ std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ // set length value
+ std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+ std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+
+ double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+
+ //std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+ // ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ //if(!aValueAttr->isInitialized()) {
+ // aValueAttr->setValue(aLenght);
+ //}
+
+ // the value should to be computed here, not in the getAISObject in order to change the model value
+ // inside the object transaction. This is important for creating a constraint by preselection.
+ // The display of the presentation in this case happens after the transaction commit
+ AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+ if (!aFlyOutAttribute->isInitialized()) {
+ compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());