Salome HOME
Copyrights update 2015.
[modules/paravis.git] / test / VisuPrs / dump_study / B3.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/dump_study/B3 case
21
22 import paravistest
23 from presentations import *
24 import pvserver as paravis
25 from pvsimple import *
26
27 my_paravis = paravis.myParavis
28
29 # 1. Table creation
30 title = "My Table"
31 errors = 0
32
33 table_title = "My Table"
34
35 # define script for table creation
36 table_script = """
37 import math
38
39
40 # Get table output
41 table = self.GetTableOutput()
42
43 # Create first column
44 col1 = vtk.vtkDoubleArray()
45 col1.SetName('First Column')
46 col1.InsertNextValue(1.11)
47 col1.InsertNextValue(4.44)
48 table.AddColumn(col1)
49
50 # Create second column
51 col2 = vtk.vtkDoubleArray()
52 col2.SetName('Second Column')
53 col2.InsertNextValue(2.22)
54 col2.InsertNextValue(5.55)
55 table.AddColumn(col2)
56
57 # Create third column
58 col3 = vtk.vtkDoubleArray()
59 col3.SetName('Third Column')
60 col3.InsertNextValue(3.33)
61 col3.InsertNextValue(6.66)
62 table.AddColumn(col3)
63 """
64
65 # creating programmable source for the table
66 table = ProgrammableSource()
67 table.OutputDataSetType = 'vtkTable'
68 table.Script = table_script
69 RenameSource(title, table)
70 table.UpdatePipeline()
71
72 orig_script = table.Script
73
74 # 2. Dump Study
75 path_to_save = os.path.join(os.getenv("HOME"), "table.py")
76 SaveTrace(path_to_save)
77
78 # 3. Delete the table
79 Delete(table)
80
81 # 4. Execution of the created script
82 execfile(path_to_save)
83
84 # 5. Check the restored table
85 table = FindSource(title)
86 if table is None:
87     raise RuntimeError, "There is no table in the study (must be created by executed python script)!!!"
88
89 if table.Script != orig_script:
90     print "ERROR!!! The script value is incorrect:"
91     print table.Script
92     errors += 1
93     
94 if errors > 0:
95     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."