Salome HOME
Update copyrights 2014.
[modules/paravis.git] / test / VisuPrs / imps / A2.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/imps/A2 case
21
22 import time
23 from paravistest import datadir
24 from presentations import *
25 import paravis
26 import pvsimple
27
28 my_paravis = paravis.myParavis
29 sleep_delay = 2
30
31 med_file = "pointe.med"
32 entity = EntityType.NODE
33 field_name = "fieldnodedouble";
34 timestamp = 1
35
36 # 1. Import MED file
37 print 'Import "pointe.med"....................',
38 med_file_path = datadir + med_file
39 my_paravis.ImportFile(med_file_path)
40 med_reader = pvsimple.GetActiveSource()
41
42 if med_reader is None:
43     print "FAILED"
44 else:
45     print "OK"
46
47 # 2. Create Scalar Map
48 print "Build Scalar Map presentation"
49 scalar_map = ScalarMapOnField(med_reader, entity, field_name, timestamp)
50
51 display_only(scalar_map)
52 reset_view()
53 time.sleep(sleep_delay)
54
55 # 3. Set representation type to Point
56 print "Set representation type to Point"
57 scalar_map.Representation = 'Points'
58 pvsimple.Render()
59 time.sleep(sleep_delay)
60
61 # 4. Set representation type to Point Sprite
62 print "Set Point Sprite representation"
63 scalar_map.Representation = 'Point Sprite'
64
65 data_range = get_data_range(med_reader, entity,
66                             field_name, 'Magnitude')
67 mult = abs(0.1 / data_range[1])
68 scalar_map.RadiusScalarRange = data_range
69 scalar_map.RadiusTransferFunctionEnabled = 1
70 scalar_map.RadiusMode = 'Scalar'
71 scalar_map.RadiusArray = ['POINTS', field_name]
72 scalar_map.RadiusTransferFunctionMode = 'Table'
73 scalar_map.RadiusScalarRange = data_range
74 scalar_map.RadiusUseScalarRange = 1
75 scalar_map.RadiusIsProportional = 1
76 scalar_map.RadiusProportionalFactor = mult
77
78 pvsimple.Render()
79
80