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