From: Renaud Barate Date: Mon, 2 Dec 2013 14:05:40 +0000 (+0000) Subject: Add new type SalomeEntry to handle selection from Salome object browser X-Git-Tag: MAP_V2014_1~78 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6b887474c6a5fe25c09e4000acf7008678297922;p=tools%2Feficas.git Add new type SalomeEntry to handle selection from Salome object browser --- diff --git a/Accas/A_SALOME_ENTRY.py b/Accas/A_SALOME_ENTRY.py new file mode 100644 index 00000000..c78346a7 --- /dev/null +++ b/Accas/A_SALOME_ENTRY.py @@ -0,0 +1,24 @@ +# Copyright (C) 2007-2013 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# This empty class is replaced by the class eficas.SalomeEntry +# (defined in Salome EFICAS module) when Eficas is launched in Salome context. +# It handles the objects that can be selected from Salome object browser. +class SalomeEntry: + pass diff --git a/Accas/__init__.py b/Accas/__init__.py index 6c9a6542..a8c44a6d 100644 --- a/Accas/__init__.py +++ b/Accas/__init__.py @@ -105,3 +105,4 @@ from Extensions.parametre_eval import PARAMETRE_EVAL from Extensions.commande_comm import COMMANDE_COMM from Extensions.mcnuplet import MCNUPLET +from A_SALOME_ENTRY import SalomeEntry diff --git a/InterfaceQT4/monPlusieursBasePanel.py b/InterfaceQT4/monPlusieursBasePanel.py index cb69d061..e8b25694 100644 --- a/InterfaceQT4/monPlusieursBasePanel.py +++ b/InterfaceQT4/monPlusieursBasePanel.py @@ -88,7 +88,8 @@ class MonPlusieursBasePanel(DPlusBase,QTPanel,SaisieValeur): self.BSalome.setIcon(icon3) mc = self.node.item.get_definition() type = mc.type[0] - if not(('grma' in repr(type)) or ('grno' in repr(type)) or ('SalomeEntry' in repr(type))) or not(self.editor.salome) : + from Accas import SalomeEntry + if not(('grma' in repr(type)) or ('grno' in repr(type)) or (isinstance(type, types.ClassType) and issubclass(type, SalomeEntry))) or not(self.editor.salome) : self.BSalome.close() self.BView2D.close() @@ -230,13 +231,12 @@ class MonPlusieursBasePanel(DPlusBase,QTPanel,SaisieValeur): for e in genea: if "GROUP_NO" in e: kwType = "GROUP_NO" if "GROUP_MA" in e: kwType = "GROUP_MA" - mc = self.node.item.get_definition() - type = mc.type[0] + if 'grno' in repr(kwType): kwType = "GROUP_NO" + if 'grma' in repr(kwType): kwType = "GROUP_NO" - if 'grno' in repr(type): kwType = "GROUP_NO" - if 'grma' in repr(type): kwType = "GROUP_NO" - if 'SalomeEntry' in repr(type): - selection, commentaire = self.appliEficas.selectEntryFromSalome(editor=self.editor) + from Accas import SalomeEntry + if isinstance(kwType, types.ClassType) and issubclass(kwType, SalomeEntry): + selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor) selection[0]=str(selection[0]) #print "BkwType",kwType diff --git a/InterfaceQT4/monUniqueBasePanel.py b/InterfaceQT4/monUniqueBasePanel.py index bfdafe8a..a6ed13b5 100644 --- a/InterfaceQT4/monUniqueBasePanel.py +++ b/InterfaceQT4/monUniqueBasePanel.py @@ -102,9 +102,10 @@ class MonUniqueBasePanel(DUnBase,QTPanel,SaisieValeur): self.BFichier.close() self.BRepertoire.close() # TODO: Use type properties instead of hard-coded "grno" and "grma" type check + from Accas import SalomeEntry enable_salome_selection = self.editor.salome and \ - (('grma' in repr(mctype)) or ('grno' in repr(mctype)) or ('SalomeEntry' in repr(mctype)) or - (hasattr(mctype, "enable_salome_selection") and mctype.enable_salome_selection)) + (('grma' in repr(mctype)) or ('grno' in repr(mctype)) or \ + (isinstance(mctype, types.ClassType) and issubclass(mctype, SalomeEntry))) if not enable_salome_selection: self.BSalome.close() if not(('grma' in repr(mctype)) or ('grno' in repr(mctype))) or not(self.editor.salome): @@ -254,16 +255,15 @@ class MonUniqueBasePanel(DUnBase,QTPanel,SaisieValeur): if "GROUP_NO" in e: kwType = "GROUP_NO" if "GROUP_MA" in e: kwType = "GROUP_MA" - mc = self.node.item.get_definition() - type = mc.type[0] - if 'grno' in repr(type): kwType = "GROUP_NO" - if 'grma' in repr(type): kwType = "GROUP_NO" + if 'grno' in repr(kwType): kwType = "GROUP_NO" + if 'grma' in repr(kwType): kwType = "GROUP_NO" if kwType in ("GROUP_NO","GROUP_MA"): selection, commentaire = self.appliEficas.selectGroupFromSalome(kwType,editor=self.editor) - if 'SalomeEntry' in repr(type): - selection, commentaire = self.appliEficas.selectEntryFromSalome(editor=self.editor) + from Accas import SalomeEntry + if isinstance(kwType, types.ClassType) and issubclass(kwType, SalomeEntry): + selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor) if commentaire !="" : self.Commentaire.setText(QString(commentaire)) diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index a8e4e2c4..37e0cfe5 100644 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -58,6 +58,11 @@ class Appli(Ui_Eficas,QMainWindow): self.listeAEnlever=[] self.ListeCode=['Aster','Carmel3D','Cuve2dg','Openturns_Study','Openturns_Wrapper','MAP'] + if self.salome: + import Accas + import eficasSalome + Accas.SalomeEntry = eficasSalome.SalomeEntry + self.RepIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'../Editeur/icons') self.multi=multi if langue=='fr': self.langue=langue