Back to index

salome-paravis  6.5.0
B7.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/SWIG_scripts/B7 case
00021 # Import a table from file and show it in 2D viewer
00022 
00023 from paravistest import tablesdir
00024 from presentations import *
00025 import paravis
00026 import pvsimple
00027 
00028 
00029 # Import table from CSV file
00030 file_path = tablesdir + "table_test.csv"
00031 table_csv = pvsimple.CSVReader(FileName=file_path)
00032 
00033 # Set space as separator
00034 table_csv.FieldDelimiterCharacters = ';'
00035 
00036 # Display curve
00037 cur_view = pvsimple.GetRenderView()
00038 if cur_view:
00039     pvsimple.Delete(cur_view)
00040 xy_view = pvsimple.CreateXYPlotView()
00041 
00042 xy_rep = pvsimple.Show(table_csv)
00043 xy_rep.AttributeType = 'Row Data'
00044 xy_rep.UseIndexForXAxis = 0
00045 xy_rep.XArrayName = 'X'
00046 xy_rep.SeriesVisibility = ['X', '0']
00047 
00048 # Set view properties
00049 title = xy_view.ChartTitle
00050 xy_view.ChartTitle = "Change the title from python"
00051 pvsimple.Render(xy_view)
00052 
00053 axis_title = xy_view.AxisTitle
00054 xy_view.AxisTitle[0] = "Y axis"
00055 xy_view.AxisTitle[1] = "X axis"
00056 pvsimple.Render(xy_view)
00057 
00058 xy_view.ShowLegend = 0
00059 pvsimple.Render(xy_view)
00060 
00061 xy_view.ShowAxis = [0, 0, 0, 0]
00062 pvsimple.Render(xy_view)
00063 xy_view.ShowAxis = [1, 0, 0, 0]
00064 pvsimple.Render(xy_view)
00065 xy_view.ShowAxis[1] = 1
00066 pvsimple.Render(xy_view)
00067 
00068 # Set logarithmic scaling
00069 xy_view.AxisLogScale[0] = 1
00070 pvsimple.Render(xy_view)
00071 xy_view.AxisLogScale[1] = 1
00072 pvsimple.Render(xy_view)
00073 
00074 # Set representation properties
00075 
00076 # Show/hide curves
00077 xy_rep.SeriesVisibility = ['Y0', '0', 'Y1', '0',
00078                            'Y2', '0', 'Y3', '0']
00079 pvsimple.Render(xy_view)
00080 xy_rep.SeriesVisibility = ['Y0', '1']
00081 pvsimple.Render(xy_view)
00082 xy_rep.SeriesVisibility = ['Y1', '1']
00083 pvsimple.Render(xy_view)
00084 xy_rep.SeriesVisibility = ['Y2', '1']
00085 pvsimple.Render(xy_view)
00086 
00087 xy_rep.SeriesVisibility = ['Y3', '1']
00088 xy_rep.SeriesVisibility = ['Y3', '0']
00089 xy_rep.SeriesVisibility = ['Y3', '1']
00090 pvsimple.Render(xy_view)
00091 
00092 # Line style
00093 xy_rep.SeriesLineStyle = ['Y0', '5']
00094 pvsimple.Render(xy_view)
00095 xy_rep.SeriesLineStyle = ['Y1', '4']
00096 pvsimple.Render(xy_view)
00097 xy_rep.SeriesLineStyle = ['Y2', '3']
00098 pvsimple.Render(xy_view)
00099 xy_rep.SeriesLineStyle = ['Y3', '2']
00100 pvsimple.Render(xy_view)
00101 
00102 # Line thickness
00103 values = (2, 4, 6, 8, 10, 1)
00104 for val in values:
00105     xy_rep.SeriesLineThickness = ['Y3', str(val)]
00106     pvsimple.Render(xy_view)
00107 
00108 xy_rep.SeriesLineStyle = ['Y3', '0']
00109 pvsimple.Render(xy_view)
00110 
00111 # Marker type
00112 xy_rep.SeriesMarkerStyle = ['Y3', '5']
00113 pvsimple.Render(xy_view)
00114 xy_rep.SeriesMarkerStyle = ['Y2', '4']
00115 pvsimple.Render(xy_view)
00116 xy_rep.SeriesMarkerStyle = ['Y1', '3']
00117 pvsimple.Render(xy_view)
00118 xy_rep.SeriesMarkerStyle = ['Y0', '8']
00119 pvsimple.Render(xy_view)
00120 
00121 # Marker size
00122 for val in values:
00123     xy_rep.SeriesLineThickness = ['Y3', str(val)]
00124     pvsimple.Render(xy_view)