Salome HOME
Merge branch 'akl/tests_update'
[modules/paravis.git] / test / VisuPrs / united / B0.py
1 # Copyright (C) 2010-2014  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/united1/B0 case
21
22 from paravistest import datadir, compare_lists
23 from presentations import *
24 import paravis
25 import pvsimple
26
27 my_paravis = paravis.myParavis
28
29 error=0
30
31 # 1. Import MED file
32 file_path = datadir + "TimeStamps.med"
33 my_paravis.ImportFile(file_path)
34 med_reader = pvsimple.GetActiveSource()
35
36 if med_reader is None:
37     print "FAILED"
38 else:
39     print "OK"
40
41 # 2. Create scalar map on deformed shape
42 smondefshape = DeformedShapeAndScalarMapOnField(med_reader, EntityType.NODE, 'vitesse', 1)
43 if smondefshape is None:
44     print "FAILED"
45 else:
46     print "OK"
47
48 # 3. Make compare
49
50 # Offset
51 smondefshape.Position = [0, 0, 0]
52 error = error + compare_lists(smondefshape.Position, [0,0,0])
53
54 # Scalar mode
55 smondefshape.LookupTable.VectorMode = 'Magnitude'
56 if smondefshape.LookupTable.VectorMode != 'Magnitude':
57     print "ScalarMode is wrong..."
58     error=error+1
59
60 # Scalar bar Position
61 bar = get_bar()
62 bar.Position = [0.01, 0.01]
63 error = error + compare_lists(bar.Position, [0.01, 0.01])
64
65 # Scalar bar size
66 bar.Position2 = [0.05, 0.5]
67 error = error + compare_lists(bar.Position2, [0.05, 0.5])
68
69 # Number of colors and labels
70 smondefshape.LookupTable.NumberOfTableValues = 4
71 bar.NumberOfLabels = 5
72
73 nb_colors = smondefshape.LookupTable.NumberOfTableValues
74 nb_labels = bar.NumberOfLabels
75 error = error + compare_lists([nb_colors, nb_labels], [4, 5])
76
77 # Title
78 bar.Title = 'Pression, Pa'
79 bar.ComponentTitle = "Comp."
80
81 if bar.Title != 'Pression, Pa':
82     print "Title is wrong..."
83     error=error+1
84
85 if bar.ComponentTitle!= 'Comp.':
86     print "Component title is wrong..."
87     error=error+1
88
89 # Scaling
90 smondefshape.LookupTable.UseLogScale = 0
91 if smondefshape.LookupTable.UseLogScale != 0:
92     print "Error!!! Scaling is wrong"
93     error=error+1
94
95 # Bar orientation
96 bar.Orientation = 'Horizontal'
97 if bar.Orientation != 'Horizontal':
98     print "ERROR!!! Scalar Bar orientation is wrong..."
99     error=error+1
100
101 # Scale factor
102 smondefshape.Input.ScaleFactor = 0.15
103 error = error + compare_lists([smondefshape.Input.ScaleFactor], [0.15])
104
105
106 if error > 0:
107     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."