Salome HOME
some fixes in tests
[modules/paravis.git] / test / VisuPrs / dump_study / 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/dump_study/B0 case
21
22 from paravistest import datadir
23 from presentations import *
24 from pvsimple import *
25
26 # 1. TimeStamps.med import
27 file_path = datadir + "TimeStamps.med"
28 OpenDataFile(file_path)
29 med_reader = GetActiveSource()
30 if med_reader is None :
31     raise RuntimeError, "TimeStamps.med wasn't imported..."
32
33 # 2. Presentations creation
34 errors = 0
35 prs_names = ["ScalarMap", "IsoSurfaces", "CutPlanes", "CutLines", "DeformedShape", "Vectors", "StreamLines", "Plot3D", "DeformedShapeAndScalarMap", "GaussPoints"]
36 prs_list = []
37
38 med_field = "vitesse"
39
40 for name in prs_names:
41     print "Creation of ", name, " presentation..."
42     if name == "GaussPoints":
43         prs = GaussPointsOnField(med_reader, EntityType.CELL, "pression", 1)
44         pass
45     else:
46         prs = eval(name + "OnField(med_reader, EntityType.NODE, med_field, 1)")
47     if prs is None:
48         print "ERROR!!! ", name," presentation wasn't created..."
49         errors += 1
50     else:
51         RenameSource(name, prs.Input)
52         prs_list.append(prs)
53
54 # 3. Dump Study
55 path_to_save = os.path.join(os.getenv("HOME"), "AllPresentations.py")
56 SaveTrace( path_to_save )
57
58 # 4. Delete the created objects, recreate the view
59 source_list = GetSources().values()
60 for source in source_list:
61     Delete(source)
62
63 Delete(GetActiveView())
64 view = CreateRenderView()
65
66 # 5. Execution of the created script
67 execfile(path_to_save)
68
69 # 6. Check the restored objects
70 for name in prs_names:
71     source = FindSource(name)
72     if source is None:
73         print "There is no ", name, " in the study (must be created by executed python script)!!!"
74         errors += 1
75     else:
76         print name + " was found..."
77
78 if errors > 0:
79     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."
80
81