Salome HOME
Merge remote branch 'origin/V7_dev'
[modules/paravis.git] / test / VisuPrs / ScalarMap_On_DeformedShape / B3.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/ScalarMap_On_DeformedShape/B3 case
21
22 from paravistest import datadir
23 from presentations import *
24 import pvsimple
25
26 #====================Stage1: Import MED file=========================
27 print 'Importing "fra.med"...................',
28 medFile = datadir + "fra.med"
29 pvsimple.OpenDataFile(medFile)
30 med_reader = pvsimple.GetActiveSource()
31
32 if med_reader is None:
33     print "FAILED"
34 else:
35     print "OK"
36
37 view = pvsimple.GetRenderView()
38 reset_view(view)
39
40 #=============Stage2: Create Scalar Map On Deformed Shape=============
41 field_name = "VITESSE"
42 node_entity = EntityType.NODE
43 timestamp = 1
44
45 print "Creating Scalar Map On Deformed Shape...................",
46 smondefshape1 = DeformedShapeAndScalarMapOnField(med_reader, node_entity,
47                                                  field_name, 1)
48
49 if smondefshape1 is None:
50     print "FAILED"
51 else:
52     display_only(smondefshape1, view)
53     pvsimple.ResetCamera(view)
54     print "OK"
55
56 #=============Stage3: Create with 'Y' vector mode========================
57 hide_all(view)
58 smondefshape2 = DeformedShapeAndScalarMapOnField(med_reader,
59                                                  node_entity,
60                                                  field_name, 1,
61                                                  vector_mode='Y')
62
63 print "Creating Scalar Map On Deformed Shape with 'Y' scalar mode.....",
64 if smondefshape2 is None:
65     print "FAILED"
66 else:
67     print "OK"
68
69 #=============Stage4: scaling of Scalar Map On Deformed Shape============
70 bar = get_bar()
71 lt = bar.LookupTable
72
73 print "Changing scaling mode:"
74 lt.UseLogScale = 0
75 print "Log scaling ....", lt.UseLogScale
76 pvsimple.Render(view)
77
78 lt.UseLogScale = 1
79 print "Log scaling ....", lt.UseLogScale
80 pvsimple.Render()
81
82 #=============Stage5: range of Scalar Map On Deformed Shape==============
83 print "Changing scalar range:"
84 range_min = 12
85 range_max = 120
86 lt.RGBPoints[0] = range_min
87 lt.RGBPoints[4] = range_max
88 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
89 pvsimple.Render(view)
90
91 range_min = 120
92 range_max = 120
93 lt.RGBPoints[0] = range_min
94 lt.RGBPoints[4] = range_max
95 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
96 pvsimple.Render(view)
97
98 range_min = 120
99 range_max = 15
100 lt.RGBPoints[0] = range_min
101 lt.RGBPoints[4] = range_max
102 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
103 pvsimple.Render(view)
104
105 #=============Stage6: bar orientation of Scalar Map On Deformed Shape==
106 print "Changing bar orientation:"
107 print "Default orientation: ", bar.Orientation
108
109 print "Set horizontal bar orientation"
110 bar.Orientation = 'Horizontal'
111 print "Bar orientation: ", bar.Orientation
112 pvsimple.Render(view)
113
114 print "Set vertical bar orientation"
115 bar.Orientation = 'Vertical'
116 print "Bar orientation: ", bar.Orientation
117 pvsimple.Render(view)
118
119 #=============Stage7: bar position of Scalar Map On Deformed Shape ====
120 print "Changing bar position:"
121 print "Default position: ", bar.Position
122
123 print "Set position X,Y positive"
124 x_pos = 200
125 y_pos = 100
126 bar.Position = [x_pos, y_pos]
127 print "Bar position [X,Y]: ", bar.Position
128 pvsimple.Render(view)
129
130 print "Set position X negative ,Y positive"
131 x_pos = -100
132 y_pos = 150
133 bar.Position = [x_pos, y_pos]
134 print "Bar position [X,Y]: ", bar.Position
135 pvsimple.Render(view)
136
137 print "Set position X positive, Y negative"
138 x_pos = 100
139 y_pos = -100
140 bar.Position = [x_pos, y_pos]
141 print "Bar position [X,Y]: ", bar.Position
142 pvsimple.Render(view)
143
144 print "Set position X = 0.1, Y = 0.01"
145 x_pos = 0.1
146 y_pos = 0.01
147 bar.Position = [x_pos, y_pos]
148 print "Bar position [X,Y]: ", bar.Position
149 pvsimple.Render(view)
150
151 #============Stage8: bar size of Scalar Map On Deformed Shape===========
152 print "Changing bar size:"
153 print "Default [width, height]: ", bar.Position2
154
155 print "Set height = height*1.2"
156 height = bar.Position2[1] * 1.2
157 bar.Position2[1] = height
158 print "Bar [width, height]: ", bar.Position2
159 pvsimple.Render(view)
160
161 print "Set width = width*2"
162 width = bar.Position2[0] * 2
163 bar.Position2[0] = width
164 print "Bar [width, height]: ", bar.Position2
165 pvsimple.Render(view)
166
167 #=============Stage9: nb of colors of Scalar Map On Deformed Shape======
168 print "Changing number of colors:"
169 print "Default number of colors: ", lt.NumberOfTableValues
170 lt.Discretize = 1
171
172 #print "Set negative number of colors"
173 #num = -128
174 #lt.NumberOfTableValues = num
175 #print "Number of colors: ", lt.NumberOfTableValues
176 #pvsimple.Render(view)
177
178 print "Set zero number of colors"
179 num = 0
180 lt.NumberOfTableValues = num
181 print "Number of colors: ", lt.NumberOfTableValues
182 pvsimple.Render(view)
183
184 print "Set positive number of colors"
185 num = 256
186 lt.NumberOfTableValues = num
187 print "Number of colors: ", lt.NumberOfTableValues
188 pvsimple.Render(view)
189
190 #=============Stage10: nb of labels of Scalar Map On Deformed Shape=====
191 print "Changing number of labels:"
192 print "Default number of labels: ", bar.NumberOfLabels
193
194 print "Set negative number of labels"
195 num = -128
196 bar.NumberOfLabels = num
197 print "Number of labels: ", bar.NumberOfLabels
198 pvsimple.Render(view)
199
200 print "Set zero number of labels"
201 num = 0
202 bar.NumberOfLabels = num
203 print "Number of labels: ", bar.NumberOfLabels
204 pvsimple.Render(view)
205
206 print "Set positive number of labels"
207 num = 256
208 bar.NumberOfLabels = num
209 print "Number of labels: ", bar.NumberOfLabels
210 pvsimple.Render(view)
211
212 #=============Stage11: bar title of Scalar Map On Deformed Shape=========
213 print "Changing bar title:"
214 print "Default bar title: ", bar.Title
215
216 print "Set not null title"
217 title = "Scalar Bar Title"
218 bar.Title = title
219 print 'Bar title: "' + bar.Title + '"'
220 pvsimple.Render(view)
221
222 print "Set title from spaces"
223 title = '    '
224 bar.Title = title
225 print 'Bar title: "' + bar.Title + '"'
226 pvsimple.Render(view)
227
228 #============Stage12: scale factor of ScalarMap On Deformed Shape =====
229 print "Changing scale factor:"
230 warp_vector = smondefshape2.Input
231
232 print 'Default scale: ', warp_vector.ScaleFactor
233
234 scale = 0.8
235 warp_vector.ScaleFactor = scale
236 warp_vector.UpdatePipeline()
237 print "Scale: ", warp_vector.ScaleFactor
238 pvsimple.Render(view)