+boost::shared_ptr<ModelAPI_Attribute> ModuleBase_WidgetFeatureOrAttribute::findAttribute(
+ ModuleBase_WidgetValue* theValue)
+{
+ boost::shared_ptr<ModelAPI_Attribute> anAttribute;
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ if (!aFeatureValue)
+ return anAttribute;
+
+ boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
+ if (aValuePoint) {
+ ObjectPtr aObject = aFeatureValue->object();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
+ if (aFeature) {
+ // find the given point in the feature attributes
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes = aFeature->data()
+ ->attributes(GeomDataAPI_Point2D::type());
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes
+ .begin(), aLast = anAttiributes.end();
+ for (; anIt != aLast && !anAttribute; anIt++) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(*anIt);
+ if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
+ anAttribute = aCurPoint;
+ }
+ }
+ }
+ return anAttribute;