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