From 2e0baf44706fc850ef58e781adff18cf49f2e46a Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 19 Nov 2008 17:15:32 +0000 Subject: [PATCH] Now study declared as being modifyed after change variables. --- .../SALOMEDSImpl_GenericVariable.cxx | 45 +++++-------------- .../SALOMEDSImpl_GenericVariable.hxx | 8 +--- .../SALOMEDSImpl_ScalarVariable.cxx | 8 ++-- .../SALOMEDSImpl_ScalarVariable.hxx | 2 +- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 12 +++-- 5 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx index e266329c4..7de967c2c 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx @@ -75,9 +75,13 @@ string SALOMEDSImpl_GenericVariable::Name() const * Purpose : */ //============================================================================ -void SALOMEDSImpl_GenericVariable::setType(const SALOMEDSImpl_GenericVariable::VariableTypes theType) +bool SALOMEDSImpl_GenericVariable::setType(const SALOMEDSImpl_GenericVariable::VariableTypes theType) { + if(_type == theType) + return false; + _type = theType; + return true; } //============================================================================ @@ -85,44 +89,15 @@ void SALOMEDSImpl_GenericVariable::setType(const SALOMEDSImpl_GenericVariable::V * Purpose : */ //============================================================================ -void SALOMEDSImpl_GenericVariable::setName(const std::string& theName) +bool SALOMEDSImpl_GenericVariable::setName(const std::string& theName) { - _name = theName; -} + if(_name.compare(theName) == 0) + return false; -//============================================================================ -/*! Function : CheckLocked - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_GenericVariable::CheckLocked() -{ - DF_Label aLabel = DF_Label(); - if(aLabel.IsNull()) return; - - SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel); - if(!aStudy) return; - if(aStudy->IsLocked()) { - aStudy->_errorCode = "LockProtection"; - throw LockProtection("LockProtection"); - } -} - -//============================================================================ -/*! Function : SetModifyFlag - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_GenericVariable::SetModifyFlag() -{ - DF_Label aLabel = DF_Label(); - if(aLabel.IsNull()) return; - - SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel); - if(aStudy) aStudy->Modify(); + _name = theName; + return true; } - //============================================================================ /*! Function : String2VariableType * Purpose : diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx index c5166f217..5dc385cc0 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx @@ -46,13 +46,9 @@ class SALOMEDSIMPL_EXPORT SALOMEDSImpl_GenericVariable static VariableTypes String2VariableType(const std::string& theStrType); - void setType(const VariableTypes theType); + bool setType(const VariableTypes theType); - void setName(const std::string& theName); - - virtual void CheckLocked(); - - virtual void SetModifyFlag(); + bool setName(const std::string& theName); virtual std::string Save() const; virtual std::string SaveToScript() const; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx index 683dbbf16..c6fa46c82 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx @@ -49,16 +49,14 @@ SALOMEDSImpl_ScalarVariable::~SALOMEDSImpl_ScalarVariable(){} * Purpose : */ //============================================================================ -void SALOMEDSImpl_ScalarVariable::setValue(const double theValue) +bool SALOMEDSImpl_ScalarVariable::setValue(const double theValue) { - CheckLocked(); if(myValue == theValue) - return; + return false; myValue = theValue; - - SetModifyFlag(); + return true; } //============================================================================ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx index b13ddeed2..9684f6e06 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx @@ -35,7 +35,7 @@ public: const std::string& theName); ~SALOMEDSImpl_ScalarVariable(); - void setValue(const double theValue); + bool setValue(const double theValue); double getValue() const; virtual std::string Save() const; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index dca7d19da..8b4a1fd40 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1554,7 +1554,7 @@ void SALOMEDSImpl_Study::SetVariable(const string& theVarName, const double theValue, const SALOMEDSImpl_GenericVariable::VariableTypes theType) { - + bool modified = false; SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); if( aGVar == NULL ) { @@ -1563,14 +1563,16 @@ void SALOMEDSImpl_Study::SetVariable(const string& theVarName, aSVar->setValue(theValue); myNoteBookVars.push_back(aSVar); + modified = true; } else { if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast(aGVar)) { - aSVar->setValue(theValue); - if(aSVar->Type() != theType) - aSVar->setType(theType); + modified = aSVar->setValue(theValue) || modified; + modified = aSVar->setType(theType) || modified; } } + if(modified) + Modify(); } //============================================================================ @@ -1680,6 +1682,7 @@ bool SALOMEDSImpl_Study::RemoveVariable(const string& theVarName) if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 ) { myNoteBookVars.erase( it ); + Modify(); break; } } @@ -1707,6 +1710,7 @@ bool SALOMEDSImpl_Study::RenameVariable(const string& theVarName, const string& if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 ) { aVariableRef->setName( theNewVarName ); + Modify(); break; } } -- 2.39.2