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