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