Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / VISU_SWIG / visu_cache.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 import os
25 import time
26 import VISU
27 import SALOMEDS
28 from batchmode_visu import *
29
30 #---------------------------------------------------------------
31 def WalkTroughTimeStamps(theVISUType,
32                          theInput,
33                          theViewManager):
34   aView = theViewManager.Create3DView();
35   aView.SetTitle("To test presentation of %s type" % theVISUType)
36
37   aCache = myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
38   aHolder = aCache.CreateHolder(theVISUType, theInput)
39
40   if not aHolder:
41     print "It is impossible to create such kind of holder (%s) with the given parameters" % theVISUType
42     print "\ttheMeshName = '%s'" % theInput.myMeshName
43     print "\ttheEntity = %s" % theInput.myEntity
44     print "\ttheFieldName = '%s'" % theInput.myFieldName
45     print "\ttheTimeStampNumber = %s" % theInput.myTimeStampNumber
46     return
47
48   aPrs3d = aHolder.GetDevice()
49
50   if not aHolder.Apply(aPrs3d, theInput, aView):
51     print "It is impossible to create such kind of presentation (%s) with the given parameters" % theVISUType
52     print "\ttheMeshName = '%s'" % theInput.myMeshName
53     print "\ttheEntity = %s" % theInput.myEntity
54     print "\ttheFieldName = '%s'" % theInput.myFieldName
55     print "\ttheTimeStampNumber = %s" % theInput.myTimeStampNumber
56     return
57
58   aView.FitAll()
59
60   aDelay = 0.0
61   aRange = aHolder.GetTimeStampsRange()
62   for anInfo in aRange:
63     print "%d (%s); " % (anInfo.myNumber, anInfo.myTime)
64     theInput.myTimeStampNumber = anInfo.myNumber
65     aHolder.Apply(aPrs3d, theInput, aView)
66     time.sleep(aDelay)
67     pass
68   pass
69
70 #---------------------------------------------------------------
71 PRS3D_TYPE_LIST = []
72 PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS)
73 PRS3D_TYPE_LIST.append(VISU.TSCALARMAP)
74 PRS3D_TYPE_LIST.append(VISU.TISOSURFACES)
75 PRS3D_TYPE_LIST.append(VISU.TCUTPLANES)
76 PRS3D_TYPE_LIST.append(VISU.TCUTLINES)
77 PRS3D_TYPE_LIST.append(VISU.TCUTSEGMENT)
78 PRS3D_TYPE_LIST.append(VISU.TPLOT3D)
79 PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE)
80 PRS3D_TYPE_LIST.append(VISU.TVECTORS)
81 PRS3D_TYPE_LIST.append(VISU.TSTREAMLINES)
82 PRS3D_TYPE_LIST.append(VISU.TSCALARMAPONDEFORMEDSHAPE)
83 PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPEANDSCALARMAP)
84
85
86 #---------------------------------------------------------------
87 aMedFile = "TimeStamps.med"
88 aMedFile = "ResOK_0000.med"
89 aMedFile = os.getenv('DATA_DIR') + '/MedFiles/' + aMedFile
90 aResult = myVisu.ImportFile(aMedFile)
91
92 aMeshName ="dom"
93 anEntity = VISU.NODE
94 aFieldName = "vitesse";
95 aTimeStampNumber = 1
96
97 anInput = VISU.ColoredPrs3dHolder.BasicInput(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
98
99 aViewManager = myVisu.GetViewManager();
100
101 WalkTroughTimeStamps(VISU.TSCALARMAP, anInput, aViewManager)
102
103 for aVISUType in PRS3D_TYPE_LIST:
104   WalkTroughTimeStamps(aVISUType, anInput, aViewManager)
105   pass
106
107 anInput.myEntity = VISU.CELL;
108 anInput.myFieldName = "pression";
109 WalkTroughTimeStamps(VISU.TGAUSSPOINTS, anInput, aViewManager)
110
111 #execfile('/data/apo/a.py')