1 # VISU VISU_SWIG : binding of C++ implementation and Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # File : visu_apply_properties.py
30 from visu_gui import *
34 myViewManager = myVisu.GetViewManager();
36 myView = myViewManager.Create3DView();
37 myView.SetTitle("The viewer for Animation")
38 print "myViewManager.Create3DView()"
41 medFile = "TimeStamps.med"
42 myFieldName = "temperature"
44 medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
45 myResult = myVisu.ImportFile(medFile)
47 anAnim = myVisu.CreateAnimation(myView);
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)
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)
60 print "Generate frames"
61 anAnim.generateFrames()
63 print "Start Animation"
65 anAnim.startAnimation()
70 if not anAnim.isRunning():
71 anAnim.stopAnimation()
74 anAnim.publishInStudy()
75 anAnim.saveAnimation()
77 for i in range(0,anAnim.getNbFields()):
78 aPrs = anAnim.getPresentation(i,0)
79 aPlot3D = aPrs._narrow(VISU.Plot3D)
82 aNbLabels = aPlot3D.GetLabels()
83 aPlot3D.SetLabels(aNbLabels+3)
85 aWidth = aPlot3D.GetWidth()
86 aHeight = aPlot3D.GetHeight()
87 aPlot3D.SetSize(aWidth+0.07,aHeight+0.07)
89 print "Apply properties for all time stamps of ", i, " field."
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)
99 raise RuntimeError, "There are some errors were occured... For more info see ERRORs above..."
101 print "Generate frames"
102 anAnim.generateFrames()
104 print "Start Animation"
105 anAnim.startAnimation()
110 if not anAnim.isRunning():
111 anAnim.stopAnimation()
114 anAnim.publishInStudy()
115 anAnim.saveAnimation()
118 print "The number of fields in animation after clearFields method is", anAnim.getNbFields()