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"...', end=' ')
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 ...", end=' ')
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 ...", end=' ')
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 ...", end=' ')
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 Length=", bar.ScalarBarLength," : Thickness=", bar.ScalarBarThickness)
115 print("Set positive Height and Width")
118 bar.ScalarBarLength = h
119 bar.ScalarBarThickness = int(w)
120 print("Length=", bar.ScalarBarLength," : Thickness=", bar.ScalarBarThickness)
122 print("Set negative Height and Width")
125 bar.ScalarBarLength = h
126 bar.ScalarBarThickness = int(w)
127 print("Length=", bar.ScalarBarLength," : Thickness=", bar.ScalarBarThickness)
129 # 9. Number of colors
130 print("Default number of colors = ", scalarmap.LookupTable.NumberOfTableValues)
132 scalarmap.LookupTable.Discretize = 1
134 #print "Set negative number of colors"
136 #scalarmap.LookupTable.NumberOfTableValues = nb_colors
137 #print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
139 print("Set zero number of colors")
141 scalarmap.LookupTable.NumberOfTableValues = nb_colors
142 print("Number of colors =", scalarmap.LookupTable.NumberOfTableValues)
144 print("Set positive number of colors")
146 scalarmap.LookupTable.NumberOfTableValues = nb_colors
147 print("Number of colors =", scalarmap.LookupTable.NumberOfTableValues)
149 # NumberOfLabels no longer exists since Paraview 5.4
151 # 10. Number of labels
152 # print("Default number of labels = ", bar.NumberOfLabels)
154 #print("Set negative number of labels")
156 #bar.NumberOfLabels = nb_labels
157 #print("Number of labels=", bar.NumberOfLabels)
159 #print("Set zero number of labels")
161 #bar.NumberOfLabels = nb_labels
162 #print("Number of labels=", bar.NumberOfLabels)
164 #print("Set positive number of labels")
166 #bar.NumberOfLabels = nb_labels
167 #print("Number of labels=", bar.NumberOfLabels)
169 # 11. Scalar bar title
170 print('Default Title ="', bar.Title, '"')
172 print("Set not null title")
173 title = "Scalar Bar Title"
175 print(' Title ="', bar.Title, '"')
177 print("Set title from spaces")
180 print(' Title ="', bar.Title, '"')