SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
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);
if(MYDEBUG) MESSAGE(aString);
// prevent misuse of already treated variables
if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
myStream << "hyp_" << theArg->GetId();
else
- *this << CORBA::Object_ptr( theArg );
+ *this << aSObject;
return *this;
}
}
// NEW APPROACH
-
- TEntry2VarVecMap::iterator ent2varVec = _entry2VarsMap.find( aObject );
+ // 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().
+
+ // 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() )
{
- TCollection_AsciiString & cmdStr = aCmd->GetString();
const std::vector< std::string >& vars = ent2varVec->second;
int pos = 1, pos2;
// look for '$VarIndex$' in cmdStr. TVar::Quote() == '$'
}
// 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
TVariablesMap::const_iterator it = _objectMap.find(aObject);
// string used to temporary quote variable names in order
// not to confuse variables with string arguments
static char Quote() { return '$'; }
+ // string preceding an entry of object storing the attribute holding var names
+ static const char* ObjPrefix() { return " # OBJ: "; }
};
// ===========================================================================================