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 ScalarBarLength: ", bar.ScalarBarLength)
154 print("Default ScalarBarThickness: ", bar.ScalarBarThickness)
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)
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)
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)
173 #print "Set negative number of colors"
175 #lt.NumberOfTableValues = num
176 #print "Number of colors: ", lt.NumberOfTableValues
177 #pvsimple.Render(view)
179 print("Set zero number of colors")
181 lt.NumberOfTableValues = num
182 print("Number of colors: ", lt.NumberOfTableValues)
183 pvsimple.Render(view)
185 print("Set positive number of colors")
187 lt.NumberOfTableValues = num
188 print("Number of colors: ", lt.NumberOfTableValues)
189 pvsimple.Render(view)
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)
196 #print("Set negative number of labels")
198 #bar.NumberOfLabels = num
199 #print("Number of labels: ", bar.NumberOfLabels)
200 #pvsimple.Render(view)
202 #print("Set zero number of labels")
204 #bar.NumberOfLabels = num
205 #print("Number of labels: ", bar.NumberOfLabels)
206 #pvsimple.Render(view)
208 #print("Set positive number of labels")
210 #bar.NumberOfLabels = num
211 #print("Number of labels: ", bar.NumberOfLabels)
212 #pvsimple.Render(view)
214 #=============Stage11: bar title of Scalar Map On Deformed Shape=========
215 print("Changing bar title:")
216 print("Default bar title: ", bar.Title)
218 print("Set not null title")
219 title = "Scalar Bar Title"
221 print('Bar title: "' + bar.Title + '"')
222 pvsimple.Render(view)
224 print("Set title from spaces")
227 print('Bar title: "' + bar.Title + '"')
228 pvsimple.Render(view)
230 #============Stage12: scale factor of ScalarMap On Deformed Shape =====
231 print("Changing scale factor:")
232 warp_vector = smondefshape2.Input
234 print('Default scale: ', warp_vector.ScaleFactor)
237 warp_vector.ScaleFactor = scale
238 warp_vector.UpdatePipeline()
239 print("Scale: ", warp_vector.ScaleFactor)
240 pvsimple.Render(view)