X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetDoubleValue.cpp;h=a17ea26c9793ee4a8c3acab86dc7f5df40b0646b;hb=af851100774c4ff33b515c884abe0cd03c3f0528;hp=e314234a247fed9b6d169a7eac38a2079fb78c9a;hpb=b25922145a97fccf8d2613d0ef52a283d3ce0987;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index e314234a2..a17ea26c9 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -5,10 +5,11 @@ // Author: Vitaly Smetannikov #include -#include +#include #include #include +#include #include #include @@ -46,7 +47,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, if (!aLabelIcon.isEmpty()) myLabel->setPixmap(QPixmap(aLabelIcon)); - mySpinBox = new ModuleBase_DoubleSpinBox(this); + mySpinBox = new ModuleBase_ParamSpinBox(this); QString anObjName = QString::fromStdString(attributeID()); mySpinBox->setObjectName(anObjName); @@ -103,15 +104,25 @@ void ModuleBase_WidgetDoubleValue::reset() else { bool isOk; double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0); + // reset the value just if there is a default value definition in the XML definition + // if the double value can not be found by the default value, do nothing + if (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()); aReal->setValue(mySpinBox->value()); + std::string aTextRepr = aReal->text(); + if (mySpinBox->hasVariable()) { + aTextRepr = mySpinBox->text().toStdString(); + } + aReal->setText(aTextRepr); updateObject(myFeature); return true; } @@ -120,9 +131,12 @@ bool ModuleBase_WidgetDoubleValue::restoreValue() { DataPtr aData = myFeature->data(); AttributeDoublePtr aRef = aData->real(attributeID()); - - ModuleBase_Tools::setSpinValue(mySpinBox, aRef->value()); - + std::string aTextRepr = aRef->text(); + if (!aTextRepr.empty()) { + mySpinBox->setText(QString::fromStdString(aTextRepr)); + } else { + ModuleBase_Tools::setSpinValue(mySpinBox, aRef->value()); + } return true; }