Salome HOME
8c0c15227bcf55bdfda0b099a6f66fc585f62860
[modules/paravis.git] / test / VisuPrs / Vectors / B3.py
1 # Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This case corresponds to: /visu/Vectors/B3 case
21
22 import sys
23
24 from paravistest import datadir
25 from presentations import VectorsOnField, EntityType
26 import pvserver as paravis
27 import pvsimple
28
29 my_paravis = paravis.myParavis
30
31 #====================Stage1: Importing MED file====================
32
33 print "**** Stage1: Importing MED file"
34
35 print 'Import "ResOK_0000.med"...............',
36 medFile = datadir + "ResOK_0000.med"
37 my_paravis.ImportFile(medFile)
38 med_reader = pvsimple.GetActiveSource()
39
40 if med_reader is None:
41     print "FAILED"
42 else:
43     print "OK"
44
45 cell_entity = EntityType.CELL
46 node_entity = EntityType.NODE
47
48 #====================Stage2: Creation of Vectors====================
49
50 print "Creating Vectors..........",
51 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
52
53 if vectors is None:
54     print "FAILED"
55 else:
56     print "OK"
57
58 #====================Stage3: Change properties======================
59 glyph = vectors.Input
60
61 print "Default LineWidth : ", vectors.LineWidth
62 print "Default GlyphType : ", glyph.GlyphType
63 print "Default subtype   : ", glyph.GlyphType.GlyphType
64 print "Default GlyphPos  : ", glyph.GlyphType.Center
65
66 print "Changing value of line width"
67 width = -10
68 vectors.LineWidth = width
69 print "Negative value -10 : ", vectors.LineWidth
70 pvsimple.Render()
71
72 width = 10
73 vectors.LineWidth = width
74 print "Positive value  10 : ", vectors.LineWidth
75 pvsimple.Render()
76
77 width = 0
78 vectors.LineWidth = width
79 print "Zero value       0 : ", vectors.LineWidth
80 pvsimple.Render()
81
82 width = 2
83 vectors.LineWidth = width
84 print "Positive value   2 : ", vectors.LineWidth
85 pvsimple.Render()
86
87 print "Changing glyph type"
88 gtype = "Arrow"
89 glyph.GlyphType = gtype
90 print "Arrow type     : ", glyph.GlyphType
91 pvsimple.Render()
92
93 gtype = "Cone"
94 glyph.GlyphType = gtype
95 glyph.GlyphType.Resolution = 3
96 glyph.GlyphType.Height = 4
97 print "Cone type: " + str(glyph.GlyphType) + ", resolution: " + str(glyph.GlyphType.Resolution)
98 pvsimple.Render()
99
100 glyph.GlyphType.Resolution = 6
101 print "Cone type: " + str(glyph.GlyphType) + ", resolution: " + str(glyph.GlyphType.Resolution)
102 pvsimple.Render()
103
104 gtype = "Line"
105 glyph.GlyphType = gtype
106 print "Line Type      : ", glyph.GlyphType
107 pvsimple.Render()
108
109 gtype = "2D Glyph"
110 glyph.GlyphType = gtype
111 glyph.GlyphType.GlyphType = "Arrow"
112 pvsimple.Render()
113
114 print "Changing glyph position"
115 pos = [0.0, 0.0, 0.0]
116 glyph.GlyphType.Center = pos
117 print "Center position : ", glyph.GlyphType.Center
118 pvsimple.Render()
119
120 pos = [0.5, 0.0, 0.0]
121 glyph.GlyphType.Center = pos
122 print "Tail position   : ", glyph.GlyphType.Center
123 pvsimple.Render()
124
125 pos = [-0.5, 0.0, 0.0]
126 glyph.GlyphType.Center = pos
127 print "Head position   : ", glyph.GlyphType.Center
128 pvsimple.Render()