From 3c6d69dbcde7450292cdf3b7bde8df716d8f577e Mon Sep 17 00:00:00 2001 From: sbh Date: Thu, 16 Apr 2015 16:36:25 +0300 Subject: [PATCH] Issue #451: restore variable in editor --- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 4 +++- src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 57e21b80b..925b1cc94 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -256,5 +256,7 @@ void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e) void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent) { ModuleBase_DoubleSpinBox::showEvent(theEvent); - //setText(myTextValue); + if (hasVariable(myTextValue)) { + setText(myTextValue); + } } diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index a17ea26c9..551f9e7c8 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -96,12 +96,11 @@ 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); // reset the value just if there is a default value definition in the XML definition @@ -121,6 +120,8 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom() const std::string aTextRepr = aReal->text(); if (mySpinBox->hasVariable()) { aTextRepr = mySpinBox->text().toStdString(); + } else { + aTextRepr = ""; } aReal->setText(aTextRepr); updateObject(myFeature); -- 2.39.2