Salome HOME
NRI : merge from 1.2c
[modules/visu.git] / src / VISU_SWIG / batchmode_visu.py
1 #  VISU VISU_SWIG : binding of C++ implementation and Python
2 #
3 #  Copyright (C) 2003  CEA/DEN, EDF R&D
4 #
5 #
6 #
7 #  File   : batchmode_visu.py
8 #  Module : VISU
9
10 from batchmode_salome import *
11 import visu
12
13 myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10)
14 if myVisu is None:
15     raise RuntimeError, "myVisu is none, VISU component is not loaded  or found"
16
17 def try_mesh_parameters(theMeshPattern):
18     aResult = []
19     if theMeshPattern is None : return aResult ;
20     theMeshPattern =  theMeshPattern._narrow(VISU.Mesh)
21     if theMeshPattern is None : return aResult ;
22
23     aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
24     import copy; import os;
25     for ind in aTYPES:
26         aNewMesh = copy.deepcopy(theMeshPattern);
27         aNewMesh.SetPresentationType(ind)
28         aResult.append(aNewMesh)
29
30     return aResult
31     
32 def try_scalarmap_parameters(thePattern, theNum):
33     aList = []
34     if thePattern  is None : return aList 
35     thePattern =  thePattern._narrow(VISU.ScalarMap)
36     if thePattern  is None : return aList 
37     SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
38     import copy
39     import random
40     for ind in range(0,theNum):
41         anObj = copy.deepcopy(thePattern);
42         if ind%2 :
43             #try incorrect value deliberately (but allowed by idl description)
44             #try SetScalarMode(long)
45             mode = random.randint(-100000,100000); #incorrect value deliberately
46         else:
47             #correct value of ScalarMode
48             mode = random.randint(0, 3)
49
50         print "\tSetScalarMode(" + str(mode) +")"
51         anObj.SetScalarMode(mode)
52
53         # --- SCALING ---
54         scal = random.randint(0,1)
55         print "\tSetScaling(" + str(SCALING[scal]) +")"
56         anObj.SetScaling(SCALING[scal])
57         
58         # --- BOUNDARIES ---
59         if ind%2 :
60             alfa =  random.random()*random.randint(-100000,100000)
61             betta = random.random()*random.randint(-100000,100000)
62             aMin = alfa; aMax = betta
63         else:
64             #more correct set
65             aPMin = thePattern.GetMin()
66             aPMax = thePattern.GetMax()
67             aLen = aPMax - aPMin
68             alfa =  random.random()%0.5
69             betta = random.random()%0.5
70             aMin = alfa*aLen*random.randint(-1,1) + aPMin
71             aMax = betta*aLen*random.randint(-1,1) + aPMax
72         print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
73         anObj.SetRange(aMin, aMax)
74         aList.append(anObj) 
75        
76     return aList