1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Manage view parameters of presentations:
24 # Representation Mode, Shrink, Shading, Opacity, Line Width
34 datadir = os.getenv("DATA_DIR") + "/MedFiles/"
36 myVisu = visu_gui.myVisu
37 myVisu.SetCurrentStudy(salome.myStudy)
38 myViewManager = myVisu.GetViewManager()
39 myView = myViewManager.Create3DView()
43 def AfterSet(error_string, method_name, old_value, new_value):
44 print method_name, "(): old_value = ", old_value, "new_value = ", new_value
45 if error_string == "":
46 time.sleep(sleep_delay)
48 print method_name, "() error = ", error_string
52 def ChangeRepresentation(scalarmap,repres,shrink,shading,opacity,linew):
53 if scalarmap is None : print "Error"
56 myView.DisplayOnly(scalarmap)
59 time.sleep(sleep_delay)
61 # enum PresentationType{ POINT, WIREFRAME, SHADED, INSIDEFRAME, SURFACEFRAME, SHRINK }
62 old_prs_type = myView.GetPresentationType(scalarmap)
63 if old_prs_type != repres:
64 err_str = myView.SetPresentationType(scalarmap, repres)
65 AfterSet(err_str, "SetPresentationType", old_prs_type, repres)
68 old_is_shrinked = myView.IsShrinked(scalarmap)
69 if old_is_shrinked != shrink:
70 err_str = myView.SetShrinked(scalarmap, shrink) # 1 - shrinked, 0 - not shrinked
71 AfterSet(err_str, "SetShrinked", old_is_shrinked, shrink)
74 old_is_shaded = myView.IsShaded(scalarmap)
75 if old_is_shaded != shading:
76 err_str = myView.SetShaded(scalarmap, shading) # 1 - shaded, 0 - not shaded
77 AfterSet(err_str, "SetShaded", old_is_shaded, shading)
80 old_opacity = myView.GetOpacity(scalarmap)
81 if old_opacity != opacity:
82 err_str = myView.SetOpacity(scalarmap, opacity) # double value [0, 1]
83 AfterSet(err_str, "SetOpacity", old_opacity, opacity)
86 old_linew = myView.GetLineWidth(scalarmap)
87 if old_linew != linew:
88 err_str = myView.SetLineWidth(scalarmap, linew) # double value, recommended round [1, 10]
89 AfterSet(err_str, "SetLineWidth", old_linew, linew)
97 print 'Import "ResOK_0000.med"...............',
98 medFile = datadir + "ResOK_0000.med"
100 myFieldName = 'vitesse'
102 myResult = myVisu.ImportFile(medFile)
103 if myResult is None : print "Error"
106 print "Creating Scalar Map.......",
107 scmap = myVisu.ScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
108 ChangeRepresentation(scmap, VISU.INSIDEFRAME, 1, 0, 0.3, 5)
110 print "Creating Stream Lines.......",
111 scmap = myVisu.StreamLinesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
112 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
114 print "Creating Vectors..........",
115 scmap = myVisu.VectorsOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
116 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.7, 2)
118 print "Creating Iso Surfaces.....",
119 scmap = myVisu.IsoSurfacesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
120 ChangeRepresentation(scmap, VISU.SHADED, 1, 0, 0.4, 8)
122 print "Creating Cut Planes.......",
123 scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
124 ChangeRepresentation(scmap, VISU.POINT, 0, 0, 0.6, 4)
128 print 'Import "fra.med"...............',
129 medFile = datadir + "fra.med"
130 myMeshName = 'LE VOLUME'
131 myFieldName = 'VITESSE'
133 myResult = myVisu.ImportFile(medFile)
134 if myResult is None : print "Error"
137 print "Creating Scalar Map.......",
138 scmap = myVisu.ScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
139 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
141 print "Creating Iso Surfaces.....",
142 scmap = myVisu.IsoSurfacesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
143 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
145 print "Creating Cut Planes.......",
146 scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
147 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)
149 print "Creating Scalar Map On Deformed Shape.......",
150 scmap = myVisu.DeformedShapeAndScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
151 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)
153 print "Creating Deformed Shape.......",
154 scmap = myVisu.DeformedShapeOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
156 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
158 print "Creating Cut Lines.......",
159 scmap = myVisu.CutLinesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
160 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
162 print "Creating Plot 3D.......",
163 scmap = myVisu.Plot3DOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
164 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)