Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetDoubleValue.cpp
index 2b5437e46910ab5df783ff68054e89ec6303a9a7..4053a2a4b6c8d33f25b9c116462d7d9d3ca93555 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_Events.h>
 
 #include <QWidget>
-#include <QLayout>
+#include <QFormLayout>
 #include <QLabel>
 #include <QEvent>
 #include <QTimer>
@@ -37,18 +37,16 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
                                                            const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  myContainer = new QWidget(theParent);
-  QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
+  QFormLayout* aControlLay = new QFormLayout(this);
   ModuleBase_Tools::adjustMargins(aControlLay);
 
   QString aLabelText = QString::fromStdString(theData->widgetLabel());
   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
-  myLabel = new QLabel(aLabelText, myContainer);
+  myLabel = new QLabel(aLabelText, this);
   if (!aLabelIcon.isEmpty())
     myLabel->setPixmap(QPixmap(aLabelIcon));
-  aControlLay->addWidget(myLabel);
 
-  mySpinBox = new ModuleBase_DoubleSpinBox(myContainer);
+  mySpinBox = new ModuleBase_DoubleSpinBox(this);
   QString anObjName = QString::fromStdString(attributeID());
   mySpinBox->setObjectName(anObjName);
 
@@ -87,9 +85,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
   QString aTTip = QString::fromStdString(theData->widgetTooltip());
   mySpinBox->setToolTip(aTTip);
 
-  aControlLay->addWidget(mySpinBox);
-  aControlLay->setStretch(1, 1);
-
+  aControlLay->addRow(myLabel, mySpinBox);
   connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
 }
 
@@ -108,10 +104,11 @@ void ModuleBase_WidgetDoubleValue::reset()
     bool isOk;
     double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
     ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
+    storeValueCustom();
   }
 }
 
-bool ModuleBase_WidgetDoubleValue::storeValue() const
+bool ModuleBase_WidgetDoubleValue::storeValueCustom() const
 {
   DataPtr aData = myFeature->data();
   AttributeDoublePtr aReal = aData->real(attributeID());