From: pascale.noyret Date: Fri, 22 May 2015 14:40:47 +0000 (+0200) Subject: ajout des SDCO X-Git-Tag: PSEN_V1~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ea440f7c90a999dccca3963cf88cec323fe7652f;p=tools%2Feficas.git ajout des SDCO --- diff --git a/InterfaceQT4/monWidgetCreeParam.py b/InterfaceQT4/monWidgetCreeParam.py new file mode 100644 index 00000000..c51f705b --- /dev/null +++ b/InterfaceQT4/monWidgetCreeParam.py @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- +# 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 +# +# Modules Python +import string,types,os,re +pattern_name = re.compile(r'^[^\d\W]\w*\Z') + +# Modules Eficas + +from PyQt4 import * +from PyQt4.QtGui import * +from PyQt4.QtCore import * +from Extensions.i18n import tr +from desWidgetCreeParam import Ui_desWidgetCreeParam + + +class MonWidgetCreeParam(Ui_desWidgetCreeParam,QDialog): + """ + """ + def __init__(self,editor, name = None,fl = 0): + self.editor=editor + QDialog.__init__(self,editor) + self.setupUi(self) + self.connecterSignaux() + self.dejaExistant=0 + self.listeTousParam=self.editor.jdc.params + self.dictListe={} + self.initToutesVal() + + def connecterSignaux(self) : + self.connect(self.lineEditVal,SIGNAL("returnPressed()"),self.lineEditValReturnPressed) + self.connect(self.lineEditNom,SIGNAL("returnPressed()"),self.lineEditNomReturnPressed) + + + def CreeParametre(self): + nom=str(self.lineEditNom.text()) + val=str(self.lineEditVal.text()) + if val == "" or None : return + if nom == "" or None : return + if len(self.editor.tree.selectedItems()) == 0 : + itemAvant=self.editor.tree.racine + else : + itemAvant=self.editor.tree.selectedItems()[0] + param=itemAvant.addParameters(True) + param.item.set_nom(nom) + param.item.set_valeur(val) + param.update_node_texte() + self.LBParam.addItem(QString(repr(param.item))) + + + def lineEditValReturnPressed(self): + qtVal=self.lineEditVal.text() + valString=str(self.lineEditVal.text()) + contexte={} + exec "from math import *" in contexte + jdc=self.editor.jdc + if jdc == None : + self.editor.affiche_infos(tr("La Creation de parametre n est possible que dans un jeu de données"),Qt.red) + return + + for p in jdc.params : + try: + tp=p.nom+'='+str(repr(p.valeur)) + exec tp in contexte + except : + pass + monTexte="monParam="+valString + try : + exec monTexte in contexte + except : + self.editor.affiche_infos(tr("Valeur incorrecte"),Qt.red) + if self.lineEditNom.text()!="" and self.dejaExistant==False : self.CreeParametre() + + + def lineEditNomReturnPressed(self): + qtNom=self.lineEditNom.text() + nom=str(qtNom) + if not pattern_name.match(nom) : + self.lineEditNom.setText("") + commentaire=nom + tr(" n est pas un identifiant correct\n ") + self.editor.affiche_infos(commentaire,Qt.red) + for p in self.editor.jdc.params : + if p.nom==nom : + commentaire=nom + tr(" existe déjà\n ") + self.editor.affiche_infos(commentaire,Qt.red) + return + + if self.lineEditVal.text()!="" : self.CreeParametre() + self.lineEditVal.setFocus(Qt.OtherFocusReason) + + + def initToutesVal(self): + self.LBParam.clear() + for param in self.listeTousParam : + self.LBParam.addItem(QString(repr(param))) + self.dictListe[QString(repr(param))] = param + + def valideParam(self): + if self.LBParam.selectedItems()== None : return + lParam=[] + for indice in range(len(self.LBParam.selectedItems())): + i=self.LBParam.selectedItems()[indice].text() + param=self.dictListe[i] + lParam.append(param) + + try : + self.panel.AjoutNValeur(lParam) + except : + for p in lParam : + self.panel.Ajout1Valeur(p) + self.close() + diff --git a/InterfaceQT4/monWidgetSDCOInto.py b/InterfaceQT4/monWidgetSDCOInto.py new file mode 100644 index 00000000..7b2638ec --- /dev/null +++ b/InterfaceQT4/monWidgetSDCOInto.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +# 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 +# +# Modules Python +import string,types,os + +# Modules Eficas +from PyQt4.QtGui import * +from PyQt4.QtCore import * +from Extensions.i18n import tr + +from feuille import Feuille +from desWidgetSDCOInto import Ui_WidgetSDCOInto +from qtSaisie import SaisieSDCO +from politiquesValidation import PolitiqueUnique + + + +class MonWidgetSDCOInto (Ui_WidgetSDCOInto,Feuille,SaisieSDCO): + + def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande): + print "MonWidgetSDCOInto init" + Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande) + self.politique=PolitiqueUnique(self.node,self.editor) + self.parentQt.commandesLayout.insertWidget(-1,self) + self.maCommande.listeAffichageWidget.append(self.LESDCO) + self.AAficher=self.LESDCO + self.initLBSDCO() + self.connect(self.LESDCO, SIGNAL("returnPressed()"),self.LESDCOReturnPressed) + self.connect(self.LBSDCO, SIGNAL("itemDoubleClicked(QListWidgetItem*)" ), self.LBSDCODoubleClicked ) + + def LESDCOReturnPressed(self) : + self.LBSDCO.clearSelection() + SaisieSDCO.LESDCOReturnPressed(self) + + + def initLBSDCO(self): + listeNomsSDCO = self.node.item.get_sd_avant_du_bon_type() + for aSDCO in listeNomsSDCO: + self.LBSDCO.insertItem( 1,aSDCO) + valeur = self.node.item.get_valeur() + if valeur != "" and valeur != None : + self.LESDCO.setText(QString(valeur.nom)) + + + def LBSDCODoubleClicked(self): + """ + Teste si la valeur fournie par l'utilisateur est une valeur permise : + - si oui, l'enregistre + - si non, restaure l'ancienne valeur + """ + nomConcept=str(self.LBSDCO.currentItem().text()) + self.LESDCO.clear() + self.editor.init_modif() + anc_val = self.node.item.get_valeur() + test_CO=self.node.item.is_CO(anc_val) + + valeur,validite=self.node.item.eval_valeur(nomConcept) + test = self.node.item.set_valeur(valeur) + if not test : + commentaire = tr("impossible d'evaluer : ") + valeur + elif validite: + commentaire = tr("Valeur du mot-clef enregistree") + if test_CO: + # il faut egalement propager la destruction de l'ancien concept + self.node.item.delete_valeur_co(valeur=anc_val) + self.node.item.object.etape.get_type_produit(force=1) + self.node.item.object.etape.parent.reset_context() + self.LESDCO.setText(QString(nomConcept)) + else : + commentaire = self.node.item.get_cr() + self.reset_old_valeur(anc_val,mess=mess) + self.editor.affiche_infos(commentaire,Qt.red) + self.Commentaire.setText(tr(commentaire)) + + diff --git a/InterfaceQT4/monWidgetUniqueSDCO.py b/InterfaceQT4/monWidgetUniqueSDCO.py new file mode 100644 index 00000000..960ab82d --- /dev/null +++ b/InterfaceQT4/monWidgetUniqueSDCO.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# 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 +# +# Modules Python +import string,types,os + +# Modules Eficas +from PyQt4.QtGui import * +from PyQt4.QtCore import * +from Extensions.i18n import tr + +from feuille import Feuille +from desWidgetUniqueSDCO import Ui_WidgetUniqueSDCO +from politiquesValidation import PolitiqueUnique +from qtSaisie import SaisieSDCO + + + + +class MonWidgetUniqueSDCO (Ui_WidgetUniqueSDCO,Feuille,SaisieSDCO): + + def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande): + print "dans MonWidgetSDCO" + Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande) + self.politique=PolitiqueUnique(self.node,self.editor) + self.parentQt.commandesLayout.insertWidget(-1,self) + self.maCommande.listeAffichageWidget.append(self.LESDCO) + self.AAficher=self.LESDCO + + valeur = self.node.item.get_valeur() + if valeur != "" and valeur != None : self.LESDCO.setText(valeur.nom) + self.connect(self.LESDCO,SIGNAL("returnPressed()"),self.LESDCOReturnPressed) +