1 # Copyright (C) 2010-2014 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 *
27 my_paravis = paravis.myParavis
29 #====================Stage1: Import MED file=========================
30 print 'Importing "fra.med"...................',
31 medFile = datadir + "fra.med"
32 my_paravis.ImportFile(medFile)
33 med_reader = pvsimple.GetActiveSource()
35 if med_reader is None:
40 view = pvsimple.GetRenderView()
43 #=============Stage2: Create Scalar Map On Deformed Shape=============
44 field_name = "VITESSE"
45 node_entity = EntityType.NODE
48 print "Creating Scalar Map On Deformed Shape...................",
49 smondefshape1 = DeformedShapeAndScalarMapOnField(med_reader, node_entity,
52 if smondefshape1 is None:
55 display_only(smondefshape1, view)
56 pvsimple.ResetCamera(view)
59 #=============Stage3: Create with 'Y' vector mode========================
61 smondefshape2 = DeformedShapeAndScalarMapOnField(med_reader,
66 print "Creating Scalar Map On Deformed Shape with 'Y' scalar mode.....",
67 if smondefshape2 is None:
72 #=============Stage4: scaling of Scalar Map On Deformed Shape============
76 print "Changing scaling mode:"
78 print "Log scaling ....", lt.UseLogScale
82 print "Log scaling ....", lt.UseLogScale
85 #=============Stage5: range of Scalar Map On Deformed Shape==============
86 print "Changing scalar range:"
89 lt.RGBPoints[0] = range_min
90 lt.RGBPoints[4] = range_max
91 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
96 lt.RGBPoints[0] = range_min
97 lt.RGBPoints[4] = range_max
98 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
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)
108 #=============Stage6: bar orientation of Scalar Map On Deformed Shape==
109 print "Changing bar orientation:"
110 print "Default orientation: ", bar.Orientation
112 print "Set horizontal bar orientation"
113 bar.Orientation = 'Horizontal'
114 print "Bar orientation: ", bar.Orientation
115 pvsimple.Render(view)
117 print "Set vertical bar orientation"
118 bar.Orientation = 'Vertical'
119 print "Bar orientation: ", bar.Orientation
120 pvsimple.Render(view)
122 #=============Stage7: bar position of Scalar Map On Deformed Shape ====
123 print "Changing bar position:"
124 print "Default position: ", bar.Position
126 print "Set position X,Y positive"
129 bar.Position = [x_pos, y_pos]
130 print "Bar position [X,Y]: ", bar.Position
131 pvsimple.Render(view)
133 print "Set position X negative ,Y positive"
136 bar.Position = [x_pos, y_pos]
137 print "Bar position [X,Y]: ", bar.Position
138 pvsimple.Render(view)
140 print "Set position X positive, Y negative"
143 bar.Position = [x_pos, y_pos]
144 print "Bar position [X,Y]: ", bar.Position
145 pvsimple.Render(view)
147 print "Set position X = 0.1, Y = 0.01"
150 bar.Position = [x_pos, y_pos]
151 print "Bar position [X,Y]: ", bar.Position
152 pvsimple.Render(view)
154 #============Stage8: bar size of Scalar Map On Deformed Shape===========
155 print "Changing bar size:"
156 print "Default [width, height]: ", bar.Position2
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)
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)
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
175 print "Set negative number of colors"
177 lt.NumberOfTableValues = num
178 print "Number of colors: ", lt.NumberOfTableValues
179 pvsimple.Render(view)
181 print "Set zero number of colors"
183 lt.NumberOfTableValues = num
184 print "Number of colors: ", lt.NumberOfTableValues
185 pvsimple.Render(view)
187 print "Set positive number of colors"
189 lt.NumberOfTableValues = num
190 print "Number of colors: ", lt.NumberOfTableValues
191 pvsimple.Render(view)
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
197 print "Set negative number of labels"
199 bar.NumberOfLabels = num
200 print "Number of labels: ", bar.NumberOfLabels
201 pvsimple.Render(view)
203 print "Set zero number of labels"
205 bar.NumberOfLabels = num
206 print "Number of labels: ", bar.NumberOfLabels
207 pvsimple.Render(view)
209 print "Set positive number of labels"
211 bar.NumberOfLabels = num
212 print "Number of labels: ", bar.NumberOfLabels
213 pvsimple.Render(view)
215 #=============Stage11: bar title of Scalar Map On Deformed Shape=========
216 print "Changing bar title:"
217 print "Default bar title: ", bar.Title
219 print "Set not null title"
220 title = "Scalar Bar Title"
222 print 'Bar title: "' + bar.Title + '"'
223 pvsimple.Render(view)
225 print "Set title from spaces"
228 print 'Bar title: "' + bar.Title + '"'
229 pvsimple.Render(view)
231 #============Stage12: scale factor of ScalarMap On Deformed Shape =====
232 print "Changing scale factor:"
233 warp_vector = smondefshape2.Input
235 print 'Default scale: ', warp_vector.ScaleFactor
238 warp_vector.ScaleFactor = scale
239 warp_vector.UpdatePipeline()
240 print "Scale: ", warp_vector.ScaleFactor
241 pvsimple.Render(view)