]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/ScalarMap/B3.py
Salome HOME
Porting to python3
[modules/paravis.git] / test / VisuPrs / ScalarMap / B3.py
1 # Copyright (C) 2010-2016  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This case corresponds to: /visu/ScalarMap/B3 case
21 # Test ScalarMap interface methods.
22
23 from paravistest import datadir
24 import presentations
25 import pvsimple
26
27 # 1. Import MED file
28
29 print('Importing "fra.med"...', end=' ')
30 file_path = datadir + "fra.med"
31 pvsimple.OpenDataFile(file_path)
32 med_reader = pvsimple.GetActiveSource()
33
34 if med_reader is None:
35     print("FAILED")
36 else:
37     print("OK")
38
39 # 2. Create ScalarMap
40 field_name = 'TAUX_DE_VIDE'
41 entity =  presentations.EntityType.NODE
42 myMeshName='LE VOLUME'
43
44 scalarmap = presentations.ScalarMapOnField(med_reader, entity, field_name, 1)
45 if scalarmap is None:
46     print("FAILED")
47
48 # 3. Scalar mode
49 lookup_table = scalarmap.LookupTable
50 print("Vector mode .....", lookup_table.VectorMode)
51 print("Vector component .....", lookup_table.VectorComponent)
52
53 lookup_table.VectorMode = 'Component'
54 lookup_table.VectorComponent = 0
55
56 scalarmap.LookupTable = lookup_table
57
58 print("Vector mode .....", scalarmap.LookupTable.VectorMode)
59 print("Vector component .....", scalarmap.LookupTable.VectorComponent)
60
61 # 4. Scaling mode
62 scalarmap.LookupTable.UseLogScale = 1
63 print("Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale)
64
65 scalarmap.LookupTable.UseLogScale = 0
66 print("Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale)
67
68 # 5. Scalar range
69 print("Set scalar range min=12 < max=120 ...", end=' ')
70 rmin = 12
71 rmax = 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])
75
76 print("Set scalar range min=max=12 ...", end=' ')
77 rmin = 120
78 rmax = rmin
79 scalarmap.LookupTable.RGBPoints[0] = rmin
80 scalarmap.LookupTable.RGBPoints[4] = rmax
81 print("min = ", scalarmap.LookupTable.RGBPoints[0],"  : max = ",scalarmap.LookupTable.RGBPoints[4])
82
83 print("Set scalar range min=120 > max=15 ...", end=' ')
84 rmin = 120
85 rmax = 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])
89
90 # 6. Bar orientation
91 bar = presentations.get_bar()
92
93 print("Set bar orientation = 'Horizontal'")
94 bar.Orientation = 'Horizontal'
95 print("Bar orientation ....", bar.Orientation)
96
97 print("Set bar orientation = 'Vertical'")
98 bar.Orientation = 'Vertical'
99 print("Bar orientation ....", bar.Orientation)
100
101 # 7. Position of scalar bar
102 print("Default position ....", bar.Position)
103
104 print("Set left down corner position")
105 bar.Position = [0, 0]
106 print("Position =", bar.Position)
107
108 print("Set position outside of the screen")
109 bar.Position = [-1, -1]
110 print("Position =", bar.Position)
111
112 # 8. Size of scalar bar
113 print("Default Height=", bar.Position2[1],"  :  Width=", bar.Position2[0])
114
115 print("Set positive Height and Width")
116 h = 0.4
117 w = 0.2
118 bar.Position2 = [w, h]
119 print("Size =", bar.Position2)
120
121 print("Set negative Height and Width")
122 h = -0.4
123 w = -0.2
124 bar.Position2 = [w, h]
125 print("Size =", bar.Position2)
126
127 # 9. Number of colors
128 print("Default number of colors = ", scalarmap.LookupTable.NumberOfTableValues)
129
130 scalarmap.LookupTable.Discretize = 1
131
132 #print "Set negative number of colors"
133 #nb_colors = -128
134 #scalarmap.LookupTable.NumberOfTableValues = nb_colors
135 #print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
136
137 print("Set zero number of colors")
138 nb_colors = 0
139 scalarmap.LookupTable.NumberOfTableValues = nb_colors
140 print("Number of colors =", scalarmap.LookupTable.NumberOfTableValues)
141
142 print("Set positive number of colors")
143 nb_colors = 256
144 scalarmap.LookupTable.NumberOfTableValues = nb_colors
145 print("Number of colors =", scalarmap.LookupTable.NumberOfTableValues)
146
147 # 10. Number of labels
148 print("Default number of labels = ", bar.NumberOfLabels)
149
150 print("Set negative number of labels")
151 nb_labels = -10
152 bar.NumberOfLabels = nb_labels
153 print("Number of labels=", bar.NumberOfLabels)
154
155 print("Set zero number of labels")
156 nb_labels = 0
157 bar.NumberOfLabels = nb_labels
158 print("Number of labels=", bar.NumberOfLabels)
159
160 print("Set positive number of labels")
161 nb_labels = 10
162 bar.NumberOfLabels = nb_labels
163 print("Number of labels=", bar.NumberOfLabels)
164
165 # 11. Scalar bar title
166 print('Default Title ="', bar.Title, '"')
167
168 print("Set not null title")
169 title = "Scalar Bar Title"
170 bar.Title = title
171 print('   Title ="', bar.Title, '"')
172
173 print("Set title from spaces")
174 title='    '
175 bar.Title = title
176 print('   Title ="', bar.Title, '"')