From: mzn Date: Wed, 19 Oct 2005 14:06:28 +0000 (+0000) Subject: Movement of examples to CVS EXAMPLES SAMPLES_SRC. X-Git-Tag: ForTest2_3_1_0a2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e4559f04a3d811caf455199a54119c7ca4ff9052;p=modules%2Fvisu.git Movement of examples to CVS EXAMPLES SAMPLES_SRC. --- diff --git a/Makefile.in b/Makefile.in index ca5acded..519f470b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,7 +14,7 @@ VPATH=.:@srcdir@:@top_srcdir@/bin:@top_srcdir@/resources:./bin:@top_srcdir@/idl: @COMMENCE@ -SUBDIRS = idl src examples doc +SUBDIRS = idl src doc BIN_SCRIPT= \ VERSION diff --git a/examples/Fields_group3D.med b/examples/Fields_group3D.med deleted file mode 100644 index 95601774..00000000 Binary files a/examples/Fields_group3D.med and /dev/null differ diff --git a/examples/Makefile.in b/examples/Makefile.in deleted file mode 100644 index 52f3a639..00000000 --- a/examples/Makefile.in +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D -# -# -# -# File : Makefile.in -# Author : Vasily Rusyaev (Open Cascade NN) -# Module : examples -# $Header: - -top_srcdir=@top_srcdir@ -top_builddir=.. -srcdir=@srcdir@ -VPATH=.:@srcdir@ -curdir = $(shell pwd) -instdatadir=${prefix}/examples - -SUBDIRS=. - -@COMMENCE@ - -data: - (cd $(srcdir) ; cp -fr `ls | grep -v "Makefile.in"` $(curdir)) - -clean: - rm -rf `ls | grep -v "Makefile"` - -install: - rm -rf $(instdatadir) - mkdir $(instdatadir) - cp -rf `ls | grep -v "Makefile"` $(instdatadir) - -uninstall: - rm -rf $(instdatadir) diff --git a/examples/ResOK_0000.med b/examples/ResOK_0000.med deleted file mode 100644 index 47afde89..00000000 Binary files a/examples/ResOK_0000.med and /dev/null differ diff --git a/examples/VISU_Example_01.py b/examples/VISU_Example_01.py deleted file mode 100644 index 8de2ce6c..00000000 --- a/examples/VISU_Example_01.py +++ /dev/null @@ -1,191 +0,0 @@ -# T 2.23, 28: Displaying fields (scalar and vectorial) on nodes, change presentation options. -# Uses MED files ResOK_0000.med and Fields_group3D.med -# -# This script is equivalent to non-regression test script 003/A1 - -import salome -import visu_gui -import SALOMEDS -import VISU -import os - -datadir = os.getenv("VISU_ROOT_DIR") + "/examples/" - -#%====================Stage1: Creating a new study====================% - -print "**** Stage1: Creating a new study" - -print "Creating a new study..................", -myVisu = visu_gui.myVisu -myVisu.SetCurrentStudy(salome.myStudy) -myViewManager = myVisu.GetViewManager() -if myViewManager is None : print "Error" -else : print "OK" - -#%====================Stage2: Importing MED file====================% - -print "**** Stage2: Importing MED file" - -print 'Import "ResOK_0000.med"...............', -medFile = datadir + "ResOK_0000.med" -myResult = myVisu.ImportFile(medFile) -if myResult is None : print "Error" -else : print "OK" - -print 'Creating new View3D...................', -myView = myViewManager.Create3DView() -if myView is None : print "Error" -else : print "OK" - -myMeshName = 'dom' -myCellEntity = VISU.CELL -myNodeEntity = VISU.NODE - -#%====================Stage3: Displaying vector field====================% - -print "**** Stage3: Displaying vector field" - -print "Creating Scalar Map.......", -scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); -if scalarmap is None : print "Error" -else : print "OK" -scalarmap.SetSize(0.15, 0.8) -myView.DisplayOnly(scalarmap) -myView.FitAll() - -print "Creating Stream Lines.....", -streamlines = myVisu.StreamLinesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); -if streamlines is None : print "Error" -else : print "OK" -myView.DisplayOnly(streamlines) - -print "Creating Vectors..........", -vectors = myVisu.VectorsOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); -if vectors is None : print "Error" -else : print "OK" -myView.DisplayOnly(vectors) - - -print "Creating Iso Surfaces.....", -isosurfaces = myVisu.IsoSurfacesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); -if isosurfaces is None : print "Error" -else : print "OK" -myView.DisplayOnly(isosurfaces) - -print "Creating Cut Planes.......", -cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); -if cutplanes is None : print "Error" -else : print "OK" -cutplanes.SetNbPlanes(30) -cutplanes.SetOrientation(VISU.CutPlanes.YZ, 0, 0) -myView.DisplayOnly(cutplanes) - -#%====================Stage4: Opening a new study and Med file import====================% - -print "**** Stage4: Opening a new study and Med file import" - -print "Creating a new study..................", -newStudy = salome.myStudyManager.NewStudy('newStudy') -myVisu.SetCurrentStudy(newStudy) -myViewManager = myVisu.GetViewManager() -myView = myViewManager.Create3DView() -if myView is None : print "Error" -else : print "OK" - -print 'Importing "Fields_group3D.med"........', -medFile = datadir + "Fields_group3D.med" -myResult1 = myVisu.ImportFile(medFile) -if myResult1 is None : print "Error" -myView1 = myViewManager.Create3DView() -if myView1 is None : print "Error" -else : print "OK" - -#%====================Stage5: Displaying scalar field====================% - -print "**** Stage5: Displaying scalar field" - -myMeshName1 = 'mailles_MED' - -print "Creating Scalar Map.......", -scalarmap1 = myVisu.ScalarMapOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1); -if scalarmap1 is None : print "Error" -else : print "OK" -myView1.DisplayOnly(scalarmap1) -myView1.FitAll() - -print "Creating Iso Surfaces.....", -isosurfaces1 = myVisu.IsoSurfacesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1); -if isosurfaces1 is None : print "Error" -else : print "OK" -myView1.DisplayOnly(isosurfaces1) - -print "Creating Cut Planes.......", -cutplanes1 = myVisu.CutPlanesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1); -if cutplanes1 is None : print "Error" -else : print "OK" -cutplanes1.SetOrientation(VISU.CutPlanes.YZ, 0, 0) -myView1.DisplayOnly(cutplanes1) - -#%====================Stage6: Object browser popup====================% - -print "**** Stage6: Object browser popup" - -print "Creating mesh.............", -mesh = myVisu.MeshOnEntity(myResult1,myMeshName1,myCellEntity); -if mesh is None : print "Error" -else : print "OK" -myView1.DisplayOnly(mesh) - - -print "Changing type of presentation of mesh:" -mesh.SetPresentationType(VISU.WIREFRAME) -PrsType = mesh.GetPresentationType() -print "Presentation type..", PrsType -myView1.DisplayOnly(mesh) - -mesh.SetPresentationType(VISU.SHADED) -PrsType = mesh.GetPresentationType() -print "Presentation type.....", PrsType -myView1.DisplayOnly(mesh) - -mesh.SetPresentationType(VISU.POINT) -PrsType = mesh.GetPresentationType() -print "Presentation type......", PrsType -myView1.DisplayOnly(mesh) -myView1.Update() - -mesh.SetPresentationType(VISU.SHRINK) -PrsType = mesh.GetPresentationType() -print "Presentation type.....", PrsType -myView1.DisplayOnly(mesh) - -print "Changing color of mesh....", -aColor = SALOMEDS.Color(0,0,1) -mesh.SetCellColor(aColor) -myView1.DisplayOnly(mesh) -print "OK" - -print "Renaming ScalarMap........", -SObj = newStudy.FindObjectIOR(scalarmap1.GetID()) -newName = 'Renamed Object' -SObj.Name = newName -print "OK" - -print "Deleting Cut Planes.......", -SObj = newStudy.FindObjectIOR(cutplanes1.GetID()) -myBuilder = newStudy.NewBuilder() -myBuilder.RemoveObject(SObj) -print "OK" - -print "Changing first IsoSurfaces", -myVisu.SetCurrentStudy(salome.myStudy) -myView.DisplayOnly(isosurfaces) -isosurfaces.SetNbSurfaces(25) -print "OK" - -myView.Maximize() -myView.DisplayOnly(isosurfaces) - -print "Hide IsoSurfaces..........", -myView.Erase(isosurfaces) -print "OK" diff --git a/examples/VISU_Example_02.py b/examples/VISU_Example_02.py deleted file mode 100644 index a7f6ea3b..00000000 --- a/examples/VISU_Example_02.py +++ /dev/null @@ -1,348 +0,0 @@ -# T 2.24: Save/retrieve view parameters. -# Uses MED file fra.med from ${KERNEL_ROOT_DIR}/examples directory. -# -# This script is equivalent to non-regression test script 003/A3 - -import salome -import visu_gui -import SALOMEDS -import VISU -import os - -medFile = os.getenv("KERNEL_ROOT_DIR") + "/examples/fra.med" - -#%====================Stage1: Creating a new study====================% - -print "**** Stage1: Creating a new study " - -print "Creating a new study..................", -myVisu = visu_gui.myVisu -myVisu.SetCurrentStudy(salome.myStudy) -myViewManager = myVisu.GetViewManager() -if myViewManager is None : print "Error" -else : print "OK" - -#%====================Stage2: Saving view parameters before import====================% - -print "**** Stage2: Saving view parameters before import " - -myView = myViewManager.Create3DView() - -print "Zooming trihedron.....................", -aScale = myView.GetParallelScale() -myView.SetParallelScale(aScale*4) -print "OK" - -print "Rotating trihedron....................", -aPoint = (100,100,100) -myView.SetPointOfView(aPoint) -print "OK" - -print "Saving view parameters................", -aViewParamsName1 = 'ViewParams:1' -aSaveRes = myView.SaveViewParams(aViewParamsName1) -if aSaveRes != 1 : print "Error" -else : print "OK" - -#%====================Stage3: Import MED file====================% - -print "**** Stage3: Import MED file" - -print 'Importing "fra.med"...................', -myResult = myVisu.ImportFile(medFile) -if myResult is None : print "Error" -else : print "OK" - -print "Creating mesh.........................", -myMeshName = 'LE VOLUME' -myCellEntity = VISU.CELL -mesh = myVisu.MeshOnEntity(myResult,myMeshName,myCellEntity); -if mesh is None : print "Error" -else : print "OK" - -myView.Maximize() -myView.Display(mesh) -myView.FitAll() - -#%====================Stage4: Saving view parameters after import====================% - -print "**** Stage4: Saving view parameters after import" - -print "Creating Scalar Map...................", -myFieldName = 'TAUX_DE_VIDE' -myNodeEntity = VISU.NODE -scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,myFieldName,1); -if scalarmap is None : print "Error" -else : print "OK" -myView.DisplayOnly(scalarmap) - -print "Zooming 3D view.......................", -aScale = myView.GetParallelScale() -myView.SetParallelScale(aScale*2) -print "OK" - -print "Setting view point(LEFT)..............", -myView.SetView((VISU.View3D.LEFT)) -print "OK" - -print "Saving view parameters................", -aViewParamsName2 = 'ViewParams:2' -aSaveRes = myView.SaveViewParams(aViewParamsName2) -if aSaveRes != 1 : print "Error" -else : print "OK" - -print "Creating Cut Planes...................", -cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,myFieldName,1); -if cutplanes is None : print "Error" -else : print "OK" -cutplanes.SetNbPlanes(4) -myView.DisplayOnly(cutplanes) - -print "Setting scaling.......................", - -#Define parameters of scaling: -myXParam = 5 -myYParam = 5 -myZParam = 1 - -myXAxis = VISU.View3D.XAxis -myYAxis = VISU.View3D.YAxis -myZAxis = VISU.View3D.ZAxis - -myView.ScaleView(myXAxis,myXParam) -myView.ScaleView(myYAxis,myYParam) -myView.ScaleView(myZAxis,myZParam) -print "OK" - -print "Rotating 3d view......................", -aPoint = (100,40,0) -myView.SetPointOfView(aPoint) -print "OK" - -print "Fit All...............................", -myView.FitAll() -print "OK" - -print "Saving view parameters................", -aViewParamsName3 = 'ViewParams:3' -aSaveRes = myView.SaveViewParams(aViewParamsName3) -if aSaveRes != 1 : print "Error" -else : print "OK" - -#%====================Stage5: Restoring view parameters====================% - -print "**** Stage5: Restoring view parameters" - -print "Restoring first view parameters.......", -aRestoreRes = myView.RestoreViewParams(aViewParamsName1) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Restoring second view parameters......", -aRestoreRes = myView.RestoreViewParams(aViewParamsName2) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Displaing only Scalar Map.............", -myView.DisplayOnly(scalarmap) -print "OK" - -print "Displaing only Cut Planes.............", -myView.DisplayOnly(cutplanes) -print "OK" - -print "Restoring third view parameters.......", -aRestoreRes = myView.RestoreViewParams(aViewParamsName3) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Displaing only Mesh...................", -myView.DisplayOnly(mesh) -print "OK" - -print "Displaing only Scalar Map.............", -myView.DisplayOnly(scalarmap) -print "OK" - -print "Displaing only Cut Planes.............", -myView.DisplayOnly(cutplanes) -print "OK" - -#%====================Stage6: Changing of view parameters====================% - -print "**** Stage6: Changing of view parameters" - -print "Remove scaling........................", -myView.RemoveScale() -print "OK" - -print "Fit All...............................", -myView.FitAll() -print "OK" - -print "Rotating 3d view......................", -aPoint = (0,60,150) -myView.SetPointOfView(aPoint) -print "OK" - -print "Resaving first view parameters........", -aSaveRes = myView.SaveViewParams(aViewParamsName1) -if aSaveRes != 1 : print "Error" -else : print "OK" - -print "Restoring third view parameters.......", -aRestoreRes = myView.RestoreViewParams(aViewParamsName3) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Restoring first view parameters.......", -aRestoreRes = myView.RestoreViewParams(aViewParamsName1) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Displaying only Mesh..................", -myView.DisplayOnly(mesh) -print "OK" - -print "Displaying only Scalar Map............", -myView.DisplayOnly(scalarmap) -print "OK" - -#%====================Stage7: Saving of created view parameters====================% - -print "**** Stage7: Saving of created view parameters" - -print "Saving study..........................", - -str = os.getenv("TmpDir") -if str == None: - str = "/tmp" - -file = str+'/VISU_005.hdf' - -salome.myStudyManager.SaveAs(file, salome.myStudy, 0) -study_id = salome.myStudy._get_StudyId() -#salome.sg.CloseStudy(study_id) -#salome.myStudyManager.Close(salome.myStudy) -#salome.myStudy.Close() -print "OK" - -print "Opening just saved study..............", - -openedStudy = salome.myStudyManager.Open(file) -myVisu.SetCurrentStudy(openedStudy) -myViewManager = myVisu.GetViewManager() -myView1 = myViewManager.Create3DView() -if myView1 is None : print "Error" -else : print "OK" - -print "Restoring first view parameters.......", -aRestoreRes = myView1.RestoreViewParams(aViewParamsName1) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -Builder = openedStudy.NewBuilder() -SCom = openedStudy.FindComponent("VISU") -Builder.LoadWith(SCom ,myVisu) - -print "Displaying Scalar Map.................", -SObj = openedStudy.FindObject('ScalarMap') -scalarmap1 = visu_gui.visu.SObjectToObject(SObj) -if scalarmap1 is None : print "Error" -else : print "OK" -myView1.DisplayOnly(scalarmap1) - -print "Displaying Cut Planes.................", -SObj = openedStudy.FindObject('CutPlanes') -cutplanes1 = visu_gui.visu.SObjectToObject(SObj) -if cutplanes1 is None : print "Error" -else : print "OK" -myView1.DisplayOnly(cutplanes1) - -print "Restoring second view parameters......", -aRestoreRes = myView1.RestoreViewParams(aViewParamsName2) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Displaying Scalar Map.................", -myView1.DisplayOnly(scalarmap1) -print "OK" - -print "Restoring third view parameters.......", -aRestoreRes = myView1.RestoreViewParams(aViewParamsName3) -if aRestoreRes != 1 : print "Error" -else : print "OK" - -print "Displaying Cut Planes.................", -myView1.DisplayOnly(cutplanes1) -print "OK" - -#%====================Stage8: Changing of saved session====================% - -print "**** Stage8: Changing of saved session" - -print "Deleting ViewParams:3,1,2.............", -SObj = openedStudy.FindObject(aViewParamsName3) -Builder.RemoveObject(SObj) -SObj = openedStudy.FindObject(aViewParamsName1) -Builder.RemoveObject(SObj) -SObj = openedStudy.FindObject(aViewParamsName2) -Builder.RemoveObject(SObj) -print "OK" - -SObjList2 = openedStudy.FindObjectByName(aViewParamsName1, "VISU") -print "FindObjectByName(aViewParamsName1, VISU) returned ", len(SObjList2), " objects" - -print "Zooming trihedron.....................", -aScale = myView.GetParallelScale() -myView1.SetParallelScale(aScale*2) -myView1.Update() -print "OK" - -print "Rotating trihedron....................", -aPoint = (200,40,-40) -myView1.SetPointOfView(aPoint) -print "OK" - -print "Saving view parameters................", -aSaveRes = myView1.SaveViewParams(aViewParamsName1) -if aSaveRes != 1 : print "Error" -else : print "OK" - -print "Renaming ViewParams:1.................", -SObj = openedStudy.FindObject(aViewParamsName1) -SObj.Name = "New_view" -print "OK" - -print "Setting scaling.......................", -#Define parameters of scaling: -myXParam = 4 -myYParam = 4 -myZParam = 8 - -myXAxis = VISU.View3D.XAxis -myYAxis = VISU.View3D.YAxis -myZAxis = VISU.View3D.ZAxis - -myView1.ScaleView(myXAxis,myXParam) -myView1.ScaleView(myYAxis,myYParam) -myView1.ScaleView(myZAxis,myZParam) -print "OK" - -myView1.FitAll() - -print "Saving view parameters................", -aSaveRes = myView1.SaveViewParams(aViewParamsName2) -if aSaveRes != 1 : print "Error" -else : print "OK" - -print "Restoring first view parameters.......", -aRestoreRes = myView1.RestoreViewParams(aViewParamsName1) -if aSaveRes != 1 : print "Error" -else : print "OK" - -print "Restoring second view parameters......", -aRestoreRes = myView1.RestoreViewParams(aViewParamsName2) -if aRestoreRes != 1 : print "Error" -else : print "OK" - diff --git a/examples/VISU_Example_03.py b/examples/VISU_Example_03.py deleted file mode 100644 index c64de44b..00000000 --- a/examples/VISU_Example_03.py +++ /dev/null @@ -1,60 +0,0 @@ -# Animation of "vitesse" field, stored in file TimeStamps.med -# -# This script is equivalent to non-regression test script 003/A5 - -import salome -import visu_gui -import SALOMEDS -import VISU -import os -import time - -medFile = os.getenv("KERNEL_ROOT_DIR") + "/examples/TimeStamps.med" - -print 'Importing "TimeStamps.med"................', -myVisu = visu_gui.myVisu -myResult = myVisu.ImportFile(medFile) -if myResult is None : print "Error" -else : print "OK" - -print "Creating Cut Lines........................", -medMesh = 'dom' -medField = "vitesse" -aCutLines = myVisu.CutLinesOnField(myResult,'dom',VISU.NODE,medField,1.0) -aCutLines.SetOrientation(VISU.CutPlanes.XY, 0, 0) -aCutLines.SetOrientation2(VISU.CutPlanes.ZX, 0, 0) -aCutLines.SetNbLines(20) -if aCutLines is None : print "Error" -else : print "OK" - -print "Creating a Viewer.........................", -myViewManager = myVisu.GetViewManager(); -myView = myViewManager.Create3DView(); -if myView is None : print "Error" -else : print "OK" -myView.Display(aCutLines); -myView.FitAll(); - -aCutLinesSObj = salome.myStudy.FindObjectIOR(aCutLines.GetID()) -aFather = aCutLinesSObj.GetFather().GetFather(); - -print "Creating an Animation.....................", -myAnim = myVisu.CreateAnimation(myView); -if myAnim is None : print "Error" -else : print "OK" - -print "Animation.................................", -myAnim.addField(aFather); -myAnim.generatePresentations(0); -myAnim.generateFrames(); -myAnim.setSpeed(33) -myAnim.startAnimation(); - -myView.FitAll() -while 1: - time.sleep(1) - if not myAnim.isRunning(): - myAnim.stopAnimation() - break - -print "OK" diff --git a/examples/VISU_Example_04.py b/examples/VISU_Example_04.py deleted file mode 100644 index 71e40845..00000000 --- a/examples/VISU_Example_04.py +++ /dev/null @@ -1,255 +0,0 @@ -# Show some results presentations in different 3D and 2D viewers -# with different options (view parameters and display modes). -# Uses MED files fra.med and TimeStamps.med from ${KERNEL_ROOT_DIR}/examples directory. -# -# Pay attention to a viewer title to know its purpose. -# -# This script is equivalent to script VISU_SWIG/visu_view3d.py - -import os -import time -import math -import VISU -import SALOMEDS -from visu_gui import * - -aDelay = 1 - -myViewManager = myVisu.GetViewManager(); - -myView = myViewManager.Create3DView(); -myView.SetTitle("The window will be soon destroyed!") -print "myViewManager.Create3DView()" -time.sleep(aDelay) - -myView.Maximize() -print "myView.Maximize()" -time.sleep(aDelay) - -myView.Restore() -print "myView.Restore()" -time.sleep(aDelay) - -myView.Minimize() -print "myView.Minimize()" -time.sleep(aDelay) - -myViewManager.Destroy(myView) -print "myViewManager.Destroy(myView)" -time.sleep(aDelay) - - -medFile = "fra.med" -myFieldName = "VITESSE"; - -aMeshName ="LE VOLUME" -anEntity = VISU.NODE -aTimeStampId = 1 - -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile -myResult = myVisu.ImportFile(medFile) - -myView = myViewManager.Create3DView(); - -print "myView.SetBackground(...)" -aColor = SALOMEDS.Color(0.0,0.3,1.0) -myView.SetBackground(aColor); - -myView.SetTitle("The viewer will display ScalarMap") -print "myViewManager.Create3DView()" - -aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) - -myView.Display(aScalarMap); -print "myView.Display(aScalarMap)" -myView.SetFocalPoint([0,0,0]); -print "myView.SetFocalPoint(...)" -myView.SetParallelScale(2); -print "myView.SetParallelScale(...)" -myView.FitAll(); - -aMax = aScalarMap.GetMax() -aMin = aScalarMap.GetMin() -aDelta = (aMax - aMin)/2.0 -aNbColors = aScalarMap.GetNbColors() -aNbColors = 64 -for i in range(2,aNbColors) : - aScalarMap.SetNbColors(i) - aX = aMin + aDelta*i/aNbColors - aY = aMax - aDelta*i/aNbColors - aScalarMap.SetRange(aX,aY) - myView.Update(); - time.sleep(aDelay) - -aScalarMap.SetRange(aMin,aMax) - -print "myView.Update()" -myView.Update(); -print "myView.FitAll()" -myView.FitAll(); - - -myView = myViewManager.Create3DView(); -myView.SetTitle("Here we will display CutPlanes") - -print "myView.SetBackground(...)" -aColor = SALOMEDS.Color(0.0,0.7,0.0) -myView.SetBackground(aColor); - -aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) -print "myVisu.CutPlanesOnField(...)" - -myView.DisplayOnly(aCutPlanes); -print "myView.DisplayOnly(aCutPlanes)" - -aPoint = myView.GetPointOfView(); -aPoint[0] = aPoint[0] + 10; -myView.SetPointOfView(aPoint); -print "myView.SetPointOfView(...)" -myView.ScaleView(VISU.View3D.YAxis,10.0); -myView.ScaleView(VISU.View3D.XAxis,3.0); -print "myView.ScaleView(...)" -time.sleep(aDelay) - -myView.FitAll(); - -aNbPlanes = aCutPlanes.GetNbPlanes() -aNbPlanes = 30 -aXAngle = aCutPlanes.GetRotateX() -aYAngle = aCutPlanes.GetRotateY() -anOrientation = aCutPlanes.GetOrientationType() -for i in range(aNbPlanes,1,-1) : - aCutPlanes.SetNbPlanes(i) - aX = math.pi/2.0*(aNbPlanes-i)/aNbPlanes - aY = math.pi/2.0*(aNbPlanes-i)/aNbPlanes - aCutPlanes.SetOrientation(anOrientation,aX,aY) - myView.Update(); - time.sleep(aDelay) - -aNbPlanes = 10 -aCutPlanes.SetOrientation(VISU.CutPlanes.ZX,0,0) -for i in range(1,aNbPlanes) : - aCutPlanes.SetNbPlanes(i) - myView.Update(); - time.sleep(aDelay) - -myView.SaveViewParams('AAA') -print "myView.SaveViewParams('AAA')" -time.sleep(aDelay) - -aCutPlanes.SetOrientation(VISU.CutPlanes.XY,0,0) -myView.RemoveScale(); - -print "myView.Update()" -myView.Update(); -print "myView.FitAll()" -myView.FitAll(); - - -myView = myViewManager.Create3DView(); -print "myViewManager.Create3DView()" - -myView.SetTitle("IsoSurface's viewer") - -print "myView.SetBackground(...)" -aColor = SALOMEDS.Color(1.0,0.7,0.0) -myView.SetBackground(aColor); -time.sleep(aDelay) - -aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) - -myView.DisplayOnly(aIsoSurfaces); -myView.FitAll(); -print "myView.DisplayOnly(aCutPlanes)" -time.sleep(aDelay) - -aNbSurfaces = aIsoSurfaces.GetNbSurfaces() -aNbSurfaces = 32 -for i in range(2,aNbSurfaces) : - aIsoSurfaces.SetNbSurfaces(i) - myView.Update(); - time.sleep(aDelay) - -aIsoSurfaces.SetNbSurfaces(10) - -print "myView.Update()" -myView.Update(); -print "myView.FitAll()" -myView.FitAll(); - - -myView = myViewManager.Create3DView(); -myView.SetTitle("The viewer for CutLines") -print "myViewManager.Create3DView()" -time.sleep(aDelay) - -print "myView.SetBackground(...)" -aColor = SALOMEDS.Color(0.7,0.7,0.7) -myView.SetBackground(aColor); -time.sleep(aDelay) - -aCutLines = myVisu.CutLinesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) -aCutLines.SetOrientation(VISU.CutPlanes.ZX,0,0) -aCutLines.SetOrientation2(VISU.CutPlanes.YZ,0,0) - -myView.DisplayOnly(aCutLines); -myView.FitAll(); -print "myView.DisplayOnly(aCutLines)" -time.sleep(aDelay) - -aSObj = myStudy.FindObjectIOR(aCutLines.GetID()) -aTable = myVisu.CreateTable( aSObj.GetID() ) -print "myVisu.CreateTable(...)" - -aTableView = myViewManager.CreateTableView(aTable) -aTableView.SetTitle('Changed Title') - -aContainer = myVisu.CreateContainer() -print "myVisu.CreateContainer(...)" - -aNbCurve = aTable.GetNbRows() - 1 -for i in range(2,aNbCurve): - aCurve = myVisu.CreateCurve( aTable, 1, i ) - print i, aCurve - aContainer.AddCurve(aCurve) - - -myView = myViewManager.CreateXYPlot(); -myView.SetTitle("The viewer for Curves from CutLines") -print "myViewManager.CreateXYPlot()" -time.sleep(aDelay) - -myView.Display(aContainer) - - -myView = myViewManager.Create3DView(); -myView.SetTitle("The viewer for Animation") -print "myViewManager.Create3DView()" -time.sleep(aDelay) - -medFile = "TimeStamps.med" -myFieldName = "vitesse"; - -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile -myResult = myVisu.ImportFile(medFile) - -anAnim = myVisu.CreateAnimation(myView); -aSObj = myStudy.FindObjectIOR(myResult.GetID()) -aSObj = aSObj.FindSubObject(1)[1] -aSObj = aSObj.FindSubObject(2)[1] -aSObj = aSObj.FindSubObject(2)[1] -anAnim.addField(aSObj) -anAnim.setPresentationType(0,VISU.TISOSURFACE) -print "Generate presentations" -anAnim.generatePresentations(0) -print "Generate frames" -anAnim.generateFrames() -print "Start Animation" -anAnim.setSpeed(99) -anAnim.startAnimation() -myView.FitAll() -while 1: - time.sleep(1+aDelay) - if not anAnim.isRunning(): - anAnim.stopAnimation() - break diff --git a/examples/VISU_Example_05.py b/examples/VISU_Example_05.py deleted file mode 100644 index a70943e4..00000000 --- a/examples/VISU_Example_05.py +++ /dev/null @@ -1,77 +0,0 @@ -# Create a table and show it in Plot2d viewer -# -# This script is equivalent to script VISU_SWIG/visu_big_table.py - -import salome -import math -import SALOMEDS -import VISU -#from visu_gui import * - -# >>> Getting study builder ================================================== -myStudy = salome.myStudy -myBuilder = myStudy.NewBuilder() - -# >>> Getting (loading) VISU component ======================================= -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") -myComponent = myStudy.FindComponent("VISU") -myVisu.SetCurrentStudy(myStudy) -if not myComponent: - myComponent = myBuilder.NewComponent("VISU") - aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") - aName.SetValue( salome.sg.getComponentUserName("VISU") ) - - A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap"); - aPixmap = A2._narrow(SALOMEDS.AttributePixMap); - aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); - - myBuilder.DefineComponentInstance(myComponent,myVisu) - -# >>> Creating object with Table of real[ 200 * 20 ] ========================= -myTRealObject = myBuilder.NewObject(myComponent) -AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") -AName.SetValue("Table Of Real") -ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") -myHorNb = 10 -myVerNb = 200 - -k={} -for j in range(0,myHorNb): - k[j] = j*10+1 -ARealTable.AddRow(k.values()) -ARealTable.SetRowTitle(1, "Frequency") -ARealTable.SetRowUnit(1, "Hz") - -for i in range(1,myVerNb+1): - for j in range(0,myHorNb): - if j % 2 == 1: - k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 - else: - k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 - ARealTable.AddRow(k.values()) - ARealTable.SetRowTitle(i+1, "Power " + str(i)) - ARealTable.SetRowUnit(i+1, "Wt") - -ARealTable.SetTitle("Very useful data") - -# >>> Create Visu table ====================================================== -myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() ) - -# >>> Create container and insert curves -myContainer = myVisu.CreateContainer() - -# >>> Create curves ========================================================== -for i in range(1,myVerNb+1): - myCurve = myVisu.CreateCurve( myVisuTableReal, 1, i+1 ) - myContainer.AddCurve(myCurve) - -# >>> Updating Object Browser ================================================ -salome.sg.updateObjBrowser(1) - -# >>> Display curves in Plot2d viewer ======================================== -myViewManager = myVisu.GetViewManager(); -myView = myViewManager.CreateXYPlot(); -myView.SetTitle("The viewer for Curves from the Table") -myView.Display(myContainer) - -# ============================================================================ diff --git a/examples/VISU_Example_06.py b/examples/VISU_Example_06.py deleted file mode 100644 index a4eee6cc..00000000 --- a/examples/VISU_Example_06.py +++ /dev/null @@ -1,61 +0,0 @@ -# Import a table from file and show it in Plot2d viewer - -import salome -import math -import SALOMEDS -import VISU -#from visu_gui import * - -# >>> Getting study builder ================================================== -myStudy = salome.myStudy -myBuilder = myStudy.NewBuilder() - -# >>> Getting (loading) VISU component ======================================= -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") -myComponent = myStudy.FindComponent("VISU") -myVisu.SetCurrentStudy(myStudy) -if not myComponent: - myComponent = myBuilder.NewComponent("VISU") - aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") - #aName.SetValue("Visu") - aName.SetValue( salome.sg.getComponentUserName("VISU") ) - - A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap"); - aPixmap = A2._narrow(SALOMEDS.AttributePixMap); - aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); - - myBuilder.DefineComponentInstance(myComponent,myVisu) - -# >>> Import a tables from a file ============================================ -aFileName = os.getenv("VISU_ROOT_DIR") + "/examples/tables_test.xls" -sobj = myVisu.ImportTables(aFileName) - -# >>> Create container and insert curves ===================================== -myContainer = myVisu.CreateContainer() - -chiter = myStudy.NewChildIterator(sobj) -while chiter.More(): - sobj_table = chiter.Value() - - # >>> Create Visu table ==================================================== - myVisuTableReal = myVisu.CreateTable(sobj_table.GetID()) - - nbRows = myVisuTableReal.GetNbRows() - - # >>> Create curves ======================================================== - for i in range(1, nbRows): - myCurve = myVisu.CreateCurve(myVisuTableReal, 1, i+1) - myContainer.AddCurve(myCurve) - - chiter.Next() - -# >>> Updating Object Browser ================================================ -salome.sg.updateObjBrowser(1) - -# >>> Display curves in Plot2d viewer ======================================== -myViewManager = myVisu.GetViewManager(); -myView = myViewManager.CreateXYPlot(); -myView.SetTitle("The viewer for Curves from the Table") -myView.Display(myContainer) - -# ============================================================================ diff --git a/examples/tables_test.xls b/examples/tables_test.xls deleted file mode 100644 index 4fedc011..00000000 --- a/examples/tables_test.xls +++ /dev/null @@ -1,115 +0,0 @@ -0 1 -1 2 -2 2.5 - -#TITLE: Table toto 1 -#COLUMN_TITLES: toto 1 | titi2 | subtitle 2.3 -#COLUMN_UNITS: s kg/m3 m -# It's a comment ... -0 4.3 -3 #TITLE: row title 1 -1 5 6 #TITLE: row title 2 -# Another comment -2 -7 4.5 #TITLE: row title 3 - -#TITLE: sinus -0.0 0.0 -0.01 0.125333233564 -0.02 0.248689887165 -0.03 0.368124552685 -0.04 0.481753674102 -0.05 0.587785252292 -0.06 0.684547105929 -0.07 0.770513242776 -0.08 0.844327925502 -0.09 0.904827052466 -0.1 0.951056516295 -0.11 0.982287250729 -0.12 0.998026728428 -0.13 0.998026728428 -0.14 0.982287250729 -0.15 0.951056516295 -0.16 0.904827052466 -0.17 0.844327925502 -0.18 0.770513242776 -0.19 0.684547105929 -0.2 0.587785252292 -0.21 0.481753674102 -0.22 0.368124552685 -0.23 0.248689887165 -0.24 0.125333233564 -0.25 1.22460635382e-16 -0.26 -0.125333233564 -0.27 -0.248689887165 -0.28 -0.368124552685 -0.29 -0.481753674102 -0.3 -0.587785252292 -0.31 -0.684547105929 -0.32 -0.770513242776 -0.33 -0.844327925502 -0.34 -0.904827052466 -0.35 -0.951056516295 -0.36 -0.982287250729 -0.37 -0.998026728428 -0.38 -0.998026728428 -0.39 -0.982287250729 -0.4 -0.951056516295 -0.41 -0.904827052466 -0.42 -0.844327925502 -0.43 -0.770513242776 -0.44 -0.684547105929 -0.45 -0.587785252292 -0.46 -0.481753674102 -0.47 -0.368124552685 -0.48 -0.248689887165 -0.49 -0.125333233564 -0.5 -2.44921270764e-16 -0.51 0.125333233564 -0.52 0.248689887165 -0.53 0.368124552685 -0.54 0.481753674102 -0.55 0.587785252292 -0.56 0.684547105929 -0.57 0.770513242776 -0.58 0.844327925502 -0.59 0.904827052466 -0.6 0.951056516295 -0.61 0.982287250729 -0.62 0.998026728428 -0.63 0.998026728428 -0.64 0.982287250729 -0.65 0.951056516295 -0.66 0.904827052466 -0.67 0.844327925502 -0.68 0.770513242776 -0.69 0.684547105929 -0.7 0.587785252292 -0.71 0.481753674102 -0.72 0.368124552685 -0.73 0.248689887165 -0.74 0.125333233564 -0.75 3.67381906147e-16 -0.76 -0.125333233564 -0.77 -0.248689887165 -0.78 -0.368124552685 -0.79 -0.481753674102 -0.8 -0.587785252292 -0.81 -0.684547105929 -0.82 -0.770513242776 -0.83 -0.844327925502 -0.84 -0.904827052466 -0.85 -0.951056516295 -0.86 -0.982287250729 -0.87 -0.998026728428 -0.88 -0.998026728428 -0.89 -0.982287250729 -0.9 -0.951056516295 -0.91 -0.904827052466 -0.92 -0.844327925502 -0.93 -0.770513242776 -0.94 -0.684547105929 -0.95 -0.587785252292 -0.96 -0.481753674102 -0.97 -0.368124552685 -0.98 -0.248689887165 -0.99 -0.125333233564 -1.0 -4.89842541529e-16 diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in index 9c9f3dd3..30d837a1 100644 --- a/src/VISU_SWIG/Makefile.in +++ b/src/VISU_SWIG/Makefile.in @@ -44,7 +44,8 @@ SWIG_DEF = libVISU_Swig.i EXPORT_PYSCRIPTS = libVISU_Swig.py batchmode_visu.py batchmode_visu_table.py batchmode_visu_view3d.py \ visu_med.py visu_view3d.py visu.py visu_gui.py visu_prs_example.py \ visu_table.py visu_big_table.py visu_view.py visu_delete.py \ - visu_swig_test.py test_events.py batch_test_events.py visu_split_views.py + visu_swig_test.py test_events.py batch_test_events.py visu_split_views.py \ + VISU_Example_01.py VISU_Example_02.py VISU_Example_03.py VISU_Example_04.py VISU_Example_05.py VISU_Example_06.py EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py LIB_CLIENT_IDL = diff --git a/src/VISU_SWIG/VISU_Example_01.py b/src/VISU_SWIG/VISU_Example_01.py new file mode 100644 index 00000000..82228544 --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_01.py @@ -0,0 +1,191 @@ +# T 2.23, 28: Displaying fields (scalar and vectorial) on nodes, change presentation options. +# Uses MED files ResOK_0000.med and Fields_group3D.med +# +# This script is equivalent to non-regression test script 003/A1 + +import salome +import visu_gui +import SALOMEDS +import VISU +import os + +datadir = os.getenv("DATA_DIR") + "/MedFiles/" + +#%====================Stage1: Creating a new study====================% + +print "**** Stage1: Creating a new study" + +print "Creating a new study..................", +myVisu = visu_gui.myVisu +myVisu.SetCurrentStudy(salome.myStudy) +myViewManager = myVisu.GetViewManager() +if myViewManager is None : print "Error" +else : print "OK" + +#%====================Stage2: Importing MED file====================% + +print "**** Stage2: Importing MED file" + +print 'Import "ResOK_0000.med"...............', +medFile = datadir + "ResOK_0000.med" +myResult = myVisu.ImportFile(medFile) +if myResult is None : print "Error" +else : print "OK" + +print 'Creating new View3D...................', +myView = myViewManager.Create3DView() +if myView is None : print "Error" +else : print "OK" + +myMeshName = 'dom' +myCellEntity = VISU.CELL +myNodeEntity = VISU.NODE + +#%====================Stage3: Displaying vector field====================% + +print "**** Stage3: Displaying vector field" + +print "Creating Scalar Map.......", +scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); +if scalarmap is None : print "Error" +else : print "OK" +scalarmap.SetSize(0.15, 0.8) +myView.DisplayOnly(scalarmap) +myView.FitAll() + +print "Creating Stream Lines.....", +streamlines = myVisu.StreamLinesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); +if streamlines is None : print "Error" +else : print "OK" +myView.DisplayOnly(streamlines) + +print "Creating Vectors..........", +vectors = myVisu.VectorsOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); +if vectors is None : print "Error" +else : print "OK" +myView.DisplayOnly(vectors) + + +print "Creating Iso Surfaces.....", +isosurfaces = myVisu.IsoSurfacesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); +if isosurfaces is None : print "Error" +else : print "OK" +myView.DisplayOnly(isosurfaces) + +print "Creating Cut Planes.......", +cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1); +if cutplanes is None : print "Error" +else : print "OK" +cutplanes.SetNbPlanes(30) +cutplanes.SetOrientation(VISU.CutPlanes.YZ, 0, 0) +myView.DisplayOnly(cutplanes) + +#%====================Stage4: Opening a new study and Med file import====================% + +print "**** Stage4: Opening a new study and Med file import" + +print "Creating a new study..................", +newStudy = salome.myStudyManager.NewStudy('newStudy') +myVisu.SetCurrentStudy(newStudy) +myViewManager = myVisu.GetViewManager() +myView = myViewManager.Create3DView() +if myView is None : print "Error" +else : print "OK" + +print 'Importing "Fields_group3D.med"........', +medFile = datadir + "Fields_group3D.med" +myResult1 = myVisu.ImportFile(medFile) +if myResult1 is None : print "Error" +myView1 = myViewManager.Create3DView() +if myView1 is None : print "Error" +else : print "OK" + +#%====================Stage5: Displaying scalar field====================% + +print "**** Stage5: Displaying scalar field" + +myMeshName1 = 'mailles_MED' + +print "Creating Scalar Map.......", +scalarmap1 = myVisu.ScalarMapOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1); +if scalarmap1 is None : print "Error" +else : print "OK" +myView1.DisplayOnly(scalarmap1) +myView1.FitAll() + +print "Creating Iso Surfaces.....", +isosurfaces1 = myVisu.IsoSurfacesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1); +if isosurfaces1 is None : print "Error" +else : print "OK" +myView1.DisplayOnly(isosurfaces1) + +print "Creating Cut Planes.......", +cutplanes1 = myVisu.CutPlanesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1); +if cutplanes1 is None : print "Error" +else : print "OK" +cutplanes1.SetOrientation(VISU.CutPlanes.YZ, 0, 0) +myView1.DisplayOnly(cutplanes1) + +#%====================Stage6: Object browser popup====================% + +print "**** Stage6: Object browser popup" + +print "Creating mesh.............", +mesh = myVisu.MeshOnEntity(myResult1,myMeshName1,myCellEntity); +if mesh is None : print "Error" +else : print "OK" +myView1.DisplayOnly(mesh) + + +print "Changing type of presentation of mesh:" +mesh.SetPresentationType(VISU.WIREFRAME) +PrsType = mesh.GetPresentationType() +print "Presentation type..", PrsType +myView1.DisplayOnly(mesh) + +mesh.SetPresentationType(VISU.SHADED) +PrsType = mesh.GetPresentationType() +print "Presentation type.....", PrsType +myView1.DisplayOnly(mesh) + +mesh.SetPresentationType(VISU.POINT) +PrsType = mesh.GetPresentationType() +print "Presentation type......", PrsType +myView1.DisplayOnly(mesh) +myView1.Update() + +mesh.SetPresentationType(VISU.SHRINK) +PrsType = mesh.GetPresentationType() +print "Presentation type.....", PrsType +myView1.DisplayOnly(mesh) + +print "Changing color of mesh....", +aColor = SALOMEDS.Color(0,0,1) +mesh.SetCellColor(aColor) +myView1.DisplayOnly(mesh) +print "OK" + +print "Renaming ScalarMap........", +SObj = newStudy.FindObjectIOR(scalarmap1.GetID()) +newName = 'Renamed Object' +SObj.Name = newName +print "OK" + +print "Deleting Cut Planes.......", +SObj = newStudy.FindObjectIOR(cutplanes1.GetID()) +myBuilder = newStudy.NewBuilder() +myBuilder.RemoveObject(SObj) +print "OK" + +print "Changing first IsoSurfaces", +myVisu.SetCurrentStudy(salome.myStudy) +myView.DisplayOnly(isosurfaces) +isosurfaces.SetNbSurfaces(25) +print "OK" + +myView.Maximize() +myView.DisplayOnly(isosurfaces) + +print "Hide IsoSurfaces..........", +myView.Erase(isosurfaces) +print "OK" diff --git a/src/VISU_SWIG/VISU_Example_02.py b/src/VISU_SWIG/VISU_Example_02.py new file mode 100644 index 00000000..be71fa76 --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_02.py @@ -0,0 +1,348 @@ +# T 2.24: Save/retrieve view parameters. +# Uses MED file fra.med from ${DATA_DIR}/MedFiles directory. +# +# This script is equivalent to non-regression test script 003/A3 + +import salome +import visu_gui +import SALOMEDS +import VISU +import os + +medFile = os.getenv("DATA_DIR") + "/MedFiles/fra.med" + +#%====================Stage1: Creating a new study====================% + +print "**** Stage1: Creating a new study " + +print "Creating a new study..................", +myVisu = visu_gui.myVisu +myVisu.SetCurrentStudy(salome.myStudy) +myViewManager = myVisu.GetViewManager() +if myViewManager is None : print "Error" +else : print "OK" + +#%====================Stage2: Saving view parameters before import====================% + +print "**** Stage2: Saving view parameters before import " + +myView = myViewManager.Create3DView() + +print "Zooming trihedron.....................", +aScale = myView.GetParallelScale() +myView.SetParallelScale(aScale*4) +print "OK" + +print "Rotating trihedron....................", +aPoint = (100,100,100) +myView.SetPointOfView(aPoint) +print "OK" + +print "Saving view parameters................", +aViewParamsName1 = 'ViewParams:1' +aSaveRes = myView.SaveViewParams(aViewParamsName1) +if aSaveRes != 1 : print "Error" +else : print "OK" + +#%====================Stage3: Import MED file====================% + +print "**** Stage3: Import MED file" + +print 'Importing "fra.med"...................', +myResult = myVisu.ImportFile(medFile) +if myResult is None : print "Error" +else : print "OK" + +print "Creating mesh.........................", +myMeshName = 'LE VOLUME' +myCellEntity = VISU.CELL +mesh = myVisu.MeshOnEntity(myResult,myMeshName,myCellEntity); +if mesh is None : print "Error" +else : print "OK" + +myView.Maximize() +myView.Display(mesh) +myView.FitAll() + +#%====================Stage4: Saving view parameters after import====================% + +print "**** Stage4: Saving view parameters after import" + +print "Creating Scalar Map...................", +myFieldName = 'TAUX_DE_VIDE' +myNodeEntity = VISU.NODE +scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,myFieldName,1); +if scalarmap is None : print "Error" +else : print "OK" +myView.DisplayOnly(scalarmap) + +print "Zooming 3D view.......................", +aScale = myView.GetParallelScale() +myView.SetParallelScale(aScale*2) +print "OK" + +print "Setting view point(LEFT)..............", +myView.SetView((VISU.View3D.LEFT)) +print "OK" + +print "Saving view parameters................", +aViewParamsName2 = 'ViewParams:2' +aSaveRes = myView.SaveViewParams(aViewParamsName2) +if aSaveRes != 1 : print "Error" +else : print "OK" + +print "Creating Cut Planes...................", +cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,myFieldName,1); +if cutplanes is None : print "Error" +else : print "OK" +cutplanes.SetNbPlanes(4) +myView.DisplayOnly(cutplanes) + +print "Setting scaling.......................", + +#Define parameters of scaling: +myXParam = 5 +myYParam = 5 +myZParam = 1 + +myXAxis = VISU.View3D.XAxis +myYAxis = VISU.View3D.YAxis +myZAxis = VISU.View3D.ZAxis + +myView.ScaleView(myXAxis,myXParam) +myView.ScaleView(myYAxis,myYParam) +myView.ScaleView(myZAxis,myZParam) +print "OK" + +print "Rotating 3d view......................", +aPoint = (100,40,0) +myView.SetPointOfView(aPoint) +print "OK" + +print "Fit All...............................", +myView.FitAll() +print "OK" + +print "Saving view parameters................", +aViewParamsName3 = 'ViewParams:3' +aSaveRes = myView.SaveViewParams(aViewParamsName3) +if aSaveRes != 1 : print "Error" +else : print "OK" + +#%====================Stage5: Restoring view parameters====================% + +print "**** Stage5: Restoring view parameters" + +print "Restoring first view parameters.......", +aRestoreRes = myView.RestoreViewParams(aViewParamsName1) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Restoring second view parameters......", +aRestoreRes = myView.RestoreViewParams(aViewParamsName2) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Displaing only Scalar Map.............", +myView.DisplayOnly(scalarmap) +print "OK" + +print "Displaing only Cut Planes.............", +myView.DisplayOnly(cutplanes) +print "OK" + +print "Restoring third view parameters.......", +aRestoreRes = myView.RestoreViewParams(aViewParamsName3) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Displaing only Mesh...................", +myView.DisplayOnly(mesh) +print "OK" + +print "Displaing only Scalar Map.............", +myView.DisplayOnly(scalarmap) +print "OK" + +print "Displaing only Cut Planes.............", +myView.DisplayOnly(cutplanes) +print "OK" + +#%====================Stage6: Changing of view parameters====================% + +print "**** Stage6: Changing of view parameters" + +print "Remove scaling........................", +myView.RemoveScale() +print "OK" + +print "Fit All...............................", +myView.FitAll() +print "OK" + +print "Rotating 3d view......................", +aPoint = (0,60,150) +myView.SetPointOfView(aPoint) +print "OK" + +print "Resaving first view parameters........", +aSaveRes = myView.SaveViewParams(aViewParamsName1) +if aSaveRes != 1 : print "Error" +else : print "OK" + +print "Restoring third view parameters.......", +aRestoreRes = myView.RestoreViewParams(aViewParamsName3) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Restoring first view parameters.......", +aRestoreRes = myView.RestoreViewParams(aViewParamsName1) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Displaying only Mesh..................", +myView.DisplayOnly(mesh) +print "OK" + +print "Displaying only Scalar Map............", +myView.DisplayOnly(scalarmap) +print "OK" + +#%====================Stage7: Saving of created view parameters====================% + +print "**** Stage7: Saving of created view parameters" + +print "Saving study..........................", + +str = os.getenv("TmpDir") +if str == None: + str = "/tmp" + +file = str+'/VISU_005.hdf' + +salome.myStudyManager.SaveAs(file, salome.myStudy, 0) +study_id = salome.myStudy._get_StudyId() +#salome.sg.CloseStudy(study_id) +#salome.myStudyManager.Close(salome.myStudy) +#salome.myStudy.Close() +print "OK" + +print "Opening just saved study..............", + +openedStudy = salome.myStudyManager.Open(file) +myVisu.SetCurrentStudy(openedStudy) +myViewManager = myVisu.GetViewManager() +myView1 = myViewManager.Create3DView() +if myView1 is None : print "Error" +else : print "OK" + +print "Restoring first view parameters.......", +aRestoreRes = myView1.RestoreViewParams(aViewParamsName1) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +Builder = openedStudy.NewBuilder() +SCom = openedStudy.FindComponent("VISU") +Builder.LoadWith(SCom ,myVisu) + +print "Displaying Scalar Map.................", +SObj = openedStudy.FindObject('ScalarMap') +scalarmap1 = visu_gui.visu.SObjectToObject(SObj) +if scalarmap1 is None : print "Error" +else : print "OK" +myView1.DisplayOnly(scalarmap1) + +print "Displaying Cut Planes.................", +SObj = openedStudy.FindObject('CutPlanes') +cutplanes1 = visu_gui.visu.SObjectToObject(SObj) +if cutplanes1 is None : print "Error" +else : print "OK" +myView1.DisplayOnly(cutplanes1) + +print "Restoring second view parameters......", +aRestoreRes = myView1.RestoreViewParams(aViewParamsName2) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Displaying Scalar Map.................", +myView1.DisplayOnly(scalarmap1) +print "OK" + +print "Restoring third view parameters.......", +aRestoreRes = myView1.RestoreViewParams(aViewParamsName3) +if aRestoreRes != 1 : print "Error" +else : print "OK" + +print "Displaying Cut Planes.................", +myView1.DisplayOnly(cutplanes1) +print "OK" + +#%====================Stage8: Changing of saved session====================% + +print "**** Stage8: Changing of saved session" + +print "Deleting ViewParams:3,1,2.............", +SObj = openedStudy.FindObject(aViewParamsName3) +Builder.RemoveObject(SObj) +SObj = openedStudy.FindObject(aViewParamsName1) +Builder.RemoveObject(SObj) +SObj = openedStudy.FindObject(aViewParamsName2) +Builder.RemoveObject(SObj) +print "OK" + +SObjList2 = openedStudy.FindObjectByName(aViewParamsName1, "VISU") +print "FindObjectByName(aViewParamsName1, VISU) returned ", len(SObjList2), " objects" + +print "Zooming trihedron.....................", +aScale = myView.GetParallelScale() +myView1.SetParallelScale(aScale*2) +myView1.Update() +print "OK" + +print "Rotating trihedron....................", +aPoint = (200,40,-40) +myView1.SetPointOfView(aPoint) +print "OK" + +print "Saving view parameters................", +aSaveRes = myView1.SaveViewParams(aViewParamsName1) +if aSaveRes != 1 : print "Error" +else : print "OK" + +print "Renaming ViewParams:1.................", +SObj = openedStudy.FindObject(aViewParamsName1) +SObj.Name = "New_view" +print "OK" + +print "Setting scaling.......................", +#Define parameters of scaling: +myXParam = 4 +myYParam = 4 +myZParam = 8 + +myXAxis = VISU.View3D.XAxis +myYAxis = VISU.View3D.YAxis +myZAxis = VISU.View3D.ZAxis + +myView1.ScaleView(myXAxis,myXParam) +myView1.ScaleView(myYAxis,myYParam) +myView1.ScaleView(myZAxis,myZParam) +print "OK" + +myView1.FitAll() + +print "Saving view parameters................", +aSaveRes = myView1.SaveViewParams(aViewParamsName2) +if aSaveRes != 1 : print "Error" +else : print "OK" + +print "Restoring first view parameters.......", +aRestoreRes = myView1.RestoreViewParams(aViewParamsName1) +if aSaveRes != 1 : print "Error" +else : print "OK" + +print "Restoring second view parameters......", +aRestoreRes = myView1.RestoreViewParams(aViewParamsName2) +if aRestoreRes != 1 : print "Error" +else : print "OK" + diff --git a/src/VISU_SWIG/VISU_Example_03.py b/src/VISU_SWIG/VISU_Example_03.py new file mode 100644 index 00000000..dfa066cc --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_03.py @@ -0,0 +1,60 @@ +# Animation of "vitesse" field, stored in file TimeStamps.med +# +# This script is equivalent to non-regression test script 003/A5 + +import salome +import visu_gui +import SALOMEDS +import VISU +import os +import time + +medFile = os.getenv("DATA_DIR") + "/MedFiles/TimeStamps.med" + +print 'Importing "TimeStamps.med"................', +myVisu = visu_gui.myVisu +myResult = myVisu.ImportFile(medFile) +if myResult is None : print "Error" +else : print "OK" + +print "Creating Cut Lines........................", +medMesh = 'dom' +medField = "vitesse" +aCutLines = myVisu.CutLinesOnField(myResult,'dom',VISU.NODE,medField,1.0) +aCutLines.SetOrientation(VISU.CutPlanes.XY, 0, 0) +aCutLines.SetOrientation2(VISU.CutPlanes.ZX, 0, 0) +aCutLines.SetNbLines(20) +if aCutLines is None : print "Error" +else : print "OK" + +print "Creating a Viewer.........................", +myViewManager = myVisu.GetViewManager(); +myView = myViewManager.Create3DView(); +if myView is None : print "Error" +else : print "OK" +myView.Display(aCutLines); +myView.FitAll(); + +aCutLinesSObj = salome.myStudy.FindObjectIOR(aCutLines.GetID()) +aFather = aCutLinesSObj.GetFather().GetFather(); + +print "Creating an Animation.....................", +myAnim = myVisu.CreateAnimation(myView); +if myAnim is None : print "Error" +else : print "OK" + +print "Animation.................................", +myAnim.addField(aFather); +myAnim.generatePresentations(0); +myAnim.generateFrames(); +myAnim.setSpeed(33) +myAnim.startAnimation(); + +myView.FitAll() +while 1: + time.sleep(1) + if not myAnim.isRunning(): + myAnim.stopAnimation() + break + +print "OK" diff --git a/src/VISU_SWIG/VISU_Example_04.py b/src/VISU_SWIG/VISU_Example_04.py new file mode 100644 index 00000000..a50a831a --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_04.py @@ -0,0 +1,255 @@ +# Show some results presentations in different 3D and 2D viewers +# with different options (view parameters and display modes). +# Uses MED files fra.med and TimeStamps.med from ${DATA_DIR}/MedFiles directory. +# +# Pay attention to a viewer title to know its purpose. +# +# This script is equivalent to script VISU_SWIG/visu_view3d.py + +import os +import time +import math +import VISU +import SALOMEDS +from visu_gui import * + +aDelay = 1 + +myViewManager = myVisu.GetViewManager(); + +myView = myViewManager.Create3DView(); +myView.SetTitle("The window will be soon destroyed!") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +myView.Maximize() +print "myView.Maximize()" +time.sleep(aDelay) + +myView.Restore() +print "myView.Restore()" +time.sleep(aDelay) + +myView.Minimize() +print "myView.Minimize()" +time.sleep(aDelay) + +myViewManager.Destroy(myView) +print "myViewManager.Destroy(myView)" +time.sleep(aDelay) + + +medFile = "fra.med" +myFieldName = "VITESSE"; + +aMeshName ="LE VOLUME" +anEntity = VISU.NODE +aTimeStampId = 1 + +medFile = os.getenv('DATA_DIR') + '/MedFIles/' + medFile +myResult = myVisu.ImportFile(medFile) + +myView = myViewManager.Create3DView(); + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.3,1.0) +myView.SetBackground(aColor); + +myView.SetTitle("The viewer will display ScalarMap") +print "myViewManager.Create3DView()" + +aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) + +myView.Display(aScalarMap); +print "myView.Display(aScalarMap)" +myView.SetFocalPoint([0,0,0]); +print "myView.SetFocalPoint(...)" +myView.SetParallelScale(2); +print "myView.SetParallelScale(...)" +myView.FitAll(); + +aMax = aScalarMap.GetMax() +aMin = aScalarMap.GetMin() +aDelta = (aMax - aMin)/2.0 +aNbColors = aScalarMap.GetNbColors() +aNbColors = 64 +for i in range(2,aNbColors) : + aScalarMap.SetNbColors(i) + aX = aMin + aDelta*i/aNbColors + aY = aMax - aDelta*i/aNbColors + aScalarMap.SetRange(aX,aY) + myView.Update(); + time.sleep(aDelay) + +aScalarMap.SetRange(aMin,aMax) + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + +myView = myViewManager.Create3DView(); +myView.SetTitle("Here we will display CutPlanes") + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.7,0.0) +myView.SetBackground(aColor); + +aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +print "myVisu.CutPlanesOnField(...)" + +myView.DisplayOnly(aCutPlanes); +print "myView.DisplayOnly(aCutPlanes)" + +aPoint = myView.GetPointOfView(); +aPoint[0] = aPoint[0] + 10; +myView.SetPointOfView(aPoint); +print "myView.SetPointOfView(...)" +myView.ScaleView(VISU.View3D.YAxis,10.0); +myView.ScaleView(VISU.View3D.XAxis,3.0); +print "myView.ScaleView(...)" +time.sleep(aDelay) + +myView.FitAll(); + +aNbPlanes = aCutPlanes.GetNbPlanes() +aNbPlanes = 30 +aXAngle = aCutPlanes.GetRotateX() +aYAngle = aCutPlanes.GetRotateY() +anOrientation = aCutPlanes.GetOrientationType() +for i in range(aNbPlanes,1,-1) : + aCutPlanes.SetNbPlanes(i) + aX = math.pi/2.0*(aNbPlanes-i)/aNbPlanes + aY = math.pi/2.0*(aNbPlanes-i)/aNbPlanes + aCutPlanes.SetOrientation(anOrientation,aX,aY) + myView.Update(); + time.sleep(aDelay) + +aNbPlanes = 10 +aCutPlanes.SetOrientation(VISU.CutPlanes.ZX,0,0) +for i in range(1,aNbPlanes) : + aCutPlanes.SetNbPlanes(i) + myView.Update(); + time.sleep(aDelay) + +myView.SaveViewParams('AAA') +print "myView.SaveViewParams('AAA')" +time.sleep(aDelay) + +aCutPlanes.SetOrientation(VISU.CutPlanes.XY,0,0) +myView.RemoveScale(); + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + +myView = myViewManager.Create3DView(); +print "myViewManager.Create3DView()" + +myView.SetTitle("IsoSurface's viewer") + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(1.0,0.7,0.0) +myView.SetBackground(aColor); +time.sleep(aDelay) + +aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) + +myView.DisplayOnly(aIsoSurfaces); +myView.FitAll(); +print "myView.DisplayOnly(aCutPlanes)" +time.sleep(aDelay) + +aNbSurfaces = aIsoSurfaces.GetNbSurfaces() +aNbSurfaces = 32 +for i in range(2,aNbSurfaces) : + aIsoSurfaces.SetNbSurfaces(i) + myView.Update(); + time.sleep(aDelay) + +aIsoSurfaces.SetNbSurfaces(10) + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for CutLines") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.7,0.7,0.7) +myView.SetBackground(aColor); +time.sleep(aDelay) + +aCutLines = myVisu.CutLinesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +aCutLines.SetOrientation(VISU.CutPlanes.ZX,0,0) +aCutLines.SetOrientation2(VISU.CutPlanes.YZ,0,0) + +myView.DisplayOnly(aCutLines); +myView.FitAll(); +print "myView.DisplayOnly(aCutLines)" +time.sleep(aDelay) + +aSObj = myStudy.FindObjectIOR(aCutLines.GetID()) +aTable = myVisu.CreateTable( aSObj.GetID() ) +print "myVisu.CreateTable(...)" + +aTableView = myViewManager.CreateTableView(aTable) +aTableView.SetTitle('Changed Title') + +aContainer = myVisu.CreateContainer() +print "myVisu.CreateContainer(...)" + +aNbCurve = aTable.GetNbRows() - 1 +for i in range(2,aNbCurve): + aCurve = myVisu.CreateCurve( aTable, 1, i ) + print i, aCurve + aContainer.AddCurve(aCurve) + + +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curves from CutLines") +print "myViewManager.CreateXYPlot()" +time.sleep(aDelay) + +myView.Display(aContainer) + + +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for Animation") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +medFile = "TimeStamps.med" +myFieldName = "vitesse"; + +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile +myResult = myVisu.ImportFile(medFile) + +anAnim = myVisu.CreateAnimation(myView); +aSObj = myStudy.FindObjectIOR(myResult.GetID()) +aSObj = aSObj.FindSubObject(1)[1] +aSObj = aSObj.FindSubObject(2)[1] +aSObj = aSObj.FindSubObject(2)[1] +anAnim.addField(aSObj) +anAnim.setPresentationType(0,VISU.TISOSURFACE) +print "Generate presentations" +anAnim.generatePresentations(0) +print "Generate frames" +anAnim.generateFrames() +print "Start Animation" +anAnim.setSpeed(99) +anAnim.startAnimation() +myView.FitAll() +while 1: + time.sleep(1+aDelay) + if not anAnim.isRunning(): + anAnim.stopAnimation() + break diff --git a/src/VISU_SWIG/VISU_Example_05.py b/src/VISU_SWIG/VISU_Example_05.py new file mode 100644 index 00000000..a70943e4 --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_05.py @@ -0,0 +1,77 @@ +# Create a table and show it in Plot2d viewer +# +# This script is equivalent to script VISU_SWIG/visu_big_table.py + +import salome +import math +import SALOMEDS +import VISU +#from visu_gui import * + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Getting (loading) VISU component ======================================= +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myComponent = myStudy.FindComponent("VISU") +myVisu.SetCurrentStudy(myStudy) +if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue( salome.sg.getComponentUserName("VISU") ) + + A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap"); + aPixmap = A2._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); + + myBuilder.DefineComponentInstance(myComponent,myVisu) + +# >>> Creating object with Table of real[ 200 * 20 ] ========================= +myTRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") +AName.SetValue("Table Of Real") +ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") +myHorNb = 10 +myVerNb = 200 + +k={} +for j in range(0,myHorNb): + k[j] = j*10+1 +ARealTable.AddRow(k.values()) +ARealTable.SetRowTitle(1, "Frequency") +ARealTable.SetRowUnit(1, "Hz") + +for i in range(1,myVerNb+1): + for j in range(0,myHorNb): + if j % 2 == 1: + k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 + else: + k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 + ARealTable.AddRow(k.values()) + ARealTable.SetRowTitle(i+1, "Power " + str(i)) + ARealTable.SetRowUnit(i+1, "Wt") + +ARealTable.SetTitle("Very useful data") + +# >>> Create Visu table ====================================================== +myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() ) + +# >>> Create container and insert curves +myContainer = myVisu.CreateContainer() + +# >>> Create curves ========================================================== +for i in range(1,myVerNb+1): + myCurve = myVisu.CreateCurve( myVisuTableReal, 1, i+1 ) + myContainer.AddCurve(myCurve) + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# >>> Display curves in Plot2d viewer ======================================== +myViewManager = myVisu.GetViewManager(); +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curves from the Table") +myView.Display(myContainer) + +# ============================================================================ diff --git a/src/VISU_SWIG/VISU_Example_06.py b/src/VISU_SWIG/VISU_Example_06.py new file mode 100644 index 00000000..f31b80e4 --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_06.py @@ -0,0 +1,61 @@ +# Import a table from file and show it in Plot2d viewer + +import salome +import math +import SALOMEDS +import VISU +#from visu_gui import * + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Getting (loading) VISU component ======================================= +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myComponent = myStudy.FindComponent("VISU") +myVisu.SetCurrentStudy(myStudy) +if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + #aName.SetValue("Visu") + aName.SetValue( salome.sg.getComponentUserName("VISU") ) + + A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap"); + aPixmap = A2._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); + + myBuilder.DefineComponentInstance(myComponent,myVisu) + +# >>> Import a tables from a file ============================================ +aFileName = os.getenv("DATA_DIR") + "/Tables/tables_test.xls" +sobj = myVisu.ImportTables(aFileName) + +# >>> Create container and insert curves ===================================== +myContainer = myVisu.CreateContainer() + +chiter = myStudy.NewChildIterator(sobj) +while chiter.More(): + sobj_table = chiter.Value() + + # >>> Create Visu table ==================================================== + myVisuTableReal = myVisu.CreateTable(sobj_table.GetID()) + + nbRows = myVisuTableReal.GetNbRows() + + # >>> Create curves ======================================================== + for i in range(1, nbRows): + myCurve = myVisu.CreateCurve(myVisuTableReal, 1, i+1) + myContainer.AddCurve(myCurve) + + chiter.Next() + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# >>> Display curves in Plot2d viewer ======================================== +myViewManager = myVisu.GetViewManager(); +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curves from the Table") +myView.Display(myContainer) + +# ============================================================================ diff --git a/src/VISU_SWIG/batchmode_visu_view3d.py b/src/VISU_SWIG/batchmode_visu_view3d.py index 0d41aa6d..f5154355 100644 --- a/src/VISU_SWIG/batchmode_visu_view3d.py +++ b/src/VISU_SWIG/batchmode_visu_view3d.py @@ -50,7 +50,7 @@ aMeshName ="LE VOLUME" anEntity = VISU.NODE aTimeStampId = 1 -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile myResult = myVisu.ImportFile(medFile) @@ -240,7 +240,7 @@ time.sleep(aDelay) medFile = "TimeStamps.med" myFieldName = "vitesse"; -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile myResult = myVisu.ImportFile(medFile) anAnim = myVisu.CreateAnimation(myView); diff --git a/src/VISU_SWIG/visu_delete.py b/src/VISU_SWIG/visu_delete.py index b73173ca..d001d601 100644 --- a/src/VISU_SWIG/visu_delete.py +++ b/src/VISU_SWIG/visu_delete.py @@ -12,7 +12,7 @@ aMeshName ="LE VOLUME" anEntity = VISU.NODE aTimeStampId = 1 -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile myResult = myVisu.ImportFile(medFile) aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) diff --git a/src/VISU_SWIG/visu_med.py b/src/VISU_SWIG/visu_med.py index 2a5532ae..04715e52 100644 --- a/src/VISU_SWIG/visu_med.py +++ b/src/VISU_SWIG/visu_med.py @@ -42,7 +42,7 @@ def getFieldObjectFromStudy(number,subnumber): med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED") -medDir = os.getenv('KERNEL_ROOT_DIR') + '/examples/' +medDir = os.getenv('DATA_DIR') + '/MedFiles/' def importMedFrom(medDir,medFile): medFile = medDir + medFile diff --git a/src/VISU_SWIG/visu_prs_example.py b/src/VISU_SWIG/visu_prs_example.py index 84d65be4..1453c5ad 100644 --- a/src/VISU_SWIG/visu_prs_example.py +++ b/src/VISU_SWIG/visu_prs_example.py @@ -22,7 +22,7 @@ import visu_gui myVisu = visu_gui.myVisu medFile = "pointe.med" -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile print medFile studyCurrent = salome.myStudyName diff --git a/src/VISU_SWIG/visu_swig_test.py b/src/VISU_SWIG/visu_swig_test.py index 9946faba..411e532e 100644 --- a/src/VISU_SWIG/visu_swig_test.py +++ b/src/VISU_SWIG/visu_swig_test.py @@ -1,5 +1,5 @@ from libVISU_Swig import * -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/fra.med' +medFile = os.getenv('DATA_DIR') + '/MedFiles/fra.med' myCon=Convertor(medFile) myPrs=ScalarMap(myCon,"LE VOLUME",0,"VITESSE",1) myView=View3D() diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py index be807a71..d1bf0721 100644 --- a/src/VISU_SWIG/visu_view3d.py +++ b/src/VISU_SWIG/visu_view3d.py @@ -50,7 +50,7 @@ aMeshName ="LE VOLUME" anEntity = VISU.NODE aTimeStampId = 1 -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile myResult = myVisu.ImportFile(medFile) @@ -247,7 +247,7 @@ time.sleep(aDelay) medFile = "TimeStamps.med" myFieldName = "vitesse"; -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile myResult = myVisu.ImportFile(medFile) anAnim = myVisu.CreateAnimation(myView);