From: asl Date: Mon, 7 Dec 2009 11:20:45 +0000 (+0000) Subject: 1. Parameter should update other parameters immediately after value/expression change X-Git-Tag: PHASE_17_Part1_V3~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1867787f3782f7ea3de404fa1d0fe1b322c09b36;p=modules%2Fkernel.git 1. Parameter should update other parameters immediately after value/expression change 2. If expression is invalid, the previous state of parameter should be restored --- diff --git a/src/Notebook/SALOME_Parameter.cxx b/src/Notebook/SALOME_Parameter.cxx index c62b79700..8fc4ca6aa 100644 --- a/src/Notebook/SALOME_Parameter.cxx +++ b/src/Notebook/SALOME_Parameter.cxx @@ -122,6 +122,12 @@ void SALOME_Parameter::Update( SALOME::Notebook_ptr /*theNotebook*/ ) } } +void SALOME_Parameter::Update() +{ + myNotebook->SetToUpdate( _this() ); + myNotebook->Update(); +} + void SALOME_Parameter::SetExpression( const char* theExpr ) { if( myIsAnonymous ) @@ -130,8 +136,7 @@ void SALOME_Parameter::SetExpression( const char* theExpr ) else { InternalSetExpression( theExpr ); - myIsCalculable = true; - myNotebook->SetToUpdate( _this() ); + Update(); } } @@ -144,7 +149,7 @@ void SALOME_Parameter::SetBoolean( CORBA::Boolean theValue ) { myResult = theValue; myIsCalculable = false; - myNotebook->SetToUpdate( _this() ); + Update(); } } @@ -157,7 +162,7 @@ void SALOME_Parameter::SetInteger( CORBA::Long theValue ) { myResult = (int)theValue; myIsCalculable = false; - myNotebook->SetToUpdate( _this() ); + Update(); } } @@ -170,7 +175,7 @@ void SALOME_Parameter::SetReal( CORBA::Double theValue ) { myResult = theValue; myIsCalculable = false; - myNotebook->SetToUpdate( _this() ); + Update(); } } @@ -183,7 +188,7 @@ void SALOME_Parameter::SetString( const char* theValue ) { myResult = theValue; myIsCalculable = false; - myNotebook->SetToUpdate( _this() ); + Update(); } } @@ -371,12 +376,27 @@ void SALOME_Parameter::ThrowTypeError( const std::string& theMsg ) void SALOME_Parameter::InternalSetExpression( const std::string& theExpr ) { - myExpr.setExpression( theExpr ); - AnalyzeError(); + std::string anOldExpr = myExpr.expression(); + bool anOldCalc = myIsCalculable; + try + { + myExpr.setExpression( theExpr ); + myIsCalculable = true; + AnalyzeError(); + } + catch( SALOME::ExpressionError anError ) + { + myExpr.setExpression( anOldExpr ); + myIsCalculable = anOldCalc; + throw anError; + } } void SALOME_Parameter::AnalyzeError() { + if( !myIsCalculable ) + return; + std::string aMsg; SALOME_EvalExprError anError = myExpr.parser()->error(); bool isCalcError = true; diff --git a/src/Notebook/SALOME_Parameter.hxx b/src/Notebook/SALOME_Parameter.hxx index 71165b6a3..e1380123e 100644 --- a/src/Notebook/SALOME_Parameter.hxx +++ b/src/Notebook/SALOME_Parameter.hxx @@ -89,6 +89,7 @@ private: void InternalSetExpression( const std::string& theExpr ); void AnalyzeError(); void SetId(); + void Update(); private: SALOME_Notebook* myNotebook;