From 99670743286d6408ccf6380c967b6e4ec96f07d8 Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Mon, 1 Apr 2019 14:11:27 +0200 Subject: [PATCH] Test des ASSD et des UserASSD --- CatasDeTests/cata_proc.py | 50 +++++++++ CatasDeTests/prefs.py | 22 ++++ CatasDeTests/prefs_Essai.py | 56 ++++++++++ CatasDeTests/qtEficasEssai.py | 35 +++++++ Ihm/I_JDC.py | 10 +- Ihm/I_MCSIMP.py | 28 ++++- InterfaceQT4/browser.py | 6 +- InterfaceQT4/composimp.py | 8 +- InterfaceQT4/configuration.py | 3 +- InterfaceQT4/gereListe.py | 51 +++++++--- InterfaceQT4/monWidgetCommande.py | 2 +- InterfaceQT4/monWidgetPlusieursBase.py | 135 +++++++++++-------------- InterfaceQT4/monWidgetRadioButton.py | 1 - InterfaceQT4/politiquesValidation.py | 2 + InterfaceQT4/qtSaisie.py | 12 +-- Noyau/N_BLOC.py | 2 +- Noyau/N_ENTITE.py | 29 +++--- Noyau/N_JDC.py | 4 +- Noyau/N_MCSIMP.py | 24 +++-- Noyau/N_OBJECT.py | 38 +++++++ Noyau/N_SIMP.py | 43 ++------ Noyau/N_VALIDATOR.py | 2 +- 22 files changed, 389 insertions(+), 174 deletions(-) create mode 100644 CatasDeTests/cata_proc.py create mode 100644 CatasDeTests/prefs.py create mode 100644 CatasDeTests/prefs_Essai.py create mode 100755 CatasDeTests/qtEficasEssai.py diff --git a/CatasDeTests/cata_proc.py b/CatasDeTests/cata_proc.py new file mode 100644 index 00000000..19984c0f --- /dev/null +++ b/CatasDeTests/cata_proc.py @@ -0,0 +1,50 @@ +# Copyright (C) 2008-2018 EDF R&D +# +# This file is part of SALOME ADAO module +# +# 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 +import os, re +import Accas +from Accas import * + +JdC = JDC_CATA ( + code = 'Map2', + ) +VERSION_CATALOGUE='V_0' + +class classCL(ASSD): pass + +class Surface_Elementaire(UserASSD): pass + +def creeSurfaceElementaire(MC) : + # PNPN pour qu eric puisse tester + MC.creeObjetClasse(Surface_Elementaire) + return + + +CL=OPER(nom = 'CL', sd_prod=classCL, + Unite = SIMP(statut='o',typ='I',defaut=1), +) +MODELE_NUM = PROC( nom = 'MODELE_NUM', + MCA = SIMP(statut='o',typ='TXM'), + Condition = SIMP(statut='o',typ=classCL), +) +MODELE_NUM2 = PROC( nom = 'MODELE_NUM2', + surface_Elementaire=SIMP(statut= 'o',typ= 'TXM',max='**', siValide=creeSurfaceElementaire), + essai=SIMP(statut = 'f', typ = Surface_Elementaire), +) + diff --git a/CatasDeTests/prefs.py b/CatasDeTests/prefs.py new file mode 100644 index 00000000..540898b5 --- /dev/null +++ b/CatasDeTests/prefs.py @@ -0,0 +1,22 @@ +# Copyright (C) 2007-2012 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 +# +code="Essai" +import sys, os +if os.path.dirname(os.path.abspath(__file__)) not in sys.path : + sys.path.insert(0,os.path.dirname(os.path.abspath(__file__))) diff --git a/CatasDeTests/prefs_Essai.py b/CatasDeTests/prefs_Essai.py new file mode 100644 index 00000000..66852da1 --- /dev/null +++ b/CatasDeTests/prefs_Essai.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# maConfiguration MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM 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 +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +import os,sys +# repIni sert a localiser le fichier editeur.ini +# Obligatoire +repIni=os.path.dirname(os.path.abspath(__file__)) +INSTALLDIR=os.path.join(repIni,'..') +sys.path[:0]=[INSTALLDIR] + + +# lang indique la langue utilisee pour les chaines d'aide : fr ou ang +lang='fr' + +# Codage des strings qui accepte les accents (en remplacement de 'ascii') +encoding='iso-8859-1' + +# +#typeDeCata='XML' +catalogues=( +# ('Essai','V2017',os.path.join(repIni,'cata_bloc_ambigu.py'),'python','xml'), +# ('Essai','V2017',os.path.join(repIni,'cata_blocs.py'),'python','xml'), +# ('Essai','V2017',os.path.join(repIni,'cata_blocs_alter.py'),'python','xml'), + ('Essai','V2017',os.path.join(repIni,'cata_proc.py'),'python','python'), +# ('Essai','V2017',os.path.join(repIni,'cata_condition_2MC.py'),'python','python'), +# ('Essai','V2017',os.path.join(repIni,'cata_bloc_V0.py'),'python','xml'), +# ('Essai','V2017',os.path.join(repIni,'cata_global.py'),'python','python'), +) +#nombreDeBoutonParLigne=4 +simpleClic=True +#closeFrameRechercheCommande=True +boutonDsMenuBar=False +#closeArbre=True +afficheListesPliees=False +#withXSD=True +afficheCommandesPliees = False +#dumpXSD=True +#afficheIhm=False diff --git a/CatasDeTests/qtEficasEssai.py b/CatasDeTests/qtEficasEssai.py new file mode 100755 index 00000000..f16668ba --- /dev/null +++ b/CatasDeTests/qtEficasEssai.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# -*- 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 +# +""" + Ce module sert a lancer EFICAS configure pour MAP +""" +# Modules Python +# Modules Eficas +import prefs +name='prefs_'+prefs.code +__import__(name) + +import os, sys +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) + +import prefs +from InterfaceQT4 import eficas_go +eficas_go.lanceEficas(code=prefs.code) diff --git a/Ihm/I_JDC.py b/Ihm/I_JDC.py index aaf1bc0a..47491375 100644 --- a/Ihm/I_JDC.py +++ b/Ihm/I_JDC.py @@ -73,7 +73,6 @@ class JDC(I_OBJECT.OBJECT): """ d=self.getContexteAvant(etape) - l=[] for k,v in d.items(): #if type(v) != types.InstanceType and not isinstance(v,object): continue @@ -86,6 +85,14 @@ class JDC(I_OBJECT.OBJECT): l.sort() return l + def getSdCreeParObjet(self,classeAChercher): + l=[] + for v in list(self.sds_dict.keys()): + if (isinstance(self.sds_dict[v], classeAChercher)) : + l.append(self.sds_dict[v]) + return l + + def getVariables(self,etape): etapeStop=etape l=[] @@ -915,6 +922,7 @@ class JDC(I_OBJECT.OBJECT): # positionne prealablement par un appel a setEtapeContext if CONTEXT.debug : print(("JDC.NommerSdprod ",sd,sdnom)) + print(("JDC.NommerSdprod ",sd,sdnom)) if self._etape_context: o=self.getContexteAvant(self._etape_context).get(sdnom,None) diff --git a/Ihm/I_MCSIMP.py b/Ihm/I_MCSIMP.py index 7e421fd4..4602db88 100644 --- a/Ihm/I_MCSIMP.py +++ b/Ihm/I_MCSIMP.py @@ -45,6 +45,7 @@ from . import CONNECTOR from Noyau.N_ASSD import ASSD,assd from Noyau.N_GEOM import GEOM,geom from Noyau.N_CO import CO +from Accas.A_ASSD import UserASSD import Accas # fin attention @@ -69,6 +70,7 @@ class MCSIMP(I_OBJECT.OBJECT): self.definition.siValide(self) return validite + def getNomConcept(self): p=self while p.parent : @@ -191,16 +193,28 @@ class MCSIMP(I_OBJECT.OBJECT): return 0 def waitAssd(self): + """ + Methode booleenne qui retourne 1 si le MCS attend un objet de type ASSD ou UserASSD + ou derive, 0 sinon + """ + for typ in self.definition.type: + if type(typ) == type or isinstance(typ,type): + if issubclass(typ,ASSD) and not issubclass(typ,GEOM) : + return 1 + return 0 + + def waitUserAssd(self): """ Methode booleenne qui retourne 1 si le MCS attend un objet de type ASSD ou derive, 0 sinon """ for typ in self.definition.type: if type(typ) == type or isinstance(typ,type): - if issubclass(typ,ASSD) and not issubclass(typ,GEOM): + if issubclass(typ,UserASSD) : return 1 return 0 + def waitAssdOrGeom(self): """ Retourne 1 si le mot-cle simple attend un objet de type @@ -323,7 +337,7 @@ class MCSIMP(I_OBJECT.OBJECT): self.parent.updateConditionBloc() def setValeur(self,new_valeur,evaluation='oui'): - print ("setValeur Ihm/IMCSIMP ",new_valeur) + #print ("setValeur Ihm/IMCSIMP ",new_valeur) self.initModif() self.valeur = new_valeur self.val = new_valeur @@ -340,7 +354,6 @@ class MCSIMP(I_OBJECT.OBJECT): """ sd = self.jdc.getSdAvantEtape(new_valeur,self.etape) #sd = self.jdc.getContexteAvant(self.etape).get(new_valeur,None) - #print sd if sd is not None: return sd,1 lsd = self.jdc.chercheListAvant(self.etape,new_valeur) @@ -352,8 +365,10 @@ class MCSIMP(I_OBJECT.OBJECT): d['EVAL']=Accas.EVAL try : objet = eval(new_valeur,d) + print (1) return objet,1 except Exception: + print (2) itparam=self.chercheItemParametre(new_valeur) if itparam: return itparam,1 @@ -385,11 +400,14 @@ class MCSIMP(I_OBJECT.OBJECT): def evalValItem(self,new_valeur): """ - Tente d'evaluer new_valeur comme un concept, un parametre, un objet Python + Tente d'evaluer new_valeur comme un concept, un parametre, un objet Python ou un UserASSD Si c'est impossible retourne new_valeur inchange argument new_valeur : string (nom de concept, de parametre, expression ou simple chaine) """ - if self.etape and self.etape.parent: + if new_valeur in list(self.jdc.sds_dict.keys()) and self.waitUserAssd(): + valeur=self.jdc.sds_dict[new_valeur] + return valeur + elif self.etape and self.etape.parent: valeur=self.etape.parent.evalInContext(new_valeur,self.etape) return valeur else: diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 169cc7a5..d1bbb146 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -292,6 +292,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): self.item.connect("valid",self.onValid,()) self.item.connect("supp" ,self.onSupp,()) self.item.connect("add" ,self.onAdd,()) + self.item.connect("reconstruit" ,self.onReconstruit,()) self.state="" self.fenetre=None @@ -684,7 +685,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): # #------------------------------------------------------------------ def onValid(self): - #print ("onValid pour ", self.item.nom) + print ("onValid pour ", self.item.nom) if self.JESUISOFF==1 : return if hasattr(self,'fenetre') and self.fenetre: try : @@ -703,6 +704,9 @@ class JDCNode(QTreeWidgetItem,GereRegles): self.updateNodeLabel() self.updateNodeTexte() + def onReconstruit(self): + print ("onReconstruire pour ", self.item.nom) + def onAdd(self,object): if self.JESUISOFF==1 : return #print ("onAdd pour ", self.item.nom, object) diff --git a/InterfaceQT4/composimp.py b/InterfaceQT4/composimp.py index 9566ef2a..782698b5 100644 --- a/InterfaceQT4/composimp.py +++ b/InterfaceQT4/composimp.py @@ -35,6 +35,7 @@ from Editeur import Objecttreeitem from InterfaceQT4 import browser from Noyau.N_CR import justifyText from Accas import SalomeEntry +from Accas import UserASSD class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): @@ -536,8 +537,12 @@ class SIMPTreeItem(Objecttreeitem.AtomicObjectTreeItem): Retourne la liste des noms des SD presentes avant l'etape qui contient le MCS pointe par self et du type requis par ce MCS """ + print ('self.object.definition.type' , self.object.definition.type) a=self.object.etape.parent.getSdAvantDuBonType(self.object.etape,self.object.definition.type) - return a + + if self.waitUserAssd() : l=self.jdc.getSdCreeParObjet(self.object.definition.type) + else :l=[] + return a+l def getSdAvantDuBonTypePourTypeDeBase(self): a=self.object.jdc.getSdAvantDuBonTypePourTypeDe_Base(self.object.etape,"LASSD") @@ -716,7 +721,6 @@ class SIMPTreeItem(Objecttreeitem.AtomicObjectTreeItem): valeurretour,validite = valeur,1 else : valeurretour,validite= self.object.evalValeur(valeur) - #print "evalValeurItem",valeurretour,validite if validite == 0: if (type(valeur) == bytes or type(valeur) == str )and self.object.waitTxm(): diff --git a/InterfaceQT4/configuration.py b/InterfaceQT4/configuration.py index f4ab1d9b..6057ce38 100644 --- a/InterfaceQT4/configuration.py +++ b/InterfaceQT4/configuration.py @@ -124,10 +124,11 @@ class configBase(object): self.boutonDsMenuBar=False self.ficIcones=None self.repIcones=None - self.differencieSiDefaut=True + self.differencieSiDefaut=False self.typeDeCata='Python' self.closeParenthese=False self.closeOptionnel=False + self.afficheFactOptionnel=False self.enleverActionStructures=False self.enleverPoubellePourCommande=False self.enleverParametres=False diff --git a/InterfaceQT4/gereListe.py b/InterfaceQT4/gereListe.py index 755b00e7..de215c01 100644 --- a/InterfaceQT4/gereListe.py +++ b/InterfaceQT4/gereListe.py @@ -32,7 +32,7 @@ import traceback import six from six.moves import range -from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog +from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog, QMessageBox from PyQt5.QtCore import QEvent, Qt, QTimer from PyQt5.QtGui import QIcon, QPalette @@ -55,39 +55,62 @@ class LECustom(QLineEdit): self.numDsLaListe=-1 self.parentTuple=None self.valeur=None + self.editingFinished.connect(self.editFinished) + self.textEdited.connect(self.edited) + self.parentWidgetPlusieurs = parent + self.oldValeur=None + + def edited(self,text): + #print ('dans textEdited') + self.parentQt.changeUnLineEdit=True def focusInEvent(self,event): #print ("dans focusInEvent de LECustom") self.parentQt.aEuLeFocus=True - self.aEuLeFocus=True - self.parentQt.LineEditEnCours=self self.parentQt.numLineEditEnCours=self.num self.parentQt.textSelected=self.text() self.setStyleSheet("border: 2px solid gray") + self.oldValeur=self.text() QLineEdit.focusInEvent(self,event) def focusOutEvent(self,event): - #print (self.aEuLeFocus) + #print ("dans focusOutEvent de LECustom") self.setStyleSheet("border: 0px") if self.dansUnTuple : self.setStyleSheet("background:rgb(235,235,235); border: 0px;") elif self.num % 2 == 1 : self.setStyleSheet("background:rgb(210,210,210)") else : self.setStyleSheet("background:rgb(235,235,235)") - if self.aEuLeFocus: - self.aEuLeFocus=False - self.litValeur() - if self.dansUnTuple : self.parentTuple.getValeur() + if (self.oldValeur == self.text()): QLineEdit.focusOutEvent(self,event);return + self.litValeur() QLineEdit.focusOutEvent(self,event) + def editFinished(self): + #print ("dans editFinished de LECustom") + if (self.oldValeur == self.text()): return + self.litValeur() def litValeur(self): #print ("dans litValeur de LECustom") - self.aEuLeFocus=False + if (self.oldValeur == self.text()): return + self.oldValeur = self.text() val=str(self.text()) - if str(val)=="" or val==None : - self.valeur=None - return - try : - valeur=eval(val,{}) + + # on verifie les ',' + lval=val.split(',') + if len (lval) == 2 : + msgBox=QMessageBox() + msgBox.setText("separator ',' ") + msgBox.setInformativeText("Do you want to enter " + '.'.join(lval) + "?") + msgBox.setStandardButtons( QMessageBox.Ok | QMessageBox.Cancel) + msgBox.setDefaultButton(QMessageBox.Ok) + ret = msgBox.exec_() + if ret != 1024 : self.setText("") + else : self.setText('.'.join(lval)) + self.litValeur() + if len (lval) > 2 : + self.setText("") + self.litValeur() + if str(val)=="" or val==None : self.valeur=None; return + try : valeur=eval(val,{}) except : try : d=self.parentQt.parentQt.objSimp.jdc.getContexteAvant(self.parentQt.objSimp. etape) diff --git a/InterfaceQT4/monWidgetCommande.py b/InterfaceQT4/monWidgetCommande.py index 64c208e7..da899b4e 100644 --- a/InterfaceQT4/monWidgetCommande.py +++ b/InterfaceQT4/monWidgetCommande.py @@ -29,7 +29,7 @@ from desWidgetCommande import Ui_WidgetCommande from .groupe import Groupe from .gereIcones import FacultatifOuOptionnel -from PyQt5.QtWidgets import QApplication, QWidget, QSpacerItem, QSizePolicy +from PyQt5.QtWidgets import QApplication, QWidget, QSpacerItem, QSizePolicy, QRadioButton from PyQt5.QtGui import QFont, QIcon from PyQt5.QtCore import QTimer from PyQt5.QtCore import Qt diff --git a/InterfaceQT4/monWidgetPlusieursBase.py b/InterfaceQT4/monWidgetPlusieursBase.py index 31cb03c1..d00e22df 100644 --- a/InterfaceQT4/monWidgetPlusieursBase.py +++ b/InterfaceQT4/monWidgetPlusieursBase.py @@ -43,93 +43,92 @@ from InterfaceQT4.gereListe import GereListe from InterfaceQT4.gereListe import GerePlie from InterfaceQT4.gereListe import LECustom -dicoLongueur={2:95,3:125,4:154,5:183,6:210,float('inf'):210} -hauteurMax=253 +dicoLongueur = {2:90,3:100,4:123,5:145,6:160,float('inf'):190} +hauteurMaxFenetre = 190 class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie): def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande): - #print "MonWidgetPlusieursBase", nom - self.inFocusOutEvent=False - self.nomLine="lineEditVal" - self.inInit=True - self.indexDernierLabel=0 - self.numLineEditEnCours=0 - self.listeAffichageWidget=[] + self.inFocusOutEvent = False + self.changeUnLineEdit = False + self.nomLine = "lineEditVal" + self.inInit = True # pour l affichage quand on cree le lineEdit + self.indexDernierLabel = 0 + self.numLineEditEnCours = 0 + self.listeAffichageWidget = [] + self.politique = PolitiquePlusieurs(node,parentQt) Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande) GereListe.__init__(self) self.gereIconePlier() self.BSelectFichier.clicked.connect(self.selectInFile) if sys.platform[0:5]!="linux": - repIcon=self.node.editor.appliEficas.repIcon - fichier=os.path.join(repIcon, 'arrow_up.png') - icon = QIcon(fichier) - self.RBHaut.setIcon(icon) + repIcon = self.node.editor.appliEficas.repIcon + fichierUp = os.path.join(repIcon, 'arrow_up.png') + iconUp = QIcon(fichierUp) + self.RBHaut.setIcon(iconUp) self.RBHaut.setIconSize(QSize(32, 32)) - fichier2=os.path.join(repIcon, 'arrow_down.png') - icon2 = QIcon(fichier2) - self.RBBas.setIcon(icon2) - fichier3=os.path.join(repIcon, 'file-explorer.png') - icon3 = QIcon(fichier2) - self.BSelectFichier.setIcon(icon3) + fichierDown = os.path.join(repIcon, 'arrow_down.png') + iconDown = QIcon(fichierDown) + self.RBBas.setIcon(iconArrowDown) + fichierExp = os.path.join(repIcon, 'file-explorer.png') + iconExp = QIcon(fichierExp) + self.BSelectFichier.setIcon(iconExp) self.BSelectFichier.setIconSize(QSize(32, 32)) - icon=QIcon(self.repIcon+"/MoinsBleu.png") - self.RBMoins.setIcon(icon) - icon=QIcon(self.repIcon+"/PlusBleu.png") - self.RBPlus.setIcon(icon) - icon=QIcon(self.repIcon+"/verre-loupe-icone-6087-64.png") - self.RBVoisListe.setIcon(icon) + + iconMoins = QIcon (self.repIcon+"/MoinsBleu.png") + self.RBMoins.setIcon(iconMoins) + iconPlus = QIcon(self.repIcon+"/PlusBleu.png") + self.RBPlus.setIcon(iconPlus) + iconLoupe =QIcon(self.repIcon+"/verre-loupe-icone-6087-64.png") + self.RBVoisListe.setIcon(iconLoupe) self.listeValeursCourantes=self.node.item.getListeValeurs() - if self.monSimpDef.max != "**" and self.monSimpDef.max < 7: - hauteurMax=dicoLongueur[self.monSimpDef.max] - else : - hauteurMax=220 - # if self.monSimpDef.max == self.monSimpDef.min : self.setMaximumHeight(hauteur) - self.resize(self.width(),hauteurMax) + self.vScrollBar = self.scrollArea.verticalScrollBar() + + if self.monSimpDef.max < 7 : + hauteurMax = dicoLongueur[self.monSimpDef.max] + self.RBVoisListe.close() + self.RBMoins.close() + self.RBPlus.close() + aConstruire = self.monSimpDef.max + else : + hauteurMax = hauteurMaxFenetre + aConstruire = 7 self.setMinimumHeight(hauteurMax) - self.finCommentaireListe() + for i in range(1,aConstruire): self.ajoutLineEdit() + + self.parentQt.commandesLayout.insertWidget(-1,self) + self.maCommande.listeAffichageWidget.append(self.lineEditVal1) - self.AAfficher=self.lineEditVal1 - self.inInit=False + self.AAfficher = self.lineEditVal1 + self.inInit = False # PNPN a completer __ si tuple le type des tuples sinon le tuple + self.finCommentaireListe() self.monCommentaireLabel.setText(self.finCommentaireListe()) self.scrollArea.leaveEvent = self.leaveEventScrollArea def setValeurs(self): - self.vScrollBar = self.scrollArea.verticalScrollBar() - self.politique=PolitiquePlusieurs(self.node,self.editor) - # construction du min de valeur a entrer - if self.monSimpDef.max == "**" : aConstruire=7 - elif self.monSimpDef.max == float('inf'): aConstruire=7 - else : aConstruire=self.monSimpDef.max - - for i in range(1,aConstruire): - self.ajoutLineEdit() - QApplication.processEvents() - self.scrollArea.ensureWidgetVisible(self.lineEditVal1) + # uniquement appele a l initialisation. + # les lineEdit ont deja ete crees self.listeValeursCourantes=self.node.item.getListeValeurs() index=1 for valeur in self.listeValeursCourantes : - val=self.politique.getValeurTexte(valeur) - nomLineEdit="lineEditVal"+str(index) + val = self.politique.getValeurTexte(valeur) + nomLineEdit = "lineEditVal"+str(index) if hasattr(self,nomLineEdit) : - courant=getattr(self,nomLineEdit) + courant = getattr(self,nomLineEdit) if 'R' in self.objSimp.definition.type and str(val) != repr(val) : courant.setText(repr(val)) - else : courant.setText(str(val)) + else : courant.setText(str(val)) else : self.ajoutLineEdit(val) index=index+1 - # ajout d'une ligne vide ou affichage commentaire + if self.indexDernierLabel < self.monSimpDef.max : self.ajoutLineEdit() - else : self.scrollArea.setToolTip('nb max de valeurs atteint') - #self.adjustSize() - #self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum) def ajoutLineEdit(self,valeur=None,): @@ -173,6 +172,8 @@ class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie) return self.finCommentaireListe() def ajout1Valeur(self,valeur=None): + #import traceback + #traceback.print_stack() if valeur == None : return liste,validite=SaisieValeur.TraiteLEValeur(self,str(valeur)) if validite == 0 : return @@ -198,7 +199,7 @@ class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie) def ajoutNValeur(self,liste): #---------------------------- # attention quand on charge par un fichier, on ne peut pas se contenter d ajouter N fois 1 valeur - # car alors le temps de verification devient prohibitif reconstructu=ion et verification a + # car alors le temps de verification devient prohibitif reconstructution et verification a # chaque valeur. d ou l ajout de ajoutNTuple a politique plusieurs @@ -238,28 +239,12 @@ class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie) def changeValeur(self,changeDePlace=True,oblige=False): + #print ('monWidgetPlusieursBase changeValeur') + self.changeUnLineEdit = False donneFocus=None derniereValeur=None self.listeValeursCourantes = [] fin=self.indexDernierLabel - for i in range (1, fin): - nomLineEdit="lineEditVal"+str(i) - courant=getattr(self,nomLineEdit) - valeur=courant.text() - lval=valeur.split(',') - if len (lval) > 1 : - msgBox=QMessageBox() - msgBox.setText("separator ',' ") - msgBox.setInformativeText("Do you want to enter " + str (lval) + "?") - msgBox.setStandardButtons( QMessageBox.Ok | QMessageBox.Cancel) - msgBox.setDefaultButton(QMessageBox.Ok) - ret = msgBox.exec_() - if ret != 1024 : - courant.setText("") - return - courant.setText(lval[0]) - self.ajoutNValeur(lval[1:]) - self.listeValeursCourantes = [] for i in range (1, self.indexDernierLabel+1): nomLineEdit="lineEditVal"+str(i) @@ -300,7 +285,7 @@ class MonWidgetPlusieursBase (Ui_WidgetPlusieursBase,Feuille,GereListe,GerePlie) def leaveEventScrollArea(self,event): - self.changeValeur(changeDePlace=False) - QScrollArea.leaveEvent(self.scrollArea,event) + #print ('monWidgetPlusBase leaveEventScrollArea', self.changeUnLineEdit) + if self.changeUnLineEdit : self.changeValeur(changeDePlace=False) + QScrollArea.leaveEvent(self.scrollArea,event) -# Avertissement quand on quitte le widget diff --git a/InterfaceQT4/monWidgetRadioButton.py b/InterfaceQT4/monWidgetRadioButton.py index 129046be..569e56be 100644 --- a/InterfaceQT4/monWidgetRadioButton.py +++ b/InterfaceQT4/monWidgetRadioButton.py @@ -89,7 +89,6 @@ class MonWidgetRadioButtonCommun (Feuille): def boutonclic(self): for valeur in self.dict_bouton: if self.dict_bouton[valeur].isChecked(): - #print "dans boutonclic is checked", valeur, type(valeur) SaisieValeur.LEvaleurPressed(self,valeur) self.reaffiche() diff --git a/InterfaceQT4/politiquesValidation.py b/InterfaceQT4/politiquesValidation.py index a93175d7..274a9f82 100644 --- a/InterfaceQT4/politiquesValidation.py +++ b/InterfaceQT4/politiquesValidation.py @@ -34,9 +34,11 @@ class Validation(object) : def __init__(self,node,parent) : self.node=node self.parent=parent + def testeUneValeur(self,valeurentree): commentaire = None + #print ('testeUneValeur', valeurentree) valeur,validite=self.node.item.evalValeur(valeurentree) if not validite : commentaire = "impossible d'evaluer : %s " %repr(valeurentree) diff --git a/InterfaceQT4/qtSaisie.py b/InterfaceQT4/qtSaisie.py index 1b0b79ab..b674b031 100644 --- a/InterfaceQT4/qtSaisie.py +++ b/InterfaceQT4/qtSaisie.py @@ -42,6 +42,7 @@ class SaisieValeur(object): def LEvaleurPressed(self,valeur=None): + #print('LEvaleurPressed', valeur, type(valeur)) if not hasattr(self, 'inSaisieValeur' ) : self.inSaisieValeur=False if self.inSaisieValeur : return self.inSaisieValeur=True @@ -82,17 +83,6 @@ class SaisieValeur(object): self.setValide() - #def TraiteLEValeurTuple(self,valeurBrute=None) : - # listeValeurs=[] - # if valeurBrute== None :valeurBrute=str(self.LEValeur.text()) - # listeValeursSplit=valeurBrute.split(',') - # for val in listeValeursSplit : - # try : - # valeur=eval(val,{}) - # except : - # valeur=val - # listeValeurs.append(valeur) - # return listeValeurs def TraiteLEValeur(self,valeurTraitee=None) : # lit la chaine entree dans le line edit diff --git a/Noyau/N_BLOC.py b/Noyau/N_BLOC.py index b1315229..dba5f82b 100644 --- a/Noyau/N_BLOC.py +++ b/Noyau/N_BLOC.py @@ -147,7 +147,7 @@ class BLOC(N_ENTITE.ENTITE): def longueurDsArbre(self): longueur=0 for mc in self.mcListe : - longueur = longueur + longueurDsArbre(mc) + longueur = longueur + mc.longueurDsArbre() return longueur def blocUtils(): diff --git a/Noyau/N_ENTITE.py b/Noyau/N_ENTITE.py index 4735edd3..8d9d11a5 100644 --- a/Noyau/N_ENTITE.py +++ b/Noyau/N_ENTITE.py @@ -67,6 +67,7 @@ class ENTITE(object): self.validators = self.factories['validator'](validators) else: self.validators = validators + self.doitSenregistrerComme = None def affecter_parente(self): """ @@ -262,17 +263,17 @@ class ENTITE(object): self.cr.fatal(_(u"L'attribut 'position' doit valoir 'local', 'global' " u"ou 'global_jdc' : %r"), self.position) - def dumpXSD(self): - args = self.entites.copy() - mcs = set() - for nom, val in list(args.items()): - if val.label == 'SIMP': - mcs.add(nom) - # XXX - # if val.max != 1 and val.type == 'TXM': - # print "#CMD", parent, nom - elif val.label == 'FACT': - liste=val.dumpXSD() - mcs.update(liste) - print (self.nom, mcs) - return mcs +# def dumpXSD(self): +# args = self.entites.copy() +# mcs = set() +# for nom, val in list(args.items()): +# if val.label == 'SIMP': +# mcs.add(nom) +# # XXX +# # if val.max != 1 and val.type == 'TXM': +# # print "#CMD", parent, nom +# elif val.label == 'FACT': +# liste=val.dumpXSD() +# mcs.update(liste) +# print (self.nom, mcs) +# return mcs diff --git a/Noyau/N_JDC.py b/Noyau/N_JDC.py index 172ed05a..7e0a7455 100644 --- a/Noyau/N_JDC.py +++ b/Noyau/N_JDC.py @@ -41,7 +41,6 @@ from . import N_CR from .N_Exception import AsException, InterruptParsingError from .N_ASSD import ASSD from .strfunc import getEncoding -from six.moves import range MemoryErrorMsg = """MemoryError : @@ -131,6 +130,7 @@ NONE = None # Dictionnaire pour stocker tous les concepts du JDC (acces rapide par # le nom) self.sds_dict = {} + self.utilise_un_sds_dict = {} self.etapes = [] self.index_etapes = {} self.mc_globaux = {} @@ -651,3 +651,5 @@ Causes possibles : self._reserved_kw.difference_update( ['OPER', 'MACRO', 'BLOC', 'SIMP', 'FACT', 'FORM', 'GEOM', 'MCSIMP', 'MCFACT']) + + diff --git a/Noyau/N_MCSIMP.py b/Noyau/N_MCSIMP.py index 73d01872..e4d510c0 100644 --- a/Noyau/N_MCSIMP.py +++ b/Noyau/N_MCSIMP.py @@ -45,11 +45,8 @@ class MCSIMP(N_OBJECT.OBJECT): Attributs : - val : valeur du mot clé simple - - definition - - nom - - parent Autres attributs : @@ -66,22 +63,28 @@ class MCSIMP(N_OBJECT.OBJECT): self.parent = parent self.convProto = ConversionFactory('type', typ=self.definition.type) self.valeur = self.GETVAL(self.val) - self.objPyxbDeConstruction=objPyxbDeConstruction + self.objPyxbDeConstruction = objPyxbDeConstruction + self.listeNomsObjsCrees = [] if parent: - self.jdc = self.parent.jdc + self.jdc = self.parent.jdc if self.jdc : self.cata = self.jdc.cata - else : self.cata = None + else : self.cata = None self.niveau = self.parent.niveau - self.etape = self.parent.etape + self.etape = self.parent.etape self.buildObjPyxb() else: # Le mot cle simple a été créé sans parent # est-ce possible ? print ('je suis dans le else sans parent du build') - self.jdc = None - self.cata = None + self.jdc = None + self.cata = None self.niveau = None - self.etape = None + self.etape = None + if self.definition.doitSenregistrerComme != None : + if self.definition.doitSenregistrerComme in list(self.jdc.utilise_un_sds_dict.keys()): + self.jdc.utilise_un_sds_dict[self.definition.doitSenregistrerComme].append(self) + else : + self.jdc.utilise_un_sds_dict[self.definition.doitSenregistrerComme] = [self,] def GETVAL(self, val): """ @@ -185,6 +188,7 @@ class MCSIMP(N_OBJECT.OBJECT): dico[self.nom] = l return dico + def getMcsWithCo(self, co): """ Cette methode retourne l'objet MCSIMP self s'il a le concept co diff --git a/Noyau/N_OBJECT.py b/Noyau/N_OBJECT.py index 8765539f..25228f5a 100644 --- a/Noyau/N_OBJECT.py +++ b/Noyau/N_OBJECT.py @@ -110,6 +110,44 @@ class OBJECT(object): def longueurDsArbre(self): return 1 + def creeObjetClasse(self, classeACreer): + # lors de la lecture du .comm, 1ere phase, les objets n existent pas + # mais il ne faut pas mettre la valeur des MC utilisant la classe a None + # sinon, le siValide ne peut rien faire + # c est pourquoi il faut gerer listeDesValeursSupprimees + if not hasattr(self,'listeNomsObjsCrees') : self.listeNomsObjsCrees = [] + newlisteNomsObjsCrees = [] + listeSupprimees = [] + change=False + for v in self.valeur: + if not (v in self.listeNomsObjsCrees): + newObj=classeACreer(v) + change=True + if v in list(self.jdc.sds_dict.keys()): + if not isinstance (self.jdc.sds_dict[v], classeACreer): + self.valeur.remove(v) + continue + self.jdc.sds_dict[v] = newObj + newObj.sdnom = v + newlisteNomsObjsCrees.append(v) + for oldv in self.listeNomsObjsCrees : + if oldv not in self.valeur : + change=True + listeSupprimees.append(self.jdc.sds_dict[oldv]) + self.jdc.sds_dict.pop(oldv) + self.listeNomsObjsCrees.remove(oldv) + for v in newlisteNomsObjsCrees : + self.listeNomsObjsCrees.append(v) + if not change : return + if classeACreer in list(self.jdc.utilise_un_sds_dict.keys()): + for MC in self.jdc.utilise_un_sds_dict[classeACreer] : + if isinstance(MC.valeur, str) and MC.valeur in list(self.jdc.sds_dict.keys()): + MC.valeur=self.jdc.sds_dict[MC.valeur] + if MC.valeur in listeSupprimees: + MC.valeur=None + MC.state = 'undetermined' + MC.isValid() + class ErrorObj(OBJECT): diff --git a/Noyau/N_SIMP.py b/Noyau/N_SIMP.py index 9606f351..49306e70 100644 --- a/Noyau/N_SIMP.py +++ b/Noyau/N_SIMP.py @@ -25,6 +25,7 @@ from __future__ import absolute_import import types +import Accas from Noyau import N_ENTITE from Noyau import N_MCSIMP @@ -49,7 +50,7 @@ class SIMP(N_ENTITE.ENTITE): def __init__(self, typ,ang="", fr="", statut='f', into=None, intoSug = None,siValide = None, defaut=None, min=1, max=1, homo=1, position='local', val_min=float('-inf'), val_max=float('inf'), docu="", validators=None, - sug=None,fenetreIhm=None): + sug=None,fenetreIhm=None, attribut=False): """ Un mot-clé simple est caractérisé par les attributs suivants : - type : cet attribut est obligatoire et indique le type de valeur attendue @@ -67,7 +68,8 @@ class SIMP(N_ENTITE.ENTITE): - val_max : valeur maximale autorisée - docu : clef sur de la documentation utilisateur - sug : valeur suggere - - fenetreIhm=None + - fenetreIhm : si widget particulier + - attribut : si projection XSD sur attribut """ #print (self) #import traceback @@ -79,6 +81,9 @@ class SIMP(N_ENTITE.ENTITE): self.type = typ else: self.type = (typ,) + for t in (self.type) : + if isinstance(t,str):continue + if issubclass(t, Accas.UserASSD) : self.doitSenregistrerComme= t self.fr = fr self.statut = statut self.into = into @@ -99,7 +104,7 @@ class SIMP(N_ENTITE.ENTITE): if self.min == '**' : self.min = float('-inf') if self.val_min == '**' : self.val_min = float('-inf') self.fenetreIhm=fenetreIhm - #self.creeT_SIMP() + self.attribut = attribut def verifCata(self): """ @@ -121,38 +126,6 @@ class SIMP(N_ENTITE.ENTITE): """ return self.class_instance(nom=nom, definition=self, val=val, parent=parent, objPyxbDeConstruction=objPyxbDeConstruction) -# def creeT_SIMP(self): -# from Efi2Xsd.readerEfficas import monSIMP -# from Efi2Xsd.mapDesTypes import dictSIMPEficasXML -# self.objXML=monSIMP() -# for nomEficasArg in dictSIMPEficasXML : -# argu=getattr(self,nomEficasArg) -# nomXMLarg=dictSIMPEficasXML[nomEficasArg] -# if not isinstance(nomXMLarg, (list, tuple)) : -# print(nomXMLarg, argu) - #if nomEficasArg in listeParamDeTypeTypeAttendu: - # typeAttendu = self.typ -# -# setattr(self.objXML, nomXMLarg, argu) -# for nomXMLArg in dir(self) : -# if nomXMLArg in self.dictATraiter : -# nomEficasArg=self.dictATraiter[nomXMLArg] -# argu=getattr(self,nomXMLArg) -# if argu==None : continue -# -# if type(nomEficasArg) == types.DictionaryType: -# for nomXML in list(nomEficasArg.keys()): -# arguDecoupe=getattr(argu,nomXML) -# nomEficasDecoupe=nomEficasArg[nomXML] -# if arguDecoupe == None : continue -# self.dictArgsEficas[nomEficasDecoupe]=arguDecoupe -# else : -# self.dictArgsEficas[nomEficasArg] = argu -# -# -# -# -# diff --git a/Noyau/N_VALIDATOR.py b/Noyau/N_VALIDATOR.py index 9f7720cf..7d7fa449 100644 --- a/Noyau/N_VALIDATOR.py +++ b/Noyau/N_VALIDATOR.py @@ -64,6 +64,7 @@ class Protocol(object): self.args = {} def register(self, T, A): + print (T,A) self.registry[T] = A def adapt(self, obj): @@ -146,7 +147,6 @@ class TypeProtocol(PProtocol): self.typ = typ def default(self, obj, typ): - err = "" for type_permis in typ: if type_permis == 'R': -- 2.39.2