Salome HOME
Check selection for sketcher
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPoint2dDistance.cpp
index ed6ae6916f52e3e4e992a41f848762d8dba03173..871654bd21c99da06bc005768d8b300c1be95419 100644 (file)
@@ -32,8 +32,13 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue
     ModuleBase_WidgetValueFeature* aFeatureValue = 
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
-      setPoint(aFeatureValue->feature(), aFeatureValue->point());
-      isDone = true;
+      boost::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
+      ObjectPtr aObject = aFeatureValue->object();
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+      if (aFeature && aPnt) {
+        setPoint(aFeature, aPnt);
+        isDone = true;
+      }
     }
   }
   return isDone;
@@ -44,6 +49,8 @@ void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boo
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                                               (aData->attribute(myFirstPntName));
+  if (!aPoint) return;
+
   double aRadius = thePnt->distance(aPoint->pnt());
   AttributeDoublePtr aReal = aData->real(attributeID());
   if (aReal && (aReal->value() != aRadius)) {