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/B3 case
21 # Test ScalarMap interface methods.
23 from paravistest import datadir
28 my_paravis = paravis.myParavis
32 print 'Importing "fra.med"...',
33 file_path = datadir + "fra.med"
34 my_paravis.ImportFile(file_path)
35 med_reader = pvsimple.GetActiveSource()
37 if med_reader is None:
43 field_name = 'TAUX_DE_VIDE'
44 entity = presentations.EntityType.NODE
45 myMeshName='LE VOLUME'
47 scalarmap = presentations.ScalarMapOnField(med_reader, entity, field_name, 1)
52 lookup_table = scalarmap.LookupTable
53 print "Vector mode .....", lookup_table.VectorMode
54 print "Vector component .....", lookup_table.VectorComponent
56 lookup_table.VectorMode = 'Component'
57 lookup_table.VectorComponent = 0
59 scalarmap.LookupTable = lookup_table
61 print "Vector mode .....", scalarmap.LookupTable.VectorMode
62 print "Vector component .....", scalarmap.LookupTable.VectorComponent
65 scalarmap.LookupTable.UseLogScale = 1
66 print "Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale
68 scalarmap.LookupTable.UseLogScale = 0
69 print "Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale
72 print "Set scalar range min=12 < max=120 ...",
75 scalarmap.LookupTable.RGBPoints[0] = rmin
76 scalarmap.LookupTable.RGBPoints[4] = rmax
77 print "min = ", scalarmap.LookupTable.RGBPoints[0]," : max = ",scalarmap.LookupTable.RGBPoints[4]
79 print "Set scalar range min=max=12 ...",
82 scalarmap.LookupTable.RGBPoints[0] = rmin
83 scalarmap.LookupTable.RGBPoints[4] = rmax
84 print "min = ", scalarmap.LookupTable.RGBPoints[0]," : max = ",scalarmap.LookupTable.RGBPoints[4]
86 print "Set scalar range min=120 > max=15 ...",
89 scalarmap.LookupTable.RGBPoints[0] = rmin
90 scalarmap.LookupTable.RGBPoints[4] = rmax
91 print "min = ", scalarmap.LookupTable.RGBPoints[0]," : max = ",scalarmap.LookupTable.RGBPoints[4]
94 bar = presentations.get_bar()
96 print "Set bar orientation = 'Horizontal'"
97 bar.Orientation = 'Horizontal'
98 print "Bar orientation ....", bar.Orientation
100 print "Set bar orientation = 'Vertical'"
101 bar.Orientation = 'Vertical'
102 print "Bar orientation ....", bar.Orientation
104 # 7. Position of scalar bar
105 print "Default position ....", bar.Position
107 print "Set left down corner position"
108 bar.Position = [0, 0]
109 print "Position =", bar.Position
111 print "Set position outside of the screen"
112 bar.Position = [-1, -1]
113 print "Position =", bar.Position
115 # 8. Size of scalar bar
116 print "Default Height=", bar.Position2[1]," : Width=", bar.Position2[0]
118 print "Set positive Height and Width"
121 bar.Position2 = [w, h]
122 print "Size =", bar.Position2
124 print "Set negative Height and Width"
127 bar.Position2 = [w, h]
128 print "Size =", bar.Position2
130 # 9. Number of colors
131 print "Default number of colors = ", scalarmap.LookupTable.NumberOfTableValues
133 scalarmap.LookupTable.Discretize = 1
135 print "Set negative number of colors"
137 scalarmap.LookupTable.NumberOfTableValues = nb_colors
138 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
140 print "Set zero number of colors"
142 scalarmap.LookupTable.NumberOfTableValues = nb_colors
143 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
145 print "Set positive number of colors"
147 scalarmap.LookupTable.NumberOfTableValues = nb_colors
148 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
150 # 10. Number of labels
151 print "Default number of labels = ", bar.NumberOfLabels
153 print "Set negative number of labels"
155 bar.NumberOfLabels = nb_labels
156 print "Number of labels=", bar.NumberOfLabels
158 print "Set zero number of labels"
160 bar.NumberOfLabels = nb_labels
161 print "Number of labels=", bar.NumberOfLabels
163 print "Set positive number of labels"
165 bar.NumberOfLabels = nb_labels
166 print "Number of labels=", bar.NumberOfLabels
168 # 11. Scalar bar title
169 print 'Default Title ="', bar.Title, '"'
171 print "Set not null title"
172 title = "Scalar Bar Title"
174 print ' Title ="', bar.Title, '"'
176 print "Set title from spaces"
179 print ' Title ="', bar.Title, '"'