Salome HOME
b29edbf611c59f5b093ecf80ae2ed4a04f80e396
[modules/paravis.git] / test / VisuPrs / Animation / G8.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/animation/G8 case
21 #%Create animation for Vectors for 'vitesse' field of the the given MED file and dumps picture files in JPEG format %
22
23 import sys
24 import os
25 from paravistest import * 
26 from presentations import *
27 from pvsimple import *
28 import pvserver as paravis
29
30 #import file
31 myParavis = paravis.myParavis
32
33 # Directory for saving snapshots
34 picturedir = get_picture_dir("Animation/G8")
35
36 theFileName = datadir +  "TimeStamps.med"
37 print " --------------------------------- "
38 print "file ", theFileName
39 print " --------------------------------- "
40
41 myParavis.ImportFile(theFileName)
42 aProxy = GetActiveSource()
43 if aProxy is None:
44         raise RuntimeError, "Error: can't import file."
45 else: print "OK"
46
47 print "Creating a Viewer.........................",
48 aView = GetRenderView()
49 reset_view(aView)
50 Render(aView)
51
52 if aView is None : print "Error"
53 else : print "OK"
54
55 # Vectors creation
56 prs= VectorsOnField(aProxy,EntityType.NODE,'vitesse' , 1)
57 prs.Visibility=1
58 aView.ResetCamera()
59 print "Creating an Animation.....................",
60 my_format = "jpeg"
61 print "Current format to save snapshots: ",my_format
62 # Add path separator to the end of picture path if necessery
63 if not picturedir.endswith(os.sep):
64     picturedir += os.sep
65
66 # Select only the current field:
67 aProxy.AllArrays = []
68 aProxy.UpdatePipeline()
69 aProxy.AllArrays = ['TS0/dom/ComSup0/vitesse@@][@@P1']
70 aProxy.UpdatePipeline()
71    
72 # Animation creation and saving into set of files into picturedir
73 scene = AnimateReader(aProxy,aView,picturedir+"G8_dom."+my_format)
74 nb_frames = len(scene.TimeKeeper.TimestepValues)
75
76 pics = os.listdir(picturedir) 
77 if len(pics) != nb_frames:
78    print "FAILED!!! Number of made pictures is equal to ", len(pics), " instead of ", nb_frames
79     
80 for pic in pics:
81     os.remove(picturedir+pic)    
82     
83 # Prepare animation  performance    
84 scene.PlayMode = 1 #  set RealTime mode for animation performance
85 # set period
86 scene.Duration = 30 # correspond to set the speed of animation in VISU 
87 scene.GoToFirst()
88 print "Animation.................................",
89 scene.Play()
90 scene.GoToFirst()