]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/visu_apply_properties.py
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISU_SWIG / visu_apply_properties.py
1 #  VISU VISU_SWIG : binding of C++ implementation and Python
2 #
3 #  Copyright (C) 2003  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 #  File   : visu_apply_properties.py
23 #  Module : VISU
24
25 import os
26 import time
27 import math
28 import VISU
29 import SALOMEDS
30 from visu_gui import *
31
32 aDelay = 0
33
34 myViewManager = myVisu.GetViewManager();
35
36 myView = myViewManager.Create3DView();
37 myView.SetTitle("The viewer for Animation")
38 print "myViewManager.Create3DView()"
39 time.sleep(aDelay)
40
41 medFile = "TimeStamps.med"
42 myFieldName = "temperature"
43
44 medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
45 myResult = myVisu.ImportFile(medFile)
46
47 anAnim = myVisu.CreateAnimation(myView);
48
49 aSObj = myStudy.FindObjectIOR(myResult.GetID())
50 aSObj = aSObj.FindSubObject(1)[1]
51 aSObj = aSObj.FindSubObject(3)[1]
52 aSObj = aSObj.FindSubObject(1)[1]
53 print "addField 1 : ", anAnim.addField(aSObj)
54
55 print "Generate presentations for ", anAnim.getNbFields(), " fields"
56 for i in range(0,anAnim.getNbFields()):
57     anAnim.setPresentationType(i,VISU.TPLOT3D)
58     anAnim.generatePresentations(i)
59
60 print "Generate frames"
61 anAnim.generateFrames()
62
63 print "Start Animation"
64 anAnim.setSpeed(22)
65 anAnim.startAnimation()
66 myView.FitAll()
67
68 while 1:
69     time.sleep(1+aDelay)
70     if not anAnim.isRunning():
71         anAnim.stopAnimation()
72         break
73
74 anAnim.publishInStudy()
75 anAnim.saveAnimation()
76
77 for i in range(0,anAnim.getNbFields()):
78     aPrs = anAnim.getPresentation(i,0)
79     aPlot3D = aPrs._narrow(VISU.Plot3D)
80
81     if aPlot3D:
82         aNbLabels = aPlot3D.GetLabels()
83         aPlot3D.SetLabels(aNbLabels+3)
84
85         aWidth = aPlot3D.GetWidth()
86         aHeight = aPlot3D.GetHeight()
87         aPlot3D.SetSize(aWidth+0.07,aHeight+0.07)
88
89         print "Apply properties for all time stamps of ", i, " field."
90         try:
91             anAnim.ApplyProperties(i,aPlot3D)
92         except SALOME.SALOME_Exception, inst:
93             msg = "SALOME.SALOME_Exception caught, see details:"
94             msg+="\n******* text:\t" + inst.details.text
95             msg+="\n******* type:\t" + str(inst.details.type)
96             msg+="\n******* where:\t" + inst.details.sourceFile + ":" + \
97                   str(inst.details.lineNumber)    
98             print msg
99             raise RuntimeError, "There are some errors were occured... For more info see ERRORs above..."
100
101 print "Generate frames"
102 anAnim.generateFrames()
103
104 print "Start Animation"
105 anAnim.startAnimation()
106 myView.FitAll()
107
108 while 1:
109     time.sleep(1+aDelay)
110     if not anAnim.isRunning():
111         anAnim.stopAnimation()
112         break
113
114 anAnim.publishInStudy()
115 anAnim.saveAnimation()
116
117 anAnim.clearFields()
118 print "The number of fields in animation after clearFields method is", anAnim.getNbFields()
119