Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPoint2D.cpp
index 9cd0a47c975e0a63ab269386da4afef39926c7e4..d0ce1b11e50e5d7266f83a467664d6049494a1a0 100644 (file)
 #include <QDoubleSpinBox>
 #include <QLabel>
 
+#include <cfloat>
+#include <climits>
+
 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);
@@ -57,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