Salome HOME
Update ParaVis non-regression test base in the following ways:
[modules/paravis.git] / test / VisuPrs / ScalarMap / G2.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/ScalarMap/G2 case
21 # Create Scalar Map for field of the the given MED file for 10 timestamps%
22
23 import sys
24 import os
25 from paravistest import datadir, pictureext, get_picture_dir, get_png_picture_resolution
26 from pvsimple import GetActiveSource, GetRenderView, Render, OpenDataFile
27 from presentations import ScalarMapOnField, hide_all, EntityType, PrsTypeEnum,reset_view,process_prs_for_test
28
29 picturedir = get_picture_dir("ScalarMap/G2")
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 proxy = GetActiveSource()
40 if proxy is None:
41         raise RuntimeError, "Error: can't import file."
42 else: print "OK"
43 # Get view
44 aView = GetRenderView()
45
46
47 import time
48
49 aFieldEntity = EntityType.NODE
50 aFieldName = "MODES___DEPL____________________"
51 #create list to store picture files sizes
52 sizesw=[]
53 sizesh=[]
54 #create Scalar Map presentations for 10 timestamps
55 for i in range(1,11):
56     hide_all(aView, True)
57     aPrs = ScalarMapOnField(proxy, aFieldEntity,aFieldName , i)
58     if aPrs is None:
59         raise RuntimeError, "Presentation is None!!!"
60     #display only current scalar map
61     aPrs.Visibility=1
62     reset_view(aView)
63     Render(aView)
64
65     # Add path separator to the end of picture path if necessery
66     if not picturedir.endswith(os.sep):
67             picturedir += os.sep
68     prs_type = PrsTypeEnum.SCALARMAP
69
70     # Get name of presentation type
71     prs_name = PrsTypeEnum.get_name(prs_type)
72     f_prs_type = prs_name.replace(' ', '').upper()
73     # Construct image file name
74     pic_name = picturedir + aFieldName + "_" + str(i) + "_" + f_prs_type + "." + pictureext
75
76     # Show and record the presentation
77     process_prs_for_test(aPrs, aView, pic_name)
78     (w,h) = get_png_picture_resolution(pic_name)
79     sizesw.append(w)
80     sizesh.append(h)
81
82 # check sizes of pictures: width
83 if abs(max(sizesw)-min(sizesw)) > 0:
84     print "<b>ERROR!!! Pictures have different width !!!</b>";
85     for i in range(1,11):
86         picture_name = "time_stamp_"+str(i)+"."+pictureext
87         print "Picture: "+picture_name+"; width : "+str(sizesw[i-1])
88     raise RuntimeError
89
90 # check sizes of pictures: height
91 if abs(max(sizesh)-min(sizesh)) > 0:
92     print "<b>WARNING!!! Pictures have different height !!!</b>";
93     for i in range(1,11):
94         picture_name = "time_stamp_"+str(i)+"."+pictureext
95         print "Picture: "+picture_name+"; height : "+str(sizesh[i-1])
96     raise RuntimeError
97