Salome HOME
CMake: add option SALOME_PARAVIS_ALL_TEST which lets to select - run all SALOME PARAV...
[modules/paravis.git] / test / VisuPrs / ScalarMap / B3.py
1 # Copyright (C) 2010-2013  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.
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 paravis
26 import pvsimple
27
28 my_paravis = paravis.myParavis
29
30 # 1. Import MED file
31
32 print 'Importing "fra.med"...',
33 file_path = datadir + "fra.med"
34 my_paravis.ImportFile(file_path)
35 med_reader = pvsimple.GetActiveSource()
36
37 if med_reader is None:
38     print "FAILED"
39 else:
40     print "OK"
41
42 # 2. Create ScalarMap
43 field_name = 'TAUX_DE_VIDE'
44 entity =  presentations.EntityType.NODE
45 myMeshName='LE VOLUME'
46
47 scalarmap = presentations.ScalarMapOnField(med_reader, entity, field_name, 1)
48 if scalarmap is None:
49     print "FAILED"
50
51 # 3. Scalar mode
52 lookup_table = scalarmap.LookupTable
53 print "Vector mode .....", lookup_table.VectorMode
54 print "Vector component .....", lookup_table.VectorComponent
55
56 lookup_table.VectorMode = 'Component'
57 lookup_table.VectorComponent = 0
58
59 scalarmap.LookupTable = lookup_table 
60
61 print "Vector mode .....", scalarmap.LookupTable.VectorMode
62 print "Vector component .....", scalarmap.LookupTable.VectorComponent
63
64 # 4. Scaling mode
65 scalarmap.LookupTable.UseLogScale = 1
66 print "Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale
67
68 scalarmap.LookupTable.UseLogScale = 0
69 print "Use logarithmic scaling ....", scalarmap.LookupTable.UseLogScale
70
71 # 5. Scalar range
72 print "Set scalar range min=12 < max=120 ...",
73 rmin = 12
74 rmax = 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]
78
79 print "Set scalar range min=max=12 ...",
80 rmin = 120
81 rmax = rmin
82 scalarmap.LookupTable.RGBPoints[0] = rmin
83 scalarmap.LookupTable.RGBPoints[4] = rmax
84 print "min = ", scalarmap.LookupTable.RGBPoints[0],"  : max = ",scalarmap.LookupTable.RGBPoints[4]
85
86 print "Set scalar range min=120 > max=15 ...",
87 rmin = 120
88 rmax = 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]
92
93 # 6. Bar orientation
94 bar = presentations.get_bar()
95
96 print "Set bar orientation = 'Horizontal'"
97 bar.Orientation = 'Horizontal'
98 print "Bar orientation ....", bar.Orientation
99
100 print "Set bar orientation = 'Vertical'"
101 bar.Orientation = 'Vertical'
102 print "Bar orientation ....", bar.Orientation
103
104 # 7. Position of scalar bar
105 print "Default position ....", bar.Position
106
107 print "Set left down corner position"
108 bar.Position = [0, 0]
109 print "Position =", bar.Position
110
111 print "Set position outside of the screen"
112 bar.Position = [-1, -1]
113 print "Position =", bar.Position
114
115 # 8. Size of scalar bar
116 print "Default Height=", bar.Position2[1],"  :  Width=", bar.Position2[0]
117
118 print "Set positive Height and Width"
119 h = 0.4
120 w = 0.2
121 bar.Position2 = [w, h]
122 print "Size =", bar.Position2
123
124 print "Set negative Height and Width"
125 h = -0.4
126 w = -0.2
127 bar.Position2 = [w, h]
128 print "Size =", bar.Position2
129
130 # 9. Number of colors
131 print "Default number of colors = ", scalarmap.LookupTable.NumberOfTableValues
132
133 scalarmap.LookupTable.Discretize = 1
134
135 print "Set negative number of colors"
136 nb_colors = -128
137 scalarmap.LookupTable.NumberOfTableValues = nb_colors
138 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
139
140 print "Set zero number of colors"
141 nb_colors = 0
142 scalarmap.LookupTable.NumberOfTableValues = nb_colors
143 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
144
145 print "Set positive number of colors"
146 nb_colors = 256
147 scalarmap.LookupTable.NumberOfTableValues = nb_colors
148 print "Number of colors =", scalarmap.LookupTable.NumberOfTableValues
149
150 # 10. Number of labels
151 print "Default number of labels = ", bar.NumberOfLabels
152
153 print "Set negative number of labels"
154 nb_labels = -10
155 bar.NumberOfLabels = nb_labels
156 print "Number of labels=", bar.NumberOfLabels
157
158 print "Set zero number of labels"
159 nb_labels = 0
160 bar.NumberOfLabels = nb_labels
161 print "Number of labels=", bar.NumberOfLabels
162
163 print "Set positive number of labels"
164 nb_labels = 10
165 bar.NumberOfLabels = nb_labels
166 print "Number of labels=", bar.NumberOfLabels
167
168 # 11. Scalar bar title
169 print 'Default Title ="', bar.Title, '"'
170
171 print "Set not null title"
172 title = "Scalar Bar Title"
173 bar.Title = title
174 print '   Title ="', bar.Title, '"'
175
176 print "Set title from spaces"
177 title='    '
178 bar.Title = title
179 print '   Title ="', bar.Title, '"'