Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / VISU_SWIG / batchmode_visu.py
index cc9f9552b2056dba87c656bbcb0252d530e84663..559a3eb448664431ec4703ac1f9fd93433138526 100644 (file)
@@ -7,18 +7,70 @@
 #  File   : batchmode_visu.py
 #  Module : VISU
 
-import os
-import re
-from time import sleep
-
-import VISU
-import SALOMEDS
-import SALOME_MED
-from omniORB import CORBA
-
 from batchmode_salome import *
 import visu
 
 myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10)
 if myVisu is None:
     raise RuntimeError, "myVisu is none, VISU component is not loaded  or found"
+
+def try_mesh_parameters(theMeshPattern):
+    aResult = []
+    if theMeshPattern is None : return aResult ;
+    theMeshPattern =  theMeshPattern._narrow(VISU.Mesh)
+    if theMeshPattern is None : return aResult ;
+
+    aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
+    import copy; import os;
+    for ind in aTYPES:
+        aNewMesh = copy.deepcopy(theMeshPattern);
+        aNewMesh.SetPresentationType(ind)
+        aResult.append(aNewMesh)
+
+    return aResult
+    
+def try_scalarmap_parameters(thePattern, theNum):
+    aList = []
+    if thePattern  is None : return aList 
+    thePattern =  thePattern._narrow(VISU.ScalarMap)
+    if thePattern  is None : return aList 
+    SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
+    import copy
+    import random
+    for ind in range(0,theNum):
+        anObj = copy.deepcopy(thePattern);
+        if ind%2 :
+            #try incorrect value deliberately (but allowed by idl description)
+            #try SetScalarMode(long)
+            mode = random.randint(-100000,100000); #incorrect value deliberately
+        else:
+            #correct value of ScalarMode
+            mode = random.randint(0, 3)
+
+        print "\tSetScalarMode(" + str(mode) +")"
+        anObj.SetScalarMode(mode)
+
+        # --- SCALING ---
+        scal = random.randint(0,1)
+        print "\tSetScaling(" + str(SCALING[scal]) +")"
+        anObj.SetScaling(SCALING[scal])
+        
+        # --- BOUNDARIES ---
+        if ind%2 :
+            alfa =  random.random()*random.randint(-100000,100000)
+            betta = random.random()*random.randint(-100000,100000)
+            aMin = alfa; aMax = betta
+        else:
+            #more correct set
+            aPMin = thePattern.GetMin()
+            aPMax = thePattern.GetMax()
+            aLen = aPMax - aPMin
+            alfa =  random.random()%0.5
+            betta = random.random()%0.5
+            aMin = alfa*aLen*random.randint(-1,1) + aPMin
+            aMax = betta*aLen*random.randint(-1,1) + aPMax
+        print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
+        anObj.SetRange(aMin, aMax)
+        aList.append(anObj) 
+       
+    return aList