1 # Copyright (C) 2010-2016 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # This case corresponds to: /visu/SWIG_scripts/B6 case
21 # Create table of integer, create table of real, create curves
23 from paravistest import tablesdir
26 # Define script for table of integer creation
28 def add_column(table, name, lst):
29 col = vtk.vtkIntArray()
32 col.InsertNextValue(item)
36 table = self.GetTableOutput()
39 lst = [1,2,3,4,5,6,7,8,9,10]
40 add_column(table, 'FR', lst)
42 lst = [110,120,130,140,150,160,170,180,190,200]
43 add_column(table, 'SR', lst)
45 lst = [-1,272,0,0,-642,10000,13,578,-578,99]
46 add_column(table, 'TR', lst)
49 # Define script for table of real creation
55 table = self.GetTableOutput()
58 col1 = vtk.vtkDoubleArray()
60 for i in xrange(0, 21):
61 col1.InsertNextValue(i * 10 + 1)
64 # Create the rest columns
65 for i in range(1, 11):
66 col = vtk.vtkDoubleArray()
67 col.SetName('Row ' + str(i))
69 # Fill the next column
70 col.InsertNextValue(1)
71 for j in range(1, 21):
73 col.InsertNextValue(math.log10(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
75 col.InsertNextValue(math.sin(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
80 # Creating programmable source for the table of integer
81 ps_ti = pvsimple.ProgrammableSource()
82 ps_ti.OutputDataSetType = 'vtkTable'
83 ps_ti.Script = script_ti
84 pvsimple.RenameSource("TEST table of integer", ps_ti)
85 ps_ti.UpdatePipeline()
87 # Creating programmable source for the table of real
88 ps_tr = pvsimple.ProgrammableSource()
89 ps_tr.OutputDataSetType = 'vtkTable'
90 ps_tr.Script = script_tr
91 pvsimple.RenameSource("TEST table of real", ps_tr)
92 ps_tr.UpdatePipeline()
94 # Replace the current view with chart line one
95 cur_view = pvsimple.GetRenderView()
97 pvsimple.Delete(cur_view)
99 xy_view1 = pvsimple.CreateXYPlotView()
100 xy_view1.ChartTitle = 'TEST table of real'
101 xy_view1.BottomAxisTitle = '[ Wt ]'
102 xy_view1.LeftAxisTitle = 'Row 0 [ Hz ]'
104 # Display curves for the table of real
105 tr_rep = pvsimple.Show(ps_tr)
106 tr_rep.AttributeType = 'Row Data'
107 tr_rep.UseIndexForXAxis = 0
108 tr_rep.XArrayName = 'Row 0'
109 tr_rep.SeriesVisibility = ['Row 0', '0', 'Row 4', '0', \
110 'Row 6', '0', 'Row 8', '0', 'Row 9', '0']
112 # Set 'Square' marker style for 'Row 5' line
113 tr_rep.SeriesMarkerStyle = ['Row 5', '3']
114 # Set 'Dash' line style for 'Row 5' line
115 tr_rep.SeriesLineStyle = ['Row 5', '2']
116 # Set color for 'Row 5' line
117 tr_rep.SeriesColor = ['Row 5', '0', '0.7', '0.3']
118 # Set 'Diamond' marker style for 'Row 10' line
119 tr_rep.SeriesMarkerStyle = ['Row 10', '5']
120 # Set 'Dot' line style for 'Row 10' line
121 tr_rep.SeriesLineStyle = ['Row 10', '3']
122 # Set color for 'Row 10' line
123 tr_rep.SeriesColor = ['Row 10', '0.2', '0.2', '0.9']
125 # Create another chart line view
126 xy_view2 = pvsimple.CreateXYPlotView()
127 xy_view2.ChartTitle = 'TEST table of integer'
128 xy_view2.LeftAxisTitle = 'FR [ m/h ]'
130 # Display curves for the table of integer
131 ti_rep = pvsimple.Show(ps_ti, xy_view2)
132 ti_rep.AttributeType = 'Row Data'
133 ti_rep.UseIndexForXAxis = 0
134 ti_rep.XArrayName = 'FR'
135 ti_rep.SeriesVisibility = ['SR', '0']
137 # Change legend label for "FR" line
138 ti_rep.SeriesLabel = ["FR", "FREQ"]
140 # Set 'Square' marker style for 'FR' line
141 ti_rep.SeriesMarkerStyle = ['FR', '3']
142 # Set 'Dash' line style for 'FR' line
143 ti_rep.SeriesLineStyle = ['FR', '2']
144 # Set color for 'FR' line
145 ti_rep.SeriesColor = ['FR', '0', '0.7', '0.3']
149 pvsimple.Render(xy_view1)
150 pvsimple.Render(xy_view2)