From: imn Date: Mon, 14 Nov 2016 11:17:30 +0000 (+0300) Subject: Small correction fix for python scripts X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6e563a545c49766e80e1bf70a3863916fbad6f68;p=modules%2Fgui.git Small correction fix for python scripts --- diff --git a/src/GUI_PY/helper.py b/src/GUI_PY/helper.py index 0155ded09..ce652e4e8 100644 --- a/src/GUI_PY/helper.py +++ b/src/GUI_PY/helper.py @@ -53,22 +53,6 @@ sgPyQt=SalomePyQt.SalomePyQt() import libSALOME_Swig SalomeGUI = libSALOME_Swig.SALOMEGUI_Swig() -# -# ================================================================== -# General helper function for GUI programming actions -# ================================================================== -# -# Get the active study -# -def getActiveStudy(): - """ - This returns a study object that corresponds to the active - study. The active study is a GUI concept: it's the study currently - active on the desktop. - """ - study = services.getStudy() - return study - # # ================================================================== # Functions to manipulate the objects in the browser (generic) @@ -83,7 +67,7 @@ def getSObjectSelected(): ''' sobj = None entry = None - study = getActiveStudy() + study = services.getStudy() if SalomeGUI.SelectedCount() == 1: # We only considere the first element of the list. If you need # something else, create another function in your own context. @@ -111,7 +95,7 @@ def deleteSObjectSelected(): ''' sobj, entry = getSObjectSelected() if ( sobj ): - study = getActiveStudy() + study = services.getStudy() builder = study.NewBuilder() builder.RemoveObject( sobj ) SalomeGUI.updateObjBrowser() @@ -129,7 +113,7 @@ def deleteSObjectSelected(): # # Definitions: -# - the SObject is an item in the active study (Study Object). +# - the SObject is an item in the study (Study Object). # - the entry is the identifier of an item. # - the object (geom object or smesh object) is a CORBA servant # embedded in the SALOME component container and with a reference in diff --git a/src/SalomeApp/pluginsdemo/tubebuilder.py b/src/SalomeApp/pluginsdemo/tubebuilder.py index beb570c45..e121161c0 100644 --- a/src/SalomeApp/pluginsdemo/tubebuilder.py +++ b/src/SalomeApp/pluginsdemo/tubebuilder.py @@ -27,7 +27,7 @@ DEFAULT_WIDTH = 20 from salome.geom import geomtools -def createGeometry(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH): +def createGeometry(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH): ''' This function creates the geometry on the specified study and with given parameters. @@ -43,12 +43,12 @@ def createGeometry(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DE Tube = geompy.MakeCut(CylinderExt, CylinderInt) return Tube -def createGeometryWithPartition(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH): +def createGeometryWithPartition(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH): ''' This function create the geometrical shape with a partition so that the hexaedric algorithm could be used for meshing. ''' - shape = createGeometry(study,radius,length,width) + shape = createGeometry(radius,length,width) # We have to create a partition so that we can use an hexaedric # meshing algorithm. @@ -87,13 +87,13 @@ def createMesh(shape): return mesh -def createModel(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH,width=DEFAULT_WIDTH): +def createModel(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH,width=DEFAULT_WIDTH): ''' This function create the geomtrical shape AND the associated mesh. ''' # We first create a shape with a partition so that the hexaedric # algorithm could be used. - shape = createGeometryWithPartition(study,radius,length,width) + shape = createGeometryWithPartition(radius,length,width) # Then the mesh can be defined and computed mesh = createMesh(shape) @@ -114,23 +114,21 @@ def exportModel(mesh, filename): # def TEST_createGeometry(): salome.salome_init() - theStudy=salome.myStudy - createGeometry(theStudy) + createGeometry() def TEST_createMesh(): salome.salome_init() - shape = createGeometryWithPartition(salome.myStudy) + shape = createGeometryWithPartition() mesh = createMesh(shape) def TEST_createModel(): salome.salome_init() - theStudy=salome.myStudy - createModel(theStudy) + createModel() def TEST_exportModel(): salome.salome_init() - shape = createGeometryWithPartition(salome.myStudy) - mesh = createMesh() + shape = createGeometryWithPartition() + mesh = createMesh(shape) exportModel(mesh,"tubemesh.med") if __name__ == "__main__": diff --git a/src/SalomeApp/pluginsdemo/xalome.py b/src/SalomeApp/pluginsdemo/xalome.py index c0f61a789..c2d55be7d 100644 --- a/src/SalomeApp/pluginsdemo/xalome.py +++ b/src/SalomeApp/pluginsdemo/xalome.py @@ -36,7 +36,7 @@ from salome.geom import geomtools # Helper functions to add/remove a geometrical shape in/from the study # ====================================================================== -def addToStudy(study,shape,shapeName,folderName=None): +def addToStudy(shape,shapeName,folderName=None): """ Add a GEOM shape in the study. It returns the associated entry that corresponds to the identifier of the entry in the study. This @@ -70,7 +70,7 @@ def addToStudy(study,shape,shapeName,folderName=None): return entry -def removeFromStudy(study,shapeStudyEntry): +def removeFromStudy(shapeStudyEntry): """ This removes the specified entry from the study. Note that this operation does not destroy the underlying GEOM object, neither @@ -124,7 +124,7 @@ def eraseShape_version65(shapeStudyEntry): # Helper functions for a complete suppression of a shape from the # SALOME session. # ====================================================================== -def deleteShape(study,shapeStudyEntry): +def deleteShape(shapeStudyEntry): """ This completly deletes a geom shape. @@ -136,7 +136,7 @@ def deleteShape(study,shapeStudyEntry): 3. destroy the underlying geom object """ eraseShape(shapeStudyEntry) - shape = removeFromStudy(study, shapeStudyEntry) + shape = removeFromStudy(shapeStudyEntry) if shape is not None: shape.Destroy() @@ -160,7 +160,7 @@ def TEST_createAndDeleteShape(): """ import salome salome.salome_init() - study = salome.myStudy + study = salome.myStudy from salome.geom import geomtools geompy = geomtools.getGeompy() @@ -175,7 +175,7 @@ def TEST_createAndDeleteShape(): # folder. A name must be specified. The register operation # (addToStudy) returns an identifier of the entry in the study. cylinderName = "cyl.r%s.l%s"%(radius,length) - cylinderStudyEntry = addToStudy(study, cylinder, cylinderName) + cylinderStudyEntry = addToStudy(cylinder, cylinderName) # Display the registered shape in a viewer displayShape(cylinderStudyEntry) @@ -185,7 +185,7 @@ def TEST_createAndDeleteShape(): radius = 10 sphere = geompy.MakeSphereR(radius) sphereName = "sph.r%s"%radius - sphereStudyEntry = addToStudy(study, sphere, sphereName) + sphereStudyEntry = addToStudy(sphere, sphereName) displayShape(sphereStudyEntry) # -------------------------------------------------- @@ -196,7 +196,7 @@ def TEST_createAndDeleteShape(): box = geompy.MakeBoxDXDYDZ(length,length,length) boxName = "box.l%s"%length folderName = "boxset" - boxStudyEntry = addToStudy(study, box, boxName, folderName) + boxStudyEntry = addToStudy(box, boxName, folderName) displayShape(boxStudyEntry,PreviewColor) # -------------------------------------------------- @@ -211,7 +211,7 @@ def TEST_createAndDeleteShape(): # SALOME session (erase from viewer, remove from study and finnaly # destroy the object). This is done by a simple call to # deleteShape(). - deleteShape(study,cylinderStudyEntry) + deleteShape(cylinderStudyEntry) # -------------------------------------------------- # At the end of the executioon of this test, you should have in