Back to index

salome-gui  6.5.0
Functions | Variables
xalome Namespace Reference

Functions

def addToStudy
def removeFromStudy
def displayShape
def eraseShape
def displayShape_version65
def eraseShape_version65
def deleteShape
def TEST_createAndDeleteShape

Variables

int ModeShading = 1
 DisplayMode = ModeShading
list PreviewColor = [236,163,255]

Function Documentation

def xalome.addToStudy (   study,
  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
entry can be used to retrieve an object in the study. A folderName
can be specified. In this case, a folder with this name is first
created in the Geometry part of the study, and the shape study
object is stored in this folder of the study. 

Definition at line 39 of file xalome.py.

00039 
00040 def addToStudy(study,shape,shapeName,folderName=None):
00041     """
00042     Add a GEOM shape in the study. It returns the associated entry
00043     that corresponds to the identifier of the entry in the study. This
00044     entry can be used to retrieve an object in the study. A folderName
00045     can be specified. In this case, a folder with this name is first
00046     created in the Geometry part of the study, and the shape study
00047     object is stored in this folder of the study. 
00048     """
00049     studyId = study._get_StudyId()
00050     geompy = geomtools.getGeompy(studyId)
00051 
00052     if folderName is None:
00053         # Insert the shape in the study by the standard way
00054         entry = geompy.addToStudy( shape, shapeName )
00055     else:
00056         # A folder name has been specified to embed this shape. Find
00057         # or create a folder with this name in the Geometry study, and
00058         # then store the shape in this folder.
00059         studyEditor = getStudyEditor(studyId)
00060         geomStudyFolder = studyEditor.findOrCreateComponent("GEOM")
00061         shapeStudyFolder = studyEditor.findOrCreateItem(geomStudyFolder,folderName)
00062 
00063         shapeIor = salome.orb.object_to_string(shape)
00064         geomgui = salome.ImportComponentGUI("GEOM")
00065         shapeIcon = geomgui.getShapeTypeIcon(shapeIor)
00066 
00067         shapeStudyObject = studyEditor.createItem(shapeStudyFolder,
00068                                                   name=shapeName,
00069                                                   IOR=shapeIor,
00070                                                   icon=shapeIcon)
00071         entry = shapeStudyObject.GetID()
00072 
00073     return entry

Here is the caller graph for this function:

def xalome.deleteShape (   study,
  shapeStudyEntry 
)
This completly deletes a geom shape.

WARNING: please be aware that to delete a geom object, you have
three operations to perform:

1. erase the shape from the viewers
2. remove the entry from the study
3. destroy the underlying geom object

Definition at line 129 of file xalome.py.

00129 
00130 def deleteShape(study,shapeStudyEntry):
00131     """
00132     This completly deletes a geom shape.
00133 
00134     WARNING: please be aware that to delete a geom object, you have
00135     three operations to perform:
00136 
00137     1. erase the shape from the viewers
00138     2. remove the entry from the study
00139     3. destroy the underlying geom object
00140     """
00141     eraseShape(shapeStudyEntry)
00142     shape = removeFromStudy(study, shapeStudyEntry)
00143     shape.Destroy()
00144     
00145 
00146 #
00147 # ======================================================================
00148 # Unit tests
00149 # ======================================================================
00150 #
00151 # To experiment this unit test, just execute this script in
00152 # SALOME. The script is self-consistent.

Here is the call graph for this function:

Here is the caller graph for this function:

def xalome.displayShape (   shapeStudyEntry,
  color = None 
)
This displays the shape specified by its entry in the study

Definition at line 98 of file xalome.py.

00098 
00099 def displayShape(shapeStudyEntry, color=None):
00100     """This displays the shape specified by its entry in the study"""
00101     geomgui = salome.ImportComponentGUI("GEOM")            
00102     geomgui.createAndDisplayFitAllGO(shapeStudyEntry)
00103     geomgui.setDisplayMode(shapeStudyEntry, DisplayMode)
00104     if color is not None:
00105         geomgui.setColor(shapeStudyEntry, color[0], color[1], color[2])

Here is the caller graph for this function:

def xalome.displayShape_version65 (   shapeStudyEntry)

Definition at line 116 of file xalome.py.

00116 
00117 def displayShape_version65(shapeStudyEntry):
00118     gst = geomtools.GeomStudyTools()
00119     gst.displayShapeByEntry(shapeStudyEntry)

def xalome.eraseShape (   shapeStudyEntry)
This erases from the viewers the shape specified by its study
entry.

Definition at line 106 of file xalome.py.

00106 
00107 def eraseShape(shapeStudyEntry):
00108     """
00109     This erases from the viewers the shape specified by its study
00110     entry.
00111     """
00112     geomgui = salome.ImportComponentGUI("GEOM")
00113     eraseFromAllWindows=True
00114     geomgui.eraseGO(shapeStudyEntry,eraseFromAllWindows)
00115 
# Available in SALOME 6.5 only

Here is the caller graph for this function:

def xalome.eraseShape_version65 (   shapeStudyEntry)

Definition at line 120 of file xalome.py.

00120 
00121 def eraseShape_version65(shapeStudyEntry):
00122     gst = geomtools.GeomStudyTools()
00123     gst.eraseShapeByEntry(shapeStudyEntry)
00124 
00125 
00126 # ======================================================================
00127 # Helper functions for a complete suppression of a shape from the
00128 # SALOME session.
# ======================================================================
def xalome.removeFromStudy (   study,
  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)

Definition at line 74 of file xalome.py.

00074 
00075 def removeFromStudy(study,shapeStudyEntry):
00076     """
00077     This removes the specified entry from the study. Note that this
00078     operation does not destroy the underlying GEOM object, neither
00079     erase the drawing in the viewer.
00080     The underlying GEOM object is returned (so that it can be destroyed)
00081     """
00082     studyId = study._get_StudyId()
00083     shape = IDToObject(shapeStudyEntry)    
00084     studyObject = IDToSObject(shapeStudyEntry)
00085     studyEditor = getStudyEditor(studyId)
00086     studyEditor.removeItem(studyObject,True)
00087     return shape
00088 
00089 
00090 # ======================================================================
00091 # Helper functions to display/erase a shape in/from the viewer. The
00092 # shape must be previously put in the study and the study entry must
00093 # be known.
00094 # ======================================================================

Here is the caller graph for this function:

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
the study, and display the shape in a viewer) and delete a shape
from a SALOME session (erase the shape from the viewer, delete the
entry from the study, and finally destroy the underlying GEOM
object).

Definition at line 153 of file xalome.py.

00153 
00154 def TEST_createAndDeleteShape():
00155     """
00156     This test is a simple use case that illustrates how to create a
00157     GEOM shape in a SALOME session (create the GEOM object, put in in
00158     the study, and display the shape in a viewer) and delete a shape
00159     from a SALOME session (erase the shape from the viewer, delete the
00160     entry from the study, and finally destroy the underlying GEOM
00161     object).
00162     """
00163     import salome
00164     salome.salome_init()
00165     study   = salome.myStudy
00166     studyId = salome.myStudyId
00167 
00168     from salome.geom import geomtools
00169     geompy = geomtools.getGeompy(studyId)
00170 
00171     # --------------------------------------------------
00172     # Create a first shape (GEOM object)
00173     radius = 5
00174     length = 100
00175     cylinder = geompy.MakeCylinderRH(radius, length)
00176 
00177     # Register the shape in the study, at the root of the GEOM
00178     # folder. A name must be specified. The register operation
00179     # (addToStudy) returns an identifier of the entry in the study.
00180     cylinderName = "cyl.r%s.l%s"%(radius,length)
00181     cylinderStudyEntry = addToStudy(study, cylinder, cylinderName)
00182 
00183     # Display the registered shape in a viewer
00184     displayShape(cylinderStudyEntry)
00185 
00186     # --------------------------------------------------
00187     # A second shape
00188     radius = 10
00189     sphere = geompy.MakeSphereR(radius)
00190     sphereName = "sph.r%s"%radius
00191     sphereStudyEntry = addToStudy(study, sphere, sphereName)
00192     displayShape(sphereStudyEntry)
00193 
00194     # --------------------------------------------------
00195     # This new shape is stored in the study, but in a specific
00196     # sub-folder, and is displayed in the viewer with a specific
00197     # color.
00198     length = 20
00199     box = geompy.MakeBoxDXDYDZ(length,length,length)
00200     boxName = "box.l%s"%length
00201     folderName = "boxset" 
00202     boxStudyEntry = addToStudy(study, box, boxName, folderName)
00203     displayShape(boxStudyEntry,PreviewColor)
00204 
00205     # --------------------------------------------------
00206     # In this example, we illustrate how to erase a shape (the sphere)
00207     # from the viewer. After this operation, the sphere is no longer
00208     # displayed but still exists in the study. You can then redisplay
00209     # it using the context menu of the SALOME object browser.
00210     eraseShape(sphereStudyEntry)
00211 
00212     # --------------------------------------------------
00213     # In this last example, we completly delete an object from the
00214     # SALOME session (erase from viewer, remove from study and finnaly
00215     # destroy the object). This is done by a simple call to
00216     # deleteShape().
00217     deleteShape(study,cylinderStudyEntry)
00218 
00219     # --------------------------------------------------
00220     # At the end of the executioon of this test, you should have in
00221     # the SALOME session:
00222     # - the box, in a dedicated folder of the study, and displayed in the viewer
00223     # - the sphere, in the standard place of the study, and not displayed 
00224 
00225     # If you comment the deleteShape line, you should see the cylinder
00226     # in the study and displayed in the viewer. 

Here is the call graph for this function:


Variable Documentation

Definition at line 96 of file xalome.py.

Definition at line 95 of file xalome.py.

list xalome.PreviewColor = [236,163,255]

Definition at line 97 of file xalome.py.