]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/batchmode_visu.py
Salome HOME
sources v1.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 import os
11 import re
12 from time import sleep
13
14 import VISU
15 import SALOMEDS
16 import SALOME_MED
17 from omniORB import CORBA
18
19 from batchmode_salome import *
20 import visu
21
22 myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10)
23 if myVisu is None:
24     raise RuntimeError, "myVisu is none, VISU component is not loaded  or found"
25
26 def try_mesh_parameters(theMeshPattern):
27     aResult = []
28     if theMeshPattern is None : return aResult ;
29     theMeshPattern =  theMeshPattern._narrow(VISU.Mesh)
30     if theMeshPattern is None : return aResult ;
31
32     aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
33     import copy; import os;
34     for ind in aTYPES:
35         aNewMesh = copy.deepcopy(theMeshPattern);
36         aNewMesh.SetPresentationType(ind)
37         aResult.append(aNewMesh)
38
39     return aResult
40     
41 def try_scalarmap_parameters(thePattern, theNum):
42     aList = []
43     if thePattern  is None : return aList 
44     thePattern =  thePattern._narrow(VISU.ScalarMap)
45     if thePattern  is None : return aList 
46     SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
47     import copy
48     import random
49     for ind in range(0,theNum):
50         anObj = copy.deepcopy(thePattern);
51         if ind%2 :
52             #try incorrect value deliberately (but allowed by idl description)
53             #try SetScalarMode(long)
54             mode = random.randint(-100000,100000); #incorrect value deliberately
55         else:
56             #correct value of ScalarMode
57             mode = random.randint(0, 3)
58
59         print "\tSetScalarMode(" + str(mode) +")"
60         anObj.SetScalarMode(mode)
61
62         # --- SCALING ---
63         scal = random.randint(0,1)
64         print "\tSetScaling(" + str(SCALING[scal]) +")"
65         anObj.SetScaling(SCALING[scal])
66         
67         # --- BOUNDARIES ---
68         if ind%2 :
69             alfa =  random.random()*random.randint(-100000,100000)
70             betta = random.random()*random.randint(-100000,100000)
71             aMin = alfa; aMax = betta
72         else:
73             #more correct set
74             aPMin = thePattern.GetMin()
75             aPMax = thePattern.GetMax()
76             aLen = aPMax - aPMin
77             alfa =  random.random()%0.5
78             betta = random.random()%0.5
79             aMin = alfa*aLen*random.randint(-1,1) + aPMin
80             aMax = betta*aLen*random.randint(-1,1) + aPMax
81         print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
82         anObj.SetRange(aMin, aMax)
83         aList.append(anObj) 
84        
85     return aList