From: prascle Date: Wed, 26 Jan 2005 09:39:40 +0000 (+0000) Subject: PR: geompy usable outside GUI, idem for some SMESH scripts X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3112076e362647aa3aaf437ee25ea026b1e499ab;p=modules%2Fkernel.git PR: geompy usable outside GUI, idem for some SMESH scripts --- diff --git a/src/SALOME_SWIG_WITHOUTIHM/Makefile.in b/src/SALOME_SWIG_WITHOUTIHM/Makefile.in index 6df9f2893..be103f272 100755 --- a/src/SALOME_SWIG_WITHOUTIHM/Makefile.in +++ b/src/SALOME_SWIG_WITHOUTIHM/Makefile.in @@ -38,7 +38,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl 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 salome_kernel.py salome_study.py salome_iapp.py +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 salome_kernel.py salome_study.py salome_iapp.py salome_ComponentGUI.py EXPORT_SHAREDPYSCRIPTS=kernel_shared_modules.py diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome.py b/src/SALOME_SWIG_WITHOUTIHM/salome.py index 25ccbfbaa..5591226dd 100755 --- a/src/SALOME_SWIG_WITHOUTIHM/salome.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome.py @@ -37,7 +37,10 @@ def salome_init(): if salome_initial: salome_initial=0 - orb, lcc, naming_service, cm = salome_kernel_init() sg = salome_iapp_init() + if not sg.hasDesktop(): + print "import salome_shared_modules once" + import salome_shared_modules + orb, lcc, naming_service, cm = salome_kernel_init() myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init() diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome_ComponentGUI.py b/src/SALOME_SWIG_WITHOUTIHM/salome_ComponentGUI.py new file mode 100644 index 000000000..617c88218 --- /dev/null +++ b/src/SALOME_SWIG_WITHOUTIHM/salome_ComponentGUI.py @@ -0,0 +1,56 @@ +# 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$ + + +# to replace some function from _SWIG, outside GUI + +# --- From GeometryGUI_SWIG + + #-------------------------------------------------------------------------- + +def getIndexTopology(aSubId, aMainId): + return 0 + + #-------------------------------------------------------------------------- + +def getShapeTypeString(aSubId): + return "SubShape" + + #-------------------------------------------------------------------------- + +# --- From SMESHGUI_SWIG + + #-------------------------------------------------------------------------- + +def Init(studyId): + return + + #-------------------------------------------------------------------------- + +def SetName(objId, name): + return + + #-------------------------------------------------------------------------- diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py b/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py index 33e47811e..519714a08 100644 --- a/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py @@ -25,17 +25,25 @@ # $Header$ from libSALOME_Swig import * +import salome_ComponentGUI #-------------------------------------------------------------------------- +IN_SALOME_GUI=0 + def ImportComponentGUI(ComponentName): - libName = "lib" + ComponentName + "_Swig" - command = "from " + libName + " import *" - exec ( command ) - constructor = ComponentName + "_Swig()" - command = "gui = " + constructor - exec ( command ) - return gui + if IN_SALOME_GUI: + libName = "lib" + ComponentName + "_Swig" + command = "from " + libName + " import *" + exec ( command ) + constructor = ComponentName + "_Swig()" + command = "gui = " + constructor + exec ( command ) + return gui + else: + print "Warning: ImportComponentGUI(",ComponentName,") outside GUI !" + print "calls to GUI methods may crash..." + return salome_ComponentGUI #-------------------------------------------------------------------------- diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome_study.py b/src/SALOME_SWIG_WITHOUTIHM/salome_study.py index ecc76728c..3fa7fb12b 100644 --- a/src/SALOME_SWIG_WITHOUTIHM/salome_study.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome_study.py @@ -139,7 +139,7 @@ def createNewStudy(): theStudyId = theStudy._get_StudyId() print aStudyName, theStudyId return theStudyId - + #-------------------------------------------------------------------------- salome_study_initial = 1