Salome HOME
Hide "by general equation" case for plane creation
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetExprEditor.cpp
index 64ca2e312ca86254fae29a9ef714f6902c1a50da..f96eec92c48a15a98066430cb477ef62d8873925 100644 (file)
 #include <ModuleBase_WidgetExprEditor.h>
 #include <ModuleBase_Tools.h>
 
-#include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultParameter.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeDouble.h>
 
 #include <Config_WidgetAPI.h>
 
@@ -149,6 +151,9 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor(QWidget* theParent,
   QVBoxLayout* aMainLay = new QVBoxLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
 
+  myResultLabel = new QLabel(this);
+  myResultLabel->setWordWrap(true);
+  aMainLay->addWidget(myResultLabel);
   myEditor = new ExpressionEditor(this);
   myEditor->setMinimumHeight(20);
   aMainLay->addWidget(myEditor);
@@ -171,6 +176,25 @@ bool ModuleBase_WidgetExprEditor::storeValueCustom() const
   QString aWidgetValue = myEditor->toPlainText();
   aStringAttr->setValue(aWidgetValue.toStdString());
   updateObject(myFeature);
+
+  // Try to get the value
+  QString aStateMsg;
+  std::string anErrorMessage = myFeature->error();
+  if (anErrorMessage.empty()) {
+    ResultParameterPtr aParam =
+      std::dynamic_pointer_cast<ModelAPI_ResultParameter>(myFeature->firstResult());
+    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;
 }