]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/batchmode_visu.py
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/visu.git] / src / VISU_SWIG / batchmode_visu.py
1 #  VISU VISU_SWIG : binding of C++ implementation and Python
2 #
3 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5
6 #  This library is free software; you can redistribute it and/or 
7 #  modify it under the terms of the GNU Lesser General Public 
8 #  License as published by the Free Software Foundation; either 
9 #  version 2.1 of the License. 
10
11 #  This library is distributed in the hope that it will be useful, 
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 #  Lesser General Public License for more details. 
15
16 #  You should have received a copy of the GNU Lesser General Public 
17 #  License along with this library; if not, write to the Free Software 
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #  File   : batchmode_visu.py
23 #  Module : VISU
24
25 from batchmode_salome import *
26 import visu
27
28 myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10)
29 if myVisu is None:
30     raise RuntimeError, "myVisu is none, VISU component is not loaded  or found"
31
32 def try_mesh_parameters(theMeshPattern):
33     aResult = []
34     if theMeshPattern is None : return aResult ;
35     theMeshPattern =  theMeshPattern._narrow(VISU.Mesh)
36     if theMeshPattern is None : return aResult ;
37
38     aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
39     import copy; import os;
40     for ind in aTYPES:
41         aNewMesh = copy.deepcopy(theMeshPattern);
42         aNewMesh.SetPresentationType(ind)
43         aResult.append(aNewMesh)
44
45     return aResult
46     
47 def try_scalarmap_parameters(thePattern, theNum):
48     aList = []
49     if thePattern  is None : return aList 
50     thePattern =  thePattern._narrow(VISU.ScalarMap)
51     if thePattern  is None : return aList 
52     SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
53     import copy
54     import random
55     for ind in range(0,theNum):
56         anObj = copy.deepcopy(thePattern);
57         if ind%2 :
58             #try incorrect value deliberately (but allowed by idl description)
59             #try SetScalarMode(long)
60             mode = random.randint(-100000,100000); #incorrect value deliberately
61         else:
62             #correct value of ScalarMode
63             mode = random.randint(0, 3)
64
65         print "\tSetScalarMode(" + str(mode) +")"
66         anObj.SetScalarMode(mode)
67
68         # --- SCALING ---
69         scal = random.randint(0,1)
70         print "\tSetScaling(" + str(SCALING[scal]) +")"
71         anObj.SetScaling(SCALING[scal])
72         
73         # --- BOUNDARIES ---
74         if ind%2 :
75             alfa =  random.random()*random.randint(-100000,100000)
76             betta = random.random()*random.randint(-100000,100000)
77             aMin = alfa; aMax = betta
78         else:
79             #more correct set
80             aPMin = thePattern.GetMin()
81             aPMax = thePattern.GetMax()
82             aLen = aPMax - aPMin
83             alfa =  random.random()%0.5
84             betta = random.random()%0.5
85             aMin = alfa*aLen*random.randint(-1,1) + aPMin
86             aMax = betta*aLen*random.randint(-1,1) + aPMax
87         print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
88         anObj.SetRange(aMin, aMax)
89         aList.append(anObj) 
90        
91     return aList