3 \page tui_animation_page Animation
5 Example of <b>Successive Animation</b>:
14 from visu_gui import *
16 # The directory containing MED files
17 datadir = os.getenv("DATA_DIR")
20 medFile = os.path.join(datadir,"MedFiles","TimeStamps.med")
21 myResult = myVisu.ImportFile(medFile)
24 myViewManager = myVisu.GetViewManager()
25 myView = myViewManager.Create3DView()
26 myView.SetTitle("Animation view")
28 # Create an animation instance
31 myAnimation = myVisu.CreateAnimation(myView);
33 # Set the successive animation mode
34 myAnimation.setAnimationMode(VISU.Animation.SUCCESSIVE)
36 # Set the animation properties:
38 # Add a field with timestamps, on which the animation will be performed
39 fieldName = "vitesse, m/s"
40 fieldSO = salome.myStudy.FindObject(fieldName)
41 myAnimation.addField(fieldSO)
43 # Set the presentation type for the first field
44 myAnimation.setPresentationType(0, VISU.TDEFORMEDSHAPEANDSCALARMAP)
46 # Generate presentations
47 myAnimation.generatePresentations(0)
49 # Create the pattern of a Deformed Shape and Scalar Map presentation
52 fieldEntity = VISU.NODE
54 myDefShapeScalarMap = myVisu.DeformedShapeAndScalarMapOnField(myResult, meshName, fieldEntity, fieldName, timestampId)
55 myDefShapeScalarMap.SetScale(0.75)
57 # Apply the pattern properties to all generated presentations
58 myAnimation.ApplyProperties(0, myDefShapeScalarMap)
61 myAnimation.generateFrames()
63 # Publish the animation object in the study
64 myAnimation.publishInStudy()
67 myAnimation.setSpeed(80)
69 # Save the animation after changing the speed
70 myAnimation.saveAnimation()
76 myAnimation.startAnimation()
78 # Rewind to the first frame
80 myAnimation.firstFrame()
82 # Update the object browser
83 salome.sg.updateObjBrowser(1)
86 <br>Example of <b>Parallel Animation</b>:
90 from time import sleep
95 from visu_gui import *
97 # The directory containing MED files
98 datadir = os.getenv("DATA_DIR")
101 medFile = os.path.join(datadir,"MedFiles","TimeStamps.med")
102 myResult = myVisu.ImportFile(medFile)
105 myViewManager = myVisu.GetViewManager()
106 myView = myViewManager.Create3DView()
107 myView.SetTitle("Animation view")
109 # Create an animation instance
110 fieldName = "vitesse"
112 myAnimation = myVisu.CreateAnimation(myView);
114 # Set the successive animation mode
115 myAnimation.setAnimationMode(VISU.Animation.PARALLEL)
117 # Set animation properties:
119 # Add two fields with timestamps, on which the animation will be performed
120 fieldName1 = "vitesse, m/s"
121 fieldSO1 = salome.myStudy.FindObject(fieldName1)
122 fieldName2 = "temperature, K"
123 fieldSO2 = salome.myStudy.FindObject(fieldName2)
125 myAnimation.addField(fieldSO1)
126 myAnimation.addField(fieldSO2)
128 # Set the presentation type for the first field
129 myAnimation.setPresentationType(0, VISU.TVECTORS)
131 # Set the presentation type for the second field
132 myAnimation.setPresentationType(1, VISU.TSCALARMAP)
134 # Generate presentations for all fields
135 nbFileds = myAnimation.getNbFields()
136 for i in range(0, nbFileds):
137 myAnimation.generatePresentations(i)
139 # Create the pattern of Vectors presentation
141 fieldName = "vitesse"
142 fieldEntity = VISU.NODE
144 myVectors = myVisu.VectorsOnField(myResult, meshName, fieldEntity, fieldName, timestampId)
145 myVectors.SetScale(1)
146 myVectors.ShowColored(True)
148 # Apply the vectors pattern properties to all presentations generated for 'vitesse' field
149 myAnimation.ApplyProperties(0, myVectors)
152 myAnimation.generateFrames()
154 # Publish the animation object in the study
155 myAnimation.publishInStudy()
158 myAnimation.setSpeed(95)
163 # Start the animation
164 myAnimation.startAnimation()
166 # Update the object browser
167 salome.sg.updateObjBrowser(1)
170 <br>Please, see \ref VISU.Animation "Animation interface reference documentation"