Salome HOME
Merge branch 'V7_dev'
[modules/paravis.git] / test / VisuPrs / Animation / A1.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/animation/A1 case
21 # Test animation API
22
23 import sys
24 import os
25 from paravistest import *
26 from presentations import *
27 from pvsimple import *
28
29 # 1. TimeStamps.med import
30 print 'Importing "TimeStamps.med"................',
31 file_path = datadir + "TimeStamps.med"
32 OpenDataFile(file_path)
33 med_reader = GetActiveSource()
34 if med_reader is None:
35     print "FAILED"
36 else:
37     print "OK"
38
39 # 2. CutLines creation
40 print "Creating Cut Lines........................",
41 med_field = "vitesse"
42 cutlines = CutLinesOnField(med_reader, EntityType.NODE, med_field, 1,
43                            nb_lines = 20,
44                            orientation1=Orientation.XY, orientation2=Orientation.ZX)
45 if cutlines is None:
46     print "FAILED"
47 else:
48     print "OK"
49
50 # 3. Display CutLines
51 print "Getting a Viewer.........................",
52 view = GetRenderView()
53 if view is None:
54     print "FAILED"
55 else:
56     print "OK"
57 cutlines.Visibility = 1
58 Render(view=view)
59 cutlines.Visibility = 0
60 Render(view=view)
61 display_only(cutlines, view=view)
62 reset_view(view=view)
63
64 # 4. Animation
65 print "Get Animation scene.....................",
66 scene = GetAnimationScene()
67 if scene is None:
68     print "FAILED"
69 else:
70     print "OK"
71
72 print "Duration default... ", scene.Duration
73 scene.Duration = -10
74 scene.Duration = 120
75 scene.Duration = 0
76 scene.Duration = 30
77 print "Duration        ... ", scene.Duration
78
79 print "Loop            ... ", scene.Loop
80 scene.Loop = 1
81 print "Loop            ... ", scene.Loop
82 scene.Loop = 0
83 print "Loop            ... ", scene.Loop
84
85 print "AnimationTime   ... ", scene.AnimationTime
86
87 scene.Play()
88
89 scene.GoToFirst()
90 scene.GoToNext()
91 scene.GoToNext()
92
93 print "AnimationTime   ... ", scene.AnimationTime
94
95 scene.GoToPrevious()
96 scene.GoToLast()
97
98 scene.Stop()
99
100 print "AnimationTime   ... ", scene.AnimationTime
101
102 scene.AnimationTime = -1
103 scene.AnimationTime = scene.TimeKeeper.TimestepValues[1]
104 scene.AnimationTime = scene.TimeKeeper.TimestepValues[0]
105
106 nb_frames = scene.NumberOfFrames
107 print "NumberOfFrames  ... ", nb_frames
108