Version: 8.3.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
studyedit.StudyEditor Class Reference

This class provides utility methods to complement Study and StudyBuilder classes. More...

Public Member Functions

def __init__
 
def findOrCreateComponent
 Find a component corresponding to the Salome module moduleName in the study. More...
 
def loadComponentEngine
 Load the engine corresponding to sComponent in the container containerName, associate the engine with the component and load the CORBA objects of this component in the study. More...
 
def getOrLoadObject
 Get the CORBA object associated with the SObject item, eventually by first loading it with the corresponding engine. More...
 
def findOrCreateItem
 Find an object under fatherItem in the study with the given attributes. More...
 
def findItem
 Find an item with given attributes under fatherItem in the study. More...
 
def createItem
 Create a new object named name under fatherItem in the study, with the given attributes. More...
 
def setItem
 Modify the attributes of an item in the study. More...
 
def removeItem
 Remove the given item from the study. More...
 
def setItemAtTag
 Find an item tagged tag under fatherItem in the study tree or create it if there is none, then set its attributes. More...
 
def getName
 Return the name of the object sObject. More...
 
def setName
 Set the name of the object sObject. More...
 
def getComment
 Return the comment of the object sObject. More...
 
def setComment
 Set the comment of the object sObject. More...
 
def getAttributeValue
 Return the value of the attribute named attributeName on the object sObject, or default if the attribute doesn't exist. More...
 
def setAttributeValue
 Set the value of the attribute named attributeName on the object sObject to the value attributeValue. More...
 
def getTypeId
 Return the value of the attribute "AttributeLocalID" of the object sObject, or None if it is not set. More...
 
def setTypeId
 Set the attribute "AttributeLocalID" of the object sObject to the value value. More...
 
def getFileType
 Return the value of the attribute "AttributeFileType" of the object sObject, or an empty string if it is not set. More...
 
def setFileType
 Set the attribute "AttributeFileType" of the object sObject to the value value. More...
 
def getFileName
 Return the value of the attribute "AttributeExternalFileDef" of the object sObject, or an empty string if it is not set. More...
 
def setFileName
 Set the attribute "AttributeExternalFileDef" of the object sObject to the value value. More...
 
def getIcon
 Return the value of the attribute "AttributePixMap" of the object sObject, or an empty string if it is not set. More...
 
def setIcon
 Set the attribute "AttributePixMap" of the object sObject to the value value. More...
 

Data Fields

 studyId
 
 study
 
 builder
 

Detailed Description

This class provides utility methods to complement Study and StudyBuilder classes.

Those methods may be moved in those classes in the future. The parameter studyId defines the ID of the study to edit. If it is None, the edited study will be the current study. The preferred way to get a StudyEditor object is through the method getStudyEditor which allows to reuse existing instances.

Parameters
studyIdThis instance attribute contains the ID of the edited study. This attribute should not be modified.
studyThis instance attribute contains the underlying Study object. It can be used to access the study but the attribute itself should not be modified.
builderThis instance attribute contains the underlying StudyBuilder object. It can be used to edit the study but the attribute itself should not be modified.

Member Function Documentation

def studyedit.StudyEditor.findOrCreateComponent (   self,
  moduleName,
  componentName = None,
  icon = None,
  containerName = _DEFAULT_CONTAINER 
)

Find a component corresponding to the Salome module moduleName in the study.

If none is found, create a new component and associate it with the corresponding engine (i.e. the engine named moduleName). Note that in Salome 5, the module name and engine name must be identical (every module must provide an engine with the same name). In Salome 6 it will be possible to define a different name for the engine.

Parameters
moduleName(string) name of the module corresponding to the component (the module name is the string value in the attribute "AttributeComment" of the component)
componentName(string) name of the new component if created. If None, use moduleName instead.
icon(string) icon for the new component (attribute "AttributePixMap").
containerName(string) name of the container in which the engine should be loaded.
Returns
the SComponent found or created.
def studyedit.StudyEditor.loadComponentEngine (   self,
  sComponent,
  containerName = _DEFAULT_CONTAINER 
)

Load the engine corresponding to sComponent in the container containerName, associate the engine with the component and load the CORBA objects of this component in the study.

def studyedit.StudyEditor.getOrLoadObject (   self,
  item 
)

Get the CORBA object associated with the SObject item, eventually by first loading it with the corresponding engine.

def studyedit.StudyEditor.findOrCreateItem (   self,
  fatherItem,
  name,
  fileType = None,
  fileName = None,
  comment = None,
  icon = None,
  IOR = None,
  typeId = None 
)

Find an object under fatherItem in the study with the given attributes.

Return the first one found if at least one exists, otherwise create a new one with the given attributes and return it.

See setItem() for the description of the parameters.

def studyedit.StudyEditor.findItem (   self,
  fatherItem,
  name = None,
  fileType = None,
  fileName = None,
  comment = None,
  icon = None,
  IOR = None,
  typeId = None 
)

Find an item with given attributes under fatherItem in the study.

If none is found, return None. If several items correspond to the parameters, only the first one is returned. The search is made only on given parameters (i.e. not None). To look explicitly for an empty attribute, use an empty string in the corresponding parameter.

See setItem() for the description of the parameters.

def studyedit.StudyEditor.createItem (   self,
  fatherItem,
  name,
  fileType = None,
  fileName = None,
  comment = None,
  icon = None,
  IOR = None,
  typeId = None 
)

Create a new object named name under fatherItem in the study, with the given attributes.

If an object named name already exists under the father object, the new object is created with a new name name_X where X is the first available index.

param fatherItem (SObject) item under which the new item will be added.

Returns
new SObject created in the study.

See setItem() for the description of the other parameters.

def studyedit.StudyEditor.setItem (   self,
  item,
  name = None,
  fileType = None,
  fileName = None,
  comment = None,
  icon = None,
  IOR = None,
  typeId = None 
)

Modify the attributes of an item in the study.

Unspecified attributes (i.e. those set to None) are left unchanged.

Parameters
item(SObject) item to modify.
name(string or unicode) item name (attribute AttributeName).
fileType(string or unicode) item file type (attribute AttributeFileType).
fileName(string or unicode) item file name (attribute AttributeExternalFileDef).
comment(string or unicode) item comment (attribute AttributeComment). Note that this attribute will appear in the Value column in the object browser.
icon(string or unicode) item icon name (attribute AttributePixMap).
IOR(string) IOR of a CORBA object associated with the item (attribute AttributeIOR).
typeId(integer) item type (attribute AttributeLocalID).
def studyedit.StudyEditor.removeItem (   self,
  item,
  withChildren = False 
)

Remove the given item from the study.

Note that the items are never really deleted. They just don't appear in the study anymore.

Parameters
item(SObject) the item to be removed
withChildren(boolean) if True, also remove the children of item
Returns
True if the item was removed successfully, or False if an error happened.
def studyedit.StudyEditor.setItemAtTag (   self,
  fatherItem,
  tag,
  name = None,
  fileType = None,
  fileName = None,
  comment = None,
  icon = None,
  IOR = None,
  typeId = None 
)

Find an item tagged tag under fatherItem in the study tree or create it if there is none, then set its attributes.

Parameters
fatherItem(SObject) item under which the tagged item will be looked for and eventually created.
taginteger) tag of the item to look for.
Returns
the SObject at tag if found or created successfully, or None if an error happened.

See setItem() for the description of the other parameters.

def studyedit.StudyEditor.getName (   self,
  sObject 
)

Return the name of the object sObject.

def studyedit.StudyEditor.setName (   self,
  sObject,
  name 
)

Set the name of the object sObject.

def studyedit.StudyEditor.getComment (   self,
  sObject 
)

Return the comment of the object sObject.

def studyedit.StudyEditor.setComment (   self,
  sObject,
  comment 
)

Set the comment of the object sObject.

def studyedit.StudyEditor.getAttributeValue (   self,
  sObject,
  attributeName,
  default = None 
)

Return the value of the attribute named attributeName on the object sObject, or default if the attribute doesn't exist.

def studyedit.StudyEditor.setAttributeValue (   self,
  sObject,
  attributeName,
  attributeValue 
)

Set the value of the attribute named attributeName on the object sObject to the value attributeValue.

def studyedit.StudyEditor.getTypeId (   self,
  sObject 
)

Return the value of the attribute "AttributeLocalID" of the object sObject, or None if it is not set.

def studyedit.StudyEditor.setTypeId (   self,
  sObject,
  value 
)

Set the attribute "AttributeLocalID" of the object sObject to the value value.

def studyedit.StudyEditor.getFileType (   self,
  sObject 
)

Return the value of the attribute "AttributeFileType" of the object sObject, or an empty string if it is not set.

def studyedit.StudyEditor.setFileType (   self,
  sObject,
  value 
)

Set the attribute "AttributeFileType" of the object sObject to the value value.

def studyedit.StudyEditor.getFileName (   self,
  sObject 
)

Return the value of the attribute "AttributeExternalFileDef" of the object sObject, or an empty string if it is not set.

def studyedit.StudyEditor.setFileName (   self,
  sObject,
  value 
)

Set the attribute "AttributeExternalFileDef" of the object sObject to the value value.

def studyedit.StudyEditor.getIcon (   self,
  sObject 
)

Return the value of the attribute "AttributePixMap" of the object sObject, or an empty string if it is not set.

def studyedit.StudyEditor.setIcon (   self,
  sObject,
  value 
)

Set the attribute "AttributePixMap" of the object sObject to the value value.