Salome HOME
projects
/
modules
/
geom.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[bos #35160][EDF](2023-T1) Keyboard shortcuts.
[modules/geom.git]
/
src
/
GEOM_PY
/
geomtools.py
diff --git
a/src/GEOM_PY/geomtools.py
b/src/GEOM_PY/geomtools.py
index 6fbac893d29137808139fb477b6317f314d88a44..f5c61f2460052a4fd1be7a2ccf37097736873dbf 100644
(file)
--- a/
src/GEOM_PY/geomtools.py
+++ b/
src/GEOM_PY/geomtools.py
@@
-1,6
+1,6
@@
# -*- coding: utf-8 -*-
#
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2007-20
16 CEA/DEN, EDF R&D
, OPEN CASCADE
+# Copyright (C) 2007-20
24 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
@@
-38,9
+38,10
@@
from salome.kernel.logger import Logger
from salome.kernel import termcolor
logger = Logger("salome.geom.geomtools", color = termcolor.RED)
from salome.kernel import termcolor
logger = Logger("salome.geom.geomtools", color = termcolor.RED)
-from salome.kernel.studyedit import get
ActiveStudyId, get
StudyEditor
+from salome.kernel.studyedit import getStudyEditor
from salome.kernel.services import IDToObject, IDToSObject
from salome.kernel.deprecation import is_called_by_sphinx
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():
try:
if not is_called_by_sphinx():
@@
-50,29
+51,16
@@
try:
except:
pass
except:
pass
-_geompy
s = {}
+_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
# \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()
salome.salome_init()
- if studyId is None:
- studyId = getActiveStudyId()
- if studyId not in _geompys:
- from salome.geom import geomBuilder
- study = salome.myStudyManager.GetStudyByID(studyId)
- _geompys[studyId] = geomBuilder.New(study)
- return _geompys[studyId]
+ return _geompy
ModeWireFrame = 0
ModeWireFrame = 0
@@
-146,8
+134,7
@@
class GeomStudyTools:
:param folderName: the name of a folder in the GEOM part of the study
"""
study = self.editor.study
: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
if folderName is None:
# Insert the shape in the study by the standard way
@@
-183,7
+170,6
@@
class GeomStudyTools:
The underlying GEOM object is returned (so that it can be destroyed)
"""
study = self.editor.study
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)
shape = self.getGeomObjectFromEntry(shapeStudyEntry)
studyObject = IDToSObject(shapeStudyEntry)
self.editor.removeItem(studyObject,True)
@@
-230,13
+216,13
@@
class GeomStudyTools:
## Display the geometrical shape whose entry is given by \em entry.
# You should prefer use this function instead of the
## Display the geometrical shape whose entry is given by \em entry.
# You should prefer use this function instead of the
- # displayShapeByName() which can have an unpredict
i
ble behavior in
+ # displayShapeByName() which can have an unpredict
a
ble behavior in
# the case where several objects exist with the same name in the study.
def displayShapeByEntry(self, shapeStudyEntry, color = None, fit=True):
"""
Display the geometrical shape whose entry is given by
`entry`. You should prefer use this function instead of the
# the case where several objects exist with the same name in the study.
def displayShapeByEntry(self, shapeStudyEntry, color = None, fit=True):
"""
Display the geometrical shape whose entry is given by
`entry`. You should prefer use this function instead of the
- displayShapeByName which can have an unpredict
i
ble behavior in
+ displayShapeByName which can have an unpredict
a
ble behavior in
the case where several objects exist with the same name in the
study.
"""
the case where several objects exist with the same name in the
study.
"""
@@
-271,7
+257,7
@@
class GeomStudyTools:
# 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.
# ======================================================================
- ## This completly deletes a geom shape.
+ ## This complet
e
ly deletes a geom shape.
# \warning Please be aware that to delete a geom object,
# you have three operations to perform:
#
# \warning Please be aware that to delete a geom object,
# you have three operations to perform:
#
@@
-280,7
+266,7
@@
class GeomStudyTools:
# 3. destroy the underlying geom object
def deleteShape(self,shapeStudyEntry):
"""
# 3. destroy the underlying geom object
def deleteShape(self,shapeStudyEntry):
"""
- This completly deletes a geom shape.
+ This complet
e
ly deletes a geom shape.
WARNING: please be aware that to delete a geom object, you have
three operations to perform:
WARNING: please be aware that to delete a geom object, you have
three operations to perform:
@@
-337,7
+323,7
@@
def TEST_createBox():
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
geompy.addToStudy( box, 'box' )
if salome.sg.hasDesktop():
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
geompy.addToStudy( box, 'box' )
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(
True
)
+ salome.sg.updateObjBrowser()
def TEST_getGeomObjectSelected():
def TEST_getGeomObjectSelected():
@@
-364,13
+350,12
@@
def TEST_createAndDeleteShape():
import salome
salome.salome_init()
study = salome.myStudy
import salome
salome.salome_init()
study = salome.myStudy
- studyId = salome.myStudyId
from salome.geom import geomtools
from salome.geom import geomtools
- geompy = geomtools.getGeompy(
studyId
)
+ geompy = geomtools.getGeompy()
from salome.kernel.studyedit import getStudyEditor
from salome.kernel.studyedit import getStudyEditor
- studyEditor = getStudyEditor(
studyId
)
+ studyEditor = getStudyEditor()
gst = geomtools.GeomStudyTools(studyEditor)
gst = geomtools.GeomStudyTools(studyEditor)
@@
-416,14
+401,14
@@
def TEST_createAndDeleteShape():
gst.eraseShapeByEntry(sphereStudyEntry)
# --------------------------------------------------
gst.eraseShapeByEntry(sphereStudyEntry)
# --------------------------------------------------
- # In this last example, we completly delete an object from the
+ # In this last example, we complet
e
ly delete an object from the
# SALOME session (erase from viewer, remove from study and finnaly
# destroy the object). This is done by a simple call to
# deleteShape().
gst.deleteShape(cylinderStudyEntry)
# --------------------------------------------------
# SALOME session (erase from viewer, remove from study and finnaly
# destroy the object). This is done by a simple call to
# deleteShape().
gst.deleteShape(cylinderStudyEntry)
# --------------------------------------------------
- # At the end of the executio
o
n 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
# 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