Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPoint2D.cpp
index 5ca2eb98d74d8c0075dd023a4c5876257b2c0a3b..d0ce1b11e50e5d7266f83a467664d6049494a1a0 100644 (file)
@@ -20,7 +20,7 @@
 
 ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, QString theTitle,
                                                    const std::string& theFeatureAttributeID)
-: ModuleBase_WidgetCustom(theParent), myFeatureAttributeID(theFeatureAttributeID)
+: ModuleBase_ModelWidget(theParent), myFeatureAttributeID(theFeatureAttributeID)
 {
   myGroupBox = new QGroupBox(theTitle, theParent);
   QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
@@ -60,13 +60,29 @@ ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
 {
 }
 
-void ModuleBase_WidgetPoint2D::store(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool ModuleBase_WidgetPoint2D::storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
 {
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myFeatureAttributeID));
 
+  bool isBlocked = this->blockSignals(true);
   aPoint->setValue(myXSpin->value(), myYSpin->value());
+  this->blockSignals(isBlocked);
+  return true;
+}
+
+bool ModuleBase_WidgetPoint2D::restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myFeatureAttributeID));
+
+  bool isBlocked = this->blockSignals(true);
+  myXSpin->setValue(aPoint->x());
+  myYSpin->setValue(aPoint->y());
+  this->blockSignals(isBlocked);
+  return true;
 }
 
 QWidget* ModuleBase_WidgetPoint2D::getControl() const