]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for bug 10040: 'Dump study' doesn't restore name of Prs in Post-Pro.
authorjfa <jfa@opencascade.com>
Thu, 2 Mar 2006 14:20:01 +0000 (14:20 +0000)
committerjfa <jfa@opencascade.com>
Thu, 2 Mar 2006 14:20:01 +0000 (14:20 +0000)
src/VISU_I/VISU_DumpPython.cc
src/VISU_SWIG/visu.py

index 91b8ef80fbdc5f9a9d214cca5d7dd3585dbea8ff..79fb6e44b80c622c1d2d381a2e8814b851bc41d3 100644 (file)
@@ -175,8 +175,14 @@ namespace VISU{
     theStr<<thePrefix<<"if "<<theName<<":"<<endl;
     thePrefix += PREFIX;
 
+    // Add to Name->Object map
     theStr<<thePrefix<<"aName2ObjectMap['"<<theName<<"'] = "<<theName<<endl;
 
+    // Set name (as this object could be renamed by user)
+    CORBA::String_var aNameInStudy = theSObject->GetName();
+    theStr<<thePrefix<<"visu.SetName("<<theName<<",'"<<aNameInStudy.in()<<"')"<<endl;
+
+    // Set parameters
     theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
 
     switch(theServant->GetScaling()){
@@ -359,6 +365,10 @@ namespace VISU{
       theStr<<thePrefix<<"if "<<aName<<":"<<endl;
       std::string aPrefix2 = thePrefix + PREFIX;
 
+      // Set name (as this object could be renamed by user)
+      CORBA::String_var aNameInStudy = theSObject->GetName();
+      theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 1"<<endl;
+
       DumpChildrenToPython(theStudy,
                           theIsPublished,
                           theIsValidScript,
@@ -594,8 +604,14 @@ namespace VISU{
            theStr<<thePrefix<<"if "<<aName<<":"<<endl;
            thePrefix += PREFIX;
 
+           // Add to Name->Object map
            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 presentation parameters
            SALOMEDS::Color aColor;
            aColor = aServant->GetCellColor();
            theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
@@ -897,7 +913,6 @@ namespace VISU{
          return;
         case VISU::TTABLE:
           if(Table_i* aServant = dynamic_cast<Table_i*>(GetServant(anObj).in())){
-           SALOMEDS::SObject_var aSObject = aServant->GetSObject();
            SALOMEDS::GenericAttribute_var anAttr;
            if(theSObject->FindAttribute(anAttr,"AttributeComment")){
              using namespace SALOMEDS;
@@ -921,6 +936,11 @@ namespace VISU{
 
                  theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
                  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;
 
                  theArgumentName = aName;
@@ -944,6 +964,11 @@ namespace VISU{
 
                  theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
                  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;
 
                  theArgumentName = aName;
@@ -976,7 +1001,7 @@ namespace VISU{
           return;
        }
       }
-    }else{
+    }else{ /*if(!CORBA::is_nil(anObj))*/
       SALOMEDS::GenericAttribute_var anAttr;
       if(theSObject->FindAttribute(anAttr,"AttributeComment")){
        SALOMEDS::AttributeComment_var aComment =
@@ -1117,6 +1142,10 @@ namespace VISU{
        std::string aPrefix = thePrefix + PREFIX;
        theArgumentName = aName;
 
+       // Set name (as this object could be renamed by user)
+       CORBA::String_var aNameInStudy = aSObject->GetName();
+       theStr<<aPrefix<<"visu.SetName("<<aName<<",'"<<aNameInStudy.in()<<"')"<<endl;
+
        SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
        for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
          SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
index 4b7b442000772cb3e6bff4e3e3274f5147ae8f42..ea05e2bf4578b6c7a86d4c306a3f41fe5e57c0c8 100644 (file)
@@ -81,6 +81,12 @@ def PublishComponent(theStudyDocument):
         pass
     
     return aSComponent;
+
+def SetName(theObj, theName):
+    anIOR  = myORB.object_to_string(theObj)
+    aSObj  = myLocalStudy.FindObjectIOR(anIOR)
+    anAttr = aSObj.FindAttribute("AttributeName")[1]
+    anAttr.SetValue(theName)
         
 def StrToMap(theString) :
     aPairList = split(theString,";")