1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
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
21 # VISU VISU_SWIG : binding of C++ implementation and Python
22 # File : visu_view3d.py
31 medFile = os.getenv("DATA_DIR") + "/MedFiles/fra.med"
33 #%====================Stage1: Creating a study====================%
35 print "Creating a new study... "
36 myVisu.SetCurrentStudy(salome.myStudy)
38 myVisu = visu_gui.myVisu
39 myVisu.SetCurrentStudy(salome.myStudy)
40 myViewManager = myVisu.GetViewManager()
41 if myViewManager is None : print "Error"
44 myView = myViewManager.Create3DView()
46 #%====================Stage2: Import MED file====================%
48 print "Importing Med file... "
49 myResult = myVisu.ImportFile(medFile)
50 if myResult is None : print "Error"
53 print "Creating mesh... "
54 myMeshName = 'LE VOLUME'
55 myCellEntity = VISU.CELL
56 mesh = myVisu.MeshOnEntity(myResult,myMeshName,myCellEntity);
57 if mesh is None : print "Error"
62 #%====================Stage3: Changing of view parameters====================%
69 for i in range(0,100) :
71 myView.SetPointOfView(aPoint)
77 print "Zooming out...",
78 aScale = myView.GetParallelScale()
79 print "Zooming 3D view..."
80 for i in range(0,50) :
81 aScale = aScale + 0.05
82 myView.SetParallelScale(aScale)
87 print "Change Focal Point..."
88 aFocalPoint = myView.GetFocalPoint()
89 for i in range(0,61) :
91 aFocalPoint[0] = aFocalPoint[0] - 0.1;
93 aFocalPoint[0] = aFocalPoint[0] + 0.1;
94 myView.SetFocalPoint(aFocalPoint)
97 for i in range(0,61) :
99 aFocalPoint[1] = aFocalPoint[1] - 0.1;
101 aFocalPoint[1] = aFocalPoint[1] + 0.1;
102 myView.SetFocalPoint(aFocalPoint)
107 print "Change View Up..."
108 aViewUp = myView.GetViewUp();
109 for i in range(0,40) :
110 aViewUp[0] = aViewUp[0] + 0.1;
111 myView.SetViewUp(aViewUp)
116 #create second viewer
118 myView1 = myViewManager.Create3DView()
120 myView1.Display(mesh)
124 # Get properties from the First viewer and apply it to the New viewer
125 aP = myView.GetPointOfView()
126 myView1.SetPointOfView(aP)
128 aFP = myView.GetFocalPoint()
129 myView1.SetFocalPoint(aFP)
131 aVU = myView.GetViewUp()
132 myView1.SetViewUp(aVU)
134 aScale = myView.GetParallelScale()
135 myView1.SetParallelScale( aScale )
141 # Change Parameters in both viewers
144 aScale = myView.GetParallelScale()
145 for i in range(0,70) :
146 aScale = aScale - 0.08
147 myView.SetParallelScale(aScale)
149 myView1.SetParallelScale(aScale)
154 print "Rotating Y..."
155 aPoint = myView1.GetPointOfView();
156 for i in range(0,150) :
157 aPoint[1] = aPoint[1] + 1;
158 myView1.SetPointOfView(aPoint)
160 myView.SetPointOfView(aPoint)
164 print "Zooming back...",
165 for i in range(0,40) :
166 aScale = aScale + 0.08
167 myView.SetParallelScale(aScale)
169 myView1.SetParallelScale(aScale)