From fe94c2dd91946f3ad6d09b952a039395c4a31bb6 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 1 Jul 2015 16:59:54 +0300 Subject: [PATCH] Issue #694: Consider that only one of coordinates can contain a formula (not both as it is considered before) --- src/PartSet/PartSet_WidgetPoint2d.cpp | 32 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 62709442b..ab596837d 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -184,16 +184,36 @@ bool PartSet_WidgetPoint2D::restoreValue() std::shared_ptr aData = myFeature->data(); std::shared_ptr aPoint = std::dynamic_pointer_cast( aData->attribute(attributeID())); - std::string aTextX = aPoint->textX(); - std::string aTextY = aPoint->textY(); - if (aTextX.empty() || aTextY.empty()) { - double aX = aPoint->x(); + QString aTextX = QString::fromStdString(aPoint->textX()); + QString aTextY = QString::fromStdString(aPoint->textY()); + + bool isDouble = false; + double aVal = 0; + if (aTextX.isEmpty()) { ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x()); + } else { + aVal = aTextX.toDouble(&isDouble); + if (isDouble) + ModuleBase_Tools::setSpinValue(myXSpin, aVal); + else + ModuleBase_Tools::setSpinText(myXSpin, aTextX); + } + if (aTextY.isEmpty()) { ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y()); } else { - ModuleBase_Tools::setSpinText(myXSpin, QString::fromStdString(aTextX)); - ModuleBase_Tools::setSpinText(myYSpin, QString::fromStdString(aTextY)); + aVal = aTextY.toDouble(&isDouble); + if (isDouble) + ModuleBase_Tools::setSpinValue(myYSpin, aVal); + else + ModuleBase_Tools::setSpinText(myYSpin, aTextY); } + //if (aTextX.empty() || aTextY.empty()) { + // ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x()); + // ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y()); + //} else { + // ModuleBase_Tools::setSpinText(myXSpin, QString::fromStdString(aTextX)); + // ModuleBase_Tools::setSpinText(myYSpin, QString::fromStdString(aTextY)); + //} return true; } -- 2.39.2