--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Help.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+class SalomeDoc:
+ def __init__(self, aDoc):
+ self.doc = aDoc
+ def __repr__(self):
+ print self.doc
+ return "---"
+ def salome(self):
+ doc_salome = '''
+MODULE : salome
+---------------
+module salome gives access to Salome ressources:
+variables:
+
+ salome:orb : CORBA
+ salome.naming_service : instance of naming Service class
+ methods:
+ Resolve(name) : find a CORBA object (ior) by its pathname
+ Register(name) : register a CORBA object under a pathname
+ salome.lcc : instance of lifeCycleCORBA class
+ methods:
+ FindOrLoadComponent(server,name) :
+ obtain an Engine (CORBA object)
+ or launch the Engine if not found,
+ with a Server name and an Engine name
+ salome.sg
+ methods:
+ updateObjBrowser(bool):
+ getActiveStudyId():
+ getActiveStudyName():
+
+ SelectedCount(): returns number of selected objects
+ getSelected(i): returns entry of selected object number i
+ getAllSelected(): returns list of entry of selected objects
+ AddIObject(Entry): select an existing Interactive object
+ RemoveIObject(Entry): remove object from selection
+ ClearIObjects(): clear selection
+
+ Display(*Entry):
+ DisplayOnly(Entry):
+ Erase(Entry):
+ DisplayAll():
+ EraseAll():
+
+ IDToObject(Entry): returns CORBA reference from entry
+
+ salome.myStudyName : active Study Name
+ salome.myStudyId : active Study Id
+ salome.myStudy : the active Study itself (CORBA ior)
+ methods : defined in SALOMEDS.idl
+
+methods:
+ salome.DumpStudy(study) : Dump a study, given the ior
+---
+'''
+ print doc_salome
+
+ def geompy(self):
+ doc_geompy = '''
+MODULE : geompy
+---------------
+module geompy provides an encapsulation of GEOM Engine methods
+variables:
+ geompy.geom : a Geometry Engine, found or loaded
+ at first import of module geompy.
+ methods : defined in GEOM_Gen.idl
+ geompy.myBuilder : a study builder
+ geompy.father : GEOM root in current study (salome.myStudy)
+
+methods:
+ addToStudy(aShape, aName) : add the shape into the current study
+ --- all methods of GEOM_Gen.idl that returns a shape are encapsulated,
+ with the same interface : shapes are named with their ior
+'''
+ print doc_geompy
+
+ def supervision(self):
+ doc_supervision = '''
+MODULES : SALOME_SuperVisionEditor and SALOME_SuperVisionExecutor
+-----------------------------------------------------------------
+this modules provide access to Editor and Executor Engine methods
+
+See SUPERV.idl
+
+In order to run the example (supervisionexample.py)
+
+ Type : from supervisionexample import *
+ supervisionexample.py contains comments
+
+A new python example avoids references to LifeCycleCORBA
+ avoids references to NamingService
+ avoids references to ModuleCatalog
+ avoids SuperVisionComponent creation
+ allows G.Input(...) instead of AddInput(G,...)
+ replaces Editor/Executor with Graph
+ allows Nodes, Ports and Links CORBA objects
+ shortens methods names
+ ...
+
+ See /SuperVisionTest/resources/GraphExample.py
+ and GraphExample.xml
+---
+'''
+ print doc_supervision
+
+
+
+help = SalomeDoc('''
+Availables modules:
+ salome : gives access to Salome ressources
+ geompy : encapsulation of GEOM Engine methods
+ supervision : gives access to SuperVision Engine
+To obtain specific help on a module "truc", type: help.truc()
+To run an example, type: import example3
+''')
+
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+# Libraries targets
+
+#LIB = libSALOME_Swigcmodule.la
+LIB_SRC =
+
+#SWIG_DEF = libSALOME_Swig.i
+EXPORT_PYSCRIPTS = Help.py PyInterp.py salome.py examplevtk1.py supervisionexample.py supervisiongeomexample.py salome_shared_modules.py batchmode_salome.py test_table.py test_big_table.py test_many_objects.py import_hook.py salome_test.py
+
+EXPORT_SHAREDPYSCRIPTS=kernel_shared_modules.py
+
+#LIB_CLIENT_IDL = SALOMEDS.idl \
+ #SALOME_Exception.idl
+
+#CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H
+#LIBS+= $(PYTHON_LIBS)
+#LDFLAGS+= -lSalomeGUI
+
+@CONCLUDE@
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : PyInterp.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+import sys
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+import SALOMEDS
+from SALOME_NamingServicePy import *
+
+ #--------------------------------------------------------------------------
+
+def DumpComponent(Study, SO, offset):
+ it = Study.NewChildIterator(SO)
+ Builder = Study.NewBuilder()
+ while it.More():
+ CSO = it.Value()
+ it.Next()
+ anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
+ AtName = anAttr._narrow(SALOMEDS.AttributeName)
+ t_name = AtName.Value()
+ if t_name[0] == 1:
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + "--"
+ ofs = ofs +1
+ print a + ">" + CSO.GetID() + " " + t_name[1]
+ t_RefSO = CSO.ReferencedObject()
+ if t_RefSO[0] == 1:
+ RefSO = t_RefSO[1]
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + " "
+ ofs = ofs +1
+ print a + ">" + RefSO.GetID()
+ DumpComponent(Study, CSO, offset+2)
+
+ #--------------------------------------------------------------------------
+
+def DumpStudy(Study):
+ itcomp = Study.NewComponentIterator()
+ while itcomp.More():
+ SC = itcomp.Value()
+ itcomp.Next()
+ name = SC.ComponentDataType()
+ print "-> ComponentDataType is " + name
+ DumpComponent(Study, SC, 1)
+
+
+ #--------------------------------------------------------------------------
+
+# initialise the ORB
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+
+# create an LifeCycleCORBA instance
+lcc = LifeCycleCORBA(orb)
+
+# create an SALOMEGUI_Swig instance
+sg = SALOMEGUI_Swig()
+
+#create an naming service instance
+naming_service = SALOME_NamingServicePy_i(orb)
+
+# get active study name and id
+myStudyName = sg.getActiveStudyName()
+print myStudyName
+
+myStudyId = sg.getActiveStudyId()
+print myStudyId
+
+# get Study Manager reference
+obj = naming_service.Resolve('myStudyManager')
+myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+
+# get active study
+myStudy = myStudyManager.GetStudyByName(myStudyName)
--- /dev/null
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : batchmode_salome.py
+# Module : SALOME
+
+import salome_shared_modules
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+import SALOMEDS
+from SALOME_NamingServicePy import *
+
+#--------------------------------------------------------------------------
+
+def ImportComponentGUI(ComponentName):
+ libName = "lib" + ComponentName + "_Swig"
+ command = "from " + libName + " import *"
+ exec ( command )
+ constructor = ComponentName + "GUI_Swig()"
+ command = "gui = " + constructor
+ exec ( command )
+ return gui
+
+ #--------------------------------------------------------------------------
+
+def SalomeGUIgetAllSelected(self):
+ selNumber = self.SelectedCount()
+ listSelected = []
+ for i in range(selNumber):
+ listSelected.append(self.getSelected(i))
+ return listSelected
+ #--------------------------------------------------------------------------
+
+def generateName(prefix = None):
+ import whrandom;
+ int = whrandom.randint(1,1000);
+ if prefix is None:
+ return "Study" + str(int)
+ else :
+ return prefix + str(int)
+
+#WITHOUTIHMfrom libSALOME_Swig import *
+###from SalomePyQt import *
+#WITHOUTIHMclass SalomeGUI(SALOMEGUI_Swig):
+ #WITHOUTIHMgetAllSelected = SalomeGUIgetAllSelected
+
+ #WITHOUTIHMdef getDesktop(self) :
+# return SalomePyQt.getDesktop()
+ #WITHOUTIHMreturn None
+
+ #WITHOUTIHMdef getSelection(self) :
+# return SalomePyQt.getSelection()
+ #WITHOUTIHMreturn None
+
+ #--------------------------------------------------------------------------
+
+def IDToObject(id):
+ myObj = None
+ mySO = myStudy.FindObjectID(id);
+ if mySO is not None:
+ ok, anAttr = mySO.FindAttribute("AttributeIOR")
+ if ok:
+ AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
+ if AtIOR.Value() != "":
+ myObj = orb.string_to_object(AtIOR.Value())
+ return myObj
+
+def ObjectToSObject(obj):
+ mySO = None
+ if obj is not None:
+ ior = orb.object_to_string(obj)
+ if ior != "":
+ mySO = myStudy.FindObjectIOR(ior)
+ return mySO
+
+def ObjectToID(obj):
+ mySO = ObjectToSObject(obj)
+ if mySO:
+ return mySO.GetID()
+ return ""
+
+def IDToSObject(id):
+ mySO = myStudy.FindObjectID(id);
+ return mySO
+
+ #--------------------------------------------------------------------------
+
+def PersistentPresentation(theStudy, theSO, theWithID):
+ # put the sobject's content (with subchildren) to the string
+ aResult = ""
+ attrs = theSO.GetAllAttributes()
+ aLen = len(attrs)
+ anUncopied = 0
+ for a in range(0,aLen):
+ attr = attrs[a]
+ if isinstance(attr,SALOMEDS._objref_AttributeTreeNode):
+ anUncopied += 1
+ elif isinstance(attr,SALOMEDS._objref_AttributeTarget):
+ anUncopied += 1
+ elif isinstance(attr,SALOMEDS._objref_AttributeReal) or \
+ isinstance(attr,SALOMEDS._objref_AttributeInteger) or \
+ isinstance(attr,SALOMEDS._objref_AttributeName) or \
+ isinstance(attr,SALOMEDS._objref_AttributeComment) or \
+ isinstance(attr,SALOMEDS._objref_AttributePersistentRef) or \
+ isinstance(attr,SALOMEDS._objref_AttributeLocalID) or \
+ isinstance(attr,SALOMEDS._objref_AttributeUserID):
+ aResult += " attribute value: " + str(attr.Value())
+ elif isinstance(attr,SALOMEDS._objref_AttributeIOR):
+ aResult += " attribute: IOR"
+ elif isinstance(attr,SALOMEDS._objref_AttributeSequenceOfReal) or \
+ isinstance(attr,SALOMEDS._objref_AttributeSequenceOfInteger):
+ aResult += " Sequence: " + str(attr.CorbaSequence())
+ elif isinstance(attr,SALOMEDS._objref_AttributeDrawable):
+ aResult += " Drawable: " + str(attr.IsDrawable())
+ elif isinstance(attr,SALOMEDS._objref_AttributeSelectable):
+ aResult += " Selectable: " + str(attr.IsSelectable())
+ elif isinstance(attr,SALOMEDS._objref_AttributeExpandable):
+ aResult += " Expandable: " + str(attr.IsExpandable())
+ elif isinstance(attr,SALOMEDS._objref_AttributeOpened):
+ aResult += " Opened: " + str(attr.IsOpened())
+ elif isinstance(attr,SALOMEDS._objref_AttributeTextColor):
+ aResult += " TextColor: " + str(attr.TextColor())
+ elif isinstance(attr,SALOMEDS._objref_AttributeTextHighlightColor):
+ aResult += " TextHighlightColor: " + str(attr.TextHighlightColor())
+ elif isinstance(attr,SALOMEDS._objref_AttributePixMap):
+ aResult += " PixMap: " + str(attr.GetPixMap())
+ elif isinstance(attr,SALOMEDS._objref_AttributeTableOfInteger) or \
+ isinstance(attr,SALOMEDS._objref_AttributeTableOfReal):
+ aResult += " Table with title: " + attr.GetTitle()
+ elif isinstance(attr,SALOMEDS._objref_AttributePythonObject):
+ aResult += " PythonObject: " + attr.GetObject()
+
+ if theWithID:
+ aResult = "sobject: " + theSO.GetID() + " nbattrs: " + str(aLen - anUncopied) + aResult + '\n'
+ else:
+ aResult = " nbattrs: " + str(aLen - anUncopied) + aResult + '\n'
+ anIter = theStudy.NewChildIterator(theSO)
+ while anIter.More():
+ aResult += PersistentPresentation(theStudy, anIter.Value(), theWithID)
+ anIter.Next()
+ return aResult
+
+ #--------------------------------------------------------------------------
+
+def GetTree(theSO):
+ # returns the document list tree (as list)
+ aResult = [theSO.GetID()]
+ anIter = myStudy.NewChildIterator(theSO)
+ while anIter.More():
+ aResult += GetTree(anIter.Value())
+ anIter.Next()
+ return aResult
+
+ #--------------------------------------------------------------------------
+
+def CheckCopyPaste(theSO, theInfo ,theComponentPaste):
+ aRoot = theSO
+ while aRoot.GetID() != "0:":
+ aRoot = aRoot.GetFather()
+ aTree = GetTree(aRoot)
+ aStudyPersist = PersistentPresentation(myStudy, aRoot, 1)
+
+ if not myStudyManager.CanCopy(theSO):
+ raise RuntimeError, "<CanCopy> for "+theInfo+" returns false"
+
+ if not myStudyManager.Copy(theSO):
+ raise RuntimeError, "<Copy> for "+theInfo+" returns false"
+
+
+ if not myStudyManager.CanPaste(theSO):
+ raise RuntimeError, "<CanPaste> for "+theInfo+" returns false"
+
+ # check: before paste study is not changed check
+ if aStudyPersist != PersistentPresentation(myStudy, aRoot, 1):
+ raise RuntimeError, "Study is changed before Paste calling for "+theInfo
+
+ aSObj = theSO
+ if theComponentPaste:
+ aSObj = theSO.GetFatherComponent()
+ theInfo = theInfo + "(paste for component)"
+ if myStudyManager.Paste(aSObj) == None:
+ raise RuntimeError, "<Paste> for "+theInfo+" returns None object"
+ aNewTree = GetTree(aRoot)
+ aLen = len(aTree)
+ for a in range(0,aLen):
+ if aTree[a] != aNewTree[a]:
+ return myStudy.FindObjectID(aNewTree[a])
+
+ if aLen < len(aNewTree):
+ return myStudy.FindObjectID(aNewTree[aLen])
+
+ raise RuntimeError, "After Copy calling the tree is not changed"
+
+ #--------------------------------------------------------------------------
+def FindFileInDataDir(filename):
+ import os
+ datadir = os.getenv("DATA_DIR")
+ if datadir is not None:
+ import string
+ dirs = string.split(datadir, ":")
+ for dir in dirs:
+ file = dir + "/" + filename
+ if os.path.exists(file):
+ return file;
+ datadir = os.getenv("KERNEL_ROOT_DIR") + "/examples/"
+ file = datadir + filename
+ if os.path.exists(file):
+ return file;
+
+ return None
+
+#--------------------------------------------------------------------------
+# initialise the ORB
+orb = None
+
+step = 0
+while step < 100 and orb is None:
+ orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+ step = step + 1
+ time.sleep(4)
+
+if orb is None:
+ print "Warning: ORB has not been initialized !!!"
+
+# create an LifeCycleCORBA instance
+lcc = LifeCycleCORBA(orb)
+
+step = 0
+while step < 100 and lcc._catalog is None:
+ lcc = LifeCycleCORBA(orb)
+ step = step + 1
+ time.sleep(4)
+
+if lcc._catalog is None:
+ print "Warning: LifeCycleCORBA object is incomplete !!!"
+
+#create a naming service instance
+naming_service = SALOME_NamingServicePy_i(orb)
+
+# get Study Manager reference
+obj = None
+
+step = 0
+while step < 100 and obj == None:
+ obj = naming_service.Resolve('myStudyManager')
+ step = step + 1
+ time.sleep(4)
+
+myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+
+if myStudyManager is None:
+ print "Warning: SALOMEDS.StudyManager has not been created !!!"
+
+# create new study
+aListOfOpenStudies = myStudyManager.GetOpenStudies();
+myStudy = None;
+if len(aListOfOpenStudies) == 0 :
+ myStudy = myStudyManager.NewStudy("Study1")
+else:
+ myStudyName = aListOfOpenStudies[0]
+ myStudy = myStudyManager.GetStudyByName(myStudyName)
+
+myStudyName = myStudy._get_Name()
+
+myStudyId = myStudy._get_StudyId()
+print myStudyId
+
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : examplevtk1.py
+# Module : SALOME
+
+import libSalomePy
+ren=libSalomePy.renderer
+#iren=libSalomePy.interactor
+
+from libVTKCommonPython import *
+from libVTKGraphicsPython import *
+cone = vtkConeSource()
+cone.SetResolution(8)
+coneMapper = vtkPolyDataMapper()
+coneMapper.SetInput(cone.GetOutput())
+coneActor = vtkActor()
+coneActor.SetMapper(coneMapper)
+
+ren.AddActor(coneActor)
+iren = vtkRenderWindowInteractor()
+
--- /dev/null
+"""
+This module replaces the standard import mechanism with one
+that filters some imports that can't be done more than once.
+
+This is related to the multi study feature that is implemented
+by using the Python multi interpreter feature.
+Some modules register objects or classes by calling modules
+implemented in C. These operations can't be done multiple times.
+So it's very important to control these imports.
+
+Examples:
+ - PyQt : import qt calls a C module to register classes
+ - OmniORB : import *_idl calls a C module to register CORBA interfaces
+
+Usage:
+ - First import the module : import import_hook. This module will
+ replace the original importer mechanism
+
+ - Next register the module names or pattern names to filter out::
+ import_hook.register_name("a")
+ import_hook.register_pattern(pattern)
+
+ where pattern is a function with one parameter, the module name
+ to be imported, that returns true or false depending if this module is
+ to be filtered or not.
+
+ - Then it's done
+
+IMPORTANT : Every subinterpretor has its own import_hook module. import_hook is not shared among subinterpretors.
+The mechanism only works if shared_imported and pattern are shared between all subinterpretors.
+This is done by calling init_shared_modules().
+
+"""
+import sys, imp, __builtin__
+
+# Keep in shared_imported a copy of dictionnary modules
+# that need to be imported only once in multi-study context
+shared_imported={}
+
+# patterns contains functions that returns 1 or 0 depending if
+# the module name (argument) must be filtered out or not
+# These functions are added by calling register_pattern
+patterns=[]
+
+original_import=__builtin__.__import__
+
+def register_name(name):
+ if shared_imported.has_key(name):return
+ shared_imported[name]=None
+
+def register_pattern(pattern):
+ patterns.append(pattern)
+
+def is_shared(name):
+ if shared_imported.has_key(name):return 1
+ for pattern in patterns:
+ if pattern(name) : return 1
+ return 0
+
+def get_shared_imported(name):
+ return shared_imported.get(name)
+def set_shared_imported(name,module):
+ shared_imported[name]=module
+ #print "Module %s shared registered" % name
+
+def get_shared_imported_with_copy(name):
+ module_dict= shared_imported.get(name)
+ m=imp.new_module(name)
+ m.__dict__.update(module_dict)
+ return m
+def set_shared_imported_with_copy(name,module):
+ shared_imported[name]=module.__dict__.copy()
+ #print "Module %s shared registered" % name
+
+def import_hook(name, globals=None, locals=None, fromlist=None):
+ module=get_shared_imported(name)
+ if module:
+ sys.modules[name]=module
+ return module
+
+ module= original_import(name, globals, locals, fromlist)
+
+ if is_shared(name):
+ set_shared_imported(name,module)
+ return module
+
+original_reload=__builtin__.reload
+
+def reload_hook(module):
+ if is_shared(module.__name__):
+ return module
+ return original_reload(module)
+
+__builtin__.__import__=import_hook
+# Reload is not replaced
+#__builtin__.reload=reload_hook
+
+def init_shared_modules(shared_module):
+ global shared_imported, patterns
+ shared_imported=shared_module.shared_imported
+ patterns= shared_module.patterns
+ shared_imported["salome_shared_modules"]=shared_module
+ import salome_shared_modules
+ for m in salome_shared_modules.list_modules:
+ m.init_shared_modules()
--- /dev/null
+"""
+
+"""
+import glob,os,sys
+
+import import_hook
+from import_hook import register_name
+from import_hook import register_pattern
+
+register_name("qt")
+register_pattern(lambda(x):x.endswith("_idl"))
+
+register_name("omniORB")
+register_name("CosNaming")
+
+register_name("Engines")
+register_name("SALOME")
+register_name("SALOMEDS")
+register_name("SALOME_ModuleCatalog")
+
+# BE CAREFUL
+# Engines, SALOME, SALOMEDS must be imported in that order because :
+# Engines imports SALOME_Component_idl
+# SALOME imports SALOME_Session_idl and SALOME_Exception_idl which imports SALOME_Component_idl
+# and SALOMEDS imports SALOMEDS_idl and SALOMEDS_Attributes_idl which imports SALOME_Exception_idl
+# If SALOME is imported before Engines, that module would not be completely imported
+import Engines
+import SALOME
+import SALOMEDS
+
+import SALOME_ModuleCatalog
+from SALOME_utilities import MESSAGE
+#
+# We search all Python CORBA (omniorb) modules.
+# A Python CORBA module has 2 associated Python packages
+# These packages are named : <module_name> and <module_name>__POA
+#
+# Get the SALOMEPATH if set or else use KERNEL_ROOT_DIR that should be set.
+salome_path=os.environ.get("SALOMEPATH",os.getenv("KERNEL_ROOT_DIR"))
+
+# Register all CORBA modules in the path and python modules in shared_modules
+path=salome_path.split(":")
+#
+for rep in path:
+ rep_salome=os.path.join(rep,"lib","python"+sys.version[:3],"site-packages","salome")
+ # Find all the *__POA packages in the path
+ for elem in glob.glob(os.path.join(rep_salome,"*__POA")):
+ if os.path.isdir(elem):
+ # Found a directory (Python package) named *__POA
+ module__POA=os.path.basename(elem)
+ module=module__POA[:-5]
+ MESSAGE( "Register CORBA module: " + module + ". Directory: " + os.path.abspath(elem)[:-5] )
+ register_name(module)
+
+ # Now we import modules found in shared_modules directory
+ for elem in glob.glob(os.path.join(rep_salome,"shared_modules","*.py")):
+ module=os.path.basename(elem)[:-3]
+ MESSAGE( "Register Python module: " + module + ". Location: " + os.path.abspath(elem) )
+ register_name(module)
+
+def init_shared_modules():
+ """
+ This function initializes shared modules that need to be
+ """
+ # EDF-CCAR:
+ # Problem with omniORB : omniORB creates a C Python module named _omnipy
+ # this module has sub-modules : omni_func, ...
+ # _omnipy is quite a package but import with Python sub-interpreters does not seem to work
+ # To make it work we need to add those sub-modules in sys.modules
+ import sys
+ import _omnipy
+ sys.modules["_omnipy.omni_func"]=_omnipy.omni_func
+ sys.modules["_omnipy.poa_func"]=_omnipy.poa_func
+ sys.modules["_omnipy.poamanager_func"]=_omnipy.poamanager_func
+ sys.modules["_omnipy.orb_func"]=_omnipy.orb_func
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : salome.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+import SALOMEDS
+from SALOME_NamingServicePy import *
+
+from SALOME_utilities import *
+
+#--------------------------------------------------------------------------
+
+def DumpComponent(Study, SO, offset):
+ it = Study.NewChildIterator(SO)
+ Builder = Study.NewBuilder()
+ while it.More():
+ CSO = it.Value()
+ it.Next()
+ anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
+ AtName = anAttr._narrow(SALOMEDS.AttributeName)
+ t_name = AtName.Value()
+ if t_name[0] == 1:
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + "--"
+ ofs = ofs +1
+ MESSAGE( a + ">" + str(CSO.GetID()) + " " + str(t_name[1]) )
+ t_RefSO = CSO.ReferencedObject()
+ if t_RefSO[0] == 1:
+ RefSO = t_RefSO[1]
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + " "
+ ofs = ofs +1
+ MESSAGE( a + ">" + str(RefSO.GetID()) )
+ DumpComponent(Study, CSO, offset+2)
+
+ #--------------------------------------------------------------------------
+
+def DumpStudy(Study):
+ itcomp = Study.NewComponentIterator()
+ while itcomp.More():
+ SC = itcomp.Value()
+ itcomp.Next()
+ name = SC.ComponentDataType()
+ MESSAGE( "-> ComponentDataType is " + name )
+ DumpComponent(Study, SC, 1)
+
+
+ #--------------------------------------------------------------------------
+
+def ImportComponentGUI(ComponentName):
+ libName = "lib" + ComponentName + "_Swig"
+ command = "from " + libName + " import *"
+ exec ( command )
+ constructor = ComponentName + "_Swig()"
+ command = "gui = " + constructor
+ exec ( command )
+ return gui
+
+ #--------------------------------------------------------------------------
+
+def SalomeGUIgetAllSelected(self):
+ selNumber = self.SelectedCount()
+ listSelected = []
+ for i in range(selNumber):
+ listSelected.append(self.getSelected(i))
+ return listSelected
+
+class SalomeGUI(SALOMEGUI_Swig):
+ getAllSelected = SalomeGUIgetAllSelected
+
+ #--------------------------------------------------------------------------
+
+def IDToObject(id):
+ myObj = None
+ mySO = myStudy.FindObjectID(id);
+ if mySO is not None:
+ ok, anAttr = mySO.FindAttribute("AttributeIOR")
+ if ok:
+ AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
+ if AtIOR.Value() != "":
+ myObj = orb.string_to_object(AtIOR.Value())
+ return myObj
+
+def ObjectToSObject(obj):
+ mySO = None
+ if obj is not None:
+ ior = orb.object_to_string(obj)
+ if ior != "":
+ mySO = myStudy.FindObjectIOR(ior)
+ return mySO
+
+def ObjectToID(obj):
+ mySO = ObjectToSObject(obj)
+ if mySO:
+ return mySO.GetID()
+ return ""
+
+def IDToSObject(id):
+ mySO = myStudy.FindObjectID(id);
+ return mySO
+
+ #--------------------------------------------------------------------------
+
+# initialise the ORB
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+
+# create an LifeCycleCORBA instance
+lcc = LifeCycleCORBA(orb)
+
+# create an SALOMEGUI_Swig instance
+sg = SalomeGUI()
+
+#create an naming service instance
+naming_service = SALOME_NamingServicePy_i(orb)
+
+# get active study name and id
+myStudyName = sg.getActiveStudyName()
+MESSAGE( myStudyName )
+
+myStudyId = sg.getActiveStudyId()
+MESSAGE( str(myStudyId) )
+
+# get Study Manager reference
+obj = naming_service.Resolve('myStudyManager')
+myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+
+# get active study
+myStudy = myStudyManager.GetStudyByName(myStudyName)
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : salome_shared_modules.py
+# Module : SALOME
+
+from SALOME_utilities import *
+
+"""
+This module with help of import_hook and *_shared_modules
+filters imports when using the embedded Python interpretor.
+
+Some imports can't be done more than once.
+This is related to the multi study feature that is implemented
+by using the Python multi interpreter feature.
+Some modules register objects or classes by calling modules
+implemented in C. These operations can't be done multiple times.
+So it's very important to control these imports.
+
+Examples:
+ - PyQt : import qt calls a C module to register classes
+ - OmniORB : import *_idl calls a C module to register CORBA interfaces
+
+Usage:
+ - First : the module salome_shared_modules is imported by main Python interpretor.
+ It will keep a dictionnary and a list that are shared among all
+ the subinterpretors and imports import_hook module that replaces
+ the standard import mechanism par one that prevents more than one import
+ for some modules identified by name (call register_name) or by a
+ validator (call register_pattern).
+
+ Calls to register_name and register_pattern are done in modules named *_shared_modules
+ that could be found in the path SALOMEPATH
+
+"""
+import glob,os,sys
+
+import import_hook
+# shared_imported, patterns, register_name, register_pattern
+# will be shared by all Python sub interpretors
+from import_hook import shared_imported
+from import_hook import patterns
+from import_hook import register_name
+from import_hook import register_pattern
+
+register_name("salome_shared_modules")
+
+# Get the SALOMEPATH if set or else use KERNEL_ROOT_DIR that should be set.
+salome_path=os.environ.get("SALOMEPATH",os.getenv("KERNEL_ROOT_DIR"))
+
+list_modules=[]
+
+# Import all *_shared_modules in the path and store them in list_modules
+path=salome_path.split(":")
+for rep in path:
+ # Import all *_shared_modules in rep
+ for f in glob.glob(os.path.join(rep,"lib","python"+sys.version[:3],"site-packages","salome","shared_modules","*_shared_modules.py")):
+ try:
+ m=__import__(os.path.splitext(os.path.basename(f))[0])
+ list_modules.append(m)
+ except:
+ pass
+
+#
+# If shared modules have been imported before installing import mechanism
+# we add them to shared_imported
+#
+for name,module in sys.modules.items():
+ if import_hook.is_shared(name) and shared_imported.get(name) is None:
+ #print "Module shared added to shared_imported: ",name
+ shared_imported[name]=module
--- /dev/null
+# SALOME SALOME_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : salome_test.py
+# Module : SALOME
+
+print "Test the application loading GEOM, SMESH, VISU, MED, components and doing some"
+print "operation within the components."
+
+import salome
+from salome import sg
+import SALOMEDS
+import os
+
+import SALOME_ModuleCatalog
+
+print "======================================================================"
+print " Get Catalog "
+print "======================================================================"
+obj = salome.naming_service.Resolve('Kernel/ModulCatalog')
+catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
+
+print "======================================================================"
+print " Create Study "
+print "======================================================================"
+
+comp = catalog.GetComponent("GEOM")
+if comp is None:
+ raise RuntimeError,"Component GEOM not found in Module Catalog."
+
+import geompy
+
+print "================================="
+print " create AttributeReal "
+print "================================="
+A = geompy.myBuilder.FindOrCreateAttribute(geompy.father, "AttributeReal")
+if A == None :
+ raise RuntimeError, "Can't create AttributeReal attribute"
+A = A._narrow(SALOMEDS.AttributeReal)
+A.SetValue(0.0001)
+if A.Value() != 0.0001:
+ raise RuntimeError, "Error : wrong value of AttributeReal"
+
+print
+print " =========== Test Geometry =========================="
+print
+
+print "==================================="
+print " define a box"
+print "==================================="
+
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geompy.addToStudy(box,"box")
+
+print
+print "============= Test SMESH ============================="
+print
+
+import StdMeshers
+
+comp = catalog.GetComponent("SMESH")
+if comp is None:
+ raise RuntimeError,"Component SMESH not found in Module Catalog."
+
+comp = catalog.GetComponent("MED")
+if comp is None:
+ raise RuntimeError,"Component MED not found in Module Catalog."
+
+import SMESH
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+myBuilder = salome.myStudy.NewBuilder()
+
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
+
+ShapeTypeCompSolid = 1
+ShapeTypeSolid = 2
+ShapeTypeShell = 3
+ShapeTypeFace = 4
+ShapeTypeWire = 5
+ShapeTypeEdge = 6
+ShapeTypeVertex = 7
+
+# ---- define a box
+
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geompy.addToStudy(box,"box")
+
+# ---- add first face of box in study
+
+subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
+face=subShapeList[0]
+name = geompy.SubShapeName(face, box)
+print name
+idface=geompy.addToStudyInFather(box,face,name)
+
+# ---- add shell from box in study
+
+subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
+shell = subShellList[0]
+name = geompy.SubShapeName(shell, box)
+print name
+idshell=geompy.addToStudyInFather(box,shell,name)
+
+# ---- add first edge of face in study
+
+edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
+edge=edgeList[0];
+name = geompy.SubShapeName(edge, face)
+print name
+idedge=geompy.addToStudyInFather(face,edge,name)
+
+
+# ---- SMESH
+
+# ---- create Hypothesis
+
+print "-------------------------- create Hypothesis"
+print "-------------------------- LocalLength"
+hypLen1 = smesh.CreateHypothesis( "LocalLength", "libStdMeshersEngine.so" )
+hypLen1.SetLength(100)
+print hypLen1.GetName()
+print hypLen1.GetId()
+print hypLen1.GetLength()
+
+smeshgui.SetName(salome.ObjectToID(hypLen1), "Local_Length_100")
+
+print "-------------------------- NumberOfSegments"
+hypNbSeg1= smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
+hypNbSeg1.SetNumberOfSegments(7)
+print hypNbSeg1.GetName()
+print hypNbSeg1.GetId()
+print hypNbSeg1.GetNumberOfSegments()
+
+smeshgui.SetName(salome.ObjectToID(hypNbSeg1), "NumberOfSegments_7")
+
+print "-------------------------- MaxElementArea"
+hypArea1 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
+hypArea1.SetMaxElementArea(2500)
+print hypArea1.GetName()
+print hypArea1.GetId()
+print hypArea1.GetMaxElementArea()
+
+smeshgui.SetName(salome.ObjectToID(hypArea1), "MaxElementArea_2500")
+
+print "-------------------------- MaxElementArea"
+hypArea2 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
+hypArea2.SetMaxElementArea(500)
+print hypArea2.GetName()
+print hypArea2.GetId()
+print hypArea2.GetMaxElementArea()
+
+smeshgui.SetName(salome.ObjectToID(hypArea2), "MaxElementArea_500")
+
+print "-------------------------- Regular_1D"
+algoReg = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
+listHyp=algoReg.GetCompatibleHypothesis()
+for hyp in listHyp:
+ print hyp
+print algoReg.GetName()
+print algoReg.GetId()
+
+smeshgui.SetName(salome.ObjectToID(algoReg), "Regular_1D" )
+
+print "-------------------------- MEFISTO_2D"
+algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
+listHyp=algoMef.GetCompatibleHypothesis()
+for hyp in listHyp:
+ print hyp
+print algoMef.GetName()
+print algoMef.GetId()
+
+smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D" )
+
+# ---- add hypothesis to box
+
+print "-------------------------- add hypothesis to box"
+box=salome.IDToObject(idbox)
+mesh = smesh.CreateMesh(box)
+
+smeshgui.SetName( salome.ObjectToID(mesh), "MeshBox" );
+
+ret=mesh.AddHypothesis(box,algoReg)
+print ret
+ret=mesh.AddHypothesis(box,algoMef)
+print ret
+
+
+ret=mesh.AddHypothesis(box,hypNbSeg1)
+print ret
+ret=mesh.AddHypothesis(box,hypArea1)
+print ret
+
+
+# ---- add hypothesis to edge
+
+print "-------------------------- add hypothesis to edge"
+edge=salome.IDToObject(idedge)
+submesh=mesh.GetSubMesh(edge, "SubMeshEdge")
+
+ret=mesh.AddHypothesis(edge,algoReg)
+print ret
+ret=mesh.AddHypothesis(edge,hypLen1)
+print ret
+
+print "-------------------------- add hypothesis to face"
+face=salome.IDToObject(idface)
+submesh = mesh.GetSubMesh(face, "SubMeshFace")
+
+ret=mesh.AddHypothesis(face,hypArea2)
+print ret
+
+smesh.Compute(mesh, box)
+sg.updateObjBrowser(1);
+
+print
+print "============= Test Supervisor ============================="
+print
+
+comp = catalog.GetComponent("SUPERV")
+if comp is None:
+ raise RuntimeError,"Component SUPERV not found in Module Catalog."
+
+from SuperV import *
+import SALOMEDS
+myStudy = salome.myStudy
+myBuilder = myStudy.NewBuilder()
+
+SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
+father = myStudy.FindComponent("SUPERV")
+if father is None:
+ father = myBuilder.NewComponent("SUPERV")
+ A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
+ FName = A1._narrow(SALOMEDS.AttributeName)
+ FName.SetValue( salome.sg.getComponentUserName("SUPERV") )
+ A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
+ aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
+ myBuilder.DefineComponentInstance(father,SuperVision)
+
+def addStudy(ior):
+ dataflow = SuperVision.getStreamGraph(ior)
+ name=dataflow.Name()
+ itr = myStudy.NewChildIterator(father)
+ while itr.More():
+ item=itr.Value()
+ res,A=item.FindAttribute("AttributeName")
+ if res:
+ aName = A._narrow(SALOMEDS.AttributeName)
+ if aName.Value() == name :
+ print myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
+ A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
+ print "A = ", A
+ if A is not None :
+ #res,A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
+ anIOR = A._narrow(SALOMEDS.AttributeIOR);
+ print "anIOR.SetValue(dataflow.getIOR())"
+ anIOR.SetValue(dataflow.getIOR())
+ return
+ itr.Next()
+ obj = myBuilder.NewObject(father)
+ A=myBuilder.FindOrCreateAttribute(obj, "AttributeName")
+ aName=A._narrow(SALOMEDS.AttributeName)
+ aName.SetValue(name)
+ A=myBuilder.FindOrCreateAttribute(obj, "AttributeIOR")
+ anIOR = A._narrow(SALOMEDS.AttributeIOR)
+ anIOR.SetValue(dataflow.getIOR())
+
+import os
+dir= os.getenv("SUPERV_ROOT_DIR")
+if dir == None:
+ raise RuntimeError, "SUPERV_ROOT_DIR is not defined"
+xmlfile = dir +"/examples/GraphGeomEssai.xml"
+print "Load dataflow from the file : "
+print xmlfile
+print
+
+myGraph = StreamGraph ( xmlfile )
+
+# This DataFlow is "valid" : no loop, correct links between Nodes etc...
+print "myGraph.IsValid() = ", myGraph.IsValid()
+
+# Get Nodes
+myGraph.PrintNodes()
+
+# This DataFlow is "executable" : all pending Ports are defined with Datas
+print myGraph.IsExecutable()
+
+# Starts only execution of that DataFlow and gets control immediatly
+print myGraph.Run()
+
+# That DataFlow is running ==> 0 (false)
+print myGraph.IsDone()
+
+# Events of execution :
+aStatus,aNode,anEvent,aState = myGraph.Event()
+while aStatus :
+ print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
+ aStatus,aNode,anEvent,aState = myGraph.Event()
+print "myGraph.IsDone() = ",myGraph.IsDone()
+
+# Wait for Completion (but it is already done after event loop ...)
+print "Done : ",myGraph.DoneW()
+
+print " "
+#print "Type : print myGraph.IsDone()"
+#print " If execution is finished ==> 1 (true)"
+res=myGraph.IsDone()
+if res != 1:
+ raise RuntimeError, "myGraph.Run() is not done"
+
+print " "
+print "Type : myGraph.PrintPorts()"
+print " to see input and output values of the graph"
+myGraph.PrintPorts()
+
+# Export will create newsupervisionexample.xml and the corresponding .py file
+tmpdir=os.getenv("TmpDir")
+if tmpdir is None:
+ tmpdir="/tmp"
+file = tmpdir + "/newsupervisionexample"
+print "--------------\n"+file+"\n--------------\n"
+myGraph.Export(file)
+
+ior = salome.orb.object_to_string(myGraph.G)
+addStudy(ior)
+
+GraphName = myGraph.Name()
+print "Befor save ",
+#nodes = myGraph.Nodes()
+nodes = myGraph.G.Nodes().FNodes
+length_bs = len(nodes)
+print "ListOfNodes length = ", length_bs
+names=[]
+for node in nodes:
+ names.append(node.Name())
+print names
+
+# Graph creation
+GraphInLines = StreamGraph( 'GraphInLines' )
+GraphInLines.SetName( 'GraphInLines' )
+GraphInLines.SetAuthor( '' )
+GraphInLines.SetComment( '' )
+GraphInLines.Coords( 0 , 0 )
+
+# Creation of InLine Nodes
+PyAdd = []
+PyAdd.append( 'def Add(a,b) : ' )
+PyAdd.append( ' return a+b ' )
+PyAdd.append( '' )
+Add = GraphInLines.INode( 'Add' , PyAdd )
+Add.InPort( 'a' , 'long' )
+Add.InPort( 'b' , 'long' )
+Add.OutPort( 'f' , 'long' )
+Add.SetName( 'Add' )
+Add.SetAuthor( '' )
+Add.SetComment( 'Python function' )
+Add.Coords( 351 , 77 )
+PySub = []
+PySub.append( 'def Sub(a,b) : ' )
+PySub.append( ' return a-b ' )
+PySub.append( '' )
+Sub = GraphInLines.INode( 'Sub' , PySub )
+Sub.InPort( 'a' , 'long' )
+Sub.InPort( 'b' , 'long' )
+Sub.OutPort( 'f' , 'long' )
+Sub.SetName( 'Sub' )
+Sub.SetAuthor( '' )
+Sub.SetComment( 'Python function' )
+Sub.Coords( 86 , 333 )
+PyMul = []
+PyMul.append( 'def Mul(a,b) : ' )
+PyMul.append( ' return a*b ' )
+Mul = GraphInLines.INode( 'Mul' , PyMul )
+Mul.InPort( 'a' , 'long' )
+Mul.InPort( 'b' , 'long' )
+Mul.OutPort( 'Result' , 'long' )
+Mul.SetName( 'Mul' )
+Mul.SetAuthor( '' )
+Mul.SetComment( 'Python function' )
+Mul.Coords( 616 , 247 )
+
+# Creation of intermediate Output variables and of Control Links
+Addf = Add.Port( 'f' )
+Mula = GraphInLines.Link( Addf , Mul.Port( 'a' ) )
+Mula.AddCoord( 1 , 570 , 356 )
+Mula.AddCoord( 2 , 570 , 186 )
+Subf = Sub.Port( 'f' )
+Mulb = GraphInLines.Link( Subf , Mul.Port( 'b' ) )
+Mulb.AddCoord( 1 , 282 , 376 )
+Mulb.AddCoord( 2 , 282 , 442 )
+Addb = GraphInLines.Link( Subf , Add.Port( 'b' ) )
+Addb.AddCoord( 1 , 283 , 209 )
+Addb.AddCoord( 2 , 283 , 374 )
+Addb.AddCoord( 3 , 283 , 442 )
+
+# Creation of Input datas
+Adda = Add.Input( 'a' , 1)
+Suba = Sub.Input( 'a' , 3)
+Subb = Sub.Input( 'b' , 4)
+
+# Creation of Output variables
+MulResult = Mul.Port( 'Result' )
+
+GraphInLines.Run()
+
+GraphInLines.DoneW()
+
+GraphInLines.PrintPorts()
+
+sg.updateObjBrowser(1);
+
+print
+print "============= Test VISU and MED ============================="
+print
+
+comp = catalog.GetComponent("VISU")
+if comp is None:
+ raise RuntimeError,"Component VISU not found in Module Catalog."
+
+import sys
+import SALOMEDS
+import SALOME
+import SALOME_MED
+import VISU
+
+import visu_gui
+
+medFileName = "pointe.med"
+medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFileName
+print "Load ", medFile
+
+studyCurrent = salome.myStudyName
+
+med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
+myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
+
+try:
+ if os.access(medFile, os.R_OK) :
+ if not os.access(medFile, os.W_OK) :
+ import random
+ medFileNew = "/tmp/" + str(random.randint(0,1000000)) + "_" + medFileName
+ print " -- Copy " + medFile + " to " + medFileNew
+ os.system("cp "+ medFile + " " + medFileNew)
+ medFile = medFileNew
+ os.system("chmod 755 " + medFile)
+
+ if os.access(medFile, os.W_OK) :
+ med_comp.readStructFileWithFieldType(medFile,studyCurrent)
+ med_obj = visu_gui.visu.getMedObjectFromStudy()
+ print "med_obj - ", med_obj
+
+ myField1 = visu_gui.visu.getFieldObjectFromStudy(2,1)
+ aMeshName = "maa1"
+ anEntity = VISU.NODE
+ aTimeStampId = -1
+
+ myResult1 = myVisu.ImportMedField(myField1)
+ aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity);
+
+ aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField1.getName(), aTimeStampId)
+
+ myResult2 = myVisu.ImportFile(medFile);
+ aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity);
+
+ aTimeStampId = 3
+ aScalarMap2= myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField1.getName(), aTimeStampId)
+
+ sg.updateObjBrowser(0)
+ else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file";
+ else : print "We have no permission to read medFile, it will not be opened";
+
+except:
+ if sys.exc_type == SALOME.SALOME_Exception :
+ print "There is no permission to read " + medFile
+ else :
+ print sys.exc_type
+ print sys.exc_value
+ print sys.exc_traceback
+
+sg.updateObjBrowser(1);
--- /dev/null
+#==============================================================================
+# File : supervisionexample.py
+# Created : 23 nov 2001
+# Author : Jean Rahuel
+# Project : SALOME
+# Copyright : CEA
+#==============================================================================
+
+from SuperV import *
+
+
+
+# load this object with Nodes, Links and Datas stored in GraphEssai.xml
+# (GraphEssai.xml was created with python in SuperVisionTest and GraphEssai.py)
+myGraph = Graph("@ROOT_BUILDDIR@/share/salome/resources/GraphEssai.xml")
+
+#myGraph = Graph("/home/data/jr_HEAD/build/share/salome/resources/GraphEssai.xml")
+# This DataFlow is "valid" : no loop, correct links between Nodes etc...
+
+print myGraph.IsValid()
+
+# Get Nodes
+myGraph.PrintNodes()
+Add,Sub,Mul,Div = myGraph.Nodes()
+
+# Load Datas
+Addx = Add.Input("x",3.)
+Addy = Add.Input("y",4.5)
+Subx = Sub.Input("x",1.5)
+
+# Get Output Port
+Addz = Add.Port('z')
+Subz = Sub.Port('z')
+Mulz = Mul.Port('z')
+Divz = Div.Port('z')
+
+# This DataFlow is "executable" : all pending Ports are defined with Datas
+print myGraph.IsExecutable()
+
+# Starts only execution of that DataFlow and gets control immediatly
+print myGraph.Run()
+
+# That DataFlow is running ==> 0 (false)
+print myGraph.IsDone()
+
+# Events of execution :
+aStatus,aNode,anEvent,aState = myGraph.Event()
+while aStatus :
+ print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
+ aStatus,aNode,anEvent,aState = myGraph.Event()
+print myGraph.IsDone()
+
+# Wait for Completion (but it is already done after event loop ...)
+print "Done : ",myGraph.DoneW()
+
+# Get result
+print "Result : ",Divz.ToString()
+
+# Intermediate results :
+print "Intermediate Result Add\z : ",Addz.ToString()
+print "Intermediate Result Sub\z : ",Subz.ToString()
+print "Intermediate Result Mul\z : ",Mulz.ToString()
+
+print " "
+print "Type : print myGraph.IsDone()"
+print " If execution is finished ==> 1 (true)"
+print " "
+print "Type : print Divz.ToString()"
+print " You will get the result"
+print " "
+print "Type : myGraph.PrintPorts()"
+print " to see input and output values of the graph"
+print " "
+print "Type : Add.PrintPorts()"
+print "Type : Sub.PrintPorts()"
+print "Type : Mul.PrintPorts()"
+print "Type : Div.PrintPorts()"
+print " to see input and output values of nodes"
+
+# Export will create newsupervisionexample.xml and the corresponding .py file
+print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml")
+
+print " "
+print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml"
+print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.py"
+
--- /dev/null
+# Generated python file of Graph GraphGeom2Essai
+
+from SuperV import *
+
+import salome
+
+import geompy
+
+
+geom = lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+geom.GetCurrentStudy(salome.myStudyId)
+
+myBuilder = salome.myStudy.NewBuilder()
+
+# Graph creation
+GraphGeom2Essai = Graph( 'GraphGeom2Essai' )
+print GraphGeom2Essai.SetAuthor( '' )
+print GraphGeom2Essai.SetComment( '' )
+GraphGeom2Essai.Coords( 0 , 0 )
+
+# Creation of Nodes
+MakeSphere = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeSphere' )
+print MakeSphere.SetAuthor( '' )
+print MakeSphere.SetContainer( 'FactoryServer' )
+print MakeSphere.SetComment( '' )
+MakeSphere.Coords( 26 , 13 )
+MakeCopy = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeCopy' )
+print MakeCopy.SetAuthor( '' )
+print MakeCopy.SetContainer( 'FactoryServer' )
+print MakeCopy.SetComment( '' )
+MakeCopy.Coords( 219 , 12 )
+MakeTranslation = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeTranslation' )
+print MakeTranslation.SetAuthor( '' )
+print MakeTranslation.SetContainer( 'FactoryServer' )
+print MakeTranslation.SetComment( '' )
+MakeTranslation.Coords( 219 , 159 )
+MakeFuse = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeFuse' )
+print MakeFuse.SetAuthor( '' )
+print MakeFuse.SetContainer( 'FactoryServer' )
+print MakeFuse.SetComment( '' )
+MakeFuse.Coords( 465 , 106 )
+
+# Creation of intermediate Output variables and of links
+MakeSphereshape = MakeSphere.Port( 'shape' )
+MakeCopyshape1 = GraphGeom2Essai.Link( MakeSphereshape , MakeCopy.Port( 'shape1' ) )
+MakeTranslationshape1 = GraphGeom2Essai.Link( MakeSphereshape , MakeTranslation.Port( 'shape1' ) )
+MakeCopyshape = MakeCopy.Port( 'shape' )
+MakeFuseshape1 = GraphGeom2Essai.Link( MakeCopyshape , MakeFuse.Port( 'shape1' ) )
+MakeTranslationshape = MakeTranslation.Port( 'shape' )
+MakeFuseshape2 = GraphGeom2Essai.Link( MakeTranslationshape , MakeFuse.Port( 'shape2' ) )
+
+# Creation of Input datas
+MakeSpherex1 = MakeSphere.Input( 'x1' , 0)
+MakeSpherey1 = MakeSphere.Input( 'y1' , 0)
+MakeSpherez1 = MakeSphere.Input( 'z1' , 0)
+MakeSphereradius = MakeSphere.Input( 'radius' , 50)
+MakeTranslationx1 = MakeTranslation.Input( 'x1' , 80)
+MakeTranslationy1 = MakeTranslation.Input( 'y1' , 0)
+MakeTranslationz1 = MakeTranslation.Input( 'z1' , 0)
+
+# Missing Input datas : None
+
+# Creation of Output variables
+MakeFuseshape = MakeFuse.Port( 'shape' )
+
+# State of Ports of the Graph
+GraphGeom2Essai.PrintPorts()
+
+# Start asynchronous run
+print GraphGeom2Essai.Run()
+
+# Done ?
+print GraphGeom2Essai.IsDone()
+
+# Events of execution :
+aStatus,aNode,anEvent,aState = GraphGeom2Essai.Event()
+while aStatus :
+ print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
+ aStatus,aNode,anEvent,aState = GraphGeom2Essai.Event()
+print GraphGeom2Essai.IsDone()
+
+# Waiting end of execution :
+print GraphGeom2Essai.DoneW()
+
+print " "
+print "Type print GraphGeom2Essai.IsDone()"
+print "1 <==> It's done"
+print " "
+print "Type print GraphGeom2Essai.DoneW()"
+print "Wait until end of execution : 1(success)"
+print " "
+print "Type GraphGeom2Essai.PrintPorts()"
+print " to see input and output values of the graph"
+print " "
+print "Type MakeSphere.PrintPorts()"
+print "Type MakeCopy.PrintPorts()"
+print "Type MakeTranslation.PrintPorts()"
+print "Type MakeFuse.PrintPorts()"
+print " to see input and output values of nodes"
+print " "
+print "Type print GraphGeom2Essai.Export('File-Name')"
+print "You will get a .py and a .xml file of this graph"
--- /dev/null
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : test_big_table.py
+# Author : Vadim SANDLER
+# Module : SALOME
+# $Header$
+
+import salome
+import math
+import SALOMEDS
+
+# >>> Getting study builder ==================================================
+myStudy = salome.myStudy
+myBuilder = myStudy.NewBuilder()
+
+# >>> Creating virtual component =============================================
+myComponent = myStudy.FindComponent("VirtualComponent")
+if not myComponent:
+ myComponent = myBuilder.NewComponent("VirtualComponent")
+ aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
+ aName.SetValue("VirtualComponent")
+
+# >>> Creating object with Table of real[ 200 * 20 ] ========================
+myTRealObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
+AName.SetValue("Table Of Real")
+ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
+myHorNb = 10
+myVerNb = 200
+
+k={}
+for j in range(0,myHorNb):
+ k[j] = j*10+1
+ARealTable.AddRow(k.values())
+ARealTable.SetRowTitle(1, "Frequency")
+ARealTable.SetRowUnit(1, "Hz")
+
+for i in range(1,myVerNb+1):
+ for j in range(0,myHorNb):
+ if j % 2 == 1:
+ k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
+ else:
+ k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
+ ARealTable.AddRow(k.values())
+ ARealTable.SetRowTitle(i+1, "Power " + str(i))
+ ARealTable.SetRowUnit(i+1, "Wt")
+ARealTable.SetTitle("Very useful data")
+
+# >>> Updating Object Browser ================================================
+salome.sg.updateObjBrowser(1)
+
+# ============================================================================
--- /dev/null
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : visu_many_objects.py
+# Author : Vadim SANDLER
+# Module : SALOME
+# $Header$
+
+import salome
+import SALOMEDS
+
+# >>> Getting study builder ==================================================
+myStudy = salome.myStudy
+myBuilder = myStudy.NewBuilder()
+
+# >>> Creating virtual component =============================================
+myComponent = myBuilder.NewComponent("VIRTUAL")
+AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
+AName.SetValue("Virtual")
+ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment")
+ACmt.SetValue("Virtual")
+
+# >>> Creating objects =======================================================
+# TO CHANGE TOTAL NUMBER OF OBJECTS, SET PROPER <myNb1>, <myNb2>, <myNb3>
+# IF YOU DON'T WANT TO ADD REFERENCES, SET <myAddRef> = 0
+myNb1 = 20
+myNb2 = 5
+myNb3 = 3
+myAddRef = 1
+
+if myAddRef == 1:
+ myContainer = myBuilder.NewObject(myComponent)
+ AName = myBuilder.FindOrCreateAttribute(myContainer, "AttributeName")
+ AName.SetValue("References")
+ ACmt = myBuilder.FindOrCreateAttribute(myContainer, "AttributeComment")
+ ACmt.SetValue("Container for objects")
+
+for i in range(0,myNb1):
+ myObject1 = myBuilder.NewObject(myComponent)
+ AName = myBuilder.FindOrCreateAttribute(myObject1, "AttributeName")
+ AName.SetValue("Object "+str(i))
+ ACmt = myBuilder.FindOrCreateAttribute(myObject1, "AttributeComment")
+ ACmt.SetValue("Virtual object "+str(i))
+ if myAddRef == 1:
+ myRefObject = myBuilder.NewObject(myContainer)
+ myBuilder.Addreference(myRefObject,myObject1);
+
+ for j in range(0,myNb2):
+ myObject2 = myBuilder.NewObject(myObject1)
+ AName = myBuilder.FindOrCreateAttribute(myObject2, "AttributeName")
+ AName.SetValue("Object "+str(i)+"-"+str(j))
+ ACmt = myBuilder.FindOrCreateAttribute(myObject2, "AttributeComment")
+ ACmt.SetValue("Virtual object "+str(i)+"-"+str(j))
+ if myAddRef == 1:
+ myRefObject = myBuilder.NewObject(myContainer)
+ myBuilder.Addreference(myRefObject,myObject2);
+
+ for k in range(0,myNb3):
+ myObject3 = myBuilder.NewObject(myObject2)
+ AName = myBuilder.FindOrCreateAttribute(myObject3, "AttributeName")
+ AName.SetValue("Object "+str(i)+"-"+str(j)+"-"+str(k))
+ ACmt = myBuilder.FindOrCreateAttribute(myObject3, "AttributeComment")
+ ACmt.SetValue("Virtual object "+str(i)+"-"+str(j)+"-"+str(k))
+ if myAddRef == 1:
+ myRefObject = myBuilder.NewObject(myContainer)
+ myBuilder.Addreference(myRefObject,myObject3);
+
+# >>> Updating Object Browser ================================================
+salome.sg.updateObjBrowser(1)
+
+# ============================================================================
+
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : test_remove_ref.py
+# Module : SALOMEDS
+
+from salome import *
+
+myBuilder = myStudy.NewBuilder()
+
+
+obj1 = myStudy.FindObjectID("0:1")
+if obj1 is None: print "Is null obj1 "
+else: print obj1.GetID()
+
+obj2 = myBuilder.NewObject(obj1)
+print "Obj2 ID = "+obj2.GetID()
+
+myBuilder.Addreference(obj1, obj2)
+
+(f, obj3) = obj1.ReferencedObject()
+
+print "Ref obj ID = "+obj3.GetID()
+
+
+myBuilder.RemoveReference(obj1)
+
+(f, obj4) = obj1.ReferencedObject()
+
+print "Ref is found ", f
--- /dev/null
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : test_table.py
+# Author : Vadim SANDLER
+# Module : SALOME
+# $Header$
+
+import salome
+import math
+import SALOMEDS
+
+# >>> Getting study builder ==================================================
+myStudy = salome.myStudy
+myBuilder = myStudy.NewBuilder()
+
+# >>> Creating virtual component =============================================
+myComponent = myStudy.FindComponent("VirtualComponent")
+if not myComponent:
+ myComponent = myBuilder.NewComponent("VirtualComponent")
+ aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
+ aName.SetValue("VirtualComponent")
+
+# >>> Creating object with Table of integer ==================================
+myTIntObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName")
+AName.SetValue("Table Of Integer")
+AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger")
+
+a=[1,2,3,4,5,6,7,8,9,10]
+AIntTable.AddRow(a)
+a=[110,120,130,140,150,160,170,180,190,200]
+AIntTable.AddRow(a)
+a=[-1,272,0,0,-642,10000,13,578,-578,99]
+AIntTable.AddRow(a)
+AIntTable.SetTitle("TEST table of integer")
+AIntTable.SetRowTitle(1,"FR")
+AIntTable.SetRowUnit(1,"m/h")
+AIntTable.SetRowTitle(2,"SR")
+AIntTable.SetRowUnit(2,"s")
+AIntTable.SetRowTitle(3,"TR")
+AIntTable.SetRowUnit(3,"$")
+c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"]
+AIntTable.SetColumnTitles(c)
+
+# >>> Creating object with Table of real =====================================
+myTRealObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
+AName.SetValue("Table Of Real")
+ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
+
+k={}
+l={}
+for j in range(0,20):
+ k[j] = j*10+1
+ l[j] = "C"+str(j+1)
+ARealTable.AddRow(k.values())
+ARealTable.SetRowTitle(1, "Row 0")
+ARealTable.SetRowUnit(1, "Hz")
+ARealTable.SetColumnTitles(l.values())
+for i in range(1,11):
+ for j in range(1,21):
+ if j % 2 == 1:
+ k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
+ else:
+ k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
+ ARealTable.AddRow(k.values())
+ ARealTable.SetRowTitle(i+1, "Row " + str(i))
+ ARealTable.SetRowUnit(i+1, "Wt")
+ARealTable.SetTitle("TEST table of real")
+
+# >>> Creating object with integer attribute =================================
+myIntObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName")
+AName.SetValue("Integer")
+AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger")
+AInt.SetValue(123)
+
+# >>> Creating object with real attribute ====================================
+myRealObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName")
+AName.SetValue("Real")
+AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal")
+AReal.SetValue(-56.9634)
+
+# >>> Creating object with comment attribute =================================
+myCmtObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName")
+AName.SetValue("Comment")
+ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment")
+ACmt.SetValue("Just a comment")
+
+# >>> Updating Object Browser ================================================
+salome.sg.updateObjBrowser(1)
+
+# ============================================================================
+
+
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : testattr.py
+# Module : SALOME
+
+import SALOMEDS
+#import SALOMEDS_Attributes_idl
+import geompy
+import salome
+# ===============================================================
+
+# creating new object ===========================================
+obj = geompy.myBuilder.NewObject(geompy.father)
+
+# adding Name attribute =========================================
+A1 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeName")
+name = A1._narrow(SALOMEDS.AttributeName)
+name.SetValue("First Object")
+
+# adding Comment attribute ======================================
+A2 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeComment")
+comment = A2._narrow(SALOMEDS.AttributeComment)
+comment.SetValue("This is Comment attribute")
+
+# adding IOR attribute ==========================================
+#A3 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeIOR")
+# ...
+
+# adding integer attribute ======================================
+A4 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeInteger")
+integer = A4._narrow(SALOMEDS.AttributeInteger)
+integer.SetValue(12)
+
+# adding real attribute =========================================
+A5 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeReal")
+real = A5._narrow(SALOMEDS.AttributeReal)
+real.SetValue(0.25)
+
+# adding sequence of integer attribute ==========================
+A6 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeSequenceOfInteger")
+intseq = A6._narrow(SALOMEDS.AttributeSequenceOfInteger)
+intseq.Add(1)
+intseq.Add(2)
+intseq.Add(3)
+
+
+# adding sequence of real attribute =============================
+A7 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeSequenceOfReal")
+realseq = A7._narrow(SALOMEDS.AttributeSequenceOfReal)
+realseq.Add(0.001)
+realseq.Add(0.002)
+realseq.Add(0.003)
+
+# adding PersistentRef attribute ================================
+#A8 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributePersistentRef")
+# ...
+
+# adding Drawable attribute =====================================
+A9 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeDrawable")
+drawable = A9._narrow(SALOMEDS.AttributeDrawable)
+drawable.SetDrawable(1)
+
+# adding Selectable attribute ===================================
+#A10 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeSelectable")
+# ...
+
+# adding Expandable attribute ===================================
+#A11 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeExpandable")
+# ...
+
+# adding Opened attribute =======================================
+#A12 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeOpened")
+# ...
+
+# adding TextColor attribute ====================================
+A13 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeTextColor")
+textcolor = A13._narrow(SALOMEDS.AttributeTextColor)
+
+# ...
+
+# adding TextHighlightColor of real attribute ===================
+#A14 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeTextHighlightColor")
+# ...
+
+# adding PixMap of real attribute ===============================
+#A15 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributePixMap")
+# ...
+
+# opening OCAF Browser ==========================================
+# result = salome.myStudy.OCAFBrowser()