# -*- coding: utf-8 -*-
#
-# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-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
from salome.kernel import termcolor
logger = Logger("salome.geom.geomtools", color = termcolor.RED)
-from salome.kernel.studyedit import getActiveStudyId, getStudyEditor
+from salome.kernel.studyedit import getStudyEditor
from salome.kernel.services import IDToObject, IDToSObject
from salome.kernel.deprecation import is_called_by_sphinx
+from salome.geom import geomBuilder
try:
if not is_called_by_sphinx():
except:
pass
-_geompys = {}
+_geompy = geomBuilder.New()
-## Return an object behaving exactly like geompy module, except that it is
-# associated with the study \em studyId. If \em studyId is \b None, return
-# a pseudo geompy object for the current study.
+## Return an object behaving exactly like geompy module.
# \ingroup geomtools
-def getGeompy(studyId = None):
+def getGeompy():
"""
- Return an object behaving exactly like geompy module, except that it is
- associated with the study `studyId`. If `studyId` is :const:`None`, return
- a pseudo geompy object for the current study.
+ Return an object behaving exactly like geompy module.
"""
- # We can't use geompy module because it initializes GEOM with
- # salome.myStudy, which may not exist. So we use this trick to create
- # a pseudo geompy module.
salome.salome_init()
- if studyId is None:
- studyId = getActiveStudyId()
- if not _geompys.has_key(studyId):
- from salome.geom import geomBuilder
- study = salome.myStudyManager.GetStudyByID(studyId)
- _geompys[studyId] = geomBuilder.New(study)
- return _geompys[studyId]
+ return _geompy
ModeWireFrame = 0
:param folderName: the name of a folder in the GEOM part of the study
"""
study = self.editor.study
- studyId = study._get_StudyId()
- geompy = getGeompy(studyId)
+ geompy = getGeompy()
if folderName is None:
# Insert the shape in the study by the standard way
The underlying GEOM object is returned (so that it can be destroyed)
"""
study = self.editor.study
- studyId = study._get_StudyId()
shape = self.getGeomObjectFromEntry(shapeStudyEntry)
studyObject = IDToSObject(shapeStudyEntry)
self.editor.removeItem(studyObject,True)
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
geompy.addToStudy( box, 'box' )
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
+ salome.sg.updateObjBrowser()
def TEST_getGeomObjectSelected():
tool = GeomStudyTools()
myGeomObject = tool.getGeomObjectSelected()
- print myGeomObject
+ print(myGeomObject)
## This test is a simple use case that illustrates how to create a
# GEOM shape in a SALOME session (create the GEOM object, put in in
import salome
salome.salome_init()
study = salome.myStudy
- studyId = salome.myStudyId
from salome.geom import geomtools
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
from salome.kernel.studyedit import getStudyEditor
- studyEditor = getStudyEditor(studyId)
+ studyEditor = getStudyEditor()
gst = geomtools.GeomStudyTools(studyEditor)
gst.deleteShape(cylinderStudyEntry)
# --------------------------------------------------
- # At the end of the executioon of this test, you should have in
+ # At the end of the execution of this test, you should have in
# the SALOME session:
# - the box, in a dedicated folder of the study, and displayed in the viewer
# - the sphere, in the standard place of the study, and not displayed