Salome HOME
0051789: TC7.2.0: NoteBook cannot update study
authoreap <eap@opencascade.com>
Fri, 29 Mar 2013 13:35:25 +0000 (13:35 +0000)
committereap <eap@opencascade.com>
Fri, 29 Mar 2013 13:35:25 +0000 (13:35 +0000)
Fix for "LayerDistribution" hypothesis

+    // string preceding an entry of object storing the attribute holding var names
+    static const char* ObjPrefix() { return " # OBJ: "; }

src/SMESH_I/SMESH_DumpPython.cxx
src/SMESH_I/SMESH_NoteBook.cxx
src/SMESH_I/SMESH_PythonDump.hxx

index 0e3ae652fd399f3c0767bf945130a3f03224f7f8..15770dcc866b3a28755f43f3ebfa53e10084daec 100644 (file)
@@ -73,6 +73,9 @@ namespace SMESH
       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
@@ -312,7 +315,7 @@ namespace SMESH
     if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
       myStream << "hyp_" << theArg->GetId();
     else
-      *this << CORBA::Object_ptr( theArg );
+      *this << aSObject;
     return *this;
   }
 
index 19470f6014396b66668ea285e9b0118253349aca..0168a96e7ef3db68b9eec1e9cc5ffefeeece906c 100644 (file)
@@ -250,11 +250,28 @@ void SMESH_NoteBook::ReplaceVariables()
     }
 
     // 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() == '$'
@@ -287,6 +304,8 @@ void SMESH_NoteBook::ReplaceVariables()
     }
 
     // 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);
index a78563c60b101af667757d4c9c68ee2b1d1b9dfa..d1ba4f4ce1d21af24578af0168b6e8ec68d698f8 100644 (file)
@@ -102,6 +102,8 @@ namespace SMESH
     // 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: "; }
   };
 
   // ===========================================================================================