Back to index

salome-paravis  6.5.0
A0.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/tables/A0 case
00021 # Import table in Post-Pro specific format from the file;
00022 # choose 'sinus' table; create curve.
00023 
00024 import sys
00025 
00026 from paravistest import tablesdir, get_picture_dir, pictureext
00027 from presentations import *
00028 import paravis
00029 import pvsimple
00030 
00031 
00032 # Import table from file
00033 print 'Import tables_test.xls ....',
00034 file_path = tablesdir + "tables_test.xls"
00035 table_reader = pvsimple.TableReader(FileName=file_path)
00036 if table_reader is None:
00037     print "FAILED"
00038 else:
00039     print "OK"
00040 
00041 # Get available tables
00042 print 'Get available tables .....'
00043 available_tables = table_reader.GetPropertyValue("AvailableTables")
00044 if (available_tables is None) or (len(available_tables) == 0):
00045     print "FAILED"
00046 else:
00047     print available_tables
00048 
00049 # Choose 'sinus' table
00050 table_reader.TableNumber = available_tables.GetData().index('sinus')
00051 table_reader.UpdatePipeline()
00052 
00053 # Create curves
00054 cur_view = pvsimple.GetRenderView()
00055 if cur_view:
00056     pvsimple.Delete(cur_view)
00057 xy_view = pvsimple.CreateXYPlotView()
00058 
00059 # xy_rep = pvsimple.Show(table_reader)
00060 xy_rep = pvsimple.Show(table_reader)
00061 xy_rep.AttributeType = 'Row Data'
00062 xy_rep.UseIndexForXAxis = 0
00063 x_array = xy_rep.GetPropertyValue("SeriesNamesInfo")[0]
00064 xy_rep.XArrayName = x_array
00065 xy_rep.SeriesVisibility = [x_array, '0']
00066 pvsimple.Render(xy_view)
00067 
00068 # Write image
00069 
00070 # Directory for saving snapshots
00071 picturedir = get_picture_dir(sys.argv[1], "Tables/A0")
00072 if not picturedir.endswith(os.sep):
00073     picturedir += os.sep
00074 
00075 file_name = picturedir + "sinus." + pictureext
00076 pvsimple.WriteImage(file_name, view=xy_view, Magnification=1)
00077 
00078