X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModuleBase%2FModuleBase_WidgetPoint2dDistance.cpp;h=210f4bcba873de3765486f3fee698b88aad5e389;hb=d29ed3f3f7c0e119d2917b2d4120aa7b473220f4;hp=7597fe126f3b86d447dfbb9ab18486cb5e46c751;hpb=d7e03da669a038a5a47ce8c8d878d8c81cf3faa5;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp index 7597fe126..210f4bcba 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp @@ -2,7 +2,9 @@ // Created: 23 June 2014 // Author: Vitaly Smetannikov -#include "ModuleBase_WidgetPoint2dDistance.h" +#include +#include +#include #include #include @@ -11,10 +13,10 @@ #include #include -#include - -ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData) - : ModuleBase_WidgetDoubleValue(theParent, theData) +ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) { myFirstPntName = theData->getProperty("first_point"); } @@ -23,15 +25,39 @@ ModuleBase_WidgetPoint2dDistance::~ModuleBase_WidgetPoint2dDistance() { } -void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boost::shared_ptr& thePnt) +bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue) +{ + bool isDone = false; + + if (theValue) { + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); + if (aFeatureValue) { + std::shared_ptr aPnt = aFeatureValue->point(); + ObjectPtr aObject = aFeatureValue->object(); + FeaturePtr aFeature = std::dynamic_pointer_cast(aObject); + if (aFeature && aPnt) { + setPoint(aFeature, aPnt); + isDone = true; + } + } + } + return isDone; +} + +void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, + const std::shared_ptr& thePnt) { - boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(myFirstPntName)); + std::shared_ptr aData = theFeature->data(); + std::shared_ptr aPoint = std::dynamic_pointer_cast( + aData->attribute(myFirstPntName)); + if (!aPoint) + return; + double aRadius = thePnt->distance(aPoint->pnt()); AttributeDoublePtr aReal = aData->real(attributeID()); if (aReal && (aReal->value() != aRadius)) { aReal->setValue(aRadius); mySpinBox->setValue(aRadius); } -} \ No newline at end of file +}