]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/ScalarMap_On_DeformedShape/B3.py
Salome HOME
Paraview 5.4: ScalarBar no longer have Position2 and NumberOfLabels attributes
[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"...................', end=' ')
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...................", end=' ')
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.....", end=' ')
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 ScalarBarLength: ", bar.ScalarBarLength)
154 print("Default ScalarBarThickness: ", bar.ScalarBarThickness)
155
156 print("Set length = length*1.2")
157 length = bar.ScalarBarLength * 1.2
158 bar.ScalarBarLength = length
159 print("Bar length: ", bar.ScalarBarLength)
160 pvsimple.Render(view)
161
162 print("Set thickness = thickness*2")
163 thickness = bar.ScalarBarThickness * 2
164 bar.ScalarBarThickness = thickness
165 print("Bar thickness: ", bar.ScalarBarThickness)
166 pvsimple.Render(view)
167
168 #=============Stage9: nb of colors of Scalar Map On Deformed Shape======
169 print("Changing number of colors:")
170 print("Default number of colors: ", lt.NumberOfTableValues)
171 lt.Discretize = 1
172
173 #print "Set negative number of colors"
174 #num = -128
175 #lt.NumberOfTableValues = num
176 #print "Number of colors: ", lt.NumberOfTableValues
177 #pvsimple.Render(view)
178
179 print("Set zero number of colors")
180 num = 0
181 lt.NumberOfTableValues = num
182 print("Number of colors: ", lt.NumberOfTableValues)
183 pvsimple.Render(view)
184
185 print("Set positive number of colors")
186 num = 256
187 lt.NumberOfTableValues = num
188 print("Number of colors: ", lt.NumberOfTableValues)
189 pvsimple.Render(view)
190
191 # NumberOfLabels no longer exists in Paraview 5.4
192 #=============Stage10: nb of labels of Scalar Map On Deformed Shape=====
193 #print("Changing number of labels:")
194 #print("Default number of labels: ", bar.NumberOfLabels)
195
196 #print("Set negative number of labels")
197 #num = -128
198 #bar.NumberOfLabels = num
199 #print("Number of labels: ", bar.NumberOfLabels)
200 #pvsimple.Render(view)
201
202 #print("Set zero number of labels")
203 #num = 0
204 #bar.NumberOfLabels = num
205 #print("Number of labels: ", bar.NumberOfLabels)
206 #pvsimple.Render(view)
207
208 #print("Set positive number of labels")
209 #num = 256
210 #bar.NumberOfLabels = num
211 #print("Number of labels: ", bar.NumberOfLabels)
212 #pvsimple.Render(view)
213
214 #=============Stage11: bar title of Scalar Map On Deformed Shape=========
215 print("Changing bar title:")
216 print("Default bar title: ", bar.Title)
217
218 print("Set not null title")
219 title = "Scalar Bar Title"
220 bar.Title = title
221 print('Bar title: "' + bar.Title + '"')
222 pvsimple.Render(view)
223
224 print("Set title from spaces")
225 title = '    '
226 bar.Title = title
227 print('Bar title: "' + bar.Title + '"')
228 pvsimple.Render(view)
229
230 #============Stage12: scale factor of ScalarMap On Deformed Shape =====
231 print("Changing scale factor:")
232 warp_vector = smondefshape2.Input
233
234 print('Default scale: ', warp_vector.ScaleFactor)
235
236 scale = 0.8
237 warp_vector.ScaleFactor = scale
238 warp_vector.UpdatePipeline()
239 print("Scale: ", warp_vector.ScaleFactor)
240 pvsimple.Render(view)