From: mpa Date: Fri, 3 Feb 2017 13:22:20 +0000 (+0300) Subject: Deleted Study parameter X-Git-Tag: Before_python3_27062017^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c9601cf0acc0071be22d794d0506aee0954940a5;p=samples%2Fpyhello.git Deleted Study parameter --- diff --git a/idl/PYHELLO_Gen.idl b/idl/PYHELLO_Gen.idl index 71a12d0..b4528e8 100644 --- a/idl/PYHELLO_Gen.idl +++ b/idl/PYHELLO_Gen.idl @@ -39,8 +39,7 @@ module PYHELLO_ORB string makeBanner(in string name) raises (SALOME::SALOME_Exception); - void createObject(in SALOMEDS::Study theStudy, - in string name) + void createObject(in string name) raises (SALOME::SALOME_Exception); void raiseAnException() diff --git a/resources/PYHELLOCatalog.xml.in b/resources/PYHELLOCatalog.xml.in index 8ba1887..b7da2e7 100644 --- a/resources/PYHELLOCatalog.xml.in +++ b/resources/PYHELLOCatalog.xml.in @@ -39,7 +39,6 @@ SALOME team @SALOMEPYHELLO_VERSION@ - 1 1 PYHELLO.png @@ -79,11 +78,6 @@ unknown 0 - - theStudy - Study - unknown - name string diff --git a/src/PYHELLO/PYHELLO.py b/src/PYHELLO/PYHELLO.py index f6b7caa..64d83cd 100644 --- a/src/PYHELLO/PYHELLO.py +++ b/src/PYHELLO/PYHELLO.py @@ -77,9 +77,9 @@ class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen, """ Create object. """ - def createObject( self, study, name ): - builder = study.NewBuilder() - father = findOrCreateComponent( study ) + def createObject( self, name ): + builder = salome.myStudy.NewBuilder() + father = findOrCreateComponent() object = builder.NewObject( father ) attr = builder.FindOrCreateAttribute( object, "AttributeName" ) attr.SetValue( name ) @@ -93,10 +93,9 @@ class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen, def DumpPython( self, isPublished, isMultiFile ): abuffer = [] names = [] - study = self._naming_service.Resolve("/Study") - father = study.FindComponent( moduleName() ) + father = salome.myStudy.FindComponent( moduleName() ) if father: - iter = study.NewChildIterator( father ) + iter = salome.myStudy.NewChildIterator( father ) while iter.More(): name = iter.Value().GetName() if name: names.append( name ) @@ -109,7 +108,7 @@ class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen, abuffer += [ "" ] abuffer += [ "pyhello = salome.lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ] abuffer += [ "" ] - abuffer += [ "pyhello.createObject( salome.myStudy, '%s' )" % name for name in names ] + abuffer += [ "pyhello.createObject( '%s' )" % name for name in names ] abuffer += [ "" ] pass if isMultiFile: diff --git a/src/PYHELLO/PYHELLO_utils.py b/src/PYHELLO/PYHELLO_utils.py index 0e5d6eb..224e0fb 100644 --- a/src/PYHELLO/PYHELLO_utils.py +++ b/src/PYHELLO/PYHELLO_utils.py @@ -32,7 +32,6 @@ __all__ = [ "getORB", "getNS", "getLCC", - "getStudy", "getEngine", "getEngineIOR", "findOrCreateComponent", @@ -128,18 +127,6 @@ def getLCC(): pass return __lcc__ -## -# Get study -### -__study__ = None -def getStudy(): - global __study__ - if __study__ is None: - obj = getNS().Resolve( '/Study' ) - __study__ = obj._narrow( SALOMEDS.Study ) - pass - return __study__ - ### # Get PYHELLO engine ### @@ -164,10 +151,10 @@ def getEngineIOR(): ### # Find or create PYHELLO component object in a study ### -def findOrCreateComponent( study ): - father = study.FindComponent( moduleName() ) +def findOrCreateComponent(): + father = salome.myStudy.FindComponent( moduleName() ) if father is None: - builder = study.NewBuilder() + builder = salome.myStudy.NewBuilder() father = builder.NewComponent( moduleName() ) attr = builder.FindOrCreateAttribute( father, "AttributeName" ) attr.SetValue( moduleName() ) @@ -186,10 +173,10 @@ def findOrCreateComponent( study ): ### # Get object's ID ### -def getObjectID( study, entry ): +def getObjectID( entry ): ID = unknownID() - if study and entry: - sobj = study.FindObjectID( entry ) + if entry: + sobj = salome.myStudy.FindObjectID( entry ) if sobj is not None: test, anAttr = sobj.FindAttribute( "AttributeLocalID" ) if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value() diff --git a/src/PYHELLOGUI/PYHELLOGUI.py b/src/PYHELLOGUI/PYHELLOGUI.py index f2d5478..708aa74 100644 --- a/src/PYHELLOGUI/PYHELLOGUI.py +++ b/src/PYHELLOGUI/PYHELLOGUI.py @@ -131,8 +131,7 @@ sg = libSALOME_Swig.SALOMEGUI_Swig() ### def _hasChildren( sobj ): if sobj: - study = getStudy() - iter = study.NewChildIterator( sobj ) + iter = salome.myStudy.NewChildIterator( sobj ) while iter.More(): name = iter.Value().GetName() if name: @@ -157,7 +156,7 @@ def _getSelection(): selcount = sg.SelectedCount() seltypes = {} for i in range( selcount ): - _incObjToMap( seltypes, getObjectID( _getStudy(), sg.getSelected( i ) ) ) + _incObjToMap( seltypes, getObjectID( sg.getSelected( i ) ) ) pass return selcount, seltypes @@ -231,7 +230,6 @@ def deactivate(): # popup menu and menu context are passed as parameters def createPopupMenu( popup, context ): if verbose() : print "PYHELLOGUI.createPopupMenu(): context = %s" % context - study = getStudy() selcount, selected = _getSelection() if verbose() : print selcount, selected if selcount == 1: @@ -428,25 +426,24 @@ def CreateObject(): name = "%s %d" % ( default_name, __objectid__ ) pass if not name: return - getEngine().createObject( getStudy(), name ) - sg.updateObjBrowser( True ) + getEngine().createObject( name ) + sg.updateObjBrowser() pass ### # Delete all objects ### def DeleteAll(): - study = getStudy() - father = study.FindComponent( moduleName() ) + father = salome.myStudy.FindComponent( moduleName() ) if father: - iter = study.NewChildIterator( father ) - builder = study.NewBuilder() + iter = salome.myStudy.NewChildIterator( father ) + builder = salome.myStudy.NewBuilder() while iter.More(): sobj = iter.Value() iter.Next() builder.RemoveObjectWithChildren( sobj ) pass - sg.updateObjBrowser( True ) + sg.updateObjBrowser() pass pass @@ -454,10 +451,9 @@ def DeleteAll(): # Show object's name ### def ShowMe(): - study = getStudy() entry = sg.getSelected( 0 ) if entry != '': - sobj = study.FindObjectID( entry ) + sobj = salome.myStudy.FindObjectID( entry ) if ( sobj ): test, attr = sobj.FindAttribute( "AttributeName" ) if test: @@ -471,30 +467,28 @@ def ShowMe(): # Delete selected object(s) ### def Delete(): - study = getStudy() - builder = study.NewBuilder() + builder = salome.myStudy.NewBuilder() if sg.SelectedCount() <= 0: return for i in range( sg.SelectedCount() ): entry = sg.getSelected( i ) if entry != '': - sobj = study.FindObjectID( entry ) + sobj = salome.myStudy.FindObjectID( entry ) if ( sobj ): builder.RemoveObject( sobj ) pass pass pass - sg.updateObjBrowser( True ) + sg.updateObjBrowser() pass ### # Rename selected object ### def Rename(): - study = getStudy() - builder = study.NewBuilder() + builder = salome.myStudy.NewBuilder() entry = sg.getSelected( 0 ) if entry != '': - sobj = study.FindObjectID( entry ) + sobj = salome.myStudy.FindObjectID( entry ) if ( sobj ): name, ok = QInputDialog.getText( sgPyQt.getDesktop(), "Object name", @@ -505,7 +499,7 @@ def Rename(): if not ok or not name: return attr = builder.FindOrCreateAttribute( sobj, "AttributeName" ) attr.SetValue( name ) - sg.updateObjBrowser( True ) + sg.updateObjBrowser() pass pass pass