Salome HOME
Merge Python 3 porting.
[modules/paravis.git] / test / VisuPrs / SWIG_scripts / B5.py
1 # Copyright (C) 2010-2016  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 pvsimple
27
28 DELAY = 2
29
30 # Step 1
31 print('Importing "pointe.med"...............', end=' ')
32 file_path = datadir + "pointe.med"
33 pvsimple.OpenDataFile(file_path)
34 med_reader = pvsimple.GetActiveSource()
35
36 if med_reader is None:
37     print("FAILED")
38 else:
39     print("OK")
40
41 field_name = "fieldnodedouble"
42 entity = EntityType.NODE
43 timestamp = 1
44
45
46 # Step 2
47 view1 = pvsimple.GetRenderView()
48 print("view1 = pvsimple.GetRenderView()")
49
50 sleep(DELAY)
51
52 delete_pv_object(view1)
53 print("delete_pv_object(view1)")
54
55
56 # Step 3
57 view2 = pvsimple.CreateRenderView()
58 print("view2 = pvsimple.CreateRenderView()")
59
60 color = [0.0, 0.3, 1.0]
61 view2.Background = color
62 print("view2.Background =", str(color))
63 pvsimple.Render(view2)
64
65 scalarmap = ScalarMapOnField(med_reader, entity, field_name, timestamp)
66 print("ScalarMapOnField(...)")
67 scalarmap.Visibility = 1
68 pvsimple.Render(view2)
69
70 view2.CameraFocalPoint = [0, 0, 0]
71 print("view2.CameraFocalPoint = [0, 0, 0]")
72 view2.CameraParallelScale = 2
73 print("view2.CameraParallelScale = 2")
74 pvsimple.Render(view2)
75
76 view2.ResetCamera()
77 print("view2.ResetCamera()")
78 pvsimple.Render(view2)
79
80 sleep(DELAY)
81
82
83 # Step 4
84 view3 = pvsimple.CreateRenderView()
85 print("view3 = pvsimple.CreateRenderView()")
86
87 color = [0.0, 0.7, 0.0]
88 view3.Background = color
89 print("view3.Background = ", str(color))
90 pvsimple.Render(view3)
91
92 cutplanes = CutPlanesOnField(med_reader, entity, field_name, timestamp,
93                              orientation=Orientation.XY)
94 print("CutPlanesOnField(...)")
95
96 display_only(cutplanes, view3)
97 print("display_only(cutplanes, view3)")
98
99 point = view3.CameraFocalPoint
100 point[0] = point[0] + 10
101 view3.CameraFocalPoint = point
102 print("view3.CameraFocalPoint = ", str(point))
103
104 view3.ResetCamera()
105 print("view3.ResetCamera()")
106 pvsimple.Render(view3)
107 print("pvsimple.Render(view3)")
108
109 sleep(DELAY)
110
111
112 # Step 5
113 view4 = pvsimple.CreateRenderView()
114 print("view4 = pvsimple.CreateRenderView()")
115
116 color = [1.0, 0.7, 0.0]
117 view4.Background = color
118 print("view5.Background = ", str(color))
119 pvsimple.Render(view4)
120
121 isosurfaces = IsoSurfacesOnField(med_reader, entity, field_name, timestamp)
122 print("isosurfaces = IsoSurfacesOnField(...)")
123
124 display_only(isosurfaces, view4)
125 print("display_only(isosurfaces, view4)")
126 view4.ResetCamera()
127 print("view4.ResetCamera()")
128
129 pvsimple.Render(view4)
130 print("pvsimple.Render(view4)")
131
132 sleep(DELAY)
133
134
135 # Step 6
136 view5 = pvsimple.CreateRenderView()
137 print("view5 = pvsimple.CreateRenderView()")
138
139 color = [0.7, 0.7, 0.7]
140 view5.Background = color
141 print("view5.Background =", str(color))
142 pvsimple.Render(view5)
143
144 cutlines = CutLinesOnField(med_reader, entity, field_name, timestamp,
145                            orientation1=Orientation.ZX,
146                            orientation2=Orientation.YZ)
147 print("cutlines = CutLinesOnField(...)")
148
149 display_only(cutlines, view5)
150 print("display_only(cutlines, view5)")
151 pvsimple.ResetCamera(view5)
152 print("pvsimple.ResetCamera(view5)")
153
154 sleep(DELAY)
155
156
157 # Step 7
158 file_path = tablesdir + "sinus.csv"
159 sinus_csv = pvsimple.CSVReader(FileName=file_path)
160 sinus_csv.FieldDelimiterCharacters = ' '
161
162 view6 = pvsimple.CreateXYPlotView()
163 print("view6 = pvsimple.CreateXYPlotView()")
164
165 xy_rep = pvsimple.Show(sinus_csv)
166 xy_rep.AttributeType = 'Row Data'
167 xy_rep.UseIndexForXAxis = 0
168 xy_rep.XArrayName = 'x'
169 xy_rep.SeriesVisibility = ['x', '0']
170
171 sleep(DELAY)