From d3f983b3b69cfdeb02a2a2170f3df29719584e4c Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 15 Jul 2015 12:41:56 +0300 Subject: [PATCH] parameter problem. Scenario: dimension: parameter using, scenario: create a=100, sketch, line, line->length=a*2 edit length value by double click -> parameter is '3' --- src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp | 5 ++++- src/ModuleBase/ModuleBase_WidgetEditor.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index ba196af65..82a8800b3 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -116,8 +116,11 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom() const DataPtr aData = myFeature->data(); AttributeDoublePtr aReal = aData->real(attributeID()); if (!mySpinBox->hasVariable()) { - aReal->setValue(mySpinBox->value()); + // it is important to set the empty text value to the attribute before set the value + // because setValue tries to calculate the attrubyte bakye according to the + // attribute current text aReal->setText(""); + aReal->setValue(mySpinBox->value()); } else { // Here is a text of a real value or an expression. std::string aText = mySpinBox->text().toStdString(); diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 2b77ecafa..5aa9aa24f 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -52,7 +52,11 @@ void editedValue(double& outValue, QString& outText) ModuleBase_ParamSpinBox* aEditor = new ModuleBase_ParamSpinBox(&aDlg); aEditor->setMinimum(0); aEditor->setMaximum(DBL_MAX); - aEditor->setValue(outValue); + if (outText.isEmpty()) + aEditor->setValue(outValue); + else + aEditor->setText(outText); + aLay->addWidget(aEditor); aEditor->setFocus(); @@ -95,6 +99,9 @@ void ModuleBase_WidgetEditor::showPopupEditor() //QApplication::processEvents(); double aValue = mySpinBox->value(); QString aText; + if (mySpinBox->hasVariable()) + aText = mySpinBox->text(); + editedValue(aValue, aText); if (aText.isEmpty()) { ModuleBase_Tools::setSpinValue(mySpinBox, aValue); -- 2.39.2