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