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/C3 case
21 # Create table and display curves
25 # Define script for table creation
31 table = self.GetTableOutput()
37 col1 = vtk.vtkDoubleArray()
38 col1.SetName('Frequency')
39 for i in xrange(0, nb_rows):
40 col1.InsertNextValue(i * 10 + 1)
43 # Create the rest columns
44 for i in xrange(1, nb_cols + 1):
45 col = vtk.vtkDoubleArray()
46 col.SetName('Power ' + str(i))
48 # Fill the next column
49 for j in xrange(0, nb_rows):
51 col.InsertNextValue(math.log10(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
53 col.InsertNextValue(math.sin(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
58 # Creating programmable source (table)
59 ps = pvsimple.ProgrammableSource()
60 ps.OutputDataSetType = 'vtkTable'
62 pvsimple.RenameSource("Very useful data", ps)
66 # TODO: no possibility to create spreadsheet view
69 xy_view = pvsimple.CreateXYPlotView()
70 xy_view.ChartTitle = 'Very useful data'
71 xy_view.BottomAxisTitle = '[ Wt ]'
72 xy_view.LeftAxisTitle = 'Frequency [ Hz ]'
74 xy_rep = pvsimple.Show(ps)
75 xy_rep.AttributeType = 'Row Data'
76 xy_rep.UseIndexForXAxis = 0
77 xy_rep.XArrayName = 'Frequency'
78 xy_rep.SeriesVisibility = ['Frequency', '0']
79 pvsimple.Render(xy_view)
82 xy_view.ShowLegend = 0
83 pvsimple.Render(xy_view)
85 # Set logarithmic scaling for Y axis
86 xy_view.LeftAxisLogScale = 1
87 pvsimple.Render(xy_view)
89 # Set linear scaling for Y axis
90 xy_view.LeftAxisLogScale = 0
91 pvsimple.Render(xy_view)
93 # Set logarithmic scaling for X axis
94 xy_view.BottomAxisLogScale = 1
95 pvsimple.Render(xy_view)
98 xy_view.ShowLegend = 1
99 pvsimple.Render(xy_view)