]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix bug 10040: 'Dump Study' doesn't restore the name of presentation in Post-Pro.
authorjfa <jfa@opencascade.com>
Thu, 13 Apr 2006 08:09:28 +0000 (08:09 +0000)
committerjfa <jfa@opencascade.com>
Thu, 13 Apr 2006 08:09:28 +0000 (08:09 +0000)
idl/VISU_Gen.idl
src/ENGINE/VISU_Engine_i.cc
src/ENGINE/VISU_Engine_i.hh
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh

index af87ae1cc8f97d2988ff19a83da0fca3581f2a62..a769fa054a347c48a35bcc7fd7eb5cb52e36e0b5 100644 (file)
@@ -1398,6 +1398,28 @@ module VISU {
      */
     Result ImportMedField(in SALOME_MED::FIELD theField);
 
+    /*!
+     * Rename a study object, representing a mesh, specified by given values.
+     * \param theResult   Data generated in other sources (MED object or file).
+     * \param theMeshName One of the meshes presented in MED file.
+     * \param theEntity   Type of entity where the field is defined.
+     * \param theSubMeshName Name of sub-mesh (group or family).
+     * \param theNewName  Name to be given to the study object.
+     */
+    void RenameEntityInStudy(in Result theResult,
+                            in string theMeshName,
+                            in Entity theEntity,
+                            in string theNewName);
+    void RenameFamilyInStudy(in Result theResult,
+                            in string theMeshName,
+                            in Entity theEntity,
+                            in string theSubMeshName,
+                            in string theNewName);
+    void RenameGroupInStudy(in Result theResult,
+                           in string theMeshName,
+                           in string theSubMeshName,
+                           in string theNewName);
+
     /*!
      * Creates a mesh on the basis of the data generated in other sources (MED object or file).
      * \param theResult   Data generated in other sources. (MED object or file)
index b1a29e01e354aa4be79d857546fb7186d8989243..c6c73c1d06919baad3745d71b85e1d66c189f217 100644 (file)
@@ -189,7 +189,6 @@ namespace VISU{
     return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
   }
 
-  
   Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, 
                                          const char* theMeshName, 
                                          VISU::Entity theEntity, 
@@ -198,7 +197,6 @@ namespace VISU{
     return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
   }
 
-
   Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, 
                                 const char* theMeshName, 
                                 const char* theGroupName)
@@ -207,6 +205,26 @@ namespace VISU{
   }
 
 
+  void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName, 
+                                      VISU::Entity theEntity, const char* theNewName)
+  {
+    myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
+  }
+
+  void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, 
+                                      VISU::Entity theEntity, const char* theFamilyName,
+                                      const char* theNewName)
+  {
+    myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
+  }
+
+  void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName, 
+                                     const char* theGroupName, const char* theNewName)
+  {
+    myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
+  }
+
+
   ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, 
                                             const char* theMeshName, 
                                             VISU::Entity theEntity, 
index b56e216cf74a23484dae11d8ed6a886a10f0a8ac..21892f5e2c7661b1abf65612f021d8d8d2cf53dc 100644 (file)
@@ -53,7 +53,7 @@ namespace VISU{
     virtual ViewManager_ptr GetViewManager();
 
     virtual SALOMEDS::SObject_ptr ImportTables(const char* theFileName);
-    virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName );
+    virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
 
     //Create Result
     virtual Result_ptr ImportFile(const char* theFileName);
@@ -64,30 +64,47 @@ namespace VISU{
 
     //Create Presentation Of Submeshes
     virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity);
-    virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, 
+    virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName,
                                        VISU::Entity theEntity, const char* theFamilyName);
     virtual Mesh_ptr GroupMesh(Result_ptr theResult, const char* theMeshName, const char* theGroupName);
 
-    virtual ScalarMap_ptr ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                          const char* theFieldName, CORBA::Double theIteration);
-    virtual GaussPoints_ptr GaussPointsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                              const char* theFieldName, CORBA::Double theIteration);
-    virtual DeformedShape_ptr DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                                  const char* theFieldName, CORBA::Double theIteration);
-    virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
+    //Rename Presentation Of Submeshes
+    virtual void RenameEntityInStudy(Result_ptr theResult, const char* theMeshName,
+                                    VISU::Entity theEntity, const char* theNewName);
+    virtual void RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                    const char* theFamilyName, const char* theNewName);
+    virtual void RenameGroupInStudy (Result_ptr theResult, const char* theMeshName,
+                                    const char* theGroupName, const char* theNewName);
+
+    //Create Presentation Of Results
+    virtual ScalarMap_ptr ScalarMapOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual GaussPoints_ptr GaussPointsOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual DeformedShape_ptr DeformedShapeOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual IsoSurfaces_ptr IsoSurfacesOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual CutPlanes_ptr CutPlanesOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual CutLines_ptr CutLinesOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual StreamLines_ptr StreamLinesOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual Plot3D_ptr Plot3DOnField  (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+                                      const char* theFieldName, CORBA::Double theIteration);
+    virtual ScalarMapOnDeformedShape_ptr ScalarMapOnDeformedShapeOnField
+                                      (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
                                       const char* theFieldName, CORBA::Double theIteration);
-    virtual IsoSurfaces_ptr IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                              const char* theFieldName, CORBA::Double theIteration);
-    virtual CutPlanes_ptr CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                          const char* theFieldName, CORBA::Double theIteration);
-    virtual CutLines_ptr CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                        const char* theFieldName, CORBA::Double theIteration);
-    virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                              const char* theFieldName, CORBA::Double theIteration);
-    virtual Plot3D_ptr Plot3DOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                    const char* theFieldName, CORBA::Double theIteration);
-    virtual ScalarMapOnDeformedShape_ptr ScalarMapOnDeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                                                        const char* theFieldName, CORBA::Double theIteration);
     //Create Digital Presentation
     virtual Table_ptr CreateTable(const char* theTableEntry);
     virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow);
@@ -125,7 +142,7 @@ namespace VISU{
                                         const char* aLocalPersistentID,
                                         CORBA::Boolean isMultiFile,
                                         CORBA::Boolean isASCII);
-    
+
     virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR);
     virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
                                                 SALOMEDS::SObject_ptr theSObject,
@@ -143,9 +160,8 @@ namespace VISU{
     virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
                                         CORBA::Boolean theIsPublished,
                                         CORBA::Boolean& theIsValidScript);   
-
   };
 };
 
 
-#endif 
+#endif
index a012ca37e64d31bb4f9469d9aea1b29756d2675e..d85247b98d5f0e4333b470a2bf133450a31f66a2 100644 (file)
@@ -509,15 +509,17 @@ namespace VISU{
               std::string thePrefix)
   {
     std::string aName = GetName(theSObject);
-    if(aName == "")
+    if (aName == "")
       return;
 
+    CORBA::String_var anID = theSObject->GetID();
+    CORBA::String_var aNameInStudy = theSObject->GetName();
+
     CORBA::Object_var anObj = SObjectToObject(theSObject);
-    if(!CORBA::is_nil(anObj)){
+    if (!CORBA::is_nil(anObj)) {
       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
       if(!CORBA::is_nil(aBase)){
        std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
-       CORBA::String_var anID = theSObject->GetID();
 
         VISU::VISUType aType = aBase->GetType();
         switch(aType){
@@ -641,7 +643,6 @@ namespace VISU{
            theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
 
            // Set name (as this object could be renamed by user)
-           CORBA::String_var aNameInStudy = theSObject->GetName();
            theStr<<thePrefix<<"visu.SetName("<<aName<<",'"<<aNameInStudy.in()<<"')"<<endl;
 
            // Set parameters common for all Prs3d objects (offset values)
@@ -1013,7 +1014,6 @@ namespace VISU{
                  theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
 
                  // Set name (as this object could be renamed by user)
-                 CORBA::String_var aNameInStudy = theSObject->GetName();
                  theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 2"<<endl;
 
                  theStr<<endl;
@@ -1041,7 +1041,6 @@ namespace VISU{
                  theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
 
                  // Set name (as this object could be renamed by user)
-                 CORBA::String_var aNameInStudy = theSObject->GetName();
                  theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
 
                  theStr<<endl;
@@ -1076,9 +1075,9 @@ namespace VISU{
           return;
        }
       }
-    }else{ /*if(!CORBA::is_nil(anObj))*/
+    } else { /*if(!CORBA::is_nil(anObj))*/
       SALOMEDS::GenericAttribute_var anAttr;
-      if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+      if (theSObject->FindAttribute(anAttr,"AttributeComment")) {
        SALOMEDS::AttributeComment_var aComment =
          SALOMEDS::AttributeComment::_narrow(anAttr);
        CORBA::String_var aValue = aComment->Value();
@@ -1086,8 +1085,8 @@ namespace VISU{
        Storable::StrToMap(aValue.in(),aMap);
        bool anIsExist;
        QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
-       if(anIsExist){
-         if(strcmp(aTypeName.latin1(),"ImportTables") == 0){
+       if (anIsExist) {
+         if (strcmp(aTypeName.latin1(),"ImportTables") == 0) {
            QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
            if(anIsExist){
              std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
@@ -1109,7 +1108,7 @@ namespace VISU{
              theStr<<thePrefix<<"pass"<<endl<<endl;
              return;
            }
-         }else if(strcmp(aTypeName.latin1(),"VIEW3D") == 0){
+         } else if (strcmp(aTypeName.latin1(),"VIEW3D") == 0) {
            std::string aName = GetName(theSObject);
            theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
 
@@ -1124,9 +1123,40 @@ namespace VISU{
 
            theStr<<thePrefix<<"pass"<<endl<<endl;
            return;
+         } else if (aTypeName == "ENTITY" || aTypeName == "FAMILY" || aTypeName == "GROUP") {
+           // Set name (as this object could be renamed by user)
+           string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
+           string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").latin1();
+           string anEntityTypeKey = "myEntityId";
+           if (aTypeName == "ENTITY") anEntityTypeKey = "myId";
+           int anEntity = VISU::Storable::FindValue(aMap,anEntityTypeKey,"0").toInt();
+           std::string anEntityType;
+           switch ((TEntity)anEntity) {
+           case NODE_ENTITY: anEntityType = "VISU.NODE"; break;
+           case EDGE_ENTITY: anEntityType = "VISU.EDGE"; break;
+           case FACE_ENTITY: anEntityType = "VISU.FACE"; break;
+           case CELL_ENTITY: anEntityType = "VISU.CELL"; break;
+           }
+
+           if (aTypeName == "ENTITY" ) {
+             theStr<<thePrefix<<"aVisu.RenameEntityInStudy("<<theArgumentName<<",'"<<aMeshName
+                   <<"',"<<anEntityType<<",'"<<aNameInStudy.in()<<"')"<<endl;
+           }
+           else if (aTypeName == "FAMILY") {
+             if (aSubMeshName != aNameInStudy.in()) {
+               theStr<<thePrefix<<"aVisu.RenameFamilyInStudy("<<theArgumentName<<",'"<<aMeshName
+                     <<"',"<<anEntityType<<",'"<<aSubMeshName<<"','"<<aNameInStudy.in()<<"')"<<endl;
+             }
+           }
+           else { // "GROUP"
+             if (aSubMeshName != aNameInStudy.in()) {
+               theStr<<thePrefix<<"aVisu.RenameGroupInStudy("<<theArgumentName<<",'"<<aMeshName
+                     <<"','"<<aSubMeshName<<"','"<<aNameInStudy.in()<<"')"<<endl;
+             }
+           }
          }
        }
-      }else{
+      } else {
        DumpTableAttrToPython(theStudy,
                              theIsPublished,
                              theIsValidScript,
index c5a950cc427b8c7462ddfb5d9f007d1ba927e70d..d225b3d04f4da5be2ce56f9ee4afc0a7d68694fa 100644 (file)
@@ -605,6 +605,85 @@ namespace VISU
     }
   }
 
+  void VISU_Gen_i::RenameMeshInStudy(Result_ptr theResult,
+                                    string     theMeshName,
+                                    int        theEntity,      // -1 for group indication
+                                    string     theSubMeshName, // Family or Group name
+                                    string     theNewName)
+  {
+    if (myStudyDocument->GetProperties()->IsLocked()) return;
+    Mutex mt(myMutex);
+
+    Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in());
+    if (!pResult) return;
+
+    QString aComment;
+    VISU::VISUType aType;
+    if (theEntity >= 0)
+      if (theSubMeshName == "")
+       aType = VISU::TENTITY;
+      else
+       aType = VISU::TFAMILY;
+    else
+      aType = VISU::TGROUP;
+
+    switch (aType) {
+    case VISU::TENTITY:
+      aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
+                      VISU::TENTITY, theMeshName.c_str(), theEntity);
+      break;
+    case VISU::TFAMILY:
+      aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
+                      VISU::TFAMILY, theMeshName.c_str(), theEntity, theSubMeshName.c_str());
+      break;
+    case VISU::TGROUP:
+      aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
+                      VISU::TGROUP, theMeshName.c_str(), theSubMeshName.c_str());
+      break;
+    }
+
+    string aResultEntry = pResult->GetEntry();
+    string anEntry = pResult->GetEntry(aComment.latin1());
+    if (anEntry == "") return;
+
+    SALOMEDS::SObject_ptr aSObject = myStudyDocument->FindObjectID(anEntry.c_str());
+
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+    aStudyBuilder->NewCommand(); // There is a transaction
+
+    SALOMEDS::GenericAttribute_var anAttr =
+      aStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
+    SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
+    aNameAttr->SetValue(theNewName.c_str());
+
+    aStudyBuilder->CommitCommand();
+  }
+
+  void VISU_Gen_i::RenameEntityInStudy(Result_ptr   theResult,
+                                      const char*  theMeshName,
+                                      VISU::Entity theEntity,
+                                      const char*  theNewName)
+  {
+    RenameMeshInStudy(theResult, theMeshName, (int)theEntity, "", theNewName);
+  }
+
+  void VISU_Gen_i::RenameFamilyInStudy(Result_ptr   theResult,
+                                      const char*  theMeshName,
+                                      VISU::Entity theEntity,
+                                      const char*  theFamilyName,
+                                      const char*  theNewName)
+  {
+    RenameMeshInStudy(theResult, theMeshName, (int)theEntity, theFamilyName, theNewName);
+  }
+
+  void VISU_Gen_i::RenameGroupInStudy(Result_ptr  theResult,
+                                     const char* theMeshName,
+                                     const char* theGroupName,
+                                     const char* theNewName)
+  {
+    RenameMeshInStudy(theResult, theMeshName, -1, theGroupName, theNewName);
+  }
+
   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
                                    const char* theMeshName,
                                    VISU::Entity theEntity)
index 1f4f921268ae509bbeb556e10bd70889a75a516a..5590e898b4be04071700b6767c570311776b8290 100644 (file)
@@ -15,6 +15,8 @@
 #include "SALOME_Component_i.hxx"
 #include "SALOME_NamingService.hxx"
 
+#include <string>
+
 namespace VISU
 {
   class Result_i;
@@ -92,6 +94,33 @@ namespace VISU
     ImportMedField(SALOME_MED::FIELD_ptr theField);
 
 
+    //Rename Presentation Of Submeshes
+    void
+    RenameMeshInStudy(Result_ptr  theResult,
+                     std::string theMeshName,
+                     int         theEntity,      // -1 for group indication
+                     std::string theSubMeshName, // Family or Group name
+                     std::string theNewName);
+    virtual
+    void
+    RenameEntityInStudy(Result_ptr   theResult,
+                       const char*  theMeshName,
+                       VISU::Entity theEntity,
+                       const char*  theNewName);
+    virtual
+    void
+    RenameFamilyInStudy(Result_ptr   theResult,
+                       const char*  theMeshName,
+                       VISU::Entity theEntity,
+                       const char*  theFamilyName,
+                       const char*  theNewName);
+    virtual
+    void
+    RenameGroupInStudy(Result_ptr  theResult,
+                      const char* theMeshName,
+                      const char* theGroupName,
+                      const char* theNewName);
+
     //Create Presentation Of Submeshes
     virtual
     Mesh_ptr