]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/SWIG_scripts/B5.py
Salome HOME
Copyrights update 2015.
[modules/paravis.git] / test / VisuPrs / SWIG_scripts / B5.py
1 # Copyright (C) 2010-2015  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This case corresponds to: /visu/SWIG_scripts/B5 case
21
22 from time import sleep
23
24 from paravistest import datadir, tablesdir
25 from presentations import *
26 import pvserver as paravis
27 import pvsimple
28
29
30 DELAY = 2
31
32 my_paravis = paravis.myParavis
33
34 # Step 1
35 print 'Importing "pointe.med"...............',
36 file_path = datadir + "pointe.med"
37 OpenDataFile(file_path)
38 med_reader = pvsimple.GetActiveSource()
39
40 if med_reader is None:
41     print "FAILED"
42 else:
43     print "OK"
44
45 field_name = "fieldnodedouble"
46 entity = EntityType.NODE
47 timestamp = 1
48
49
50 # Step 2
51 view1 = pvsimple.GetRenderView()
52 print "view1 = pvsimple.GetRenderView()"
53
54 sleep(DELAY)
55
56 pvsimple.Delete(view1)
57 print "pvsimple.Delete(view1)"
58
59
60 # Step 3
61 view2 = pvsimple.CreateRenderView()
62 print "view2 = pvsimple.CreateRenderView()"
63
64 color = [0.0, 0.3, 1.0]
65 view2.Background = color
66 print "view2.Background =", str(color)
67 pvsimple.Render(view2)
68
69 scalarmap = ScalarMapOnField(med_reader, entity, field_name, timestamp)
70 print "ScalarMapOnField(...)"
71 scalarmap.Visibility = 1
72 pvsimple.Render(view2)
73
74 view2.CameraFocalPoint = [0, 0, 0]
75 print "view2.CameraFocalPoint = [0, 0, 0]"
76 view2.CameraParallelScale = 2
77 print "view2.CameraParallelScale = 2"
78 pvsimple.Render(view2)
79
80 view2.ResetCamera()
81 print "view2.ResetCamera()"
82 pvsimple.Render(view2)
83
84 sleep(DELAY)
85
86
87 # Step 4
88 view3 = pvsimple.CreateRenderView()
89 print "view3 = pvsimple.CreateRenderView()"
90
91 color = [0.0, 0.7, 0.0]
92 view3.Background = color
93 print "view3.Background = ", str(color)
94 pvsimple.Render(view3)
95
96 cutplanes = CutPlanesOnField(med_reader, entity, field_name, timestamp,
97                              orientation=Orientation.XY)
98 print "CutPlanesOnField(...)"
99
100 display_only(cutplanes, view3)
101 print "display_only(cutplanes, view3)"
102
103 point = view3.CameraFocalPoint
104 point[0] = point[0] + 10
105 view3.CameraFocalPoint = point
106 print "view3.CameraFocalPoint = ", str(point)
107
108 view3.ResetCamera()
109 print "view3.ResetCamera()"
110 pvsimple.Render(view3)
111 print "pvsimple.Render(view3)"
112
113 sleep(DELAY)
114
115
116 # Step 5
117 view4 = pvsimple.CreateRenderView()
118 print "view4 = pvsimple.CreateRenderView()"
119
120 color = [1.0, 0.7, 0.0]
121 view4.Background = color
122 print "view5.Background = ", str(color)
123 pvsimple.Render(view4)
124
125 isosurfaces = IsoSurfacesOnField(med_reader, entity, field_name, timestamp)
126 print "isosurfaces = IsoSurfacesOnField(...)"
127
128 display_only(isosurfaces, view4)
129 print "display_only(isosurfaces, view4)"
130 view4.ResetCamera()
131 print "view4.ResetCamera()"
132
133 pvsimple.Render(view4)
134 print "pvsimple.Render(view4)"
135
136 sleep(DELAY)
137
138
139 # Step 6
140 view5 = pvsimple.CreateRenderView()
141 print "view5 = pvsimple.CreateRenderView()"
142
143 color = [0.7, 0.7, 0.7]
144 view5.Background = color
145 print "view5.Background =", str(color)
146 pvsimple.Render(view5)
147
148 cutlines = CutLinesOnField(med_reader, entity, field_name, timestamp,
149                            orientation1=Orientation.ZX,
150                            orientation2=Orientation.YZ)
151 print "cutlines = CutLinesOnField(...)"
152
153 display_only(cutlines, view5)
154 print "display_only(cutlines, view5)"
155 pvsimple.ResetCamera(view5)
156 print "pvsimple.ResetCamera(view5)"
157
158 sleep(DELAY)
159
160
161 # Step 7
162 file_path = tablesdir + "sinus.csv"
163 sinus_csv = pvsimple.CSVReader(FileName=file_path)
164 sinus_csv.FieldDelimiterCharacters = ' '
165
166 view6 = pvsimple.CreateXYPlotView()
167 print "view6 = pvsimple.CreateXYPlotView()"
168
169 xy_rep = pvsimple.Show(sinus_csv)
170 xy_rep.AttributeType = 'Row Data'
171 xy_rep.UseIndexForXAxis = 0
172 xy_rep.XArrayName = 'x'
173 xy_rep.SeriesVisibility = ['x', '0']
174
175 sleep(DELAY)