Back to index

salome-paravis  6.5.0
B3.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/ScalarMap_On_DeformedShape/B3 case
00021 
00022 from paravistest import datadir
00023 from presentations import *
00024 import paravis
00025 import pvsimple
00026 
00027 my_paravis = paravis.myParavis
00028 
00029 #====================Stage1: Import MED file=========================
00030 print 'Importing "fra.med"...................',
00031 medFile = datadir + "fra.med"
00032 my_paravis.ImportFile(medFile)
00033 med_reader = pvsimple.GetActiveSource()
00034 
00035 if med_reader is None:
00036     print "FAILED"
00037 else:
00038     print "OK"
00039 
00040 view = pvsimple.GetRenderView()
00041 reset_view(view)
00042 
00043 #=============Stage2: Create Scalar Map On Deformed Shape=============
00044 field_name = "VITESSE"
00045 node_entity = EntityType.NODE
00046 timestamp = 1
00047 
00048 print "Creating Scalar Map On Deformed Shape...................",
00049 smondefshape1 = DeformedShapeAndScalarMapOnField(med_reader, node_entity,
00050                                                  field_name, 1)
00051 
00052 if smondefshape1 is None:
00053     print "FAILED"
00054 else:
00055     display_only(smondefshape1, view)
00056     pvsimple.ResetCamera(view)
00057     print "OK"
00058 
00059 #=============Stage3: Create with 'Y' vector mode========================
00060 hide_all(view)
00061 smondefshape2 = DeformedShapeAndScalarMapOnField(med_reader,
00062                                                  node_entity,
00063                                                  field_name, 1,
00064                                                  vector_mode='Y')
00065 
00066 print "Creating Scalar Map On Deformed Shape with 'Y' scalar mode.....",
00067 if smondefshape2 is None:
00068     print "FAILED"
00069 else:
00070     print "OK"
00071 
00072 #=============Stage4: scaling of Scalar Map On Deformed Shape============
00073 bar = get_bar()
00074 lt = bar.LookupTable
00075 
00076 print "Changing scaling mode:"
00077 lt.UseLogScale = 0
00078 print "Log scaling ....", lt.UseLogScale
00079 pvsimple.Render(view)
00080 
00081 lt.UseLogScale = 1
00082 print "Log scaling ....", lt.UseLogScale
00083 pvsimple.Render()
00084 
00085 #=============Stage5: range of Scalar Map On Deformed Shape==============
00086 print "Changing scalar range:"
00087 range_min = 12
00088 range_max = 120
00089 lt.RGBPoints[0] = range_min
00090 lt.RGBPoints[4] = range_max
00091 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
00092 pvsimple.Render(view)
00093 
00094 range_min = 120
00095 range_max = 120
00096 lt.RGBPoints[0] = range_min
00097 lt.RGBPoints[4] = range_max
00098 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
00099 pvsimple.Render(view)
00100 
00101 range_min = 120
00102 range_max = 15
00103 lt.RGBPoints[0] = range_min
00104 lt.RGBPoints[4] = range_max
00105 print "min = " + str(lt.RGBPoints[0]) + "; max = " + str(lt.RGBPoints[4])
00106 pvsimple.Render(view)
00107 
00108 #=============Stage6: bar orientation of Scalar Map On Deformed Shape==
00109 print "Changing bar orientation:"
00110 print "Default orientation: ", bar.Orientation
00111 
00112 print "Set horizontal bar orientation"
00113 bar.Orientation = 'Horizontal'
00114 print "Bar orientation: ", bar.Orientation
00115 pvsimple.Render(view)
00116 
00117 print "Set vertical bar orientation"
00118 bar.Orientation = 'Vertical'
00119 print "Bar orientation: ", bar.Orientation
00120 pvsimple.Render(view)
00121 
00122 #=============Stage7: bar position of Scalar Map On Deformed Shape ====
00123 print "Changing bar position:"
00124 print "Default position: ", bar.Position
00125 
00126 print "Set position X,Y positive"
00127 x_pos = 200
00128 y_pos = 100
00129 bar.Position = [x_pos, y_pos]
00130 print "Bar position [X,Y]: ", bar.Position
00131 pvsimple.Render(view)
00132 
00133 print "Set position X negative ,Y positive"
00134 x_pos = -100
00135 y_pos = 150
00136 bar.Position = [x_pos, y_pos]
00137 print "Bar position [X,Y]: ", bar.Position
00138 pvsimple.Render(view)
00139 
00140 print "Set position X positive, Y negative"
00141 x_pos = 100
00142 y_pos = -100
00143 bar.Position = [x_pos, y_pos]
00144 print "Bar position [X,Y]: ", bar.Position
00145 pvsimple.Render(view)
00146 
00147 print "Set position X = 0.1, Y = 0.01"
00148 x_pos = 0.1
00149 y_pos = 0.01
00150 bar.Position = [x_pos, y_pos]
00151 print "Bar position [X,Y]: ", bar.Position
00152 pvsimple.Render(view)
00153 
00154 #============Stage8: bar size of Scalar Map On Deformed Shape===========
00155 print "Changing bar size:"
00156 print "Default [width, height]: ", bar.Position2
00157 
00158 print "Set height = height*1.2"
00159 height = bar.Position2[1] * 1.2
00160 bar.Position2[1] = height
00161 print "Bar [width, height]: ", bar.Position2
00162 pvsimple.Render(view)
00163 
00164 print "Set width = width*2"
00165 width = bar.Position2[0] * 2
00166 bar.Position2[0] = width
00167 print "Bar [width, height]: ", bar.Position2
00168 pvsimple.Render(view)
00169 
00170 #=============Stage9: nb of colors of Scalar Map On Deformed Shape======
00171 print "Changing number of colors:"
00172 print "Default number of colors: ", lt.NumberOfTableValues
00173 lt.Discretize = 1
00174 
00175 print "Set negative number of colors"
00176 num = -128
00177 lt.NumberOfTableValues = num
00178 print "Number of colors: ", lt.NumberOfTableValues
00179 pvsimple.Render(view)
00180 
00181 print "Set zero number of colors"
00182 num = 0
00183 lt.NumberOfTableValues = num
00184 print "Number of colors: ", lt.NumberOfTableValues
00185 pvsimple.Render(view)
00186 
00187 print "Set positive number of colors"
00188 num = 256
00189 lt.NumberOfTableValues = num
00190 print "Number of colors: ", lt.NumberOfTableValues
00191 pvsimple.Render(view)
00192 
00193 #=============Stage10: nb of labels of Scalar Map On Deformed Shape=====
00194 print "Changing number of labels:"
00195 print "Default number of labels: ", bar.NumberOfLabels
00196 
00197 print "Set negative number of labels"
00198 num = -128
00199 bar.NumberOfLabels = num
00200 print "Number of labels: ", bar.NumberOfLabels
00201 pvsimple.Render(view)
00202 
00203 print "Set zero number of labels"
00204 num = 0
00205 bar.NumberOfLabels = num
00206 print "Number of labels: ", bar.NumberOfLabels
00207 pvsimple.Render(view)
00208 
00209 print "Set positive number of labels"
00210 num = 256
00211 bar.NumberOfLabels = num
00212 print "Number of labels: ", bar.NumberOfLabels
00213 pvsimple.Render(view)
00214 
00215 #=============Stage11: bar title of Scalar Map On Deformed Shape=========
00216 print "Changing bar title:"
00217 print "Default bar title: ", bar.Title
00218 
00219 print "Set not null title"
00220 title = "Scalar Bar Title"
00221 bar.Title = title
00222 print 'Bar title: "' + bar.Title + '"'
00223 pvsimple.Render(view)
00224 
00225 print "Set title from spaces"
00226 title = '    '
00227 bar.Title = title
00228 print 'Bar title: "' + bar.Title + '"'
00229 pvsimple.Render(view)
00230 
00231 #============Stage12: scale factor of ScalarMap On Deformed Shape =====
00232 print "Changing scale factor:"
00233 warp_vector = smondefshape2.Input
00234 
00235 print 'Default scale: ', warp_vector.ScaleFactor
00236 
00237 scale = 0.8
00238 warp_vector.ScaleFactor = scale
00239 warp_vector.UpdatePipeline()
00240 print "Scale: ", warp_vector.ScaleFactor
00241 pvsimple.Render(view)