1 # Copyright (C) 2010-2016 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # This case corresponds to: /visu/ScalarMap_On_DeformedShape/B3 case
22 from paravistest import datadir
23 from presentations import *
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()
32 if med_reader is None:
37 view = pvsimple.GetRenderView()
40 #=============Stage2: Create Scalar Map On Deformed Shape=============
41 field_name = "VITESSE"
42 node_entity = EntityType.NODE
45 print("Creating Scalar Map On Deformed Shape...................", end=' ')
46 smondefshape1 = DeformedShapeAndScalarMapOnField(med_reader, node_entity,
49 if smondefshape1 is None:
52 display_only(smondefshape1, view)
53 pvsimple.ResetCamera(view)
56 #=============Stage3: Create with 'Y' vector mode========================
58 smondefshape2 = DeformedShapeAndScalarMapOnField(med_reader,
63 print("Creating Scalar Map On Deformed Shape with 'Y' scalar mode.....", end=' ')
64 if smondefshape2 is None:
69 #=============Stage4: scaling of Scalar Map On Deformed Shape============
73 print("Changing scaling mode:")
75 print("Log scaling ....", lt.UseLogScale)
79 print("Log scaling ....", lt.UseLogScale)
82 #=============Stage5: range of Scalar Map On Deformed Shape==============
83 print("Changing scalar range:")
86 lt.RGBPoints[0] = range_min
87 lt.RGBPoints[4] = range_max
88 print("min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4]))
93 lt.RGBPoints[0] = range_min
94 lt.RGBPoints[4] = range_max
95 print("min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4]))
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)
105 #=============Stage6: bar orientation of Scalar Map On Deformed Shape==
106 print("Changing bar orientation:")
107 print("Default orientation: ", bar.Orientation)
109 print("Set horizontal bar orientation")
110 bar.Orientation = 'Horizontal'
111 print("Bar orientation: ", bar.Orientation)
112 pvsimple.Render(view)
114 print("Set vertical bar orientation")
115 bar.Orientation = 'Vertical'
116 print("Bar orientation: ", bar.Orientation)
117 pvsimple.Render(view)
119 #=============Stage7: bar position of Scalar Map On Deformed Shape ====
120 print("Changing bar position:")
121 print("Default position: ", bar.Position)
123 print("Set position X,Y positive")
126 bar.Position = [x_pos, y_pos]
127 print("Bar position [X,Y]: ", bar.Position)
128 pvsimple.Render(view)
130 print("Set position X negative ,Y positive")
133 bar.Position = [x_pos, y_pos]
134 print("Bar position [X,Y]: ", bar.Position)
135 pvsimple.Render(view)
137 print("Set position X positive, Y negative")
140 bar.Position = [x_pos, y_pos]
141 print("Bar position [X,Y]: ", bar.Position)
142 pvsimple.Render(view)
144 print("Set position X = 0.1, Y = 0.01")
147 bar.Position = [x_pos, y_pos]
148 print("Bar position [X,Y]: ", bar.Position)
149 pvsimple.Render(view)
151 #============Stage8: bar size of Scalar Map On Deformed Shape===========
152 print("Changing bar size:")
153 print("Default [width, height]: ", bar.Position2)
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)
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)
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)
172 #print "Set negative number of colors"
174 #lt.NumberOfTableValues = num
175 #print "Number of colors: ", lt.NumberOfTableValues
176 #pvsimple.Render(view)
178 print("Set zero number of colors")
180 lt.NumberOfTableValues = num
181 print("Number of colors: ", lt.NumberOfTableValues)
182 pvsimple.Render(view)
184 print("Set positive number of colors")
186 lt.NumberOfTableValues = num
187 print("Number of colors: ", lt.NumberOfTableValues)
188 pvsimple.Render(view)
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)
194 print("Set negative number of labels")
196 bar.NumberOfLabels = num
197 print("Number of labels: ", bar.NumberOfLabels)
198 pvsimple.Render(view)
200 print("Set zero number of labels")
202 bar.NumberOfLabels = num
203 print("Number of labels: ", bar.NumberOfLabels)
204 pvsimple.Render(view)
206 print("Set positive number of labels")
208 bar.NumberOfLabels = num
209 print("Number of labels: ", bar.NumberOfLabels)
210 pvsimple.Render(view)
212 #=============Stage11: bar title of Scalar Map On Deformed Shape=========
213 print("Changing bar title:")
214 print("Default bar title: ", bar.Title)
216 print("Set not null title")
217 title = "Scalar Bar Title"
219 print('Bar title: "' + bar.Title + '"')
220 pvsimple.Render(view)
222 print("Set title from spaces")
225 print('Bar title: "' + bar.Title + '"')
226 pvsimple.Render(view)
228 #============Stage12: scale factor of ScalarMap On Deformed Shape =====
229 print("Changing scale factor:")
230 warp_vector = smondefshape2.Input
232 print('Default scale: ', warp_vector.ScaleFactor)
235 warp_vector.ScaleFactor = scale
236 warp_vector.UpdatePipeline()
237 print("Scale: ", warp_vector.ScaleFactor)
238 pvsimple.Render(view)