]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/visu_succcessive_animation.py
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/visu.git] / src / VISU_SWIG / visu_succcessive_animation.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #  VISU VISU_SWIG : binding of C++ implementation and Python
23 #  File   : visu_view3d.py
24 #  Module : VISU
25 #
26 import os
27 import time
28 import math
29 import VISU
30 import SALOMEDS
31 from visu_gui import *
32
33 aDelay = 0
34
35 myViewManager = myVisu.GetViewManager();
36
37 myView = myViewManager.Create3DView();
38 myView.SetTitle("The viewer for Animation")
39 print "myViewManager.Create3DView()"
40 time.sleep(aDelay)
41
42 medFile = "TimeStamps.med"
43 myFieldName = "temperature"
44
45 medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
46 myResult = myVisu.ImportFile(medFile)
47
48 anAnim = myVisu.CreateAnimation(myView);
49 anAnim.setAnimationMode(VISU.Animation.SUCCESSIVE);
50
51 aSObj = myStudy.FindObjectIOR(myResult.GetID())
52 aSObj = aSObj.FindSubObject(1)[1]
53 aSObj = aSObj.FindSubObject(3)[1]
54 aSObj = aSObj.FindSubObject(1)[1]
55 print "addField 1 : ", anAnim.addField(aSObj)
56
57 medFile1 = "TimeStamps_import22.med"
58 myFieldName1 = "pression"
59
60 medFile1 = os.getenv('DATA_DIR') + '/MedFiles/' + medFile1
61 myResult1 = myVisu.ImportFile(medFile1)
62
63 aSObj1 = myStudy.FindObjectIOR(myResult1.GetID())
64 aSObj1 = aSObj1.FindSubObject(1)[1]
65 aSObj1 = aSObj1.FindSubObject(3)[1]
66 aSObj1 = aSObj1.FindSubObject(3)[1]
67 print "addField 2 : ", anAnim.addField(aSObj1)
68
69 print "Generate presentations for ", anAnim.getNbFields(), " fields"
70 for i in range(0,anAnim.getNbFields()):
71     anAnim.setPresentationType(i,VISU.TPLOT3D)
72     anAnim.generatePresentations(i)
73
74 print "Generate frames"
75 anAnim.generateFrames()
76
77 print "Start Animation"
78 anAnim.setSpeed(22)
79 anAnim.startAnimation()
80 myView.FitAll()
81
82 while 1:
83     time.sleep(1+aDelay)
84     if not anAnim.isRunning():
85         anAnim.stopAnimation()
86         break
87
88 anAnim.publishInStudy()
89 anAnim.saveAnimation()
90
91 if anAnim.getAnimationMode() == VISU.Animation.SUCCESSIVE:
92    print "End of succcessive animation for 2 fields with presentation type VISU.Animation.SUCCESSIVE"
93    
94 anAnim.clearFields()
95 print "The number of fields in animation after clearFields method is", anAnim.getNbFields()
96