Back to index

salome-paravis  6.5.0
A7.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 # This case corresponds to: /visu/3D_viewer/A7 case
00021 # Create 3D Viewer and test set view properties for CutPlanes presentation
00022 # Author: POLYANSKIKH VERA
00023 from paravistest import *
00024 from presentations import *
00025 from pvsimple import *
00026 import sys
00027 import paravis
00028 import time
00029 
00030 # Directory for saving snapshots
00031 picturedir = get_picture_dir(sys.argv[1], "3D_viewer/A7")
00032 
00033 # Add path separator to the end of picture path if necessery
00034 if not picturedir.endswith(os.sep):
00035     picturedir += os.sep
00036 #import file
00037 my_paravis = paravis.myParavis
00038 
00039 # Get view
00040 my_view = GetRenderView()
00041 reset_view(my_view)
00042 Render(my_view)
00043 
00044 file_name = datadir + "Tetra4.med"
00045 print " --------------------------------- "
00046 print "file ", file_name
00047 print " --------------------------------- "
00048 
00049 my_paravis.ImportFile(file_name)
00050 proxy = GetActiveSource()
00051 if proxy is None:
00052     raise RuntimeError("Error: can't import file.")
00053 else:
00054     print "OK"
00055 
00056 represents = [RepresentationType.POINTS, RepresentationType.WIREFRAME,\
00057 RepresentationType.SURFACE, RepresentationType.VOLUME]
00058 shrinks = [0, 1]
00059 shadings = [0, 1]
00060 opacities = [1.0, 0.5, 0.0]
00061 linewidths = [1.0, 3.0, 10.0]
00062 compare_prec = 0.00001
00063 
00064 field_name = 'scalar_field'
00065 
00066 print "\nCreating cut planes.......",
00067 cut_planes = CutPlanesOnField(proxy, EntityType.CELL, field_name, 1,
00068 nb_planes=10, orientation=Orientation.YZ, displacement=0.5)
00069 if cut_planes is None:
00070     raise RuntimeError("Error!!! Presentation wasn't created...")
00071 
00072 display_only(cut_planes, my_view)
00073 reset_view(my_view)
00074 Render(my_view)
00075 
00076 print "\nChange Presentation Parameters..."
00077 
00078 for reprCode in represents:
00079     repr = RepresentationType.get_name(reprCode)
00080     if reprCode == RepresentationType.VOLUME:
00081         is_good = call_and_check(cut_planes, "Representation", repr, 0)
00082         if is_good:
00083             msg = "VOLUME representation must be not available for Iso Surface"
00084             raise RuntimeError(msg)
00085     else:
00086         call_and_check(cut_planes, "Representation", repr, 1)
00087 
00088         for sha in shadings:
00089             setShaded(my_view, sha)
00090             call_and_check(cut_planes, "Shading", sha, 1)
00091             Render(my_view)
00092 
00093             for opa in opacities:
00094                 call_and_check(cut_planes, "Opacity", opa, 1, compare_prec)
00095 
00096                 for lwi in linewidths:
00097                     call_and_check(cut_planes, "LineWidth", lwi, 1,
00098                     compare_prec)
00099                     time.sleep(1)
00100 
00101                     # save picture in file
00102                     # Construct image file name
00103                     pic_name = picturedir + "params_" + repr.replace(' ', '_') + "_any_" +  \
00104                         str(sha) + "_" + str(opa) + "_" + str(lwi) + "." + pictureext
00105                     # Show and record the presentation
00106                     process_prs_for_test(cut_planes, my_view, pic_name)