X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetDoubleValue.cpp;h=9e222e9869d3d007ef441173dc7b041830977705;hb=872ac5e3e0196ad70c2a01a79bd070c9a7d4a2e6;hp=4053a2a4b6c8d33f25b9c116462d7d9d3ca93555;hpb=0c0573f4321deb94f9c5d3182a34fb672cc6e1f0;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 4053a2a4b..9e222e986 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); @@ -95,16 +96,19 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue() void ModuleBase_WidgetDoubleValue::reset() { - if (isComputedDefault()) { + if (isComputedDefault() || mySpinBox->hasVariable()) { return; //if (myFeature->compute(myAttributeID)) // restoreValue(); - } - else { + } else { bool isOk; double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0); - storeValueCustom(); + // 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(); + } } } @@ -113,6 +117,13 @@ 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(); + } else { + aTextRepr = ""; + } + aReal->setText(aTextRepr); updateObject(myFeature); return true; } @@ -121,9 +132,14 @@ 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()) { + bool isBlocked = mySpinBox->blockSignals(true); + mySpinBox->setText(QString::fromStdString(aTextRepr)); + mySpinBox->blockSignals(isBlocked); + } else { + ModuleBase_Tools::setSpinValue(mySpinBox, aRef->value()); + } return true; }