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