-void SketchPlugin_Circle::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<GeomAPI_Circ> aCirc = anEdge->circle();
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_ID()));
- aCenterAttr->setValue(sketch()->to2D(aCirc->center()));
- real(RADIUS_ID())->setValue(aCirc->radius());
- myIsUpdated = false;
+void SketchPlugin_Circle::attributeChanged(const std::string& theID) {
+ // the second condition for unability to move external segments anywhere
+ if (theID == EXTERNAL_ID() || isFixed()) {
+ std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+ // update arguments due to the selection value
+ if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
+ std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
+ std::shared_ptr<GeomAPI_Circ> aCirc = anEdge->circle();
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_ID()));
+ aCenterAttr->setValue(sketch()->to2D(aCirc->center()));
+ real(RADIUS_ID())->setValue(aCirc->radius());
+ }