1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Manage view parameters of presentations:
21 # Representation Mode, Shrink, Shading, Opacity, Line Width
31 datadir = os.getenv("DATA_DIR") + "/MedFiles/"
33 myVisu = visu_gui.myVisu
34 myVisu.SetCurrentStudy(salome.myStudy)
35 myViewManager = myVisu.GetViewManager()
36 myView = myViewManager.Create3DView()
40 def AfterSet(error_string, method_name, old_value, new_value):
41 print method_name, "(): old_value = ", old_value, "new_value = ", new_value
42 if error_string == "":
43 time.sleep(sleep_delay)
45 print method_name, "() error = ", error_string
49 def ChangeRepresentation(scalarmap,repres,shrink,shading,opacity,linew):
50 if scalarmap is None : print "Error"
53 myView.DisplayOnly(scalarmap)
56 time.sleep(sleep_delay)
58 # enum PresentationType{ POINT, WIREFRAME, SHADED, INSIDEFRAME, SURFACEFRAME, SHRINK }
59 old_prs_type = myView.GetPresentationType(scalarmap)
60 if old_prs_type != repres:
61 err_str = myView.SetPresentationType(scalarmap, repres)
62 AfterSet(err_str, "SetPresentationType", old_prs_type, repres)
65 old_is_shrinked = myView.IsShrinked(scalarmap)
66 if old_is_shrinked != shrink:
67 err_str = myView.SetShrinked(scalarmap, shrink) # 1 - shrinked, 0 - not shrinked
68 AfterSet(err_str, "SetShrinked", old_is_shrinked, shrink)
71 old_is_shaded = myView.IsShaded(scalarmap)
72 if old_is_shaded != shading:
73 err_str = myView.SetShaded(scalarmap, shading) # 1 - shaded, 0 - not shaded
74 AfterSet(err_str, "SetShaded", old_is_shaded, shading)
77 old_opacity = myView.GetOpacity(scalarmap)
78 if old_opacity != opacity:
79 err_str = myView.SetOpacity(scalarmap, opacity) # double value [0, 1]
80 AfterSet(err_str, "SetOpacity", old_opacity, opacity)
83 old_linew = myView.GetLineWidth(scalarmap)
84 if old_linew != linew:
85 err_str = myView.SetLineWidth(scalarmap, linew) # double value, recommended round [1, 10]
86 AfterSet(err_str, "SetLineWidth", old_linew, linew)
94 print 'Import "ResOK_0000.med"...............',
95 medFile = datadir + "ResOK_0000.med"
97 myFieldName = 'vitesse'
99 myResult = myVisu.ImportFile(medFile)
100 if myResult is None : print "Error"
103 print "Creating Scalar Map.......",
104 scmap = myVisu.ScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
105 ChangeRepresentation(scmap, VISU.INSIDEFRAME, 1, 0, 0.3, 5)
107 print "Creating Stream Lines.......",
108 scmap = myVisu.StreamLinesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
109 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
111 print "Creating Vectors..........",
112 scmap = myVisu.VectorsOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
113 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.7, 2)
115 print "Creating Iso Surfaces.....",
116 scmap = myVisu.IsoSurfacesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
117 ChangeRepresentation(scmap, VISU.SHADED, 1, 0, 0.4, 8)
119 print "Creating Cut Planes.......",
120 scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
121 ChangeRepresentation(scmap, VISU.POINT, 0, 0, 0.6, 4)
125 print 'Import "fra.med"...............',
126 medFile = datadir + "fra.med"
127 myMeshName = 'LE VOLUME'
128 myFieldName = 'VITESSE'
130 myResult = myVisu.ImportFile(medFile)
131 if myResult is None : print "Error"
134 print "Creating Scalar Map.......",
135 scmap = myVisu.ScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
136 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
138 print "Creating Iso Surfaces.....",
139 scmap = myVisu.IsoSurfacesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
140 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
142 print "Creating Cut Planes.......",
143 scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
144 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)
146 print "Creating Scalar Map On Deformed Shape.......",
147 scmap = myVisu.ScalarMapOnDeformedShapeOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
148 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)
150 print "Creating Deformed Shape.......",
151 scmap = myVisu.DeformedShapeOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
153 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
155 print "Creating Cut Lines.......",
156 scmap = myVisu.CutLinesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
157 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
159 print "Creating Plot 3D.......",
160 scmap = myVisu.Plot3DOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
161 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)