]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement DumpPython functionality for VISU MULTIPR extension
authorapo <apo@opencascade.com>
Wed, 4 Jul 2007 09:22:30 +0000 (09:22 +0000)
committerapo <apo@opencascade.com>
Wed, 4 Jul 2007 09:22:30 +0000 (09:22 +0000)
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_MultiResult_i.cc
src/VISU_I/VISU_MultiResult_i.hh
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

index d40749fdc9ce3d6425c03134def70fa4e53d3a9f..733b0a8109b8dd2f0828df05b6bf82eaaa1aeb74 100644 (file)
@@ -122,6 +122,17 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------------------
+  inline
+  std::string
+  GetBoolean(bool theArgument)
+  {
+    if(theArgument)
+      return "True";
+
+    return "False";
+  }
+
   //---------------------------------------------------------------------------
   typedef void (*TDumpToPython)(SALOMEDS::Study_ptr theStudy,
                                CORBA::Boolean theIsPublished,
@@ -840,6 +851,7 @@ namespace VISU
     }
   }
 
+  
 
   //---------------------------------------------------------------------------
   void
@@ -880,15 +892,15 @@ namespace VISU
                theStr<<thePrefix<<aName<<" = aVisu.CreateResult('"<<aFileName<<"')"<<endl;
 
                theStr<<thePrefix<<aName<<".SetBuildGroups("<<
-                 aServant->IsGroupsDone()<<")"<<
+                 GetBoolean(aServant->IsGroupsDone())<<")"<<
                  endl;
 
                theStr<<thePrefix<<aName<<".SetBuildFields("<<
-                 aServant->IsFieldsDone()<<", "<<
-                 aServant->IsMinMaxDone()<<")"<<
+                 GetBoolean(aServant->IsFieldsDone())<<", "<<
+                 GetBoolean(aServant->IsMinMaxDone())<<")"<<
                  endl;
 
-               theStr<<thePrefix<<aName<<".Build(0,1)"<<endl;
+               theStr<<thePrefix<<aName<<".Build(False, True)"<<endl;
 
                theStr<<thePrefix<<"if "<<aName<<".IsDone() :"<<endl;
                break;
@@ -899,6 +911,38 @@ namespace VISU
              }
 
              thePrefix += PREFIX;
+             {
+               VISU::Result::EntityNames_var aMeshNames = aServant->GetMeshNames();
+               if (aMeshNames->length() > 0) {
+                 for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){
+                   CORBA::String_var aMeshName = aMeshNames[aMeshId];
+                   VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName);
+                   if (aParts->length() > 0) {
+                     for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){
+                       CORBA::String_var aPart = aParts[aPartId];
+                       VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart);
+                       std::string aParam;
+                       switch(aResolution){
+                       case VISU::Result::FULL:
+                         aParam = "VISU.Result.FULL";
+                         break;
+                       case VISU::Result::MEDIUM:
+                         aParam = "VISU.Result.MEDIUM";
+                         break;
+                       case VISU::Result::LOW:
+                         aParam = "VISU.Result.LOW";
+                         break;
+                       case VISU::Result::HIDDEN:
+                         aParam = "VISU.Result.HIDDEN";
+                         break;
+                       }
+                       theStr<<thePrefix<<aName<<".SetResolution('"<<aMeshName.in()<<"', '"<<aPart.in()<<"', "<<aParam<<")"<<endl;
+                     }
+                     theStr<<thePrefix<<endl;
+                   }
+                 }
+               }
+             }
 
              theArgumentName = aName;
              DumpChildrenToPython(theStudy,
index 794fbe963d89f421a560d9f40c1561c97ac74549..cd7ea864d28428bbb3c2af16fbf32d52581ccfbd 100644 (file)
@@ -477,6 +477,7 @@ VISU::MultiResult_i
     myMultiprObj.create(theFileName);
     if (myMultiprObj.isValidDistributedMEDFile()) {
       aTargetFileName = myMultiprObj.getSequentialMEDFilename();
+      SetFileName(aFileInfo.filePath().latin1());
       myIsBuildParts = true;
     }
   }
@@ -551,8 +552,12 @@ VISU::MultiResult_i
 //---------------------------------------------------------------
 VISU::Result::EntityNames* 
 VISU::MultiResult_i
-::GetParts(const char* theMeshName)
+::GetPartNames(const char* theMeshName)
 {
+  VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
+  if(!myIsBuildParts)
+    return aResult._retn();
+    
   MultiResult_i::TParts aMeshParts;
   MultiResult_i::TParts aParts = myMultiprObj.getParts();
   for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
@@ -569,7 +574,6 @@ VISU::MultiResult_i
       aMeshParts.push_back(aPartName);
   }
 
-  VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
   if(aMeshParts.empty())
     return aResult._retn();
 
@@ -588,6 +592,9 @@ VISU::MultiResult_i
                 const char* thePartName)
 {
   VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions();
+  if(!myIsBuildParts)
+    return aResult._retn();
+
   MultiResult_i::TParts aParts = myMultiprObj.getParts();
   for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
     const MultiResult_i::TPartName& aPartName = aParts[aPartID];
@@ -643,6 +650,9 @@ VISU::MultiResult_i
     return;
 
   TPartName2Resolution::iterator anIter = myPartName2Resolution.find(thePartName);
+  if(anIter == myPartName2Resolution.end())
+    return;
+
   VISU::Result::Resolution& aResolution = anIter->second;
   if(aResolution == theResolution)
     return;
index 40961be7acb70ecf1a67208a4efc3e8df28131db..b98c962c55450f2074561e24451f9bf47d325b1f 100644 (file)
@@ -64,7 +64,7 @@ namespace VISU
 
     virtual
     VISU::Result::EntityNames* 
-    GetParts(const char* theMeshName);
+    GetPartNames(const char* theMeshName);
 
     virtual
     VISU::Result::Resolutions* 
index 915c63fcc16d1425cc80214d77fa54acaec9353d..e1ea7dfedaec7bbf067cb33e6947e66a17e4ae6b 100644 (file)
@@ -372,7 +372,7 @@ VISU::Result_i
   aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
                   GetComment(),
                   myFileInfo.filePath().latin1(),
-                  myInitFileName.c_str()); // Restoring of Python dump
+                  GetFileName().c_str()); // Restoring of Python dump
   std::string aResultEntry = 
     CreateAttributes(myStudy,
                     aSComponentEntry.in(),
@@ -486,7 +486,8 @@ Create(const char* theFileName)
 {      
   try {
     myFileInfo.setFile(theFileName);
-    myInitFileName = myFileInfo.filePath().latin1();
+    if(!myIsBuildParts)
+      SetFileName(myFileInfo.filePath().latin1());
     myName = VISU::GenerateName(myFileInfo.fileName()).latin1();
     if(mySourceId == eRestoredFile){
       std::string aTmpDir(SALOMEDS_Tool::GetTmpDir());
@@ -534,7 +535,7 @@ VISU::Result_i
 
     string aCompDataType = GetComponentDataType(theMedSObject);
     myFileInfo.setFile(aCompDataType.c_str());
-    myInitFileName = aCompDataType;
+    SetFileName(aCompDataType);
 
     myName = VISU::GenerateName("aResult").latin1();
 
@@ -563,7 +564,7 @@ VISU::Result_i
 
     string aCompDataType = "MED";
     myFileInfo.setFile(aCompDataType.c_str());
-    myInitFileName = aCompDataType;
+    SetFileName(aCompDataType);
 
     myName = VISU::GenerateName("aResult").latin1();
 
@@ -716,7 +717,7 @@ VISU::Result_i
     myStudyDocument = mySObject->GetStudy();
     mySComponent = mySObject->GetFatherComponent();
     myName = VISU::Storable::FindValue(theMap, "myName").latin1();
-    myInitFileName = VISU::Storable::FindValue(theMap, "myInitFileName").latin1();
+    SetFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1());
     
     SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
     if (mySObject->FindSubObject(1, aRefSObj) &&
@@ -828,7 +829,7 @@ VISU::Result_i
       aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
                       GetComment(), 
                       myFileInfo.filePath().latin1(),
-                      myInitFileName.c_str()); // Restoring of Python dump
+                      GetFileName().c_str()); // Restoring of Python dump
       SALOMEDS::GenericAttribute_var anAttr;
       if (!theSObject->FindAttribute(anAttr, "AttributeString"))
        throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
@@ -1154,7 +1155,7 @@ VISU::Result_i
 
 VISU::Result::EntityNames* 
 VISU::Result_i
-::GetParts(const char* theMeshName)
+::GetPartNames(const char* theMeshName)
 {
   VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
   return aResult._retn();
@@ -1246,7 +1247,7 @@ VISU::Result_i
 {
   if(MYDEBUG) MESSAGE(GetComment());
   Storable::DataToStream(theStr,"myName",myName.c_str());
-  Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
+  Storable::DataToStream(theStr,"myInitFileName",GetFileName().c_str());
   Storable::DataToStream(theStr,"myCreationId",myCreationId);
   Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone);
   Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone);
@@ -1257,28 +1258,36 @@ VISU::Result_i
 //---------------------------------------------------------------
 const std::string&
 VISU::Result_i
-::GetName() const
+::GetFileName() const
 {
-  return myName;
+  return myInitFileName;
 }
 
 
-const QFileInfo&
+void 
 VISU::Result_i
-::GetFileInfo() const
+::SetFileName(const std::string& theFileName)
 {
-  return myFileInfo;
+  myInitFileName = theFileName;
 }
 
 
+//---------------------------------------------------------------
 const std::string&
 VISU::Result_i
-::GetFileName() const
+::GetName() const
 {
-  return myInitFileName;
+  return myName;
 }
 
 
+const QFileInfo&
+VISU::Result_i
+::GetFileInfo() const
+{
+  return myFileInfo;
+}
+
 const VISU::Result_i::ECreationId&
 VISU::Result_i
 ::GetCreationId() const
index 31bdfae5b837d867ba7063a9e0901c23ccfb8367..bfb6f9b7a462dc38223a97b0d29366fdb045836e 100644 (file)
@@ -160,7 +160,7 @@ namespace VISU
 
     virtual
     VISU::Result::EntityNames* 
-    GetParts(const char* theMeshName);
+    GetPartNames(const char* theMeshName);
 
     virtual
     VISU::Result::Resolutions* 
@@ -326,15 +326,20 @@ namespace VISU
             const std::string& theFieldName = "", 
             CORBA::Long theTimeStampNumber = -1);
 
+    virtual
+    const std::string& 
+    GetFileName() const;
+
+    virtual
+    void 
+    SetFileName(const std::string& theFileName);
+
     const std::string& 
     GetName() const;
 
     const QFileInfo& 
     GetFileInfo() const;
 
-    const std::string& 
-    GetFileName() const;
-
     const ECreationId& 
     GetCreationId() const;