Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Thu, 16 Apr 2015 14:18:15 +0000 (17:18 +0300)
committersbh <sergey.belash@opencascade.com>
Thu, 16 Apr 2015 14:18:15 +0000 (17:18 +0300)
src/ModuleBase/ModuleBase_ParamSpinBox.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ParametersPlugin/ParametersPlugin_Parameter.cpp
src/ParametersPlugin/ParametersPlugin_PyInterp.cpp
src/ParametersPlugin/ParametersPlugin_PyInterp.h

index 57e21b80b345375dec256c0fe0109f6260bf5957..925b1cc94c8508545041d6b63677ae962331aa76 100644 (file)
@@ -256,5 +256,7 @@ void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e)
 void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent)
 {
   ModuleBase_DoubleSpinBox::showEvent(theEvent);
-  //setText(myTextValue);
+  if (hasVariable(myTextValue)) {
+    setText(myTextValue);
+  }
 }
index a17ea26c9793ee4a8c3acab86dc7f5df40b0646b..551f9e7c8bfa2afa74aba0b190e449790bd122eb 100644 (file)
@@ -96,12 +96,11 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
 
 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
@@ -121,6 +120,8 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom() const
   std::string aTextRepr = aReal->text();
   if (mySpinBox->hasVariable()) {
     aTextRepr = mySpinBox->text().toStdString();
+  } else {
+    aTextRepr = "";
   }
   aReal->setText(aTextRepr);
   updateObject(myFeature);
index 70840ccff61641a071de1ab711ca1ba972df0a98..48f5d731236e99c4d008b66a7bccb0206c73d53f 100644 (file)
@@ -18,6 +18,7 @@
 ParametersPlugin_Parameter::ParametersPlugin_Parameter()
 {
   myInterp = new ParametersPlugin_PyInterp();
+  myInterp->initialize();
 }
 
 ParametersPlugin_Parameter::~ParametersPlugin_Parameter()
@@ -76,7 +77,7 @@ void ParametersPlugin_Parameter::execute()
 
 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;
@@ -92,6 +93,6 @@ double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, st
   }
   myInterp->extendLocalContext(aContext);
   double result = myInterp->evaluate(theExpression, theError);
-  myInterp->destroy();
+  myInterp->clearLocalContext();
   return result;
 }
index 7a5f42c4fe5243e9abf000951c50ce36971aded1..4afbfaa2a93f75a404e12d1f7cd57c2dd6bb12ee 100644 (file)
@@ -69,6 +69,12 @@ void ParametersPlugin_PyInterp::extendLocalContext(const std::list<std::string>&
   }
 }
 
+void ParametersPlugin_PyInterp::clearLocalContext()
+{
+  PyLockWrapper lck;
+  PyDict_Clear(_local_context);
+}
+
 
 double ParametersPlugin_PyInterp::evaluate(const std::string& theExpression, std::string& theError)
 {
index 4151f4e231cf192a3dd18c3cb26b06b7db318dd0..0e3cdee56401f7819ae60e5d31ce7a63102f2a99 100644 (file)
@@ -22,6 +22,7 @@ class PARAMETERSPLUGIN_EXPORT ParametersPlugin_PyInterp : public PyInterp_Interp
 
   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: