0051789: TC7.2.0: NoteBook cannot update study

Fix for "LayerDistribution" hypothesis

+    // string preceding an entry of object storing the attribute holding var names
+    static const char* ObjPrefix() { return " # OBJ: "; }
This commit is contained in:
eap 2013-03-29 13:35:25 +00:00
parent b72983c0ad
commit 21a7cf3d64
3 changed files with 27 additions and 3 deletions

View File

@ -73,6 +73,9 @@ namespace SMESH
SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy(); SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
if(!aStudy->_is_nil() && !aCollection.IsEmpty()) if(!aStudy->_is_nil() && !aCollection.IsEmpty())
{ {
const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
if ( !objEntry.empty() )
aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection); aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
if(MYDEBUG) MESSAGE(aString); if(MYDEBUG) MESSAGE(aString);
// prevent misuse of already treated variables // prevent misuse of already treated variables
@ -312,7 +315,7 @@ namespace SMESH
if(aSObject->_is_nil() && !CORBA::is_nil(theArg)) if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
myStream << "hyp_" << theArg->GetId(); myStream << "hyp_" << theArg->GetId();
else else
*this << CORBA::Object_ptr( theArg ); *this << aSObject;
return *this; return *this;
} }

View File

@ -250,11 +250,28 @@ void SMESH_NoteBook::ReplaceVariables()
} }
// NEW APPROACH // NEW APPROACH
// Names of variables are stored in the Study, in "StringAttribute". Python commands
// store zero-based indices (as e.g.'$1$') of variables within "StringAttribute";
// An entry of object storing "StringAttribute" is at the end of the command
// after TVar::ObjPrefix().
TEntry2VarVecMap::iterator ent2varVec = _entry2VarsMap.find( aObject ); // Get the entry of object storing "StringAttribute"
TCollection_AsciiString & cmdStr = aCmd->GetString();
TEntry2VarVecMap::iterator ent2varVec;
if (int pos = cmdStr.Location( SMESH::TVar::ObjPrefix(), 6, cmdStr.Length() ))
{
TCollection_AsciiString varHolderEntry =
cmdStr.SubString( pos + strlen( SMESH::TVar::ObjPrefix() ), cmdStr.Length() );
ent2varVec = _entry2VarsMap.find( varHolderEntry );
cmdStr.Split( pos - 1 );
}
else
{
ent2varVec = _entry2VarsMap.find( aObject );
}
// Set variables in cmdStr
if ( ent2varVec != _entry2VarsMap.end() && !ent2varVec->second.empty() ) if ( ent2varVec != _entry2VarsMap.end() && !ent2varVec->second.empty() )
{ {
TCollection_AsciiString & cmdStr = aCmd->GetString();
const std::vector< std::string >& vars = ent2varVec->second; const std::vector< std::string >& vars = ent2varVec->second;
int pos = 1, pos2; int pos = 1, pos2;
// look for '$VarIndex$' in cmdStr. TVar::Quote() == '$' // look for '$VarIndex$' in cmdStr. TVar::Quote() == '$'
@ -287,6 +304,8 @@ void SMESH_NoteBook::ReplaceVariables()
} }
// OLD APPROACH // OLD APPROACH
// Variable names are stored historically in "StringAttribute",
// i.e. for each command there is a set of either var names or separated empty places.
// check if method modifies the object itself // check if method modifies the object itself
TVariablesMap::const_iterator it = _objectMap.find(aObject); TVariablesMap::const_iterator it = _objectMap.find(aObject);

View File

@ -102,6 +102,8 @@ namespace SMESH
// string used to temporary quote variable names in order // string used to temporary quote variable names in order
// not to confuse variables with string arguments // not to confuse variables with string arguments
static char Quote() { return '$'; } static char Quote() { return '$'; }
// string preceding an entry of object storing the attribute holding var names
static const char* ObjPrefix() { return " # OBJ: "; }
}; };
// =========================================================================================== // ===========================================================================================