Salome HOME
Copyright update: 2016
[modules/paravis.git] / test / VisuPrs / Animation / G0.py
index 4975156a6dfde819d6556f3d35b356f260b8400b..65f39ef27f1a5bcc2791536b92fe7432ae655bf9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014  CEA/DEN, EDF R&D
+# Copyright (C) 2010-2016  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 
 import sys
 import os
-from paravistest import * 
+from paravistest import *
 from presentations import *
 from pvsimple import *
-import paravis
-
-#import file
-myParavis = paravis.myParavis
 
 # Directory for saving snapshots
 picturedir = get_picture_dir("Animation/G0")
@@ -38,14 +34,17 @@ print " --------------------------------- "
 print "file ", theFileName
 print " --------------------------------- "
 
-myParavis.ImportFile(theFileName)
+OpenDataFile(theFileName)
 aProxy = GetActiveSource()
 if aProxy is None:
-       raise RuntimeError, "Error: can't import file."
+        raise RuntimeError, "Error: can't import file."
 else: print "OK"
 
 print "Creating a Viewer.........................",
 aView = GetRenderView()
+time_value = get_time(aProxy, 0)
+aView.ViewTime = time_value
+UpdatePipeline(time=time_value, proxy=aProxy)
 reset_view(aView)
 Render(aView)
 
@@ -54,7 +53,11 @@ else : print "OK"
 
 # Stream Lines creation
 prs= StreamLinesOnField(aProxy,EntityType.NODE,'vitesse' , 1)
-prs.Visibility=1
+if prs is None:
+  # TODO: check why stream lines prs is empty
+  print "WARNING! StreamLines presentation wasn't created or is empty..."
+else:
+  prs.Visibility=1
 aView.ResetCamera()
 print "Creating an Animation.....................",
 my_format = "jpeg"
@@ -64,26 +67,26 @@ if not picturedir.endswith(os.sep):
     picturedir += os.sep
 
 # Select only the current field:
-aProxy.AllArrays = []
-aProxy.UpdatePipeline()
 aProxy.AllArrays = ['TS0/dom/ComSup0/vitesse@@][@@P1']
-aProxy.UpdatePipeline()
-   
+time_value = get_time(aProxy, 0)
+aView.ViewTime = time_value
+UpdatePipeline(time=time_value, proxy=aProxy)
+
 # Animation creation and saving into set of files into picturedir
 scene = AnimateReader(aProxy,aView,picturedir+"G0_dom."+my_format)
 nb_frames = len(scene.TimeKeeper.TimestepValues)
 
-pics = os.listdir(picturedir) 
+pics = os.listdir(picturedir)
 if len(pics) != nb_frames:
    print "FAILED!!! Number of made pictures is equal to ", len(pics), " instead of ", nb_frames
-    
+
 for pic in pics:
-    os.remove(picturedir+pic)    
-    
-# Prepare animation  performance    
+    os.remove(picturedir+pic)
+
+# Prepare animation  performance
 scene.PlayMode = 1 #  set RealTime mode for animation performance
 # set period
-scene.Duration = 30 # correspond to set the speed of animation in VISU 
+scene.Duration = 30 # correspond to set the speed of animation in VISU
 scene.GoToFirst()
 print "Animation.................................",
 scene.Play()