Salome HOME
Updated copyright comment
[modules/gui.git] / src / SalomeApp / pluginsdemo / xalome.py
index 05555b04490e99ba1f27a553a2064150d33387de..6bd7e3808276f8c36f6f1f858840cc17fa460217 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2024  CEA, EDF, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -36,7 +36,7 @@ from salome.geom import geomtools
 # Helper functions to add/remove a geometrical shape in/from the study
 # ======================================================================
 
 # 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
     """
     Add a GEOM shape in the study. It returns the associated entry
     that corresponds to the identifier of the entry in the study. This
@@ -45,8 +45,7 @@ def addToStudy(study,shape,shapeName,folderName=None):
     created in the Geometry part of the study, and the shape study
     object is stored in this folder of the study. 
     """
     created in the Geometry part of the study, and the shape study
     object is stored in this folder of the study. 
     """
-    studyId = study._get_StudyId()
-    geompy = geomtools.getGeompy(studyId)
+    geompy = geomtools.getGeompy()
 
     if folderName is None:
         # Insert the shape in the study by the standard way
 
     if folderName is None:
         # Insert the shape in the study by the standard way
@@ -55,7 +54,7 @@ def addToStudy(study,shape,shapeName,folderName=None):
         # A folder name has been specified to embed this shape. Find
         # or create a folder with this name in the Geometry study, and
         # then store the shape in this folder.
         # A folder name has been specified to embed this shape. Find
         # or create a folder with this name in the Geometry study, and
         # then store the shape in this folder.
-        studyEditor = getStudyEditor(studyId)
+        studyEditor = getStudyEditor()
         geomStudyFolder = studyEditor.findOrCreateComponent("GEOM")
         shapeStudyFolder = studyEditor.findOrCreateItem(geomStudyFolder,folderName)
 
         geomStudyFolder = studyEditor.findOrCreateComponent("GEOM")
         shapeStudyFolder = studyEditor.findOrCreateItem(geomStudyFolder,folderName)
 
@@ -71,17 +70,16 @@ def addToStudy(study,shape,shapeName,folderName=None):
 
     return entry
 
 
     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
     erase the drawing in the viewer.
     The underlying GEOM object is returned (so that it can be destroyed)
     """
     """
     This removes the specified entry from the study. Note that this
     operation does not destroy the underlying GEOM object, neither
     erase the drawing in the viewer.
     The underlying GEOM object is returned (so that it can be destroyed)
     """
-    studyId = study._get_StudyId()
     shape = IDToObject(shapeStudyEntry)    
     studyObject = IDToSObject(shapeStudyEntry)
     shape = IDToObject(shapeStudyEntry)    
     studyObject = IDToSObject(shapeStudyEntry)
-    studyEditor = getStudyEditor(studyId)
+    studyEditor = getStudyEditor()
     studyEditor.removeItem(studyObject,True)
     return shape
 
     studyEditor.removeItem(studyObject,True)
     return shape
 
@@ -126,7 +124,7 @@ def eraseShape_version65(shapeStudyEntry):
 # Helper functions for a complete suppression of a shape from the
 # SALOME session.
 # ======================================================================
 # 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.
 
     """
     This completly deletes a geom shape.
 
@@ -138,7 +136,7 @@ def deleteShape(study,shapeStudyEntry):
     3. destroy the underlying geom object
     """
     eraseShape(shapeStudyEntry)
     3. destroy the underlying geom object
     """
     eraseShape(shapeStudyEntry)
-    shape = removeFromStudy(study, shapeStudyEntry)
+    shape = removeFromStudy(shapeStudyEntry)
     if shape is not None:
       shape.Destroy()
     
     if shape is not None:
       shape.Destroy()
     
@@ -162,11 +160,10 @@ def TEST_createAndDeleteShape():
     """
     import salome
     salome.salome_init()
     """
     import salome
     salome.salome_init()
-    study   = salome.myStudy
-    studyId = salome.myStudyId
+    study = salome.myStudy
 
     from salome.geom import geomtools
 
     from salome.geom import geomtools
-    geompy = geomtools.getGeompy(studyId)
+    geompy = geomtools.getGeompy()
 
     # --------------------------------------------------
     # Create a first shape (GEOM object)
 
     # --------------------------------------------------
     # Create a first shape (GEOM object)
@@ -178,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)
     # 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)
 
     # Display the registered shape in a viewer
     displayShape(cylinderStudyEntry)
@@ -188,7 +185,7 @@ def TEST_createAndDeleteShape():
     radius = 10
     sphere = geompy.MakeSphereR(radius)
     sphereName = "sph.r%s"%radius
     radius = 10
     sphere = geompy.MakeSphereR(radius)
     sphereName = "sph.r%s"%radius
-    sphereStudyEntry = addToStudy(study, sphere, sphereName)
+    sphereStudyEntry = addToStudy(sphere, sphereName)
     displayShape(sphereStudyEntry)
 
     # --------------------------------------------------
     displayShape(sphereStudyEntry)
 
     # --------------------------------------------------
@@ -199,7 +196,7 @@ def TEST_createAndDeleteShape():
     box = geompy.MakeBoxDXDYDZ(length,length,length)
     boxName = "box.l%s"%length
     folderName = "boxset" 
     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)
 
     # --------------------------------------------------
     displayShape(boxStudyEntry,PreviewColor)
 
     # --------------------------------------------------
@@ -214,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().
     # 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
 
     # --------------------------------------------------
     # At the end of the executioon of this test, you should have in