Salome HOME
Highload tests added.
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPoint2dDistance.cpp
index 303d4508e07d04c6cf45b8cf8872ac837204c9ad..210f4bcba873de3765486f3fee698b88aad5e389 100644 (file)
@@ -2,8 +2,9 @@
 // Created:     23 June 2014
 // Author:      Vitaly Smetannikov
 
-#include "ModuleBase_WidgetPoint2dDistance.h"
-#include "ModuleBase_WidgetValueFeature.h"
+#include <ModuleBase_WidgetPoint2dDistance.h>
+#include <ModuleBase_WidgetValueFeature.h>
+#include <ModuleBase_DoubleSpinBox.h>
 
 #include <GeomAPI_Pnt2d.h>
 #include <Config_WidgetAPI.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDouble.h>
 
-#include <QDoubleSpinBox>
-
-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");
 }
@@ -29,11 +30,12 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue
   bool isDone = false;
 
   if (theValue) {
-    ModuleBase_WidgetValueFeature* aFeatureValue = 
-                         dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+    ModuleBase_WidgetValueFeature* aFeatureValue =
+        dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
-      boost::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
-      FeaturePtr aFeature = aFeatureValue->feature();
+      std::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
+      ObjectPtr aObject = aFeatureValue->object();
+      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
       if (aFeature && aPnt) {
         setPoint(aFeature, aPnt);
         isDone = true;
@@ -43,12 +45,14 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue
   return isDone;
 }
 
-void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boost::shared_ptr<GeomAPI_Pnt2d>& thePnt)
+void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
+                                                const std::shared_ptr<GeomAPI_Pnt2d>& thePnt)
 {
-  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;
+  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aData->attribute(myFirstPntName));
+  if (!aPoint)
+    return;
 
   double aRadius = thePnt->distance(aPoint->pnt());
   AttributeDoublePtr aReal = aData->real(attributeID());
@@ -56,4 +60,4 @@ void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boo
     aReal->setValue(aRadius);
     mySpinBox->setValue(aRadius);
   }
-}
\ No newline at end of file
+}