1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 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
24 # Manage view parameters of presentations:
25 # Representation Mode, Shrink, Shading, Opacity, Line Width
35 datadir = os.getenv("DATA_DIR") + "/MedFiles/"
37 myVisu = visu_gui.myVisu
38 myVisu.SetCurrentStudy(salome.myStudy)
39 myViewManager = myVisu.GetViewManager()
40 myView = myViewManager.Create3DView()
44 def AfterSet(error_string, method_name, old_value, new_value):
45 print method_name, "(): old_value = ", old_value, "new_value = ", new_value
46 if error_string == "":
47 time.sleep(sleep_delay)
49 print method_name, "() error = ", error_string
53 def ChangeRepresentation(scalarmap,repres,shrink,shading,opacity,linew):
54 if scalarmap is None : print "Error"
57 myView.DisplayOnly(scalarmap)
60 time.sleep(sleep_delay)
62 # enum PresentationType{ POINT, WIREFRAME, SHADED, INSIDEFRAME, SURFACEFRAME, SHRINK }
63 old_prs_type = myView.GetPresentationType(scalarmap)
64 if old_prs_type != repres:
65 err_str = myView.SetPresentationType(scalarmap, repres)
66 AfterSet(err_str, "SetPresentationType", old_prs_type, repres)
69 old_is_shrinked = myView.IsShrinked(scalarmap)
70 if old_is_shrinked != shrink:
71 err_str = myView.SetShrinked(scalarmap, shrink) # 1 - shrinked, 0 - not shrinked
72 AfterSet(err_str, "SetShrinked", old_is_shrinked, shrink)
75 old_is_shaded = myView.IsShaded(scalarmap)
76 if old_is_shaded != shading:
77 err_str = myView.SetShaded(scalarmap, shading) # 1 - shaded, 0 - not shaded
78 AfterSet(err_str, "SetShaded", old_is_shaded, shading)
81 old_opacity = myView.GetOpacity(scalarmap)
82 if old_opacity != opacity:
83 err_str = myView.SetOpacity(scalarmap, opacity) # double value [0, 1]
84 AfterSet(err_str, "SetOpacity", old_opacity, opacity)
87 old_linew = myView.GetLineWidth(scalarmap)
88 if old_linew != linew:
89 err_str = myView.SetLineWidth(scalarmap, linew) # double value, recommended round [1, 10]
90 AfterSet(err_str, "SetLineWidth", old_linew, linew)
98 print 'Import "ResOK_0000.med"...............',
99 medFile = datadir + "ResOK_0000.med"
101 myFieldName = 'vitesse'
103 myResult = myVisu.ImportFile(medFile)
104 if myResult is None : print "Error"
107 print "Creating Scalar Map.......",
108 scmap = myVisu.ScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
109 ChangeRepresentation(scmap, VISU.INSIDEFRAME, 1, 0, 0.3, 5)
111 print "Creating Stream Lines.......",
112 scmap = myVisu.StreamLinesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
113 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
115 print "Creating Vectors..........",
116 scmap = myVisu.VectorsOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
117 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.7, 2)
119 print "Creating Iso Surfaces.....",
120 scmap = myVisu.IsoSurfacesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
121 ChangeRepresentation(scmap, VISU.SHADED, 1, 0, 0.4, 8)
123 print "Creating Cut Planes.......",
124 scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
125 ChangeRepresentation(scmap, VISU.POINT, 0, 0, 0.6, 4)
129 print 'Import "fra.med"...............',
130 medFile = datadir + "fra.med"
131 myMeshName = 'LE VOLUME'
132 myFieldName = 'VITESSE'
134 myResult = myVisu.ImportFile(medFile)
135 if myResult is None : print "Error"
138 print "Creating Scalar Map.......",
139 scmap = myVisu.ScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
140 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
142 print "Creating Iso Surfaces.....",
143 scmap = myVisu.IsoSurfacesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
144 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
146 print "Creating Cut Planes.......",
147 scmap = myVisu.CutPlanesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
148 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)
150 print "Creating Scalar Map On Deformed Shape.......",
151 scmap = myVisu.DeformedShapeAndScalarMapOnField(myResult,myMeshName,VISU.NODE,myFieldName,1);
152 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)
154 print "Creating Deformed Shape.......",
155 scmap = myVisu.DeformedShapeOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
157 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
159 print "Creating Cut Lines.......",
160 scmap = myVisu.CutLinesOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
161 ChangeRepresentation(scmap, VISU.WIREFRAME, 1, 1, 0.5, 3)
163 print "Creating Plot 3D.......",
164 scmap = myVisu.Plot3DOnField(myResult,myMeshName,VISU.NODE,myFieldName,1)
165 ChangeRepresentation(scmap, VISU.SHADED, 1, 1, 0.5, 3)