Salome HOME
0022071: EDF 2497 PARAVIS : Porting of VISU tests for PARAVIS
[modules/paravis.git] / test / VisuPrs / united / A2.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/united/A2 case
21
22 from paravistest import datadir
23 from presentations import *
24 import paravis
25 import pvsimple
26 from math import radians
27
28 my_paravis = paravis.myParavis
29
30 cell_entity = EntityType.CELL
31 node_entity = EntityType.NODE
32
33 # 1. Import MED file
34 print "**** Step1: Import MED file"
35
36 print 'Import "fra.med"....................',
37 file_path = datadir + "fra.med"
38 my_paravis.ImportFile(file_path)
39 med_reader = pvsimple.GetActiveSource()
40
41 if med_reader is None:
42     print "FAILED"
43 else:
44     print "OK"
45
46 view = pvsimple.GetRenderView()
47
48 field_name = 'VITESSE'
49 print "Creating Cut Planes.................",
50 orient = Orientation.YZ
51 cutplanes = CutPlanesOnField(med_reader, node_entity, field_name, 1, orientation=orient)
52 if cutplanes is None:
53     print "FAILED"
54 else:
55     display_only(cutplanes, view)
56     print "OK"
57
58 slice_filter = pvsimple.GetActiveSource()
59
60 # 2. Changing view
61 print "**** Step2: Changing view"
62
63 print "Fit All.............................",
64 reset_view(view)
65 print "OK"
66
67 print "Rotate..............................",
68 x_angle = 0
69 y_angle = 0
70
71 nb_planes = len(slice_filter.SliceOffsetValues)
72
73 for i in xrange(1, 50):
74     y_angle = y_angle + 0.05
75     normal = get_normal_by_orientation(orient, x_angle, radians(y_angle))
76     slice_filter.SliceType.Normal = normal
77     pvsimple.Render()
78
79 for i in xrange(1,50):
80     y_angle = y_angle - 0.05
81     normal = get_normal_by_orientation(orient, x_angle, radians(y_angle))
82     slice_filter.SliceType.Normal = normal
83     pvsimple.Render()
84     
85 print "OK"
86
87 print "View Point (FRONT)..................",
88 view.CameraViewUp = [0.0, 0.0, 1.0]
89 view.CameraPosition = [2.4453961849843453, 0.03425, 0.541]
90 pvsimple.Render()
91 print "OK"
92
93 print "View Point (BACK)...................", 
94 view.CameraPosition = [-2.0343961849843457, 0.03425, 0.541]
95 pvsimple.Render()
96 print "OK"
97
98 print "View Point (TOP)....................",
99 view.CameraViewUp = [0.0, 1.0, 0.0]
100 view.CameraPosition = [0.2055, 0.03425, 2.7808961849843454]
101 pvsimple.Render()
102 print "OK"
103
104 print "View Point (BOTTOM).................",
105 view.CameraPosition = [0.2055, 0.03425, -1.6988961849843456]
106 pvsimple.Render()
107 print "OK"
108
109 print "View Point (LEFT)...................",
110 view.CameraViewUp = [0.0, 0.0, 1.0]
111 view.CameraPosition = [0.2055, -2.2056461849843454, 0.541]
112 pvsimple.Render()
113 print "OK"
114
115 print "View Point (RIGHT) .................", 
116 view.CameraPosition = [0.2055, 2.2741461849843456, 0.541]
117 pvsimple.Render()
118 print "OK"
119
120 print "Restore View........................",
121 reset_view(view)
122 print "OK"