Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VISU_SWIG / visu.py
index f7c75a1ccab3f919f12754b100b4766415893a50..c287e79aa922c4abff22e41042e8bdd24826b940 100644 (file)
@@ -12,6 +12,8 @@ import re
 from time import sleep
 
 import VISU
+import SALOME
+import SALOME_Session_idl
 import SALOMEDS
 import SALOME_MED
 from omniORB import CORBA
@@ -36,15 +38,56 @@ def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, the
     myNamingService = theNamingService
     myLifeCycleCORBA = theLifeCycleCORBA
     myLocalStudyManager = theStudyManager
-    mySession = myNamingService.Resolve("/Kernel/Session")
+    while mySession == None:
+       mySession = myNamingService.Resolve("/Kernel/Session")
+    mySession = mySession._narrow(SALOME.Session)
     mySession.GetInterface()
     myDelay = theDelay
     sleep(myDelay)
-    myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "Visu")
+    myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "VISU")
     myLocalStudy = theStudy
     myLocalVisu.SetCurrentStudy(myLocalStudy)
     return myLocalVisu
+
+def PublishComponent(theStudyDocument):
+    aComponentDataType = myLocalVisu.ComponentDataType()
+    aSComponent = theStudyDocument.FindComponent(aComponentDataType)
+    if aSComponent == None:
+        aStudyBuilder = theStudyDocument.NewBuilder()
+        aStudyBuilder.NewCommand()
+        aLocked = theStudyDocument.GetProperties().IsLocked()
+        if aLocked:
+            theStudyDocument.GetProperties().SetLocked(0)
+            pass
+
+        aSComponent = aStudyBuilder.NewComponent(aComponentDataType);
+        aName = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributeName")
+        aModuleCatalog = myNamingService.Resolve("/Kernel/ModulCatalog");
+        aComponent = aModuleCatalog.GetComponent(aComponentDataType);
+        if aComponent != None:
+            aComponentUserName = aComponent._get_componentusername()
+            aName.SetValue(aComponentUserName)
+            pass
+        
+        aPixMap = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributePixMap")
+        aPixMap.SetPixMap("ICON_OBJBROWSER_Visu")
+        
+        aStudyBuilder.DefineComponentInstance(aSComponent,myLocalVisu);
+        if aLocked:
+            theStudyDocument.GetProperties().SetLocked(1);
+            pass
+        
+        aStudyBuilder.CommitCommand();
+        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,";")
     aMap = {}
@@ -74,10 +117,10 @@ def HasValue(theList, theValue) :
 def CreateStudyForMed(theVisu, theFileName) :
     print "CreateStudyForMed ", theFileName,
     if os.path.isfile(theFileName) :
-        if os.path.splitext(theFileName)[1] == '.med' :
+        if re.search("\.med$", theFileName) is not None :
             print "OK"
             aStudyName = os.path.basename(theFileName)
-            aStudyName = os.path.splitext(aStudyName)[0]
+            aStudyName = re.sub(r'\.med', "", aStudyName)
             aStudyName = generateName(aStudyName)
             print "myLocalStudyManager.NewStudy -", aStudyName, "...",
             aStudy = myLocalStudyManager.NewStudy(aStudyName)
@@ -96,17 +139,20 @@ def CreateStudyForMed(theVisu, theFileName) :
             return [aStudy, myViewManager, myView]
     raise RuntimeError, "Error: There is no shuch file."
 
-def getMedObjectFromStudy(theStudy = myLocalStudy):
+def getMedSObject(theStudy = myLocalStudy ):
     if theStudy is None:
         theStudy = myLocalStudy
-    mySO = theStudy.FindObject("Objet MED")
-    anAttr = mySO.FindAttribute("AttributeIOR")[1]
-    obj = myORB.string_to_object(anAttr.Value())
-    myObj = obj._narrow(SALOME_MED.MED)
-    return myObj
+    aSO = theStudy.FindObject("Med")
+    anIsPresetn, aSObject = aSO.FindSubObject(1)
+    return aSObject
 
-def getMedSObject(theStudy = myLocalStudy ):
-    return theStudy.FindObject("Objet MED")
+def getMedObjectFromStudy(theStudy = myLocalStudy):
+    aSObject = getMedSObject(theStudy)
+    if aSObject:
+        anAttr = aSObject.FindAttribute("AttributeIOR")[1]
+        anObj = myORB.string_to_object(anAttr.Value())
+        return  anObj._narrow(SALOME_MED.MED)
+    return None
 
 def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
     if theStudy is None:
@@ -144,11 +190,11 @@ def SObjectToObject(theSObject) :
        print "SObjectToObject - IOR = ''"
     return anObj;
  
-def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
+def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete = 0) :
 #    try:
         global myLifeCycleCORBA
         print "lcc.FindOrLoadComponent...",
-        aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "Med")
+        aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "MED")
         if aMedComp is None : print "Error"
         else : print "OK"
         
@@ -164,10 +210,14 @@ def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePict
         aResult = theVisu.ImportMed(aMedSObj)
         if aResult is None : raise RuntimeError, "Error"
         else : print "OK"
-        aVISUObjList.append(aResult)
-        aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+        aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
+        if theIsAutoDelete :
+            aResult.RemoveFromStudy()
+        else :
+            aVISUObjList.append(aResult)
         
-        aFolderIter = myLocalStudy.NewChildIterator(aMedSObj);
+        aFolderIter = myLocalStudy.NewChildIterator(aMedSObj.GetFather());
         while aFolderIter.More() :
             aFolderSObj = aFolderIter.Value()
             aFolderIter.Next()
@@ -209,8 +259,12 @@ def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePict
                     aResult = theVisu.ImportMed(aFieldSObj)
                     if aResult is None : raise RuntimeError, "Error"
                     else : print "OK"
-                    aVISUObjList.append(aResult)
-                    aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+                    aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
+                    if theIsAutoDelete :
+                        aResult.RemoveFromStudy()
+                    else :
+                        aVISUObjList.append(aResult)
 
                     aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
                     if aTimeStampIter.More() :
@@ -225,37 +279,51 @@ def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePict
 
                             print "theVisu.ImportMed...",
                             aMedField = SObjectToObject(aTimeStampSObj)
-                            aResult = theVisu.ImportMedFiled(aMedField)
+                            aResult = theVisu.ImportMedField(aMedField)
                             if aResult is None : raise RuntimeError, "Error"
                             else : print "OK"
-                            aVISUObjList.append(aResult)
-                            aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+                            aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
+                            if theIsAutoDelete :
+                                aResult.RemoveFromStudy()
+                            else :
+                                aVISUObjList.append(aResult)
                     
         return aVISUObjList
     
 #    except Exception, e:
 #        print str(e)
         
-def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
+def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete = 0) :
  #   try:
         aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
 
-        print "theVisu.ImportMed..."
+        print "theVisu.ImportMed...",
         aResult = theVisu.ImportFile(theFileName)
         if aResult is None : raise RuntimeError, "Error"
         else : print "OK"
         
-        aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
-        
+        aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
+
+        if theIsAutoDelete :
+            aResult.RemoveFromStudy()
+        else :
+            aVISUObjList.append(aResult)
+
         return aVISUObjList
     
 #    except Exception, e:
 #        print str(e)
                 
-def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt) :
-    aVISUObjList = []
+def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete = 0) :
+    aVISUObjList = None
+    if theIsAutoDelete is not None :
+       aVISUObjList = []
+       pass
+       
     print "CreatePrsForResult - myLocalStudy.FindObjectIOR...",
     myLocalStudy = theVisu.GetCurrentStudy()
+
     aSObj = myLocalStudy.FindObjectIOR(theResult.GetID())
     if aSObj is None : raise RuntimeError, "Error"
     else : print "OK"
@@ -277,7 +345,9 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi
         while aFolderIter.More() :
             aFolderSObj = aFolderIter.Value()
             aFolderIter.Next()
-            anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
+            anIsFound, anAttr = aFolderSObj.FindAttribute("AttributeName")
+            if not anIsFound :
+                continue
             anAttr = anAttr._narrow(SALOMEDS.AttributeName);
             aFolderName = anAttr.Value()
             print "    ", aFolderName
@@ -309,13 +379,17 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi
                         print "      ", anEntityName, aMeshName,
                         aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity)
                         if aMesh is None : print "Error"
-                        else : print ",OK"
-                        theView.DisplayOnly(aMesh)
-                        theView.FitAll()
-                        aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
-                        aPictureName = re.sub("\s+","_", aPictureName);
-                        theView.SavePicture(aPictureName)
-                        aVISUObjList.append(aMesh)
+                        else :
+                            print ",OK"
+                            theView.DisplayOnly(aMesh)
+                            theView.FitAll()
+                            aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
+                            aPictureName = re.sub("\s+","_", aPictureName);
+                            theView.SavePicture(aPictureName)
+                            if theIsAutoDelete :
+                                aMesh.RemoveFromStudy()
+                            else :
+                                aVISUObjList.append(aMesh)
                         
                         anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj);
                         while anFamilyIter.More() :
@@ -328,13 +402,17 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi
                                 print "        ", anFamilyName,
                                 aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName)
                                 if aMesh is None : print "Error"
-                                else : print ",OK"
-                                theView.DisplayOnly(aMesh)
-                                theView.FitAll()
-                                aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
-                                aPictureName = re.sub("\s+","_", aPictureName);
-                                theView.SavePicture(aPictureName)
-                                aVISUObjList.append(aMesh)
+                                else :
+                                    print ",OK"
+                                    theView.DisplayOnly(aMesh)
+                                    theView.FitAll()
+                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
+                                    aPictureName = re.sub("\s+","_", aPictureName);
+                                    theView.SavePicture(aPictureName)
+                                    if theIsAutoDelete :
+                                        aMesh.RemoveFromStudy()
+                                    else :
+                                        aVISUObjList.append(aMesh)
                                 
             if aFolderName == 'Groups' :
                 aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj);
@@ -348,13 +426,17 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi
                         print "      ", aGroupName,
                         aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName)
                         if aMesh is None : print "Error"
-                        else : print ",OK"
-                        theView.DisplayOnly(aMesh)
-                        theView.FitAll()
-                        aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
-                        aPictureName = re.sub("\s+","_", aPictureName);
-                        theView.SavePicture(aPictureName)
-                        aVISUObjList.append(aMesh)
+                        else :
+                            print ",OK"
+                            theView.DisplayOnly(aMesh)
+                            theView.FitAll()
+                            aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
+                            aPictureName = re.sub("\s+","_", aPictureName);
+                            theView.SavePicture(aPictureName)
+                            if theIsAutoDelete :
+                                aMesh.RemoveFromStudy()
+                            else :
+                                aVISUObjList.append(aMesh)
                         
             if aFolderName == 'Fields' :
                 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
@@ -396,52 +478,88 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi
                                 print "          Creating ScalarMapOnField",
                                 aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                 if aPrsObj is None : print "Error"
-                                else : print ",OK"
-                                theView.DisplayOnly(aPrsObj)
-                                theView.FitAll()
-                                aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
-                                aPictureName = re.sub("\s+","_", aPictureName);
-                                theView.SavePicture(aPictureName)
-                                aVISUObjList.append(aPrsObj)
-                                
+                                else :
+                                    print ",OK"
+                                    theView.DisplayOnly(aPrsObj)
+                                    theView.FitAll()
+                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
+                                    aPictureName = re.sub("\s+","_", aPictureName);
+                                    theView.SavePicture(aPictureName)
+                                    if theIsAutoDelete :
+                                       aPrsObj.RemoveFromStudy()
+                                    else :
+                                        aVISUObjList.append(aPrsObj)
+
                             if HasValue(thePrsTypeList,VISU.TISOSURFACE) :
                                 print "          Creating IsoSurfacesOnField",
                                 aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                 if aPrsObj is None : print "Error"
-                                else : print ",OK"
-                                theView.DisplayOnly(aPrsObj)
-                                theView.FitAll()
-                                aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt
-                                aPictureName = re.sub("\s+","_", aPictureName);
-                                theView.SavePicture(aPictureName)
-                                aVISUObjList.append(aPrsObj)
+                                else :
+                                    print ",OK"
+                                    theView.DisplayOnly(aPrsObj)
+                                    theView.FitAll()
+                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt
+                                    aPictureName = re.sub("\s+","_", aPictureName);
+                                    theView.SavePicture(aPictureName)
+                                    if theIsAutoDelete :
+                                       aPrsObj.RemoveFromStudy()
+                                    else :
+                                        aVISUObjList.append(aPrsObj)
                                 
                             if HasValue(thePrsTypeList,VISU.TCUTPLANES) :
                                 print "          Creating CutPlanesOnField",
                                 aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                 if aPrsObj is None : print "Error"
-                                else : print ",OK"
-                                aPrsObj.SetOrientationType(VISU.CutPlanes.ZX)
-                                theView.DisplayOnly(aPrsObj)
-                                theView.FitAll()
-                                aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
-                                aPictureName = re.sub("\s+","_", aPictureName)
-                                theView.SavePicture(aPictureName)
-                                aVISUObjList.append(aPrsObj)
+                                else :
+                                    print ",OK"
+                                    aPrsObj.SetOrientation(VISU.CutPlanes.ZX,aPrsObj.GetRotateX(),aPrsObj.GetRotateY())
+                                    theView.DisplayOnly(aPrsObj)
+                                    theView.FitAll()
+                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
+                                    aPictureName = re.sub("\s+","_", aPictureName)
+                                    theView.SavePicture(aPictureName)
+                                    if theIsAutoDelete :
+                                       aPrsObj.RemoveFromStudy()
+                                    else :
+                                        aVISUObjList.append(aPrsObj)
                                 
                             if HasValue(thePrsTypeList,VISU.TCUTLINES) :
                                 print "          Creating CutLinesOnField",
                                 aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                 if aPrsObj is None : print "Error"
-                                else : print ",OK"
-                                aPrsObj.SetOrientationType(VISU.CutPlanes.XY)
-                                aPrsObj.SetOrientationType2(VISU.CutPlanes.ZX)
-                                theView.DisplayOnly(aPrsObj)
-                                theView.FitAll()
-                                aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
-                                aPictureName = re.sub("\s+","_", aPictureName)
-                                theView.SavePicture(aPictureName)
-                                aVISUObjList.append(aPrsObj)
+                                else :
+                                    print ",OK"
+                                    aPrsObj.SetOrientation(VISU.CutPlanes.XY,aPrsObj.GetRotateX(),aPrsObj.GetRotateY())
+                                    aPrsObj.SetOrientation2(VISU.CutPlanes.ZX,aPrsObj.GetRotateX2(),aPrsObj.GetRotateY2())
+                                    theView.DisplayOnly(aPrsObj)
+                                    theView.FitAll()
+                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
+                                    aPictureName = re.sub("\s+","_", aPictureName)
+                                    theView.SavePicture(aPictureName)
+                                    if theIsAutoDelete :
+                                       aPrsObj.RemoveFromStudy()
+                                    else :
+                                        aVISUObjList.append(aPrsObj)
+                                
+                            if HasValue(thePrsTypeList,VISU.TPLOT3D) :
+                                print "          Creating Plot3DOnField",
+                                aPrsObj = theVisu.Plot3DOnField(theResult,aMeshName,anEntity,
+                                                                aFieldName,aTimeStampId)
+                                if aPrsObj is None : print "Error"
+                                else :
+                                    print ",OK"
+                                #aPrsObj.SetOrientation(VISU.CutPlanes.ZX,
+                                #                       aPrsObj.GetRotateX(),
+                                #                       aPrsObj.GetRotateY())
+                                    theView.DisplayOnly(aPrsObj)
+                                    theView.FitAll()
+                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TPLOT3D." + thePictureExt
+                                    aPictureName = re.sub("\s+","_", aPictureName)
+                                    theView.SavePicture(aPictureName)
+                                    if theIsAutoDelete :
+                                       aPrsObj.RemoveFromStudy()
+                                    else :
+                                        aVISUObjList.append(aPrsObj)
                                 
                             aNumComponent = atoi(aMap["myNumComponent"])
                             if aNumComponent > 1 :
@@ -449,38 +567,66 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi
                                     print "          Creating DeformedShapeOnField",
                                     aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                     if aPrsObj is None : print "Error"
-                                    else : print ",OK"
-                                    theView.DisplayOnly(aPrsObj)
-                                    theView.FitAll()
-                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
-                                    aPictureName = re.sub("\s+","_", aPictureName)
-                                    theView.SavePicture(aPictureName)
-                                    aVISUObjList.append(aPrsObj)
+                                    else :
+                                        print ",OK"
+                                        theView.DisplayOnly(aPrsObj)
+                                        theView.FitAll()
+                                        aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
+                                        aPictureName = re.sub("\s+","_", aPictureName)
+                                        theView.SavePicture(aPictureName)
+                                        if theIsAutoDelete :
+                                            aPrsObj.RemoveFromStudy()
+                                        else :
+                                            aVISUObjList.append(aPrsObj)
 
                                 if HasValue(thePrsTypeList,VISU.TVECTORS) :
                                     print "          Creating VectorsOnField",
-                                    aPrsObj = theVisu.VectorsOnField(theResult,aMeshNamePic,anEntity,aFieldName,aTimeStampId)
+                                    aPrsObj = theVisu.VectorsOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                     if aPrsObj is None : print "Error"
-                                    else : print ",OK"
-                                    theView.DisplayOnly(aPrsObj)
-                                    theView.FitAll()
-                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
-                                    aPictureName = re.sub("\s+","_", aPictureName)
-                                    theView.SavePicture(aPictureName)
-                                    aVISUObjList.append(aPrsObj)
+                                    else :
+                                        print ",OK"
+                                        theView.DisplayOnly(aPrsObj)
+                                        theView.FitAll()
+                                        aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
+                                        aPictureName = re.sub("\s+","_", aPictureName)
+                                        theView.SavePicture(aPictureName)
+                                        if theIsAutoDelete :
+                                            aPrsObj.RemoveFromStudy()
+                                        else :
+                                            aVISUObjList.append(aPrsObj)
                                     
                                 if HasValue(thePrsTypeList,VISU.TSTREAMLINES) :
                                     print "          Creating StreamLinesOnField",
                                     aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
                                     if aPrsObj is None : print "Error"
-                                    else : print ",OK"
-                                    theView.DisplayOnly(aPrsObj)
-                                    theView.FitAll()
-                                    aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
-                                    aPictureName = re.sub("\s+","_", aPictureName)
-                                    theView.SavePicture(aPictureName)
-                                    aVISUObjList.append(aPrsObj)
-                    
+                                    else :
+                                        print ",OK"
+                                        theView.DisplayOnly(aPrsObj)
+                                        theView.FitAll()
+                                        aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
+                                        aPictureName = re.sub("\s+","_", aPictureName)
+                                        theView.SavePicture(aPictureName)
+                                        if theIsAutoDelete :
+                                            aPrsObj.RemoveFromStudy()
+                                        else :
+                                            aVISUObjList.append(aPrsObj)
+
+                                if HasValue(thePrsTypeList,VISU.TSCALARMAPONDEFORMEDSHAPE) :
+                                    print "          Creating ScalarMapOnDeformedShapeOnField",
+                                    aPrsObj = theVisu.ScalarMapOnDeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+                                    if aPrsObj is None : print "Error"
+                                    else :
+                                        print ",OK"
+                                        theView.DisplayOnly(aPrsObj)
+                                        theView.FitAll()
+                                        aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAPONDEFORMEDSHAPE." + thePictureExt
+                                        aPictureName = re.sub("\s+","_", aPictureName)
+                                        theView.SavePicture(aPictureName)
+                                        if theIsAutoDelete :
+                                            aPrsObj.RemoveFromStudy()
+                                        else :
+                                            aVISUObjList.append(aPrsObj)
+                                
     return aVISUObjList
 
 
@@ -621,7 +767,7 @@ def dump_deformedshape_parameters(theObject):
 # ----------------------
 def try_cutplanes_parameters(thePattern) :
 
-    if thePattern  is None : return aList 
+    if thePattern  is None : return None 
     import copy
     import random
 
@@ -630,10 +776,6 @@ def try_cutplanes_parameters(thePattern) :
     ind = random.randint(1,2)
     anObj = try_scalarmap_parameters(thePattern)
         
-    # --- ORIENTATION ---
-    anObj.SetOrientationType(ORIENT[random.randint(0,2)])
-
-    # --- NUMBER OF PLANES ---
     if ind%2 :   anObj.SetNbPlanes(random.randint(-40,40))
     else :       anObj.SetNbPlanes(random.randint(0,10)) #try behaivor if NbPlanes=0
 
@@ -658,8 +800,8 @@ def try_cutplanes_parameters(thePattern) :
             angle1 = random.random()*3.14
             angle2 = random.random()*3.14
         
-    anObj.SetRotateX(angle1)
-    anObj.SetRotateY(angle2)
+    # --- ORIENTATION ---
+    anObj.SetOrientation(ORIENT[random.randint(0,2)],angle1,angle2)
 
     return anObj
         
@@ -692,8 +834,12 @@ def try_cutlines_parameters(thePattern):
     anObj = try_scalarmap_parameters(thePattern)
 
     # --- ORIENTATION ---
-    anObj.SetOrientationType(ORIENT[random.randint(0,2)])
-    anObj.SetOrientationType2(ORIENT[random.randint(0,2)])
+    anObj.SetOrientation(ORIENT[random.randint(0,2)],
+                         random.randint(-100,100)*random.random(),
+                         random.randint(-100,100)*random.random())
+    anObj.SetOrientation2(ORIENT[random.randint(0,2)],
+                          random.randint(-100,100)*random.random(),
+                          random.randint(-100,100)*random.random())
 
     # --- Base Plane Position ---
     anObj.SetBasePlanePosition( random.random()*random.randint(-100000,100000))
@@ -702,12 +848,6 @@ def try_cutlines_parameters(thePattern):
     if ind%2:
             anObj.SetNbLines(random.randint(-5, 50))
 
-    # --- ROTATION ---
-    anObj.SetRotateX(random.randint(-100,100)*random.random())
-    anObj.SetRotateX2(random.randint(-100,100)*random.random())
-    anObj.SetRotateY(random.randint(-100,100)*random.random())
-    anObj.SetRotateY2(random.randint(-100,100)*random.random())
-
     return anObj
 
 def dump_cutlines_parameters(theObject):
@@ -828,3 +968,41 @@ def dump_isosurfaces_parameters(theObject):
     
     dump_scalarmap_parameters(theObject)
     print "GetNbSurfaces() = "+ str(theObject.GetNbSurfaces())
+
+
+# ----------------------
+# TABLES AND CURVES
+# ----------------------
+
+def FillTable( theTable, theValues, theRows, theColumns, theRowTitles, theRowUnits, theColumnTitles ):
+    if theTable is None: return
+    if len(theRows) != len(theColumns): return
+    if len(theRows) != len(theValues): return
+    i = 0
+    for value in theValues:
+        theTable.PutValue( value, theRows[ i ], theColumns[ i ])
+        i = i + 1
+        pass
+    i = 1
+    for title in theRowTitles:
+        theTable.SetRowTitle( i, title )
+        theTable.SetRowUnit( i, theRowUnits[ i - 1 ])
+        i = i + 1
+        pass
+    i = 1
+    for title in theColumnTitles:
+        theTable.SetColumnTitle( i, title )
+        i = i + 1
+        pass
+    pass
+
+def CreateCurve( theTable, theHRow, theVRow, theTitle, theColor, theMarker, theLineType, theLineWidth ):
+    if theTitle is None: return
+    curve = myLocalVisu.CreateCurve( theTable, theHRow, theVRow );
+    if curve:
+        curve.SetTitle( theTitle )
+        curve.SetColor( theColor )
+        curve.SetMarker( theMarker )
+        curve.SetLine( theLineType, theLineWidth )
+        pass
+    return curve