]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/SWIG_scripts/C3.py
Salome HOME
Add frequency info in mode mode.
[modules/paravis.git] / test / VisuPrs / SWIG_scripts / C3.py
1 # Copyright (C) 2010-2013  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.
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/C3 case
21 # Create table and display curves
22
23 import paraview.simple as pv
24 import paraview.servermanager as sm
25
26
27 # Define script for table creation
28 script = """
29 import math
30
31
32 # Get table output
33 table = self.GetTableOutput()
34
35 nb_rows = 10
36 nb_cols = 200
37
38 # Create first column
39 col1 = vtk.vtkDoubleArray()
40 col1.SetName('Frequency')
41 for i in xrange(0, nb_rows):
42     col1.InsertNextValue(i * 10 + 1)
43 table.AddColumn(col1)
44
45 # Create the rest columns
46 for i in xrange(1, nb_cols + 1):
47    col = vtk.vtkDoubleArray()
48    col.SetName('Power ' + str(i))
49
50    # Fill the next column
51    for j in xrange(0, nb_rows):
52       if j % 2 == 1:
53          col.InsertNextValue(math.log10(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
54       else:
55          col.InsertNextValue(math.sin(j * 30 * math.pi / 180) * 20 + i * 15 + j * 5)
56
57    table.AddColumn(col)
58 """
59
60 # Creating programmable source (table)
61 ps = pv.ProgrammableSource()
62 ps.OutputDataSetType = 'vtkTable'
63 ps.Script = script
64 pv.RenameSource("Very useful data", ps)
65 ps.UpdatePipeline()
66
67 # Display table
68 # TODO: no possibility to create spreadsheet view
69
70 # Display curves
71 xy_view = pv.CreateXYPlotView()
72 xy_view.ChartTitle = 'Very useful data'
73 xy_view.AxisTitle = ['[ Wt ]', 'Frequency [ Hz ]']
74
75 xy_rep = pv.Show(ps)
76 xy_rep.AttributeType = 'Row Data'
77 xy_rep.UseIndexForXAxis = 0
78 xy_rep.XArrayName = 'Frequency'
79 xy_rep.SeriesVisibility = ['Frequency', '0']
80 pv.Render(xy_view)
81
82 # Hide legend
83 xy_view.ShowLegend = 0
84 pv.Render(xy_view)
85
86 # Set logarithmic scaling for X axis
87 xy_view.AxisLogScale[1] = 1
88 pv.Render(xy_view)
89
90 # Set linear scaling for X axis
91 xy_view.AxisLogScale[1] = 0
92 pv.Render(xy_view)
93
94 # Set logarithmic scaling for X axis
95 xy_view.AxisLogScale[0] = 1
96 pv.Render(xy_view)
97
98 # Show legend
99 xy_view.ShowLegend = 1
100 pv.Render(xy_view)