Salome HOME
Merge Python 3 porting.
[modules/paravis.git] / test / VisuPrs / SWIG_scripts / A8.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/A8 case
21 # Create table
22
23 import pvsimple
24
25 # Define script for table creation
26 script = """
27 import math
28
29
30 # Get table output
31 table = self.GetTableOutput()
32
33 nb_rows = 10
34 nb_cols = 200
35
36 # Create first column
37 col1 = vtk.vtkDoubleArray()
38 col1.SetName('Frequency')
39 for i in xrange(0, nb_rows):
40     col1.InsertNextValue(i * 10 + 1)
41 table.AddColumn(col1)
42
43 # Create the rest columns
44 for i in xrange(1, nb_cols + 1):
45    col = vtk.vtkDoubleArray()
46    col.SetName('Power ' + str(i))
47
48    # Fill the next column
49    for j in xrange(0, nb_rows):
50       if j % 2 == 1:
51          col.InsertNextValue(math.log10(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
52       else:
53          col.InsertNextValue(math.sin(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
54
55    table.AddColumn(col)
56 """
57
58 # Creating programmable source (table)
59 ps = pvsimple.ProgrammableSource()
60 ps.OutputDataSetType = 'vtkTable'
61 ps.Script = script
62 pvsimple.RenameSource("Very useful data", ps)
63 ps.UpdatePipeline()