Back to index

salome-paravis  6.5.0
B0.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 # This case corresponds to: /visu/SWIG_scripts/B0 case
00021 # Create table
00022 
00023 from paravistest import tablesdir
00024 import paravis
00025 import pvsimple
00026 
00027 
00028 # Define script for table creation
00029 script = """
00030 import math
00031 
00032 
00033 # Get table output
00034 table = self.GetTableOutput()
00035 
00036 nb_rows = 10
00037 nb_cols = 200
00038 
00039 # Create first column
00040 col1 = vtk.vtkDoubleArray()
00041 col1.SetName('Frequency')
00042 for i in xrange(0, nb_rows):
00043     col1.InsertNextValue(i * 10 + 1)
00044 table.AddColumn(col1)
00045 
00046 # Create the rest columns
00047 for i in xrange(1, nb_cols + 1):
00048    col = vtk.vtkDoubleArray()
00049    col.SetName('Power ' + str(i))
00050 
00051    # Fill the next column
00052    for j in xrange(0, nb_rows):
00053       if j % 2 == 1:
00054          col.InsertNextValue(math.log10(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
00055       else:
00056          col.InsertNextValue(math.sin(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
00057 
00058    table.AddColumn(col)
00059 """
00060 
00061 # Creating programmable source (table)
00062 ps = pvsimple.ProgrammableSource()
00063 ps.OutputDataSetType = 'vtkTable'
00064 ps.Script = script
00065 pvsimple.RenameSource("Very useful data", ps)
00066 ps.UpdatePipeline()