Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VISU_SWIG / VISU_Example_03.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 #  See http://www.salome-platform.org/
19 #
20 # Animation of "vitesse" field, stored in file TimeStamps.med
21
22 # This script is equivalent to non-regression test script 003/A5
23
24 import salome
25 import visu_gui
26 import SALOMEDS
27 import VISU
28 import os
29 import time
30
31 medFile = os.getenv("DATA_DIR") + "/MedFiles/TimeStamps.med"
32
33 print 'Importing "TimeStamps.med"................',
34 myVisu = visu_gui.myVisu
35 myResult = myVisu.ImportFile(medFile)
36 if myResult is None : print "Error"
37 else : print "OK"
38
39 print "Creating Cut Lines........................",
40 medMesh = 'dom'
41 medField = "vitesse"
42 aCutLines = myVisu.CutLinesOnField(myResult,'dom',VISU.NODE,medField,1.0)
43 aCutLines.SetOrientation(VISU.CutPlanes.XY, 0, 0)
44 aCutLines.SetOrientation2(VISU.CutPlanes.ZX, 0, 0)
45 aCutLines.SetNbLines(20)
46 if aCutLines is None : print "Error"
47 else : print "OK"
48
49 print "Creating a Viewer.........................",
50 myViewManager = myVisu.GetViewManager();
51 myView = myViewManager.Create3DView();
52 if myView is None : print "Error"
53 else : print "OK"
54 myView.Display(aCutLines);
55 myView.FitAll();
56
57 aCutLinesSObj = salome.myStudy.FindObjectIOR(aCutLines.GetID())
58 aFather = aCutLinesSObj.GetFather().GetFather();
59
60 print "Creating an Animation.....................",
61 myAnim = myVisu.CreateAnimation(myView); 
62 if myAnim is None : print "Error"
63 else : print "OK"
64
65 print "Animation.................................",
66 myAnim.addField(aFather);
67 myAnim.generatePresentations(0);
68 myAnim.generateFrames();
69 myAnim.setSpeed(33)
70 myAnim.startAnimation();
71
72 myView.FitAll()
73 while 1:
74     time.sleep(1)
75     if not myAnim.isRunning():
76         myAnim.stopAnimation()
77         break
78
79 print "OK"