Back to index

salome-paravis  6.5.0
B5.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/B5 case
00021 
00022 from time import sleep
00023 
00024 from paravistest import datadir, tablesdir
00025 from presentations import *
00026 import paravis
00027 import pvsimple
00028 
00029 
00030 DELAY = 2
00031 
00032 my_paravis = paravis.myParavis
00033 
00034 # Step 1
00035 print 'Importing "pointe.med"...............',
00036 file_path = datadir + "pointe.med"
00037 my_paravis.ImportFile(file_path)
00038 med_reader = pvsimple.GetActiveSource()
00039 
00040 if med_reader is None:
00041     print "FAILED"
00042 else:
00043     print "OK"
00044 
00045 field_name = "fieldnodedouble"
00046 entity = EntityType.NODE
00047 timestamp = 1
00048 
00049 
00050 # Step 2
00051 view1 = pvsimple.GetRenderView()
00052 print "view1 = pvsimple.GetRenderView()"
00053 
00054 sleep(DELAY)
00055 
00056 pvsimple.Delete(view1)
00057 print "pvsimple.Delete(view1)"
00058 
00059 
00060 # Step 3
00061 view2 = pvsimple.CreateRenderView()
00062 print "view2 = pvsimple.CreateRenderView()"
00063 
00064 color = [0.0, 0.3, 1.0]
00065 view2.Background = color
00066 print "view2.Background =", str(color)
00067 pvsimple.Render(view2)
00068 
00069 scalarmap = ScalarMapOnField(med_reader, entity, field_name, timestamp)
00070 print "ScalarMapOnField(...)"
00071 scalarmap.Visibility = 1
00072 pvsimple.Render(view2)
00073 
00074 view2.CameraFocalPoint = [0, 0, 0]
00075 print "view2.CameraFocalPoint = [0, 0, 0]"
00076 view2.CameraParallelScale = 2
00077 print "view2.CameraParallelScale = 2"
00078 pvsimple.Render(view2)
00079 
00080 view2.ResetCamera()
00081 print "view2.ResetCamera()"
00082 pvsimple.Render(view2)
00083 
00084 sleep(DELAY)
00085 
00086 
00087 # Step 4
00088 view3 = pvsimple.CreateRenderView()
00089 print "view3 = pvsimple.CreateRenderView()"
00090 
00091 color = [0.0, 0.7, 0.0]
00092 view3.Background = color
00093 print "view3.Background = ", str(color)
00094 pvsimple.Render(view3)
00095 
00096 cutplanes = CutPlanesOnField(med_reader, entity, field_name, timestamp,
00097                              orientation=Orientation.XY)
00098 print "CutPlanesOnField(...)"
00099 
00100 display_only(cutplanes, view3)
00101 print "display_only(cutplanes, view3)"
00102 
00103 point = view3.CameraFocalPoint
00104 point[0] = point[0] + 10
00105 view3.CameraFocalPoint = point
00106 print "view3.CameraFocalPoint = ", str(point)
00107 
00108 view3.ResetCamera()
00109 print "view3.ResetCamera()"
00110 pvsimple.Render(view3)
00111 print "pvsimple.Render(view3)"
00112 
00113 sleep(DELAY)
00114 
00115 
00116 # Step 5
00117 view4 = pvsimple.CreateRenderView()
00118 print "view4 = pvsimple.CreateRenderView()"
00119 
00120 color = [1.0, 0.7, 0.0]
00121 view4.Background = color
00122 print "view5.Background = ", str(color)
00123 pvsimple.Render(view4)
00124 
00125 isosurfaces = IsoSurfacesOnField(med_reader, entity, field_name, timestamp)
00126 print "isosurfaces = IsoSurfacesOnField(...)"
00127 
00128 display_only(isosurfaces, view4)
00129 print "display_only(isosurfaces, view4)"
00130 view4.ResetCamera()
00131 print "view4.ResetCamera()"
00132 
00133 pvsimple.Render(view4)
00134 print "pvsimple.Render(view4)"
00135 
00136 sleep(DELAY)
00137 
00138 
00139 # Step 6
00140 view5 = pvsimple.CreateRenderView()
00141 print "view5 = pvsimple.CreateRenderView()"
00142 
00143 color = [0.7, 0.7, 0.7]
00144 view5.Background = color
00145 print "view5.Background =", str(color)
00146 pvsimple.Render(view5)
00147 
00148 cutlines = CutLinesOnField(med_reader, entity, field_name, timestamp,
00149                            orientation1=Orientation.ZX,
00150                            orientation2=Orientation.YZ)
00151 print "cutlines = CutLinesOnField(...)"
00152 
00153 display_only(cutlines, view5)
00154 print "display_only(cutlines, view5)"
00155 pvsimple.ResetCamera(view5)
00156 print "pvsimple.ResetCamera(view5)"
00157 
00158 sleep(DELAY)
00159 
00160 
00161 # Step 7
00162 file_path = tablesdir + "sinus.csv"
00163 sinus_csv = pvsimple.CSVReader(FileName=file_path)
00164 sinus_csv.FieldDelimiterCharacters = ' '
00165 
00166 view6 = pvsimple.CreateXYPlotView()
00167 print "view6 = pvsimple.CreateXYPlotView()"
00168 
00169 xy_rep = pvsimple.Show(sinus_csv)
00170 xy_rep.AttributeType = 'Row Data'
00171 xy_rep.UseIndexForXAxis = 0
00172 xy_rep.XArrayName = 'x'
00173 xy_rep.SeriesVisibility = ['x', '0']
00174 
00175 sleep(DELAY)