X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetExprEditor.cpp;h=346b324c810e66a937512785773a0ca3b7d9f66f;hb=cdc2caa21375bc96aaad9bb7c3ee1140dac1d738;hp=01d7ba4d5ab8b0db8e9033d0f8da0ab896eab5da;hpb=150ef68b3ea2df3c2130a4f5ea8128ddb5c76048;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index 01d7ba4d5..346b324c8 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -10,11 +10,12 @@ #include #include -#include #include #include #include #include +#include +#include #include @@ -28,6 +29,7 @@ #include #include #include +#include #include #include @@ -152,6 +154,9 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor(QWidget* theParent, myResultLabel = new QLabel(this); myResultLabel->setWordWrap(true); + QFontMetrics fm(myResultLabel->font()); + myResultLabel->setMinimumHeight(fm.height() * 2); // set 2 line height as minimum + myResultLabel->setAlignment(Qt::AlignLeft|Qt::AlignBottom); aMainLay->addWidget(myResultLabel); myEditor = new ExpressionEditor(this); myEditor->setMinimumHeight(20); @@ -176,13 +181,24 @@ bool ModuleBase_WidgetExprEditor::storeValueCustom() const aStringAttr->setValue(aWidgetValue.toStdString()); updateObject(myFeature); - if(!myFeature->firstResult().get()) - return true; - - ResultParameterPtr aResult = + // Try to get the value + QString aStateMsg; + std::string anErrorMessage = myFeature->error(); + if (anErrorMessage.empty()) { + ResultParameterPtr aParam = std::dynamic_pointer_cast(myFeature->firstResult()); - AttributeStringPtr aErrorAttr = aResult->data()->string(ModelAPI_ResultParameter::STATE()); - myResultLabel->setText(QString::fromStdString(aErrorAttr->value())); + if(aParam.get()) { + AttributeDoublePtr aValueAttr = + aParam->data()->real(ModelAPI_ResultParameter::VALUE()); + if (aValueAttr.get()) { + double aValue = aValueAttr->value(); + aStateMsg = "Result: " + QString::number(aValue); + } + } + } else { + aStateMsg = QString::fromStdString(anErrorMessage); + } + myResultLabel->setText(aStateMsg); return true; }