]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/SWIG_scripts/B6.py
Salome HOME
Normalize installation dir of all plugins
[modules/paravis.git] / test / VisuPrs / SWIG_scripts / B6.py
1 # Copyright (C) 2010-2016  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/SWIG_scripts/B6 case
21 # Create table of integer, create table of real, create curves
22
23 from paravistest import tablesdir
24 import pvsimple
25 from presentations import delete_pv_object
26
27 # Define script for table of integer creation
28 script_ti = """
29 def add_column(table, name, lst):
30     col = vtk.vtkIntArray()
31     col.SetName(name)
32     for item in lst:
33         col.InsertNextValue(item)
34     table.AddColumn(col)
35
36 # Get table output
37 table = self.GetTableOutput()
38
39 # Add columns
40 lst = [1,2,3,4,5,6,7,8,9,10]
41 add_column(table, 'FR', lst)
42
43 lst = [110,120,130,140,150,160,170,180,190,200]
44 add_column(table, 'SR', lst)
45
46 lst = [-1,272,0,0,-642,10000,13,578,-578,99]
47 add_column(table, 'TR', lst)
48 """
49
50 # Define script for table of real creation
51 script_tr = """
52 import math
53
54
55 # Get table output
56 table = self.GetTableOutput()
57
58 # Create first column
59 col1 = vtk.vtkDoubleArray()
60 col1.SetName('Row 0')
61 for i in xrange(0, 21):
62     col1.InsertNextValue(i * 10 + 1)
63 table.AddColumn(col1)
64
65 # Create the rest columns
66 for i in range(1, 11):
67     col = vtk.vtkDoubleArray()
68     col.SetName('Row ' + str(i))
69
70     # Fill the next column
71     col.InsertNextValue(1)
72     for j in range(1, 21):
73         if j % 2 == 1:
74             col.InsertNextValue(math.log10(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
75         else:
76             col.InsertNextValue(math.sin(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
77
78     table.AddColumn(col)
79 """
80
81 # Creating programmable source for the table of integer
82 ps_ti = pvsimple.ProgrammableSource()
83 ps_ti.OutputDataSetType = 'vtkTable'
84 ps_ti.Script = script_ti
85 pvsimple.RenameSource("TEST table of integer", ps_ti)
86 ps_ti.UpdatePipeline()
87
88 # Creating programmable source for the table of real
89 ps_tr = pvsimple.ProgrammableSource()
90 ps_tr.OutputDataSetType = 'vtkTable'
91 ps_tr.Script = script_tr
92 pvsimple.RenameSource("TEST table of real", ps_tr)
93 ps_tr.UpdatePipeline()
94
95 # Replace the current view with chart line one
96 xy_view1 = pvsimple.CreateXYPlotView()
97 xy_view1.ChartTitle = 'TEST table of real'
98 xy_view1.BottomAxisTitle = '[ Wt ]'
99 xy_view1.LeftAxisTitle = 'Row 0 [ Hz ]'
100
101 # Display curves for the table of real
102 tr_rep = pvsimple.Show(ps_tr)
103 tr_rep.AttributeType = 'Row Data'
104 tr_rep.UseIndexForXAxis = 0
105 tr_rep.XArrayName = 'Row 0'
106 tr_rep.SeriesVisibility = ['Row 0', '0', 'Row 4', '0', \
107 'Row 6', '0', 'Row 8', '0', 'Row 9', '0']
108
109 # Set 'Square' marker style for 'Row 5' line
110 tr_rep.SeriesMarkerStyle = ['Row 5', '3']
111 # Set 'Dash' line style for 'Row 5' line
112 tr_rep.SeriesLineStyle = ['Row 5', '2']
113 # Set color for 'Row 5' line
114 tr_rep.SeriesColor = ['Row 5', '0', '0.7', '0.3']
115 # Set 'Diamond' marker style for 'Row 10' line
116 tr_rep.SeriesMarkerStyle = ['Row 10', '5']
117 # Set 'Dot' line style for 'Row 10' line
118 tr_rep.SeriesLineStyle = ['Row 10', '3']
119 # Set color for 'Row 10' line
120 tr_rep.SeriesColor = ['Row 10', '0.2', '0.2', '0.9']
121
122 # Create another chart line view
123 xy_view2 = pvsimple.CreateXYPlotView()
124 xy_view2.ChartTitle = 'TEST table of integer'
125 xy_view2.LeftAxisTitle = 'FR [ m/h ]'
126
127 # Display curves for the table of integer
128 ti_rep = pvsimple.Show(ps_ti, xy_view2)
129 ti_rep.AttributeType = 'Row Data'
130 ti_rep.UseIndexForXAxis = 0
131 ti_rep.XArrayName = 'FR'
132 ti_rep.SeriesVisibility = ['SR', '0']
133
134 # Change legend label for "FR" line
135 ti_rep.SeriesLabel = ["FR", "FREQ"]
136
137 # Set 'Square' marker style for 'FR' line
138 ti_rep.SeriesMarkerStyle = ['FR', '3']
139 # Set 'Dash' line style for 'FR' line
140 ti_rep.SeriesLineStyle = ['FR', '2']
141 # Set color for 'FR' line
142 ti_rep.SeriesColor = ['FR', '0', '0.7', '0.3']
143
144
145 # Update views
146 pvsimple.Render(xy_view1)
147 pvsimple.Render(xy_view2)