]> SALOME platform Git repositories - modules/visu.git/blob - doc/salome/gui/VISU/input/tui_animation.doc
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/visu.git] / doc / salome / gui / VISU / input / tui_animation.doc
1 /*!
2
3 \page tui_animation_page Animation
4
5 Example of <b>Successive Animation</b>:
6
7 \code
8 import os
9 from time import sleep
10
11 import salome
12
13 import VISU
14 from visu_gui import *
15
16 # The directory containing MED files
17 datadir = os.getenv("DATA_DIR")
18
19 # Import a MED file 
20 medFile = os.path.join(datadir,"MedFiles","TimeStamps.med")
21 myResult = myVisu.ImportFile(medFile)
22
23 # Create a 3D view
24 myViewManager = myVisu.GetViewManager()
25 myView = myViewManager.Create3DView()
26 myView.SetTitle("Animation view")
27
28 # Create an animation instance
29 fieldName = "vitesse"
30
31 myAnimation = myVisu.CreateAnimation(myView);
32
33 # Set the successive animation mode
34 myAnimation.setAnimationMode(VISU.Animation.SUCCESSIVE)
35
36 # Set the animation properties:
37
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)
42
43 # Set the presentation type for the first field
44 myAnimation.setPresentationType(0, VISU.TDEFORMEDSHAPEANDSCALARMAP)
45
46 # Generate presentations
47 myAnimation.generatePresentations(0)
48
49 # Create the pattern of a Deformed Shape and Scalar Map presentation
50 meshName = "dom"
51 fieldName = "vitesse"
52 fieldEntity = VISU.NODE
53 timestampId = 1
54 myDefShapeScalarMap = myVisu.DeformedShapeAndScalarMapOnField(myResult, meshName, fieldEntity, fieldName, timestampId)
55 myDefShapeScalarMap.SetScale(0.75)
56
57 # Apply the pattern properties to all generated presentations
58 myAnimation.ApplyProperties(0, myDefShapeScalarMap)
59
60 # Generate frames
61 myAnimation.generateFrames()
62
63 # Publish the animation object in the study
64 myAnimation.publishInStudy()
65
66 # Set the speed
67 myAnimation.setSpeed(80)
68
69 # Save the animation after changing the speed
70 myAnimation.saveAnimation()
71
72 # Fit All
73 myView.FitAll()
74
75 # Start the animation
76 myAnimation.startAnimation()
77
78 # Rewind to the first frame
79 sleep(10)
80 myAnimation.firstFrame()
81
82 # Update the object browser
83 salome.sg.updateObjBrowser(1)
84 \endcode
85
86 <br>Example of <b>Parallel Animation</b>:
87
88 \code
89 import os
90 from time import sleep
91
92 import salome
93
94 import VISU
95 from visu_gui import *
96
97 # The directory containing MED files
98 datadir = os.getenv("DATA_DIR")
99
100 # Import a MED file 
101 medFile = os.path.join(datadir,"MedFiles","TimeStamps.med")
102 myResult = myVisu.ImportFile(medFile)
103
104 # Create a 3D view
105 myViewManager = myVisu.GetViewManager()
106 myView = myViewManager.Create3DView()
107 myView.SetTitle("Animation view")
108
109 # Create an animation instance
110 fieldName = "vitesse"
111
112 myAnimation = myVisu.CreateAnimation(myView);
113
114 # Set the successive animation mode
115 myAnimation.setAnimationMode(VISU.Animation.PARALLEL)
116
117 # Set animation properties:
118
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)
124
125 myAnimation.addField(fieldSO1)
126 myAnimation.addField(fieldSO2)
127
128 # Set the presentation type for the first field
129 myAnimation.setPresentationType(0, VISU.TVECTORS)
130
131 # Set the presentation type for the second field
132 myAnimation.setPresentationType(1, VISU.TSCALARMAP)
133
134 # Generate presentations for all fields
135 nbFileds = myAnimation.getNbFields()
136 for i in range(0, nbFileds):
137     myAnimation.generatePresentations(i)
138
139 # Create the pattern of Vectors presentation
140 meshName = "dom"
141 fieldName = "vitesse"
142 fieldEntity = VISU.NODE
143 timestampId = 1
144 myVectors = myVisu.VectorsOnField(myResult, meshName, fieldEntity, fieldName, timestampId)
145 myVectors.SetScale(1)
146 myVectors.ShowColored(True)
147
148 # Apply the vectors pattern properties to all presentations generated for 'vitesse' field
149 myAnimation.ApplyProperties(0, myVectors)
150
151 # Generate frames
152 myAnimation.generateFrames()
153
154 # Publish the animation object in the study
155 myAnimation.publishInStudy()
156
157 # Set the speed
158 myAnimation.setSpeed(95)
159
160 # Fit All
161 myView.FitAll()
162
163 # Start the animation
164 myAnimation.startAnimation()
165
166 # Update the object browser
167 salome.sg.updateObjBrowser(1)
168 \endcode
169
170 <br>Please, see \ref VISU.Animation "Animation interface reference documentation" 
171 for more details.
172
173 */