Salome HOME
updated copyright message
[modules/gui.git] / src / SalomeApp / pluginsdemo / xalome.py
index 724afa40c9ba39a87965cc8e3b3b6f2e8112505e..a9736d15cced26689103f2a1e69815ba9c44d28d 100644 (file)
@@ -1,10 +1,10 @@
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2023  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
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -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
@@ -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. 
     """
-    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
@@ -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.
-        studyEditor = getStudyEditor(studyId)
+        studyEditor = getStudyEditor()
         geomStudyFolder = studyEditor.findOrCreateComponent("GEOM")
         shapeStudyFolder = studyEditor.findOrCreateItem(geomStudyFolder,folderName)
 
@@ -71,17 +70,16 @@ 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
     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)
-    studyEditor = getStudyEditor(studyId)
+    studyEditor = getStudyEditor()
     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.
 # ======================================================================
-def deleteShape(study,shapeStudyEntry):
+def deleteShape(shapeStudyEntry):
     """
     This completly deletes a geom shape.
 
@@ -138,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()
     
@@ -162,11 +160,10 @@ def TEST_createAndDeleteShape():
     """
     import salome
     salome.salome_init()
-    study   = salome.myStudy
-    studyId = salome.myStudyId
+    study = salome.myStudy
 
     from salome.geom import geomtools
-    geompy = geomtools.getGeompy(studyId)
+    geompy = geomtools.getGeompy()
 
     # --------------------------------------------------
     # 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)
-    cylinderStudyEntry = addToStudy(study, cylinder, cylinderName)
+    cylinderStudyEntry = addToStudy(cylinder, cylinderName)
 
     # 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
-    sphereStudyEntry = addToStudy(study, sphere, sphereName)
+    sphereStudyEntry = addToStudy(sphere, sphereName)
     displayShape(sphereStudyEntry)
 
     # --------------------------------------------------
@@ -199,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)
 
     # --------------------------------------------------
@@ -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().
-    deleteShape(study,cylinderStudyEntry)
+    deleteShape(cylinderStudyEntry)
 
     # --------------------------------------------------
     # At the end of the executioon of this test, you should have in