Salome HOME
Merge branch 'V7_dev'
[modules/paravis.git] / test / VisuPrs / DeformedShape / F9.py
1 # Copyright (C) 2010-2016  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/DeformedShape/F9 case
21 # Create Deformed Shape for field of the the given MED file for 10 timestamps%
22
23 import sys
24 from paravistest import datadir, pictureext, get_picture_dir
25 from presentations import *
26 from pvsimple import *
27
28 picturedir = get_picture_dir("DeformedShape/F9")
29
30 theFileName = datadir +  "Bug829_resu_mode.med"
31 print " --------------------------------- "
32 print "file ", theFileName
33 print " --------------------------------- "
34
35 """Build presentations of the given types for all fields of the given file."""
36 #print "Import %s..." % theFileName.split('/')[-1],
37 result = OpenDataFile(theFileName)
38 aProxy = GetActiveSource()
39 if aProxy is None:
40         raise RuntimeError, "Error: can't import file."
41 else: print "OK"
42 # Get view
43 aView = GetRenderView()
44
45 # Create required presentations for the proxy
46 # CreatePrsForProxy(aProxy, aView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete)
47 aFieldEntity = EntityType.NODE
48 aFieldName = "MODES___DEPL____________________"
49
50 #Creation of a set of non-colored and then colored Deformed Shapes, based on time stamps of MODES_DEP field
51 for colored in [False,True]:
52     colored_str = "_non-colored"
53     if colored:
54         colored_str = "_colored"
55     for i in range(1,11):
56         hide_all(aView, True)
57         aPrs = DeformedShapeOnField(aProxy, aFieldEntity, aFieldName, i, is_colored=colored)
58         if aPrs is None:
59             raise RuntimeError, "Presentation is None!!!"
60         # display only current deformed shape
61         #display_only(aView,aPrs)
62         aPrs.Visibility =1
63
64         reset_view(aView)
65         Render(aView)
66         # Add path separator to the end of picture path if necessery
67         if not picturedir.endswith(os.sep):
68                 picturedir += os.sep
69         prs_type = PrsTypeEnum.DEFORMEDSHAPE
70
71         # Get name of presentation type
72         prs_name = PrsTypeEnum.get_name(prs_type)
73         f_prs_type = prs_name.replace(' ', '').upper()
74         # Construct image file name
75         pic_name = picturedir + aFieldName+colored_str + "_" + str(i) + "_" + f_prs_type + "." + pictureext
76
77         # Show and record the presentation
78         process_prs_for_test(aPrs, aView, pic_name)