+
+void SketchPlugin_Line::attributeChanged() {
+ static bool myIsUpdated = false; // to avoid infinitive cycle on attrubtes change
+ boost::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+ if (aSelection && !myIsUpdated) { // update arguments due to the selection value
+ myIsUpdated = true;
+ boost::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(START_ID()));
+ aStartAttr->setValue(sketch()->to2D(anEdge->firstPoint()));
+ boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(END_ID()));
+ anEndAttr->setValue(sketch()->to2D(anEdge->lastPoint()));
+ myIsUpdated = false;
+ }
+}