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/B3 case
21 # Test ScalarMap interface methods.
23 from paravistest import datadir
29 print 'Importing "fra.med"...',
30 file_path = datadir + "fra.med"
31 pvsimple.OpenDataFile(file_path)
32 med_reader = pvsimple.GetActiveSource()
34 if med_reader is None:
40 field_name = 'TAUX_DE_VIDE'
41 entity = presentations.EntityType.NODE
42 myMeshName='LE VOLUME'
44 scalarmap = presentations.ScalarMapOnField(med_reader, entity, field_name, 1)
49 lookup_table = scalarmap.LookupTable
50 print "Vector mode .....", lookup_table.VectorMode
51 print "Vector component .....", lookup_table.VectorComponent
53 lookup_table.VectorMode = 'Component'
54 lookup_table.VectorComponent = 0
56 scalarmap.LookupTable = lookup_table
58 print "Vector mode .....", scalarmap.LookupTable.VectorMode
59 print "Vector component .....", scalarmap.LookupTable.VectorComponent
62 scalarmap.LookupTable.UseLogScale = 1
63 print "Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale
65 scalarmap.LookupTable.UseLogScale = 0
66 print "Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale
69 print "Set scalar range min=12 < max=120 ...",
72 scalarmap.LookupTable.RGBPoints[0] = rmin
73 scalarmap.LookupTable.RGBPoints[4] = rmax
74 print "min = ", scalarmap.LookupTable.RGBPoints[0]," : max = ",scalarmap.LookupTable.RGBPoints[4]
76 print "Set scalar range min=max=12 ...",
79 scalarmap.LookupTable.RGBPoints[0] = rmin
80 scalarmap.LookupTable.RGBPoints[4] = rmax
81 print "min = ", scalarmap.LookupTable.RGBPoints[0]," : max = ",scalarmap.LookupTable.RGBPoints[4]
83 print "Set scalar range min=120 > max=15 ...",
86 scalarmap.LookupTable.RGBPoints[0] = rmin
87 scalarmap.LookupTable.RGBPoints[4] = rmax
88 print "min = ", scalarmap.LookupTable.RGBPoints[0]," : max = ",scalarmap.LookupTable.RGBPoints[4]
91 bar = presentations.get_bar()
93 print "Set bar orientation = 'Horizontal'"
94 bar.Orientation = 'Horizontal'
95 print "Bar orientation ....", bar.Orientation
97 print "Set bar orientation = 'Vertical'"
98 bar.Orientation = 'Vertical'
99 print "Bar orientation ....", bar.Orientation
101 # 7. Position of scalar bar
102 print "Default position ....", bar.Position
104 print "Set left down corner position"
105 bar.Position = [0, 0]
106 print "Position =", bar.Position
108 print "Set position outside of the screen"
109 bar.Position = [-1, -1]
110 print "Position =", bar.Position
112 # 8. Size of scalar bar
113 print "Default Height=", bar.Position2[1]," : Width=", bar.Position2[0]
115 print "Set positive Height and Width"
118 bar.Position2 = [w, h]
119 print "Size =", bar.Position2
121 print "Set negative Height and Width"
124 bar.Position2 = [w, h]
125 print "Size =", bar.Position2
127 # 9. Number of colors
128 print "Default number of colors = ", scalarmap.LookupTable.NumberOfTableValues
130 scalarmap.LookupTable.Discretize = 1
132 #print "Set negative number of colors"
134 #scalarmap.LookupTable.NumberOfTableValues = nb_colors
135 #print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
137 print "Set zero number of colors"
139 scalarmap.LookupTable.NumberOfTableValues = nb_colors
140 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
142 print "Set positive number of colors"
144 scalarmap.LookupTable.NumberOfTableValues = nb_colors
145 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
147 # 10. Number of labels
148 print "Default number of labels = ", bar.NumberOfLabels
150 print "Set negative number of labels"
152 bar.NumberOfLabels = nb_labels
153 print "Number of labels=", bar.NumberOfLabels
155 print "Set zero number of labels"
157 bar.NumberOfLabels = nb_labels
158 print "Number of labels=", bar.NumberOfLabels
160 print "Set positive number of labels"
162 bar.NumberOfLabels = nb_labels
163 print "Number of labels=", bar.NumberOfLabels
165 # 11. Scalar bar title
166 print 'Default Title ="', bar.Title, '"'
168 print "Set not null title"
169 title = "Scalar Bar Title"
171 print ' Title ="', bar.Title, '"'
173 print "Set title from spaces"
176 print ' Title ="', bar.Title, '"'