Salome HOME
0022071: EDF 2497 PARAVIS : Porting of VISU tests for PARAVIS
[modules/paravis.git] / test / VisuPrs / bugs / D6.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/bugs3/D6 case
21
22 from paravistest import datadir
23 from presentations import *
24 import paravis
25 import pvsimple
26
27 my_paravis = paravis.myParavis
28
29 # 1. Import MED file
30 med_file_path = datadir + "fra.med"
31
32 my_paravis.ImportFile(med_file_path)
33 med_reader = pvsimple.GetActiveSource()
34
35 # 2. Creation of CutSegment presentations, based on time stamps of "VITESSE" field
36 point1 = [0.0, 0.0, 0.0]
37 point2 = [0.4, 0.05, 1.0]
38 cut_segment1 = CutSegmentOnField(med_reader, EntityType.NODE, "VITESSE", 1,
39                                 point1, point2)
40 if cut_segment1 == None:
41    raise RuntimeError, "ERROR!!! The first CutSegment presentation is not built!" 
42
43 # 3. Creation of CutSegment presentations, based on time stamps of "TAUX_DE_VIDE" field
44 point1 = [0, 0, 1]
45 point2 = [0.2055, 0.0685, 0.541]
46 cut_segment2 = CutSegmentOnField(med_reader, EntityType.NODE, "TAUX_DE_VIDE", 1,
47                                 point1, point2)
48 if cut_segment2 == None:
49    raise RuntimeError, "ERROR!!! The second CutSegment presentation is not built!"
50
51 # 4. Creation of Table based on CutSegment presentation
52
53 # TODO: it's possible to display CutSegment (PlotOverLine in terms of ParaViS) presentation
54 #       as a table in GUI, but it seems that there is no possibility to create table view
55 #       (spreadsheet view in terms of ParaViS) from in Python script
56
57 # 5. Creation of curve based on Table
58 xy_view = pv.CreateXYPlotView()
59
60 curve1 = pv.Show(cut_segment1.Input, xy_view)
61 if curve1 == None:
62    raise RuntimeError, " ERROR!!! Curve based on the first CutSegment is not built!"
63
64 curve2 = pv.Show(cut_segment2.Input, xy_view)
65 if curve2 == None:
66    raise RuntimeError, " ERROR!!! Curve based on the second CutSegment is not built!"
67
68 curves = [curve1, curve2]
69 for c in curves:
70     c.AttributeType = 'Point Data'
71     c.UseIndexForXAxis = 0
72     c.XArrayName = 'arc_length'
73
74 pvsimple.SetActiveSource(cut_segment1.Input)
75 set_visible_lines(curve1, ['VITESSE (Magnitude)'])
76
77 pvsimple.SetActiveSource(cut_segment2.Input)
78 set_visible_lines(curve2, ['TAUX_DE_VIDE'])
79
80 pvsimple.ResetCamera(xy_view)