Back to index

salome-kernel  6.5.0
Functions | Variables
KERNEL_PY.batchmode_salome Namespace Reference

Functions

def ImportComponentGUI
def SalomeGUIgetAllSelected
def generateName
def IDToObject
 from SalomePyQt import * WITHOUTIHMclass SalomeGUI(SALOMEGUI_Swig): WITHOUTIHMgetAllSelected = SalomeGUIgetAllSelected
def ObjectToSObject
def ObjectToID
def IDToSObject
def PersistentPresentation
def GetTree
def CheckCopyPaste
def FindFileInDataDir

Variables

 orb = None
int step = 0
float sleeping_time = 0.01
float sleeping_time_max = 1.0
tuple lcc = LifeCycleCORBA(orb)
tuple naming_service = SALOME_NamingServicePy_i(orb)
 obj = None
tuple myStudyManager = obj._narrow(SALOMEDS.StudyManager)
tuple aListOfOpenStudies = myStudyManager.GetOpenStudies()
 myStudy = None;
list myStudyName = aListOfOpenStudies[0]
tuple myStudyId = myStudy._get_StudyId()

Function Documentation

def KERNEL_PY.batchmode_salome.CheckCopyPaste (   theSO,
  theInfo,
  theComponentPaste 
)

Definition at line 177 of file batchmode_salome.py.

00177 
00178 def CheckCopyPaste(theSO, theInfo ,theComponentPaste):
00179     aRoot = theSO
00180     while aRoot.GetID() != "0:":
00181         aRoot = aRoot.GetFather()
00182     aTree = GetTree(aRoot)
00183     aStudyPersist = PersistentPresentation(myStudy, aRoot, 1)
00184 
00185     if not myStudyManager.CanCopy(theSO):
00186         raise RuntimeError, "<CanCopy> for "+theInfo+" returns false"
00187     
00188     if not myStudyManager.Copy(theSO):
00189         raise RuntimeError, "<Copy> for "+theInfo+" returns false"
00190 
00191     
00192     if not myStudyManager.CanPaste(theSO):
00193         raise RuntimeError, "<CanPaste> for "+theInfo+" returns false"
00194 
00195     # check: before paste study is not changed check
00196     if aStudyPersist != PersistentPresentation(myStudy, aRoot, 1):
00197         raise RuntimeError, "Study is changed before Paste calling for "+theInfo
00198     
00199     aSObj = theSO
00200     if theComponentPaste:
00201         aSObj = theSO.GetFatherComponent()
00202         theInfo = theInfo + "(paste for component)"
00203     if myStudyManager.Paste(aSObj) == None:
00204         raise RuntimeError, "<Paste> for "+theInfo+" returns None object"
00205     aNewTree = GetTree(aRoot)
00206     aLen = len(aTree)
00207     for a in range(0,aLen):
00208         if aTree[a] != aNewTree[a]:
00209             return myStudy.FindObjectID(aNewTree[a])
00210         
00211     if aLen < len(aNewTree):
00212         return myStudy.FindObjectID(aNewTree[aLen])
00213     
00214     raise RuntimeError, "After Copy calling the tree is not changed"
00215     
    #--------------------------------------------------------------------------

Here is the call graph for this function:

Definition at line 216 of file batchmode_salome.py.

00216 
00217 def FindFileInDataDir(filename):
00218     import os
00219     datadir = os.getenv("DATA_DIR")
00220     if datadir is not None:
00221         import string
00222         dirs = string.split(datadir, ":")
00223         for dir in dirs:
00224             file = dir + "/" + filename
00225             if os.path.exists(file):
00226                 return file;
00227     datadir = os.getenv("KERNEL_ROOT_DIR") + "/examples/"
00228     file = datadir + filename
00229     if os.path.exists(file):
00230         return file;
00231 
00232     return None
00233         
00234 #--------------------------------------------------------------------------
# initialise the ORB
def KERNEL_PY.batchmode_salome.generateName (   prefix = None)

Definition at line 55 of file batchmode_salome.py.

00055 
00056 def generateName(prefix = None):
00057     import random;
00058     int = random.randint(1,1000);
00059     if prefix is None:
00060         return "Study" + str(int)
00061     else :
00062         return prefix + str(int)
00063 
#WITHOUTIHMfrom libSALOME_Swig import *

Definition at line 166 of file batchmode_salome.py.

00166 
00167 def GetTree(theSO):
00168     # returns the document list tree (as list)
00169     aResult = [theSO.GetID()]
00170     anIter = myStudy.NewChildIterator(theSO)
00171     while anIter.More():
00172         aResult += GetTree(anIter.Value())
00173         anIter.Next()
00174     return aResult
00175 
00176     #--------------------------------------------------------------------------

Here is the caller graph for this function:

from SalomePyQt import * WITHOUTIHMclass SalomeGUI(SALOMEGUI_Swig): WITHOUTIHMgetAllSelected = SalomeGUIgetAllSelected

Definition at line 78 of file batchmode_salome.py.

00078 
00079 def IDToObject(id):
00080     myObj = None
00081     mySO = myStudy.FindObjectID(id);
00082     if mySO is not None:
00083         ok, anAttr = mySO.FindAttribute("AttributeIOR")
00084         if ok:
00085             AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
00086             if AtIOR.Value() != "":
00087                 myObj = orb.string_to_object(AtIOR.Value())
00088     return myObj

Definition at line 103 of file batchmode_salome.py.

00103 
00104 def IDToSObject(id):
00105     mySO = myStudy.FindObjectID(id);
00106     return mySO
00107 
00108     #--------------------------------------------------------------------------

Definition at line 36 of file batchmode_salome.py.

00036 
00037 def ImportComponentGUI(ComponentName):
00038     libName = "lib" + ComponentName + "_Swig"
00039     command = "from " + libName + " import *"
00040     exec ( command )
00041     constructor = ComponentName + "GUI_Swig()"
00042     command = "gui = " + constructor
00043     exec ( command )
00044     return gui
00045 
00046     #--------------------------------------------------------------------------

Definition at line 97 of file batchmode_salome.py.

00097 
00098 def ObjectToID(obj):
00099     mySO = ObjectToSObject(obj)
00100     if mySO:
00101         return mySO.GetID()
00102     return ""

Here is the call graph for this function:

Definition at line 89 of file batchmode_salome.py.

00089 
00090 def ObjectToSObject(obj):
00091     mySO = None
00092     if obj is not None:
00093         ior =  orb.object_to_string(obj)
00094         if ior != "":
00095             mySO = myStudy.FindObjectIOR(ior)
00096     return mySO

Here is the caller graph for this function:

def KERNEL_PY.batchmode_salome.PersistentPresentation (   theStudy,
  theSO,
  theWithID 
)

Definition at line 109 of file batchmode_salome.py.

00109 
00110 def PersistentPresentation(theStudy, theSO, theWithID):
00111     # put the sobject's content (with subchildren) to the string
00112     aResult = ""
00113     attrs = theSO.GetAllAttributes()
00114     aLen = len(attrs)
00115     anUncopied = 0
00116     for a in range(0,aLen):
00117         attr = attrs[a]
00118         if isinstance(attr,SALOMEDS._objref_AttributeTreeNode):
00119             anUncopied += 1
00120         elif isinstance(attr,SALOMEDS._objref_AttributeTarget):
00121             anUncopied += 1
00122         elif isinstance(attr,SALOMEDS._objref_AttributeReal) or \
00123              isinstance(attr,SALOMEDS._objref_AttributeInteger) or \
00124              isinstance(attr,SALOMEDS._objref_AttributeName) or \
00125              isinstance(attr,SALOMEDS._objref_AttributeComment) or \
00126              isinstance(attr,SALOMEDS._objref_AttributePersistentRef) or \
00127              isinstance(attr,SALOMEDS._objref_AttributeLocalID) or \
00128              isinstance(attr,SALOMEDS._objref_AttributeUserID):
00129             aResult += " attribute value: " + str(attr.Value())
00130         elif isinstance(attr,SALOMEDS._objref_AttributeIOR):
00131             aResult += " attribute: IOR"
00132         elif isinstance(attr,SALOMEDS._objref_AttributeSequenceOfReal) or \
00133              isinstance(attr,SALOMEDS._objref_AttributeSequenceOfInteger):
00134             aResult += " Sequence: " + str(attr.CorbaSequence())
00135         elif isinstance(attr,SALOMEDS._objref_AttributeDrawable):
00136             aResult += " Drawable: " + str(attr.IsDrawable())
00137         elif isinstance(attr,SALOMEDS._objref_AttributeSelectable):
00138             aResult += " Selectable: " + str(attr.IsSelectable())
00139         elif isinstance(attr,SALOMEDS._objref_AttributeExpandable):
00140             aResult += " Expandable: " + str(attr.IsExpandable())
00141         elif isinstance(attr,SALOMEDS._objref_AttributeOpened):
00142             aResult += " Opened: " + str(attr.IsOpened())
00143         elif isinstance(attr,SALOMEDS._objref_AttributeTextColor):
00144             aResult += " TextColor: " + str(attr.TextColor())
00145         elif isinstance(attr,SALOMEDS._objref_AttributeTextHighlightColor):
00146             aResult += " TextHighlightColor: " + str(attr.TextHighlightColor())
00147         elif isinstance(attr,SALOMEDS._objref_AttributePixMap):
00148             aResult += " PixMap: " + str(attr.GetPixMap())
00149         elif isinstance(attr,SALOMEDS._objref_AttributeTableOfInteger) or \
00150              isinstance(attr,SALOMEDS._objref_AttributeTableOfReal):
00151             aResult += " Table with title: " + attr.GetTitle()
00152         elif isinstance(attr,SALOMEDS._objref_AttributePythonObject):
00153             aResult += " PythonObject: " + attr.GetObject()
00154 
00155     if theWithID:
00156         aResult = "sobject: " + theSO.GetID() + " nbattrs: " + str(aLen - anUncopied) + aResult + '\n'
00157     else:
00158         aResult = " nbattrs: " + str(aLen - anUncopied) + aResult + '\n'
00159     anIter = theStudy.NewChildIterator(theSO)
00160     while anIter.More():
00161         aResult += PersistentPresentation(theStudy, anIter.Value(), theWithID)
00162         anIter.Next()
00163     return aResult
00164 
00165     #--------------------------------------------------------------------------

Here is the caller graph for this function:

Definition at line 47 of file batchmode_salome.py.

00047 
00048 def SalomeGUIgetAllSelected(self):
00049     selNumber = self.SelectedCount()
00050     listSelected = []
00051     for i in range(selNumber):
00052         listSelected.append(self.getSelected(i))
00053     return listSelected
00054     #--------------------------------------------------------------------------


Variable Documentation

tuple KERNEL_PY.batchmode_salome.aListOfOpenStudies = myStudyManager.GetOpenStudies()

Definition at line 294 of file batchmode_salome.py.

Definition at line 253 of file batchmode_salome.py.

Definition at line 295 of file batchmode_salome.py.

tuple KERNEL_PY.batchmode_salome.myStudyId = myStudy._get_StudyId()

Definition at line 304 of file batchmode_salome.py.

Definition at line 288 of file batchmode_salome.py.

Definition at line 299 of file batchmode_salome.py.

Definition at line 271 of file batchmode_salome.py.

Definition at line 274 of file batchmode_salome.py.

Definition at line 235 of file batchmode_salome.py.

Definition at line 238 of file batchmode_salome.py.

Definition at line 239 of file batchmode_salome.py.

Definition at line 237 of file batchmode_salome.py.