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