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