From: pascale.noyret Date: Wed, 16 Jun 2021 13:24:32 +0000 (+0200) Subject: pour la matrice coloree X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aa859e0fbb5c087258f43bae0d7299e56333b908;p=tools%2Feficas.git pour la matrice coloree --- diff --git a/Accas/A_TUPLE.py b/Accas/A_TUPLE.py index c9564e28..3abdd067 100644 --- a/Accas/A_TUPLE.py +++ b/Accas/A_TUPLE.py @@ -1,6 +1,12 @@ # from __future__ import absolute_import from Noyau import N_TUPLE +from Ihm import I_TUPLE class Tuple (N_TUPLE.N_Tuple): pass -class Matrice(N_TUPLE.N_Matrice): pass +class Matrice (I_TUPLE.I_Matrice,N_TUPLE.N_Matrice):pass +# def __init__(self,*tup,**args): +# I_TUPLE.I_Matrice.__init__(self) +# N_TUPLE.N_Matrice(self,*tup,**args) +# print (tup) +# print (args) diff --git a/Ihm/I_ENTITE.py b/Ihm/I_ENTITE.py index 64323a9d..167f8190 100644 --- a/Ihm/I_ENTITE.py +++ b/Ihm/I_ENTITE.py @@ -62,11 +62,6 @@ class ENTITE: #print "#CMD", parent, nom elif val.label == 'FACT': val.checkDefinition(parent) - #PNPNPN surcharge - # CALC_SPEC ! - #assert self.label != 'FACT', \ - # 'Commande %s : Mot-clef facteur present sous un mot-clef facteur : interdit !' \ - # % parent else: continue del args[nom] @@ -80,159 +75,4 @@ class ENTITE: # % (parent, tuple(mcs.intersection(mcbloc))) return mcs -# def enregistreXML(self,root,catalogueXml): -# import xml.etree.ElementTree as ET -# import types -# moi=ET.SubElement(root,str(self.__class__)) -# nom=ET.SubElement(moi,'nom') -# nom.text=self.nom -# -# if hasattr(self,'validators') and (self.validators != () and self.validators != None): -# valid=ET.SubElement(moi,'validators') -# valid.text= str(self.validators.__class__) -# catalogueXml.validatorsUtilises.append(self.validators) -# -# if hasattr(self,'regles') and (self.regles !=() and self.regles != None): -# for regle in self.regles: -# regle.enregistreXML(moi,catalogueXml) -# catalogueXml.reglesUtilisees.append(self.regles) -# -# if ((self.getDocu() !="" and self.getDocu() !=None) or \ -# (self.fr != "" and self.fr != None) or \ -# (self.ang != "" and self.ang != None) ): -# dico={} -# if self.getDocu() !=None : dico["docu"]=self.getDocu() -# if self.fr != None : dico["fr"]=six.text_type(self.fr,"iso-8859-1") -# if self.ang != None : dico["ang"]=self.ang -# doc=ET.SubElement(moi,'doc') -# doc.attrib=dico -# -# if ((self.getSug() !=None) or \ -# (hasattr(self,'defaut') and (self.defaut != None) and (self.defaut != 'None'))) : -# # il faut ajouter des sug dans le catalogue -# # les attributs sont toujours du texte -# dico={} -# if (self.defaut != None) and (self.defaut != 'None') : -# if isinstance(self.defaut,str ) : dico["defaut"]=six.text_type(self.defaut,"iso-8859-1") -# else :dico["defaut"]=str(self.defaut) -# if self.getSug() !=None: -# if isinstance(self.getSug(),str ) : dico["sug"]=six.text_type(self.getSug(),"iso-8859-1") -# else :dico["sug"]=str(self.getSug()) -# -# doc=ET.SubElement(moi,'ValeurDef') -# doc.attrib=dico -# -# dico={} -# if hasattr(self,'into') and self.into!=None: dico['into']=str(self.into) -# if hasattr(self,'val_max') and self.val_max != "**" : dico['max']=str(self.val_max) -# if hasattr(self,'val_min') and self.val_min != "**" : dico['min']=str(self.val_min) -# if dico != {} : -# PV=ET.SubElement(moi,'PlageValeur') -# PV.attrib=dico -# -# dico={} -# if hasattr(self,'max') and self.max != 1 : dico['max']=str(self.max) -# if hasattr(self,'min') and self.min != 1 : dico['max']=str(self.min) -# if dico != {} : -# Card=ET.SubElement(moi,'Cardinalite') -# Card.attrib=dico -# -# dico={} -# if hasattr(self,'reentrant') and self.reentrant not in ('f','n') : dico['reentrant']=str(self.reentrant) -# if hasattr(self,'position') and self.position != "local": dico['position']=str(self.position) -# if hasattr(self,'homo') and self.homo != 1 : dico['homogene']=str(self.homo) -# if hasattr(self,'statut') : dico['statut']=str(self.statut) -# if hasattr(self,'repetable') : dico['repetable']=str(self.repetable) -# if dico != {} : -# pos=ET.SubElement(moi,'situation') -# pos.attrib=dico -# -# if hasattr(self,'type') and self.type != (): -# typeAttendu=ET.SubElement(moi,'typeAttendu') -# l=[] -# for t in self.type: -# if type(t) == type : l.append(t.__name__) -# else : l.append(t) -# typeAttendu.text=str(l) -# -# if hasattr(self,'sd_prod') and self.sd_prod != () and self.sd_prod !=None: -# typeCree=ET.SubElement(moi,'typeCree') -# typeCree.text=str(self.sd_prod.__name__) -# -# if hasattr(self,'op') and self.op !=None : -# subRoutine=ET.SubElement(moi,'subRoutine') -# subRoutine.text=str(self.op) -# -# if hasattr(self,'proc') and self.proc != None : -# construction=ET.SubElement(moi,'Construction') -# construction.text=self.proc.uri -# -# for nomFils, fils in self.entites.items() : -# fils.enregistreXML(moi,catalogueXml) -# -# def enregistreXMLStructure(self,root,catalogueXml): -# import xml.etree.ElementTree as ET -# import types -# moi=ET.SubElement(root,str(self.__class__)) -# -# if hasattr(self,'into') and self.into!=None: -# INTO=ET.SubElement(moi,'into') -# INTO.text='into' -# -# dico={} -# if hasattr(self,'val_max') and self.val_max != "**" : dico['max']=str(self.val_max) -# if hasattr(self,'val_min') and self.val_min != "**" : dico['min']=str(self.val_min) -# if dico != {} : -# PV=ET.SubElement(moi,'maxOrMin') -# PV.text='maxOrMin' -# -# dico={} -# if hasattr(self,'max') and self.max != 1 : dico['max']=str(self.max) -# if hasattr(self,'min') and self.min != 1 : dico['max']=str(self.min) -# if dico != {} : -# Card=ET.SubElement(moi,'liste') -# Card.text="liste" -# -# dico={} -# if hasattr(self,'statut') and self.statut=="f" : -# statut=ET.SubElement(moi,'facultatif') -# statut.text='facultatif' -# if hasattr(self,'statut') and self.statut !="f" : -# statut=ET.SubElement(moi,'obligatoire') -# statut.text='obligatoire' -# -# if hasattr(self,'type') and self.type != (): -# try : -# if 'Fichier' in self.type : ty=ET.SubElement(moi,'Fichier') -# ty.text='type' -# except : -# try : -# if 'Repertoire' in self.type : ty=ET.SubElement(moi,'Repertoire') -# ty.text='type' -# except : -# for t in self.type: -# if t == "I" : ty=ET.SubElement(moi,'typeEntier') -# elif t == "R" : ty=ET.SubElement(moi,'typeReel') -# elif t == "TXM" : ty=ET.SubElement(moi,'typeTXM') -# else : -# try : -# ty=ET.SubElement(moi,t.__name__) -# except : -# ty=ET.SubElement(moi,'autre') -# ty.text='type' -# -# if hasattr(self,'sd_prod') and self.sd_prod != () and self.sd_prod !=None: -# typeCree=ET.SubElement(moi,'typeCree') -# typeCree.text='sd_prod' -# -# if hasattr(self,'op') and self.op !=None : -# subRoutine=ET.SubElement(moi,'subRoutine') -# subRoutine.text='op' -# -# if hasattr(self,'proc') and self.proc != None : -# construction=ET.SubElement(moi,'Construction') -# construction.text='proc' -# -# for nomFils, fils in self.entites.items() : -# fils.enregistreXMLStructure(moi,catalogueXml) # diff --git a/Ihm/I_TUPLE.py b/Ihm/I_TUPLE.py new file mode 100644 index 00000000..519ba37a --- /dev/null +++ b/Ihm/I_TUPLE.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2021 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 +# + +class I_Matrice: + def activeCouleur(self): + self.dictCouleurs={} + self.indiceCouleur=1 + self.listeCouleurs=((10, 186, 181),(204, 204, 255),(121, 248, 248),(254, 231, 240),(250, 234, 115), (254, 191, 210),(248, 142, 85),(133, 193, 126),(210, 202, 236),(225, 206, 154), (187, 174, 152),(240, 195, 0),(242, 255, 255),(239, 239, 239),(149, 165, 149), (150, 131, 236),(201, 160, 220),(103, 159, 90),(176, 242, 182),(233, 201, 177)) + diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index 7300db67..f233f328 100755 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -121,6 +121,7 @@ def genereXML(code=None): from .editorSsIhm import JDCEditorSsIhm monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier) + print (options) if options.fichierXMLOut == None : fichierXMLOut=fichier[:fichier.rfind(".")]+'.xml' else : diff --git a/InterfaceQT4/monWidgetMatrice.py b/InterfaceQT4/monWidgetMatrice.py index 0edff3a8..02fb9311 100644 --- a/InterfaceQT4/monWidgetMatrice.py +++ b/InterfaceQT4/monWidgetMatrice.py @@ -37,7 +37,7 @@ from desWidgetMatrice import Ui_desWidgetMatrice from PyQt5.QtCore import QSize, Qt from PyQt5.QtWidgets import QTableWidgetItem, QTableWidget -from PyQt5.QtGui import QIcon +from PyQt5.QtGui import QIcon, QColor from PyQt5.QtWidgets import QMessageBox @@ -76,6 +76,20 @@ class MonWidgetMatrice (Ui_desWidgetMatrice,Feuille): self.editor.afficheInfos(tr(commentaire),Qt.red) monItem.setText("") return + if self.monType.coloree : self.coloreItem(monItem,texte) + + + def coloreItem(self,monItem,texte): + if texte in self.monType.dictCouleurs.keys() : + monItem.setBackground(self.monType.dictCouleurs[texte]) + else : + i=self.monType.indiceCouleur%20 + newCouleur=QColor(*self.monType.listeCouleurs[i]) + #monItem.setBackground(Qt.red) + monItem.setBackground(newCouleur) + self.monType.dictCouleurs[texte]=newCouleur + self.monType.indiceCouleur+=1 + def creeColonnes(self): @@ -88,14 +102,21 @@ class MonWidgetMatrice (Ui_desWidgetMatrice,Feuille): else : self.nbLigs=self.monType.nbLigs self.nbCols=self.monType.nbCols - self.TBMatrice.setColumnCount(self.nbLigs) - self.TBMatrice.setRowCount(self.nbCols) + self.TBMatrice.setColumnCount(self.nbCols) + self.TBMatrice.setRowCount(self.nbLigs) + if self.nbLigs <15 : taille = 50 + else : taille = 30 + for i in range(self.nbLigs) : + self.TBMatrice.setRowHeight(i,taille) + for i in range(self.nbCols) : + self.TBMatrice.setColumnWidth(i,taille) if self.monType.listeHeaders != None : - self.TBMatrice.setVerticalHeaderLabels(self.monType.listeHeaders[0]) - self.TBMatrice.setHorizontalHeaderLabels(self.monType.listeHeaders[1]) + self.TBMatrice.setHorizontalHeaderLabels(self.monType.listeHeaders[0]) + self.TBMatrice.setVerticalHeaderLabels(self.monType.listeHeaders[1]) else : self.TBMatrice.verticalHeader().hide() self.TBMatrice.horizontalHeader().hide() + # self.TBMatrice.setFixedSize(self.nbCols*20+10,self.nbLigs*20+10) def initialValeur(self): @@ -111,6 +132,7 @@ class MonWidgetMatrice (Ui_desWidgetMatrice,Feuille): raise EficasException('dimension') for j in range(self.nbCols): self.TBMatrice.setItem(i,j,QTableWidgetItem(str(liste[i][j]))) + if self.monType.coloree : self.coloreItem(self.TBMatrice.item(i,j),str(liste[i][j])) def acceptVal(self): liste=[] diff --git a/InterfaceQT4/monWidgetPlusieursBase.py b/InterfaceQT4/monWidgetPlusieursBase.py index 2a6f56c6..882ea440 100644 --- a/InterfaceQT4/monWidgetPlusieursBase.py +++ b/InterfaceQT4/monWidgetPlusieursBase.py @@ -136,7 +136,7 @@ class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie) def ajoutLineEdit(self,valeur=None,): - #print ('ajoutLineEdit plusieursBase') + print ('ajoutLineEdit plusieursBase') #print ('self.indexDernierLabel', self.indexDernierLabel) self.indexDernierLabel=self.indexDernierLabel+1 nomLineEdit="lineEditVal"+str(self.indexDernierLabel) @@ -182,7 +182,7 @@ class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie) return self.finCommentaireListe() def ajout1Valeur(self,valeur=None): - #print ('ajout1Valeur plusieursBase') + print ('ajout1Valeur plusieursBase') if valeur == None : return liste,validite=SaisieValeur.TraiteLEValeur(self,str(valeur)) if validite == 0 : return diff --git a/InterfaceQT4/readercata.py b/InterfaceQT4/readercata.py index e2550adb..a2ee29fa 100644 --- a/InterfaceQT4/readercata.py +++ b/InterfaceQT4/readercata.py @@ -228,14 +228,14 @@ class ReaderCata (ReaderCataCommun): self.QWParent.informe('environnement', 'please source pyxb environment') exit() try : - #if 1 : nomCataXsd = os.path.splitext(os.path.basename(self.fichierCata))[0] fichierCataTrunc=os.path.splitext(os.path.basename(self.fichierCata))[0] nomCataXsd = fichierCataTrunc+'_driver' pathCata = os.path.dirname(self.fichierCata)+'/raw/'+nomCataXsd+'.py' + print ('nomCataXsd , pathCata ',nomCataXsd,pathCata) import imp modeleMetier= imp.load_source(nomCataXsd,pathCata) - #print ('nomCataXsd , pathCata ',nomCataXsd,pathCata) + print ('nomCataXsd , pathCata ',nomCataXsd,pathCata) try : #if 1 : #monObjetAnnotation = getattr(modeleMetier,'PNEFdico_'+self.code) @@ -251,7 +251,6 @@ class ReaderCata (ReaderCataCommun): #print ('dans readerCata _________', dicoEltDif) except : - #else : if self.appliEficas.ssIhm == False :print ('______________ poum import cata_genere ') self.QWParent.informe('XSD driver', 'unable to load xsd driver',critique=False) modeleMetier = None @@ -437,9 +436,9 @@ class ReaderCata (ReaderCataCommun): #else : print (niveau+1)*" ", nom - def dumpToXsdEficas(self): + #def dumpToXsdEficas(self): # Pas sur qu on ait jamais besoin de cela - pass + # pass #from Efi2Xsd import readerEfficas #newSchema= xml = open('Cata_MED_FAM.xml').read() #SchemaMed = efficas.CreateFromDocument(xml) diff --git a/Noyau/N_TUPLE.py b/Noyau/N_TUPLE.py index fe1694c4..8b146cad 100644 --- a/Noyau/N_TUPLE.py +++ b/Noyau/N_TUPLE.py @@ -20,7 +20,7 @@ class N_Matrice: def __init__(self, nbLigs=None, nbCols=None, methodeCalculTaille=None, formatSortie="ligne", valSup=None, valMin=None, structure=None, typElt='R', - typEltInto=None, listeHeaders=None): + typEltInto=None, listeHeaders=None, coloree=False): self.nbLigs = nbLigs self.nbCols = nbCols self.methodeCalculTaille = methodeCalculTaille @@ -32,6 +32,9 @@ class N_Matrice: self.listeHeaders = listeHeaders self.typEltInto = typEltInto self.jdc=None + self.coloree=coloree + self.coloree=True + if self.coloree : self.activeCouleur() def __convert__(self, valeur): # Attention ne verifie pas grand chose diff --git a/UiQT5/desWidgetMatrice.ui b/UiQT5/desWidgetMatrice.ui index 62220b3d..378b9d7f 100644 --- a/UiQT5/desWidgetMatrice.ui +++ b/UiQT5/desWidgetMatrice.ui @@ -6,40 +6,34 @@ 0 0 - 1067 - 770 + 399 + 226 + + + 0 + 0 + + 0 - 250 + 0 Dialog - - 4 - - - 0 - - - 0 - - - 0 - - - 0 - 0 + + QLayout::SetFixedSize + @@ -130,7 +124,8 @@ - .. + + @@ -165,7 +160,7 @@ - 178 + 100 16777215 @@ -184,9 +179,83 @@ - + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 2 + 2 + + + + + + + + + + + 200 + 200 + + + + QFrame::Box + + + QFrame::Raised + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Ignored + + + + 20 + 2 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 2 + 2 + + + + label + horizontalSpacer_2 + TBMatrice