void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent)
{
ModuleBase_DoubleSpinBox::showEvent(theEvent);
- //setText(myTextValue);
+ if (hasVariable(myTextValue)) {
+ setText(myTextValue);
+ }
}
void ModuleBase_WidgetDoubleValue::reset()
{
- if (isComputedDefault()) {
+ if (isComputedDefault() || mySpinBox->hasVariable()) {
return;
//if (myFeature->compute(myAttributeID))
// restoreValue();
- }
- else {
+ } else {
bool isOk;
double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
// reset the value just if there is a default value definition in the XML definition
std::string aTextRepr = aReal->text();
if (mySpinBox->hasVariable()) {
aTextRepr = mySpinBox->text().toStdString();
+ } else {
+ aTextRepr = "";
}
aReal->setText(aTextRepr);
updateObject(myFeature);
ParametersPlugin_Parameter::ParametersPlugin_Parameter()
{
myInterp = new ParametersPlugin_PyInterp();
+ myInterp->initialize();
}
ParametersPlugin_Parameter::~ParametersPlugin_Parameter()
double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, std::string& theError)
{
- myInterp->initialize();
+
std::list<std::string> anExprParams = myInterp->compile(theExpression);
// find expression's params in the model
std::list<std::string> aContext;
}
myInterp->extendLocalContext(aContext);
double result = myInterp->evaluate(theExpression, theError);
- myInterp->destroy();
+ myInterp->clearLocalContext();
return result;
}
}
}
+void ParametersPlugin_PyInterp::clearLocalContext()
+{
+ PyLockWrapper lck;
+ PyDict_Clear(_local_context);
+}
+
double ParametersPlugin_PyInterp::evaluate(const std::string& theExpression, std::string& theError)
{
std::list<std::string> compile(const std::string&);
void extendLocalContext(const std::list<std::string>&);
+ void clearLocalContext();
double evaluate(const std::string&, std::string&);
protected: