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/dump_study/B0 case
22 from paravistest import datadir
23 from presentations import *
24 from pvsimple import *
25 from paravistest import save_trace
26 from paraview import smtrace
28 GetActiveViewOrCreate('RenderView')
30 config = smtrace.start_trace()
31 config.SetFullyTraceSupplementalProxies(True)
32 config.SetPropertiesToTraceOnCreate(config.RECORD_ALL_PROPERTIES)
34 # 1. TimeStamps.med import
35 file_path = datadir + "TimeStamps.med"
36 OpenDataFile(file_path)
37 med_reader = GetActiveSource()
38 if med_reader is None :
39 raise RuntimeError, "TimeStamps.med wasn't imported..."
41 # 2. Presentations creation
43 prs_names = ["ScalarMap", "IsoSurfaces", "CutPlanes", "CutLines", "DeformedShape", "Vectors", "StreamLines", "Plot3D", "DeformedShapeAndScalarMap", "GaussPoints"]
48 for name in prs_names:
49 print "Creation of ", name, " presentation..."
50 if name == "GaussPoints":
51 prs = GaussPointsOnField(med_reader, EntityType.CELL, "pression", 1)
54 prs = eval(name + "OnField(med_reader, EntityType.NODE, med_field, 1)")
56 print "ERROR!!! ", name," presentation wasn't created..."
57 # StreamLines presentation is empty for "vitesse" field defined in the loaded MED file.
58 # TODO: check why stream lines prs is empty
59 if name == "StreamLines":
60 print "WARNING: Stream lines presentation is empty!"
64 RenameSource(name, prs.Input)
68 text = smtrace.stop_trace()
69 path_to_save = os.path.join(os.getenv("HOME"), "AllPresentations.py")
70 save_trace( path_to_save, text )
72 # 4. Delete the created objects, recreate the view
73 source_list = GetSources().values()
74 for source in source_list:
75 delete_pv_object(source)
77 delete_pv_object(GetActiveView())
78 view = CreateRenderView()
80 # 5. Execution of the created script
81 execfile(path_to_save)
83 # 6. Check the restored objects
84 for name in prs_names:
85 source = FindSource(name)
87 print "There is no ", name, " in the study (must be created by executed python script)!!!"
90 print name + " was found..."
93 raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."