Salome HOME
Dump Python extension
[modules/geom.git] / src / GEOM_I / GEOM_DumpPython.cc
index 19e6ed621f3a7730969c0693dafadd3db05aadc5..25ffab45b60db6d5175f600ee9b53a299830af51 100644 (file)
@@ -15,7 +15,7 @@
 // License along with this library; if not, write to the Free Software 
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 #ifdef WNT
 #pragma warning( disable:4786 )
 #include <Standard_Stream.hxx>
 
 #include "GEOM_Gen_i.hh"
+
+//#include <GEOM_Engine.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <TColStd_HSequenceOfAsciiString.hxx>
 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
 
+#include <vector>
+#include <string>
+
 //=======================================================================
 //function : DumpPython
 //purpose  : 
@@ -48,6 +53,8 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
 
   Resource_DataMapOfAsciiStringAsciiString aMap;
 
+  TVariablesList aVariableMap;
+
   SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
   for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
     SALOMEDS::SObject_var aValue = Itr->Value();
@@ -59,14 +66,45 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
         CORBA::String_var aName = aValue->GetName();
         CORBA::String_var anEntry = GO->GetEntry();
        aMap.Bind( (char*)anEntry.in(), (char*)aName.in() );
+
+       //Find attribute with list of used notebook variables
+       SALOMEDS::GenericAttribute_var anAttr;
+       SALOMEDS::AttributeString_var anAttrStr;
+       vector<TVariable> aVariables;
+       if(aValue->FindAttribute(anAttr,"AttributeString")){
+         anAttrStr = SALOMEDS::AttributeString::_narrow(anAttr);
+         SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(anAttrStr->Value());
+         for(int i = 0; i < aSections->length(); i++) {
+           SALOMEDS::ListOfStrings aListOfVars = aSections[i];
+           for(int j = 0; j < aListOfVars.length(); j++) {
+             bool isVar = aStudy->IsVariable(aListOfVars[j].in());
+             TVariable aVar = TVariable( (char*)aListOfVars[j].in(), isVar );
+             aVariables.push_back(aVar);
+           }
+         }
+       }
+       aVariableMap.insert(pair<TCollection_AsciiString,vector<TVariable> >((char*)anEntry,aVariables));
       }
     }
   }
-
+  
   TCollection_AsciiString aScript =
-    "### This file is generated by SALOME automatically by dump python funcitonality\n"
+    "### This file is generated by SALOME automatically by dump python functionality\n"
       "### of GEOM component\n\n";
-  aScript += _impl->DumpPython(aStudy->StudyId(), aMap, isPublished, isValidScript);
+  aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, isPublished, isValidScript);
+
+  if (isPublished)
+  {
+    //Output the script that sets up the visual parameters.
+    char* script = aStudy->GetDefaultScript(ComponentDataType(), "\t");
+    if (script && strlen(script) > 0) {
+      aScript += "\n\t### Store presentation parameters of displayed objects\n";
+      aScript += script;
+      CORBA::string_free(script);
+    }
+  }
+
+  aScript += "\n\tpass\n";
 
   int aLen = aScript.Length(); 
   unsigned char* aBuffer = new unsigned char[aLen+1];