#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>
#include <QSize>
#include <QShortcut>
#include <QScrollBar>
+#include <QFontMetrics>
#include <memory>
#include <string>
QVBoxLayout* aMainLay = new QVBoxLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
+ 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);
aMainLay->addWidget(myEditor);
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;
}