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