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/Vectors/B3 case
00021 
00022 import sys
00023 
00024 from paravistest import datadir
00025 from presentations import VectorsOnField, EntityType
00026 import paravis
00027 import pvsimple
00028 
00029 my_paravis = paravis.myParavis
00030 
00031 #====================Stage1: Importing MED file====================
00032 
00033 print "**** Stage1: Importing MED file"
00034 
00035 print 'Import "ResOK_0000.med"...............',
00036 medFile = datadir + "ResOK_0000.med"
00037 my_paravis.ImportFile(medFile)
00038 med_reader = pvsimple.GetActiveSource()
00039 
00040 if med_reader is None:
00041     print "FAILED"
00042 else:
00043     print "OK"
00044 
00045 cell_entity = EntityType.CELL
00046 node_entity = EntityType.NODE
00047 
00048 #====================Stage2: Creation of Vectors====================
00049 
00050 print "Creating Vectors..........",
00051 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
00052 
00053 if vectors is None:
00054     print "FAILED"
00055 else:
00056     print "OK"
00057 
00058 #====================Stage3: Change properties======================
00059 glyph = vectors.Input
00060 
00061 print "Default LineWidth : ", vectors.LineWidth
00062 print "Default GlyphType : ", glyph.GlyphType
00063 print "Default subtype   : ", glyph.GlyphType.GlyphType
00064 print "Default GlyphPos  : ", glyph.GlyphType.Center
00065 
00066 print "Changing value of line width"
00067 width = -10
00068 vectors.LineWidth = width
00069 print "Negative value -10 : ", vectors.LineWidth
00070 pvsimple.Render()
00071 
00072 width = 10
00073 vectors.LineWidth = width
00074 print "Positive value  10 : ", vectors.LineWidth
00075 pvsimple.Render()
00076 
00077 width = 0
00078 vectors.LineWidth = width
00079 print "Zero value       0 : ", vectors.LineWidth
00080 pvsimple.Render()
00081 
00082 width = 2
00083 vectors.LineWidth = width
00084 print "Positive value   2 : ", vectors.LineWidth
00085 pvsimple.Render()
00086 
00087 print "Changing glyph type"
00088 gtype = "Arrow"
00089 glyph.GlyphType = gtype
00090 print "Arrow type     : ", glyph.GlyphType
00091 pvsimple.Render()
00092 
00093 gtype = "Cone"
00094 glyph.GlyphType = gtype
00095 glyph.GlyphType.Resolution = 3
00096 glyph.GlyphType.Height = 4
00097 print "Cone type: " + str(glyph.GlyphType) + ", resolution: " + str(glyph.GlyphType.Resolution)
00098 pvsimple.Render()
00099 
00100 glyph.GlyphType.Resolution = 6
00101 print "Cone type: " + str(glyph.GlyphType) + ", resolution: " + str(glyph.GlyphType.Resolution)
00102 pvsimple.Render()
00103 
00104 gtype = "Line"
00105 glyph.GlyphType = gtype
00106 print "Line Type      : ", glyph.GlyphType
00107 pvsimple.Render()
00108 
00109 gtype = "2D Glyph"
00110 glyph.GlyphType = gtype
00111 glyph.GlyphType.GlyphType = "Arrow"
00112 pvsimple.Render()
00113 
00114 print "Changing glyph position"
00115 pos = [0.0, 0.0, 0.0]
00116 glyph.GlyphType.Center = pos
00117 print "Center position : ", glyph.GlyphType.Center
00118 pvsimple.Render()
00119 
00120 pos = [0.5, 0.0, 0.0]
00121 glyph.GlyphType.Center = pos
00122 print "Tail position   : ", glyph.GlyphType.Center
00123 pvsimple.Render()
00124 
00125 pos = [-0.5, 0.0, 0.0]
00126 glyph.GlyphType.Center = pos
00127 print "Head position   : ", glyph.GlyphType.Center
00128 pvsimple.Render()