et de remplir le dictionnaire composants utilise par makeObjecttreeitem
"""
debug = 0
- repertoire = os.path.join("..", GUIPath)
+ repertoire = os.path.join("..", "Interface",GUIPath)
package = GUIPath
listfich = glob.glob(os.path.join(repertoire, "compo*.py"))
for fichier in listfich:
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# 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 sys, os
+
+repIni = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
+
+if sys.version_info[0] < 3:
+ print("Must be using Python 3")
+ sys.exit()
+
+
+def lanceEficas(code=None, multi=False, langue="en", labelCode=None, GUI='QT5', salome=0):
+# ---------------------------------------------------------------------------------------
+ """
+ Lance l'appli EFICAS avec Ihm QT
+ """
+ try:
+ from PyQt5.QtWidgets import QApplication
+ except:
+ print("Please, set qt environment")
+ return
+
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if options.code != None:
+ code = options.code
+
+ pathGui='InterfaceGUI.QT5.qtEficas'
+ qtEficas =__import__(pathGui, globals(), locals(), ['qtEficas',])
+
+ app = QApplication(sys.argv)
+ Eficas = qtEficas.Appli(code=code, salome=salome, multi=multi, langue=langue, labelCode=labelCode, GUI=GUI)
+ Eficas.show()
+
+ res = app.exec_()
+ sys.exit(res)
+
+
+def getEficasSsIhm( code=None, multi=False, langue="en", ssCode=None, labelCode=None,
+ forceXML=False, genereXSD=False, fichierCata=None,):
+# -----------------------------------------------------------------------------------
+ """
+ instancie l'appli EFICAS sans Ihm
+ """
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if options.code != None:
+ code = options.code
+ if forceXML:
+ options.withXSD = True
+
+ from InterfaceQT4.qtEficasSsIhm import AppliSsIhm
+
+ Eficas = AppliSsIhm( code=code, salome=0, multi=multi, langue=langue,
+ ssCode=ssCode, labelCode=labelCode, genereXSD=genereXSD, fichierCata=fichierCata,)
+ return Eficas
+
+
+def genereXSD(code=None):
+# -----------------------
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if code != None:
+ options.code = code
+ if options.fichierCata == None:
+ print("Use -c cata_name.py")
+ return
+
+ monEficasSsIhm = getEficasSsIhm(code=options.code, genereXSD=True)
+ monEditor = monEficasSsIhm.getEditor()
+ # texteXSD=monEficasSsIhm.dumpXsd(avecEltAbstrait=options.avecEltAbstrait)
+ texteXSD = monEditor.dumpXsd(avecEltAbstrait=options.avecEltAbstrait)
+
+ fichierCataTrunc = os.path.splitext(os.path.basename(options.fichierCata))[0]
+ # if fichierCataTrunc[0:4] in ('cata','Cata'): fichierCataTrunc=fichierCataTrunc[4:]
+ # if fichierCataTrunc[0] in ('_','-') : fichierCataTrunc=fichierCataTrunc[1:]
+ fileXSD = fichierCataTrunc + ".xsd"
+
+ f = open(str(fileXSD), "w")
+ f.write(str(texteXSD))
+
+
+def genereXML(code=None):
+ # -----------------------
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if code != None:
+ options.code = code
+ if options.fichierCata == None:
+ print("Use -c cata_name.py")
+ return
+ try:
+ fichier = options.comm[0]
+ except:
+ fichier = None
+ if fichier == None:
+ print("comm file is needed")
+ return
+
+ monEficasSsIhm = getEficasSsIhm(code=options.code, forceXML=True)
+
+ from .editorSsIhm import JDCEditorSsIhm
+
+ monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier)
+ if options.fichierXMLOut == None:
+ fichierXMLOut = fichier[: fichier.rfind(".")] + ".xml"
+ else:
+ fichierXMLOut = options.fichierXMLOut
+ if not (monEditeur.jdc.isValid()):
+ print("Fichier comm is not valid")
+ return
+ # print ('Fichier comm is not valid')
+ monEditeur.XMLgenerator.gener(monEditeur.jdc)
+ monEditeur.XMLgenerator.writeDefault(fichierXMLOut)
+
+
+def genereStructure(code=None):
+ # ------------------------------
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if code != None:
+ options.code = code
+ if options.fichierCata == None:
+ print("Use -c cata_name.py")
+ return
+
+ monEficasSsIhm = getEficasSsIhm(code=options.code, genereXSD=True)
+ monEditor = monEficasSsIhm.getEditor()
+ texteStructure = monEditor.dumpStructure()
+
+ fichierCataTrunc = os.path.splitext(os.path.basename(options.fichierCata))[0]
+ fileStructure = fichierCataTrunc + ".txt"
+ f = open(str(fileStructure), "w")
+ f.write(str(texteStructure))
+ f.close()
+
+
+def validateDataSet(code=None):
+ # ------------------------------
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if code != None:
+ options.code = code
+ if options.fichierCata == None:
+ print("Use -c cata_name.py")
+ return
+ fichier = options.comm[0]
+ if fichier == None:
+ print("comm file is needed")
+ return
+ from .editorSsIhm import JDCEditorSsIhm
+
+ monEficasSsIhm = getEficasSsIhm(code=options.code)
+ monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier)
+ if not (monEditeur.jdc.isValid()):
+ print(monEditeur.getJdcRapport())
+ else:
+ print("Jdc is valid")
+ return monEditeur.jdc.isValid()
+
+
+def validateFonction(laFonction, debug=False):
+ # -------------------------------
+ # ici un singleton pour avoir l editor, le catalogue et...
+ monEficasSsIhm = getEficasSsIhm(code="Essai")
+ monEditor = monEficasSsIhm.getEditor()
+ print("_______ validateFonction", laFonction, laFonction.__name__)
+ from functools import wraps
+ from collections import OrderedDict
+ from inspect import getargspec
+
+ @wraps(laFonction)
+ def fonctionValidee(*args, **kwargs):
+ laFonctionName = laFonction.__name__
+ if debug:
+ print(
+ "Appel {} avec args={} et kwargs={}".format(
+ laFonction.__name__, args, kwargs
+ )
+ )
+ laDefDeLaFonctionDansAccas = getattr(monEditor.readercata.cata, laFonctionName)
+ objConstruit = laDefDeLaFonctionDansAccas.makeObjetPourVerifSignature(
+ *args, **kwargs
+ )
+ if objConstruit.isValid():
+ ret = laFonction(*args, **kwargs)
+ return ret
+ else:
+ print("mauvais arguments")
+ print(objConstruit.CR())
+ return None
+
+ return fonctionValidee
+
+ # maClasseAccas=getattr(self.cata,objEtape.monNomClasseAccas)
+ return fonctionValidee
+
+ return laFonction
+
+
+def createFromDocumentAccas(fichierCata=None, fichier=None, code=None):
+ # ------------------------------------------------------------
+ if fichier == None:
+ print("file is needed")
+ return None
+ if fichierCata == None:
+ print("cata file is needed")
+ return None
+
+ from Noyau.N_OBJECT import activeSurcharge
+
+ activeSurcharge()
+
+ from .editorSsIhm import JDCEditorSsIhm
+
+ monEficasSsIhm = getEficasSsIhm(code="Essai", fichierCata=fichierCata)
+ monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier)
+ return monEditeur.jdc
+ # from Noyau
+
+
+# --------------------------- toutes les fonctions après sont obseletes
+def lanceEficas_ssIhm(
+ code=None, fichier=None, ssCode=None, version=None, debug=False, langue="en"
+):
+ """
+ Lance l'appli EFICAS SsIhm
+ """
+ # Analyse des arguments de la ligne de commande
+ print("deprecated")
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+ if version != None and options.version == None:
+ options.version = version
+ if fichier == None:
+ fichier = options.comm[0]
+ if code == None:
+ code = options.code
+
+ from .qtEficas import Appli
+
+ Eficas = Appli(code=code, salome=0, ssCode=ssCode, ssIhm=True, langue=langue)
+
+ from .ssIhm import QWParentSSIhm
+
+ parent = QWParentSSIhm(code, Eficas, version)
+
+ from . import readercata
+
+ if not hasattr(Eficas, "readercata"):
+ monreadercata = readercata.ReaderCata(parent, Eficas)
+ Eficas.readercata = monreadercata
+
+ from .editor import JDCEditor
+
+ monEditeur = JDCEditor(Eficas, fichier)
+ return monEditeur
+
+
+def lanceEficas_ssIhm_chercheGroupes(
+ code=None, fichier=None, ssCode=None, version=None
+):
+ print("deprecated")
+ monEditeur = lanceEficas_ssIhm(code, fichier, ssCode, version)
+ print((monEditeur.chercheGroupes()))
+
+
+def lanceEficas_ssIhm_cherche_cr(code=None, fichier=None, ssCode=None, version=None):
+ print("deprecated")
+ monEditeur = lanceEficas_ssIhm(code, fichier, ssCode, version)
+ print((monEditeur.jdc.cr))
+
+
+def lanceEficas_ssIhm_reecrit(
+ code=None,
+ fichier=None,
+ ssCode=None,
+ version=None,
+ ou=None,
+ cr=False,
+ debug=False,
+ leger=False,
+ langue="ang",
+):
+ print("deprecated")
+ # print 'lanceEficas_ssIhm_reecrit', fichier
+ monEditeur = lanceEficas_ssIhm(code, fichier, ssCode, version, langue=langue)
+ if ou == None:
+ fileName = fichier.split(".")[0] + "_reecrit.comm"
+ fn = fichier.split(".")[0] + "_cr.txt"
+ else:
+ f = fichier.split(".")[0] + "_reecrit.comm"
+ f1 = os.path.basename(f)
+ fn = fichier.split(".")[0] + "_cr.txt"
+ f2 = os.path.basename(fn)
+ fileName = os.path.join(ou, f1)
+ fileCr = os.path.join(ou, f2)
+ debut = False
+ if debug:
+ import cProfile, pstats, StringIO
+
+ pr = cProfile.Profile()
+ pr.enable()
+ monEditeur.saveFileAs(fileName=fileName)
+ pr.disable()
+ s = StringIO.StringIO()
+ sortby = "cumulative"
+ ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
+ ps.print_stats()
+ print(s.getValue())
+
+ elif not leger:
+ monEditeur.saveFileAs(fileName=fileName)
+ else:
+ monEditeur.saveFileLegerAs(fileName=fileName)
+ if cr:
+ f = open(fileCr, "w")
+ f.write(str(monEditeur.jdc.report()))
+ f.close()
+
+
+def lanceEficas_param(
+ code="Adao", fichier=None, version="V0", macro="ASSIMILATION_STUDY"
+):
+ """
+ Lance l'appli EFICAS pour trouver les noms des groupes
+ """
+ print("deprecated")
+ # Analyse des arguments de la ligne de commande
+ from Editeur import session
+
+ options = session.parse(sys.argv)
+
+ from .qtEficas import Appli
+
+ from .ssIhm import QWParentSSIhm
+
+ Eficas = QWParentSSIhm(code, version)
+
+ from . import readercata
+
+ if not hasattr(Eficas, "readercata"):
+ monreadercata = readercata.ReaderCata(parent, Eficas)
+ Eficas.readercata = monreadercata
+
+ from .editor import JDCEditor
+
+ monEditeur = JDCEditor(Eficas, fichier)
+ texte = loadJDC(fichier)
+ parameters = getJdcParameters(texte, macro)
+ return parameters
+
+
+def getJdcParameters(jdc, macro):
+ """
+ This function converts the data from the specified macro of the
+ specified jdc text to a python dictionnary whose keys are the
+ names of the data of the macro.
+ """
+ print("deprecated")
+ context = {}
+ source = "def args_to_dict(**kwargs): return kwargs \n"
+ source += "%s = _F = args_to_dict \n" % macro
+ source += "parameters=" + jdc + " \n"
+ source += "context['parameters'] = parameters \n"
+ code = compile(source, "file.py", "exec")
+ eval(code)
+ parameters = context["parameters"]
+ return parameters
+
+
+def loadJDC(filename):
+ """
+ This function loads the text from the specified JdC file. A JdC
+ file is the persistence file of Eficas (*.comm).
+ """
+ print("deprecated")
+ fcomm = open(filename, "r")
+ jdc = ""
+ for line in fcomm.readlines():
+ if not (line[0] == "#"):
+ jdc += "%s" % line
+
+ # Warning, we have to make sure that the jdc comes as a simple
+ # string without any extra spaces/newlines
+ return jdc.strip()
+
+
+if __name__ == "__main__":
+ import sys
+
+ sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "..")))
+ lanceEficas(code=None, multi=True)
--- /dev/null
+#! /usr/bin/env python
+# -*- coding:utf-8 -*-
+# /* This file is part of MED.
+# *
+# * COPYRIGHT (C) 1999 - 2013 EDF R&D, CEA/DEN
+# * MED 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 3 of the License, or
+# * (at your option) any later version.
+# *
+# * MED 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 MED. If not, see <http://www.gnu.org/licenses/>.
+# */
+
+
+import sys
+sys.path.append('/home/A96028/Salome/V7_main/tools/install/Medfichier-307-hdf51810/lib/python2.7/site-packages')
+
+from med.medfile import *
+from med.medmesh import *
+from med.medfamily import *
+from med.medfilter import *
+
+
+def getGroupes(filename,debug=0) :
+ listeGroupes=[]
+ maa=""
+
+ dicoNumFam={}
+
+ try :
+ fid = MEDfileOpen(filename,MED_ACC_RDONLY)
+ except :
+ return ("Pb a la lecture du fichier", listeGroupes,maa)
+
+
+ # /* Lecture des infos concernant le premier maillage */
+ maa, sdim, mdim, type, desc, dtunit, sort, nstep, rep, nomcoo,unicoo = MEDmeshInfo(fid, 1)
+ if debug :
+ print "Maillage de nom : |%s| de dimension : %ld , et de type %s\n"%(maa,mdim,type)
+ print "Maillage de nom : |%s| , de dimension : %ld , et de type %s\n"%(maa,mdim,type)
+ print "\t -Dimension de l'espace : %ld\n"%(sdim)
+ print "\t -Description du maillage : %s\n"%(desc)
+ print "\t -Noms des axes : |%s|\n"%(nomcoo)
+ print "\t -Unités des axes : |%s|\n"%(unicoo)
+ print "\t -Type de repère : %s\n"%(rep)
+ print "\t -Nombre d'étape de calcul : %ld\n"%(nstep)
+ print "\t -Unité des dates : |%s|\n"%(dtunit)
+
+ # /* Lecture du nombre de familles */
+ nfam = MEDnFamily(fid,maa)
+ if debug :
+ print "Nombre de familles : %d \n"%(nfam)
+
+ # /* Lecture de chaque famille */
+ for i in xrange(0,nfam):
+
+ # /* Lecture du nombre de groupe */
+ ngro = MEDnFamilyGroup(fid,maa,i+1)
+ if debug :
+ print "Famille %d a %d groupes \n"%(i+1,ngro)
+
+ gro = MEDCHAR(MED_LNAME_SIZE*ngro+1)
+
+ nomfam,numfam,gro = MEDfamilyInfo(fid,maa,i+1,gro)
+ if debug :
+ print "Famille de nom %s et de numero %d : \n"%(nomfam,numfam)
+ print "Attributs : \n"
+
+ for j in xrange(0,ngro):
+ # print "gro = %s\n"%(gro[j*MED_LNAME_SIZE:j*MED_LNAME_SIZE+MED_LNAME_SIZE])
+ groupSplit=gro[j*MED_LNAME_SIZE:j*MED_LNAME_SIZE+MED_LNAME_SIZE]
+ groupeName="".join(groupSplit).split("\x00")[0]
+ groupeName=groupeName.replace(' ','')
+ if groupeName[0:7]=="CENTRE_" : dicoNumFam[groupeName]=numfam
+ if groupeName not in listeGroupes : listeGroupes.append(groupeName)
+
+
+ #print dicoNumFam
+ #print listeGroupes
+
+ # /* Lecture des Numeros de Familles */
+
+ nnoe, chgt, trsf = MEDmeshnEntity(fid,maa,MED_NO_DT,MED_NO_IT, MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE)
+ nufano = MEDINT(nnoe)
+ MEDmeshEntityFamilyNumberRd(fid,maa, MED_NO_DT, MED_NO_IT, MED_NODE,MED_NONE,nufano)
+ dicoNumNode={}
+ for groupe in dicoNumFam.keys():
+ famille=dicoNumFam[groupe]
+ i=0
+ while i < nufano.size():
+ if nufano[i]==famille :
+ dicoNumNode[groupe]=i+1
+ break
+ i=i+1
+
+
+ #print dicoNumNode
+ dicoCoord={}
+ for groupe in dicoNumNode.keys() :
+ flt=MEDINT(1)
+ flt[0]=dicoNumNode[groupe]
+ coo1=MEDFLOAT(3)
+ filter=med_filter()
+ err=MEDfilterEntityCr( fid, nnoe, 1, sdim, MED_ALL_CONSTITUENT, MED_FULL_INTERLACE, MED_COMPACT_PFLMODE, MED_NO_PROFILE,1 , flt, filter)
+ MEDmeshNodeCoordinateAdvancedRd(fid, maa, MED_NO_DT, MED_NO_IT, filter, coo1)
+ MEDfilterClose(filter)
+ dicoCoord[groupe]=coo1
+# dicoCoord['CENTRE_saxBas']=(0,0,28.5e-3)
+# dicoCoord['CENTRE_saxHaut']=(0,0,31.5e-3)
+
+ MEDfileClose(fid)
+ return ("",listeGroupes,maa,dicoCoord)
+
+if __name__ == "__main__":
+ filename="/home/A96028/Carmel/Pascale/Domaine_Bidouille.med"
+ #filename="/home/A96028/Carmel/nouveauMed/Domaine.med"
+ print getGroupes(filename)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 package contient les fonctionnalites necessaires
+ pour l'editeur graphique QT
+"""
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import re
+import types, sys, os
+import traceback
+from . import typeNode
+
+
+from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QApplication, QMessageBox
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+from .gereRegles import GereRegles
+from .monChoixCommande import MonChoixCommande
+
+
+# ------------------------------------------
+class JDCTree(QTreeWidget, GereRegles):
+# ------------------------------------------
+
+ def __init__(self, jdc_item, QWParent):
+ # ----------------------------------------
+ self.editor = QWParent
+ self.plie = False
+ if self.editor.widgetTree != None:
+ QTreeWidget.__init__(self, self.editor.widgetTree)
+ self.editor.verticalLayout_2.addWidget(self)
+ if self.editor.enteteQTree == "complet":
+ self.headerItem().setText(0, "Commande ")
+ self.headerItem().setText(1, "Concept/Valeur")
+ else:
+ self.headerItem().setText(0, "Commande ")
+ self.setColumnWidth(0, 200)
+ self.setExpandsOnDoubleClick(False)
+ self.setSelectionMode(3)
+ else:
+ QTreeWidget.__init__(self, None)
+ self.item = jdc_item
+ self.tree = self
+ self.appliEficas = self.editor.appliEficas
+ self.childrenComplete = []
+ self.racine = self.item.itemNode(self, self.item)
+
+ self.itemCourant = None
+
+ self.itemClicked.connect(self.handleOnItem)
+ self.itemCollapsed.connect(self.handleCollapsedItem)
+ self.itemExpanded.connect(self.handleExpandedItem)
+
+ self.node_selected = self.racine
+ self.inhibeExpand = True
+ self.expandItem(self.racine)
+ self.inhibeExpand = False
+ if self.racine.children != []:
+ if self.editor.maConfiguration.afficheCommandesPliees:
+ self.racine.children[0].plieToutEtReaffiche()
+ else:
+ self.racine.children[0].deplieToutEtReaffiche()
+ self.racine.children[0].fenetre.donnePremier()
+ else:
+ self.racine.affichePanneau()
+
+ def contextMenuEvent(self, event):
+ # ---------------------------------
+ coord = event.globalPos()
+ item = self.currentItem()
+ self.handleContextMenu(item, coord)
+
+ def handleContextMenu(self, item, coord):
+ # -------------------------------------
+ """
+ Private slot to show the context menu of the listview.
+
+ @param itm the selected listview item (QListWidgetItem)
+ @param coord the position of the mouse pointer (QPoint)
+ Attention : existeMenu permet de savoir si un menu est associe a cet item
+ """
+ print("handleContextMenu")
+ if item == None:
+ return
+ self.itemCourant = item
+ if item.existeMenu == 0:
+ return
+
+ if item.menu == None:
+ item.createPopUpMenu()
+ if item.menu != None:
+ # PNPN reflechir a qqchose de generique pour remplacer cette fonctionnalite
+ # if item.item.getNom() == "DISTRIBUTION" and item.item.isValid() :
+ # item.Graphe.setEnabled(1)
+ item.menu.exec_(coord)
+
+ def handleCollapsedItem(self, item):
+ # ----------------------------------
+ # print ("dans CollapsedItem", self.inhibeExpand )
+ if self.inhibeExpand == True:
+ return
+
+ # On traite le cas de l item non selectionne
+ self.itemCourant = item
+ itemParent = item
+ while not (hasattr(itemParent, "getPanel")):
+ itemParent = itemParent.treeParent
+ if self.tree.node_selected != itemParent:
+ item.setExpanded(False)
+ return
+
+ item.setPlie()
+ item.plieToutEtReaffiche()
+ item.select()
+
+ def handleExpandedItem(self, item):
+ # ----------------------------------
+ # print ("handleExpandedItem pour ", item.item.nom, self.inhibeExpand)
+ # import traceback
+ # traceback.print_stack()
+ if self.inhibeExpand == True:
+ return
+
+ self.itemCourant = item
+ self.inhibeExpand = True
+ itemParent = item
+ while not (hasattr(itemParent, "getPanel")):
+ if itemParent.plie == True:
+ itemParent.setDeplie()
+ itemParent = itemParent.treeParent
+ if self.tree.node_selected != itemParent:
+ item.setExpanded(True)
+ self.inhibeExpand = False
+ return
+ item.deplieToutEtReaffiche()
+ self.inhibeExpand = False
+
+ def handleOnItem(self, item, int):
+ # ----------------------------------
+ # print ("je passe dans handleOnItem pour ",self, item.item.nom, item, item.item, item.item.getLabelText())
+
+ from InterfaceGUI.QT5 import composimp
+
+ self.inhibeExpand = True
+ self.itemCourant = item
+ itemParent = item
+ itemAvant = item
+
+ # PN : 22 juil 2021 --> bizarre ce itemAvant Verifier le while
+ while not (hasattr(itemParent, "getPanel")):
+ if itemParent.plie == True:
+ itemParent.setDeplie()
+ itemAvant = itemParent
+ itemParent = itemParent.treeParent
+
+ if itemParent.fenetre != self.editor.fenetreCentraleAffichee:
+ estUneFeuille = isinstance(item, composimp.Node)
+ # il faut afficher le parent
+ # Attention - Specification particuliere pour MT qui permet de nn afficher qu 1 niveau
+ # le catalogue contient cette indication dans fenetreIhm
+ if estUneFeuille and itemParent.fenetreIhm == "deplie1Niveau":
+ if item == itemParent:
+ itemParent.affichePanneau()
+ else:
+ itemAvant.afficheCeNiveau()
+ elif estUneFeuille:
+ itemParent.affichePanneau()
+ elif self.editor.maConfiguration.afficheCommandesPliees:
+ itemParent.plieToutEtReafficheSaufItem(item)
+ else:
+ itemParent.affichePanneau()
+
+ elif (isinstance(item, composimp.Node)) and item.fenetre:
+ item.fenetre.rendVisible()
+ elif itemParent != item:
+ self.tree.handleExpandedItem(item)
+
+ # aide
+ try:
+ fr = item.item.getFr()
+ chaineDecoupee = fr.split("\n")
+ if len(chaineDecoupee) > 3:
+ txt = (
+ "\n".join(chaineDecoupee[0:2])
+ + "...\nfull help : double clicked on validity chip of "
+ + str(item.item.nom)
+ + " in central widget"
+ )
+ else:
+ txt = fr
+ if self.editor:
+ self.editor.afficheCommentaire(str(txt))
+ except:
+ pass
+
+ item.select()
+ self.inhibeExpand = False
+
+ def choisitPremier(self, name):
+ # ----------------------------
+ self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
+ self.racine.fenetre.close()
+ new_node = self.racine.appendBrother(name, "after")
+
+
+# type de noeud
+COMMENT = "COMMENTAIRE"
+PARAMETERS = "PARAMETRE"
+
+
+# ------------------------------------------
+class JDCNode(QTreeWidgetItem, GereRegles):
+# ------------------------------------------
+ def __init__(self, treeParent, item, itemExpand=False, ancien=False):
+ # ----------------------------------------------------------------------
+ # print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, self)
+ # self.a=0
+
+ self.item = item
+ self.vraiParent = treeParent
+ self.treeParent = treeParent
+ self.tree = self.treeParent.tree
+ self.editor = self.treeParent.editor
+ self.appliEficas = treeParent.appliEficas
+ self.JESUISOFF = 0
+ self.firstAffiche = True
+ self.childrenComplete = []
+ self.item._object.node = self
+
+ from InterfaceGUI.QT5 import compocomm
+ from InterfaceGUI.QT5 import compoparam
+ from InterfaceGUI.QT5 import composimp
+
+ if isinstance(self.item, compocomm.COMMTreeItem):
+ name = tr("Commentaire")
+ elif isinstance(self.item, compoparam.PARAMTreeItem):
+ name = tr(str(item.getLabelText()[0]))
+ else:
+ name = tr(item.getLabelText()[0])
+ if item.nom != tr(item.nom):
+ name = str(tr(item.nom) + " :")
+ value = tr(str(item.getText()))
+
+ # si specialisation de la fenetre
+ if self.item.object.definition == None:
+ self.fenetreIhm = None
+ # Cas des listes de mots_clefs
+ else:
+ self.fenetreIhm = self.item.object.definition.fenetreIhm
+
+ if self.editor.enteteQTree == "complet":
+ mesColonnes = (name, value)
+ else:
+ mesColonnes = (name,)
+
+ if self.treeParent.plie == True:
+ self.plie = True
+ self.appartientAUnNoeudPlie = True
+ if self.treeParent.item.isMCList():
+ self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
+ else:
+ self.plie = False
+ self.appartientAUnNoeudPlie = False
+
+ # if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
+
+ if ancien and itemExpand:
+ self.plie = False
+ if ancien and not itemExpand:
+ self.plie = True
+ if isinstance(self.item, composimp.SIMPTreeItem):
+ self.plie = False
+
+ from InterfaceGUI.QT5 import compobloc
+ from InterfaceGUI.QT5 import compomclist
+
+ ajoutAuParentduNoeud = 0
+ self.treeParent = treeParent
+ while isinstance(self.treeParent, compobloc.Node) or (
+ isinstance(self.treeParent, compomclist.Node)
+ and self.treeParent.item.isMCList()
+ ):
+ self.treeParent.childrenComplete.append(self)
+ self.treeParent = self.treeParent.vraiParent
+ self.treeParent.childrenComplete.append(self)
+
+ if (
+ isinstance(self, compobloc.Node)
+ or (isinstance(self, compomclist.Node) and self.item.isMCList())
+ or (
+ hasattr(self.item.parent, "inhibeValidator")
+ and isinstance(self, compomclist.Node)
+ and self.item.parent.inhibeValidator
+ )
+ or (
+ isinstance(self, composimp.Node)
+ and self.item.definition.statut in ("c", "d")
+ )
+ ):
+ # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
+ QTreeWidgetItem.__init__(self, None, mesColonnes)
+ else:
+ QTreeWidgetItem.__init__(self, self.treeParent, mesColonnes)
+
+ self.setToolTip(0, self.item.getFr())
+ self.setToolTip(1, self.item.getFr())
+ repIcon = self.appliEficas.repIcon
+
+ couleur = self.item.getIconName()
+ monIcone = QIcon(repIcon + "/" + couleur + ".png")
+
+ self.setIcon(0, monIcone)
+
+ self.children = []
+ self.buildChildren()
+ self.menu = None
+ self.existeMenu = 1
+
+ self.item.connect("valid", self.onValid, ())
+ self.item.connect("supp", self.onSupp, ())
+ self.item.connect("add", self.onAdd, ())
+ self.item.connect("redessine", self.onRedessine, ())
+
+ self.state = ""
+ self.fenetre = None
+ try:
+ if self.item.getObject().isBLOC():
+ self.setExpanded(True)
+ self.plie = False
+ except:
+ pass
+
+ def buildChildren(self, posInsertion=10000):
+ # ------------------------------------------
+ """Construit la liste des enfants de self"""
+ """ Se charge de remettre les noeuds Expanded dans le meme etat """
+ # print ("*********** buildChildren ",self,self.item, self.item.nom)
+ # print (poum)
+
+ self.listeItemExpanded = []
+ self.listeItemPlie = []
+
+ for enfant in self.childrenComplete:
+ if enfant.plie:
+ self.listeItemPlie.append(enfant.item)
+ else:
+ self.listeItemExpanded.append(enfant.item)
+
+ for enfant in self.childrenComplete:
+ parent = enfant.treeParent
+ parent.removeChild(enfant)
+ enfant.JESUISOFF = 1
+
+ self.children = []
+ self.childrenComplete = []
+ sublist = self.item._getSubList()
+ ind = 0
+
+ for item in sublist:
+ itemExpand = False
+ ancien = False
+ if item in self.listeItemExpanded:
+ itemExpand = True
+ ancien = True
+ if item in self.listeItemPlie:
+ itemExpand = False
+ ancien = True
+ nouvelItem = item.itemNode(self, item, itemExpand, ancien)
+ self.children.append(nouvelItem)
+
+ # print ("fin *********** buildChildren ",self,self.item, self.item.nom, self.children)
+
+ def chercheNoeudCorrespondant(self, objSimp):
+ # -------------------------------------------
+ sublist = self.item._getSubList()
+ for node in self.childrenComplete:
+ if node.item.object == objSimp:
+ return node
+ return None
+
+ def afficheCeNiveau(self):
+ # -------------------------
+ # print ('afficheCeNiveau pour ', self.item.nom, self.item.getLabelText())
+ for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
+ widget = self.editor.widgetCentraleLayout.itemAt(indiceWidget)
+ self.editor.widgetCentraleLayout.removeItem(widget)
+ if self.editor.fenetreCentraleAffichee != None:
+ self.editor.widgetCentraleLayout.removeWidget(
+ self.editor.fenetreCentraleAffichee
+ )
+ self.editor.fenetreCentraleAffichee.setParent(None)
+ self.editor.fenetreCentraleAffichee.close()
+ self.editor.fenetreCentraleAffichee.deleteLater()
+
+ from monWidgetNiveauFact import MonWidgetNiveauFact, MonWidgetNiveauFactTableau
+
+ maDefinition = self.item.get_definition()
+ monObjet = self.item.object
+ if maDefinition.fenetreIhm == "Tableau":
+ self.maFenetreCadre = MonWidgetNiveauFactTableau(
+ self, self.editor, maDefinition, monObjet
+ )
+ else:
+ self.maFenetreCadre = MonWidgetNiveauFact(
+ self, self.editor, maDefinition, monObjet
+ )
+
+ self.fenetre = self.maFenetreCadre
+ self.editor.widgetCentraleLayout.addWidget(self.maFenetreCadre)
+ self.editor.fenetreCentraleAffichee = self.maFenetreCadre
+ self.select()
+ # print ('fin afficheCeNiveau pour ', self.item.nom)
+
+ def getPanelModifie(self):
+ # -------------------------
+
+ if self.fenetreIhm == None:
+ return None
+ if self.fenetreIhm == "deplie1Niveau":
+ from InterfaceGUI.QT5.monWidgetCommandeDeplie1Niveau import (
+ MonWidgetCommandeDeplie1Niveau,
+ )
+
+ return MonWidgetCommandeDeplie1Niveau(self, self.editor, self.item.object)
+ return None
+
+ def affichePanneau(self):
+ # -------------------------
+ # print ('_________________ds affichePanneau pour', self.item.nom)
+ # pour l instant pas d inactif
+ if not (self.item.isActif()):
+ from .monWidgetInactif import MonWidgetInactif
+
+ self.fenetre = MonWidgetInactif(self, self.editor)
+ else:
+ itemParent = self
+ while not (hasattr(itemParent, "getPanel")):
+ itemParent = itemParent.treeParent
+ if itemParent != self:
+ # print ('j appelle affichePanneau pour ', itemParent.item.nom , 'par', self.item.nom)
+ itemParent.affichePanneau()
+ # print ('fin _________________ds affichePanneau pour', self.item.nom)
+ return
+
+ self.fenetre = self.getPanelModifie()
+ if self.fenetre == None:
+ self.fenetre = self.getPanel()
+ self.editor.restoreSplitterSizes()
+
+ for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
+ widget = self.editor.widgetCentraleLayout.itemAt(indiceWidget)
+ self.editor.widgetCentraleLayout.removeItem(widget)
+
+ # ceinture et bretelle
+ # print 'old fenetre = ',self.editor.fenetreCentraleAffichee
+ if self.editor.fenetreCentraleAffichee != None:
+ try:
+ self.editor.widgetCentraleLayout.removeWidget(
+ self.editor.fenetreCentraleAffichee
+ )
+ self.editor.fenetreCentraleAffichee.setParent(None)
+ self.editor.fenetreCentraleAffichee.close()
+ self.editor.fenetreCentraleAffichee.deleteLater()
+ # print ('en sortie du try sur la vieille fenetre')
+ except:
+ pass
+
+ self.editor.widgetCentraleLayout.addWidget(self.fenetre)
+ # print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
+ self.editor.fenetreCentraleAffichee = self.fenetre
+ self.tree.node_selected = self
+
+ if self.editor.first:
+ if not (isinstance(self.fenetre, MonChoixCommande)):
+ self.editor.first = False
+ self.tree.inhibeExpand = True
+ self.tree.expandItem(self)
+ self.tree.inhibeExpand = False
+ # print( '_________________fin affichePanneau pour', self.item.nom)
+
+ def createPopUpMenu(self):
+ # -------------------------
+ # implemente dans les noeuds derives si necessaire
+ self.existeMenu = 0
+
+ def commentIt(self):
+ # -------------------------
+ """
+ Cette methode a pour but de commentariser la commande pointee par self
+ """
+ # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
+ # (commentariser) un commentaire.
+ try:
+ pos = self.treeParent.children.index(self)
+ commande_comment = self.item.getObjetCommentarise()
+ # On signale a l editeur du panel (le JDCDisplay) une modification
+ self.editor.initModif()
+ self.treeParent.buildChildren()
+ self.treeParent.children[pos].select()
+ self.treeParent.children[pos].affichePanneau()
+ except Exception as e:
+ traceback.print_exc()
+ QMessageBox.critical(self.editor, "TOO BAD", str(e))
+
+ def unCommentIt(self):
+ # -------------------------
+ """
+ Realise la decommentarisation de self
+ """
+ try:
+ pos = self.treeParent.children.index(self)
+ commande, nom = self.item.unComment()
+ self.editor.initModif()
+ self.treeParent.buildChildren()
+ self.treeParent.children[pos].select()
+ self.treeParent.children[pos].affichePanneau()
+ except Exception as e:
+ QMessageBox.critical(self.editor, "Erreur !", str(e))
+
+ def addComment(self, after=True):
+ # -----------------------------------
+ """
+ Ajoute un commentaire a l'interieur du JDC :
+ """
+ self.editor.initModif()
+ if after:
+ pos = "after"
+ else:
+ pos = "before"
+ return self.appendBrother(COMMENT, pos)
+
+ def addParameters(self, after=True):
+ # -------------------------------------
+ """
+ Ajoute un parametre a l'interieur du JDC :
+ """
+ self.editor.initModif()
+ if after:
+ pos = "after"
+ else:
+ pos = "before"
+ child = self.appendBrother(PARAMETERS, pos)
+ return child
+
+ def select(self):
+ # ------------------
+ """
+ Rend le noeud courant (self) selectionne et deselectionne
+ tous les autres
+ """
+ # print "select pour", self.item.nom
+ for item in self.tree.selectedItems():
+ item.setSelected(0)
+ self.tree.setCurrentItem(self)
+
+ # ------------------------------------------------------------------
+ # Methodes de creation et destruction de noeuds
+ # ------------------------------------------------------------------
+
+ def appendBrother(self, name, pos="after", plier=False):
+ # ----------------------------------------------------
+ """
+ Permet d'ajouter un objet frere a l'objet associe au noeud self
+ par defaut on l'ajoute immediatement apres
+ Methode externe
+ """
+ self.editor.initModif()
+
+ from InterfaceGUI.QT5 import compojdc
+
+ if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(
+ name, pos
+ ):
+ return 0
+
+ if self.treeParent != self.vraiParent:
+ index = self.vraiParent.children.index(self)
+ if pos == "before":
+ index = index
+ elif pos == "after":
+ index = index + 1
+ return self.vraiParent.appendChild(name, pos=index, plier=plier)
+ else:
+ index = self.treeParent.children.index(self)
+ if pos == "before":
+ index = index
+ elif pos == "after":
+ index = index + 1
+ else:
+ print(pos, tr(" n'est pas un index valide pour appendBrother"))
+ return 0
+ return self.treeParent.appendChild(name, pos=index, plier=plier)
+
+ def verifiePosition(self, name, pos, aLaRacine=False):
+ # ----------------------------------------------------
+ if name not in self.editor.readercata.Classement_Commandes_Ds_Arbre:
+ return True
+ indexName = self.editor.readercata.Classement_Commandes_Ds_Arbre.index(name)
+
+ etapes = self.item.getJdc().etapes
+ if etapes == []:
+ return True
+
+ if aLaRacine == False:
+ indexOu = etapes.index(self.item.object)
+ else:
+ indexOu = 0
+
+ if pos == "after":
+ indexOu = indexOu + 1
+ for e in etapes[:indexOu]:
+ nom = e.nom
+ if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre:
+ continue
+ indexEtape = self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
+ if indexEtape > indexName:
+ comment = (
+ tr("le mot clef ") + name + tr(" doit etre insere avant ") + nom
+ )
+ QMessageBox.information(
+ None,
+ tr("insertion impossible"),
+ comment,
+ )
+ return False
+ for e in etapes[indexOu:]:
+ nom = e.nom
+ if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre:
+ continue
+ indexEtape = self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
+ if indexEtape < indexName:
+ comment = (
+ tr("le mot clef ") + name + tr(" doit etre insere apres ") + nom
+ )
+ QMessageBox.information(
+ None,
+ tr("insertion impossible"),
+ comment,
+ )
+ return False
+ return True
+
+ def appendChild(self, name, pos=None, plier=False):
+ # ------------------------------------------------
+ """
+ Methode pour ajouter un objet fils a l'objet associe au noeud self.
+ On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
+ ou en position intermediaire.
+ Si pos vaut None, on le place a la position du catalogue.
+ """
+ # print ("************** appendChild ",self.item.getLabelText(), pos, plier)
+ # import traceback
+ # traceback.print_stack()
+
+ self.editor.initModif()
+ if pos == "first":
+ index = 0
+ elif pos == "last":
+ index = len(self.children)
+ elif type(pos) == int:
+ index = pos # position fixee
+ elif type(pos) == object:
+ index = (
+ self.item.getIndex(pos) + 1
+ ) # pos est un item. Il faut inserer name apres pos
+ elif type(name) == object:
+ index = self.item.getIndexChild(name.nom)
+ else:
+ index = self.item.getIndexChild(name)
+
+ # si on essaye d inserer a la racine
+ if isinstance(self.treeParent, JDCTree) and index == 0:
+ verifiePosition = self.verifiePosition(name, "first", aLaRacine=True)
+ if not verifiePosition:
+ return 0
+
+ self.tree.inhibeExpand = True
+ obj = self.item.addItem(name, index) # emet le signal 'add'
+ if obj is None:
+ obj = 0
+ if obj == 0:
+ return 0
+
+ try:
+ # if 1 :
+ child = self.children[index]
+ if plier == True:
+ child.setPlie()
+ else:
+ child.setDeplie()
+ except:
+ child = self.children[index]
+
+ try:
+ if len(obj) > 1:
+ self.buildChildren()
+ except:
+ pass
+
+ self.tree.inhibeExpand = False
+ # print (" fin append child")
+ return child
+
+ def deplace(self):
+ # -----------------
+ self.editor.initModif()
+ index = self.treeParent.children.index(self) - 1
+ if index < 0:
+ index = 0
+ ret = self.treeParent.item.deplaceEntite(self.item.getObject())
+
+ def delete(self):
+ # ----------------
+ """
+ Methode externe pour la destruction de l'objet associe au noeud
+ """
+ self.editor.initModif()
+ index = self.vraiParent.children.index(self) - 1
+ if index < 0:
+ index = 0
+
+ recalcule = 0
+ if self.item.nom == "VARIABLE":
+ recalcule = 1
+ jdc = self.item.jdc
+
+ ret, commentaire = self.vraiParent.item.suppItem(self.item)
+ if ret == 0:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ else:
+ self.editor.afficheInfos(commentaire)
+ self.treeParent.buildChildren()
+ if self.treeParent.childrenComplete:
+ toselect = self.treeParent.childrenComplete[index]
+ else:
+ toselect = self.treeParent
+
+ if recalcule:
+ jdc.recalculeEtatCorrelation()
+ if ret == 0:
+ if self.treeParent.childrenComplete:
+ notdeleted = self.treeParent.childrenComplete[index + 1]
+ notdeleted.select()
+ else:
+ toselect.select()
+
+ from InterfaceGUI.QT5 import compojdc
+
+ # cas ou on detruit dans l arbre sans affichage
+ if isinstance(self.treeParent, compojdc.Node):
+ toselect.affichePanneau()
+ else:
+ if self.treeParent.fenetre == None:
+ return
+ # print "J appelle reaffiche de browser apres delete"
+ self.treeParent.fenetre.reaffiche(toselect)
+
+ def deleteMultiple(self, liste=()):
+ # --------------------------------
+ """
+ Methode externe pour la destruction d une liste de noeud
+ """
+ from InterfaceGUI.QT5 import compojdc
+
+ self.editor.initModif()
+ index = 9999
+ recalcule = 0
+ jdc = self.treeParent
+ parentPosition = jdc
+ while not (isinstance(jdc, compojdc.Node)):
+ jdc = jdc.treeParent
+ for noeud in liste:
+ if not (isinstance(noeud.treeParent, compojdc.Node)):
+ continue
+ if noeud.item.nom == "VARIABLE":
+ recalcule = 1
+ if noeud.treeParent.children.index(noeud) < index:
+ index = noeud.treeParent.children.index(noeud)
+ if index < 0:
+ index = 0
+
+ # Cas ou on detruit dans une ETape
+ if index == 9999:
+ parentPosition = self.treeParent
+ while not (isinstance(parentPosition, compojdc.Node)):
+ index = parentPosition.treeParent.children.index(parentPosition)
+ parentPosition = parentPosition.treeParent
+
+ for noeud in liste:
+ noeud.treeParent.item.suppItem(noeud.item)
+
+ jdc.buildChildren()
+ if recalcule:
+ jdc.recalculeEtatCorrelation()
+ try:
+ toselect = parentPosition.children[index]
+ except:
+ toselect = jdc
+ toselect.select()
+ toselect.affichePanneau()
+
+ #
+ # ------------------------------------------------------------------
+
+ def onValid(self):
+ # -----------------
+ # print ("onValid pour ", self.item.nom)
+ if self.JESUISOFF == 1:
+ return
+
+ if hasattr(self, "fenetre") and self.fenetre:
+ try:
+ self.fenetre.setValide()
+ except:
+ pass
+
+ # PNPN lignes suivantes a repenser
+ if (
+ self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION"
+ ) and self.item.isValid():
+ self.item.jdc.recalculeEtatCorrelation()
+ if hasattr(self.item, "forceRecalcul"):
+ self.forceRecalculChildren(self.item.forceRecalcul)
+ self.editor.initModif()
+
+ self.updateNodeValid()
+ self.updateNodeLabel()
+ self.updateNodeTexte()
+
+ def onAdd(self, object):
+ # ----------------------
+ # print ("onAdd pour ", self.item.nom, object)
+ if self.JESUISOFF == 1:
+ return
+ self.editor.initModif()
+ self.buildChildren()
+ if hasattr(self.item, "jdc"):
+ self.item.jdc.aReafficher = True
+
+ def onSupp(self, object):
+ # -----------------------
+ # print ("onSup pour ", self.item.nom, object)
+ # import traceback
+ # traceback.print_stack()
+ if self.JESUISOFF == 1:
+ return
+ self.editor.initModif()
+ self.buildChildren()
+ if hasattr(self.item, "jdc"):
+ self.item.jdc.aReafficher = True
+
+ def onRedessine(self):
+ # ---------------------
+ # print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!je passe dans onRedessine pour', self.item.nom)
+ self.affichePanneau()
+
+ def updateNodeValid(self):
+ # -----------------------
+ """Cette methode remet a jour la validite du noeud (icone)
+ Elle appelle isValid
+ """
+ repIcon = self.appliEficas.repIcon
+ couleur = self.item.getIconName()
+ monIcone = QIcon(repIcon + "/" + couleur + ".png")
+ self.setIcon(0, monIcone)
+
+ def updateNodeLabel(self):
+ # -------------------------
+ """Met a jour le label du noeud"""
+ # print ("NODE updateNodeLabel", self.item.getLabelText())
+ labeltext, fonte, couleur = self.item.getLabelText()
+ # PNPN a reflechir
+ if self.item.nom != tr(self.item.nom):
+ labeltext = str(tr(self.item.nom) + " :")
+ self.setText(0, tr(labeltext))
+
+ def updateNodeLabelInBlack(self):
+ # -------------------------------
+ if hasattr(self.appliEficas, "noeudColore"):
+ self.appliEficas.noeudColore.setForeground(0, Qt.black)
+ self.appliEficas.noeudColore.updateNodeLabel
+
+ def updateNodeLabelInBlue(self):
+ # -------------------------------
+ if hasattr(self.appliEficas, "noeudColore"):
+ self.appliEficas.noeudColore.setForeground(0, Qt.black)
+ self.setForeground(0, Qt.blue)
+ labeltext, fonte, couleur = self.item.getLabelText()
+ if self.item.nom != tr(self.item.nom):
+ labeltext = str(tr(self.item.nom) + " :")
+ self.setText(0, labeltext)
+ self.appliEficas.noeudColore = self
+
+ def updatePlusieursNodeLabelInBlue(self, liste):
+ # ----------------------------------------------
+ if hasattr(self.appliEficas, "listeNoeudsColores"):
+ for noeud in self.appliEficas.listeNoeudsColores:
+ noeud.setTextColor(0, Qt.black)
+ noeud.updateNodeLabel()
+ self.appliEficas.listeNoeudsColores = []
+ for noeud in liste:
+ noeud.setTextColor(0, Qt.blue)
+ labeltext, fonte, couleur = noeud.item.getLabelText()
+ if item.nom != tr(item.nom):
+ labeltext = str(tr(item.nom) + " :")
+ noeud.setText(0, labeltext)
+ self.appliEficas.listeNoeudsColores.append(noeud)
+
+ def updateNodeTexteInBlack(self):
+ # --------------------------------
+ """Met a jour les noms des SD et valeurs des mots-cles"""
+ self.setTextColor(1, Qt.black)
+ value = tr(str(self.item.getText()))
+ self.setText(1, value)
+
+ def updateNodeTexte(self):
+ # ----------------------------
+ """Met a jour les noms des SD et valeurs des mots-cles"""
+ value = tr(str(self.item.getText()))
+ self.setText(1, value)
+
+ def updateNodeTexteInBlue(self):
+ # --------------------------------
+ self.setTextColor(1, Qt.blue)
+ value = tr(str(self.item.getText()))
+ self.setText(1, value)
+
+ def updateNodes(self):
+ # --------------------------------
+ # print 'NODE updateNodes', self.item.getLabelText()
+ self.buildChildren()
+
+ def updateValid(self):
+ # ----------------------
+ """Cette methode a pour but de mettre a jour la validite du noeud
+ et de propager la demande de mise a jour a son parent
+ """
+ # print "NODE updateValid", self.item.getLabelText()
+ self.updateNodeValid()
+ try:
+ self.treeParent.updateValid()
+ except:
+ pass
+
+ def updateTexte(self):
+ # ----------------------
+ """Met a jour les noms des SD et valeurs des mots-cles"""
+ # print "NODE updateTexte", self.item.getLabelText()
+ self.updateNodeTexte()
+ if self.isExpanded():
+ for child in self.children:
+ if child.isHidden() == false:
+ child.updateTexte()
+
+ def forceRecalculChildren(self, niveau):
+ # --------------------------------------
+ if self.state == "recalcule":
+ self.state = ""
+ return
+ self.state = "recalcule"
+ if hasattr(self.item, "object"):
+ self.item.object.state = "modified"
+ for child in self.children:
+ if niveau > 0:
+ child.forceRecalculChildren(niveau - 1)
+
+ def doPaste(self, node_selected, pos="after"):
+ # --------------------------------------------
+ """
+ Declenche la copie de l'objet item avec pour cible
+ l'objet passe en argument : node_selected
+ """
+ objet_a_copier = self.item.getCopieObjet()
+ child = node_selected.doPasteCommande(objet_a_copier, pos)
+ if self.editor.fenetreCentraleAffichee:
+ self.editor.fenetreCentraleAffichee.node.affichePanneau()
+ self.updateNodeLabelInBlack()
+ return child
+
+ def doPasteCommande(self, objet_a_copier, pos="after"):
+ # -----------------------------------------------------
+ """
+ Realise la copie de l'objet passe en argument qui est necessairement
+ un onjet
+ """
+ child = None
+ try:
+ # if 1 :
+ child = self.appendBrother(objet_a_copier, pos)
+ except:
+ pass
+ return child
+
+ def doPastePremier(self, objet_a_copier):
+ # ---------------------------------------
+ """
+ Realise la copie de l'objet passe en argument (objet_a_copier)
+ """
+ objet = objet_a_copier.item.getCopieObjet()
+ child = self.appendChild(objet, pos="first")
+ return child
+
+ def plieToutEtReafficheSaufItem(self, itemADeplier):
+ # ---------------------------------------------------
+ self.inhibeExpand = True
+ from InterfaceGUI.QT5 import compojdc
+
+ if isinstance(self, compojdc.Node):
+ self.affichePanneau()
+ self.inhibeExpand = False
+ return
+ self.editor.deplier = False
+ for item in self.children:
+ # il ne faut pas plier les blocs
+ from InterfaceGUI.QT5 import compobloc
+
+ if isinstance(item, compobloc.Node):
+ continue
+ item.setPlie()
+ if item == itemADeplier:
+ itemADeplier.setDeplie()
+ self.affichePanneau()
+ self.inhibeExpand = False
+
+ def plieToutEtReaffiche(self):
+ # -----------------------------
+ # print ('plieToutEtReaffiche', self.item.getNom())
+ from InterfaceGUI.QT5 import compojdc
+
+ if isinstance(self, compojdc.Node):
+ self.affichePanneau()
+ return
+ self.inhibeExpand = True
+ self.editor.deplier = False
+ for item in self.children:
+ # il ne faut pas plier les blocs
+ from InterfaceGUI.QT5 import compobloc
+
+ if isinstance(item, compobloc.Node):
+ continue
+ item.setPlie()
+ self.affichePanneau()
+ # print ("fin plieToutEtReaffiche", self.item.getNom())
+
+ def deplieToutEtReaffiche(self):
+ # -----------------------------
+ self.editor.deplier = True
+ for item in self.children:
+ item.setDeplie()
+ self.affichePanneau()
+
+ def setPlie(self):
+ # -----------------
+ # print "je mets inhibeExpand a true dans setPlie"
+ # print ("je suis dans plieTout", self.item.getNom())
+ from . import compojdc
+
+ if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(
+ self.treeParent, compojdc.Node
+ ):
+ return
+ self.tree.inhibeExpand = True
+ self.tree.collapseItem(self)
+ self.setPlieChildren()
+ self.tree.inhibeExpand = False
+ # print "je mets inhibeExpand a false dans setPlie"
+
+ # on ne plie pas au niveau 1
+ # self.plie=False
+ # for item in self.children :
+ # item.appartientAUnNoeudPlie=False
+
+ def setPlieChildren(self):
+ # -----------------------------
+ self.plie = True
+ from InterfaceGUI.QT5 import composimp
+
+ if isinstance(self, composimp.Node):
+ return
+ for c in self.children:
+ c.setPlieChildren()
+ # print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0]
+ c.appartientAUnNoeudPlie = True
+ c.plie = True
+ # print "dans setPlieChildren plie", c.item.nom
+ # 01/2018 PNPN : boucle sur MT __ La ligne suivante ne me semble pas necessaire
+ # if not (isinstance(c,composimp.Node)) :c.setExpanded(False)
+
+ # Pour les blocs et les motcles list
+ # on affiche un niveau de plus
+ from InterfaceGUI.QT5 import compobloc
+ from InterfaceGUI.QT5 import compomclist
+
+ if isinstance(self, compobloc.Node) or (
+ isinstance(self, compomclist.Node) and self.item.isMCList()
+ ):
+ niveauPere = self.treeParent
+ while isinstance(niveauPere, compobloc.Node) or (
+ isinstance(niveauPere, compomclist.Node) and niveauPere.item.isMCList()
+ ):
+ niveauPere = niveauPere.treeParent
+ for c in self.children:
+ c.appartientAUnNoeudPlie = niveauPere.appartientAUnNoeudPlie
+ # print ("dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie)
+ c.setExpanded(False)
+
+ def setDeplie(self):
+ # -----------------------------
+ # print "dans setPlieChildren pour", self.item.nom
+ # print "je mets inhibeExpand a true dans setDeplie"
+ self.tree.inhibeExpand = True
+ self.plie = False
+ self.tree.expandItem(self)
+ self.setDeplieChildren()
+ self.tree.inhibeExpand = False
+ # print "je mets inhibeExpand a false dans setDePlie"
+
+ def setDeplieChildren(self):
+ # -----------------------------
+ # print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.getLabelText()
+ for c in self.children:
+ c.setDeplieChildren()
+ # print "dans setDeplieChildren ", c.item.nom
+ c.appartientAUnNoeudPlie = False
+ c.setExpanded(True)
+ c.plie = False
+
+ def selectAvant(self):
+ # -----------------------------
+ i = self.item.jdc.etapes.index(self.item.object)
+ try:
+ cherche = self.item.jdc.etapes[i - 1]
+ except:
+ cherche = self.item.jdc.etapes[-1]
+ node = None
+ for i in self.tree.racine.children:
+ if i.item.object == cherche:
+ node = i
+ break
+ if node:
+ node.affichePanneau()
+ node.select()
+
+ def selectApres(self):
+ # ---------------------
+ i = self.item.jdc.etapes.index(self.item.object)
+ try:
+ cherche = self.item.jdc.etapes[i + 1]
+ except:
+ cherche = self.item.jdc.etapes[0]
+ node = None
+ for i in self.tree.racine.children:
+ if i.item.object == cherche:
+ node = i
+ break
+ if node:
+ node.affichePanneau()
+ node.select()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from Editeur import Objecttreeitem
+
+from . import compofact
+from . import browser
+from . import typeNode
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNodeMinimal):
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
+
+ def getPanelGroupe(self, parentQt, commande):
+ maDefinition = self.item.get_definition()
+ monObjet = self.item.object
+ monNom = self.item.nom
+ maCommande = commande
+ if hasattr(parentQt, "niveau"):
+ self.niveau = parentQt.niveau + 1
+ else:
+ self.niveau = 1
+ from .monWidgetBloc import MonWidgetBloc
+
+ widget = MonWidgetBloc(
+ self, self.editor, parentQt, maDefinition, monObjet, self.niveau, maCommande
+ )
+
+
+class BLOCTreeItem(compofact.FACTTreeItem):
+ itemNode = Node
+
+ def isCopiable(self):
+ return 0
+
+
+import Accas
+
+treeitem = BLOCTreeItem
+objet = Accas.MCBLOC
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+from Editeur import Objecttreeitem
+from . import browser
+from . import typeNode
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNodePartiel):
+ def getPanel(self):
+ """ """
+ from .monWidgetCommentaire import MonWidgetCommentaire
+
+ return MonWidgetCommentaire(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
+ from PyQt5.QtWidgets import QAction
+
+ self.Decommente = QAction(tr("decommenter"), self.tree)
+ self.Decommente.triggered.connect(self.decommenter)
+ self.Decommente.setStatusTip(tr("Decommente la commande "))
+
+ if hasattr(self.item, "unComment"):
+ self.menu.addAction(self.Decommente)
+
+ def decommenter(self):
+ item = self.tree.currentItem()
+ item.unCommentIt()
+
+ def updateNodeLabel(self):
+ """ """
+ debComm = self.item.getText()
+ self.setText(1, tr(debComm))
+
+
+class COMMTreeItem(Objecttreeitem.ObjectTreeItem):
+ itemNode = Node
+
+ def init(self):
+ self.setFunction = self.setValeur
+
+ def getIconName(self):
+ """
+ Retourne le nom de l'icone associee au noeud qui porte self,
+ dependant de la validite de l'objet
+ NB : un commentaire est toujours valide ...
+ """
+ return "ast-white-percent"
+
+ def getLabelText(self):
+ """Retourne 3 valeurs :
+ - le texte a afficher dans le noeud representant l'item
+ - la fonte dans laquelle afficher ce texte
+ - la couleur du texte
+ """
+ return tr("Commentaire"), None, None
+
+ def getValeur(self):
+ """
+ Retourne la valeur de l'objet Commentaire cad son texte
+ """
+ return self.object.getValeur() or ""
+
+ def getText(self):
+ texte = self.object.valeur
+ texte = texte.split("\n")[0]
+ if len(texte) < 25:
+ return texte
+ else:
+ return texte[0:24]
+
+ def setValeur(self, valeur):
+ """
+ Affecte valeur a l'objet COMMENTAIRE
+ """
+ self.object.setValeur(valeur)
+
+ def getSubList(self):
+ """
+ Retourne la liste des fils de self
+ """
+ return []
+
+ def getObjetCommentarise(self):
+ """
+ La methode getObjetCommentarise() de la classe compocomm.COMMTreeItem
+ surcharge la methode getObjetCommentarise de la classe Objecttreeitem.ObjectTreeItem
+ elle a pour but d'empecher l'utilisateur final de commentariser un commentaire.
+ """
+ raise EficasException("Impossible de commentariser un commentaire")
+
+
+import Extensions
+
+treeitem = COMMTreeItem
+objet = Extensions.commentaire.COMMENTAIRE
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import traceback
+
+from Editeur import Objecttreeitem
+from Extensions.eficas_exception import EficasException
+from . import compocomm
+
+
+class COMMANDE_COMMTreeItem(Objecttreeitem.ObjectTreeItem):
+ itemNode = compocomm.Node
+
+ def init(self):
+ self.setFunction = self.setValeur
+
+ def getIconName(self):
+ """
+ Retourne le nom de l'icone associee au noeud qui porte self,
+ dependant de la validite de l'objet
+ NB : une commande commentarisee est toujours valide ...
+ """
+ if self.isValid():
+ return "ast-green-percent"
+ else:
+ return "ast-red-percent"
+
+ def getLabelText(self):
+ """Retourne 3 valeurs :
+ - le texte a afficher dans le noeud representant l'item
+ - la fonte dans laquelle afficher ce texte
+ - la couleur du texte
+ """
+ return "commentaire"
+
+ def getValeur(self):
+ """
+ Retourne la valeur de la commande commentarisee cad son texte
+ """
+ return self.object.getValeur() or ""
+
+ def getText(self):
+ texte = self.object.valeur
+ texte = texte.split("\n")[0]
+ if len(texte) < 25:
+ return texte
+ else:
+ return texte[0:24]
+
+ def setValeur(self, valeur):
+ """
+ Afefcte valeur a l'objet commande commentarisee
+ """
+ self.object.setValeur(valeur)
+
+ def getSubList(self):
+ """
+ Retourne la liste des fils de self
+ """
+ return []
+
+ def unComment(self):
+ """
+ Demande a l'objet commande commentarisee de se decommentariser.
+ Si l'operation s'effectue correctement, retourne l'objet commande
+ et eventuellement le nom de la sd produite, sinon leve une exception
+ """
+ try:
+ commande, nom = self.object.unComment()
+ # self.parent.children[pos].select()
+ except Exception as e:
+ traceback.print_exc()
+ raise EficasException(e)
+ return commande, nom
+
+
+import Accas
+
+treeitem = COMMANDE_COMMTreeItem
+objet = Accas.COMMANDE_COMM
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from InterfaceGUI.QT5 import browser
+from InterfaceGUI.QT5 import typeNode
+from Extensions.i18n import tr
+
+from Editeur import Objecttreeitem
+import traceback
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNodePartiel):
+ def getPanelGroupe(self, parentQt, commande):
+ # ----------------------------------------
+ maDefinition = self.item.get_definition()
+ monObjet = self.item.object
+ monNom = self.item.nom
+ maCommande = commande
+ if hasattr(parentQt, "niveau"):
+ self.niveau = parentQt.niveau + 1
+ else:
+ self.niveau = 1
+ if hasattr(self, "plie") and self.plie == True:
+ from InterfaceGUI.QT5.monWidgetFactPlie import MonWidgetFactPlie
+
+ widget = MonWidgetFactPlie(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche:
+ self.firstAffiche = False
+ self.setPlie()
+ from InterfaceGUI.QT5.monWidgetFactPlie import MonWidgetFactPlie
+
+ widget = MonWidgetFactPlie(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetFact import MonWidgetFact
+
+ widget = MonWidgetFact(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ return widget
+
+ def createPopUpMenu(self):
+ # ------------------------
+ typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
+
+
+class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
+ itemNode = Node
+
+ def isExpandable(self):
+ # ----------------------
+ return 1
+
+ def getText(self):
+ # ----------------
+ return ""
+
+ def getLabelText(self):
+ # ----------------------
+ """Retourne 3 valeurs :
+ - le texte à afficher dans le noeud representant l'item
+ - la fonte dans laquelle afficher ce texte
+ - la couleur du texte
+ """
+ # None --> fonte et couleur par defaut
+ if not (hasattr(self.object, "getLabelText")):
+ return self.object.nom, None, None
+ return self.object.getLabelText(), None, None
+
+ def isValid(self):
+ # ----------------
+ return self.object.isValid()
+
+ def isCopiable(self):
+ # ----------------
+ return 1
+
+ def getIconName(self):
+ # ----------------
+ if self.object.isValid():
+ return "ast-green-los"
+ elif self.object.isOblig():
+ return "ast-red-los"
+ else:
+ return "ast-yel-los"
+
+ # PNPN ????
+ # def keys(self):
+ # keys=self.object.mc_dict
+ # return keys
+
+ def getSubList(self):
+ # ----------------
+ """
+ Reactualise la liste des items fils stockes dans self.sublist
+ """
+ liste = self.object.mcListe
+ sublist = [None] * len(liste)
+ # suppression des items lies aux objets disparus
+ for item in self.sublist:
+ old_obj = item.getObject()
+ if old_obj in liste:
+ pos = liste.index(old_obj)
+ sublist[pos] = item
+ else:
+ pass # objets supprimes ignores
+ # ajout des items lies aux nouveaux objets
+ pos = 0
+ for obj in liste:
+ if sublist[pos] is None:
+ # nouvel objet : on cree un nouvel item
+ def setFunction(value, object=obj):
+ object.setval(value)
+
+ item = self.makeObjecttreeitem(
+ self.appliEficas, obj.nom + " : ", obj, setFunction
+ )
+ sublist[pos] = item
+ pos = pos + 1
+
+ self.sublist = sublist
+ return self.sublist
+
+ def addItem(self, name, pos):
+ objet = self.object.addEntite(name, pos)
+ return objet
+
+ def suppItem(self, item):
+ """
+ Cette methode a pour fonction de supprimer l'item passee en argument
+ des fils de l'item FACT qui est son pere
+ - item = item du MOCLE a supprimer du MOCLE pere
+ - item.getObject() = MCSIMP ou MCBLOC
+ """
+ itemobject = item.getObject()
+ if itemobject.isOblig():
+ return (0, tr("Impossible de supprimer un mot-cle obligatoire "))
+
+ if self.object.suppEntite(itemobject):
+ message = tr("Mot-cle %s supprime") + itemobject.nom
+ return (1, message)
+ else:
+ return (0, tr("Pb interne : impossible de supprimer ce mot-cle"))
+
+
+import Accas
+
+objet = Accas.MCFACT
+treeitem = FACTTreeItem
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 contient les classes permettant de definir les objets graphiques
+representant un objet de type FORMULE, cad le panneau et l'item de l'arbre
+d'EFICAS
+"""
+
+from . import compooper
+from . import browser
+from . import typeNode
+
+
+class FormuleNode(browser.JDCNode, typeNode.PopUpMenuNode):
+ def getPanel(self):
+ from .monWidgetFormule import MonWidgetFormule
+
+ return MonWidgetFormule(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+
+class FORMULETreeItem(compooper.EtapeTreeItem):
+ """
+ Classe servant a definir l'item porte par le noeud de l'arbre d'EFICAS
+ qui represente la FORMULE
+ """
+
+ itemNode = FormuleNode
+
+ def init(self):
+ self.setFunction = self.setValeur
+
+ # ---------------------------------------------------------------------------
+ # API de FORMULE pour l'arbre
+ # ---------------------------------------------------------------------------
+ def getSubList(self):
+ """
+ Retourne la liste des fils de self
+ On considere que FORMULE n'a pas de fils
+ --> modification par rapport a MACRO classique
+ """
+ # dans EFICAS on ne souhaite pas afficher les mots-cles fils de FORMULE
+ # de facon traditionnelle
+ return []
+
+ def getIconName(self):
+ """
+ Retourne le nom de l'icone a afficher dans l'arbre
+ Ce nom depend de la validite de l'objet
+ """
+ if self.object.isActif():
+ if self.object.isValid():
+ return "ast-green-square"
+ else:
+ return "ast-red-square"
+ else:
+ return "ast-white-text"
+
+ def getLabelText(self):
+ """Retourne 3 valeurs :
+ - le texte a afficher dans le noeud representant l'item
+ - la fonte dans laquelle afficher ce texte
+ - la couleur du texte
+ """
+ return self.labeltext, None, None
+ # if self.object.isActif():
+ # None --> fonte et couleur par defaut
+ # return tr(self.labeltext),None,None
+ # else:
+ # return tr(self.labeltext),None,None
+ # return self.labeltext,fontes.standard_italique,None
+
+ # ---------------------------------------------------------------------------
+ # Methodes permettant la modification et la lecture des attributs
+ # du parametre = API graphique de la FORMULE pour Panel et EFICAS
+ # ---------------------------------------------------------------------------
+
+ def getNom(self):
+ """
+ Retourne le nom de la FORMULE
+ """
+ return self.object.getNom()
+
+ def getType(self):
+ """
+ Retourne le type de la valeur retournee par la FORMULE
+ """
+ return self.object.type_retourne
+
+ def getArgs(self):
+ """
+ Retourne les arguments de la FORMULE
+ """
+ args = ""
+ for mot in self.object.mcListe:
+ if mot.nom == "NOM_PARA":
+ args = mot.valeur
+ break
+ if args:
+ if args[0] == "(" and args[-1] == ")":
+ args = args[1:-1]
+ # transforme en tuple si ce n est pas deja le casa
+ try:
+ args = args.split(",")
+ except:
+ pass
+ return args
+
+ def getCorps(self):
+ """
+ Retourne le corps de la FORMULE
+ """
+ corps = ""
+ for mot in self.object.mcListe:
+ if mot.nom == "VALE":
+ corps = mot.valeur
+ break
+ return corps
+
+ def getListeTypesAutorises(self):
+ """
+ Retourne la liste des types autorises pour les valeurs de sortie
+ d'une FORMULE
+ """
+ return self.object.l_types_autorises
+
+ def saveFormule(self, new_nom, new_typ, new_arg, new_exp):
+ """
+ Verifie si (new_nom,new_typ,new_arg,new_exp) definit bien une FORMULE
+ licite :
+ - si oui, stocke ces parametres comme nouveaux parametres de la
+ FORMULE courante et retourne 1
+ - si non, laisse les parametres anciens de la FORMULE inchanges et
+ retourne 0
+ """
+ test, erreur = self.object.verifFormule_python(
+ formule=(new_nom, new_typ, new_arg, new_exp)
+ )
+ if test:
+ # la formule est bien correcte : on sauve les nouveaux parametres
+ test = self.object.updateFormulePython(
+ formule=(new_nom, new_typ, new_exp, new_arg)
+ )
+ return test, erreur
+
+ # ---------------------------------------------------------------------------
+ # Acces aux methodes de verification de l'objet FORM_ETAPE
+ # ---------------------------------------------------------------------------
+
+ def verifNom(self, nom):
+ """
+ Lance la verification du nom passe en argument
+ """
+ return self.object.verifNom(nom)
+
+ def verifArguments(self, arguments):
+ """
+ Lance la verification des arguments passes en argument
+ """
+ return self.object.verifArguments("(" + arguments + ")")
+
+ def verifFormule(self, formule):
+ """
+ Lance la verification de FORMULE passee en argument
+ """
+ return self.object.verifFormule(formule=formule)
+
+ def verifFormule_python(self, formule):
+ """
+ Lance la verification de FORMULE passee en argument
+ """
+ return self.object.verifFormule_python(formule=formule)
+
+
+import Accas
+
+treeitem = FORMULETreeItem
+objet = Accas.FORM_ETAPE
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from Editeur import Objecttreeitem
+from . import browser
+from . import typeNode
+from Extensions.i18n import tr
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuRacine):
+ def getPanel(self):
+ from .monChoixCommande import MonChoixCommande
+ return MonChoixCommande(self, self.item, self.editor)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuRacine.createPopUpMenu(self)
+
+ def addParameters(self, apres):
+ param = self.appendChild("PARAMETRE", pos=0)
+ return param
+
+
+class JDCTreeItem(Objecttreeitem.ObjectTreeItem):
+ itemNode = Node
+
+ def isExpandable(self):
+ return 1
+
+ def getText(self):
+ return " "
+
+ def getLabelText(self):
+ # None --> fonte et couleur par defaut
+ return tr(self.object.nom), None, None
+
+ def getJdc(self):
+ """
+ Retourne l'objet pointe par self
+ """
+ return self.object
+
+ def getIconName(self):
+ if self.object.isValid():
+ return "ast-green-square"
+ else:
+ return "ast-red-square"
+
+ # def keys(self):
+ # if self.object.etapes_niveaux != []:
+ # return range(len(self.object.etapes_niveaux))
+ # else:
+ # return range(len(self.object.etapes))
+
+ def addItem(self, name, pos):
+ cmd = self._object.addEntite(name, pos)
+ return cmd
+
+ def suppItem(self, item):
+ # item = item de l'ETAPE a supprimer du JDC
+ # item.getObject() = ETAPE ou COMMENTAIRE
+ # self.object = JDC
+
+ itemobject = item.getObject()
+ if self.object.suppEntite(itemobject):
+ if itemobject.nature == "COMMENTAIRE":
+ message = tr("Commentaire supprime")
+ else:
+ message = tr("Commande %s supprimee", itemobject.nom)
+ return 1, message
+ else:
+ message = tr("Pb interne : impossible de supprimer cet objet")
+ return 0, message
+
+ def getSubList(self):
+ """
+ Retourne la liste des items fils de l'item jdc.
+ Cette liste est conservee et mise a jour a chaque appel
+ """
+ if self.object.etapes_niveaux != []:
+ liste = self.object.etapes_niveaux
+ else:
+ liste = self.object.etapes
+ sublist = [None] * len(liste)
+ # suppression des items lies aux objets disparus
+ for item in self.sublist:
+ old_obj = item.getObject()
+ if old_obj in liste:
+ pos = liste.index(old_obj)
+ sublist[pos] = item
+ else:
+ pass # objets supprimes ignores
+ # ajout des items lies aux nouveaux objets
+ pos = 0
+ for obj in liste:
+ if sublist[pos] is None:
+ # nouvel objet : on cree un nouvel item
+ item = self.makeObjecttreeitem(self.appliEficas, obj.nom + " : ", obj)
+ sublist[pos] = item
+ pos = pos + 1
+
+ self.sublist = sublist
+ return self.sublist
+
+ def getLNomsEtapes(self):
+ """Retourne la liste des noms des etapes de self.object"""
+ return self.object.getLNomsEtapes()
+
+ def getListeCmd(self):
+ listeCmd = self.object.niveau.definition.getListeCmd()
+ return listeCmd
+
+
+import Accas
+
+treeitem = JDCTreeItem
+objet = Accas.JDC
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 os, sys
+import types
+import traceback
+
+# Modules Eficas
+from Editeur import Objecttreeitem
+from Extensions.i18n import tr
+from InterfaceGUI.QT5 import compooper
+from InterfaceGUI.QT5 import browser
+from InterfaceGUI.QT5 import typeNode
+
+
+class MACRONode(browser.JDCNode, typeNode.PopUpMenuNode):
+ def getPanel(self):
+ from .monWidgetCommande import MonWidgetCommande
+
+ return MonWidgetCommande(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+
+# def view3D(self) :
+# from Editeur import TroisDPal
+# troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
+# troisD.envoievisu()
+
+
+class MACROTreeItem(compooper.EtapeTreeItem):
+ # """ Cette classe herite d'une grande partie des comportements
+ # de la classe compooper.EtapeTreeItem
+ # """
+ itemNode = MACRONode
+
+
+# ------------------------------------
+# Classes necessaires a INCLUDE
+# ------------------------------------
+
+
+class INCLUDETreeItemBase(MACROTreeItem):
+ def __init__(self, appliEficas, labeltext, object, setFunction):
+ MACROTreeItem.__init__(self, appliEficas, labeltext, object, setFunction)
+
+ def isCopiable(self):
+ return 0
+
+
+class INCLUDENode(browser.JDCNode, typeNode.PopUpMenuNode):
+ def getPanel(self):
+ from .monWidgetCommande import MonWidgetCommande
+
+ return MonWidgetCommande(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+ def makeEdit(self): # ,appliEficas,node
+ if self.item.object.text_converted == 0:
+ # Le texte du fichier inclus n'a pas pu etre converti par le module convert
+ msg = tr(
+ "Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n"
+ )
+ msg = msg + self.item.object.text_error
+ return
+
+ if not hasattr(self.item.object, "jdc_aux") or self.item.object.jdc_aux is None:
+ # L'include n'est pas initialise
+ self.item.object.buildInclude(None, "")
+
+ # On cree un nouvel onglet dans le bureau
+ self.editor.vm.displayJDC(
+ self.item.object.jdc_aux, self.item.object.jdc_aux.nom
+ )
+
+
+class INCLUDETreeItem(INCLUDETreeItemBase):
+ itemNode = INCLUDENode
+
+
+# ------------------------------------
+# Classes necessaires a POURSUITE
+# ------------------------------------
+
+
+class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
+ def getPanel(self):
+ from .monWidgetCommande import MonWidgetCommande
+
+ return MonWidgetCommande(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+ def makeEdit(self): # ,appliEficas,node
+ if self.item.object.text_converted == 0:
+ msg = tr(
+ "Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n"
+ )
+ msg = msg + self.item.object.text_error
+ return
+
+ if not hasattr(self.item.object, "jdc_aux") or self.item.object.jdc_aux is None:
+ text = """DEBUT()
+ FIN()"""
+ self.object.buildPoursuite(None, text)
+
+ # On cree un nouvel onglet dans le bureau
+ self.editor.vm.displayJDC(
+ self.item.object.jdc_aux, self.item.object.jdc_aux.nom
+ )
+
+
+class POURSUITETreeItem(INCLUDETreeItemBase):
+ itemNode = POURSUITENode
+
+
+# ----------------------------------------
+# Classes necessaires a INCLUDE MATERIAU
+# ----------------------------------------
+
+
+class MATERIAUNode(MACRONode):
+ def getPanel(self):
+ from .monWidgetCommande import MonWidgetCommande
+
+ return MonWidgetCommande(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+ def makeView(self):
+ if (
+ hasattr(self.item.object, "fichier_ini")
+ and self.item.object.fichier_ini == None
+ ):
+ QMessageBox.information(
+ self,
+ tr("Include vide"),
+ tr("L'include doit etre correctement initialise pour etre visualise"),
+ )
+ return
+ f = open(self.item.object.fichier_ini, "rb")
+ texte = f.read()
+ f.close()
+ from desVisu import DVisu
+
+ monVisuDialg = DVisu(parent=self.editor.appliEficas, fl=0)
+ monVisuDialg.TB.setText(texte)
+ monVisuDialg.show()
+
+
+class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
+ itemNode = MATERIAUNode
+
+
+# ------------------------------------
+# TreeItem
+# ------------------------------------
+
+
+def treeitem(appliEficas, labeltext, object, setFunction=None):
+ """Factory qui retourne l'item adapte au type de macro :
+ INCLUDE, POURSUITE, MACRO
+ """
+ if object.nom == "INCLUDE_MATERIAU":
+ return INCLUDE_MATERIAUTreeItem(appliEficas, labeltext, object, setFunction)
+ elif object.nom == "INCLUDE" or object.nom == "DICTDATA":
+ return INCLUDETreeItem(appliEficas, labeltext, object, setFunction)
+ elif object.nom == "POURSUITE":
+ return POURSUITETreeItem(appliEficas, labeltext, object, setFunction)
+ else:
+ return MACROTreeItem(appliEficas, labeltext, object, setFunction)
+
+
+import Accas
+
+objet = Accas.MACRO_ETAPE
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+
+import types
+import traceback
+
+from . import compofact
+from . import browser
+from . import typeNode
+from Extensions.i18n import tr
+
+from Editeur import Objecttreeitem
+from Noyau.N_OBJECT import ErrorObj
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNodeMinimal):
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
+
+ def getPanelGroupe(self, parentQt, commande):
+ maDefinition = self.item.get_definition()
+ monObjet = self.item.object
+ monNom = self.item.nom
+ maCommande = commande
+ if hasattr(parentQt, "niveau"):
+ self.niveau = parentQt.niveau + 1
+ else:
+ self.niveau = 1
+ # attention si l objet est une mclist on utilise bloc
+ if not (monObjet.isMCList()):
+ if hasattr(self, "plie") and self.plie == True:
+ from InterfaceGUI.QT5.monWidgetFactPlie import MonWidgetFactPlie
+
+ widget = MonWidgetFactPlie(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche:
+ self.firstAffiche = False
+ self.setPlie()
+ from InterfaceGUI.QT5.monWidgetFactPlie import MonWidgetFactPlie
+
+ widget = MonWidgetFactPlie(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetFact import MonWidgetFact
+
+ widget = MonWidgetFact(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetBloc import MonWidgetBloc
+
+ widget = MonWidgetBloc(
+ self,
+ self.editor,
+ parentQt,
+ maDefinition,
+ monObjet,
+ self.niveau,
+ maCommande,
+ )
+ return widget
+
+ def doPaste(self, node_selected, pos):
+ objet_a_copier = self.item.getCopieObjet()
+ # before est un effet de bord heureux sur l index
+ child = self.appendBrother(objet_a_copier, "before")
+ if self.editor.fenetreCentraleAffichee:
+ self.editor.fenetreCentraleAffichee.node.affichePanneau()
+ self.update_NodeLabelInBlack()
+ self.parent().buildChildren()
+ return child
+
+
+class MCListTreeItem(Objecttreeitem.SequenceTreeItem, compofact.FACTTreeItem):
+ """La classe MCListTreeItem joue le role d'un adaptateur pour les objets
+ du noyau Accas instances de la classe MCLIST.
+ Elle adapte ces objets pour leur permettre d'etre integres en tant que
+ noeuds dans un arbre graphique (voir treewidget.py et ObjectTreeItem.py).
+ Cette classe delegue les appels de methode et les acces
+ aux attributs a l'objet du noyau soit manuellement soit
+ automatiquement (voir classe Delegate et attribut object).
+ """
+
+ itemNode = Node
+
+ def init(self):
+ # Si l'objet Accas (MCList) a moins d'un mot cle facteur
+ # on utilise directement ce mot cle facteur comme delegue
+ self.updateDelegate()
+
+ def updateDelegate(self):
+ if len(self._object) > 1:
+ self.setDelegate(self._object)
+ else:
+ self.setDelegate(self._object.data[0])
+
+ def panel(self, jdcdisplay, pane, node):
+ """Retourne une instance de l'objet panneau associe a l'item (self)
+ Si la liste ne contient qu'un mot cle facteur, on utilise le panneau
+ FACTPanel.
+ Si la liste est plus longue on utilise le panneau MCLISTPanel.
+ """
+ if len(self._object) > 1:
+ return MCLISTPanel(jdcdisplay, pane, node)
+ elif isinstance(self._object.data[0], ErrorObj):
+ return compoerror.ERRORPanel(jdcdisplay, pane, node)
+ else:
+ return compofact.FACTPanel(jdcdisplay, pane, node)
+
+ def isExpandable(self):
+ if len(self._object) > 1:
+ return Objecttreeitem.SequenceTreeItem.isExpandable(self)
+ else:
+ return compofact.FACTTreeItem.isExpandable(self)
+
+ def getSubList(self):
+ self.updateDelegate()
+ if len(self._object) <= 1:
+ self._object.data[0].alt_parent = self._object
+ return compofact.FACTTreeItem.getSubList(self)
+
+ liste = self._object.data
+ sublist = [None] * len(liste)
+ # suppression des items lies aux objets disparus
+ for item in self.sublist:
+ old_obj = item.getObject()
+ if old_obj in liste:
+ pos = liste.index(old_obj)
+ sublist[pos] = item
+ else:
+ pass # objets supprimes ignores
+ # ajout des items lies aux nouveaux objets
+ pos = 0
+ for obj in liste:
+ if sublist[pos] is None:
+ # nouvel objet : on cree un nouvel item
+ def setFunction(value, object=obj):
+ object = value
+
+ item = self.makeObjecttreeitem(
+ self.appliEficas, obj.nom + " : ", obj, setFunction
+ )
+ sublist[pos] = item
+ # Attention : on ajoute une information supplementaire pour l'actualisation de
+ # la validite. L'attribut parent d'un MCFACT pointe sur le parent de la MCLISTE
+ # et pas sur la MCLISTE elle meme ce qui rompt la chaine de remontee des
+ # informations de validite. alt_parent permet de remedier a ce defaut.
+ obj.alt_parent = self._object
+ pos = pos + 1
+
+ self.sublist = sublist
+ return self.sublist
+
+ def getIconName(self):
+ if self._object.isValid():
+ return "ast-green-los"
+ elif self._object.isOblig():
+ return "ast-red-los"
+ else:
+ return "ast-yel-los"
+
+ def getDocu(self):
+ """Retourne la clef de doc de l'objet pointe par self"""
+ return self.object.getDocu()
+
+ def isCopiable(self):
+ if len(self._object) > 1:
+ return Objecttreeitem.SequenceTreeItem.isCopiable(self)
+ else:
+ return compofact.FACTTreeItem.isCopiable(self)
+
+ def isMCFact(self):
+ """
+ Retourne 1 si l'objet pointe par self est un MCFact, 0 sinon
+ """
+ return len(self._object) <= 1
+
+ def isMCList(self):
+ """
+ Retourne 1 si l'objet pointe par self est une MCList, 0 sinon
+ """
+ return len(self._object) > 1
+
+ def getCopieObjet(self):
+ return self._object.data[0].copy()
+
+ def addItem(self, obj, pos):
+ # print "compomclist.addItem",obj,pos
+ if len(self._object) <= 1:
+ return compofact.FACTTreeItem.addItem(self, obj, pos)
+
+ o = self.object.addEntite(obj, pos)
+ return o
+
+ def suppItem(self, item):
+ """
+ Retire un objet MCFACT de la MCList (self.object)
+ """
+ # print "compomclist.suppItem",item
+ obj = item.getObject()
+ if len(self._object) <= 1:
+ return compofact.FACTTreeItem.suppItem(self, item)
+
+ if self.object.suppEntite(obj):
+ if len(self._object) == 1:
+ self.updateDelegate()
+ message = "Mot-clef " + obj.nom + " supprime"
+ return (1, message)
+ else:
+ return (0, tr("Impossible de supprimer ce mot-clef"))
+
+
+import Accas
+
+objet = Accas.MCList
+
+
+def treeitem(appliEficas, labeltext, object, setFunction):
+ """Factory qui produit un objet treeitem adapte a un objet
+ Accas.MCList (attribut objet de ce module)
+ """
+ return MCListTreeItem(appliEficas, labeltext, object, setFunction)
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2024 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
+#
+from builtins import str
+import os
+import tempfile
+
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
+
+from Editeur import Objecttreeitem
+from . import browser
+from . import typeNode
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNode):
+ def select(self):
+ browser.JDCNode.select(self)
+ self.treeParent.tree.openPersistentEditor(self, 1)
+ self.monWidgetNom = self.treeParent.tree.itemWidget(self, 1)
+ self.monWidgetNom.returnPressed.connect(self.nomme)
+ if self.item.getIconName() == "ast-red-square":
+ self.monWidgetNom.setDisabled(True)
+ # else : self.monWidgetNom.setFocus() ;self.monWidgetNom.setDisabled(False)
+
+ def nomme(self):
+ nom = str(self.monWidgetNom.text())
+ self.editor.initModif()
+ test, mess = self.item.nommeSd(nom)
+ if test == 0:
+ self.editor.afficheInfos(mess, "red")
+ old = self.item.getText()
+ self.monWidgetNom.setText(old)
+ else:
+ self.editor.afficheCommentaire(tr("Nommage du concept effectue"))
+ self.onValid()
+ try:
+ self.fenetre.LENom.setText(nom)
+ except:
+ pass
+
+ def getPanel(self):
+ from .monWidgetCommande import MonWidgetCommande
+
+ return MonWidgetCommande(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+
+# def view3D(self) :
+# from Editeur import TroisDPal
+# troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
+# troisD.envoievisu()
+
+
+class EtapeTreeItem(Objecttreeitem.ObjectTreeItem):
+ """La classe EtapeTreeItem est un adaptateur des objets ETAPE du noyau
+ Accas. Elle leur permet d'etre affichés comme des noeuds
+ d'un arbre graphique.
+ Cette classe a entre autres deux attributs importants :
+ - _object qui est un pointeur vers l'objet du noyau
+ - object qui pointe vers l'objet auquel sont délégués les
+ appels de méthode et les acces aux attributs
+ Dans le cas d'une ETAPE, _object et object pointent vers le
+ meme objet.
+ """
+
+ itemNode = Node
+
+ def isExpandable(self):
+ return 1
+
+ def getIconName(self):
+ """
+ Retourne le nom de l'icone a afficher dans l'arbre
+ Ce nom depend de la validite de l'objet
+ """
+ if not self.object.isActif():
+ return "ast-white-square"
+ elif self.object.isValid():
+ return "ast-green-square"
+ else:
+ valid = self.validChild()
+ valid = valid * self.validRegles("non")
+ if self.reste_val != {}:
+ valid = 0
+ if valid == 0:
+ return "ast-red-square"
+ else:
+ try:
+ # on traite ici le cas d include materiau
+ # print self.object.definition.nom
+ if self.object.fichier_ini != self.object.nom_mater:
+ return "ast-red-square"
+ except:
+ pass
+ return "ast-yellow-square"
+
+ def getLabelText(self):
+ """Retourne 3 valeurs :
+ - le texte a afficher dans le noeud représentant l'item
+ - la fonte dans laquelle afficher ce texte
+ - la couleur du texte
+ """
+ return self.labeltext, None, None
+ # if self.object.isActif():
+ # None --> fonte et couleur par défaut
+ # return self.labeltext,None,None
+ # else:
+ # return self.labeltext, None, None #CS_pbruno todo
+
+ # def get_objet(self,name) :
+ # for v in self.object.mcListe:
+ # if v.nom == name : return v
+ # return None
+
+ # def getType_sd_prod(self):
+ # """
+ # Retourne le nom du type du concept résultat de l'étape
+ # """
+ # sd_prod=self.object.getType_produit()
+ # if sd_prod:
+ # return sd_prod.__name__
+ # else:
+ # return ""
+
+ def addItem(self, name, pos):
+ mcent = self._object.addEntite(name, pos)
+ return mcent
+
+ def suppItem(self, item):
+ # item : item du MOCLE de l'ETAPE a supprimer
+ # item.getObject() = MCSIMP, MCFACT, MCBLOC ou MCList
+ itemobject = item.getObject()
+ if itemobject.isOblig():
+ return (0, tr("Impossible de supprimer un mot-clef obligatoire "))
+ if self.object.suppEntite(itemobject):
+ message = tr("Mot-clef %s supprime ", itemobject.nom)
+ return (1, message)
+ else:
+ return (0, tr("Pb interne : impossible de supprimer ce mot-clef"))
+
+ def getText(self):
+ try:
+ return self.object.getSdname()
+ except:
+ return ""
+
+ # PNPN ????
+ # def keys(self):
+ # keys=self.object.mc_dict
+ # return keys
+
+ def getSubList(self):
+ """
+ Reactualise la liste des items fils stockes dans self.sublist
+ """
+ if self.isActif():
+ liste = self.object.mcListe
+ else:
+ liste = []
+
+ sublist = [None] * len(liste)
+ # suppression des items lies aux objets disparus
+ for item in self.sublist:
+ old_obj = item.getObject()
+ if old_obj in liste:
+ pos = liste.index(old_obj)
+ sublist[pos] = item
+ else:
+ pass # objets supprimes ignores
+
+ # ajout des items lies aux nouveaux objets
+ pos = 0
+ for obj in liste:
+ if sublist[pos] is None:
+ # nouvel objet : on cree un nouvel item
+ def setFunction(value, object=obj):
+ object.setval(value)
+
+ item = self.makeObjecttreeitem(
+ self.appliEficas, obj.nom + " : ", obj, setFunction
+ )
+ sublist[pos] = item
+ pos = pos + 1
+
+ self.sublist = sublist
+ return self.sublist
+
+ def isValid(self):
+ return self.object.isValid()
+
+ def isCopiable(self):
+ """
+ Retourne 1 si l'objet est copiable, 0 sinon
+ """
+ return 1
+
+ def updateDeplace(self, item):
+ if item.sd and item.sd.nom:
+ self.object.sd = item.sd
+ self.object.sd.nom = item.sd.nom
+
+ def update(self, item):
+ if item.sd and item.sd.nom:
+ self.nommeSd(item.sd.nom)
+
+ def nommeSd(self, nom):
+ """Lance la méthode de nommage de la SD"""
+ oldnom = ""
+ if self.object.sd != None:
+ oldnom = self.object.sd.nom
+ test, mess = self.object.nommeSd(nom)
+ if test:
+ self.object.parent.resetContext()
+ if test and oldnom in self.appliEficas.dict_reels:
+ self.appliEficas.dict_reels[nom] = self.appliEficas.dict_reels[oldnom]
+ return test, mess
+
+ def isReentrant(self):
+ return self.object.isReentrant()
+
+ def getNomsSdOperReentrant(self):
+ return self.object.getNomsSdOperReentrant()
+
+ def getObjetCommentarise(self):
+ """
+ Cette méthode retourne un objet commentarisé
+ représentatif de self.object
+ """
+ # Format de fichier utilisé
+ format = self.appliEficas.formatFichierIn
+ return self.object.getObjetCommentarise(format)
+
+ def getObjetCommentarise_BAK(self):
+ """
+ Cette méthode retourne un objet commentarisé
+ représentatif de self.object
+ """
+ import generator, Accas
+
+ # Format de fichier utilisé
+ format = self.appliEficas.format_fichier
+ g = generator.plugins[format]()
+ texte_commande = g.gener(self.object, format="beautifie")
+ # Il faut enlever la premiere ligne vide de texte_commande que
+ # rajoute le generator
+ rebut, texte_commande = texte_commande.split("\n", 1)
+ # on construit l'objet COMMANDE_COMM repésentatif de self mais non
+ # enregistré dans le jdc
+ commande_comment = Accas.COMMANDE_COMM(
+ texte=texte_commande, reg="non", parent=self.object.parent
+ )
+ commande_comment.niveau = self.object.niveau
+ commande_comment.jdc = commande_comment.parent = self.object.jdc
+
+ pos = self.object.parent.etapes.index(self.object)
+ parent = self.object.parent
+ self.object.parent.suppEntite(self.object)
+ parent.addEntite(commande_comment, pos)
+
+ return commande_comment
+
+
+import Accas
+
+treeitem = EtapeTreeItem
+objet = Accas.ETAPE
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 contient les classes permettant de definir les objets graphiques
+ representant un objet de type PARAMETRE, cad le panneau et l'item de l'arbre
+ d'EFICAS
+"""
+# import modules Python
+import types
+from Extensions.i18n import tr
+
+# import modules EFICAS
+from Editeur import Objecttreeitem
+from . import browser
+from . import typeNode
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNodePartiel):
+ def getPanel(self):
+ """ """
+ from .monWidgetParam import MonWidgetParam
+
+ return MonWidgetParam(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
+ self.menu.removeAction(self.Documentation)
+
+ def doPaste(self, node_selected, pos="after"):
+ return None
+
+
+class PARAMTreeItem(Objecttreeitem.ObjectTreeItem):
+ """
+ Classe servant a definir l'item porte par le noeud de l'arbre d'EFICAS
+ qui represente le PARAMETRE
+ """
+
+ itemNode = Node
+
+ def init(self):
+ self.setFunction = self.setValeur
+
+ # ---------------------------------------------------------------------------
+ # API du PARAMETRE pour l'arbre
+ # ---------------------------------------------------------------------------
+
+ def getIconName(self):
+ """
+ Retourne le nom de l'icone associee au noeud qui porte self,
+ dependant de la validite de l'objet
+ NB : un PARAMETRE est toujours valide ...
+ """
+ if self.isActif():
+ if self.isValid():
+ return "ast-green-square"
+ else:
+ return "ast-red-square"
+ else:
+ return "ast-white-square"
+
+ def getLabelText(self):
+ """Retourne 3 valeurs :
+ - le texte a afficher dans le noeud representant l'item
+ - la fonte dans laquelle afficher ce texte
+ - la couleur du texte
+ """
+ return tr("PARAMETRE"), None, None
+
+ def getText(self):
+ """
+ Retourne le texte a afficher apres le nom de la commande (ici apres 'parametre')
+ Ce texte est tronque a 25 caracteres
+ """
+ texte = self.object.nom + "=" + str(self.object.valeur)
+ if type(self.object.valeur) == list:
+ texte = self.nom + " = ["
+ for l in self.object.valeur:
+ texte = texte + str(l) + ","
+ texte = texte[0:-1] + "]"
+ texte = texte.split("\n")[0]
+ if len(texte) < 25:
+ return texte
+ else:
+ return texte[0:24] + "..."
+
+ def getSubList(self):
+ """
+ Retourne la liste des fils de self
+ """
+ return []
+
+ # ---------------------------------------------------------------------------
+ # Methodes permettant la modification et la lecture des attributs
+ # du parametre = API graphique du PARAMETRE pour Panel et EFICAS
+ # ---------------------------------------------------------------------------
+
+ def getValeur(self):
+ """
+ Retourne la valeur de l'objet PARAMETRE cad son texte
+ """
+ if self.object.valeur is None:
+ return ""
+ else:
+ return self.object.valeur
+
+ def getNom(self):
+ """
+ Retourne le nom du parametre
+ """
+ return self.object.nom
+
+ def setValeur(self, new_valeur):
+ """
+ Affecte valeur a l'objet PARAMETRE
+ """
+ self.object.setValeur(new_valeur)
+
+ def setNom(self, new_nom):
+ """
+ Renomme le parametre
+ """
+ self.object.setNom(new_nom)
+ # self.object.setAttribut('nom',new_nom)
+
+ def getFr(self):
+ """
+ Retourne le fr associe au parametre, cad la bulle d'aide pour EFICAS
+ """
+ return tr("Definition d'un parametre")
+
+
+import Extensions.parametre
+
+treeitem = PARAMTreeItem
+objet = Extensions.parametre.PARAMETRE
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from Editeur import Objecttreeitem
+from . import compooper
+from . import browser
+from . import typeNode
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNode):
+ def getPanel(self):
+ # print "getPanel de compoproc"
+ from .monWidgetCommande import MonWidgetCommande
+
+ return MonWidgetCommande(self, self.editor, self.item.object)
+
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNode.createPopUpMenu(self)
+
+
+class ProcEtapeTreeItem(compooper.EtapeTreeItem):
+ itemNode = Node
+
+
+import Accas
+
+treeitem = ProcEtapeTreeItem
+objet = Accas.PROC_ETAPE
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2024 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 types, os
+
+from copy import copy, deepcopy
+import traceback
+from InterfaceGUI.QT5 import typeNode
+
+# Modules Eficas
+from Editeur import Objecttreeitem
+from InterfaceGUI.QT5 import browser
+from Noyau.N_CR import justifyText
+from Accas import SalomeEntry
+from Accas import ASSD
+from Accas import UserASSD
+from Accas import UserASSDMultiple
+
+
+class Node(browser.JDCNode, typeNode.PopUpMenuNodeMinimal):
+ def createPopUpMenu(self):
+ typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
+
+ def getPanelGroupe(self, parentQt, maCommande):
+ # print (self,self.item.nom, )
+ maDefinition = self.item.get_definition()
+ monObjet = self.item.object
+ monNom = self.item.nom
+
+ # le mot clef est cache ou cache avec defaut
+ if maDefinition.statut in ("c", "d"):
+ return None
+ # label informatif
+ if monObjet.isInformation():
+ from InterfaceGUI.QT5.monWidgetInfo import MonWidgetInfo
+
+ widget = MonWidgetInfo(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ self.widget = widget
+ return widget
+
+ # Attention l ordre des if est important
+ # Attention il faut gerer les blocs et les facteurs
+ # a gerer comme dans composimp
+ # Gestion des matrices
+ if self.item.waitMatrice():
+ from InterfaceGUI.QT5.monWidgetMatrice import MonWidgetMatrice
+
+ widget = MonWidgetMatrice(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ self.widget = widget
+ return widget
+
+ # print "____________________________", monNom, self.item.waitCo()
+ # print "____________________________", monNom, self.item.waitAssd()
+ # Gestion d'une seule valeur (eventuellement un tuple ou un complexe)
+ if maDefinition.into != [] and maDefinition.into != None:
+ if type(maDefinition.into) == types.FunctionType:
+ monInto = maDefinition.into()
+ else:
+ monInto = maDefinition.into
+
+ if maDefinition.max == 1:
+ # A verifier
+ if maDefinition.intoSug != [] and maDefinition.intoSug != None:
+ from InterfaceGUI.QT5.monWidgetCBIntoSug import MonWidgetCBIntoSug
+
+ widget = MonWidgetCBIntoSug(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif maDefinition.into != [] and maDefinition.into != None:
+ if maDefinition.fenetreIhm == "menuDeroulant":
+ from InterfaceGUI.QT5.monWidgetCB import MonWidgetCB
+
+ widget = MonWidgetCB(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif len(monInto) < 4:
+ from InterfaceGUI.QT5.monWidgetRadioButton import MonWidgetRadioButton
+
+ widget = MonWidgetRadioButton(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif len(monInto) < 7:
+ from InterfaceGUI.QT5.monWidget4a6RadioButton import (
+ MonWidget4a6RadioButton,
+ )
+
+ widget = MonWidget4a6RadioButton(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetCB import MonWidgetCB
+
+ widget = MonWidgetCB(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.waitBool():
+ from InterfaceGUI.QT5.monWidgetSimpBool import MonWidgetSimpBool
+
+ widget = MonWidgetSimpBool(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif self.item.waitFichier():
+ from InterfaceGUI.QT5.monWidgetSimpFichier import MonWidgetSimpFichier
+
+ widget = MonWidgetSimpFichier(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ # PNPNPN - a faire
+ elif self.item.waitDate():
+ from InterfaceGUI.QT5.monWidgetDate import MonWidgetDate
+
+ widget = MonWidgetDate(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif self.item.waitHeure():
+ from InterfaceGUI.QT5.monWidgetHeure import MonWidgetHeure
+
+ widget = MonWidgetHeure(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.waitTuple():
+ num = self.item.object.definition.type[0].ntuple
+ nomDeLaClasse = "MonWidgetSimpTuple" + str(num)
+ nomDuFichier = "InterfaceGUI.QT5.monWidgetSimpTupleN"
+ try:
+ # if 1 :
+ _temp = __import__(
+ nomDuFichier, globals(), locals(), [nomDeLaClasse], 0
+ )
+ # print (_temp)
+ MonWidgetSimpTuple = getattr(_temp, nomDeLaClasse)
+ # print (MonWidgetSimpTuple)
+ except:
+ print("Pas de Tuple de longueur : ", num)
+ # print ("Prevenir la maintenance ")
+ widget = MonWidgetSimpTuple(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.waitComplex():
+ from InterfaceGUI.QT5.monWidgetSimpComplexe import MonWidgetSimpComplexe
+
+ widget = MonWidgetSimpComplexe(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.waitCo():
+ if len(self.item.getSdAvantDuBonType()) == 0:
+ from InterfaceGUI.QT5.monWidgetUniqueSDCO import MonWidgetUniqueSDCO
+
+ widget = MonWidgetUniqueSDCO(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetSDCOInto import MonWidgetSDCOInto
+
+ widget = MonWidgetSDCOInto(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif self.item.waitAssd():
+ # PN - pour ne pas appeller trop souvent self.item.getSdAvantDuBonType()
+ if not (self.item.waitUserAssdOrAssdMultipleEnCreation()):
+ maListe = self.item.getSdAvantDuBonType()
+ if self.item.waitUserAssdOrAssdMultipleEnCreation():
+ from InterfaceGUI.QT5.monWidgetCreeUserAssd import MonWidgetCreeUserAssd
+
+ widget = MonWidgetCreeUserAssd(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ # elif len(self.item.getSdAvantDuBonType()) == 0 :
+ elif len(maListe) == 0:
+ from InterfaceGUI.QT5.monWidgetVide import MonWidgetVide
+
+ widget = MonWidgetVide(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ # elif len(self.item.getSdAvantDuBonType()) < 4 :
+ elif len(maListe) < 4:
+ from InterfaceGUI.QT5.monWidgetRadioButton import MonWidgetRadioButtonSD
+
+ widget = MonWidgetRadioButtonSD(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ # elif len(self.item.getSdAvantDuBonType()) < 7 :
+ elif len(maListe) < 7:
+ from InterfaceGUI.QT5.monWidget4a6RadioButton import (
+ MonWidget4a6RadioButtonSD,
+ )
+
+ widget = MonWidget4a6RadioButtonSD(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetCB import MonWidgetCBSD
+
+ widget = MonWidgetCBSD(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.waitSalome() and self.editor.salome:
+ from InterfaceGUI.QT5.monWidgetSimpSalome import MonWidgetSimpSalome
+
+ widget = MonWidgetSimpSalome(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.waitTxm():
+ from InterfaceGUI.QT5.monWidgetSimpTxt import MonWidgetSimpTxt
+
+ widget = MonWidgetSimpTxt(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetSimpBase import MonWidgetSimpBase
+
+ widget = MonWidgetSimpBase(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ # Gestion des listes
+ else:
+ if maDefinition.intoSug != [] and maDefinition.intoSug != None:
+ if self.item in self.editor.listeDesListesOuvertes or not (
+ self.editor.afficheListesPliees
+ ):
+ from InterfaceGUI.QT5.monWidgetIntoSug import MonWidgetIntoSug
+
+ widget = MonWidgetIntoSug(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetPlusieursPlie import (
+ MonWidgetPlusieursPlie,
+ )
+
+ widget = MonWidgetPlusieursPlie(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ # if maDefinition.into != [] and maDefinition.into != None:
+ # Attention pas fini --> on attend une liste de ASSD avec ordre
+ elif self.item.waitAssd() and self.item.isListSansOrdreNiDoublon():
+ listeAAfficher = self.item.getSdAvantDuBonType()
+ if len(listeAAfficher) == 0:
+ from InterfaceGUI.QT5.monWidgetVide import MonWidgetVide
+
+ widget = MonWidgetVide(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetPlusieursInto import (
+ MonWidgetPlusieursInto,
+ )
+
+ widget = MonWidgetPlusieursInto(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif (
+ self.item.waitAssd()
+ and not self.item.waitUserAssdOrAssdMultipleEnCreation()
+ ):
+ listeAAfficher = self.item.getSdAvantDuBonType()
+ # a changer selon UserASSD ou UserASSDMultiple
+ mctype = maDefinition.type[0]
+ 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
+ )
+ )
+ if enable_salome_selection:
+ from InterfaceGUI.QT5.monWidgetPlusieursBase import (
+ MonWidgetPlusieursBase,
+ )
+
+ widget = MonWidgetPlusieursBase(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif len(listeAAfficher) == 0:
+ from InterfaceGUI.QT5.monWidgetVide import MonWidgetVide
+
+ widget = MonWidgetVide(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif self.item in self.editor.listeDesListesOuvertes or not (
+ self.editor.afficheListesPliees
+ ):
+ from InterfaceGUI.QT5.monWidgetPlusieursASSDIntoOrdonne import (
+ MonWidgetPlusieursASSDIntoOrdonne,
+ )
+
+ widget = MonWidgetPlusieursASSDIntoOrdonne(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetPlusieursPlie import (
+ MonWidgetPlusieursPlieASSD,
+ )
+
+ widget = MonWidgetPlusieursPlieASSD(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif self.item.waitTuple():
+ if self.item.object.definition.fenetreIhm == "Tableau":
+ from InterfaceGUI.QT5.monWidgetTableau import MonWidgetTableau
+
+ widget = MonWidgetTableau(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ num = self.item.object.definition.type[0].ntuple
+ nomDeLaClasse = "MonWidgetPlusieursTuple" + str(num)
+ nomDuFichier = "InterfaceGUI.QT5.monWidgetPlusieursTupleN"
+ try:
+ _temp = __import__(
+ nomDuFichier, globals(), locals(), [nomDeLaClasse], 0
+ )
+ MonWidgetPlusieursTuple = getattr(_temp, nomDeLaClasse)
+ except:
+ print("Pas de Tuple de longueur : ", num)
+ print("Prevenir la maintenance ")
+ widget = MonWidgetPlusieursTuple(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ elif self.item.hasInto():
+ if self.item.isListSansOrdreNiDoublon():
+ if self.item in self.editor.listeDesListesOuvertes or not (
+ self.editor.afficheListesPliees
+ ):
+ from InterfaceGUI.QT5.monWidgetPlusieursInto import (
+ MonWidgetPlusieursInto,
+ )
+
+ widget = MonWidgetPlusieursInto(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetPlusieursPlie import (
+ MonWidgetPlusieursPlie,
+ )
+
+ widget = MonWidgetPlusieursPlie(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ if self.item in self.editor.listeDesListesOuvertes or not (
+ self.editor.afficheListesPliees
+ ):
+ from InterfaceGUI.QT5.monWidgetPlusieursIntoOrdonne import (
+ MonWidgetPlusieursIntoOrdonne,
+ )
+
+ widget = MonWidgetPlusieursIntoOrdonne(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetPlusieursPlie import (
+ MonWidgetPlusieursPlie,
+ )
+
+ widget = MonWidgetPlusieursPlie(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ if self.item.waitUserAssdOrAssdMultipleEnCreation():
+ from InterfaceGUI.QT5.monWidgetPlusieursCreeUserAssd import (
+ MonWidgetPlusieursCreeUserAssd,
+ )
+
+ widget = MonWidgetPlusieursCreeUserAssd(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ elif self.item in self.editor.listeDesListesOuvertes or not (
+ self.editor.afficheListesPliees
+ ):
+ from InterfaceGUI.QT5.monWidgetPlusieursBase import (
+ MonWidgetPlusieursBase,
+ )
+
+ widget = MonWidgetPlusieursBase(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+ else:
+ from InterfaceGUI.QT5.monWidgetPlusieursPlie import (
+ MonWidgetPlusieursPlie,
+ )
+
+ widget = MonWidgetPlusieursPlie(
+ self, maDefinition, monNom, monObjet, parentQt, maCommande
+ )
+
+ self.widget = widget
+ return widget
+
+
+class SIMPTreeItem(Objecttreeitem.AtomicObjectTreeItem):
+ itemNode = Node
+
+ def init(self):
+ self.expandable = 0
+
+ # -----------------------------------------------
+ #
+ # Methodes liees aux informations sur le Panel
+ # ou au mot-clef simple
+ #
+ # -----------------------------------------------
+ # isList
+ # hasInto
+ # getMinMax
+ # getMultiplicite
+ # getIntervalle
+ # getListeValeurs
+ # getListePossible
+
+ def isList(self):
+ """
+ Cette methode indique si le mot cle simple attend une liste (valeur de retour 1)
+ ou s'il n'en attend pas (valeur de retour 0)
+
+ Deux cas principaux peuvent se presenter : avec validateurs ou bien sans.
+ Dans le cas sans validateur, l'information est donnee par l'attribut max
+ de la definition du mot cle.
+ Dans le cas avec validateur, il faut combiner l'information precedente avec
+ celle issue de l'appel de la methode isList sur le validateur.On utilisera
+ l'operateur ET pour effectuer cette combinaison (AndVal).
+ """
+ is_a_list = 0
+ min, max = self.getMinMax()
+ assert min <= max
+ if max > 1:
+ is_a_list = 1
+ # Dans le cas avec validateurs, pour que le mot cle soit considere
+ # comme acceptant une liste, il faut que max soit superieur a 1
+ # ET que la methode isList du validateur retourne 1. Dans les autres cas
+ # on retournera 0 (n'attend pas de liste)
+ if self.definition.validators:
+ is_a_list = self.definition.validators.isList() * is_a_list
+ return is_a_list
+
+ def isListSansOrdreNiDoublon(self):
+ if self.definition.homo == "SansOrdreNiDoublon":
+ return 1
+ return 0
+
+ def hasInto(self):
+ """
+ Cette methode indique si le mot cle simple propose un choix (valeur de retour 1)
+ ou s'il n'en propose pas (valeur de retour 0)
+
+ Deux cas principaux peuvent se presenter : avec validateurs ou bien sans.
+ Dans le cas sans validateur, l'information est donnee par l'attribut into
+ de la definition du mot cle.
+ Dans le cas avec validateurs, pour que le mot cle soit considere
+ comme proposant un choix, il faut que into soit present OU
+ que la methode hasInto du validateur retourne 1. Dans les autres cas
+ on retournera 0 (ne propose pas de choix)
+ """
+ has_an_into = 0
+ if self.definition.into:
+ has_an_into = 1
+ elif self.definition.validators:
+ has_an_into = self.definition.validators.hasInto()
+ return has_an_into
+
+ def hasIntoSug(self):
+ if self.definition.intoSug:
+ return 1
+ return 0
+
+ def getMinMax(self):
+ """Retourne les valeurs min et max de la definition de object"""
+ return self.object.getMinMax()
+
+ def getMultiplicite(self):
+ """A preciser.
+ Retourne la multiplicite des valeurs affectees a l'objet
+ represente par l'item. Pour le moment retourne invariablement 1.
+ """
+ return 1
+
+ def getIntervalle(self):
+ """
+ Retourne le domaine de valeur attendu par l'objet represente
+ par l'item.
+ """
+ return self.object.getintervalle()
+
+ def getListeValeurs(self):
+ """Retourne la liste des valeurs de object"""
+ valeurs = self.object.getListeValeurs()
+ try:
+ if "R" in self.object.definition.type:
+ clef = self.object.getNomConcept()
+ if clef in self.appliEficas.dict_reels:
+ if type(valeurs) == tuple:
+ valeurs_reelles = []
+ for val in valeurs:
+ if val in self.appliEficas.dict_reels[clef]:
+ valeurs_reelles.append(
+ self.appliEficas.dict_reels[clef][val]
+ )
+ else:
+ valeurs_reelles.append(val)
+ else:
+ if valeurs in self.appliEficas.dict_reels[clef]:
+ valeurs_reelles = self.appliEficas.dict_reels[clef][valeurs]
+ valeurs = valeurs_reelles
+ except:
+ pass
+ return valeurs
+
+ def getListePossible(self, listeActuelle=[]):
+ if hasattr(self.definition.validators, "into"):
+ valeurspossibles = self.definition.validators.into
+ else:
+ valeurspossibles = self.get_definition().into
+
+ if listeActuelle == []:
+ return valeurspossibles
+
+ # On ne garde que les items valides
+ listevalideitem = []
+ if type(valeurspossibles) in (list, tuple):
+ pass
+ else:
+ valeurspossibles = (valeurspossibles,)
+ for item in valeurspossibles:
+ encorevalide = self.valideItem(item)
+ if encorevalide:
+ listevalideitem.append(item)
+
+ # on ne garde que les choix possibles qui passent le test de valideListePartielle
+ listevalideliste = []
+ for item in listevalideitem:
+ encorevalide = self.valideListePartielle(item, listeActuelle)
+ if encorevalide:
+ listevalideliste.append(item)
+ # print listevalideliste
+ return listevalideliste
+
+ def getListePossibleAvecSug(self, listeActuelle=[]):
+ if hasattr(self.definition, "intoSug"):
+ valeurspossibles = self.definition.intoSug
+ else:
+ return listeActuelle
+
+ if listeActuelle == []:
+ return valeurspossibles
+ valeurspossibles = valeurspossibles + listeActuelle
+
+ # On ne garde que les items valides
+ listevalideitem = []
+ if type(valeurspossibles) in (list, tuple):
+ pass
+ else:
+ valeurspossibles = (valeurspossibles,)
+ for item in valeurspossibles:
+ encorevalide = self.valideItem(item)
+ if encorevalide:
+ listevalideitem.append(item)
+
+ # on ne garde que les choix possibles qui passent le test de valideListePartielle
+ listevalideliste = []
+ for item in listevalideitem:
+ encorevalide = self.valideListePartielle(item, listeActuelle)
+ if encorevalide:
+ listevalideliste.append(item)
+ return listevalideliste
+
+ def getListeParamPossible(self):
+ liste_param = []
+ l1, l2 = self.jdc.getParametresFonctionsAvantEtape(self.getEtape())
+ for param in self.object.jdc.params:
+ if param.nom not in l1:
+ continue
+ encorevalide = self.valideItem(param.valeur)
+ if encorevalide:
+ type_param = param.valeur.__class__.__name__
+ for typ in self.definition.type:
+ if typ == "R":
+ liste_param.append(param)
+ if typ == "I" and type_param == "int":
+ liste_param.append(param)
+ if typ == "TXM" and type_param == "str":
+ liste_param.append(repr(param))
+ if ("grma" in repr(typ)) and type_param == "str":
+ liste_param.append(param.nom)
+ return liste_param
+
+ # --------------------------------------------------
+ #
+ # Methodes liees a la validite des valeurs saisies
+ #
+ # ---------------------------------------------------
+ # valideItem
+ # valideListePartielle
+ # valideListeComplete
+ # infoErreurItem
+ # infoErreurListe
+ # isInIntervalle
+ # isValid
+
+ def valideItem(self, item):
+ """
+ La validation est realisee directement par l'objet
+ """
+ return self.object.valideItem(item)
+
+ def valideListePartielle(self, item, listecourante):
+ # On protege la liste en entree en la copiant
+ valeur = list(listecourante)
+ if item:
+ valeur.append(item)
+ return self.object.validValeurPartielle(valeur)
+
+ def valideListeComplete(self, valeur):
+ return self.object.validValeur(valeur)
+
+ def infoErreurItem(self):
+ commentaire = ""
+ if self.definition.validators:
+ commentaire = self.definition.validators.infoErreurItem()
+ return commentaire
+
+ def aide(self):
+ commentaire = ""
+ if self.definition.validators:
+ commentaire = self.definition.validators.aide()
+ return commentaire
+
+ def infoErreurListe(self):
+ commentaire = ""
+ if self.definition.validators:
+ commentaire = self.definition.validators.infoErreurListe()
+ return commentaire
+
+ def isInIntervalle(self, valeur):
+ """
+ Retourne 1 si la valeur est dans l'intervalle permis par
+ l'objet represente par l'item.
+ """
+ return self.valideItem(valeur)
+
+ def isValid(self):
+ valide = self.object.isValid()
+ return valide
+
+ # --------------------------------------------------
+ #
+ # Autres ...
+ #
+ # ---------------------------------------------------
+ # getIconName
+ # getText
+ # setValeurCo
+ # getSdAvantDuBonType
+
+ def getIconName(self):
+ if self.appliEficas.maConfiguration.differencieSiDefaut and self.isValid():
+ if self.object.definition.defaut != None:
+ if self.object.valeur == self.object.definition.defaut:
+ return "ast-green-dark-ball"
+ if self.object.definition.max > 1 and list(self.object.valeur) == list(
+ self.object.definition.defaut
+ ):
+ return "ast-green-dark-ball"
+ return "ast-green-ball"
+ elif self.isValid():
+ return "ast-green-ball"
+ elif self.object.isOblig():
+ return "ast-red-ball"
+ else:
+ return "ast-yel-ball"
+
+ def getText(self):
+ """
+ Classe SIMPTreeItem
+ Retourne le texte a afficher dans l'arbre representant la valeur de l'objet
+ pointe par self
+ """
+ if (
+ self.waitUserAssdMultiple()
+ or self.object.waitUserAssd()
+ or self.object.waitAssd()
+ ):
+ return self.object.valeur
+ # if self.object.valeur != None : return self.object.valeur.nom
+ # else : return ""
+ text = self.object.getText()
+ if text == None:
+ text = ""
+ return text
+
+ def setValeurCo(self, nomCo):
+ """
+ Affecte au MCS pointe par self l'objet de type CO et de nom nom_co
+ """
+ ret = self.object.setValeurCo(nomCo)
+ # print "setValeurCo",ret
+ return ret
+
+ def getSdAvantDuBonType(self):
+ """
+ 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
+ """
+ # A changer pour tenir compte des UserASSDMultiple
+ # ici on passe par parent pour avoir le bon type
+ # if self.waitUserAssdMultiple() :
+ # l=self.object.parent.getSdCreeParObjetAvecFiltre(self.object)
+ # return l
+ if self.waitUserAssdMultiple():
+ l = self.object.getUserAssdPossible()
+ return l
+ a = self.object.etape.parent.getSdAvantDuBonType(
+ self.object.etape, self.object.definition.type
+ )
+ 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"
+ )
+ return a
+
+ def deleteValeurCo(self, valeur=None):
+ """
+ Supprime la valeur du mot cle (de type CO)
+ il faut propager la destruction aux autres etapes
+ """
+ if not valeur:
+ valeur = self.object.valeur
+ # XXX faut il vraiment appeler delSdprod ???
+ # self.object.etape.parent.delSdprod(valeur)
+ self.object.etape.parent.deleteConcept(valeur)
+
+ # -----------------------------------------------
+ #
+ # Methodes liees au type de l objet attendu
+ #
+ # -----------------------------------------------
+ # waitCo
+ # waitGeom
+ # waitComplex
+ # waitReel
+ # waitAssd
+ # getType
+
+ def waitCo(self):
+ """
+ Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un objet de type ASSD qui n'existe pas encore (type CO()),
+ 0 sinon
+ """
+ return self.object.waitCo()
+
+ def waitFichier(self):
+ maDefinition = self.object.definition
+ try:
+ if ("Repertoire" in maDefinition.type[0]) or (
+ "Fichier" in maDefinition.type[0]
+ ):
+ return 1
+ except:
+ return 0
+
+ def waitGeom(self):
+ """
+ Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un objet GEOM, 0 sinon
+ """
+ return self.object.waitGeom()
+
+ def waitTxm(self):
+ return self.object.waitTxm()
+
+ def waitComplex(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un complexe, 0 sinon"""
+ if "C" in self.object.definition.type:
+ return 1
+ else:
+ return 0
+
+ def waitReel(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un reel, 0 sinon"""
+ if "R" in self.object.definition.type:
+ return 1
+ else:
+ return 0
+
+ def waitTuple(self):
+ return self.object.waitTuple()
+
+ def waitDate(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un reel, 0 sinon"""
+ if "DateHHMMAAAA" in self.object.definition.type:
+ return 1
+ else:
+ return 0
+
+ def waitHeure(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un reel, 0 sinon"""
+ if "HeureHHMMSS" in self.object.definition.type:
+ return 1
+ else:
+ return 0
+
+ def waitTuple(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un Tuple, 0 sinon"""
+ for ss_type in self.object.definition.type:
+ if repr(ss_type).find("Tuple") != -1:
+ return 1
+ return 0
+
+ def waitMatrice(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un Tuple, 0 sinon"""
+ # il faut trouver autre chose que ce find!!!
+ for ss_type in self.object.definition.type:
+ # if repr(ss_type).find('Matrice') != -1 :
+ if hasattr(ss_type, "typElt"):
+ return 1
+ return 0
+
+ def waitAssd(self):
+ """Methode booleenne qui retourne 1 si l'objet pointe par self
+ attend un objet de type ASSD ou derive, 0 sinon"""
+ return self.object.waitAssd()
+
+ def waitAssdOrTypeBase(self):
+ boo = 0
+ if len(self.object.definition.type) > 1:
+ if self.waitReel():
+ boo = 1
+ if "I" in self.object.definition.type:
+ boo = 1
+ return boo
+
+ def waitSalome(self):
+ monType = self.object.definition.type[0]
+ if "grma" in repr(monType):
+ return True
+ if "grno" in repr(monType):
+ return True
+ try:
+ if issubclass(monType, SalomeEntry):
+ return True
+ except:
+ pass
+ return False
+
+ def getType(self):
+ """
+ Retourne le type de valeur attendu par l'objet represente par l'item.
+ """
+ return self.object.getType()
+
+ # -----------------------------------------------------
+ #
+ # Methodes liees a l evaluation de la valeur saisie
+ #
+ # -----------------------------------------------------
+ # evalValeur
+ # evalValeurItem
+ # isCO
+ # traiteReel
+
+ def evalValeur(self, valeur):
+ """Lance l'interpretation de 'valeur' (chaine de caracteres) comme valeur de self :
+ - retourne l'objet associe si on a pu interpreter (entier, reel, ASSD,...)
+ - retourne 'valeur' (chaine de caracteres) sinon
+ """
+ newvaleur = self.evalVal(valeur)
+ return newvaleur, 1
+
+ def evalValeurItem(self, valeur):
+ """Lance l'interpretation de 'valeur' qui doit ne pas etre un tuple
+ - va retourner la valeur de retour et la validite
+ selon le type de l objet attendu
+ - traite les reels et les parametres
+ """
+ # print "evalValeurItem",valeur
+ if valeur == None or valeur == "":
+ return None, 0
+ validite = 1
+ if self.waitReel():
+ valeurinter = self.traiteReel(valeur)
+ if valeurinter != None:
+ valeurretour, validite = self.object.evalValeur(valeurinter)
+ else:
+ valeurretour, validite = self.object.evalValeur(valeur)
+ elif self.waitGeom():
+ valeurretour, validite = valeur, 1
+ else:
+ valeurretour, validite = self.object.evalValeur(valeur)
+
+ if validite == 0:
+ if (type(valeur) == bytes or type(valeur) == str) and self.object.waitTxm():
+ essai_valeur = "'" + valeur + "'"
+ valeurretour, validite = self.object.evalValeur(essai_valeur)
+
+ if hasattr(valeurretour, "__class__"):
+ # if valeurretour.__class__.__name__ in ('PARAMETRE','PARAMETRE_EVAL'):
+ if valeurretour.__class__.__name__ in ("PARAMETRE",):
+ validite = 1
+
+ # if self.waitCo():
+ # CCAR : il ne faut pas essayer de creer un concept
+ # il faut simplement en chercher un existant ce qui a du etre fait par self.object.evalValeur(valeur)
+ # try:
+ # valeurretour=Accas.CO(valeur)
+ # except:
+ # valeurretour=None
+ # validite=0
+ # on est dans le cas ou on a evalue et ou on n'aurait pas du
+ if self.object.waitTxm():
+ if type(valeurretour) != bytes:
+ valeurretour = str(valeur)
+ validite = 1
+ return valeurretour, validite
+
+ def isCO(self, valeur=None):
+ """
+ Indique si valeur est un concept produit de la macro
+ Cette methode n'a de sens que pour un MCSIMP d'une MACRO
+ Si valeur vaut None on teste la valeur du mot cle
+ """
+ # Pour savoir si un concept est un nouveau concept de macro
+ # on regarde s'il est present dans l'attribut sdprods de l'etape
+ # ou si son nom de classe est CO.
+ # Il faut faire les 2 tests car une macro non valide peut etre
+ # dans un etat pas tres catholique avec des CO pas encore types
+ # et donc pas dans sdprods (resultat d'une exception dans typeSDProd)
+ if not valeur:
+ valeur = self.object.valeur
+ if valeur in self.object.etape.sdprods:
+ return 1
+ # if type(valeur) is not types.InstanceType:return 0
+ if type(valeur) is not object:
+ return 0
+ if valeur.__class__.__name__ == "CO":
+ return 1
+ return 0
+
+ def isParam(self, valeur):
+ for param in self.jdc.params:
+ if repr(param) == valeur:
+ return 1
+ return 0
+
+ def traiteReel(self, valeur):
+ """
+ Cette fonction a pour but de rajouter le '.' en fin de chaine pour un reel
+ ou de detecter si on fait reference a un concept produit par DEFI_VALEUR
+ ou un EVAL ...
+ """
+ valeur = valeur.strip()
+ liste_reels = self.getSdAvantDuBonType()
+ if valeur in liste_reels:
+ return valeur
+ if len(valeur) >= 3:
+ if valeur[0:4] == "EVAL":
+ # on a trouve un EVAL --> on retourne directement la valeur
+ return valeur
+ if valeur.find(".") == -1:
+ # aucun '.' n'a ete trouve dans valeur --> on en rajoute un a la fin
+ if self.isParam(valeur):
+ return valeur
+ else:
+ if valeur.find("e") != -1:
+ # Notation scientifique ?
+ try:
+ r = eval(valeur)
+ return valeur
+ except:
+ return None
+ else:
+ return valeur + "."
+ else:
+ return valeur
+
+
+import Accas
+
+treeitem = SIMPTreeItem
+objet = Accas.MCSIMP
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 pour charger les parametres de configuration d'EFICAS
+"""
+import os, sys, types, re
+import traceback
+from Extensions.i18n import tr
+
+
+class configBase(object):
+ # -------------------------------
+ def __init__(self, appliEficas, repIni):
+ # -------------------------------
+
+ # Classe de base permettant de lire, afficher
+ # et sauvegarder les fichiers utilisateurs
+ # On a deux directories : la directory generale (Repertoire d install + Nom du code
+ # Par exemple : ~/Install_Eficas/EficasV1_14/Openturns_Wrapper
+ # et la directorie de l utilisateur
+ # HOME/.Eficas_Openturns
+ # Le fichier prefs.py va etre lu dans la directory generale
+ # puis surcharge eventuellement par celui contenu dans ${PREFS_CATA_$CODE}
+ # par celui de l utilisateur
+ # le fichier de catalogue va etre lu dans la directory de l utilisateur s il exite
+ # dans le fichier general sinon
+
+ self.appliEficas = appliEficas
+ self.code = appliEficas.code
+ self.salome = appliEficas.salome
+ if self.salome:
+ self.name = "editeur_salome.ini"
+ else:
+ self.name = "editeur.ini"
+ self.rep_mat = None
+ self.repIni = repIni
+
+ if self.code == None:
+ self.code = ""
+ self.rep_user = os.path.join(
+ os.path.expanduser("~"), ".config/Eficas", self.code
+ )
+ # else :
+ # self.rep_user = os.path.join('C:/','.config/Eficas',self.code)
+
+ self.setValeursParDefaut()
+
+ if self.code != "":
+ self.lectureFichierIniStandard()
+ self.lectureFichierIniIntegrateur()
+ self.lectureFichierIniUtilisateur()
+
+ if self.boutonDsMenuBar:
+ self.closeAutreCommande = True
+ self.closeFrameRechercheCommande = True
+
+ # Particularite des schemas MAP
+ if hasattr(self, "make_ssCode"):
+ self.make_ssCode(self.ssCode)
+
+ if not os.path.isdir(self.savedir):
+ self.savedir = os.path.join(
+ os.path.expanduser("~"), ".config/Eficas", self.code
+ )
+
+ def setValeursParDefaut(self):
+ # -----------------------------
+
+ # Valeurs par defaut
+ if not os.path.isdir(self.rep_user):
+ os.makedirs(self.rep_user)
+ self.path_doc = os.path.abspath(os.path.join(self.repIni, "..", "Doc"))
+ self.exec_acrobat = "acroread"
+ nomDir = "Eficas_" + self.code
+ self.savedir = os.path.abspath(os.path.join(os.path.expanduser("~"), nomDir))
+ # if sys.platform[0:5]=="linux" :
+ # self.savedir = os.path.abspath(os.path.join(os.environ['HOME'],nomDir))
+ # else:
+ # self.savedir = os.path.abspath('C:/')
+ self.modeNouvCommande = "initial"
+ self.affiche = "alpha"
+ self.closeAutreCommande = False
+ self.closeFrameRechercheCommande = False
+ self.closeFrameRechercheCommandeSurPageDesCommandes = False
+ self.closeEntete = False
+ self.closeArbre = False
+ self.demandeLangue = False
+ self.suiteTelemac = False
+ self.nombreDeBoutonParLigne = 0
+ self.translatorFichier = None
+ self.dicoImages = {}
+ self.dicoIcones = {}
+ self.afficheCommandesPliees = True
+ self.afficheFirstPlies = False
+ self.simpleClic = False
+ self.afficheOptionnelVide = False
+ self.afficheListesPliees = True
+ self.boutonDsMenuBar = False
+ self.ficIcones = None
+ self.repIcones = None
+ self.differencieSiDefaut = False
+ self.typeDeCata = "Python"
+ self.closeParenthese = False
+ self.closeOptionnel = False
+ self.afficheFactOptionnel = False
+ self.enleverActionStructures = False
+ self.enleverPoubellePourCommande = False
+ self.enleverParametres = False
+ self.enleverSupprimer = False
+ self.ajoutExecution = False
+ self.utilParExtensions = []
+ self.rendVisiblesLesCaches = False
+ self.pasDeMCOptionnels = False
+
+ self.dumpXSD = False
+ self.withXSD = False
+ self.afficheIhm = True
+
+ # self.afficheUQ=False
+ self.afficheUQ = True
+
+ # --------------------------------------
+ def lectureFichierIniStandard(self):
+ # --------------------------------------
+
+ name = "prefs_" + self.appliEficas.code
+ try:
+ prefsCode = __import__(name)
+ except:
+ self.catalogues = []
+ print("pas de fichier de prefs")
+ return
+ for k in dir(prefsCode):
+ if k[0:1] != "__" and k[-1:-2] != "__":
+ valeur = getattr(prefsCode, k)
+ setattr(self, k, valeur)
+
+ # --------------------------------------
+ def lectureFichierIniIntegrateur(self):
+ # --------------------------------------
+ # Verifie l'existence du fichier "standard"
+ # appelle la lecture de ce fichier
+ clef = "PREFS_CATA_" + self.code
+ try:
+ repIntegrateur = os.path.abspath(os.environ[clef])
+ except:
+ return
+
+ fic_ini_integrateur = os.path.join(repIntegrateur, self.name)
+ if not os.path.isfile(fic_ini_integrateur):
+ return
+ with open(fic_ini_integrateur) as fd:
+ txt = fd.read()
+ d = locals()
+ try:
+ exec(txt, d)
+ except:
+ try:
+ from PyQt5.QtWidgets import QMessageBox
+
+ QMessageBox.critical(
+ None,
+ tr("Import du fichier de Configuration"),
+ tr(
+ "Erreur a la lecture du fichier de configuration %s ",
+ str(fic_ini_integrateur),
+ ),
+ )
+ except:
+ print(
+ "Erreur a la lecture du fichier de configuration %s ",
+ str(fic_ini_integrateur),
+ )
+ return
+ self.labels_eficas.append("rep_aide")
+ for k in self.labels_eficas:
+ try:
+ setattr(self, k, d[k])
+ except:
+ pass
+ # Glut pour les repertoires materiaux
+ # et pour la doc
+ for k in d:
+ if (k[0:8] == "rep_mat_") or (k[0:8] == "rep_doc_"):
+ setattr(self, k, d[k])
+
+ # --------------------------------------
+ def lectureFichierIniUtilisateur(self):
+ # --------------------------------------
+ # Surcharge les parametres standards par les parametres utilisateur s'ils existent
+ self.fic_ini_utilisateur = os.path.join(self.rep_user, self.name)
+ if not os.path.isfile(self.fic_ini_utilisateur):
+ return
+ with open(fic_ini_utilisateur) as fd:
+ txt = fd.read()
+ d = locals()
+ try:
+ exec(txt, d)
+ except:
+ l = traceback.format_exception(
+ sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
+ )
+ try:
+ from PyQt5.QtWidgets import QMessageBox
+
+ QMessageBox.critical(
+ None,
+ tr("Import du fichier de Configuration"),
+ tr(
+ "Erreur a la lecture du fichier de configuration %s ",
+ str(fic_ini_integrateur),
+ ),
+ )
+ except:
+ print(
+ "Erreur a la lecture du fichier de configuration %s ",
+ str(fic_ini_integrateur),
+ )
+ for k in self.labels_user:
+ try:
+ setattr(self, k, d[k])
+ except:
+ pass
+ for k in d:
+ if (k[0:8] == "rep_mat_") or (k[0:8] == "rep_doc_"):
+ setattr(self, k, d[k])
+
+ # --------------------------------------
+ def saveParams(self):
+ # --------------------------------------
+ # sauvegarde
+ # les nouveaux parametres dans le fichier de configuration utilisateur
+ #
+ texte = ""
+ for clef in self.labels_user:
+ if hasattr(self, clef):
+ valeur = getattr(self, clef)
+ texte = texte + clef + " = " + repr(valeur) + "\n"
+ # Glut pour les repertoires materiaux
+ # et pour la doc
+ for k in dir(self):
+ if (k[0:8] == "rep_mat_") or (k[0:8] == "rep_doc_"):
+ valeur = getattr(self, k)
+ texte = texte + k + " = " + repr(valeur) + "\n"
+
+ f = open(self.fic_ini_utilisateur, "w+")
+ f.write(texte)
+ f.close()
+
+
+#
+
+
+def makeConfig(appliEficas, rep):
+ return configBase(appliEficas, rep)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+
+import types, sys, os, re
+import subprocess
+
+from PyQt5.QtWidgets import QWidget, QMessageBox, QFileDialog, QApplication, QSplitter, QLabel
+from PyQt5.QtGui import QPalette, QFont
+from PyQt5.QtCore import QProcess, QFileInfo, QTimer, Qt, QDir, QSize, QProcessEnvironment
+
+import traceback
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from Editeur import session
+from Editeur import comploader
+from Editeur import Objecttreeitem
+from InterfaceGUI.QT5 import browser
+
+from desBaseWidget import Ui_baseWidget
+from InterfaceGUI.QT5.monViewTexte import ViewText
+from monWidgetCreeParam import MonWidgetCreeParam
+
+DictExtensions = {"MAP": ".map", "TELEMAC": ".cas"}
+debug = False
+
+
+from InterfaceGUI.editorSsIhm import JDCEditorSsIhm
+
+
+class JDCEditor(JDCEditorSsIhm, Ui_baseWidget, QWidget):
+# -------------------------------------------------- #
+ """
+ Editeur de jdc
+ """
+
+ # ----------------------------------------
+ # Methodes faisant appel a ssIhm
+ # ----------------------------------------
+
+ def __init__( self, appliEficas, fichier=None, jdc=None, QWParent=None, units=None, include=0):
+ # ------------------------------------------------------------------------------------------------
+
+ QWidget.__init__(self, None)
+ self.setupUi(self)
+
+ self.inhibeSplitter = 0
+ self.widgetOptionnel = None
+ self.fenetreCentraleAffichee = None
+ self.dejaDansPlieTout = False
+ self.listeDesListesOuvertes = set()
+ if appliEficas != None and hasattr(appliEficas, "statusBar"):
+ self.sb = appliEficas.statusBar()
+ else:
+ self.sb = None
+ self.QWParent = QWParent
+
+ JDCEditorSsIhm.__init__(self, appliEficas, fichier, jdc, units, include)
+ if self.jdc:
+ comploader.chargerComposants(self.appliEficas.GUIPath)
+ self.jdc_item = Objecttreeitem.makeObjecttreeitem(self, "nom", self.jdc)
+
+ # Particularites IHM : met la fenetre a jour
+ self.initSplitterSizes()
+
+ self.afficheListesPliees = self.maConfiguration.afficheListesPliees
+ if self.code in ["MAP", "CARMELCND", "PSEN"]:
+ self.maConfiguration.afficheCommandesPliees = False
+
+ if self.maConfiguration.closeArbre:
+ self.fermeArbre()
+ if self.maConfiguration.closeOptionnel:
+ self.fermeOptionnel()
+ if self.maConfiguration.boutonDsMenuBar:
+ self.appliEficas.remplitIconesCommandes()
+
+ self.formatFichierOut = self.appliEficas.formatFichierOut
+ self.formatFichierIn = self.appliEficas.formatFichierIn
+
+ self.node_selected = []
+ self.deplier = True
+ self.message = ""
+ self.afficheApresInsert = False
+ if self.maConfiguration.closeArbre:
+ self.afficheApresInsert = True
+ if self.code in ["Adao", "ADAO", "MAP"]:
+ self.afficheApresInsert = True
+ if self.code in [ "TELEMAC", ]:
+ self.enteteQTree = "premier"
+ else:
+ self.enteteQTree = "complet"
+ if self.code in ["Adao", "ADAO", "TELEMAC", "VP"]:
+ self.affichePlie = True
+ else:
+ self.affichePlie = False
+
+ #self.commandesOrdreCatalogue = self.readercata.commandesOrdreCatalogue
+
+ if self.appliEficas.readercata.demandeCatalogue == True:
+ nomFichierTranslation = (
+ "translatorFichier" + "_" + str(self.appliEficas.readercata.labelCode)
+ )
+ if hasattr(self.appliEficas.maConfiguration, nomFichierTranslation):
+ translatorFichier = getattr(
+ self.appliEficas.maConfiguration, nomFichierTranslation
+ )
+ from Extensions import localisation
+
+ localisation.localise(
+ None, self.appliEficas.langue, translatorFichier=translatorFichier
+ )
+
+ if self.jdc_item and self.appliEficas.ssIhm == False:
+ self.tree = browser.JDCTree(self.jdc_item, self)
+ self.appliEficas.construitMenu()
+
+ self.adjustSize()
+
+ # -------------------------------#
+ def readFile(self, fn):
+ # --------------------------------#
+ """
+ Public slot to read the text from a file.
+ @param fn filename to read from (string or QString)
+ """
+
+ jdc = JDCEditorSsIhm.readFile(self, fn)
+
+ # Particularites IHM : met le titre de la fenetre a jour
+ # qApp.restoreOverrideCursor()
+ if self.fileInfo != None:
+ self.lastModified = self.fileInfo.lastModified()
+ nouveauTitre = self.titre + " " + os.path.basename(self.fichier)
+ self.appliEficas.setWindowTitle(nouveauTitre)
+
+ return jdc
+
+ # ---------------------------------------------
+ # Methodes Inchangees
+ # ---------------------------------------------
+ # _newJDC
+ # _newJDCInclude
+ # __generateTempFilename
+ # getSource
+ # generDico
+ # viewJdcSource
+ # viewJdcPy
+ # viewJdcRapport
+ # getFileName
+ # initModif
+ # writeFile
+ # getTextJDC
+ # verifieChecksum
+ # getChecksum
+ # getDico
+ # chercheGroupes
+ # chercheDico
+ # saveFileLegerAs
+
+ # ---------------------------------------------
+ # Methodes Surchargees
+ # ---------------------------------------------
+
+ # -----------------------------------------------------------------------#
+ def _viewText(self, txt, caption="FILE_VIEWER", largeur=1200, hauteur=600):
+ # --------------------------------------------------------------------#
+ w = ViewText(self.QWParent, self, caption, txt, largeur, hauteur)
+ w.show()
+
+ # --------------------------------#
+ def informe(self, titre, txt, critique=True):
+ # --------------------------------#
+ if critique:
+ self.afficheInfos(tr(txt), Qt.red)
+ QMessageBox.critical(self, tr(titre), tr(txt))
+ else:
+ QMessageBox.warning(self, tr(titre), tr(txt))
+
+ # --------------------------------#
+ def ajoutCommentaire(self):
+ # --------------------------------#
+ if self.tree.selectedItems() == []:
+ QMessageBox.warning(
+ self,
+ tr("Pas de noeud selectionne"),
+ tr(
+ "Selectionnez un Noeud \nLe commentaire sera place apres le noeud selectionne"
+ ),
+ )
+ return
+ noeudAvantCommentaire = self.tree.selectedItems()[0]
+ if noeudAvantCommentaire == self.tree.racine:
+ self.tree.racine.appendChild("COMMENTAIRE", pos=0)
+ return
+ noeudAvantCommentaire.addComment(True)
+
+ # -----------------------------------------------------------------------------------------------#
+ def _viewTextExecute(
+ self, txt, prefix, suffix, fichierExe=None, shell="sh", texteCommande=None
+ ):
+ # ----------------------------------------------------------------------------------------------#
+ self.myWidget = ViewText(self.QWParent)
+ self.myWidget.setWindowTitle("execution")
+ self.myWidget.view.setFont(QFont("Monospace"))
+ self.monExe = QProcess(self.myWidget)
+ pid = self.monExe.pid()
+ if not fichierExe and txt:
+ fichierExe = self.generateTempFilename(prefix, suffix=".sh")
+ f = open(fichierExe, "self.myWidget")
+ f.write(txt)
+ f.close()
+ self.monExe.readyReadStandardOutput.connect(self.readFromStdOut)
+ self.monExe.readyReadStandardError.connect(self.readFromStdErr)
+ if texteCommande != None:
+ exe = texteCommande
+ else:
+ exe = shell + " " + fichierExe
+ monEnv = QProcessEnvironment.systemEnvironment()
+ monEnv.insert("COLUMNS", "500")
+ self.monExe.setProcessEnvironment(monEnv)
+ self.monExe.start(exe)
+ self.monExe.closeWriteChannel()
+ self.myWidget.exec_()
+ if self.monExe != None:
+ self.monExe.readyReadStandardOutput.disconnect()
+ self.monExe.readyReadStandardError.disconnect()
+ if txt:
+ commande = "rm " + fichierExe
+ os.system(commande)
+ return 1
+
+ def readFromStdErr(self):
+ a = self.monExe.readAllStandardError()
+ chaine = str(a.data(), encoding="utf-8")
+ self.myWidget.view.append(chaine)
+ # self.myWidget.view.append(str(a.data()))
+
+ def readFromStdOut(self):
+ a = self.monExe.readAllStandardOutput()
+ chaine = str(a.data(), encoding="utf-8")
+ self.myWidget.view.append(chaine)
+
+ # self.wmyWidget.view.append(str(a.data()))
+
+ # -----------------------#
+ def gestionParam(self):
+ # -----------------------#
+ w = MonWidgetCreeParam(self)
+ w.show()
+
+ # ----------------#
+ def closeIt(self):
+ # ----------------#
+ """
+ Public method called by the viewmanager to finally get rid of us.
+ """
+ if self.jdc:
+ self.jdc.supprime()
+ self.close()
+
+ # ----------------------------------------------#
+ def afficheInfos(self, message, couleur=Qt.black):
+ # ----------------------------------------------#
+ if couleur == "red":
+ couleur = Qt.red
+ if self.sb:
+ mapalette = self.sb.palette()
+ mapalette.setColor(QPalette.WindowText, couleur)
+ self.sb.setPalette(mapalette)
+ self.sb.showMessage(message, 4000)
+ self.couleur = couleur
+
+ # ------------------------------#
+ def afficheAlerte(self, titre, message):
+ # ------------------------------#
+ # appele par I_MACRO_ETAPE
+ QMessageBox.information(self, titre, message)
+
+ # -----------------------------------#
+ def afficheCommentaire(self, message):
+ # -----------------------------------#
+ self.labelCommentaire.setText(message)
+ QTimer.singleShot(6000, self.rendInvisible)
+
+ # ----------------------#
+ def rendInvisible(self):
+ # ----------------------#
+ self.labelCommentaire.setText("")
+
+ # ---------------------------------------#
+ def chercheNoeudSelectionne(self, copie=1):
+ # ---------------------------------------#
+ """
+ appele par Cut et Copy pour positionner self.node_selected
+ """
+ self.node_selected = []
+ if len(self.tree.selectedItems()) == 0:
+ return
+ self.node_selected = self.tree.selectedItems()
+
+ # ---------------------#
+ def handleSupprimer(self):
+ # ---------------------#
+ self.chercheNoeudSelectionne()
+ if len(self.node_selected) == 0:
+ return
+ self.QWParent.noeud_a_editer = []
+ if self.node_selected[0] == self.tree.racine:
+ return
+ if len(self.node_selected) == 1:
+ self.node_selected[0].delete()
+ else:
+ self.node_selected[0].deleteMultiple(self.node_selected)
+
+ # ---------------------#
+ def handleRechercher(self):
+ # ---------------------#
+ from .monRecherche import DRecherche
+
+ monRechercheDialg = DRecherche(parent=self, fl=0)
+ monRechercheDialg.show()
+
+ # --------------------------------#
+ def handleRechercherDsCatalogue(self):
+ # -----------------------------#
+ from .monRechercheCatalogue import DRechercheCatalogue
+
+ monRechercheDialg = DRechercheCatalogue(self.QWParent, self)
+ monRechercheDialg.show()
+
+ # ---------------------#
+ def handleDeplier(self):
+ # ---------------------#
+ if self.tree == None:
+ return
+ # self.tree.collapseAll()
+ if self.deplier:
+ # print "je plie"
+ self.tree.expandItem(self.tree.topLevelItem(0))
+ self.deplier = False
+ if self.fenetreCentraleAffichee != None:
+ if hasattr(self.fenetreCentraleAffichee.node, "plieToutEtReaffiche"):
+ self.fenetreCentraleAffichee.node.plieToutEtReaffiche()
+ else:
+ # print "je deplie"
+ self.tree.expandItem(self.tree.topLevelItem(0))
+ self.deplier = True
+ if self.fenetreCentraleAffichee != None:
+ if hasattr(self.fenetreCentraleAffichee.node, "deplieToutEtReaffiche"):
+ self.fenetreCentraleAffichee.node.deplieToutEtReaffiche()
+
+ # ---------------------#
+ def handleEditCut(self):
+ # ---------------------#
+ """
+ Stocke dans Eficas.noeud_a_editer le noeud a couper
+ """
+ # print "handleEditCut"
+ self.chercheNoeudSelectionne()
+ self.QWParent.edit = "couper"
+ self.QWParent.noeud_a_editer = self.node_selected
+
+ # -----------------------#
+ def handleEditCopy(self):
+ # -----------------------#
+ """
+ Stocke dans Eficas.noeud_a_editer le noeud a copier
+ """
+ self.chercheNoeudSelectionne()
+ if len(self.node_selected) == 0:
+ return
+ if len(self.node_selected) == 1:
+ self.node_selected[0].updateNodeLabelInBlue()
+ else:
+ self.node_selected[0].updatePlusieursNodeLabelInBlue(self.node_selected)
+ self.QWParent.edit = "copier"
+ self.QWParent.noeud_a_editer = self.node_selected
+
+ # ------------------------#
+ def handleEditPaste(self):
+ # ------------------------#
+ """
+ Lance la copie de l'objet place dans self.QWParent.noeud_a_editer
+ Ne permet que la copie d'objets de type Commande ou MCF
+ """
+ self.chercheNoeudSelectionne()
+ if (not (hasattr(self.QWParent, "noeud_a_editer"))) or len(
+ self.QWParent.noeud_a_editer
+ ) == 0:
+ QMessageBox.information(
+ self,
+ tr("Copie impossible"),
+ tr("Veuillez selectionner un objet a copier"),
+ )
+ return
+ if len(self.node_selected) != 1:
+ QMessageBox.information(
+ self,
+ tr("Copie impossible"),
+ tr(
+ "Veuillez selectionner un seul objet : la copie se fera apres le noeud selectionne"
+ ),
+ )
+ return
+ noeudOuColler = self.node_selected[0]
+
+ if len(self.QWParent.noeud_a_editer) != 1:
+ # self.handleEditPasteMultiple()
+ QMessageBox.information(
+ self, tr("Copie impossible"), tr("Aucun Objet n a ete copie ou coupe")
+ )
+ return
+
+ noeudACopier = self.QWParent.noeud_a_editer[0]
+
+ if self.QWParent.edit != "couper":
+ # print (noeudOuColler.item.parent.getChild(noeudOuColler.item.nom))
+ try:
+ if noeudOuColler == self.tree.racine:
+ child = noeudOuColler.doPastePremier(noeudACopier)
+ else:
+ child = noeudACopier.doPaste(noeudOuColler, "after")
+
+ if child == None or child == 0:
+ QMessageBox.critical(
+ self,
+ tr("Copie refusee"),
+ tr("Eficas n a pas reussi a copier l objet"),
+ )
+ self.message = ""
+ self.afficheInfos("Copie refusee", Qt.red)
+ if noeudACopier.treeParent.editor != noeudOuColler.treeParent.editor:
+ try:
+ nom = noeudACopier.item.sd.nom
+ child.item.nommeSd(nom)
+ except:
+ pass
+ return
+ self.initModif()
+ child.select()
+ except:
+ traceback.print_exc()
+ QMessageBox.critical(
+ self, tr("Copie refusee"), tr("Copie refusee pour ce type d objet")
+ )
+ self.message = ""
+ self.afficheInfos("Copie refusee", Qt.red)
+ return
+
+ # il faut declarer le JDCDisplay_courant modifie
+ # suppression eventuelle du noeud selectionne
+ # si possible on renomme l objet comme le noeud couper
+
+ if self.QWParent.edit == "couper":
+ if noeudACopier.treeParent.editor != noeudOuColler.treeParent.editor:
+ QMessageBox.critical(
+ self,
+ tr("Deplacement refuse"),
+ tr(
+ "Deplacement refuse entre 2 fichiers. Seule la copie est autorisee "
+ ),
+ )
+
+ # if 1:
+ try:
+ # indexNoeudACopier=noeudACopier.treeParent.children.index(noeudACopier)
+ indexNoeudACopier = self.getTreeIndex(noeudACopier)
+ noeudACopier.treeParent.item.deplaceEntite(
+ indexNoeudACopier, indexNoeudOuColler, pos
+ )
+ noeudACopier.treeParent.buildChildren()
+
+ # else:
+ except:
+ pass
+ self.QWParent.noeud_a_editer = []
+
+ # on rend la copie a nouveau possible en liberant le flag edit
+ self.QWParent.edit = "copier"
+ noeudACopier.select()
+
+ # ----------------------------------#
+ def handleDeplaceMultiple(self):
+ # ----------------------------------#
+ pass
+
+ # ----------------------------------#
+ def handleEditPasteMultiple(self):
+ # ----------------------------------#
+
+ # On ne garde que les niveaux "Etape"
+ # On insere dans l'ordre du JDC
+ listeNoeudsACouper = []
+ listeIndex = []
+ listeChild = []
+ listeItem = []
+ from InterfaceGUI.QT5 import compojdc
+
+ noeudOuColler = self.node_selected[0]
+ if not (isinstance(noeudOuColler.treeParent, compojdc.Node)):
+ QMessageBox.information(
+ self,
+ tr(
+ "Copie impossible a cet endroit",
+ ),
+ tr(
+ "Veuillez selectionner une commande, un parametre, un commentaire ou une macro"
+ ),
+ )
+ return
+ indexNoeudOuColler = noeudOuColler.treeParent.children.index(noeudOuColler)
+
+ for noeud in self.QWParent.noeud_a_editer:
+ if not (isinstance(noeud.treeParent, compojdc.Node)):
+ continue
+ indexInTree = noeud.treeParent.children.index(noeud)
+ indice = 0
+ for index in listeIndex:
+ if index < indexInTree:
+ indice = indice + 1
+ listeIndex.insert(indice, indexInTree)
+ listeNoeudsACouper.insert(indice, noeud)
+
+ noeudJdc = noeudOuColler.treeParent
+ dejaCrees = 0
+ # on les cree a l'envers parcequ'on ajoute a NoeudOuColler
+ listeIndex.reverse()
+ for index in listeIndex:
+ indexTravail = index
+ if indexNoeudOuColler < index:
+ indexTravail = indexTravail + dejaCrees
+ noeudOuColler = noeudJdc.children[indexNoeudOuColler]
+ noeud = noeudJdc.children[indexTravail]
+ child = noeud.doPaste(noeudOuColler)
+ listeChild.append(child)
+ dejaCrees = dejaCrees + 1
+
+ self.QWParent.noeud_a_editer = []
+ for i in range(len(listeIndex)):
+ noeud = noeudJdc.children[indexNoeudOuColler + 1 + i]
+ self.QWParent.noeud_a_editer.append(noeud)
+
+ listeASupprimer = []
+ if self.QWParent.edit != "couper":
+ return
+
+ for index in listeIndex:
+ indexTravail = index
+ if indexNoeudOuColler < index:
+ indexTravail = indexTravail + (len(listeIndex))
+ noeud = noeudJdc.children[indexTravail]
+
+ listeItem.append(noeud.item)
+ listeASupprimer.append(noeud)
+
+ for i in range(len(listeChild)):
+ self.tree.item.suppItem(listeItem[i])
+ listeChild[i].item.update(listeItem[i])
+
+ self.QWParent.noeud_a_editer = []
+
+ # ----------------------------------#
+ def handleAjoutEtape(self, nomEtape):
+ # ----------------------------------#
+ self.chercheNoeudSelectionne()
+ if len(self.node_selected) == 0 or self.node_selected[0] == self.tree.racine:
+ nodeOuAjouter = self.tree.racine
+ nouveau = nodeOuAjouter.appendChild(nomEtape, pos="first")
+ else:
+ nodeOuAjouter = self.node_selected[0]
+ if nodeOuAjouter != self.tree.racine:
+ while nodeOuAjouter.treeParent != self.tree.racine:
+ nodeOuAjouter = nodeOuAjouter.treeParent
+ nouveau = nodeOuAjouter.appendBrother(nomEtape)
+ try:
+ self.node_selected[0].setSelected(False)
+ except:
+ pass
+ nouveau.setSelected(True)
+ nouveau.affichePanneau()
+
+ # ---------------------------#
+ def getFileVariable(self):
+ # ---------------------------#
+ titre = tr("Choix d'un fichier XML")
+ texte = tr("Le fichier contient une commande MODEL\n")
+ texte = texte + tr(
+ "Donnez le nom du fichier XML qui contient la description des variables"
+ )
+ QMessageBox.information(self, titre, tr(texte))
+
+ fichier = QFileDialog.getOpenFileName(
+ self.appliEficas,
+ tr("Ouvrir Fichier"),
+ self.appliEficas.maConfiguration.savedir,
+ tr("Wrapper Files (*.xml);;" "All Files (*)"),
+ )
+ return fichier
+
+ # ------------#
+ def run(self):
+ # ------------#
+ fonction = "run" + self.code
+ if fonction in JDCEditor.__dict__:
+ JDCEditor.__dict__[fonction](
+ self,
+ )
+
+ # ------------#
+ def saveRun(self):
+ # ------------#
+ fonction = "saveRun" + self.code
+ if fonction in JDCEditor.__dict__:
+ JDCEditor.__dict__[fonction](
+ self,
+ )
+
+ # ---------------------------------------------
+ # Methodes Non Crees dans ssIHM
+ # ---------------------------------------------
+ # ---------------#
+ def runVP(self):
+ # ---------------#
+ texte = self.getTextJDC("MAPVp", pourRun=1)
+ print(texte)
+
+ # ---------------#
+ def runMAP(self):
+ # ---------------#
+
+ if not (self.jdc.isValid()):
+ QMessageBox.critical(
+ self,
+ tr("Execution impossible "),
+ tr("le JDC doit etre valide pour une execution MAP"),
+ )
+ return
+ if len(self.jdc.etapes) != 1:
+ QMessageBox.critical(
+ self,
+ tr("Execution impossible "),
+ tr("le JDC doit contenir un et un seul composant"),
+ )
+ return
+ if self.modified or self.fichier == None:
+ self.fichierMapInput = self.generateTempFilename(
+ prefix="map_run", suffix=".map"
+ )
+ texte = self.getTextJDC("MAP")
+ self.writeFile(self.fichierMapInput, txt=texte)
+ else:
+ self.fichierMapInput = self.fichier
+ composant = self.jdc.etapes[0].nom.lower()[0:-5]
+
+ # :TRICKY: to determine if a component requires SALOME, loads the component from Eficas catalog
+ # then instantiate corresponding class and call getUseSalome() method
+ try:
+ from mapengine.spec import factory
+
+ mapComponent = factory.new(composant)[0]
+
+ command = "map"
+ if mapComponent.getUseSalome():
+ command += " -r sappli"
+ textePython = (
+ command + " run -n " + composant + " -i " + self.fichierMapInput
+ )
+
+ # textePython="ls -l"
+ self._viewTextExecute(textePython, "map_run", ".sh")
+ # try:
+ # commande="rm "+self.fichierMapInput
+ # os.system(commande)
+ # except :
+ # pass
+ except Exception as e:
+ print((traceback.print_exc()))
+
+ # -------------------#
+ def runZCRACKS(self):
+ # -------------------#
+ if not (self.jdc.isValid()):
+ QMessageBox.critical(
+ self,
+ tr("Execution impossible "),
+ tr("le JDC doit etre valide pour une execution "),
+ )
+ return
+ if self.modified or self.fichier == None:
+ # if 1:
+ self.fichierZcracksInput = self.generateTempFilename(
+ prefix="zcracks_run", suffix=".z7p"
+ )
+ texte = self.getTextJDC("ZCRACKS", pourRun=1)
+ self.writeFile(self.fichierZcracksInput, txt=texte)
+ else:
+ self.fichierZcracksInput = self.fichier
+ try:
+ # commande ="Zrun -zp "
+ commande = "more "
+ textePython = commande + self.fichierZcracksInput
+ self._viewTextExecute(textePython, "run_zcracks", ".sh")
+ except Exception as e:
+ print((traceback.print_exc()))
+
+ # -------------------#
+ def runCARMELCND(self):
+ # -------------------#
+ # if not(self.jdc.isValid()):
+ # QMessageBox.critical( self, tr( "Execution impossible "),tr("le JDC doit etre valide pour une execution "))
+ # return
+ if self.modified or self.fichier == None:
+ QMessageBox.critical(
+ self,
+ tr("Execution impossible "),
+ tr("Sauvegarder SVP avant l'execution "),
+ )
+ return
+ if not hasattr(self, "generator"):
+ texte = self.getTextJDC(self.formatFichierOut)
+ from PrepareRunCarmel import prepareRunCarmel
+
+ fichierGenerique = os.path.basename(self.fichier).split(".")[0]
+ repMed = os.path.dirname(self.fichier)
+ repExeCarmel = self.generator.get_repExeCarmel()
+ textePython = prepareRunCarmel(repExeCarmel, repMed, fichierGenerique)
+ nomFichier = self.generateTempFilename("carmel_run", suffix=".sh")
+ f = open(nomFichier, "w")
+ f.write(textePython)
+ f.close()
+ commande = "xterm -e sh " + nomFichier + "\n"
+ os.system(commande)
+
+ # -------------------#
+ def runCarmelCS(self):
+ # -------------------#
+ try:
+ commande = "runSession pilotyacsCS.py"
+ os.system(commande)
+ except Exception as e:
+ print((traceback.print_exc()))
+
+ # -----------------------------------------------------#
+ def determineNomFichier(self, path, extension):
+ # -----------------------------------------------------#
+ if self.appliEficas.code in DictExtensions:
+ chaine1 = (
+ DictExtensions[self.appliEficas.code]
+ + " (*."
+ + DictExtensions[self.appliEficas.code]
+ + ");;"
+ )
+ extensions = tr(chaine1 + "All Files (*)")
+ else:
+ extensions = tr("JDC (*.comm);;" "All Files (*)")
+
+ if self.appliEficas.code == "MAP":
+ extensions = extensions + ";; Run (*.input);;"
+
+ fn = QFileDialog.getSaveFileName(
+ self,
+ tr("sauvegarde"),
+ path,
+ extensions,
+ None,
+ QFileDialog.DontConfirmOverwrite,
+ )
+ if fn == None:
+ return (0, None)
+ fn = fn[0]
+ if fn == "":
+ return (0, None)
+
+ ext = QFileInfo(fn).suffix()
+ if ext == "":
+ fn += extension
+
+ if QFileInfo(fn).exists():
+ msgBox = QMessageBox(self)
+ msgBox.setWindowTitle(tr("Sauvegarde du Fichier"))
+ msgBox.setText(tr("Le fichier") + " " + str(fn) + " " + tr("existe deja"))
+ msgBox.addButton(tr("&Ecraser"), 0)
+ msgBox.addButton(tr("&Abandonner"), 1)
+ abort = msgBox.exec_()
+ if abort == 1:
+ return (0, "")
+ return (1, fn)
+
+ # -----------------#
+ def saveRunMAP(self):
+ # -----------------#
+ extension = ".input"
+ if not (self.jdc.isValid()):
+ QMessageBox.critical(
+ self,
+ tr("Sauvegarde de l'input impossible "),
+ tr("Un JdC valide est necessaire pour creer un .input"),
+ )
+ return
+ try:
+ composant = self.jdc.etapes[0].nom.lower()[0:-5]
+ except:
+ QMessageBox.critical(
+ self,
+ tr("Sauvegarde de l'input impossible "),
+ tr("Choix du composant obligatoire"),
+ )
+ return
+ if hasattr(self.maConfiguration, "savedir"):
+ path = self.maConfiguration.savedir
+ else:
+ path = "C:/"
+
+ monNomFichier = ""
+ if self.fichier is not None and self.fichier != "":
+ maBase = str(QFileInfo(self.fichier).baseName()) + ".input"
+ monPath = str(QFileInfo(self.fichier).absolutePath())
+ monNomFichier = os.path.join(monPath, maBase)
+ elif hasattr(self, "monNomFichierInput"):
+ monNomFichier = self.monNomFichierInput
+
+ monDialog = QFileDialog(self.appliEficas)
+ monDialog.setDirectory(path)
+ monDialog.setWindowTitle("Save")
+
+ for c in monDialog.children():
+ if isinstance(c, QDialogButtonBox):
+ for b in c.children():
+ if isinstance(b, QPushButton):
+ avant = b.text()
+ if avant == "&Open":
+ b.setText("Save")
+ mesFiltres = "input Map (*.input);;All Files (*)"
+ monDialog.setNameFilters(mesFiltres)
+ if monNomFichier != "":
+ monDialog.selectFile(monNomFichier)
+ BOk = monDialog.exec_()
+ if BOk == 0:
+ return
+ fn = str(monDialog.selectedFiles()[0])
+ if fn == "" or fn == None:
+ return
+ if not fn.endswith(".input"):
+ fn += ".input"
+ self.monNomFichierInput = fn
+
+ if (
+ not hasattr(self, "fichierMapInput")
+ or not self.fichierMapInput
+ or not os.path.exists(self.fichierMapInput)
+ ):
+ self.fichierMapInput = self.generateTempFilename(
+ prefix="map_run", suffix=".map"
+ )
+ texte = self.getTextJDC("MAP")
+ self.writeFile(self.fichierMapInput, txt=texte)
+
+ cmd = (
+ "map gen -t dat -n "
+ + composant
+ + " -i "
+ + self.fichierMapInput
+ + " -o "
+ + fn
+ )
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+ (output, err) = p.communicate()
+
+ # -----------------#
+ def saveRunPSEN(self):
+ # -----------------#
+ # print ("saveRunPSEN")
+ self.saveFile()
+
+ # -----------------------------------------#
+ def handleAjoutGroup(self, listeGroup):
+ # -----------------------------------------#
+ try:
+ # if 1:
+ from ajoutGroupe import handleAjoutGroupFiltre
+
+ # print listeGroup
+ handleAjoutGroupFiltre(self, listeGroup)
+ # print "apres handleAjoutGroupFiltre"
+ except:
+ # else :
+ pass
+
+ # -----------------------------------------------------------------#
+ def saveCompleteFile(self, path=None, saveas=0, formatLigne="beautifie"):
+ # -----------------------------------------------------------------#
+ extension = ".casR"
+ fn = self.fichierComplet
+ # saveas=True # Pour forcer le nom
+ self.generator = self.maConfiguration.mesGenerators.plugins[
+ self.formatFichierOut
+ ]()
+ if self.fichierComplet is None or saveas:
+ if path is None:
+ path = self.maConfiguration.savedir
+ bOK, fn = self.determineNomFichier(path, extension)
+ if bOK == 0:
+ return (0, None)
+ if fn == None:
+ return (0, None)
+ if fn == "":
+ return (0, None)
+
+ ulfile = os.path.abspath(fn)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ fn = QDir.toNativeSeparators(fn)
+
+ self.fichierComplet = os.path.splitext(fn)[0] + extension
+
+ if hasattr(self.generator, "writeComplet"):
+ self.generator.writeComplet(
+ self.fichierComplet,
+ self.jdc,
+ config=self.appliEficas.maConfiguration,
+ appliEficas=self.appliEficas,
+ )
+
+ if self.salome:
+ self.appliEficas.addJdcInSalome(self.fichierComplet)
+
+ self.modified = 0
+ nouveauTitre = (
+ self.titre + " " + str(os.path.basename(self.fichierComplet))
+ )
+ self.appliEficas.setWindowTitle(nouveauTitre)
+ return (1, self.fichierComplet)
+
+ # -----------------------------------------------------------------#
+ def saveFile(self, path=None, saveas=0, formatLigne="beautifie"):
+ # -----------------------------------------------------------------#
+ """
+ Public slot to save the text to a file.
+
+ @param path directory to save the file in (string or QString)
+ @return tuple of two values (boolean, string) giving a success indicator and
+ the name of the saved file
+ """
+
+ self.modified = 1
+ if not self.modified and not saveas:
+ return (0, None) # do nothing if text wasn't changed
+
+ if self.appliEficas.code in DictExtensions:
+ extension = DictExtensions[self.appliEficas.code]
+ else:
+ extension = ".comm"
+
+ newName = None
+ fn = self.fichier
+ if self.fichier is None or saveas:
+ if path is None:
+ path = self.maConfiguration.savedir
+ bOK, fn = self.determineNomFichier(path, extension)
+ if bOK == 0:
+ return (0, None)
+ if fn == None:
+ return (0, None)
+ if fn == "":
+ return (0, None)
+
+ ulfile = os.path.abspath(fn)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ fn = QDir.toNativeSeparators(fn)
+ newName = fn
+
+ if not (self.writeFile(fn, formatLigne=formatLigne)):
+ return (0, None)
+ self.fichier = fn
+ self.modified = False
+ if self.fileInfo is None or saveas:
+ self.fileInfo = QFileInfo(self.fichier)
+ self.fileInfo.setCaching(0)
+ self.lastModified = self.fileInfo.lastModified()
+ if newName is not None:
+ self.appliEficas.addToRecentList(newName)
+ self.tree.racine.item.getObject().nom = os.path.basename(newName)
+ self.tree.racine.updateNodeLabel()
+
+ if self.jdc.cata.modeleMetier:
+ self.jdc.toXml(self.fichier)
+ if self.jdc.cata.modeleMetier and self.jdc.isValid():
+ if self.generator != self.XMLGenerator:
+ self.XMLGenerator.gener(self.jdc)
+ self.XMLGenerator.writeDefault(fn)
+
+ if self.jdc.isValid() != 0 and hasattr(self.generator, "writeDefault"):
+ # if hasattr(self.generator, "writeDefault"):
+ self.generator.writeDefault(fn)
+ elif self.code == "TELEMAC" and hasattr(self.generator, "writeDefault"):
+ msgBox = QMessageBox(None)
+ msgBox.setWindowTitle(tr("Fichier .cas invalide / incomplet"))
+ msgBox.setText(tr("Le fichier .cas est invalide / incomplet"))
+ msgBox.addButton(tr("&Sauvegarder"), 1)
+ msgBox.addButton(tr("&Quitter sans sauvegarder"), 0)
+ msgBox.addButton(tr("&Annuler"), 2)
+ res = msgBox.exec_()
+ if res == 0:
+ self.generator.writeDefault(fn)
+ return (1, self.fichier)
+ if res == 2:
+ return (0, None)
+ if self.appliEficas.salome:
+ self.appliEficas.close()
+ else:
+ sys.exit(1)
+
+ if self.salome:
+ self.appliEficas.addJdcInSalome(self.fichier)
+ self.modified = 0
+ nouveauTitre = (
+ self.titre + " " + str(os.path.basename(self.fichier))
+ )
+ self.appliEficas.setWindowTitle(nouveauTitre)
+
+ return (1, self.fichier)
+
+ # -------------------------------------------#
+ def sauvePourPersalys(self, fichier=None):
+ # -------------------------------------------#
+ if self.jdc.isValid() == 0:
+ self.informe(
+ "Fichier invalide/incomplet",
+ "Impossible de sauvegarder l étude Persalys",
+ critique=False,
+ )
+ return
+ if self.fichier is None:
+ if path is None:
+ path = self.maConfiguration.savedir
+ bOK, fn = self.determineNomFichier(path, "comm")
+ if bOK == 0:
+ return (0, None)
+ if fn == None:
+ return (0, None)
+ if fn == "":
+ return (0, None)
+ ulfile = os.path.abspath(fn)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ fn = QDir.toNativeSeparators(fn)
+ self.fichier = fn
+ else:
+ fn = self.fichier
+ ret, comm = JDCEditorSsIhm.sauvePourPersalys(self, fn)
+ if not ret:
+ if not comm:
+ comm = "Impossible de sauvegarder l étude Persalys"
+ self.informe(" invalide/incomplet", comm, critique=False)
+ return
+
+ # -----------------------------------------------#
+ def saveUQFile(self, fichier=None, path=None):
+ # ------------------------------------------------#
+ if self.fichier is None:
+ if path is None:
+ path = self.maConfiguration.savedir
+ bOK, fn = self.determineNomFichier(path, "comm")
+ if bOK == 0:
+ return (0, None)
+ if fn == None:
+ return (0, None)
+ if fn == "":
+ return (0, None)
+ ulfile = os.path.abspath(fn)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ print(fn)
+ fn = QDir.toNativeSeparators(fn)
+ self.fichier = fn
+ else:
+ fn = self.fichier
+
+ if self.jdc.isValid() == 0:
+ msgBox = QMessageBox(None)
+ msgBox.setWindowTitle(tr("Fichier invalide / incomplet"))
+ msgBox.setText(
+ tr(
+ "Le fichier .comm est invalide / incomplet \n Seuls les .comm et _det.comm seront sauvegardes"
+ )
+ )
+ msgBox.addButton(tr("&Sauvegarder les .comm et _det.comm"), 0)
+ msgBox.addButton(tr("&Quitter sans sauvegarder"), 1)
+ msgBox.addButton(tr("&Annuler"), 2)
+ res = msgBox.exec_()
+ if res == 2:
+ return (0, None)
+ if res == 0:
+ ret, fichier = JDCEditorSsIhm.saveUQFile(self, fn)
+ if ret:
+ self.fichier = fichier
+ if self.salome and ret:
+ self.appliEficas.addJdcInSalome(self.fichier)
+ return (1, self.fichier)
+ if self.appliEficas.salome:
+ self.appliEficas.close()
+ else:
+ sys.exit(1)
+
+ ret, comm = JDCEditorSsIhm.saveUQFile(self, fn)
+ if not ret:
+ if comm:
+ titre = "Probleme de sauvegarde des fichiers"
+ texte = "Impossible de sauvegarder {}".format(fn)
+ QMessageBox.information(self, titre, texte)
+ return (0, self.fichier)
+ return (1, self.fichier)
+
+ # -----------------------------------------------#
+ def exeUQ(self, fichier=None, path=None):
+ # ------------------------------------------------#
+ # if self.modified or not self.fichier :
+ sauvegarde, fichier = self.saveUQFile()
+ if not sauvegarde:
+ return 0
+ # texteCommande=' export COLUMNS=200;'
+ try:
+ virtual_env = os.environ["VIRTUAL_ENV"]
+ except:
+ titre = "Probleme d'environnement"
+ texte = "La variable d'environnement VIRTUAL_ENV n'est pas positionnée"
+ QMessageBox.information(self, titre, texte)
+ return False
+
+ texteCommande = (
+ os.path.join(os.environ["VIRTUAL_ENV"], "bin/salome")
+ + " start -k -t python3 "
+ + os.path.join(
+ self.generator.cheminFichierComm, self.generator.fichierUQExe
+ )
+ )
+ # self._viewTextExecute(None,None,None, fichierExe=self.generator.fichierUQExe, shell='python3')
+ # self._viewTextExecute('ls -l /tmp','essaiLs','.sh',)
+ # self._viewTextExecute(None,None,None, fichierExe='/home/A96028/QT5Dev/eficasRN/ReacteurNumerique/a.py',shell='python3',)
+ self._viewTextExecute(None, None, None, texteCommande=texteCommande)
+ return True
+
+ # ----------------------------------------------#
+ def sauveLigneFile(self):
+ # ----------------------------------------------#
+ self.modified = 1
+ return self.saveFile(formatLigne="Ligne")
+
+ # ----------------------------------------------#
+ def saveFileAs(self, path=None, fileName=None):
+ # ----------------------------------------------#
+ """
+ Public slot to save a file with a new name.
+
+ @param path directory to save the file in (string or QString)
+ @return tuple of two values (boolean, string) giving a success indicator and
+ the name of the saved file
+ """
+ if fileName != None:
+ self.fichier = fileName
+ return self.saveFile()
+ return self.saveFile(path, 1, "beautifie")
+
+ # ---------------------------------------------#
+ def getFile(self, unite=None, fic_origine=""):
+ # ---------------------------------------------#
+ # appele par I_JDC
+ ulfile = None
+ jdcText = ""
+
+ titre = ""
+
+ if unite:
+ titre = tr("Choix unite %d ", unite)
+ texte = (
+ tr("Le fichier %s contient une commande INCLUDE \n", str(fic_origine))
+ + "\n"
+ )
+ texte = (
+ texte
+ + tr("Donnez le nom du fichier correspondant a l unite logique ")
+ + repr(unite)
+ )
+ labeltexte = tr("Fichier pour unite ") + repr(unite)
+ else:
+ titre = tr("Choix d'un fichier de poursuite")
+ texte = tr("Le fichier %s contient une commande POURSUITE\n", fic_origine)
+ texte = texte + tr(
+ "Donnez le nom du fichier dont vous \n voulez faire une poursuite"
+ )
+
+ QMessageBox.information(self, titre, texte)
+ fn = QFileDialog.getOpenFileName(
+ self.appliEficas, titre, self.appliEficas.maConfiguration.savedir
+ )
+
+ # ce retour est impose par le getFile d'I_JDC
+ if fn == "":
+ return None, " "
+ if not fn:
+ return (0, " ")
+ fn = fn[0]
+
+ ulfile = os.path.abspath(fn)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+
+ # On utilise le convertisseur defini par formatFichierIn
+ source = self.getSource(ulfile)
+ if source:
+ # On a reussia convertir le fichier self.ulfile
+ jdcText = source
+ else:
+ # Une erreur a ete rencontree
+ jdcText = ""
+ return ulfile, jdcText
+
+ # -----------------------------------#
+ def updateJdc(self, etape, texte):
+ # ------------------------------------#
+ # ajoute une etape de JdC a partir d un texte
+ CONTEXT.setCurrentStep(etape)
+ etape.buildIncludeEtape(texte)
+ if not (etape.text_included_converted):
+ QMessageBox.information(
+ self, tr("Impossible d importer le texte"), etape.text_included_error
+ )
+
+ self.tree.racine.buildChildren()
+
+ # -----------------------------------#
+ def updateJdcEtape(self, itemApres, texte):
+ # ------------------------------------#
+ # ajoute une etape de JdC a partir d un texte
+ monItem = itemApres
+ etape = monItem.item.object
+
+ CONTEXT.setCurrentStep(etape)
+ try:
+ ok = etape.buildIncludeEtape(texte)
+ except:
+ ok = 0
+ if not ok:
+ QMessageBox.information(
+ self, tr("Import texte"), tr("Impossible d importer le texte")
+ )
+ self.tree.racine.buildChildren()
+ return ok
+
+ # -------------------------------------------#
+ def updateJdcAfterEtape(self, etape, texte):
+ # --------------------------------------------#
+ # ajoute une etape de JdC a partir d un texte
+ CONTEXT.setCurrentStep(etape)
+ try:
+ ok = etape.buildIncludeEtape(texte, doitEtreValide=0)
+ except:
+ ok = 0
+ if not ok:
+ QMessageBox.information(
+ self, tr("Import texte"), tr("Impossible d importer le texte")
+ )
+ self.tree.racine.buildChildren()
+ return ok
+
+ # -------------------------------------#
+ def deleteEtape(self, etape):
+ # -------------------------------------#
+ # dans le JDC
+ self.jdc.suppEntite(etape)
+
+ # -----------------------------------------
+ def initSplitterSizes(self, nbWidget=3):
+ # -----------------------------------------
+ # print ("je passe ds initSplitterSizes", nbWidget)
+
+ if self.code in ["Adao", "ADAO", "MAP"]:
+ self.splitterSizes3 = [1, 1550, 300]
+ # elif self.code in [ 'MAP'] : self.splitterSizes3=[700,300]
+ else:
+ self.splitterSizes3 = [150, 1000, 300]
+
+ if self.code in ["Adao", "ADAO", "MAP"]:
+ self.splitterSizes2 = [5, 1500]
+ else:
+ self.splitterSizes2 = [300, 1000]
+
+ # -----------------------------------------
+ def restoreSplitterSizes(self, nbWidget=3):
+ # ----------------------------------------
+
+ # traceback.print_stack()
+ # print ("je passe ds restoreSplitterSizes")
+ if not (hasattr(self, "splitter")):
+ return
+ if nbWidget == 2:
+ newSizes = self.splitterSizes2
+ if nbWidget == 3:
+ newSizes = self.splitterSizes3
+ # self.inhibeSplitter = 1
+ # print (newSizes)
+ self.splitter.setSizes(newSizes)
+ # self.inhibeSplitter = 0
+ QApplication.processEvents()
+ # seule la fentetre du milieu est necessaire
+ self.splitter.widget(1).resizeEvent = self.saveSplitterSizes
+
+ # -----------------------------------------
+ def saveSplitterSizes(self, event):
+ # -----------------------------------------
+ # print ("je passe ds saveSplitterSizes")
+ if self.inhibeSplitter:
+ return
+ if self.widgetOptionnel == None:
+ self.splitterSizes2 = self.splitter.sizes()[0:2]
+ else:
+ self.splitterSizes3 = self.splitter.sizes()[0:3]
+
+ # ------------------------
+ def fermeOptionnel(self):
+ # ------------------------
+ if self.widgetOptionnel == None:
+ return
+
+ self.inhibeSplitter = 1
+ self.widgetOptionnel.setParent(None)
+ self.widgetOptionnel.close()
+ self.widgetOptionnel.deleteLater()
+ self.widgetOptionnel = None
+ self.inhibeSplitter = 0
+ self.restoreSplitterSizes(2)
+
+ # ------------------------
+ def ajoutOptionnel(self):
+ # ------------------------
+ # if len(self.splitterSizes) == 2 : self.splitterSizes.append(self.oldSizeWidgetOptionnel)
+ # else : self.splitterSizes[2] = self.oldSizeWidgetOptionnel # ceinture pour les close bizarres
+ # self.splitterSizes[1] = self.splitterSizes[1] - self.splitterSizes[2]
+
+ self.restoreSplitterSizes(3)
+
+ # ------------------------
+ def fermeArbre(self):
+ # ------------------------
+ # print (self.widgetTree)
+ self.oldWidgetTree = self.widgetTree
+ self.widgetTree.hide()
+ # self.widgetTree=None
+
+ # ------------------------
+ def ouvreArbre(self):
+ # ------------------------
+ # print ('je passe la')
+ # print (self.widgetTree)
+ # self.widgetTree=self.oldWidgetTree
+ self.widgetTree.show()
+ # self.restoreSplitterSizes(3)
+
+ # -----------------------
+ def getEtapeCourante(self):
+ # -----------------------
+ if len(self.tree.selectedItems()) != 1:
+ return None
+ etape = self.tree.selectedItems()[0].item.object.getEtape()
+ return etape
+
+ # -----------------------------
+ def getTreeIndex(self, noeud):
+ # ----------------------------
+ indexNoeud = -1
+ if noeud in noeud.treeParent.children:
+ indexNoeud = noeud.treeParent.children.index(noeud)
+ else:
+ if hasattr(noeud, "vraiParent"):
+ noeudVrai = noeud
+ noeudVraiParent = noeud.vraiParent
+ while noeudVraiParent != noeud.treeParent and hasattr(
+ noeudVraiParent, "vraiParent"
+ ):
+ noeudVrai = noeudVraiParent
+ noeudVraiParent = noeudVraiParent.vraiParent
+ pass
+ if noeudVraiParent == noeud.treeParent:
+ indexNoeud = noeud.treeParent.children.index(noeudVrai)
+ pass
+ pass
+ pass
+ return indexNoeud
+
+ # -------------------# Pour execution avec output et error dans le bash
+ def runPSEN(self):
+ # -------------------#
+
+ # if self.modified or self.fichier==None : self.saveFile()
+ self.saveFile()
+
+ # lancement avec le .bat
+ path1 = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "../", "../", "PSEN_Eficas", "PSEN")
+ )
+ WrapperFilePath = os.path.join(path1, "PSSEWrapper.py")
+ import subprocess
+
+ p = subprocess.Popen(["python", WrapperFilePath])
+ (out, err) = p.communicate()
+ print(out)
+ print(err)
+
+ # -------------------# Pour execution avec output et error dans le bash
+ def runPSEN_N1(self):
+ # -------------------#
+
+ self.saveFile()
+ path1 = os.path.abspath(
+ os.path.join(
+ os.path.abspath(__file__),
+ "../",
+ "../",
+ "ProcessOutputs_Eficas",
+ "TreatOutputs",
+ )
+ )
+ sys.path.append(path1)
+
+ if not (self.jdc.isValid()):
+ QMessageBox.information(
+ self, tr("Unvalid JDC"), tr("incorrect keywords will be ignored")
+ )
+ if "dicoImbrique" in generator.plugins:
+ self.generator = generator.plugins["dicoImbrique"]()
+ jdc_formate = self.generator.gener(self.jdc)
+ dico = self.generator.Dico
+
+ ###to delete
+ # fileDico = r'C:\Logiciels DER\PSEN_V16\Code\ProcessOutputs_Eficas\TreatOutputs\dicoN1.py'
+ fileDico = os.path.join(
+ path1, "dicoN1.py"
+ ) # r'C:\Logiciels DER\PSEN_V16\Code\ProcessOutputs_Eficas\TreatOutputs\dicoN1.py'
+ f = open(str(fileDico), "w")
+ f.write("Dico =" + str(dico))
+ f.close()
+ ###
+
+ print("in runPSEN_N1", dico)
+ print(dico)
+ from Run import run
+
+ run(dico)
+ # res,txt_exception=run(dico)
+ # if res : QMessageBox.information( self, tr("fin de script run"), txt_exception)
+ # else : QMessageBox.critical( self, tr("Erreur fatale script run"), txt_exception)
+
+ # -------------------# Pour execution avec output et error dans le bash
+ def process_N1(self):
+ # -------------------#
+
+ path1 = os.path.abspath(
+ os.path.join(
+ os.path.abspath(__file__),
+ "../",
+ "../",
+ "ProcessOutputs_Eficas",
+ "TreatOutputs",
+ )
+ )
+ sys.path.append(path1)
+
+ if "dicoImbrique" in generator.plugins:
+ self.generator = generator.plugins["dicoImbrique"]()
+ jdc_formate = self.generator.gener(self.jdc)
+ dico = self.getDico() # generator.Dico
+
+ for k in dico["CONTINGENCY_PROCESSING"]:
+ # print (k)
+ if (
+ k[0:19] == "Component_List_For_"
+ or k[0:21] == "Contingency_List_For_"
+ ):
+ newK = k.replace("__", " ")
+ l = "'" + str(newK) + "'"
+ dico["CONTINGENCY_PROCESSING"][l] = dico["CONTINGENCY_PROCESSING"][
+ k
+ ]
+ del dico["CONTINGENCY_PROCESSING"][k]
+
+ ###to delete
+ fileDico = os.path.join(path1, "dicoN1_process.py")
+ f = open(str(fileDico), "w")
+ f.write("Dico =" + str(dico))
+ f.close()
+ ###
+ return dico
+
+ # return self.getDico()
+
+ # -------------------# Pour execution avec output et error dans le bash
+ def process_VP(self):
+ # -------------------#
+ if "dicoImbrique" in generator.plugins:
+ self.generator = generator.plugins["dicoImbrique"]()
+ jdc_formate = self.generator.gener(self.jdc)
+ dico = self.getDico() # generator.Dico
+ return dico
+
+
+if __name__ == "__main__":
+ print("in main")
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+import traceback
+
+from PyQt5.QtWidgets import QToolButton, QWidget, QMessageBox
+from PyQt5.QtGui import QFont, QFontMetrics, QFontInfo, QPalette
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+
+from .gereIcones import ContientIcones
+from .gereIcones import FacultatifOuOptionnel
+from .qtSaisie import SaisieValeur
+
+nomMax = 230
+
+
+# empirique les metrics ne fonctionnent pas
+# ---------------------------------------------------------------------- #
+class Feuille(QWidget, ContientIcones, SaisieValeur, FacultatifOuOptionnel):
+ # --------------------------------------------------------------------- #
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print ("Feuille", monSimpDef,nom,objSimp)
+ QWidget.__init__(self, None)
+ self.node = node
+ self.node.fenetre = self
+
+ # on se positionne pour les icones
+ # os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__))))
+ self.setupUi(self)
+ self.prendLeFocus = 0
+
+ # maPolice= QFont("Times", 10)
+ # self.setFont(maPolice)
+ # self.setFocusPolicy(Qt.StrongFocus)
+
+ self.parentQt = parentQt
+ self.editor = self.node.editor
+ self.appliEficas = self.editor.appliEficas
+ self.repIcon = self.appliEficas.repIcon
+ self.monSimpDef = monSimpDef
+ self.nom = nom
+ self.objSimp = objSimp
+ self.node.fenetre = self
+ self.maCommande = commande
+
+ self.aRedimensionner = 0
+ self.setSuggestion()
+ self.setValeurs()
+ self.setNom()
+ self.setValide()
+ self.setIconePoubelle()
+ self.setIconesFichier()
+ self.setIconesSalome()
+ self.setIconesGenerales()
+ self.setCommentaire()
+ self.setZoneInfo()
+ self.setUnite()
+ # inhibition incertitude
+ self.inhibeSignal = False
+ self.setUQ()
+
+ def setUnite(self):
+ if self.monSimpDef.unite == None:
+ if hasattr(self, "lineEditUnite"):
+ self.lineEditUnite.setText(" ")
+ else:
+ if hasattr(self, "lineEditUnite"):
+ self.lineEditUnite.setText(self.monSimpDef.unite)
+ else:
+ self.editor.informe(
+ "Erreur de Catalogue",
+ "Champ Unite non prevu pour "
+ + self.nom
+ + " correction du catalogue souhaitable, prevenez la maintenance",
+ False,
+ )
+
+ def setUQ(self):
+ if not (self.editor.appliEficas.maConfiguration.afficheUQ) and hasattr(
+ self, "checkBoxUQ"
+ ):
+ self.checkBoxUQ.close()
+ return
+ if not self.objSimp.UQPossible() and hasattr(self, "checkBoxUQ"):
+ self.checkBoxUQ.close()
+ return
+ if not self.objSimp.UQPossible():
+ return
+ if hasattr(self, "checkBoxUQ"):
+ if self.objSimp.isUQActivate():
+ self.checkBoxUQ.setChecked(True)
+ else:
+ self.checkBoxUQ.setChecked(False)
+ self.checkBoxUQ.toggled.connect(self.setEnabledUQ)
+
+ def setEnabledUQ(self):
+ if self.inhibeSignal:
+ self.inhibeSignal = False
+ return
+ if self.checkBoxUQ.isChecked():
+ if self.objSimp.etape.nature == "OPERATEUR" and not (self.objSimp.etape.sd):
+ QMessageBox.warning(
+ self,
+ tr("Attention"),
+ tr(
+ "Il faut d abord nommer "
+ + self.objSimp.etape.nom
+ + " avant de pourvoir choisir des variables incertaines"
+ ),
+ )
+ self.inhibeSignal = True
+ self.checkBoxUQ.setCheckState(False)
+ return
+ self.objSimp.lieVariableUQ()
+ else:
+ ret = self.objSimp.delieVariableUQ()
+ if not ret:
+ QMessageBox.warning(
+ self,
+ tr("Variable associée non trouvée "),
+ tr("prevenez la maintenance"),
+ )
+ else:
+ etape = self.objSimp.getJdcRoot().getEtapesByName(
+ "ExpressionIncertitude"
+ )[0]
+ etape.node.buildChildren()
+
+ def setNom(self):
+ self.debutToolTip = ""
+ nomTraduit = tr(self.objSimp.nom)
+ # metrix= QFontMetrics(self.label.font())
+ # maxLongueur = self.label.width() - 2
+ # print ('______________________')
+ # print (nomTraduit)
+ # print (self.label.font().pixelSize())
+ # longueur2 = metrix.boundingRect(nomTraduit).width()
+ longueur = QFontMetrics(self.label.font()).width(nomTraduit)
+ if longueur >= nomMax:
+ nouveauNom = self.formate(nomTraduit)
+ self.label.setText(nouveauNom)
+ else:
+ self.label.setText(nomTraduit)
+ # clidedText = metrics.elidedText(text, Qt.ElideRight, label.width());
+ # if (clippedText != nomTraduit): self.label.setToolTip(nomTraduit)
+ # self.label.setText(clippedText)
+
+ # def agrandit(self):
+ # inutile pour certains widgets
+ # if self.height() < 40 :
+ # self.setMinimumHeight(50)
+ # self.resize(self.width(),200)
+
+ # def mousePressEvent(self, event):
+ # print 'mousePressEvent'
+ # import inspect
+ # print (inspect.getmro(self.__class__))
+ # self.__class__.mousePressEvent(self, event)
+
+ def setValeurs(self):
+ # print "passe dans setValeurs pour ", self.objSimp.nom
+ # print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ pass
+
+ def finCommentaire(self):
+ return ""
+
+ def finCommentaireListe(self):
+ commentaire = ""
+ mc = self.node.item.get_definition()
+ d_aides = {
+ "TXM": "chaines de caracteres",
+ "R": "reels",
+ "I": "entiers",
+ "C": "complexes",
+ }
+ type = mc.type[0]
+ if not type in d_aides:
+ if mc.min == mc.max:
+ commentaire = tr("Entrez ") + str(mc.min) + tr(" valeurs ") + "\n"
+ else:
+ if mc.max != "**":
+ commentaire = (
+ tr("entre ")
+ + str(mc.min)
+ + tr(" et ")
+ + str(mc.max)
+ + tr(" valeurs ")
+ + "\n"
+ )
+ else:
+ commentaire = ""
+ else:
+ if mc.min == mc.max:
+ commentaire = (
+ tr("Entrez ") + str(mc.min) + " " + tr(d_aides[type]) + "\n"
+ )
+ elif mc.max == float("inf"):
+ commentaire = (
+ tr("Entrez une liste de ") + " " + tr(d_aides[type]) + "\n"
+ )
+ else:
+ commentaire = (
+ tr("Entrez entre ")
+ + "\n"
+ + str(mc.min)
+ + (" et ")
+ + str(mc.max)
+ + " "
+ + tr(d_aides[type])
+ + "\n"
+ )
+ aideval = self.node.item.aide()
+ commentaire = commentaire + tr(aideval)
+ return str(commentaire)
+
+ def setSuggestion(self):
+ if self.monSimpDef.getSug() != None and self.monSimpDef.getSug() != "":
+ suggere = (
+ str('<html><head/><body><p><span style=" font-size:8pt;">suggestion : ')
+ + str(self.monSimpDef.getSug())
+ + "</span></p></body></html>"
+ )
+ if hasattr(self, "lineEditVal"):
+ self.lineEditVal.setToolTip(suggere)
+
+ def setCommentaire(self):
+ c = self.debutToolTip
+ # if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
+ self.aide = c
+ if self.objSimp.getFr() != None and self.objSimp.getFr() != "":
+ # c2 = '<html><head/><body><p>'+c+self.objSimp.getFr().decode('latin-1','replace')+"</p></body></html>"
+ c2 = "<html><head/><body><p>" + c + self.objSimp.getFr()
+ # c2 = '<html><head/><body><p>'+c+self.objSimp.getFr()+"</p></body></html>"
+ self.label.setToolTip(c2)
+ # self.aide=self.objSimp.getFr().decode('latin-1','ignore')+" "+c
+ self.aide = self.objSimp.getFr() + " " + c
+ else:
+ c += self.finCommentaire()
+ if c != "" and c != None:
+ self.aide = c
+ # c=str('<html><head/><body><p><span style=" font-size:8pt; ">')+c+"</span></p></body></html>"
+ c = str("<html><head/><body><p>") + c + "</p></body></html>"
+ self.label.setToolTip(c)
+
+ if self.editor.maConfiguration.differencieSiDefaut:
+ self.label.setToolTip(
+ "defaut : " + tr(str(self.node.item.object.definition.defaut))
+ )
+
+ def showEvent(self, event):
+ if self.prendLeFocus == 1:
+ self.activateWindow()
+ "il faut deriver le showEvent pour", self.nom
+ self.prendLeFocus = 0
+ QWidget.showEvent(self, event)
+
+ def aideALaSaisie(self):
+ mc = self.node.item.get_definition()
+ mctype = mc.type[0]
+ d_aides = {
+ "TXM": tr("chaine de caracteres"),
+ "R": tr("reel"),
+ "I": tr("entier"),
+ "C": tr("complexe"),
+ "Matrice": tr("Matrice"),
+ "Fichier": tr("fichier"),
+ "FichierNoAbs": tr("fichier existant"),
+ "Repertoire": tr("repertoire"),
+ }
+
+ if mc.min == mc.max:
+ commentaire = tr("Entrez ") + " " + str(mc.min) + " "
+ else:
+ commentaire = (
+ tr("Entrez entre ") + str(mc.min) + tr(" et ") + str(mc.max) + " "
+ )
+
+ try:
+ if issubclass(mctype, object):
+ ctype = getattr(mctype, "help_message", tr("Type de base inconnu"))
+ else:
+ ctype = d_aides.get(mctype, tr("Type de base inconnu"))
+ except:
+ ctype = d_aides.get(mctype, tr("Type de base inconnu"))
+ if ctype == tr("Type de base inconnu") and "Tuple" in str(mctype):
+ ctype = str(mctype)
+ if ctype == tr("Type de base inconnu") and "bool" in str(mctype):
+ ctype = "bool"
+
+ if mc.max != 1:
+ if ctype == "chaine de caractere" and mc.max > 1:
+ ctype = "chaines de caractere"
+ else:
+ ctype = ctype + "s"
+ commentaire += ctype
+ if mc.max != 1:
+ commentaire += "s"
+ return commentaire
+
+ def setZoneInfo(self):
+ # info=str(self.nom)+' '
+ # if self.monSimpDef.getFr() != None and self.monSimpDef.getFr() != "": info+=self.monSimpDef.getSug() +" "
+ # if self.monSimpDef.getSug() != None and self.monSimpDef.getSug() != "": info+="Valeur suggeree : "self.monSimpDef.getSug()
+ pass
+
+ def reaffiche(self):
+ if self.editor.jdc.aReafficher == True:
+ self.parentQt.reaffiche()
+
+ # PN PN PN pas satisfaisant
+ # nodeAVoir=self.parentQt.node.chercheNoeudCorrespondant(self.objSimp)
+ # print nodeAVoir.fenetre
+ # print "nodeAVoir.fenetre.isVisible()", nodeAVoir.fenetre.isVisible()
+ # if nodeAVoir.fenetre.isVisible() : return
+ # self.editor.fenetreCentraleAffichee.rendVisibleNoeud(nodeAVoir)
+ # nodeAVoir.fenetre.setFocus()
+ # return # on est bien postionne
+
+ if self.objSimp.isValid() and hasattr(self, "AAfficher"):
+ nodeAVoir = self.parentQt.node.chercheNoeudCorrespondant(self.objSimp)
+ try:
+ index = (
+ self.editor.fenetreCentraleAffichee.listeAffichageWidget.index(
+ nodeAVoir.fenetre.AAfficher
+ )
+ )
+ if (
+ index
+ == len(self.editor.fenetreCentraleAffichee.listeAffichageWidget)
+ - 1
+ ):
+ try:
+ nodeAVoir.fenetre.setValeursApresBouton()
+ except:
+ pass
+ else:
+ self.editor.fenetreCentraleAffichee.afficheSuivant(
+ nodeAVoir.fenetre.AAfficher
+ )
+ except:
+ pass
+ else:
+ if self.objSimp.isValid() and hasattr(self, "AAfficher"):
+ try:
+ self.setValeursApresBouton()
+ except:
+ pass
+ self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
+ else:
+ if hasattr(self, "AAfficher"):
+ self.AAfficher.setFocus(7)
+
+ def reaffichePourDeplier(self):
+ self.parentQt.reaffiche()
+
+ def rendVisible(self):
+ pass
+
+ # def enterEvent(self,event):
+ # print "je passe dans enterEvent", self.nom
+ # QWidget.enterEvent(self,event)
+
+ def traiteClicSurLabel(self, texte):
+ # aide=self.aide.encode('latin-1', 'ignore').decode('latin-1')+"\n"+self.aideALaSaisie().encode('latin-1', 'ignore').decode('latin-1')
+ try:
+ aide = self.aide + "\n" + self.aideALaSaisie()
+ except:
+ aide = self.aideALaSaisie()
+ self.editor.afficheCommentaire(aide)
+
+ def formate(self, t):
+ l = len(t) // 2
+ newText = t[0:l] + "-\n" + t[l:]
+ return newText
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os, re, sys
+import traceback
+import inspect
+
+from PyQt5.QtWidgets import QMessageBox, QFileDialog, QMenu, QPushButton, QTreeView, QListView, QAbstractItemView
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import QFileInfo, Qt, QSize, QVariant
+
+
+from Extensions.i18n import tr
+
+listeSuffixe = ("bmp", "png", "jpg", "txt", "med")
+
+
+class FacultatifOuOptionnel(object):
+#-----------------------------------
+ """ Gere les boutons """
+ def setReglesEtAide(self):
+ listeRegles = ()
+ try:
+ listeRegles = self.node.item.getRegles()
+ except:
+ pass
+ if hasattr(self, "RBRegle"):
+ if listeRegles == ():
+ self.RBRegle.close()
+ else:
+ icon3 = QIcon(self.repIcon + "/lettreRblanc30.png")
+ self.RBRegle.setIcon(icon3)
+ self.RBRegle.clicked.connect(self.viewRegles)
+
+ cle_doc = None
+ if not hasattr(self, "RBInfo"):
+ return
+ icon = QIcon(self.repIcon + "/point-interrogation30.png")
+ self.RBInfo.setIcon(icon)
+
+ from .monWidgetCommande import MonWidgetCommande
+ if isinstance(self, MonWidgetCommande) and self.editor.code == "MAP":
+ self.cle_doc = self.chercheDocMAP()
+ else:
+ self.cle_doc = self.node.item.getDocu()
+ if self.cle_doc == None:
+ self.RBInfo.close()
+ else:
+ self.RBInfo.clicked.connect(self.viewDoc)
+
+ def chercheDocMAP(self):
+ try:
+ clef = self.editor.maConfiguration.adresse + "/"
+ except:
+ return None
+ for k in self.editor.readercata.cata.JdC.dict_groupes:
+ if self.obj.nom in self.editor.readercata.cata.JdC.dict_groupes[k]:
+ clef += k
+ break
+ clef += (
+ "/"
+ + self.obj.nom[0:-5].lower()
+ + "/spec_"
+ + self.obj.nom[0:-5].lower()
+ + ".html"
+ )
+
+ return clef
+
+ def viewDoc(self):
+ try:
+ if sys.platform[0:5] == "linux":
+ cmd = "xdg-open " + self.cle_doc
+ else:
+ cmd = "start " + self.cle_doc
+ os.system(cmd)
+ except:
+ QMessageBox.warning(
+ self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
+ )
+
+ def viewRegles(self):
+ self.node.appellebuildLBRegles()
+
+ def setIconePoubelle(self):
+ if not (hasattr(self, "RBPoubelle")):
+ return
+
+ if self.node.item.object.isOblig() and not (
+ hasattr(self.node.item.object, "isDeletable")
+ ):
+ icon = QIcon(self.repIcon + "/deleteRondVide.png")
+ self.RBPoubelle.setIcon(icon)
+ return
+ icon = QIcon(self.repIcon + "/deleteRond.png")
+ self.RBPoubelle.setIcon(icon)
+ self.RBPoubelle.clicked.connect(self.aDetruire)
+
+ def setIconesSalome(self):
+ if not (hasattr(self, "RBSalome")):
+ return
+ from Accas import SalomeEntry
+
+ mc = self.node.item.get_definition()
+ mctype = mc.type[0]
+ 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
+ )
+ )
+
+ if enable_salome_selection:
+ icon = QIcon(self.repIcon + "/flecheSalome.png")
+ self.RBSalome.setIcon(icon)
+ self.RBSalome.pressed.connect(self.BSalomePressed)
+
+ # PNPN --> Telemac A revoir surement
+ # cela ou le catalogue grpma ou salomeEntry
+ if not (("grma" in repr(mctype)) or ("grno" in repr(mctype))) or not (
+ self.editor.salome
+ ):
+ if hasattr(self, "RBSalomeVue"):
+ self.RBSalomeVue.close()
+ else:
+ icon1 = QIcon(self.repIcon + "/eye.png")
+ self.RBSalomeVue.setIcon(icon1)
+ self.RBSalomeVue.clicked.connect(self.BView2DPressed)
+ else:
+ self.RBSalome.close()
+ self.RBSalomeVue.close()
+
+ def setIconesFichier(self):
+ if not (hasattr(self, "BFichier")):
+ return
+ mc = self.node.item.get_definition()
+ mctype = mc.type[0]
+ if mctype == "FichierOuRepertoire":
+ self.BFichierOuRepertoire = self.BFichier
+ self.BFichierOuRepertoire.clicked.connect(self.BFichierOuRepertoirePressed)
+ self.BVisuFichier.close()
+ elif mctype == "Repertoire":
+ self.BRepertoire = self.BFichier
+ self.BRepertoire.clicked.connect(self.BRepertoirePressed)
+ self.BVisuFichier.close()
+ else:
+ self.BFichier.clicked.connect(self.BFichierPressed)
+ self.BVisuFichier.clicked.connect(self.BFichierVisu)
+
+ def setIconesGenerales(self):
+ repIcon = self.node.editor.appliEficas.repIcon
+ if hasattr(self, "BVisuListe"):
+ fichier = os.path.join(repIcon, "plusnode.png")
+ icon = QIcon(fichier)
+ self.BVisuListe.setIcon(icon)
+ if hasattr(self, "RBDeplie"):
+ fichier = os.path.join(repIcon, "plusnode.png")
+ icon = QIcon(fichier)
+ self.RBDeplie.setIcon(icon)
+ if hasattr(self, "RBPlie"):
+ fichier = os.path.join(repIcon, "minusnode.png")
+ icon = QIcon(fichier)
+ self.RBPlie.setIcon(icon)
+ if hasattr(self, "BVisuFichier"):
+ fichier = os.path.join(repIcon, "visuFichier.png")
+ icon = QIcon(fichier)
+ self.BVisuFichier.setIcon(icon)
+
+ def setRun(self):
+ if hasattr(self.editor.appliEficas, "mesScripts"):
+ if self.editor.code in self.editor.appliEficas.mesScripts:
+ self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
+ self.editor.code
+ ].dict_commandes
+ if self.obj.nom in self.dict_commandes_mesScripts:
+ self.ajoutScript()
+ icon = QIcon(self.repIcon + "/roue.png")
+ if hasattr(self, "RBRun"):
+ self.RBRun.setIcon(icon)
+ return
+ if hasattr(self, "RBRun"):
+ self.RBRun.close()
+ if hasattr(self, "CBScripts"):
+ self.CBScripts.close()
+
+ def aDetruire(self):
+ self.node.delete()
+
+ def setValide(self):
+ if not (hasattr(self, "RBValide")):
+ return
+ couleur = self.node.item.getIconName()
+ monIcone = QIcon(self.repIcon + "/" + couleur + ".png")
+ self.RBValide.setIcon(monIcone)
+
+ # il faut chercher la bonne fenetre
+ def rendVisible(self):
+ # print "je passe par rendVisible de FacultatifOuOptionnel"
+ # print self
+ # print self.node.fenetre
+ # print "return pour etre sure"
+ return
+ # PNPN
+ newNode = self.node.treeParent.chercheNoeudCorrespondant(self.node.item.object)
+ # print newNode
+ self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(
+ newNode.fenetre
+ )
+ # newNode.fenetre.setFocus()
+
+ def ajoutScript(self):
+ if not hasattr(self, "CBScripts"):
+ return # Cas des Widgets Plies
+ self.dictCommandes = {}
+ listeCommandes = self.dict_commandes_mesScripts[self.obj.nom]
+ if type(listeCommandes) != tuple:
+ listeCommandes = (listeCommandes,)
+ i = 0
+ for commande in listeCommandes:
+ conditionSalome = commande[3]
+ if self.appliEficas.salome == 0 and conditionSalome == True:
+ continue
+ self.CBScripts.addItem(commande[1])
+ self.dictCommandes[commande[1]] = i
+ i = i + 1
+ self.CBScripts.activated.connect(self.choixSaisi)
+
+ def choixSaisi(self):
+ fction = str(self.CBScripts.currentText())
+ numero = self.dictCommandes[fction]
+ self.node.appelleFonction(numero, nodeTraite=self.node)
+ # self.reaffiche()
+
+
+class ContientIcones(object):
+ def BFichierVisu(self):
+ fichier = self.lineEditVal.text()
+ if fichier == None or str(fichier) == "":
+ return
+ from .monViewTexte import ViewText
+
+ try:
+ if sys.platform[0:5] == "linux":
+ # cmd="xdg-open "+ str(fichier)
+ # changer pour marcher dans l'EDC
+ # cmd="gedit "+ str(fichier)
+ from os.path import splitext
+
+ fileName, extension = splitext(fichier)
+ if (
+ extension
+ in self.parentQt.editor.appliEficas.maConfiguration.utilParExtensions
+ ):
+ cmd = (
+ self.parentQt.editor.appliEficas.maConfiguration.utilParExtensions[
+ extension
+ ]
+ + " "
+ + str(fichier)
+ )
+ else:
+ cmd = "xdg-open " + str(fichier)
+ os.system(cmd)
+ else:
+ os.startfile(str(fichier))
+ except:
+ try:
+ fp = open(fichier)
+ txt = fp.read()
+ nomFichier = QFileInfo(fichier).baseName()
+ maVue = ViewText(self, entete=nomFichier)
+ maVue.setText(txt)
+ maVue.show()
+ fp.close()
+ except:
+ QMessageBox.warning(
+ None,
+ tr("Visualisation Fichier "),
+ tr("Impossibilite d'afficher le Fichier"),
+ )
+
+ def BFichierPressed(self):
+ mctype = self.node.item.get_definition().type
+ if len(mctype) > 1:
+ filters = mctype[1]
+ elif hasattr(mctype[0], "filters"):
+ filters = mctype[0].filters
+ else:
+ filters = ""
+ if len(mctype) > 2 and mctype[2] == "Sauvegarde":
+ fichier = QFileDialog.getSaveFileName(
+ self.appliEficas,
+ tr("Use File"),
+ self.appliEficas.maConfiguration.savedir,
+ filters,
+ )
+ else:
+ # print(filters)
+ fichier = QFileDialog.getOpenFileName(
+ self.appliEficas,
+ tr("Ouvrir Fichier"),
+ self.appliEficas.maConfiguration.savedir,
+ filters,
+ )
+
+ fichier = fichier[0]
+ if not (fichier == ""):
+ ulfile = os.path.abspath(fichier)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ self.lineEditVal.setText(fichier)
+ self.editor.afficheCommentaire(tr("Fichier selectionne"))
+ self.LEvaleurPressed()
+ if QFileInfo(fichier).suffix() in listeSuffixe:
+ self.image = fichier
+ if not hasattr(self, "BSelectInFile"):
+ try:
+ self.BSelectInFile = QPushButton(self)
+ self.BSelectInFile.setMinimumSize(QSize(140, 40))
+ self.BSelectInFile.setObjectName("BSelectInFile")
+ self.gridLayout.addWidget(self.BSelectInFile, 1, 1, 1, 1)
+ self.BSelectInFile.setText(tr("Selection"))
+ self.BSelectInFile.clicked.connect(self.BSelectInFilePressed)
+ except:
+ pass
+ else:
+ self.BSelectInFile.setVisible(1)
+
+ elif hasattr(self, "BSelectInFile"):
+ self.BSelectInFile.setVisible(0)
+
+ def BFichierOuRepertoirePressed(self):
+ self.fileName = ""
+ self.file_dialog = QFileDialog()
+ self.file_dialog.setFileMode(QFileDialog.Directory)
+ self.file_dialog.setFileMode(QFileDialog.Directory | QFileDialog.ExistingFiles)
+ self.file_dialog.setOption(QFileDialog.DontUseNativeDialog, True)
+ self.file_dialog.setWindowTitle("Choose File or Directory")
+ self.explore(self.file_dialog)
+ self.file_dialog.exec_()
+ if self.fileName == "":
+ return
+ self.lineEditVal.setText(self.fileName)
+ self.LEvaleurPressed()
+
+ def explore(self, widget):
+ for c in widget.children():
+ if isinstance(c, QTreeView):
+ c.clicked.connect(self.changeBoutonOpen)
+ self.monTreeView = c
+ try:
+ if c.text() == "&Open":
+ self.monBoutonOpen = c
+ except:
+ pass
+ self.explore(c)
+
+ def changeBoutonOpen(self):
+ self.monBoutonOpen.setEnabled(True)
+ self.monBoutonOpen.setText("Choose")
+ self.monBoutonOpen.clicked.connect(self.monBoutonOpenClicked)
+ index = self.monTreeView.currentIndex()
+ self.fileName2 = self.monTreeView.model().data(index)
+
+ def monBoutonOpenClicked(self):
+ try:
+ self.fileName = self.file_dialog.selectedFiles()[0]
+ except:
+ self.fileName = self.file_dialog.directory().absolutePath()
+ self.file_dialog.close()
+ self.file_dialog = None
+
+ def BRepertoirePressed(self):
+ directory = QFileDialog.getExistingDirectory(
+ self.appliEficas,
+ directory=self.appliEficas.maConfiguration.savedir,
+ options=QFileDialog.ShowDirsOnly,
+ )
+
+ if not (directory == ""):
+ absdir = os.path.abspath(directory)
+ self.appliEficas.maConfiguration.savedir = os.path.dirname(absdir)
+ self.lineEditVal.setText(directory)
+ self.LEvaleurPressed()
+
+ def BSelectInFilePressed(self):
+ from monSelectImage import MonSelectImage
+
+ MonSelectImage(file=self.image, parent=self).show()
+
+ def BSalomePressed(self):
+ self.editor.afficheCommentaire("")
+ selection = []
+ commentaire = ""
+ genea = self.node.item.getGenealogie()
+ kwType = self.node.item.get_definition().type[0]
+ for e in genea:
+ if "GROUP_NO" in e:
+ kwType = "GROUP_NO"
+ if "GROUP_MA" in e:
+ kwType = "GROUP_MA"
+
+ if "grno" in repr(kwType):
+ kwType = "GROUP_NO"
+ if "grma" in repr(kwType):
+ kwType = "GROUP_MA"
+
+ if kwType in ("GROUP_NO", "GROUP_MA"):
+ selection, commentaire = self.appliEficas.selectGroupFromSalome(
+ kwType, editor=self.editor
+ )
+
+ mc = self.node.item.get_definition()
+
+ if isinstance(mc.type, tuple) and len(mc.type) > 1 and "(*.med)" in mc.type[1]:
+ selection, commentaire = self.appliEficas.selectMeshFile(editor=self.editor)
+ # print selection, commentaire
+ if commentaire != "":
+ QMessageBox.warning(
+ None,
+ tr("Export Med vers Fichier "),
+ tr("Impossibilite d exporter le Fichier"),
+ )
+ return
+ else:
+ self.lineEditVal.setText(str(selection))
+ return
+
+ from Accas import SalomeEntry
+
+ if inspect.isclass(kwType) and issubclass(kwType, SalomeEntry):
+ selection, commentaire = self.appliEficas.selectEntryFromSalome(
+ kwType, editor=self.editor
+ )
+
+ if commentaire != "":
+ self.editor.afficheInfos(tr(str(commentaire)))
+ if selection == []:
+ return
+
+ min, max = self.node.item.getMinMax()
+ if max > 1:
+ self.ajoutNValeur(selection)
+ return
+
+ monTexte = ""
+ for geomElt in selection:
+ monTexte = geomElt + ","
+ monTexte = monTexte[0:-1]
+ self.lineEditVal.setText(str(monTexte))
+ self.LEvaleurPressed()
+
+ def BView2DPressed(self):
+ try:
+ # cas d un Simp de base
+ valeur = self.lineEditVal.text()
+ except:
+ valeur = self.textSelected
+ valeur = str(valeur)
+ if valeur == str(""):
+ return
+ if valeur:
+ ok, msgError = self.appliEficas.displayShape(valeur)
+ if not ok:
+ self.editor.afficheInfos(msgError, Qt.red)
+
+ def BParametresPressed(self):
+ liste = self.node.item.getListeParamPossible()
+ from monListeParamPanel import MonListeParamPanel
+
+ MonListeParamPanel(liste=liste, parent=self).show()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+import traceback
+
+
+from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog, QMessageBox
+from PyQt5.QtCore import QEvent, Qt, QTimer
+from PyQt5.QtGui import QIcon, QPalette
+
+from Extensions.i18n import tr
+from InterfaceGUI.QT5.monViewTexte import ViewText
+
+
+# ---------------------- #
+class LECustom(QLineEdit):
+ # ---------------------- #
+ def __init__(self, parent, parentQt, i):
+ """
+ Constructor
+ """
+ QLineEdit.__init__(self, parent)
+
+ self.parentQt = parentQt
+ self.num = i
+ self.dansUnTuple = False
+ self.numDsLaListe = -1
+ self.parentTuple = None
+ self.valeur = None
+ self.aEuLeFocus = 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")
+ QLineEdit.focusInEvent(self, event)
+
+ def focusOutEvent(self, event):
+ # print ('focusOutEvent', self.aEuLeFocus)
+ 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()
+ QLineEdit.focusOutEvent(self, event)
+
+ def litValeur(self):
+ # print ("dans litValeur de LECustom")
+ self.aEuLeFocus = False
+ val = str(self.text())
+ 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
+ )
+ valeur = eval(val, d)
+ except:
+ valeur = val
+ self.valeur = valeur
+ # print ('self.valeur', self.valeur)
+
+ def clean(self):
+ self.setText("")
+
+ def getValeur(self):
+ # return self.text()
+ self.litValeur()
+ return self.valeur
+
+ def setValeur(self, valeur):
+ self.setText(valeur)
+
+
+# --------------------------- #
+class LECustomTuple(LECustom):
+ # --------------------------- #
+ def __init__(self, parent):
+ # index sera mis a jour par TupleCustom
+ parentQt = parent.parent().parent().parent()
+ LECustom.__init__(self, parent, parentQt, 0)
+ # print (dir(self))
+
+
+# ---------------------------- #
+class MonLabelListeClic(QLabel):
+ # ---------------------------- #
+ def __init__(self, parent):
+ QLabel.__init__(self, parent)
+ self.parent = parent
+
+ def event(self, event):
+ if event.type() == QEvent.MouseButtonRelease:
+ self.texte = self.text()
+ self.parent.traiteClicSurLabelListe(self.texte)
+ return QLabel.event(self, event)
+
+
+# ------------- #
+class GereListe(object):
+ # ------------- #
+ def __init__(self):
+ self.connecterSignaux()
+
+ def connecterSignaux(self):
+ if hasattr(self, "RBHaut"):
+ self.RBHaut.clicked.connect(self.hautPushed)
+ self.RBBas.clicked.connect(self.basPushed)
+ self.RBMoins.clicked.connect(self.moinsPushed)
+ self.RBPlus.clicked.connect(self.plusPushed)
+ self.RBVoisListe.clicked.connect(self.voisListePushed)
+ if hasattr(self, "PBAlpha"):
+ self.PBCata.clicked.connect(self.cataPushed)
+ self.PBAlpha.clicked.connect(self.alphaPushed)
+ self.PBFind.clicked.connect(self.findPushed)
+ self.LEFiltre.returnPressed.connect(self.LEFiltreReturnPressed)
+ if hasattr(self, "PBValideFeuille"):
+ self.PBValideFeuille.clicked.connect(self.changeValeur)
+
+ def filtreListe(self):
+ l = []
+ if self.filtre != "":
+ for i in self.listeAAfficher:
+ if i.find(self.filtre) == 0:
+ l.append(i)
+ self.listeAAfficher = l
+ if self.alpha:
+ self.listeAAfficher.sort()
+
+ def LEFiltreReturnPressed(self):
+ self.filtre = self.LEFiltre.text()
+ self.prepareListeResultatFiltre()
+
+ def findPushed(self):
+ self.filtre = self.LEFiltre.text()
+ self.prepareListeResultatFiltre()
+
+ def alphaPushed(self):
+ # print "alphaPushed" ,self.alpha
+ if self.alpha == 1:
+ return
+ self.alpha = 1
+ self.prepareListeResultat()
+
+ def cataPushed(self):
+ if self.alpha == 0:
+ return
+ self.alpha = 0
+ self.prepareListeResultat()
+
+ def hautPushed(self):
+ # print ('hautPushed')
+ if self.numLineEditEnCours == 0:
+ return
+ if self.numLineEditEnCours == 1:
+ return
+ else:
+ numEchange = self.numLineEditEnCours - 1
+ self.echange(self.numLineEditEnCours, numEchange)
+ self.lineEditEnCours.setFocus(True)
+ self.scrollArea.ensureWidgetVisible(self.lineEditEnCours)
+
+ def basPushed(self):
+ # print ('hautPushed')
+ if self.numLineEditEnCours == 0:
+ return
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ return
+ else:
+ numEchange = self.numLineEditEnCours + 1
+ self.echange(self.numLineEditEnCours, numEchange)
+ self.lineEditEnCours.setFocus(True)
+ self.scrollArea.ensureWidgetVisible(self.lineEditEnCours)
+
+ def echange(self, num1, num2):
+ # on donne le focus au a celui ou on a bouge
+ # par convention le 2
+ # print ('echange')
+ nomLineEdit = self.nomLine + str(num1)
+ # print (nomLineEdit)
+ courant = getattr(self, nomLineEdit)
+ valeurAGarder = courant.text()
+ nomLineEdit2 = self.nomLine + str(num2)
+ # print (nomLineEdit2)
+ courant2 = getattr(self, nomLineEdit2)
+ courant.setText(courant2.text())
+ courant2.setText(valeurAGarder)
+ # pour monWidgetCreeUserAssd
+ self.num1 = num1
+ self.num2 = num2
+ self.changeValeur(changeDePlace=False)
+ self.numLineEditEnCours = num2
+ self.lineEditEnCours = courant2
+ self.lineEditEnCours.setFocus(True)
+
+ def moinsPushed(self):
+ # on supprime le dernier
+ # print ('moinsPushed')
+ if self.numLineEditEnCours == 0:
+ return
+ if self.indexDernierLabel == 0:
+ return
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+ courant = getattr(self, nomLineEdit)
+ courant.clean()
+ else:
+ for i in range(self.numLineEditEnCours, self.indexDernierLabel):
+ aRemonter = i + 1
+ nomLineEdit = self.nomLine + str(aRemonter)
+ courant = getattr(self, nomLineEdit)
+ valeurARemonter = courant.getValeur()
+ nomLineEdit = self.nomLine + str(i)
+ courant = getattr(self, nomLineEdit)
+ if valeurARemonter != None:
+ courant.setValeur(valeurARemonter)
+ else:
+ courant.clean()
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+ courant = getattr(self, nomLineEdit)
+ courant.clean()
+ self.changeValeur(changeDePlace=False, oblige=True)
+ self.setValide()
+
+ def plusPushed(self):
+ # print ('plusPushed gereliste')
+ if self.indexDernierLabel == self.monSimpDef.max:
+ if len(self.listeValeursCourantes) < self.monSimpDef.max:
+ self.chercheLigneVide()
+ else:
+ self.editor.afficheInfos(
+ "nb max de valeurs : " + str(self.monSimpDef.max) + " atteint",
+ Qt.red,
+ )
+ return
+ self.ajoutLineEdit()
+ self.descendLesLignes()
+ self.chercheLigneVide()
+ QTimer.singleShot(1, self.rendVisibleLigne)
+
+ def chercheLigneVide(self):
+ # print ('chercheLigneVide')
+ for i in range(self.indexDernierLabel):
+ nomLineEdit = self.nomLine + str(i + 1)
+ courant = getattr(self, nomLineEdit)
+ valeur = courant.getValeur()
+ if valeur == "" or valeur == None:
+ courant.setFocus(True)
+ self.estVisible = courant
+
+ def descendLesLignes(self):
+ # print ('descendLesLignes')
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ return
+ nomLineEdit = self.nomLine + str(self.numLineEditEnCours + 1)
+ courant = getattr(self, nomLineEdit)
+ valeurADescendre = courant.getValeur()
+ courant.clean()
+ for i in range(self.numLineEditEnCours + 1, self.indexDernierLabel):
+ aDescendre = i + 1
+ nomLineEdit = self.nomLine + str(aDescendre)
+ courant = getattr(self, nomLineEdit)
+ valeurAGarder = courant.getValeur()
+ courant.setValeur(valeurADescendre)
+ valeurADescendre = valeurAGarder
+ self.changeValeur(changeDePlace=False)
+ if hasattr(self, "lineEditEnCours"):
+ self.scrollArea.ensureWidgetVisible(self.lineEditEnCours)
+
+ def voisListePushed(self):
+ texteValeurs = ""
+ for v in self.node.item.getListeValeurs():
+ texteValeurs += str(v) + ", "
+ entete = "Valeurs pour " + self.nom
+ f = ViewText(self, self.editor, entete, texteValeurs[0:-2])
+ f.show()
+
+ def selectInFile(self):
+ init = str(self.editor.maConfiguration.savedir)
+ fn = QFileDialog.getOpenFileName(
+ self.node.appliEficas,
+ tr("Fichier de donnees"),
+ init,
+ tr(
+ "Tous les Fichiers (*)",
+ ),
+ )
+ fn = fn[0]
+ if fn == None:
+ return
+ if fn == "":
+ return
+ ulfile = os.path.abspath(fn)
+ self.editor.maConfiguration.savedir = os.path.split(ulfile)[0]
+
+ from .monSelectVal import MonSelectVal
+
+ MonSelectVal(file=fn, parent=self).show()
+
+ def noircirResultatFiltre(self):
+ filtre = str(self.LEFiltre.text())
+ for cb in self.listeCbRouge:
+ palette = QPalette(Qt.red)
+ palette.setColor(QPalette.WindowText, Qt.black)
+ cb.setPalette(palette)
+ t = cb.text()
+ cb.setText(t)
+ self.LEFiltre.setText("")
+ self.listeCbRouge = []
+
+
+# ----------- #
+class GerePlie(object):
+ # ----------- #
+
+ def gereIconePlier(self):
+ if not (hasattr(self, "BFermeListe")):
+ return
+ self.editor.listeDesListesOuvertes.add(self.node.item)
+ repIcon = self.node.editor.appliEficas.repIcon
+ if not (self.editor.afficheListesPliees):
+ fichier = os.path.join(repIcon, "empty.png")
+ icon = QIcon(fichier)
+ self.BFermeListe.setIcon(icon)
+ return
+ fichier = os.path.join(repIcon, "minusnode.png")
+ icon = QIcon(fichier)
+ self.BFermeListe.setIcon(icon)
+ self.BFermeListe.clicked.connect(self.selectWidgetPlie)
+
+ def selectWidgetPlie(self):
+ self.editor.listeDesListesOuvertes.remove(self.node.item)
+ self.reaffichePourDeplier()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+import traceback
+
+from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog, QWidget
+from PyQt5.QtCore import QEvent, Qt, QTimer
+from PyQt5.QtGui import QIcon, QPalette
+
+from Extensions.i18n import tr
+from InterfaceGUI.QT5.monViewTexte import ViewText
+
+
+# ---------------------- #
+class LECustom(QLineEdit):
+ # ---------------------- #
+ def __init__(self, parent, parentQt, i):
+ """
+ Constructor
+ """
+ QLineEdit.__init__(self, parent)
+
+ self.valeur = None
+ self.aEuLeFocus = False
+ self.parentQt = parentQt
+ self.parent = parent
+ self.num = i
+ self.dansUnTuple = False
+ self.numDsLaListe = -1
+ self.returnPressed.connect(self.litValeur)
+
+ def focusInEvent(self, event):
+ # print ("dans focusInEvent de LECustom",self.parentQt)
+ print("dans focusInEvent de LECustom", self.num, self.numDsLaListe)
+ 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")
+ QLineEdit.focusInEvent(self, event)
+
+ def focusOutEvent(self, event):
+ # print ("dans focusOutEvent de LECustom",self.num,self.numDsLaListe, self.aEuLeFocus)
+ 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()
+ QLineEdit.focusOutEvent(self, event)
+
+ def litValeur(self):
+ self.aEuLeFocus = False
+ val = str(self.text())
+ 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
+ )
+ valeur = eval(val, d)
+ except:
+ valeur = val
+
+ self.valeur = valeur
+
+ def clean(self):
+ self.setText("")
+
+ def getValeur(self):
+ return self.text()
+
+ def setValeur(self, valeur):
+ self.setText(valeur)
+ self.valeur = valeur
+
+ # def leaveEvent(self,event):
+ # ne sert a rien. quand on modifie la valeur on prend le focus
+
+
+# --------------------------- #
+class LECustomTuple(LECustom):
+ # --------------------------- #
+ def __init__(self, parent):
+ # index sera mis a jour par TupleCustom
+ parentQt = parent.parent().parent().parent()
+ LECustom.__init__(self, parent, parentQt, 0)
+ # print (dir(self))
+
+
+# ---------------------------- #
+class MonLabelListeClic(QLabel):
+ # ---------------------------- #
+ def __init__(self, parent):
+ QLabel.__init__(self, parent)
+ self.parent = parent
+
+ def event(self, event):
+ if event.type() == QEvent.MouseButtonRelease:
+ self.texte = self.text()
+ self.parent.traiteClicSurLabelListe(self.texte)
+ return QLabel.event(self, event)
+
+
+# ------------- #
+class GereListe(object):
+ # ------------- #
+
+ def __init__(self):
+ self.aEuLeFocus = False
+ self.connecterSignaux()
+
+ def leaveEvent(self, event):
+ if self.aEuLeFocus:
+ print("appel de changeValeur")
+ self.changeValeur()
+ self.aEuLeFocus = False
+ QWidget.leaveEvent(self, event)
+
+ def connecterSignaux(self):
+ if hasattr(self, "RBHaut"):
+ self.RBHaut.clicked.connect(self.hautPushed)
+ self.RBBas.clicked.connect(self.basPushed)
+ self.RBMoins.clicked.connect(self.moinsPushed)
+ self.RBPlus.clicked.connect(self.plusPushed)
+ self.RBVoisListe.clicked.connect(self.voisListePushed)
+ if hasattr(self, "PBAlpha"):
+ self.PBCata.clicked.connect(self.cataPushed)
+ self.PBAlpha.clicked.connect(self.alphaPushed)
+ self.PBFind.clicked.connect(self.findPushed)
+ self.LEFiltre.returnPressed.connect(self.LEFiltreReturnPressed)
+
+ def filtreListe(self):
+ l = []
+ if self.filtre != "":
+ for i in self.listeAAfficher:
+ if i.find(self.filtre) == 0:
+ l.append(i)
+ self.listeAAfficher = l
+ if self.alpha:
+ self.listeAAfficher.sort()
+
+ def LEFiltreReturnPressed(self):
+ self.filtre = self.LEFiltre.text()
+ self.prepareListeResultatFiltre()
+
+ def findPushed(self):
+ self.filtre = self.LEFiltre.text()
+ self.prepareListeResultatFiltre()
+
+ def alphaPushed(self):
+ # print "alphaPushed" ,self.alpha
+ if self.alpha == 1:
+ return
+ self.alpha = 1
+ self.prepareListeResultat()
+
+ def cataPushed(self):
+ if self.alpha == 0:
+ return
+ self.alpha = 0
+ self.prepareListeResultat()
+
+ def hautPushed(self):
+ if self.numLineEditEnCours == 1:
+ return
+ else:
+ numEchange = self.numLineEditEnCours - 1
+ self.echange(self.numLineEditEnCours, numEchange)
+ self.LineEditEnCours.setFocus(True)
+ self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
+
+ def basPushed(self):
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ return
+ else:
+ numEchange = self.numLineEditEnCours + 1
+ self.echange(self.numLineEditEnCours, numEchange)
+ self.LineEditEnCours.setFocus(True)
+ self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
+
+ def echange(self, num1, num2):
+ # on donne le focus au a celui ou on a bouge
+ # par convention le 2
+ nomLineEdit = self.nomLine + str(num1)
+ # print nomLineEdit
+ courant = getattr(self, nomLineEdit)
+ valeurAGarder = courant.text()
+ nomLineEdit2 = self.nomLine + str(num2)
+ # print nomLineEdit2
+ courant2 = getattr(self, nomLineEdit2)
+ courant.setText(courant2.text())
+ courant2.setText(valeurAGarder)
+ self.changeValeur(changeDePlace=False)
+ self.numLineEditEnCours = num2
+ self.LineEditEnCours = courant2
+ self.LineEditEnCours.setFocus(True)
+
+ def moinsPushed(self):
+ # on supprime le dernier
+ if self.numLineEditEnCours == 0:
+ return
+ if self.indexDernierLabel == 0:
+ return
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+ courant = getattr(self, nomLineEdit)
+ courant.clean()
+ else:
+ for i in range(self.numLineEditEnCours, self.indexDernierLabel):
+ aRemonter = i + 1
+ nomLineEdit = self.nomLine + str(aRemonter)
+ courant = getattr(self, nomLineEdit)
+ valeurARemonter = courant.getValeur()
+ nomLineEdit = self.nomLine + str(i)
+ courant = getattr(self, nomLineEdit)
+ if valeurARemonter != None:
+ courant.setValeur(valeurARemonter)
+ else:
+ courant.clean()
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+ courant = getattr(self, nomLineEdit)
+ courant.clean()
+ self.changeValeur(changeDePlace=False, oblige=True)
+ self.setValide()
+
+ def plusPushed(self):
+ if self.indexDernierLabel == self.monSimpDef.max:
+ if len(self.listeValeursCourantes) < self.monSimpDef.max:
+ self.chercheLigneVide()
+ else:
+ self.editor.afficheInfos(
+ "nb max de valeurs : " + str(self.monSimpDef.max) + " atteint",
+ Qt.red,
+ )
+ return
+ self.ajoutLineEdit()
+ self.descendLesLignes()
+ self.chercheLigneVide()
+ QTimer.singleShot(1, self.rendVisibleLigne)
+
+ def chercheLigneVide(self):
+ for i in range(self.indexDernierLabel):
+ nomLineEdit = self.nomLine + str(i + 1)
+ courant = getattr(self, nomLineEdit)
+ valeur = courant.getValeur()
+ if valeur == "":
+ courant.setFocus(True)
+ self.estVisible = courant
+ return
+
+ def descendLesLignes(self):
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ return
+ nomLineEdit = self.nomLine + str(self.numLineEditEnCours + 1)
+ courant = getattr(self, nomLineEdit)
+ valeurADescendre = courant.getValeur()
+ courant.clean()
+ for i in range(self.numLineEditEnCours + 1, self.indexDernierLabel):
+ aDescendre = i + 1
+ nomLineEdit = self.nomLine + str(aDescendre)
+ courant = getattr(self, nomLineEdit)
+ valeurAGarder = courant.getValeur()
+ courant.setValeur(valeurADescendre)
+ valeurADescendre = valeurAGarder
+ self.changeValeur(changeDePlace=False)
+ if hasattr(self, "LineEditEnCours"):
+ self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
+
+ def voisListePushed(self):
+ texteValeurs = ""
+ for v in self.node.item.getListeValeurs():
+ texteValeurs += str(v) + ", "
+ entete = "Valeurs pour " + self.nom
+ f = ViewText(self, self.editor, entete, texteValeurs[0:-2])
+ f.show()
+
+ def selectInFile(self):
+ init = str(self.editor.maConfiguration.savedir)
+ fn = QFileDialog.getOpenFileName(
+ self.node.appliEficas,
+ tr("Fichier de donnees"),
+ init,
+ tr(
+ "Tous les Fichiers (*)",
+ ),
+ )
+ fn = fn[0]
+ if fn == None:
+ return
+ if fn == "":
+ return
+ import six
+ ulfile = os.path.abspath(six.text_type(fn))
+ self.editor.maConfiguration.savedir = os.path.split(ulfile)[0]
+
+ from .monSelectVal import MonSelectVal
+
+ MonSelectVal(file=fn, parent=self).show()
+
+ def noircirResultatFiltre(self):
+ filtre = str(self.LEFiltre.text())
+ for cb in self.listeCbRouge:
+ palette = QPalette(Qt.red)
+ palette.setColor(QPalette.WindowText, Qt.black)
+ cb.setPalette(palette)
+ t = cb.text()
+ cb.setText(t)
+ self.LEFiltre.setText("")
+ self.listeCbRouge = []
+
+
+# ----------- #
+class GerePlie(object):
+ # ----------- #
+
+ def gereIconePlier(self):
+ if not (hasattr(self, "BFermeListe")):
+ return
+ self.editor.listeDesListesOuvertes.add(self.node.item)
+ repIcon = self.node.editor.appliEficas.repIcon
+ if not (self.editor.afficheListesPliees):
+ fichier = os.path.join(repIcon, "empty.png")
+ icon = QIcon(fichier)
+ self.BFermeListe.setIcon(icon)
+ return
+ fichier = os.path.join(repIcon, "minusnode.png")
+ icon = QIcon(fichier)
+ self.BFermeListe.setIcon(icon)
+ self.BFermeListe.clicked.connect(self.selectWidgetPlie)
+
+ def selectWidgetPlie(self):
+ self.editor.listeDesListesOuvertes.remove(self.node.item)
+ self.reaffichePourDeplier()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from PyQt5.QtCore import Qt
+from .monViewRegles import ViewRegles
+from Extensions.i18n import tr
+
+
+class GereRegles(object):
+ def appellebuildLBRegles(self):
+ from .browser import JDCTree
+
+ if isinstance(self, JDCTree):
+ self.appellebuildLBReglesForJdC()
+ else:
+ self.appellebuildLBReglesForCommand()
+ self.buildLBRegles(self.listeRegles, self.listeNomsEtapes)
+ self.afficheRegles()
+
+ def appellebuildLBReglesForCommand(self):
+ self.listeRegles = self.item.getRegles()
+ self.listeNomsEtapes = self.item.getMcPresents()
+
+ def appellebuildLBReglesForJdC(self):
+ self.listeRegles = self.item.getRegles()
+ self.listeNomsEtapes = self.item.getLNomsEtapes()
+
+ def buildLBRegles(self, listeRegles, listeNomsEtapes):
+ self.liste = []
+ if len(listeRegles) > 0:
+ for regle in listeRegles:
+ texteRegle = regle.getText()
+ texteMauvais, test = regle.verif(listeNomsEtapes)
+ for ligne in texteRegle.split("\n"):
+ if ligne == "":
+ continue
+ if ligne[0] == "\t":
+ ligne = " " + ligne[1:]
+ if test:
+ self.liste.append((ligne, Qt.black))
+ else:
+ self.liste.append((ligne, Qt.red))
+ self.liste.append(("", Qt.red))
+ if self.liste == []:
+ self.liste.append(
+ ("pas de regle de construction pour ce jeu de commandes", Qt.black)
+ )
+
+ def afficheRegles(self):
+ titre = "Regles pour " + self.item.nom
+ w = ViewRegles(self.editor, self.liste, titre)
+ w.exec_()
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+import os
+from PyQt5.QtWidgets import QFileDialog, QApplication
+from Extensions.i18n import tr
+
+
+def traduction(directPath, editor, version):
+ if version == "V9V10":
+ from Traducteur import traduitV9V10
+
+ suffixe = "v10.comm"
+ if version == "V10V11":
+ from Traducteur import traduitV10V11
+
+ suffixe = "v11.comm"
+ if version == "V11V12":
+ from Traducteur import traduitV11V12
+
+ suffixe = "v12.comm"
+
+ fn = QFileDialog.getOpenFileName(
+ editor.appliEficas,
+ tr("Traduire Fichier"),
+ directPath,
+ tr("Fichiers JDC (*.comm);;" "Tous les Fichiers (*)"),
+ )
+
+ fn = fn[0]
+ FichieraTraduire = str(fn)
+ if FichieraTraduire == "" or FichieraTraduire == ():
+ return
+ i = FichieraTraduire.rfind(".")
+ Feuille = FichieraTraduire[0:i]
+ FichierTraduit = Feuille + suffixe
+
+ i = Feuille.rfind("/")
+ directLog = Feuille[0:i]
+ log = directLog + "/convert.log"
+ os.system("rm -rf " + log)
+ os.system("rm -rf " + FichierTraduit)
+
+ QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ if version == "V9V10":
+ traduitV9V10.traduc(FichieraTraduire, FichierTraduit, log)
+ if version == "V10V11":
+ traduitV10V11.traduc(FichieraTraduire, FichierTraduit, log)
+ if version == "V11V12":
+ traduitV11V12.traduc(FichieraTraduire, FichierTraduit, log)
+ QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
+
+ Entete = tr("Fichier Traduit : %s\n\n", str(FichierTraduit))
+ if os.stat(log)[6] != 0:
+ f = open(log)
+ texte = f.read()
+ f.close()
+ else:
+ texte = Entete
+ commande = "diff " + FichieraTraduire + " " + FichierTraduit + " >/dev/null"
+ try:
+ if os.system(commande) == 0:
+ texte = texte + tr(
+ "Pas de difference entre le fichier origine et le fichier traduit"
+ )
+ except:
+ pass
+
+ from .monVisu import DVisu
+
+ titre = "conversion de " + FichieraTraduire
+ monVisuDialg = DVisu(parent=editor.appliEficas, fl=0)
+ monVisuDialg.setWindowTitle(titre)
+ monVisuDialg.TB.setText(texte)
+ monVisuDialg.show()
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from PyQt5.QtWidgets import QWidget, QSpacerItem, QSizePolicy
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+
+from .gereIcones import FacultatifOuOptionnel
+import traceback
+
+
+# Import des panels
+
+
+class Groupe(QWidget, FacultatifOuOptionnel):
+ """ """
+
+ def __init__(self, node, editor, parentQt, definition, obj, niveau, commande=None):
+ # print ("groupe : ",self.node.item.nom," ",self.node.fenetre)
+ QWidget.__init__(self, None)
+ self.node = node
+ self.node.fenetre = self
+ self.setupUi(self)
+ self.editor = editor
+ self.obj = obj
+ self.niveau = niveau
+ self.definition = definition
+ self.parentQt = parentQt
+ self.maCommande = commande
+ self.listeFocus = []
+ self.appliEficas = self.editor.appliEficas
+ self.repIcon = self.appliEficas.repIcon
+ self.jdc = self.node.item.getJdc()
+ self.setIconePoubelle()
+ self.setIconesGenerales()
+ self.setRun()
+ self.setValide()
+ self.setReglesEtAide()
+ self.afficheMots()
+ self.listeMCAAjouter = []
+ self.dictMCVenantDesBlocs = {}
+ if hasattr(self, "RBDeplie"):
+ self.RBDeplie.clicked.connect(self.setDeplie)
+ if hasattr(self, "RBPlie"):
+ self.RBPlie.clicked.connect(self.setPlie)
+
+ self.setAcceptDrops(True)
+ # if hasattr (self, 'commandesLayout'):
+ # print (' j ajoute un spacer dans ', self.node.item.nom)
+ # spacerItem = QSpacerItem(20, 5, QSizePolicy.Minimum, QSizePolicy.Expanding)
+ # self.commandesLayout.addItem(spacerItem)
+
+ def donneFocus(self):
+ for fenetre in self.listeFocus:
+ if fenetre == None:
+ return
+ if fenetre.node.item.isValid() == 0:
+ fenetre.prendLeFocus = 1
+ fenetre.hide()
+ fenetre.show()
+
+ def afficheMots(self):
+ # print ("ds afficheMots ",self.node.item.nom,self.node.plie)
+ for node in self.node.children:
+ # non return mais continue car il faut tenir compte des blocs
+ if node.appartientAUnNoeudPlie == True:
+ continue
+ widget = node.getPanelGroupe(self, self.maCommande)
+ # print ("widget pour ", node.item.nom, widget)
+ self.listeFocus.append(node.fenetre)
+ # print "fin pour " , self.node.item.nom
+
+ def calculOptionnel(self):
+ self.listeMc = []
+ self.listeMcRegle = []
+ self.dictToolTipMc = {}
+ genea = self.obj.getGenealogie()
+ # Attention : les mots clefs listes (+sieurs fact )
+ # n ont pas toutes ces methodes
+ try:
+ # if 1 :
+ self.listeMc = self.obj.getListeMcOrdonnee(
+ genea, self.jdc.cata_ordonne_dico
+ )
+ listeNomsPresents = self.obj.dictMcPresents()
+ for regle in self.obj.getRegles():
+ (monToolTip, regleOk) = regle.verif(listeNomsPresents)
+ if regleOk:
+ continue
+ for mc in regle.mcs:
+ self.listeMcRegle.append(mc)
+ self.dictToolTipMc[mc] = monToolTip
+ except:
+ # print ('in except')
+ # print (self)
+ return
+
+ def afficheOptionnel(self):
+ if self.editor.maConfiguration.closeOptionnel:
+ return
+ liste, liste_rouge = self.ajouteMCOptionnelDesBlocs()
+ self.monOptionnel = self.editor.widgetOptionnel
+ self.monOptionnel.afficheOptionnel(liste, liste_rouge, self)
+
+ def ajouteMCOptionnelDesBlocs(self):
+ self.dictMCVenantDesBlocs = {}
+ i = 0
+ self.calculOptionnel()
+ liste = self.listeMc
+ liste_rouge = self.listeMcRegle
+ for MC in self.listeMc:
+ self.dictMCVenantDesBlocs[MC] = self
+ # ce cas est le cas machine tournant sr le plie
+ try:
+ while i < self.commandesLayout.count():
+ from .monWidgetBloc import MonWidgetBloc
+
+ widget = self.commandesLayout.itemAt(i).widget()
+ i = i + 1
+ if not (isinstance(widget, MonWidgetBloc)):
+ continue
+ widget.calculOptionnel()
+ listeW, listeW_rouge = widget.ajouteMCOptionnelDesBlocs()
+ for MC in widget.dictMCVenantDesBlocs:
+ if MC in self.dictMCVenantDesBlocs:
+ print("Pb Sur les MC")
+ else:
+ self.dictMCVenantDesBlocs[MC] = widget.dictMCVenantDesBlocs[MC]
+ liste = liste + listeW
+ liste_rouge = liste_rouge + listeW_rouge
+ except:
+ pass
+ return (liste, liste_rouge)
+
+ def reaffiche(self, nodeAVoir=None):
+ # print "dans reaffiche de groupe.py", nodeAVoir
+ self.parentQt.reaffiche(nodeAVoir)
+
+ def recalculeListeMC(self, listeMC):
+ # print "pas si peu utile"
+ # on ajoute et on enleve
+ listeNode = []
+ for name in listeMC:
+ nodeAEnlever = self.node.appendChild(name)
+ if nodeAEnlever.item.isMCList():
+ nodeAEnlever = nodeAEnlever.children[-1]
+ listeNode.append(nodeAEnlever)
+ self.afficheOptionnel()
+ self.monOptionnel.affiche(self.listeMc)
+ if len(listeNode) == 0:
+ return
+ if len(listeNode) == 1:
+ listeNode[0].delete()
+ self.editor.afficheInfos("")
+ return
+ for noeud in listeNode:
+ noeud.treeParent.item.suppItem(noeud.item)
+ noeud.treeParent.buildChildren()
+ self.editor.afficheInfos("")
+
+ def ajoutMC(self, texteListeNom):
+ listeNom = texteListeNom.split("+")[1:]
+ firstNode = None
+ for nom in listeNom:
+ if nom not in self.dictMCVenantDesBlocs:
+ # print "bizarre, bizarre"
+ self.editor.initModif()
+ nouveau = self.node.appendChild(nom)
+ else:
+ self.editor.initModif()
+ widget = self.dictMCVenantDesBlocs[nom]
+ nouveau = widget.node.appendChild(nom)
+ if firstNode == None:
+ firstNode = nouveau
+ if nouveau == None or nouveau == 0:
+ self.editor.afficheInfos(
+ tr("insertion impossible a cet endroit pour " + nom), Qt.red
+ )
+ try:
+ self.reaffiche(firstNode)
+ if firstNode != None and firstNode != 0 and firstNode.item != None:
+ firstNode.select()
+ except:
+ pass
+
+ def setPlie(self):
+ self.node.setPlie()
+ self.reaffiche(self.node)
+
+ def setDeplie(self):
+ # print ('je passe ds setDeplie de groupe', self.obj.nom)
+ self.node.firstDeplie = False
+ self.node.setDeplie()
+ self.reaffiche(self.node)
+
+ def traiteClicSurLabel(self, texte):
+ if self.editor.code != "CARMELCND":
+ self.afficheOptionnel()
+ try:
+ fr = self.node.item.getFr()
+ self.editor.afficheCommentaire(str(fr))
+ except:
+ pass
+
+ def propageChange(self, leType, donneLefocus):
+ self.parentQt.propageChange(leType, donneLefocus)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+import re
+import os
+
+from PyQt5.QtWidgets import QToolButton, QToolTip
+from Extensions.i18n import tr
+
+class MonBoutonValide(QToolButton):
+ def __init__(self, parent):
+ QToolButton.__init__(self, parent)
+ while not (hasattr(parent, "node")):
+ parent = parent.parent()
+ self.parent = parent
+
+ def mouseDoubleClickEvent(self, event):
+ # print "dans mouseDoubleClickEvent"
+ strAide = self.parent.node.item.object.getFr()
+ if hasattr(self.parent.node.item.object.definition, "defaut"):
+ strAide += "\ndefaut : \n" + str(
+ self.parent.node.item.object.definition.defaut
+ )
+ strRapport = str(self.parent.node.item.object.report())
+ self.parent.editor._viewText(strAide + "\n" + strRapport, "JDC_RAPPORT")
+
+ def mousePressEvent(self, event):
+ # print "dans mousePressEvent"
+ if self.parent.node.item.object.isValid():
+ myToolTip = tr("objet valide")
+ if self.parent.editor.maConfiguration.differencieSiDefaut:
+ if hasattr(self.parent.node.item.object.definition, "defaut"):
+ if (
+ self.parent.node.item.object.valeur
+ != self.parent.node.item.object.definition.defaut
+ ):
+ myToolTip += "\ndefaut : \n" + str(
+ self.parent.node.item.object.definition.defaut
+ )
+
+ QToolTip.showText(event.globalPos(), myToolTip)
+ else:
+ t = ""
+ texte = self.parent.node.item.object.report().report()
+ deb = 1
+ for l in texte.split("\n")[2:-2]:
+ if re.match("^[\t !]*$", l):
+ continue
+ if re.match("^ *Fin Mot-cl", l):
+ continue
+ if re.match("^ *D?but Mot-cl", l):
+ continue
+ if re.match("^ *Mot-cl", l):
+ continue
+ l = l.replace("!", "")
+ if deb:
+ deb = 0
+ t = l
+ else:
+ t = t + "\n" + l
+ myToolTip = tr(t)
+ QToolTip.showText(event.globalPos(), myToolTip)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from desChoixCata import Ui_DChoixCata
+from PyQt5.QtWidgets import QDialog
+from Extensions.i18n import tr
+
+# Import des panels
+class MonChoixCata(Ui_DChoixCata, QDialog):
+ """ """
+
+ def __init__(self, QWparent, listeCata, title=None):
+ QDialog.__init__(self, QWparent)
+ self.setModal(True)
+ self.setupUi(self)
+ self.CBChoixCata.addItems(listeCata)
+ self.TLNb.setText(
+ tr("%d versions du catalogue sont disponibles", len(listeCata))
+ )
+ if title is not None:
+ self.setWindowTitle(tr(title))
+ self.buttonOk.clicked.connect(self.cataChoisi)
+ self.buttonCancel.clicked.connect(self.sortSansChoix)
+
+ def sortSansChoix(self):
+ QDialog.reject(self)
+
+ def cataChoisi(self):
+ QDialog.accept(self)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+
+import os, sys, re
+from desChoixCode import Ui_ChoixCode
+from PyQt5.QtWidgets import QDialog, QRadioButton, QGroupBox, QButtonGroup
+from PyQt5.QtGui import QPalette
+from PyQt5.QtCore import QProcess, QFileInfo, Qt, QSize
+
+
+# Import des panels
+
+
+class MonChoixCode(Ui_ChoixCode, QDialog):
+ """
+ Classe definissant le panel associe aux mots-cles qui demandent
+ a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
+ discretes
+ """
+
+ def __init__(self, appliEficas=None):
+ QDialog.__init__(self, parent=appliEficas, flags=Qt.Window)
+ self.setModal(True)
+ self.setupUi(self)
+ self.appliEficas = appliEficas
+ self.verifieInstall()
+ self.code = None
+ self.buttonBox.accepted.disconnect(self.accept)
+ self.buttonBox.accepted.connect(self.choisitCode)
+
+ # self.pB_OK.clicked.connect(self.choisitCode)
+ # self.pB_cancel.clicked.connect(self.sortie)
+
+ def sortie(self):
+ QDialog.reject(self)
+
+ def verifieInstall(self):
+ self.groupCodes = QButtonGroup(self.groupBox)
+ vars = list(os.environ.items())
+ listeCode = ("Telemac", "ReacteurNumerique", "Adao")
+ for code in listeCode:
+ dirCode = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "../..", code)
+ )
+ try:
+ l = os.listdir(dirCode)
+ bouton = QRadioButton(self.groupBox)
+ bouton.setText(code)
+ self.groupCodes.addButton(bouton)
+ self.vlBouton.insertWidget(0, bouton)
+ except:
+ clef = "PREFS_CATA_" + code
+ try:
+ repIntegrateur = os.path.abspath(os.environ[clef])
+ l = os.listdir(repIntegrateur)
+ bouton = QRadioButton(self.groupBox)
+ bouton.setText(code)
+ bouton.show()
+ self.groupCodes.addButton(bouton)
+ except:
+ pass
+ listeCodesIntegrateur = []
+ for k, v in vars:
+ if re.search("^PREFS_CATA_", k) != None and k[11:] not in listeCode:
+ listeCodesIntegrateur.append(k[11:])
+ for code in listeCodesIntegrateur:
+ try:
+ clef = "PREFS_CATA_" + code
+ repIntegrateur = os.path.abspath(os.environ[clef])
+ l = os.listdir(repIntegrateur)
+ bouton = QRadioButton(self)
+ bouton.setText(code)
+ bouton.show()
+ self.groupCodes.addButton(bouton)
+ except:
+ pass
+ self.appliEficas.listeCode = self.appliEficas.listeCode + listeCodesIntegrateur
+
+ def choisitCode(self):
+ bouton = self.groupCodes.checkedButton()
+ if bouton == None:
+ return
+ code = str(bouton.text())
+ codeUpper = code.upper()
+ self.appliEficas.code = codeUpper
+ try:
+ dirCode = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "../..", code)
+ )
+ l = os.listdir(dirCode)
+ sys.path.insert(0, dirCode)
+ except:
+ clef = "PREFS_CATA_" + code
+ repIntegrateur = os.path.abspath(os.environ[clef])
+ l = os.listdir(repIntegrateur)
+ sys.path.insert(0, repIntegrateur)
+ self.close()
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from desChoixCommandes import Ui_ChoixCommandes
+from PyQt5.QtWidgets import QWidget, QButtonGroup, QRadioButton, QLabel, QPushButton, QGridLayout
+from PyQt5.QtGui import QIcon, QPixmap
+from PyQt5.QtCore import QSize, QRect
+
+from Extensions.i18n import tr
+import os
+
+
+class MonChoixCommande(Ui_ChoixCommandes, QWidget):
+ """ """
+
+ def __init__(self, node, jdc_item, editor):
+ QWidget.__init__(self, parent=None)
+ self.setupUi(self)
+
+ self.repIcon = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), "..", "Editeur", "icons"
+ )
+ iconeFile = os.path.join(self.repIcon, "lettreRblanc30.png")
+ icon = QIcon(iconeFile)
+ self.RBRegle.setIcon(icon)
+ self.RBRegle.setIconSize(QSize(21, 31))
+
+ self.item = jdc_item
+ self.node = node
+ self.editor = editor
+ self.simpleClic = self.editor.maConfiguration.simpleClic
+ self.jdc = self.item.object.getJdcRoot()
+ debutTitre = self.editor.titre
+ self.listeWidget = []
+ self.dicoCmd = {}
+ if self.editor.fichier != None:
+ nouveauTitre = debutTitre + " " + os.path.basename(self.editor.fichier)
+ else:
+ nouveauTitre = debutTitre
+ self.editor.appliEficas.setWindowTitle(nouveauTitre)
+
+ self.RBalpha.clicked.connect(self.afficheAlpha)
+ self.RBGroupe.clicked.connect(self.afficheGroupe)
+ self.RBOrdre.clicked.connect(self.afficheOrdre)
+ self.RBClear.clicked.connect(self.clearFiltre)
+ self.RBCasse.toggled.connect(self.ajouteRadioButtons)
+ self.LEFiltre.returnPressed.connect(self.ajouteRadioButtons)
+ self.LEFiltre.textChanged.connect(self.ajouteRadioButtons)
+
+ if self.node.tree.item.getRegles() == ():
+ self.RBRegle.close()
+ self.labelRegle.close()
+ else:
+ self.RBRegle.clicked.connect(self.afficheRegle)
+
+ if self.editor.readercata.ordreDesCommandes == None:
+ self.RBOrdre.close()
+
+ # self.editor.labelCommentaire.setText("")
+ if self.editor.widgetOptionnel != None:
+ self.editor.fermeOptionnel()
+ self.editor.widgetOptionnel = None
+ self.name = None
+
+ self.boolAlpha = 0
+ self.boolGroupe = 0
+ self.boolOrdre = 0
+ if self.editor.maConfiguration.affiche == "alpha":
+ self.boolAlpha == 1
+ self.RBalpha.setChecked(True)
+ self.afficheAlpha()
+ elif self.editor.maConfiguration.affiche == "groupe":
+ self.boolGroupe == 1
+ self.RBGroupe.setChecked(True)
+ self.afficheGroupe()
+ elif self.editor.maConfiguration.affiche == "ordre":
+ self.boolOrdre == 1
+ self.RBOrdre.setChecked(True)
+ self.afficheOrdre()
+ if (
+ self.editor.maConfiguration.closeFrameRechercheCommandeSurPageDesCommandes
+ == True
+ ):
+ self.frameAffichage.close()
+
+ if self.editor.widgetTree != None:
+ self.editor.restoreSplitterSizes(2)
+ else:
+ self.editor.restoreSplitterSizes(3)
+
+ def afficheRegle(self):
+ self.node.tree.appellebuildLBRegles()
+
+ def afficheAlpha(self):
+ self.boolAlpha = 1
+ self.boolGroupe = 0
+ self.boolOrdre = 0
+ self.ajouteRadioButtons()
+
+ def afficheGroupe(self):
+ self.boolAlpha = 0
+ self.boolGroupe = 1
+ self.boolOrdre = 0
+ self.ajouteRadioButtons()
+
+ def afficheOrdre(self):
+ self.boolAlpha = 0
+ self.boolGroupe = 0
+ self.boolOrdre = 1
+ self.ajouteRadioButtons()
+
+ def insereNoeudApresClick(self, event):
+ # print self.editor.Classement_Commandes_Ds_Arbre
+ # if self.editor.Classement_Commandes_Ds_Arbre!= () : self.chercheOu()
+ # print ('dans insereNoeudApresClick')
+ nodeCourrant = self.node.tree.currentItem()
+ if nodeCourrant == None:
+ nodeCourrant = self.node.tree.racine
+ if self.name != None:
+ plier = self.editor.maConfiguration.afficheCommandesPliees
+ if nodeCourrant == self.node:
+ nouveau = self.node.appendChild(self.name, "first", plier)
+ else:
+ nouveau = nodeCourrant.appendBrother(self.name, plier=plier)
+ else:
+ nouveau = 0
+ # on n a pas insere le noeud
+ if nouveau == 0: return
+
+ nouveau.setDeplie()
+ # if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
+ if self.editor.afficheApresInsert == True:
+ # if self.editor.affichePlie==True: nouveau.plieToutEtReaffiche()
+ if self.editor.maConfiguration.afficheCommandesPliees == True:
+ nouveau.plieToutEtReaffiche()
+ else:
+ nouveau.deplieToutEtReaffiche()
+ nouveau.fenetre.donnePremier()
+ # nouveau.deplieToutEtReaffiche()
+ else:
+ self.node.setSelected(False)
+ nouveau.setSelected(True)
+ self.node.tree.setCurrentItem(nouveau)
+ if event != None:
+ event.accept()
+
+ def creeListeCommande(self, filtre):
+ listeGroupes, dictGroupes = self.jdc.getGroups()
+ sensibleALaCasse = self.RBCasse.isChecked()
+ if "CACHE" in dictGroupes:
+ aExclure = list(dictGroupes["CACHE"])
+ else:
+ aExclure = []
+ listeACreer = []
+ listeEtapesDejaPresentes = []
+ if self.editor.maConfiguration.rendVisiblesLesCaches:
+ for e in self.jdc.etapes:
+ listeEtapesDejaPresentes.append(e.nom)
+ for c in aExclure:
+ if c not in listeEtapesDejaPresentes:
+ aExclure.remove(c)
+ # for e in self.jdc.etapes:
+ # print (e.nom)
+ # print (e.definition.repetable)
+ # if e.definition.repetable == 'n' : aExclure.append(e.nom)
+ # print (aExclure)
+ for l in self.jdc.getListeCmd():
+ if l not in aExclure:
+ if sensibleALaCasse and (filtre != None and not filtre in l):
+ continue
+ if (
+ (not sensibleALaCasse)
+ and filtre != None
+ and (not filtre in l)
+ and (not filtre.upper() in l)
+ ):
+ continue
+ listeACreer.append(l)
+ return listeACreer
+
+ def ajouteRadioButtons(self):
+ if self.editor.maConfiguration.nombreDeBoutonParLigne != 0:
+ self.ajoutePushButtons()
+ return
+ # print 'ds ajouteRadioButtons'
+ filtre = str(self.LEFiltre.text())
+ if filtre == str(""):
+ filtre = None
+ if hasattr(self, "buttonGroup"):
+ for b in self.buttonGroup.buttons():
+ self.buttonGroup.removeButton(b)
+ b.setParent(None)
+ b.close()
+ else:
+ self.buttonGroup = QButtonGroup()
+ for w in self.listeWidget:
+ w.setParent(None)
+ w.close()
+ self.listeWidget = []
+ if self.boolAlpha == 1:
+ liste = self.creeListeCommande(filtre)
+ for cmd in liste:
+ self.dicoCmd[tr(cmd)] = cmd
+ rbcmd = QRadioButton(tr(cmd))
+ self.buttonGroup.addButton(rbcmd)
+ self.commandesLayout.addWidget(rbcmd)
+ # if self.simpleClic : rbcmd.mouseReleaseEvent=self.insereNoeudApresClick
+ # else : rbcmd.mouseDoubleClickEvent=self.insereNoeudApresClick
+ # self.buttonGroup.buttonClicked.connect(self.rbClique)
+ if not (self.simpleClic):
+ rbcmd.mouseDoubleClickEvent = self.insereNoeudApresClick
+ if self.simpleClic:
+ self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
+ else:
+ self.buttonGroup.buttonClicked.connect(self.rbClique)
+ elif self.boolGroupe == 1:
+ listeGroupes, dictGroupes = self.jdc.getGroups()
+ for grp in listeGroupes:
+ if grp == "CACHE":
+ continue
+ label = QLabel(self)
+ text = tr(
+ '<html><head/><body><p><span style=" font-weight:600;">Groupe : '
+ + tr(grp)
+ + "</span></p></body></html>"
+ )
+ label.setText(text)
+ self.listeWidget.append(label)
+ aAjouter = 1
+ sensibleALaCasse = self.RBCasse.isChecked()
+ for cmd in dictGroupes[grp]:
+ if sensibleALaCasse and (filtre != None and not filtre in cmd):
+ continue
+ if (
+ (not sensibleALaCasse)
+ and filtre != None
+ and (not filtre in cmd)
+ and (not filtre.upper() in cmd)
+ ):
+ continue
+ if aAjouter == 1:
+ self.commandesLayout.addWidget(label)
+ aAjouter = 0
+ self.dicoCmd[tr(cmd)] = cmd
+ rbcmd = QRadioButton(tr(cmd))
+ self.buttonGroup.addButton(rbcmd)
+ self.commandesLayout.addWidget(rbcmd)
+ if not (self.simpleClic):
+ rbcmd.mouseDoubleClickEvent = self.insereNoeudApresClick
+ if self.simpleClic:
+ self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
+ else:
+ self.buttonGroup.buttonClicked.connect(self.rbClique)
+ label2 = QLabel(self)
+ label2.setText(" ")
+ self.listeWidget.append(label2)
+ self.commandesLayout.addWidget(label2)
+ elif self.boolOrdre == 1:
+ listeFiltre = self.creeListeCommande(filtre)
+ liste = []
+ if self.editor.readercata.ordreDesCommandes == None:
+ ordreDesCommandes = listeFiltre
+ else:
+ ordreDesCommandes = self.editor.readercata.ordreDesCommandes
+ for cmd in ordreDesCommandes:
+ if cmd in listeFiltre:
+ liste.append(cmd)
+ for cmd in liste:
+ self.dicoCmd[tr(cmd)] = cmd
+ rbcmd = QRadioButton(tr(cmd))
+ self.buttonGroup.addButton(rbcmd)
+ self.commandesLayout.addWidget(rbcmd)
+ if not (self.simpleClic):
+ rbcmd.mouseDoubleClickEvent = self.insereNoeudApresClick
+ if self.simpleClic:
+ self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
+ else:
+ self.buttonGroup.buttonClicked.connect(self.rbClique)
+
+ def ajoutePushButtons(self):
+ if hasattr(self, "buttonGroup"):
+ for b in self.buttonGroup.buttons():
+ self.buttonGroup.removeButton(b)
+ b.setParent(None)
+ b.close()
+ else:
+ self.buttonGroup = QButtonGroup()
+ self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
+ for w in self.listeWidget:
+ w.setParent(None)
+ w.close()
+ self.listeWidget = []
+
+ if not hasattr(self, "maGrilleBouton"):
+ # self.commandesLayout.close()
+ self.maGrilleBouton = QGridLayout()
+ self.maGrilleBouton.setSpacing(20)
+ self.verticalLayout.addLayout(self.maGrilleBouton)
+ col = -1
+ ligne = 0
+
+ if self.boolAlpha == 1:
+ liste = self.creeListeCommande(None)
+ elif self.boolOrdre:
+ liste = self.creeListeCommande(None)
+ listeFiltre = self.creeListeCommande(None)
+ liste = []
+ if self.editor.readercata.ordreDesCommandes == None:
+ ordreDesCommandes = listeFiltre
+ else:
+ ordreDesCommandes = self.editor.readercata.ordreDesCommandes
+ for cmd in ordreDesCommandes:
+ if cmd in listeFiltre:
+ liste.append(cmd)
+ elif self.boolGroupe:
+ # On considere que cela n a pas de sens de filtrer sur les groupes ou ?
+ return
+ for cmd in liste:
+ col = col + 1
+ if col == self.editor.maConfiguration.nombreDeBoutonParLigne:
+ col = 0
+ ligne = ligne + 1
+ self.dicoCmd[tr(cmd)] = cmd
+ rbcmd = QPushButton(tr(cmd))
+ rbcmd.setGeometry(QRect(40, 20, 211, 71))
+ rbcmd.setMaximumSize(QSize(250, 81))
+ rbcmd.setStyleSheet(
+ "background-color : rgb(66, 165, 238);\n"
+ "/*border-style : outset;*/\n"
+ "border-radius : 20px;\n"
+ "border-width : 30 px;\n"
+ "border-color : beige;\n"
+ "text-align : center"
+ )
+ # print ('self.editor.maConfiguration.dicoImages', self.editor.maConfiguration.dicoImages)
+ if cmd in self.editor.maConfiguration.dicoImages:
+ fichier = self.editor.maConfiguration.dicoImages[cmd]
+ icon = QIcon()
+ icon.addPixmap(QPixmap(fichier), QIcon.Normal, QIcon.Off)
+ rbcmd.setIcon(icon)
+ rbcmd.setIconSize(QSize(48, 48))
+
+ self.buttonGroup.addButton(rbcmd)
+ self.maGrilleBouton.addWidget(rbcmd, ligne, col)
+
+ def clearFiltre(self):
+ self.LEFiltre.setText("")
+ self.ajouteRadioButtons()
+
+ def rbCliqueEtInsere(self, id):
+ self.rbClique(id)
+ self.insereNoeudApresClick(None)
+
+ def rbClique(self, id):
+ try:
+ self.name = self.dicoCmd[id.text()]
+ except:
+ try:
+ self.name = self.dicoCmd[str(id.text())]
+ except:
+ print("pb d accent : contacter la maintenance")
+
+ definitionEtape = getattr(self.jdc.cata, self.name)
+ # commentaire=getattr(definitionEtape,self.jdc.lang)
+ try:
+ commentaire = getattr(definitionEtape, self.jdc.lang)
+ except:
+ try:
+ commentaire = getattr(definitionEtape, "ang")
+ except:
+ commentaire = ""
+ self.editor.afficheCommentaire(commentaire)
+
+ def setValide(self):
+ # PNPN a priori pas d icone mais peut-etre a faire
+ pass
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+
+import os, sys, re
+from desChoixLangue import Ui_ChoixLangue
+
+from PyQt5.QtWidgets import QDialog, QRadioButton, QGroupBox, QButtonGroup
+from PyQt5.QtGui import QPalette
+from PyQt5.QtCore import QProcess, QFileInfo, Qt, QSize
+
+
+# Import des panels
+
+
+class MonChoixLangue(Ui_ChoixLangue, QDialog):
+ """
+ Classe definissant le panel associe aux mots-cles qui demandent
+ a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
+ discretes
+ """
+
+ def __init__(self, appliEficas=None):
+ QDialog.__init__(self, appliEficas)
+ self.setModal(True)
+ self.setupUi(self)
+ self.appliEficas = appliEficas
+ self.installLangue()
+ self.code = None
+ self.pB_OK.clicked.connect(self.choisitLangue)
+
+ def installLangue(self):
+ if self.appliEficas.langue == "fr":
+ self.rbFrancais.setChecked(True)
+ else:
+ self.rbEnglish.setChecked(True)
+
+ def choisitLangue(self):
+ if self.rbFrancais.isChecked():
+ self.appliEficas.langue = "fr"
+ else:
+ self.appliEficas.langue = "ang"
+ self.close()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+from PyQt5.QtCore import Qt
+
+
+# Modules Eficas
+from .qtSaisie import SaisieValeur
+from monPlusieursBasePanel import MonPlusieursBasePanel
+
+from Extensions.i18n import tr
+
+# Import des panels
+
+
+class MonFonctionPanel(MonPlusieursBasePanel):
+ # Classe definissant le panel associee aux mots-cles qui demandent
+ # a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
+ # discretes
+ def __init__(self, node, parent=None, name=None, fl=0):
+ # print "MonFonctionPanel"
+ self.node = node
+ self.setNbValeurs()
+ MonPlusieursBasePanel.__init__(self, node, parent, name, fl)
+
+ def setNbValeurs(self):
+ self.nbValeurs = 1
+ if self.node.item.waitTuple() == 1:
+ for a in self.node.item.definition.type:
+ try:
+ self.nbValeurs = a.ntuple
+ break
+ except:
+ pass
+ genea = self.node.item.getGenealogie()
+ self.nbValeursASaisir = self.nbValeurs
+ if "VALE" in genea:
+ self.nbValeurs = 2
+ if "VALE_C" in genea:
+ self.nbValeurs = 3
+
+ def decoupeListeValeurs(self, liste):
+ # decoupe la liste des valeurs en n ( les x puis les y)
+ l_valeurs = []
+ if len(liste) % self.nbValeursASaisir != 0 and (len(liste) % self.nbValeurs):
+ message = tr(
+ "La cardinalite n'est pas correcte, la derniere valeur est ignoree"
+ )
+ self.editor.afficheInfos(message, Qt.red)
+ i = 0
+ while i < len(liste):
+ try:
+ t = tuple(liste[i : i + self.nbValeurs])
+ i = i + self.nbValeurs
+ except:
+ t = tuple(liste[i : len(liste)])
+ l_valeurs.append(t)
+ return l_valeurs
+
+ def buildLBValeurs(self, listeValeurs=None):
+ self.LBValeurs.clear()
+ if listeValeurs == None:
+ listeValeurs = self.node.item.getListeValeurs()
+ if self.node.item.waitTuple() == 1:
+ listeATraiter = listeValeurs
+ for valeur in listeATraiter:
+ str_valeur = str(valeur)
+ self.LBValeurs.addItem(str_valeur)
+ else:
+ for valeur in self.decoupeListeValeurs(listeValeurs):
+ if type(valeur) == tuple:
+ TupleEnTexte = "("
+ for val in valeur:
+ TupleEnTexte = (
+ TupleEnTexte
+ + str(self.politique.getValeurTexte(val))
+ + ", "
+ )
+ TupleEnTexte = TupleEnTexte[0:-2] + ")"
+ self.LBValeurs.addItem(TupleEnTexte)
+ else:
+ self.LBValeurs.addItem(str(valeur))
+
+ def ajout1Valeur(self, liste=[]):
+ # Pour etre appele a partir du Panel Importer (donc plusieurs fois par AjouterNValeur)
+ validite = 1
+ if liste == []:
+ if self.node.item.waitTuple() == 1:
+ liste = SaisieValeur.TraiteLEValeurTuple(self)
+ if liste == [""]:
+ return
+ else:
+ liste, validite = SaisieValeur.TraiteLEValeur(self)
+ if validite == 0:
+ return
+ if liste == []:
+ return
+
+ if self.node.item.waitTuple() == 1 and len(liste) != self.nbValeurs:
+ commentaire = str(liste)
+ commentaire += tr(" n est pas un tuple de ")
+ commentaire += str(self.nbValeursASaisir)
+ commentaire += tr(" valeurs")
+ self.LEValeur.setText(str(liste))
+ self.editor.afficheInfos(commentaire, Qt.red)
+ return
+
+ if self.node.item.waitTuple() == 1:
+ liste2 = tuple(liste)
+ liste = liste2
+
+ index = self.LBValeurs.currentRow()
+ if (self.LBValeurs.isItemSelected(self.LBValeurs.item(index)) == 0) and (
+ index > 0
+ ):
+ index = 0
+ else:
+ index = self.LBValeurs.currentRow() + 1
+ indexListe = index * self.nbValeurs
+ if index == 0:
+ indexListe = len(self.listeValeursCourantes)
+
+ listeVal = []
+ for valeur in self.listeValeursCourantes:
+ listeVal.append(valeur)
+ if self.node.item.waitTuple() == 1:
+ indexListe = index
+ validite, comm, comm2, listeRetour = self.politique.ajoutTuple(
+ liste, index, listeVal
+ )
+ else:
+ validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
+ liste, index, listeVal
+ )
+ self.Commentaire.setText(tr(comm2))
+ if not validite:
+ self.editor.afficheInfos(comm, Qt.red)
+ else:
+ self.LEValeur.setText("")
+ l1 = self.listeValeursCourantes[:indexListe]
+ l3 = self.listeValeursCourantes[indexListe:]
+ if self.node.item.waitTuple() == 1:
+ listeATraiter = listeRetour
+ else:
+ listeATraiter = self.decoupeListeValeurs(listeRetour)
+ for valeur in listeATraiter:
+ if type(valeur) == tuple:
+ TupleEnTexte = "("
+ for val in valeur:
+ TupleEnTexte = (
+ TupleEnTexte
+ + str(self.politique.getValeurTexte(val))
+ + ", "
+ )
+ str_valeur = TupleEnTexte[0:-2] + ")"
+ else:
+ str_valeur = str(valeur)
+ self.LBValeurs.insertItem(index, str_valeur)
+ item = self.LBValeurs.item(index)
+ item.setSelected(1)
+ self.LBValeurs.setCurrentItem(item)
+ index = index + 1
+ self.listeValeursCourantes = l1 + listeRetour + l3
+ self.buildLBValeurs(self.listeValeursCourantes)
+
+ def ajoutNValeur(self, liste):
+ if len(liste) % self.nbValeurs != 0:
+ texte = "Nombre de valeur incorrecte"
+ # self.Commentaire.setText(texte)
+ self.editor.afficheInfos(texte, Qt.red)
+ return
+ listeDecoupee = self.decoupeListeValeurs(liste)
+ for vals in listeDecoupee:
+ self.ajout1Valeur(vals)
+
+ def sup1Valeur(self):
+ index = self.LBValeurs.currentRow()
+ if index == None:
+ return
+ removed_item = self.LBValeurs.takeItem(index)
+ text = removed_item.text()[1:-1] # Remove the parenthesis
+ self.LEValeur.setText(text)
+ listeVal = []
+ indexInterdit = []
+ for i in range(self.nbValeurs):
+ indexAOter = index * self.nbValeurs + i
+ indexInterdit.append(indexAOter)
+ if self.node.item.waitTuple() == 1:
+ indexInterdit = [index]
+
+ i = 0
+ for valeur in self.listeValeursCourantes:
+ if not (i in indexInterdit):
+ listeVal.append(valeur)
+ i = i + 1
+ self.listeValeursCourantes = listeVal
+ listeValeurs = self.listeValeursCourantes
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+
+from PyQt5.QtWidgets import QCheckBox, QWidget, QLabel, QPushButton
+from PyQt5.QtCore import Qt, QRect
+from PyQt5.QtGui import QPalette
+
+from Extensions.i18n import tr
+from desGroupeOptionnel import Ui_groupeOptionnel
+from desPBOptionnelMT import Ui_customPB
+
+
+# Import des panels
+
+
+class MonRBButtonCustom(QCheckBox):
+ def __init__(self, texte, monOptionnel, parent=None, couleur=None):
+ QCheckBox.__init__(self, tr(texte), parent)
+ self.mousePressed = True
+ self.monOptionnel = monOptionnel
+ self.setToolTip(tr("clicker: affichage aide, double-click: ajout"))
+ if couleur != None:
+ mapalette = self.palette()
+ mapalette.setColor(QPalette.WindowText, couleur)
+ mapalette.setColor(QPalette.Base, Qt.green)
+ self.setPalette(mapalette)
+ self.setText(tr(texte))
+ try:
+ monToolTip = monOptionnel.parentMC.dictToolTipMc[texte]
+ self.setToolTip(monToolTip)
+ except:
+ pass
+
+ def mouseDoubleClickEvent(self, event):
+ # print "dans mouseDoubleClickEvent", self
+ if self not in self.monOptionnel.dicoCb:
+ event.accept()
+ return
+ listeCheckedMC = "+" + self.monOptionnel.dicoCb[self]
+ self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
+ event.accept()
+
+ def mousePressEvent(self, event):
+ if not (event.button() != Qt.RightButton):
+ event.accept()
+ return
+ if self.monOptionnel.cbPressed != None:
+ self.monOptionnel.cbPressed.setChecked(False)
+ self.monOptionnel.cbPressed = self
+ if self.mousePressed == False:
+ self.mousePressed = True
+ else:
+ self.mousePressed = False
+ self.ajoutAideMC()
+ QCheckBox.mousePressEvent(self, event)
+ event.accept()
+
+ def ajoutAideMC(self):
+ try:
+ maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
+ maLangue = self.monOptionnel.parentMC.jdc.lang
+ if hasattr(maDefinition, maLangue):
+ self.monAide = getattr(
+ maDefinition, self.monOptionnel.parentMC.jdc.lang
+ )
+ else:
+ self.monAide = ""
+ except:
+ self.monAide = ""
+ self.monOptionnel.parentMC.editor.afficheCommentaire(self.monAide)
+
+
+class MonPBButtonCustom(QWidget, Ui_customPB):
+ def __init__(self, texte, monOptionnel, parent=None, couleur=None):
+ QWidget.__init__(self)
+ self.setupUi(self)
+ if couleur != None:
+ self.monPb.setText(texte)
+ self.monPb.setStyleSheet(
+ "QPushButton {background-color: #A3C1DA; color: red;}"
+ )
+ # mapalette=self.monPb.palette()
+ # mapalette.setColor( QPalette.ButtonText, Qt.red )
+ # self.monPb.setPalette( mapalette )
+ self.monPb.update()
+ # self.update()
+ try:
+ monToolTip = monOptionnel.parentMC.dictToolTipMc[texte]
+ self.monPb.setToolTip(monToolTip)
+ except:
+ pass
+ self.monPb.setText(texte)
+ self.monPb.clicked.connect(self.ajoutMC)
+
+ self.texte = texte
+ self.monOptionnel = monOptionnel
+ self.definitAideMC()
+ self.setToolTip(self.monAide)
+
+ def ajoutMC(self):
+ listeCheckedMC = "+" + self.monOptionnel.dicoCb[self]
+ self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
+
+ def definitAideMC(self):
+ try:
+ maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
+ maLangue = self.monOptionnel.parentMC.jdc.lang
+ if hasattr(maDefinition, maLangue):
+ self.monAide = getattr(
+ maDefinition, self.monOptionnel.parentMC.jdc.lang
+ )
+ except:
+ self.monAide = ""
+
+
+class MonGroupeOptionnel(QWidget, Ui_groupeOptionnel):
+ """ """
+
+ def __init__(self, liste, liste_rouge, parentQt, parentMC):
+ # print ("dans init de monWidgetOptionnel ", parentQt, liste,parentMC)
+ QWidget.__init__(self, None)
+ self.setupUi(self)
+ self.listeChecked = []
+ self.dicoCb = {}
+ self.mousePressed = False
+ self.cbPressed = None
+ self.cb = None
+ self.parentQt = parentQt
+ self.parentMC = parentMC
+
+ if liste != []:
+ self.affiche(liste, liste_rouge)
+ self.afficheTitre()
+ elif self.parentQt.parentQt.maConfiguration.afficheOptionnelVide != False:
+ self.afficheTitre()
+ self.MCOptionnelLayout.insertWidget(0, QLabel(tr("Pas de MC Optionnel")))
+ else:
+ self.frameLabelMC.close()
+ # print "dans fin de monWidgetOptionnel ", parentQt
+
+ def afficheTitre(self):
+ labeltext, fonte, couleur = self.parentMC.node.item.getLabelText()
+ # print (labeltext)
+ l = tr(labeltext)
+ li = []
+ while len(l) > 25:
+ li.append(l[0:24])
+ l = l[24:]
+ li.append(l)
+ texte = ""
+ for l in li:
+ texte += l + "\n"
+ texte = texte[0:-1]
+ self.MCLabel.setText(texte)
+
+ def affiche(self, liste, liste_rouge):
+ # print ("dans Optionnel ____ affiche", liste,liste_rouge)
+ self.dicoCb = {}
+ liste.reverse()
+ for mot in liste:
+ # if mot in liste_rouge : print ('je dois afficher en rouge' , mot)
+ couleur = None
+ if mot in liste_rouge:
+ couleur = Qt.red
+ if self.parentQt.parentQt.maConfiguration.simpleClic == False:
+ cb = MonRBButtonCustom(mot, self, couleur=couleur)
+ cb.clicked.connect(cb.ajoutAideMC)
+ else:
+ cb = MonPBButtonCustom(mot, self, couleur=couleur)
+
+ self.MCOptionnelLayout.insertWidget(0, cb)
+ self.dicoCb[cb] = mot
+ self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import os
+
+from PyQt5.QtWidgets import QLabel, QFrame
+from PyQt5.QtCore import QEvent
+from Extensions.i18n import tr
+
+
+class MonLabelClic(QLabel):
+ def __init__(self, parent):
+ QLabel.__init__(self, parent)
+ # Pas propre mais impossible de faire fonctionner isinstance sur Groupe, MonWidgetCommande
+ # PNPNPN ? a ameliorer
+ if isinstance(parent, QFrame):
+ parent = parent.parent()
+ while not (hasattr(parent, "traiteClicSurLabel")):
+ try:
+ parent = parent.parent()
+ except:
+ print("pb avec MonLabelClic")
+ break
+ self.parent = parent
+
+ def event(self, event):
+ if event.type() == QEvent.MouseButtonRelease:
+ self.texte = self.text()
+ self.parent.traiteClicSurLabel(self.texte)
+ return QLabel.event(self, event)
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from PyQt5.QtWidgets import QButtonGroup, QToolButton
+from PyQt5.QtGui import QIcon, QPixmap
+from Extensions.i18n import tr
+
+
+# ----------------------
+class MonLayoutBouton:
+ # ----------------------
+
+ # -------------------------------
+ def __init__(self, appliEficas):
+ # -------------------------------
+
+ self.appliEficas = appliEficas
+ self.buttonGroup = QButtonGroup()
+
+ for etape in self.appliEficas.readercata.cata.JdC.commandes:
+ nomEtape = etape.nom
+ toolButton = QToolButton(self.appliEficas.toolBarCommande)
+ icon = QIcon()
+ if nomEtape in self.appliEficas.maConfiguration.dicoIcones:
+ fichier = self.appliEficas.maConfiguration.dicoIcones[nomEtape]
+ icon.addPixmap(QPixmap(fichier), QIcon.Normal, QIcon.Off)
+ toolButton.setIcon(icon)
+ else:
+ try:
+ label = nomEtape[0:3]
+ except:
+ label = nomEtape
+ toolButton.setText(label)
+
+ action = self.appliEficas.toolBarCommande.addWidget(toolButton)
+ action.setVisible(True)
+ toolButton.setObjectName(nomEtape)
+ toolButton.setToolTip(tr(nomEtape))
+ self.buttonGroup.addButton(toolButton)
+
+ self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
+
+ def rbCliqueEtInsere(self, id):
+ self.appliEficas.handleAjoutEtape(id.objectName())
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from desRecherche import Ui_desRecherche
+from PyQt5.QtWidgets import QDialog
+from PyQt5.QtCore import Qt
+
+
+# Import des panels
+class DRecherche(Ui_desRecherche, QDialog):
+ """ """
+
+ def __init__(self, parent=None, name=None, fl=0):
+ QDialog.__init__(self, parent)
+ self.parentQT = parent
+ self.tree = self.parentQT.tree
+ self.setupUi(self)
+ self.PBSuivant.setDefault(True)
+ self.PBSuivant.setAutoDefault(False)
+ self.PBSuivant.clicked.connect(self.suivantClicked)
+ self.LERecherche.returnPressed.connect(self.recherche)
+ self.surLigne = 0
+ self.listeTrouvee = ()
+ self.nodeSurligne = None
+
+ def suivantClicked(self):
+ # if self.motAChercher!=self.LERecherche.text(): self.recherche()
+ if self.listeTrouvee == {}:
+ return
+ if self.surLigne > len(self.listeTrouvee) - 1:
+ return
+ if self.nodeSurligne != None:
+ self.nodeSurligne.updateNodeTexteInBlack()
+ # self.listeTrouvee[self.surLigne].updateNodeTexteInBlue()
+ # self.nodeSurligne=self.listeTrouvee[self.surLigne]
+ self.listeTrouvee[self.surLigne].select()
+ self.listeTrouvee[self.surLigne].affichePanneau()
+ self.surLigne = self.surLigne + 1
+ self.PBSuivant.setFocus()
+ if self.surLigne == len(self.listeTrouvee):
+ self.surLigne = 0
+
+ def recherche(self):
+ self.motAChercher = self.LERecherche.text()
+ self.listeTrouvee = self.tree.findItems(
+ self.motAChercher, Qt.MatchContains | Qt.MatchRecursive, 0
+ )
+ self.surLigne = 0
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from desRechercheCatalogue import Ui_desRechercheCatalogue
+from PyQt5.QtWidgets import QDialog, QCompleter
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+
+# Import des panels
+
+
+class DRechercheCatalogue(Ui_desRechercheCatalogue, QDialog):
+ """ """
+
+ def __init__(self, parent, editor):
+ QDialog.__init__(self, parent)
+ # self.setModal(True)
+ self.setupUi(self)
+ self.editor = editor
+ self.CBRecherche.setEditable(True)
+ self.CBRecherche.lineEdit().returnPressed.connect(self.rechercheCB)
+ self.CBRecherche.currentIndexChanged.connect(self.rechercheCB)
+ self.CBRecherche.currentTextChanged.connect(self.rechercheCB)
+
+ self.initRecherche()
+
+ def initRecherche(self):
+ listeChoix = list(self.editor.readercata.dicoInverse.keys())
+ self.CBRecherche.addItem("")
+ for choix in listeChoix:
+ self.CBRecherche.addItem(choix)
+ monCompleteur = QCompleter(listeChoix, self)
+ monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
+ self.CBRecherche.setCompleter(monCompleteur)
+
+ def rechercheCB(self):
+ motAChercher = self.CBRecherche.lineEdit().text()
+ self.recherche(motAChercher)
+
+ def recherche(self, motAChercher):
+ if str(motAChercher) == "" or str(motAChercher) == None:
+ return
+ if str(motAChercher) not in self.editor.readercata.dicoInverse:
+ return
+ try:
+ # if 1 :
+ genea = self.editor.readercata.dicoInverse[str(motAChercher)]
+ listeGenea = []
+ for t in genea:
+ listeGenea.append(t[0])
+ listeGenea.reverse()
+ texte = ""
+ i = 0
+ for mc in listeGenea:
+ ligne = i * " " + str(mc) + " / " + tr(str(mc)) + "\n"
+ i = i + 1
+ texte += ligne
+ self.teGenea.setText(texte)
+ self.teDoc.setText(getattr(genea[0][1], self.editor.appliEficas.langue))
+
+ except:
+ pass
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from desSelectVal import Ui_DSelVal
+from Extensions.i18n import tr
+
+from PyQt5.QtWidgets import QDialog, QFileDialog, QMessageBox
+from PyQt5.QtCore import QTimer, Qt
+from PyQt5.QtGui import QPalette
+
+
+class DSelVal(Ui_DSelVal, QDialog):
+ def __init__(self, parent, modal):
+ QDialog.__init__(self, parent)
+ self.setupUi(self)
+
+
+class MonSelectVal(DSelVal):
+ """
+ Classe definissant le panel associe aux mots-cles qui demandent
+ a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
+ discretes
+ """
+
+ def __init__(self, file, parent, name=None, fl=0):
+ # print "MonSelectVal"
+ self.parent = parent
+ DSelVal.__init__(self, parent, 0)
+ self.separateur = " "
+ self.texte = " "
+ self.textTraite = ""
+ self.file = str(file)
+ self.readVal()
+ self.initVal()
+ self.connecterSignaux()
+
+ def connecterSignaux(self):
+ self.Bespace.clicked.connect(self.selectEsp)
+ self.BpointVirgule.clicked.connect(self.selectPoint)
+ self.Bvirgule.clicked.connect(self.selectVir)
+ self.BImportSel.clicked.connect(self.BImportSelPressed)
+ self.BImportTout.clicked.connect(self.BImportToutPressed)
+ self.parent.editor.sb.messageChanged.connect(self.messageAChanger)
+
+ def connecterSignauxQT4(self):
+ self.connect(self.Bespace, SIGNAL("clicked()"), self.selectEsp)
+ self.connect(self.BpointVirgule, SIGNAL("clicked()"), self.selectPoint)
+ self.connect(self.Bvirgule, SIGNAL("clicked()"), self.selectVir)
+ self.connect(self.BImportSel, SIGNAL("clicked()"), self.BImportSelPressed)
+ self.connect(self.BImportTout, SIGNAL("clicked()"), self.BImportToutPressed)
+ self.connect(
+ self.parent.editor.sb,
+ SIGNAL("messageChanged(QString)"),
+ self.messageAChanger,
+ )
+
+ def messageAChanger(self):
+ message = self.parent.editor.sb.currentMessage()
+ mapalette = self.sb.palette()
+ mapalette.setColor(QPalette.Text, Qt.red)
+ self.sb.setPalette(mapalette)
+ self.sb.setText(message)
+ QTimer.singleShot(3000, self.efface)
+
+ def efface(self):
+ self.sb.setText("")
+
+ def readVal(self):
+ if self.file == "":
+ return
+ try:
+ f = open(self.file, "r")
+ self.texte = f.read()
+ f.close()
+ except:
+ QMessageBox.warning(
+ self, tr("Fichier Indisponible"), tr("Lecture impossible")
+ )
+ self.texte = ""
+ return
+
+ def initVal(self):
+ self.TBtext.clear()
+ self.TBtext.setText(self.texte)
+
+ def selectEsp(self):
+ self.separateur = " "
+
+ def selectVir(self):
+ self.separateur = ","
+
+ def selectPoint(self):
+ self.separateur = ";"
+
+ def BImportSelPressed(self):
+ texte = self.TBtext.textCursor().selectedText()
+ textTraite = texte.replace("\u2029", "\n")
+ self.textTraite = str(textTraite)
+ self.traitement()
+
+ def BImportToutPressed(self):
+ self.textTraite = self.texte
+ self.traitement()
+
+ def traitement(self):
+ if self.textTraite == "":
+ return
+ if self.textTraite[-1] == "\n":
+ self.textTraite = self.textTraite[0:-1]
+ self.textTraite = self.textTraite.replace("\n", self.separateur)
+ liste1 = self.textTraite.split(self.separateur)
+ liste = []
+ for val in liste1:
+ if val != "" and val != " " and val != self.separateur:
+ val = str(val)
+ try:
+ # if 1 :
+ val2 = eval(val, {})
+ liste.append(val2)
+ except:
+ pass
+ self.parent.ajoutNValeur(liste)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+import traceback
+
+from Extensions.i18n import tr
+from PyQt5.QtCore import Qt
+from PyQt5.QtWidgets import QDialog, QListWidgetItem
+from desViewRegles import Ui_viewRegles
+
+
+# ------------------------------------ #
+class ViewRegles(Ui_viewRegles, QDialog):
+ # ------------------------------------ #
+ """
+ Classe permettant la visualisation de texte
+ """
+
+ def __init__(self, parent, liste, entete=None):
+ QDialog.__init__(self, parent)
+ self.setupUi(self)
+ self.setModal(False)
+ self.bclose.clicked.connect(self.close)
+
+ if entete != None:
+ self.setWindowTitle(entete)
+ for ligne in liste:
+ texte = ligne[0]
+ couleur = ligne[1]
+ if couleur == Qt.black:
+ self.LBRegles.addItem(texte)
+ else:
+ monItem = QListWidgetItem(texte)
+ monItem.setForeground(Qt.red)
+ self.LBRegles.addItem(monItem)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+import traceback
+
+from Extensions.i18n import tr
+
+from PyQt5.QtWidgets import QDialog, QMessageBox, QFileDialog
+from PyQt5.QtCore import QSize
+from desViewTexte import Ui_dView
+
+
+# ------------------------------- #
+class ViewText(Ui_dView, QDialog):
+ # ------------------------------- #
+ """
+ Classe permettant la visualisation de texte
+ """
+
+ def __init__(
+ self, parent, editor=None, entete=None, texte=None, largeur=600, hauteur=600
+ ):
+ QDialog.__init__(self, parent)
+ self.editor = editor
+ self.setupUi(self)
+
+ self.resize(QSize(largeur, hauteur).expandedTo(self.minimumSizeHint()))
+ self.bclose.clicked.connect(self.close)
+ self.bsave.clicked.connect(self.saveFile)
+
+ if entete != None:
+ self.setWindowTitle(entete)
+ if entete != None:
+ self.setText(texte)
+
+ def setText(self, txt):
+ self.view.setText(txt)
+
+ def saveFile(self):
+ # recuperation du nom du fichier
+ if self.editor != None:
+ dir = self.editor.appliEficas.maConfiguration.savedir
+ else:
+ dir = "/tmp"
+ fn = QFileDialog.getSaveFileName(None, tr("Sauvegarder le fichier"), dir)
+ fn = fn[0]
+ if fn == "":
+ return
+ if fn == None:
+ return (0, None)
+
+ ulfile = os.path.abspath(fn)
+ if self.editor != None:
+ self.editor.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ try:
+ f = open(fn, "w")
+ f.write(str(self.view.toPlainText()))
+ f.close()
+ return 1
+ except IOError as why:
+ QMessageBox.critical(
+ self,
+ tr("Sauvegarder le fichier"),
+ tr("Le fichier")
+ + str(fn)
+ + tr("n a pas pu etre sauvegarde : ")
+ + str(why),
+ )
+ return
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+
+from desVisu import Ui_DVisu
+from PyQt5.QtWidgets import QDialog
+
+
+# Import des panels
+class DVisu(Ui_DVisu, QDialog):
+ """ """
+
+ def __init__(self, parent=None, name=None, fl=0):
+ QDialog.__init__(self, parent)
+ self.setModal(True)
+ self.setupUi(self)
+
+ def on_buttonCancel_clicked(self):
+ QDialog.reject(self)
+
+ def on_buttonOk_clicked(self):
+ QDialog.accept(self)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from .monWidgetRadioButton import MonWidgetRadioButtonCommun
+from desWidget4a6RadioButton import Ui_Widget4a6RadioButton
+
+
+class MonWidget4a6RadioButton(Ui_Widget4a6RadioButton, MonWidgetRadioButtonCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print "dans le init de MonWidget4a6RadioButton",self
+ if type(monSimpDef.into) == types.FunctionType:
+ self.maListeDeValeur = monSimpDef.into()
+ else:
+ self.maListeDeValeur = monSimpDef.into
+ MonWidgetRadioButtonCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def setMaxI(self):
+ self.maxI = 6
+
+
+class MonWidget4a6RadioButtonSD(Ui_Widget4a6RadioButton, MonWidgetRadioButtonCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print "dans le init de MonWidget4a6RadioButton",self
+ self.maListeDeValeur = node.item.getSdAvantDuBonType()
+ MonWidgetRadioButtonCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def setMaxI(self):
+ self.maxI = 6
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from .monWidgetRadioButton import MonWidgetRadioButtonCommun
+from desWidget4a6RadioButton import Ui_Widget4a6RadioButton
+
+
+class MonWidget4a6RadioButtonSD(Ui_Widget4a6RadioButton, MonWidgetRadioButtonCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print "dans le init de MonWidget4a6RadioButton",self
+ self.maListeDeValeur = node.item.getSdAvantDuBonType()
+ MonWidgetRadioButtonCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def setMaxI(self):
+ self.maxI = 6
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+
+from desWidgetBloc import Ui_WidgetBloc
+from .groupe import Groupe
+from Extensions.i18n import tr
+
+# Import des panels
+class MonWidgetBloc(Ui_WidgetBloc, Groupe):
+ """ """
+
+ def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
+ # print ("bloc : ",node.item.nom)
+ Groupe.__init__(self, node, editor, parentQt, definition, obj, niveau, commande)
+ # if self.editor.maConfiguration.afficheCommandesPliees ==True: self.node.plieToutEtReaffiche()
+ self.parentQt.commandesLayout.insertWidget(-1, self, 1)
+
+ def afficheOptionnel(self):
+ return
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from InterfaceGUI.QT5.feuille import Feuille
+from desWidgetCB import Ui_WidgetCB
+from InterfaceGUI.QT5.politiquesValidation import PolitiqueUnique
+from InterfaceGUI.QT5.qtSaisie import SaisieValeur
+
+from PyQt5.QtWidgets import QComboBox, QCompleter
+from PyQt5.QtCore import Qt, QEvent
+
+
+class MonWidgetCBCommun(Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ self.determineChoix()
+ self.setValeursApresBouton()
+ self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
+ self.CBChoix.wheelEvent = self.wheelEvent
+ if hasattr(self.parentQt, "commandesLayout"):
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.maCommande.listeAffichageWidget.append(self.CBChoix)
+ self.AAfficher = self.CBChoix
+
+ def setValeursApresBouton(self):
+ # print (self.objSimp.getValeur())
+ if (
+ self.node.item.definition.homo == "constant"
+ and self.objSimp.getValeur() == None
+ ):
+ self.CBChoix.addItem(tr("Choisir dans la partie probabiliste"))
+ self.CBChoix.setCurrentIndex(
+ self.CBChoix.findText(tr("Choisir dans la partie probabiliste"))
+ )
+ self.CBChoix.setEnabled(0)
+ return
+ if self.objSimp.getValeur() == None:
+ self.CBChoix.setCurrentIndex(-1)
+ self.CBChoix.lineEdit().setText(tr("Select"))
+ return
+ valeur = self.objSimp.getValeur()
+ if not (type(valeur) == str):
+ valeur = str(valeur)
+ self.CBChoix.setCurrentIndex(self.CBChoix.findText(valeur))
+
+ def determineChoix(self):
+ listeChoix = []
+ if self.maListeDeValeur == None:
+ self.maListeDeValeur = []
+ for choix in self.maListeDeValeur:
+ if not (type(choix) == str):
+ choix = str(choix)
+ listeChoix.append(choix)
+ self.CBChoix.addItem(choix)
+ if self.node.item.definition.homo == "constant":
+ self.CBChoix.setEnabled(0)
+ if self.objSimp.getValeur() != None:
+ self.CBChoix.setStyleSheet(
+ (
+ "\n"
+ "QComboBox {\n"
+ " border: 1px solid gray;\n"
+ " background: rgb(0,255,0);\n"
+ " color: rgb(24,24,7);\n"
+ " }\n"
+ "QComboBox::drop-down {\n"
+ " image: none; \n"
+ " }"
+ )
+ )
+ else:
+ self.CBChoix.setEditable(True)
+ monCompleteur = QCompleter(listeChoix, self)
+ monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
+ self.CBChoix.setCompleter(monCompleteur)
+
+ def choixSaisi(self):
+ self.CBChoix.lineEdit().setStyleSheet(
+ (
+ "\n"
+ "QLineEdit {\n"
+ " font : italic ;\n"
+ " background: rgb(235,235,235);\n"
+ " }"
+ )
+ )
+ valeur = str(self.CBChoix.currentText())
+ SaisieValeur.LEvaleurPressed(self, valeur)
+ self.reaffiche()
+
+ def wheelEvent(self, event):
+ # Sinon poum sur les fenetres trop longues
+ # lorsque la widget attrape le wheelevent
+ event.ignore()
+
+
+class MonWidgetCB(Ui_WidgetCB, MonWidgetCBCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.maListeDeValeur = monSimpDef.into
+ MonWidgetCBCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetCBSD(Ui_WidgetCB, MonWidgetCBCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.maListeDeValeur = node.item.getSdAvantDuBonType()
+ MonWidgetCBCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+from desWidgetCBIntoSug import Ui_WidgetCBIntoSug
+
+from PyQt5.QtWidgets import QComboBox, QCompleter
+from PyQt5.QtCore import Qt
+
+from monWidgetCB import MonWidgetCBCommun
+from monWidgetIntoSug import GereAjoutDsPossible
+
+
+class MonWidgetCBIntoSug(MonWidgetCBCommun, Ui_WidgetCBIntoSug, GereAjoutDsPossible):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.maListeDeValeur = monSimpDef.into
+ if node.item.hasIntoSug():
+ self.maListeDeValeur = node.item.getListePossibleAvecSug([])
+ if hasattr(node.item, "suggestion"):
+ self.maListeDeValeur += node.item.suggestion
+ MonWidgetCBCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
+
+ def ajouteValeurPossible(self, valeur):
+ self.CBChoix.addItem(valeur)
+ # on ne sait pas si on a deja ajouté une valeur
+ try:
+ self.node.item.suggestion.append(valeur)
+ except:
+ self.node.item.suggestion = (valeur,)
+ self.lineEditVal.setText("")
+ self.CBChoix.setCurrentIndex(self.CBChoix.findText(valeur))
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetCB import Ui_WidgetCB
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+
+
+from PyQt5.QtWidgets import QComboBox, QCompleter
+
+
+class MonWidgetCB(Ui_WidgetCB, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ self.determineChoix()
+ self.setValeursApresBouton()
+ self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
+
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.maCommande.listeAffichageWidget.append(self.CBChoix)
+ # print self.objSimp.isOblig()
+
+ def setValeursApresBouton(self):
+ if self.objSimp.getValeur() == None:
+ self.CBChoix.setCurrentIndex(-1)
+ return
+ valeur = self.objSimp.getValeur()
+ if not (type(valeur) == str):
+ valeur = str(valeur)
+ self.CBChoix.setCurrentIndex(self.CBChoix.findText(valeur))
+
+ def determineChoix(self):
+ self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
+
+ for choix in self.monSimpDef.into:
+ if not (type(choix) == str):
+ choix = str(choix)
+ self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
+ self.CBChoix.addItem(choix)
+ self.CBChoix.setEditable(True)
+ monCompleteur = QCompleter(listeChoix, self)
+ monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
+ self.CBChoix.setCompleter(monCompleteur)
+
+ def choixSaisi(self):
+ valeur = str(self.CBChoix.currentText())
+ SaisieValeur.LEvaleurPressed(self, valeur)
+ self.reaffiche()
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+import types
+
+from desWidgetCommande import Ui_WidgetCommande
+from .groupe import Groupe
+from .gereIcones import FacultatifOuOptionnel
+
+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
+
+
+from Extensions.i18n import tr
+import Accas
+import os
+
+
+# Import des panels
+
+
+class MonWidgetCommande(Ui_WidgetCommande, Groupe):
+ """ """
+
+ def __init__(self, node, editor, etape):
+ self.listeAffichageWidget = []
+ self.inhibe = 0
+ self.ensure = 0
+ editor.inhibeSplitter = 1
+ Groupe.__init__(self, node, editor, None, etape.definition, etape, 1, self)
+ spacerItem = QSpacerItem(21, 500, QSizePolicy.Expanding, QSizePolicy.Expanding)
+ self.verticalLayoutCommande.addItem(spacerItem)
+ editor.inhibeSplitter = 0
+
+ # Gestion du nom de L OPER si il est nomme
+ if not (hasattr(etape.definition, "sd_prod")) or (
+ etape.definition.sd_prod == None
+ ):
+ self.LENom.close()
+ elif (
+ hasattr(etape.definition, "sd_prod")
+ and type(etape.definition.sd_prod) == types.FunctionType
+ ):
+ self.LENom.close()
+ elif (
+ (hasattr(etape, "sdnom"))
+ and etape.sdnom != "sansnom"
+ and etape.sdnom != None
+ ):
+ self.LENom.setText(etape.sdnom)
+ else:
+ self.LENom.setText("")
+ if hasattr(self, "LENom"):
+ self.LENom.returnPressed.connect(self.nomChange)
+ self.racine = self.node.tree.racine
+ if self.node.item.getIconName() == "ast-red-square":
+ self.LENom.setDisabled(True)
+
+ # Gestion de la doc de l objet
+ if node.item.getFr() != "":
+ self.labelDoc.setText(node.item.getFr())
+ nouvelleSize = self.frameAffichage.height() + 60
+ self.frameAffichage.setMinimumHeight(nouvelleSize)
+ self.frameAffichage.resize(self.frameAffichage.width(), nouvelleSize)
+ else:
+ self.labelDoc.close()
+
+ # Gestion du nom de l etape
+ maPolice = QFont(
+ "Times",
+ 10,
+ )
+ self.setFont(maPolice)
+ self.labelNomCommande.setText(tr(self.obj.nom))
+
+ # Gestion du Frame d affichage des autres commandes
+ if self.editor.maConfiguration.closeAutreCommande == True:
+ self.closeAutreCommande()
+ else:
+ self.bCatalogue.clicked.connect(self.afficheCatalogue)
+ self.bAvant.clicked.connect(self.afficheAvant)
+ self.bApres.clicked.connect(self.afficheApres)
+
+ if self.editor.maConfiguration.closeFrameRechercheCommande == True:
+ self.frameAffichage.close()
+ self.closeAutreCommande()
+
+ self.setAcceptDrops(True)
+ self.etablitOrdre()
+
+ if self.editor.maConfiguration.enleverPoubellePourCommande:
+ self.RBPoubelle.close() # JDC Fige
+
+ if self.editor.maConfiguration.pasDeMCOptionnels:
+ return # Pas de MC Optionnels pour Carmel
+
+ from .monWidgetOptionnel import MonWidgetOptionnel
+
+ if self.editor.widgetOptionnel != None:
+ self.monOptionnel = self.editor.widgetOptionnel
+ else:
+ self.editor.inhibeSplitter = 1
+ self.monOptionnel = MonWidgetOptionnel(self.editor)
+ self.editor.widgetOptionnel = self.monOptionnel
+ self.editor.splitter.addWidget(self.monOptionnel)
+ self.editor.ajoutOptionnel()
+ self.editor.inhibeSplitter = 0
+ self.monOptionnel = self.editor.widgetOptionnel
+ self.afficheOptionnel()
+
+ # print "fin init de widget Commande"
+
+ def closeAutreCommande(self):
+ self.bCatalogue.close()
+ self.bAvant.close()
+ self.bApres.close()
+
+ def donnePremier(self):
+ # print "dans donnePremier"
+ QApplication.processEvents()
+ if self.listeAffichageWidget != []:
+ self.listeAffichageWidget[0].setFocus(7)
+ QApplication.processEvents()
+ # print self.focusWidget()
+
+ def focusNextPrevChild(self, next):
+ # on s assure que ce n est pas un chgt de fenetre
+ # print "je passe dans focusNextPrevChild"
+ if self.editor.fenetreCentraleAffichee != self:
+ return True
+ f = self.focusWidget()
+ if f not in self.listeAffichageWidget:
+ i = 0
+ while not hasattr(f, "AAfficher"):
+ if f == None:
+ i = -1
+ break
+ f = f.parentWidget()
+ if hasattr(f, "AAfficher"):
+ f = f.AAfficher
+ if i != -1:
+ i = self.listeAffichageWidget.index(f)
+ else:
+ i = self.listeAffichageWidget.index(f)
+ if (i == len(self.listeAffichageWidget) - 1) and next and not self.inhibe:
+ try:
+ self.listeAffichageWidget[1].setFocus(7)
+ w = self.focusWidget()
+ self.inhibe = 1
+ w.focusPreviousChild()
+ self.inhibe = 0
+ return True
+ except:
+ pass
+ # print self.listeAffichageWidget
+ # print "souci ds focusNextPrevChild"
+ if i == 0 and next == False and not self.inhibe:
+ if hasattr(self.editor.fenetreCentraleAffichee, "scrollArea"):
+ self.editor.fenetreCentraleAffichee.scrollArea.ensureWidgetVisible(
+ self.listeAffichageWidget[-1]
+ )
+ self.listeAffichageWidget[-2].setFocus(7)
+ self.inhibe = 1
+ w = self.focusWidget()
+ w.focusNextChild()
+ self.inhibe = 0
+ return True
+ if i == 0 and next == True and not self.inhibe:
+ self.listeAffichageWidget[0].setFocus(7)
+ self.inhibe = 1
+ w = self.focusWidget()
+ w.focusNextChild()
+ self.inhibe = 0
+ return True
+ if i > 0 and next == False and not self.inhibe:
+ if isinstance(self.listeAffichageWidget[i - 1], QRadioButton):
+ self.listeAffichageWidget[i - 1].setFocus(7)
+ return True
+ return QWidget.focusNextPrevChild(self, next)
+
+ def etablitOrdre(self):
+ i = 0
+ while i + 1 < len(self.listeAffichageWidget):
+ self.setTabOrder(
+ self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
+ )
+ i = i + 1
+ # si on boucle on perd l'ordre
+
+ def afficheSuivant(self, f):
+ # print ('ds afficheSuivant')
+ try:
+ i = self.listeAffichageWidget.index(f)
+ next = i + 1
+ except:
+ next = 1
+ if next == len(self.listeAffichageWidget):
+ next = 0
+ # self.f=next
+ # QTimer.singleShot(1, self.rendVisible)
+ try:
+ self.listeAffichageWidget[next].setFocus(7)
+ except:
+ pass
+
+ def nomChange(self):
+ nom = str(self.LENom.text())
+ nom = nom.strip()
+ if nom == "":
+ return # si pas de nom, on ressort sans rien faire
+ test, mess = self.node.item.nommeSd(nom)
+ self.editor.afficheCommentaire(mess)
+
+ # Notation scientifique
+ if test:
+ from .politiquesValidation import Validation
+
+ validation = Validation(self.node, self.editor)
+ validation.ajoutDsDictReelEtape()
+
+ def afficheOptionnel(self):
+ # N a pas de parentQt. doit donc etre redefini
+ if self.editor.maConfiguration.closeOptionnel:
+ self.editor.fermeOptionnel()
+ liste, liste_rouge = self.ajouteMCOptionnelDesBlocs()
+ # print "dans afficheOptionnel", self.monOptionnel
+ # dans le cas ou l insertion n a pas eu leiu (souci d ordre par exemple)
+ # if self.monOptionnel == None : return
+ self.monOptionnel.parentCommande = self
+ self.monOptionnel.titre(self.obj.nom)
+ self.monGroupe = self.monOptionnel.afficheOptionnel(liste, liste_rouge, self)
+
+ def focusInEvent(self, event):
+ # print "je mets a jour dans focusInEvent de monWidget Commande "
+ self.afficheOptionnel()
+
+ def reaffiche(self, nodeAVoir=None):
+ # Attention delicat. les appels de fonctions ne semblent pas pouvoir etre supprimes!
+ self.avantH = (
+ self.editor.fenetreCentraleAffichee.scrollAreaCommandes.horizontalScrollBar().sliderPosition()
+ )
+ self.avantV = (
+ self.editor.fenetreCentraleAffichee.scrollAreaCommandes.verticalScrollBar().sliderPosition()
+ )
+ self.inhibeExpand = True
+ # Attention : lorsqu'on reconstruit l arbre au milieu par une fonction siValide (exemple dans UQ)
+ # alors self.node.item.node est different de self.node
+ # il faut regarder si la Widget utililse self.node a d autres endroits
+ self.node.item.node.affichePanneau()
+ # QTimer.singleShot(1, self.recentre)
+ if nodeAVoir != None and nodeAVoir != 0:
+ self.f = nodeAVoir.fenetre
+ if self.f == None:
+ newNode = nodeAVoir.treeParent.chercheNoeudCorrespondant(
+ nodeAVoir.item.object
+ )
+ self.f = newNode.fenetre
+ if self.f != None and self.f.isVisible():
+ self.inhibeExpand = False
+ return
+ if self.f != None:
+ self.rendVisible()
+ else:
+ self.recentre()
+ else:
+ self.recentre()
+ self.inhibeExpand = False
+
+ def recentre(self):
+ QApplication.processEvents()
+ s = self.editor.fenetreCentraleAffichee.scrollAreaCommandes
+ s.horizontalScrollBar().setSliderPosition(self.avantH)
+ s.verticalScrollBar().setSliderPosition(self.avantV)
+
+ def rendVisible(self):
+ QApplication.processEvents()
+ self.f.setFocus(7)
+ self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(
+ self.f
+ )
+
+ def afficheCatalogue(self):
+ if self.editor.widgetOptionnel != None:
+ self.monOptionnel.hide()
+ self.racine.affichePanneau()
+ if self.node:
+ self.node.select()
+ else:
+ self.racine.select()
+
+ def afficheApres(self):
+ self.node.selectApres()
+
+ def afficheAvant(self):
+ self.node.selectAvant()
+
+ def setValide(self):
+ if not (hasattr(self, "RBValide")):
+ return
+ icon = QIcon()
+ if self.node.item.object.isValid():
+ icon = QIcon(self.repIcon + "/ast-green-ball.png")
+ else:
+ icon = QIcon(self.repIcon + "/ast-red-ball.png")
+ nomIcone = self.node.item.getIconName()
+ if nomIcone == "ast-yellow-square":
+ icon = QIcon(self.repIcon + "/ast-yel-ball.png")
+ if nomIcone == "ast-red-square":
+ self.LENom.setDisabled(True)
+
+ self.LENom.setDisabled(False)
+ self.RBValide.setIcon(icon)
+
+ def propageChange(self, typeChange, donneLeFocus):
+ aReecrire = self.propageChangeEnfant(self.node.item.object, typeChange)
+ if aReecrire:
+ self.node.affichePanneau()
+ if hasattr(donneLeFocus.node.fenetre, "selectionneDernier"):
+ QApplication.processEvents()
+ self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(
+ donneLeFocus.node.fenetre
+ )
+ donneLeFocus.node.fenetre.selectionneDernier()
+
+ def propageChangeEnfant(self, mc, typeChange):
+ for enfant in mc.mcListe:
+ if enfant.nature == "MCSIMP":
+ if enfant.waitUserAssd():
+ if enfant.definition.type[0] == typeChange:
+ return True
+ else:
+ if enfant.nature == "MCList":
+ enfant = enfant[0]
+ if self.propageChangeEnfant(enfant, typeChange):
+ return True
+ return False
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+import types, os
+import traceback
+
+from PyQt5.QtGui import QIcon
+from InterfaceGUI.QT5.monWidgetCommande import MonWidgetCommande
+from PyQt5.QtWidgets import QSpacerItem, QSizePolicy
+
+
+class MonWidgetCommandeDeplie1Niveau(MonWidgetCommande):
+ # Attention au MCLIST qui ne sont pas des MCFACT
+ # il faut donc surcharger un certain nb de fonction ici pour eux
+
+ def __init__(self, node, editor, etape):
+ # print ("debut de ---------------------- init de MonWidgetCommandeDeplie1Niveau ",node.item.nom)
+ MonWidgetCommande.__init__(self, node, editor, etape)
+ self.node.plieToutEtReaffiche = self.plieToutEtReaffiche
+ spacerItem = QSpacerItem(21, 600, QSizePolicy.Expanding, QSizePolicy.Expanding)
+ self.verticalLayoutCommande.addItem(spacerItem)
+
+ def afficheMots(self):
+ # Attention
+ # Attention --> cette methode surcharge les methodes des Nodes Fils
+ # Attention
+ # print ("debut de ---------------------- ds afficheMots de MonWidgetCommandeDeplie1Niveau ",self.node.item.nom)
+ # traceback.print_stack()
+ repIcon = self.editor.appliEficas.repIcon
+ fichier = os.path.join(repIcon, "deleteRondVide.png")
+ icon = QIcon(fichier)
+ for node in self.node.children:
+ node.plie = True
+ node.setPlieChildren()
+ if node.appartientAUnNoeudPlie == True:
+ continue
+
+ node.plieToutEtReaffiche = self.plieToutEtReaffiche
+ node.deplieToutEtReaffiche = self.deplieToutEtReaffiche
+ node.affichePanneau = self.affichePanneau
+ node.getPanel = self.getPanel
+
+ widget = node.getPanelGroupe(self, self.maCommande)
+ self.listeFocus.append(node.fenetre)
+
+ try:
+ node.fenetre.RBDeplie.setCheckable(False)
+ node.fenetre.RBDeplie.setEnabled(False)
+ node.fenetre.RBDeplie.setIcon(icon)
+ except:
+ pass
+
+ if node.item.object.isMCList():
+ node.setDeplie = self.setDepliePourMCList
+
+ for c in node.children:
+ c.setDeplie = self.setDepliePourNode
+ c.plieToutEtReaffiche = self.plieToutEtReaffiche
+ c.deplieToutEtReaffiche = self.deplieToutEtReaffiche
+ c.getPanel = self.getPanel
+ c.affichePanneau = self.affichePanneau
+ try:
+ c.fenetre.RBDeplie.setCheckable(False)
+ c.fenetre.RBDeplie.setEnabled(False)
+ c.fenetre.RBDeplie.setIcon(icon)
+ except:
+ pass
+ else:
+ node.setDeplie = self.setDepliePourNode
+
+ # print ("fin ------------------------ afficheMots de MonWidgetCommandeDeplie1Niveau ",self.node.item.nom)
+
+ def afficheSuivant(self, aAfficher):
+ fenetre = self.node.tree.itemCourant.fenetre
+ fenetre.afficheSuivant(aAfficher)
+
+ def setDepliePourNode(self):
+ noeudCourant = self.node.tree.itemCourant
+ noeudCourant.setDeplieChildren()
+ if self.editor.fenetreCentraleAffichee == noeudCourant.fenetre:
+ return
+ noeudCourant.afficheCeNiveau()
+ pass
+
+ # -------------------------------------------- Methodes qui surchargent les noeuds fils
+
+ def setDepliePourMCList(self):
+ # print ('je surcharge setDeplie pour MCList')
+ pass
+
+ def setPlieChildren(self):
+ # print ('je surcharge setPlieChildren')
+ pass
+
+ def setDeplieChildren(self):
+ # print ('je surcharge setDeplieChildren')
+ pass
+
+ def plieToutEtReaffiche(self):
+ # print ('je surcharge plieToutEtReaffiche', self.node.item.nom)
+ pass
+
+ def deplieToutEtReaffiche(self):
+ # print ('je surcharge deplieToutEtReaffiche', self.node.tree.itemCourant.item.getLabelText())
+ pass
+
+ def plieToutEtReafficheSaufItem(self):
+ # print ('je surcharge plieToutEtReaffiche', self.node.tree.itemCourant.item.getLabelText())
+ pass
+
+ def affichePanneau(self):
+ # print ('je surcharge affichePanneau', self.node.tree.itemCourant.item.getLabelText())
+ node = self.node.tree.itemCourant
+ while (
+ not (hasattr(node, "fenetreIhm"))
+ or node.treeParent.fenetreIhm != "deplie1Niveau"
+ ):
+ node = node.treeParent
+ self.node.tree.setCurrentItem(node)
+
+ item = node.item
+ if (
+ item.getLabelText()[0]
+ == self.editor.fenetreCentraleAffichee.labelNomCommande.text()
+ ):
+ return
+ node.setDeplieChildren()
+ node.afficheCeNiveau()
+ self.editor.fenetreCentraleAffichee.labelNomCommande.setText(
+ item.getLabelText()[0]
+ )
+ self.editor.fenetreCentraleAffichee.labelDoc.setText(item.getFr())
+
+ def getPanel(self):
+ # print ('surcharge ds getPanel')
+ pass
--- /dev/null
+# Copyright (C) 2007-2024 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
+# Modules Eficas
+
+from PyQt5.QtWidgets import QWidget
+from PyQt5.QtCore import Qt
+
+from desWidgetCommentaire import Ui_WidgetCommentaire
+from .gereIcones import FacultatifOuOptionnel
+from Extensions.i18n import tr
+import Accas
+import os
+
+
+# Import des panels
+
+
+class MonWidgetCommentaire(QWidget, Ui_WidgetCommentaire, FacultatifOuOptionnel):
+ """ """
+
+ def __init__(self, node, editor, commentaire):
+ QWidget.__init__(self, None)
+ self.node = node
+ self.node.fenetre = self
+ self.setupUi(self)
+ self.editor = editor
+ self.appliEficas = self.editor.appliEficas
+ self.repIcon = self.appliEficas.repIcon
+ self.setIconePoubelle()
+ self.remplitTexte()
+ self.monOptionnel = None
+
+ self.commentaireTE.textChanged.connect(self.TexteCommentaireEntre)
+ if self.editor.code in ["MAP", "CARMELCND"]:
+ self.bCatalogue.close()
+ else:
+ self.bCatalogue.clicked.connect(self.afficheCatalogue)
+ if self.editor.code in ["Adao", "MAP", "ADAO"]:
+ self.bAvant.close()
+ self.bApres.close()
+ else:
+ self.bAvant.clicked.connect(self.afficheAvant)
+ self.bApres.clicked.connect(self.afficheApres)
+ self.editor.fermeOptionnel()
+
+ def afficheApres(self):
+ self.node.selectApres()
+
+ def afficheAvant(self):
+ self.node.selectAvant()
+
+ def afficheCatalogue(self):
+ self.node.tree.racine.affichePanneau()
+ if self.node:
+ self.node.select()
+ else:
+ self.node.tree.racine.select()
+
+ def remplitTexte(self):
+ texte = self.node.item.getValeur()
+ self.commentaireTE.setText(texte)
+ if self.editor.code == "CARMELCND" and texte[0:16] == "Cree - fichier :":
+ self.commentaireTE.setReadOnly(True)
+ self.commentaireTE.setStyleSheet(
+ "background:rgb(244,244,244);\n" "border:0px;\n"
+ )
+ self.commentaireTE.setToolTip(tr("Valeur non modifiable"))
+ else:
+ self.commentaireTE.setReadOnly(False)
+
+ def donnePremier(self):
+ self.commentaireTE.setFocus(7)
+
+ def TexteCommentaireEntre(self):
+ texte = str(self.commentaireTE.toPlainText())
+ self.editor.initModif()
+ self.node.item.setValeur(texte)
+ self.node.updateNodeTexte()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os, re
+pattern_name = re.compile(r"^[^\d\W]\w*\Z")
+
+# Modules Eficas
+
+from PyQt5.QtWidgets import QDialog, QMessageBox
+from PyQt5.QtCore import Qt
+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
+ self.editor.afficheInfos("")
+ QDialog.__init__(self, editor)
+ self.setupUi(self)
+ self.connecterSignaux()
+ self.dejaExistant = 0
+ self.listeTousParam = self.editor.jdc.params
+ self.dictListe = {}
+ self.initToutesVal()
+
+ def connecterSignauxQT4(self):
+ self.connect(
+ self.lineEditVal, SIGNAL("returnPressed()"), self.lineEditValReturnPressed
+ )
+ self.connect(
+ self.lineEditNom, SIGNAL("returnPressed()"), self.lineEditNomReturnPressed
+ )
+
+ def connecterSignaux(self):
+ self.lineEditVal.returnPressed.connect(self.lineEditValReturnPressed)
+ self.lineEditNom.returnPressed.connect(self.lineEditNomReturnPressed)
+ self.LBParam.itemDoubleClicked.connect(self.paramClicked)
+
+ def paramClicked(self, item):
+ if self.editor.nodeEnCours == None:
+ QMessageBox.warning(
+ self, tr("Pas de Mot-Clef"), tr("Attention! selectionnez un mot-clef")
+ )
+ return
+ param = self.dictListe[item.text()]
+ self.editor.nodeEnCours.lineEditVal.setText(param)
+ self.editor.nodeEnCours.LEvaleurPressed()
+
+ 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.setNom(nom)
+ # PN self.val permet d entrer du texte
+ param.item.setValeur(self.val)
+ param.updateNodeTexte()
+ param.updateNodeValid()
+ self.LBParam.addItem((repr(param.item.object)))
+ self.dictListe[repr(param.item.object)] = param.item.object.nom
+ self.lineEditVal.setText("")
+ self.lineEditNom.setText("")
+ self.lineEditNom.setFocus(True)
+
+ def lineEditValReturnPressed(self):
+ qtVal = self.lineEditVal.text()
+ valString = str(self.lineEditVal.text())
+ self.val = ""
+ contexte = {}
+ exec("from math import *", contexte)
+ jdc = self.editor.jdc
+ if jdc == None:
+ self.editor.afficheInfos(
+ tr(
+ "La Creation de parametre n est possible que dans un jeu de donnees"
+ ),
+ Qt.red,
+ )
+ return
+
+ for p in jdc.params:
+ try:
+ tp = p.nom + "=" + str(repr(p.valeur))
+ exec(tp, contexte)
+ except:
+ pass
+ monTexte = "monParam=" + valString
+ try:
+ exec(monTexte, contexte)
+ self.val = valString
+ except:
+ try:
+ monTexte = "monParam='" + valString + "'"
+ self.val = "'" + valString + "'"
+ except:
+ self.editor.afficheInfos(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.afficheInfos(commentaire, Qt.red)
+ for p in self.editor.jdc.params:
+ if p.nom == nom:
+ commentaire = nom + tr(" existe deja\n ")
+ self.editor.afficheInfos(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((repr(param)))
+ self.dictListe[repr(param)] = param.nom
+
+ 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()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+from .monWidgetSimpTxt import MonWidgetSimpTxt
+from .monWidgetPlusieursBase import MonWidgetPlusieursBase
+from copy import copy, deepcopy
+from PyQt5.QtCore import Qt
+
+
+class MonWidgetCreeUserAssd(MonWidgetSimpTxt):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetSimpTxt.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ # self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
+
+ def LEvaleurPressed(self):
+ try:
+ if (
+ str(self.lineEditVal.text()) == ""
+ or str(self.lineEditVal.text()) == None
+ ):
+ return
+ except:
+ pass
+ valeurEntree = str(self.lineEditVal.text())
+ if valeurEntree == self.oldValeurTexte:
+ return
+ if self.oldValeurTexte == "":
+ enCreation = True
+ else:
+ enCreation = False
+ if enCreation:
+ validite, commentaire = self.objSimp.creeUserASSDetSetValeur(valeurEntree)
+ else:
+ validite, commentaire = self.objSimp.renommeSdCree(valeurEntree)
+ if not enCreation:
+ self.node.updateNodeTexte()
+ # PNPNPN -- signal update sur les fils ou ?
+ if commentaire != "":
+ if validite:
+ self.editor.afficheCommentaire(commentaire)
+ self.oldValeurTexte = self.lineEditVal.text()
+ else:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.lineEditVal.setText("")
+ self.oldValeurTexte = ""
+ self.parentQt.propageChange(self.objSimp.definition.type[0], self)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from .monWidgetSimpTuple import MonWidgetSimpTuple
+from desWidgetDate import Ui_WidgetDate
+
+
+class MonWidgetDate(Ui_WidgetDate, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 3
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ if self.objSimp.isImmuable():
+ self.lineEditVal1.setDisabled(True)
+ self.lineEditVal2.setDisabled(True)
+ self.lineEditVal3.setDisabled(True)
+ self.lineEditVal1.setStyleSheet(
+ QString.fromUtf8("background:rgb(244,244,244);\n" "border:0px;\n")
+ )
+ self.lineEditVal2.setStyleSheet(
+ QString.fromUtf8("background:rgb(244,244,244);\n" "border:0px;\n")
+ )
+ self.lineEditVal3.setStyleSheet(
+ QString.fromUtf8("background:rgb(244,244,244);\n" "border:0px;\n")
+ )
+ self.lineEditVal1.setToolTip(tr("Valeur non modifiable"))
+ self.lineEditVal2.setToolTip(tr("Valeur non modifiable"))
+ self.lineEditVal3.setToolTip(tr("Valeur non modifiable"))
+ else:
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
+ # self.maCommande.listeAffichageWidget.append(self.lineEditVal2)
+ # self.maCommande.listeAffichageWidget.append(self.lineEditVal3)
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+from PyQt5.QtCore import Qt, QTimer
+from PyQt5.QtWidgets import QWidget
+
+from .groupe import Groupe
+from desWidgetFact import Ui_WidgetFact
+from Extensions.i18n import tr
+
+# Import des panels
+
+
+# PN 18 mai 2020 : affiche systematique des optionnels
+class MonWidgetFactCommun(Groupe):
+ """ """
+
+ def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
+ # print ("fact : ",node.item.nom)
+ Groupe.__init__(self, node, editor, parentQt, definition, obj, niveau, commande)
+ labeltext, fonte, couleur = self.node.item.getLabelText()
+ self.GroupBox.setText(tr(labeltext))
+ # self.GroupBox.setTextInteractionFlags(Qt.TextSelectableByMouse)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.doitAfficherOptionnel = True
+ min, max = obj.getMinMax()
+ if max > 1 and hasattr(self, "RBPlus"):
+ self.RBPlus.clicked.connect(self.ajouteMCParPB)
+ if max < 2 and hasattr(self, "RBPlus"):
+ self.RBPlus.close()
+ if (
+ max > 2
+ and obj.alt_parent.nature == "MCList"
+ and len(obj.alt_parent) >= max
+ and hasattr(self, "RBPlus")
+ ):
+ self.RBPlus.close()
+
+ if max > 2 and definition.statut == "cache" and hasattr(self, "RBPlus"):
+ self.RBPlus.close()
+
+ def enterEvent(self, event):
+ # print "enterEvent ", self.node.item.getLabelText()[0]
+ self.doitAfficherOptionnel = True
+ QWidget.enterEvent(self, event)
+ QTimer.singleShot(500, self.delayAffiche)
+
+ def leaveEvent(self, event):
+ # print "leaveEvent", self.node.item.getLabelText()[0]
+ # self.doitAfficherOptionnel=False
+ QWidget.leaveEvent(self, event)
+
+ def delayAffiche(self):
+ # print "delayAffiche, self.doitAfficherOptionnel = ", self.doitAfficherOptionnel
+ if self.doitAfficherOptionnel and self.editor.code != "CARMELCND":
+ self.afficheOptionnel()
+
+ def ajouteMCParPB(self):
+ texteListeNom = "+" + self.obj.nom
+ parentOuAjouter = self.parentQt
+ from .monWidgetBloc import MonWidgetBloc
+
+ while parentOuAjouter and isinstance(parentOuAjouter, MonWidgetBloc):
+ parentOuAjouter = parentOuAjouter.parentQt
+ parentOuAjouter.ajoutMC(texteListeNom)
+
+
+# def reaffiche(self, nodeAVoir=None):
+# print ('ds reaffiche : ', self.obj.nom, self.node.firstDeplie)
+# if self.node.editor.maConfiguration.afficheFirstPlies and self.node.firstDeplie:
+# self.node.firstDeplie =False
+# self.node.setPlie()
+# Groupe.reaffiche(self,nodeAVoir)
+
+
+class MonWidgetFact(Ui_WidgetFact, MonWidgetFactCommun):
+ # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1):
+ # MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn)
+ def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
+ MonWidgetFactCommun.__init__(
+ self, node, editor, parentQt, definition, obj, niveau, commande
+ )
+
+
+class MonWidgetFactTableau(Ui_WidgetFact, MonWidgetFactCommun):
+ # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1):
+ # MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn)
+ def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
+ MonWidgetFactCommun.__init__(
+ self, node, editor, parentQt, definition, obj, niveau, commande
+ )
+ MonWidgetFactTableau.__init__(
+ self, node, editor, parentQt, definition, obj, niveau, commande
+ )
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+from desWidgetFactPlie import Ui_WidgetFactPlie
+from .groupe import Groupe
+from Extensions.i18n import tr
+
+class MonWidgetFactPlie(Ui_WidgetFactPlie, Groupe):
+ """ """
+
+ # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=-1):
+ def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
+ # print "fact plie : ",node.item.nom
+ node.fenetreAAfficher = self
+ Groupe.__init__(self, node, editor, parentQt, definition, obj, niveau, commande)
+ self.groupBox.setText(self.node.item.getLabelText()[0])
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+
+ def traiteClicSurLabel(self, texte):
+ return
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+from desWidgetFormule import Ui_WidgetFormule
+from .gereIcones import FacultatifOuOptionnel
+
+from PyQt5.QtWidgets import QWidget
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import Qt
+
+
+from Extensions.i18n import tr
+import Accas
+import os
+
+
+# Import des panels
+
+
+class MonWidgetFormule(QWidget, Ui_WidgetFormule, FacultatifOuOptionnel):
+ """ """
+
+ def __init__(self, node, editor, etape):
+ # print "MonWidgetFormule ", self
+ QWidget.__init__(self, None)
+ self.node = node
+ self.node.fenetre = self
+ self.editor = editor
+ self.appliEficas = self.editor.appliEficas
+ self.repIcon = self.appliEficas.repIcon
+ self.setupUi(self)
+
+ self.setIconePoubelle()
+ self.setIconesGenerales()
+ self.setValeurs()
+ self.setValide()
+
+ if self.editor.code in ["MAP", "CARMELCND"]:
+ self.bCatalogue.close()
+ else:
+ self.bCatalogue.clicked.connect(self.afficheCatalogue)
+ if self.editor.code in ["Adao", "MAP", "ADAO"]:
+ self.bAvant.close()
+ self.bApres.close()
+ else:
+ self.bAvant.clicked.connect(self.afficheAvant)
+ self.bApres.clicked.connect(self.afficheApres)
+ self.LENom.returnPressed.connect(self.nomChange)
+ self.LENomFormule.returnPressed.connect(self.nomFormuleSaisi)
+ self.LENomsArgs.returnPressed.connect(self.argsSaisis)
+ self.LECorpsFormule.returnPressed.connect(self.FormuleSaisie)
+
+ self.racine = self.node.tree.racine
+ self.monOptionnel = None
+ self.editor.fermeOptionnel()
+ # print "fin init de widget Commande"
+
+ def donnePremier(self):
+ self.listeAffichageWidget[0].setFocus(7)
+
+ def setValeurs(self):
+ self.LENomFormule.setText(self.node.item.getNom())
+ self.LECorpsFormule.setText(self.node.item.getCorps())
+ texte_args = ""
+ if self.node.item.getArgs() != None:
+ for i in self.node.item.getArgs():
+ if texte_args != "":
+ texte_args = texte_args + ","
+ texte_args = texte_args + i
+ self.LENomsArgs.setText(texte_args)
+
+ def nomChange(self):
+ nom = str(self.LENom.text())
+ self.LENomFormule.setText(nom)
+ self.nomFormuleSaisi()
+
+ def afficheCatalogue(self):
+ if self.editor.widgetOptionnel != None:
+ self.monOptionnel.hide()
+ self.racine.affichePanneau()
+ if self.node:
+ self.node.select()
+ else:
+ self.racine.select()
+
+ def afficheApres(self):
+ self.node.selectApres()
+
+ def afficheAvant(self):
+ self.node.selectAvant()
+
+ def setValide(self):
+ if not (hasattr(self, "RBValide")):
+ return
+ icon = QIcon()
+ if self.node.item.object.isValid():
+ icon = QIcon(self.repIcon + "/ast-green-ball.png")
+ else:
+ icon = QIcon(self.repIcon + "/ast-red-ball.png")
+ if self.node.item.getIconName() == "ast-yellow-square":
+ icon = QIcon(self.repIcon + "/ast-yel-ball.png")
+ self.RBValide.setIcon(icon)
+
+ def nomFormuleSaisi(self):
+ nomFormule = str(self.LENomFormule.text())
+ if nomFormule == "":
+ return
+ self.LENom.setText(nomFormule)
+ test, erreur = self.node.item.verifNom(nomFormule)
+ if test:
+ commentaire = nomFormule + tr(" est un nom valide pour une FORMULE")
+ self.editor.afficheInfos(commentaire)
+ else:
+ commentaire = nomFormule + tr(" n'est pas un nom valide pour une FORMULE")
+ self.editor.afficheInfos(commentaire, Qt.red)
+ return
+ if str(self.LENomsArgs.text()) != "" and str(self.LECorpsFormule.text()) != "":
+ self.BOkPressedFormule()
+ self.LENomsArgs.setFocus(7)
+
+ def argsSaisis(self):
+ arguments = str(self.LENomsArgs.text())
+ if arguments == "":
+ return
+ test, erreur = self.node.item.verifArguments(arguments)
+ if test:
+ commentaire = tr("Argument(s) valide(s) pour une FORMULE")
+ self.editor.afficheInfos(commentaire)
+ else:
+ commentaire = tr("Argument(s) invalide(s) pour une FORMULE")
+ self.editor.afficheInfos(commentaire, Qt.red)
+ if (
+ str(self.LECorpsFormule.text()) != ""
+ and str(self.LENomFormule.text()) != ""
+ ):
+ self.BOkPressedFormule()
+ self.LECorpsFormule.setFocus(7)
+
+ def FormuleSaisie(self):
+ nomFormule = str(self.LENomFormule.text())
+ arguments = str(self.LENomsArgs.text())
+ expression = str(self.LECorpsFormule.text())
+ if expression == "":
+ return
+ test, erreur = self.node.item.verifFormule_python(
+ (nomFormule, "REEL", arguments, expression)
+ )
+
+ if test:
+ commentaire = tr("Corps de FORMULE valide")
+ self.editor.afficheInfos(commentaire)
+ else:
+ commentaire = tr("Corps de FORMULE invalide")
+ self.editor.afficheInfos(commentaire, Qt.red)
+ if str(self.LENomsArgs.text()) != "" and str(self.LENomFormule.text()) != "":
+ self.BOkPressedFormule()
+
+ def BOkPressedFormule(self):
+ # print dir(self)
+ # if self.parent.modified == 'n' : self.parent.initModif()
+
+ nomFormule = str(self.LENomFormule.text())
+ test, erreur = self.node.item.verifNom(nomFormule)
+ if not test:
+ self.editor.afficheInfos(erreur, Qt.red)
+ return
+
+ arguments = str(self.LENomsArgs.text())
+ test, erreur = self.node.item.verifArguments(arguments)
+ if not test:
+ self.editor.afficheInfos(erreur, Qt.red)
+ return
+
+ expression = str(self.LECorpsFormule.text())
+ test, erreur = self.node.item.verifFormule_python(
+ (nomFormule, "REEL", arguments, expression)
+ )
+ if not test:
+ self.editor.afficheInfos(erreur, Qt.red)
+ return
+
+ test = self.node.item.object.updateFormulePython(
+ formule=(nomFormule, "REEL", arguments, expression)
+ )
+ test, erreur = self.node.item.saveFormule(
+ nomFormule, "REEL", arguments, expression
+ )
+ if test:
+ self.node.onValid()
+ self.node.update_valid()
+ commentaire = "Formule saisie"
+ self.editor.afficheInfos(commentaire)
+ else:
+ commentaire = "Formule incorrecte : " + erreur
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.editor.initModif()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from .monWidgetSimpBase import MonWidgetSimpBase
+from desWidgetHeure import Ui_WidgetHeure
+
+
+class MonWidgetHeure(Ui_WidgetHeure, MonWidgetSimpBase):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetSimpBase.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+
+from PyQt5.QtWidgets import QWidget
+
+from Extensions.i18n import tr
+from desWidgetInactif import Ui_WidgetInactif
+import Accas
+import os
+
+
+# Import des panels
+
+
+class MonWidgetInactif(QWidget, Ui_WidgetInactif):
+ """ """
+
+ def __init__(self, node, editor):
+ QWidget.__init__(self, None)
+ self.node = node
+ self.editor = editor
+ self.setupUi(self)
+ from .monWidgetOptionnel import MonWidgetOptionnel
+
+ if self.editor.widgetOptionnel != None:
+ self.monOptionnel = self.editor.widgetOptionnel
+ else:
+ self.monOptionnel = MonWidgetOptionnel(self)
+ self.editor.widgetOptionnel = self.monOptionnel
+ self.editor.splitter.addWidget(self.monOptionnel)
+ self.editor.restoreSplitterSizes()
+ self.afficheOptionnel()
+ self.bAvant.clicked.connect(self.afficheAvant)
+ self.bApres.clicked.connect(self.afficheApres)
+ self.bCatalogue.clicked.connect(self.afficheCatalogue)
+ self.labelNomCommande.setText(tr(self.node.item.nom))
+ self.labelNomCommande.setEnabled(False)
+
+ def traiteClicSurLabel(self):
+ pass
+
+ def donnePremier(self):
+ pass
+
+ def setValide(self):
+ pass
+
+ def afficheOptionnel(self):
+ # N a pas de parentQt. doit donc etre redefini
+ if self.editor.maConfiguration.closeOptionnel:
+ return
+ liste = []
+ # print "dans afficheOptionnel", self.monOptionnel
+ # dans le cas ou l insertion n a pas eu leiu (souci d ordre par exemple)
+ # if self.monOptionnel == None : return
+ self.monOptionnel.parentMC = self
+ self.monOptionnel.afficheOptionnelVide()
+
+ def afficheCatalogue(self):
+ if self.editor.widgetOptionnel != None:
+ self.monOptionnel.hide()
+ self.node.tree.racine.affichePanneau()
+ self.node.tree.racine.select()
+
+ def afficheApres(self):
+ self.node.selectApres()
+
+ def afficheAvant(self):
+ self.node.selectAvant()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os
+
+# Modules Eficas
+from PyQt5.QtWidgets import QWidget
+from Extensions.i18n import tr
+
+from desWidgetInformation import Ui_WidgetInformative
+
+
+class MonWidgetInfo(Ui_WidgetInformative, QWidget):
+ # c est juste la taille des differents widgets de base qui change
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ QWidget.__init__(self, None)
+ self.setupUi(self)
+ valeur = node.item.getValeur()
+ self.lineEditVal.setText(str(valeur))
+ self.lineEditVal.setReadOnly(True)
+ parentQt.commandesLayout.insertWidget(-1, self)
+
+ commande.listeAffichageWidget.append(self.lineEditVal)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os
+
+# Modules Eficas
+from PyQt5.QtWidgets import QCheckBox, QScrollBar, QFrame, QApplication, QLabel
+from PyQt5.QtWidgets import QSizePolicy, QSpacerItem
+from PyQt5.QtGui import QPalette, QFont
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+
+from desWidgetIntoSug import Ui_WidgetIntoSug
+from monWidgetPlusieursInto import MonWidgetPlusieursInto
+
+
+class GereAjoutDsPossible:
+ def LEValeurAjouteDsPossible(self):
+ text = str(self.lineEditVal.text())
+ if text == "":
+ return
+ # il faudrait essauer d en obtenir un reel, un tuple ou ...
+ # si cela est utilise pour autre chose que Telemac
+ # tout devrait etre fait ici
+ if not isinstance(text, str):
+ self.lineEditVal.setText("")
+ return
+ if self.node.item.hasIntoSug():
+ self.maListeDeValeur = list(self.node.item.getListePossibleAvecSug([]))
+ self.maListeDeValeur.insert(0, text)
+ else:
+ try:
+ self.monSimpDef.intoSug.insert(0, text)
+ except:
+ self.monSimpDef.intoSug = list(self.monSimpDef.intoSug)
+ self.monSimpDef.intoSug.insert(0, text)
+ # selon si on est une liste ou un combo
+ try:
+ self.ajouteValeurPossible(text)
+ except:
+ self.setValeurs()
+
+
+class MonWidgetIntoSug(Ui_WidgetIntoSug, MonWidgetPlusieursInto, GereAjoutDsPossible):
+ # Attention Attention
+ # cette wdget ne fonctionne actuellement que pour Telemac
+ # on attend du texte . on n essaye pas de transformer
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetPlusieursInto.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os, sys
+
+# Modules Eficas
+from Extensions.i18n import tr
+from .feuille import Feuille
+from Extensions.eficas_exception import EficasException
+
+
+from desWidgetMatrice import Ui_desWidgetMatrice
+
+from PyQt5.QtCore import QSize, Qt
+from PyQt5.QtWidgets import QTableWidgetItem, QTableWidget
+from PyQt5.QtGui import QIcon, QColor
+from PyQt5.QtWidgets import QMessageBox
+
+
+class MonWidgetMatrice(Ui_desWidgetMatrice, Feuille):
+ # c est juste la taille des differents widgets de base qui change
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.monType = self.node.item.object.definition.type[0]
+ parentQt.commandesLayout.insertWidget(-1, self)
+ self.nbLigs = 0
+ self.nbCols = 0
+ self.creeColonnes()
+ self.connecterSignaux()
+ self.initialValeur()
+
+ def connecterSignaux(self):
+ self.TBMatrice.itemChanged.connect(self.itemChanged)
+ self.PBrefresh.clicked.connect(self.acceptVal)
+ self.TBMatrice.focusOutEvent = self.monFocusOutEvent
+
+ def monFocusOutEvent(self, event):
+ self.acceptVal()
+ QTableWidget.focusOutEvent(self.TBMatrice, event)
+
+ def itemChanged(self):
+ monItem = self.TBMatrice.currentItem()
+ if monItem == None:
+ return
+ texte = monItem.text()
+ if texte == "":
+ return
+ boolOk, commentaire = self.monType.verifItem(texte, self.node.item.object)
+ if not boolOk:
+ 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):
+ if self.monType.methodeCalculTaille != None:
+ try:
+ MonWidgetMatrice.__dict__[self.monType.methodeCalculTaille](*(self,))
+ except:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise execution "),
+ tr("impossible d executer la methode ")
+ + self.monType.methodeCalculTaille,
+ )
+ return
+ else:
+ self.nbLigs = self.monType.nbLigs
+ self.nbCols = self.monType.nbCols
+ self.TBMatrice.setColumnCount(self.nbCols)
+ self.TBMatrice.setRowCount(self.nbLigs)
+ if self.nbLigs < 15:
+ taille = 50
+ else:
+ taille = 40
+ 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.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):
+ liste = self.node.item.getValeur()
+ if liste == None:
+ return
+ dejaAffiche = 0
+ if (len(liste)) != self.nbLigs:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise dimension de matrice"),
+ tr("le nombre de ligne n est pas egal a ") + str(self.nbLigs),
+ )
+ return
+ for i in range(self.nbLigs):
+ inter = liste[i]
+ if (len(inter)) != self.nbCols:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise dimension de matrice"),
+ tr("le nombre de colonne n est pas egal a ") + str(self.nbCols),
+ )
+ 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 = []
+ for i in range(self.nbLigs):
+ listeCol = []
+ for j in range(self.nbCols):
+ monItem = self.TBMatrice.item(i, j)
+ if monItem:
+ texte = monItem.text()
+ else:
+ texte = ""
+ if texte != "":
+ val = self.monType.convertItem(texte)
+ else:
+ val = None
+ listeCol.append(val)
+ liste.append(listeCol)
+ self.node.item.setValeur(liste)
+
+
+class MonWidgetMatriceOT(MonWidgetMatrice):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ monWidgetMatrice.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def connecterSignaux(self):
+ self.TBMatrice.itemChanged.connect(self.itemChanged)
+ self.PBrefresh.clicked.connect(self.afficheEntete)
+
+ def afficheEntete(self):
+ self.objSimp.changeEnteteMatrice()
+ self.TBMatrice.clear()
+ if self.node.item.getValeur() == None:
+ self.initialSsValeur()
+ else:
+ try:
+ self.initialValeur()
+ except:
+ self.initialSsValeur()
+ self.node.item.object.state = "changed"
+ self.node.item.object.parent.state = "changed"
+ self.setValide()
+ self.parentQt.setValide()
+ self.node.item.jdc.isValid()
+
+ def itemChanged(self):
+ monItem = self.TBMatrice.currentItem()
+ if monItem == None:
+ return
+ texte = monItem.text()
+ if texte == "":
+ return
+ try:
+ val = float(str(texte))
+ ok = True
+ except:
+ ok = False
+ if ok == False:
+ self.editor.afficheInfos(tr("Entrer un float SVP"), Qt.red)
+ monItem.setText("")
+ return
+ if self.monType.valSup != None:
+ if val > self.monType.valSup:
+ self.editor.afficheInfos(
+ tr("Entrer un float inferieur a ") + repr(self.monType.valSup),
+ Qt.red,
+ )
+ monItem.setText("")
+ return
+ if self.monType.valMin != None:
+ if val < self.monType.valMin:
+ self.editor.afficheInfos(
+ tr("Entrer un float superieur a ") + repr(self.monType.valMin),
+ Qt.red,
+ )
+ monItem.setText("")
+ return
+ self.editor.afficheInfos("")
+ if self.monType.structure != None:
+ MonWidgetMatrice.__dict__[self.monType.structure](*(self,))
+ self.acceptVal()
+
+ def creeColonnes(self):
+ if self.monType.methodeCalculTaille != None:
+ try:
+ MonWidgetMatrice.__dict__[self.monType.methodeCalculTaille](*(self,))
+ except:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise execution "),
+ tr("impossible d executer la methode ")
+ + self.monType.methodeCalculTaille,
+ )
+ return
+ else:
+ self.nbLigs = self.monType.nbLigs
+ self.nbCols = self.monType.nbCols
+
+ def nbDeVariables(self):
+ # uniquement pour OT
+ jdc = self.node.item.object.jdc
+ etape = self.node.item.object.etape
+ self.listeVariables = jdc.getVariables(etape)
+ if self.listeVariables == []:
+ QMessageBox.critical(
+ self, tr("Mauvaise Commande "), tr("Aucune variable connue")
+ )
+ return
+ self.TBMatrice.setColumnCount(len(self.listeVariables))
+ self.TBMatrice.setRowCount(len(self.listeVariables))
+ self.nbLigs = len(self.listeVariables)
+ self.nbCols = len(self.listeVariables)
+
+ def initialSsValeur(self):
+ # uniquement pour OT
+ self.listeVariables = []
+ for row in range(self.nbLigs):
+ for column in range(self.nbCols):
+ if row == column:
+ initialFloat = 1
+ else:
+ initialFloat = 0
+ self.TBMatrice.setItem(row, column, QTableWidgetItem(str(initialFloat)))
+ header = []
+ for var in liste[0]:
+ header.append(str(var))
+ self.TBMatrice.setVerticalHeaderLabels(header)
+ self.TBMatrice.setHorizontalHeaderLabels(header)
+
+ def nbDeVariables(self):
+ # uniquement pour OT
+ jdc = self.node.item.object.jdc
+ etape = self.node.item.object.etape
+ self.listeVariables = jdc.getVariables(etape)
+ if self.listeVariables == []:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise Commande "),
+ tr("Aucune variable connue. Entrez les variables avant la matrice"),
+ )
+ return
+ self.TBMatrice.setColumnCount(len(self.listeVariables))
+ self.TBMatrice.setRowCount(len(self.listeVariables))
+ self.nbLigs = len(self.listeVariables)
+ self.nbCols = len(self.listeVariables)
+
+ def initialValeur(self):
+ # uniquement pour OT
+ liste = self.node.item.getValeur()
+ dejaAffiche = 0
+ if (len(liste)) != self.nbLigs + 1:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise dimension de matrice"),
+ tr("le nombre de ligne n est pas egal a ") + str(self.nbLigs),
+ )
+ raise EficasException("dimension")
+ for i in range(self.nbLigs):
+ inter = liste[i + 1]
+ if (len(inter)) != self.nbCols:
+ QMessageBox.critical(
+ self,
+ tr("Mauvaise dimension de matrice"),
+ tr("le nombre de colonne n est pas egal a ") + str(self.nbCols),
+ )
+ raise EficasException("dimension")
+ for j in range(self.nbCols):
+ self.TBMatrice.setItem(i, j, QTableWidgetItem(str(liste[i][j])))
+ header = []
+ for var in liste[0]:
+ header.append(str(var))
+ self.TBMatrice.setVerticalHeaderLabels(header)
+ self.TBMatrice.setHorizontalHeaderLabels(header)
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+import types, os
+
+from PyQt5.QtWidgets import QWidget
+from PyQt5.QtGui import QIcon
+
+from desWidgetNiveauFact import Ui_WidgetNiveauFact
+from InterfaceGUI.QT5.monWidgetOptionnel import MonWidgetOptionnel
+from InterfaceGUI.QT5.groupe import Groupe
+
+from Extensions.i18n import tr
+
+class MonWidgetNiveauFact(Ui_WidgetNiveauFact, Groupe):
+ """ """
+
+ def __init__(self, node, editor, definition, obj):
+ self.listeAffichageWidget = []
+ self.listeBoutonAChanger = []
+ Groupe.__init__(self, node, editor, None, definition, obj, 1, self)
+ from InterfaceGUI.QT5 import composimp
+
+ if isinstance(self.node, composimp.Node):
+ widget = self.node.getPanelGroupe(self, self.maCommande)
+ self.listeBoutonAChanger.append(widget.RBValide)
+ self.afficheOptionnel()
+ self.inhibe = False
+ self.labelDoc.setText(self.node.item.getFr())
+ self.labelNomCommande.setText(self.node.item.getLabelText()[0])
+
+ def reaffiche(self, nodeAVoir=None):
+ self.node.setDeplieChildren()
+ self.node.afficheCeNiveau()
+ self.editor.fenetreCentraleAffichee.labelDoc.setText(self.node.item.getFr())
+ self.editor.fenetreCentraleAffichee.labelNomCommande.setText(
+ self.node.item.getLabelText()[0]
+ )
+
+ def getPanel(self):
+ # necessaire pour handleOnItem de browser.py
+ # non appele
+ pass
+
+ def donnePremier(self):
+ # print "dans donnePremier"
+ QApplication.processEvents()
+ if self.listeAffichageWidget != []:
+ self.listeAffichageWidget[0].setFocus(7)
+ QApplication.processEvents()
+ # print self.focusWidget()
+
+ def focusNextPrevChild(self, next):
+ # on s assure que ce n est pas un chgt de fenetre
+ # print "je passe dans focusNextPrevChild"
+ if self.editor.fenetreCentraleAffichee != self:
+ return True
+ f = self.focusWidget()
+
+ if f not in self.listeAffichageWidget:
+ i = 0
+ while not hasattr(f, "AAfficher"):
+ if f == None:
+ i = -1
+ break
+ f = f.parentWidget()
+ if hasattr(f, "AAfficher"):
+ f = f.AAfficher
+ if i != -1:
+ i = self.listeAffichageWidget.index(f)
+ else:
+ i = self.listeAffichageWidget.index(f)
+ if (i == len(self.listeAffichageWidget) - 1) and next and not self.inhibe:
+ try:
+ self.listeAffichageWidget[1].setFocus(7)
+ w = self.focusWidget()
+ self.inhibe = 1
+ w.focusPreviousChild()
+ self.inhibe = 0
+ return True
+ except:
+ pass
+
+ if i == 0 and next == False and not self.inhibe:
+ if hasattr(self.editor.fenetreCentraleAffichee, "scrollArea"):
+ self.editor.fenetreCentraleAffichee.scrollArea.ensureWidgetVisible(
+ self.listeAffichageWidget[-1]
+ )
+ self.listeAffichageWidget[-2].setFocus(7)
+ self.inhibe = 1
+ w = self.focusWidget()
+ w.focusNextChild()
+ self.inhibe = 0
+ return True
+
+ if i == 0 and next == True and not self.inhibe:
+ self.listeAffichageWidget[0].setFocus(7)
+ self.inhibe = 1
+ w = self.focusWidget()
+ w.focusNextChild()
+ self.inhibe = 0
+ return True
+
+ if i > 0 and next == False and not self.inhibe:
+ if isinstance(self.listeAffichageWidget[i - 1], QRadioButton):
+ self.listeAffichageWidget[i - 1].setFocus(7)
+ return True
+ return QWidget.focusNextPrevChild(self, next)
+
+ def etablitOrdre(self):
+ # si on boucle on perd l'ordre
+ i = 0
+ while i + 1 < len(self.listeAffichageWidget):
+ self.setTabOrder(
+ self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
+ )
+ i = i + 1
+
+ def afficheSuivant(self, f):
+ # print ('ds afficheSuivant')
+ try:
+ i = self.listeAffichageWidget.index(f)
+ next = i + 1
+ except:
+ next = 1
+ if next == len(self.listeAffichageWidget):
+ next = 0
+ try:
+ self.listeAffichageWidget[next].setFocus(7)
+ except:
+ pass
+
+ def afficheOptionnel(self):
+ # N a pas de parentQt. doit donc etre redefini
+ # print ('ds afficheOptionnel')
+ if self.editor.maConfiguration.closeOptionnel:
+ return
+ if self.editor.widgetOptionnel != None:
+ self.monOptionnel = self.editor.widgetOptionnel
+ else:
+ self.editor.inhibeSplitter = 1
+ self.monOptionnel = MonWidgetOptionnel(self.editor)
+ self.editor.widgetOptionnel = self.monOptionnel
+ self.editor.splitter.addWidget(self.monOptionnel)
+ self.editor.ajoutOptionnel()
+ self.editor.inhibeSplitter = 0
+ self.monOptionnel.vireTous()
+
+ liste, liste_rouge = self.ajouteMCOptionnelDesBlocs()
+ self.monOptionnel.parentCommande = self
+ self.monOptionnel.titre(self.obj.nom)
+ self.monGroupe = self.monOptionnel.afficheOptionnel(liste, liste_rouge, self)
+
+ def setValide(self):
+ Groupe.setValide(self)
+ for bouton in self.listeBoutonAChanger:
+ couleur = self.node.item.getIconName()
+ monIcone = QIcon(self.repIcon + "/" + couleur + ".png")
+ bouton.setIcon(monIcone)
+
+
+class MonWidgetNiveauFactTableau(MonWidgetNiveauFact):
+ def __init__(self, node, editor, definition, obj):
+ MonWidgetNiveauFact.__init__(self, node, editor, definition, obj)
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+
+from PyQt5.QtWidgets import QCheckBox, QWidget
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+from desWidgetOptionnel import Ui_WidgetOptionnel
+from .monGroupeOptionnel import MonGroupeOptionnel
+
+
+# Import des panels
+class MonWidgetOptionnel(QWidget, Ui_WidgetOptionnel):
+ def __init__(self, parentQt):
+ # print ("dans init de monWidgetOptionnel ", parentQt )
+ QWidget.__init__(self, None)
+ self.setupUi(self)
+ self.dicoMCWidgetOptionnel = {}
+ self.parentQt = parentQt
+
+ def afficheOptionnel(self, liste, liste_rouge, MC):
+ # print ('afficheOptionnel MonWidgetOptionnel',self, liste,MC.node.item.nom)
+ self.vireLesAutres(MC)
+
+ if MC.node.item.nom in self.dicoMCWidgetOptionnel:
+ # print (MC.node.item.nom)
+ self.dicoMCWidgetOptionnel[MC.node.item.nom].close()
+ self.dicoMCWidgetOptionnel[MC.node.item.nom].setParent(None)
+ self.dicoMCWidgetOptionnel[MC.node.item.nom].deleteLater()
+ del self.dicoMCWidgetOptionnel[MC.node.item.nom]
+ if liste == []:
+ return
+ groupe = MonGroupeOptionnel(liste, liste_rouge, self, MC)
+ self.groupesOptionnelsLayout.insertWidget(0, groupe)
+ self.dicoMCWidgetOptionnel[MC.node.item.nom] = groupe
+ return groupe
+
+ def vireLesAutres(self, MC):
+ # print( "je passe dans vireLesAutres")
+ genea = MC.obj.getGenealogie()
+ # print (genea)
+ for k in list(self.dicoMCWidgetOptionnel.keys()):
+ # print (k)
+ # if k not in genea : print ( k)
+ if k not in genea:
+ self.dicoMCWidgetOptionnel[k].close()
+ del self.dicoMCWidgetOptionnel[k]
+ # print( "fin vireLesAutres")
+
+ def vireTous(self):
+ for k in list(self.dicoMCWidgetOptionnel.keys()):
+ self.dicoMCWidgetOptionnel[k].close()
+ del self.dicoMCWidgetOptionnel[k]
+
+ def afficheOptionnelVide(self):
+ self.GeneaLabel.setText("")
+ for k in list(self.dicoMCWidgetOptionnel.keys()):
+ self.dicoMCWidgetOptionnel[k].close()
+ del self.dicoMCWidgetOptionnel[k]
+
+ def titre(self, MC):
+ if (
+ self.parentCommande.node.editor.maConfiguration.closeFrameRechercheCommande
+ == True
+ ):
+ self.frameLabelCommande.close()
+ return
+ labeltext, fonte, couleur = self.parentCommande.node.item.getLabelText()
+ l = tr(labeltext)
+ li = []
+ while len(l) > 25:
+ li.append(l[0:24])
+ l = l[24:]
+ li.append(l)
+ texte = ""
+ for l in li:
+ texte += l + "\n"
+ texte = texte[0:-2]
+ self.GeneaLabel.setText(tr("Options pour \n") + texte)
--- /dev/null
+# Copyright (C) 2007-2024 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
+#
+
+import os, re
+import types
+
+from desWidgetParam import Ui_WidgetParam
+from InterfaceGUI.QT5.gereIcones import FacultatifOuOptionnel
+from PyQt5.QtWidgets import QWidget, QMessageBox
+from PyQt5.QtGui import QIcon
+
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
+
+pattern_name = re.compile(r"^[^\d\W]\w*\Z")
+
+class MonWidgetParam(QWidget, Ui_WidgetParam, FacultatifOuOptionnel):
+ """ """
+
+ def __init__(self, node, editor, commentaire):
+ QWidget.__init__(self, None)
+ self.node = node
+ self.node.fenetre = self
+ self.setupUi(self)
+ self.editor = editor
+ self.appliEficas = self.editor.appliEficas
+ self.repIcon = self.appliEficas.repIcon
+
+ self.setIconePoubelle()
+ if not (self.node.item.object.isValid()):
+ icon = QIcon(self.repIcon + "/ast-red-ball.png")
+ self.RBValide.setIcon(icon)
+
+ self.remplit()
+ # if self.editor.code in ['MAP','CARMELCND','CF'] : self.bCatalogue.close()
+ if self.editor.code in ["MAP", "CARMELCND"]:
+ self.bCatalogue.close()
+ else:
+ self.bCatalogue.clicked.connect(self.afficheCatalogue)
+
+ self.lineEditVal.returnPressed.connect(self.LEvaleurPressed)
+ self.lineEditNom.returnPressed.connect(self.LENomPressed)
+ self.bAvant.clicked.connect(self.afficheAvant)
+ self.bApres.clicked.connect(self.afficheApres)
+ self.bVerifie.clicked.connect(self.verifiePressed)
+
+ self.editor.fermeOptionnel()
+
+ def afficheCatalogue(self):
+ self.node.tree.racine.affichePanneau()
+ if self.node:
+ self.node.select()
+ else:
+ self.node.tree.racine.select()
+
+ def remplit(self):
+ nom = self.node.item.getNom()
+ self.lineEditNom.setText(nom)
+
+ valeur = self.node.item.getValeur()
+ if valeur == None:
+ self.lineEditVal.clear()
+ elif type(valeur) == list:
+ texte = "["
+ for l in valeur:
+ texte = texte + str(l) + ","
+ texte = texte[0:-1] + "]"
+ self.lineEditVal.setText(texte)
+ else:
+ self.lineEditVal.setText(str(valeur))
+
+ def donnePremier(self):
+ self.lineEditVal.setFocus(7)
+
+ def LEvaleurPressed(self):
+ if self.verifiePressed() == False:
+ QMessageBox.warning(
+ self, tr("Modification Impossible"), tr("le parametre n'est pas valide")
+ )
+ nom = str(self.lineEditNom.text())
+ val = str(self.lineEditVal.text())
+ self.node.item.setNom(nom)
+ self.node.item.setValeur(val)
+ self.node.updateTexte()
+
+ def LENomPressed(self):
+ self.LEvaleurPressed()
+
+ def verifiePressed(self):
+ nomString = str(self.lineEditNom.text())
+ if not pattern_name.match(nomString):
+ self.LECommentaire.setText(
+ nomString + tr(" n est pas un identifiant correct")
+ )
+ return False
+
+ valString = str(self.lineEditVal.text())
+
+ contexte = {}
+ exec("from math import *", contexte)
+ jdc = self.node.item.getJdc()
+ for p in jdc.params:
+ try:
+ tp = p.nom + "=" + str(repr(p.valeur))
+ exec(tp, contexte)
+ except exc:
+ pass
+
+ monTexte = nomString + "=" + valString
+ try:
+ exec(monTexte, contexte)
+ except (
+ ValueError,
+ TypeError,
+ NameError,
+ RuntimeError,
+ ZeroDivisionError,
+ ) as exc:
+ self.LECommentaire.setText(tr("Valeur incorrecte: ") + str(exc))
+ return False
+ except:
+ self.LECommentaire.setText(tr("Valeur incorrecte "))
+ return False
+
+ self.LECommentaire.setText(tr("Valeur correcte "))
+ return True
+
+ def afficheApres(self):
+ self.node.selectApres()
+
+ def afficheAvant(self):
+ self.node.selectAvant()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from Extensions.i18n import tr
+from .monWidgetPlusieursIntoOrdonne import MonWidgetPlusieursIntoOrdonne
+from .politiquesValidation import PolitiquePlusieurs
+
+from six.moves import range
+from PyQt5.QtWidgets import QScrollBar
+
+
+class MonWidgetPlusieursASSDIntoOrdonne(MonWidgetPlusieursIntoOrdonne):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.numLineEditEnCours = 0
+ MonWidgetPlusieursIntoOrdonne.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def prepareListeResultat(self):
+ for i in self.listeLE:
+ i.close()
+ self.listeLE = []
+ self.vScrollBar = self.scrollArea.verticalScrollBar()
+ self.listeAAfficher = self.node.item.getSdAvantDuBonType()
+
+ if len(self.listeAAfficher) == 0:
+ self.ajoutLE(0)
+ return
+
+ if len(self.listeAAfficher) * 30 > 400:
+ self.resize(self.width(), 200)
+ else:
+ self.resize(self.width(), len(self.listeAAfficher) * 30)
+ self.politique = PolitiquePlusieurs(self.node, self.editor)
+ for i in range(1, len(self.listeAAfficher) + 1):
+ self.ajoutLE(i)
+ for i in range(len(self.listeAAfficher)):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ courant.setText(str(self.listeAAfficher[i]))
+ self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types, os
+from PyQt5.QtGui import QIcon
+from PyQt5.QtWidgets import QApplication, QMessageBox, QScrollArea
+from PyQt5.QtCore import QTimer, QSize, Qt
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from InterfaceGUI.QT5.feuille import Feuille
+from desWidgetPlusieursBase import Ui_WidgetPlusieursBase
+from InterfaceGUI.QT5.politiquesValidation import PolitiquePlusieurs
+from InterfaceGUI.QT5.qtSaisie import SaisieValeur
+from InterfaceGUI.QT5.gereListe import GereListe
+from InterfaceGUI.QT5.gereListe import GerePlie
+from InterfaceGUI.QT5.gereListe import LECustom
+
+dicoLongueur = {2: 95, 3: 125, 4: 154, 5: 183, 6: 210, float("inf"): 210}
+hauteurMax = 253
+
+
+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.dictLE = {}
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ GereListe.__init__(self)
+ self.gereIconePlier()
+ self.BSelectFichier.clicked.connect(self.selectInFile)
+
+ repIcon = self.node.editor.appliEficas.repIcon
+ fichier = os.path.join(repIcon, "arrow_up.png")
+ icon = QIcon(fichier)
+ self.RBHaut.setIcon(icon)
+ 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)
+ 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)
+
+ 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.setMinimumHeight(hauteurMax)
+ self.finCommentaireListe()
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
+ self.AAfficher = self.lineEditVal1
+ self.inInit = False
+ # PNPN a completer __ si tuple le type des tuples sinon le tuple
+ # trop moche
+ # self.monCommentaireLabel.setText(self.finCommentaireListe())
+ self.monCommentaireLabel.setText("")
+ self.scrollArea.leaveEvent = self.leaveEventScrollArea
+ self.inhibeChangeValeur = False
+ self.dejaAverti = False
+
+ 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)
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ index = 1
+ for valeur in self.listeValeursCourantes:
+ val = self.politique.getValeurTexte(valeur)
+ nomLineEdit = "lineEditVal" + str(index)
+ if hasattr(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))
+ self.dictLE[index] = 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,
+ ):
+ # print ('ajoutLineEdit plusieursBase')
+ # print ('self.indexDernierLabel', self.indexDernierLabel)
+ self.indexDernierLabel = self.indexDernierLabel + 1
+ nomLineEdit = "lineEditVal" + str(self.indexDernierLabel)
+ if hasattr(self, nomLineEdit):
+ self.indexDernierLabel = self.indexDernierLabel - 1
+ return
+ nouveauLE = LECustom(self.scrollArea, self, self.indexDernierLabel)
+ self.verticalLayoutLE.insertWidget(self.indexDernierLabel - 1, nouveauLE)
+ nouveauLE.setText("")
+ if self.indexDernierLabel % 2 == 1:
+ nouveauLE.setStyleSheet("background:rgb(210,210,210)")
+ else:
+ nouveauLE.setStyleSheet("background:rgb(235,235,235)")
+ nouveauLE.setFrame(False)
+ nouveauLE.returnPressed.connect(self.changeValeur)
+
+ setattr(self, nomLineEdit, nouveauLE)
+ self.listeAffichageWidget.append(nouveauLE)
+ self.etablitOrdre()
+ if valeur != None:
+ nouveauLE.setText(str(valeur))
+ self.dictLE[self.indexDernierLabel] = valeur
+ else:
+ self.dictLE[self.indexDernierLabel] = None
+ # deux lignes pour que le ensureVisible fonctionne
+ self.estVisible = nouveauLE
+ if self.inInit == False:
+ QTimer.singleShot(1, self.rendVisibleLigne)
+
+ def etablitOrdre(self):
+ i = 0
+ while i + 1 < len(self.listeAffichageWidget):
+ self.listeAffichageWidget[i].setFocusPolicy(Qt.StrongFocus)
+ self.setTabOrder(
+ self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
+ )
+ i = i + 1
+ # si on boucle on perd l'ordre
+
+ def rendVisibleLigne(self):
+ QApplication.processEvents()
+ self.estVisible.setFocus()
+ self.scrollArea.ensureWidgetVisible(self.estVisible, 0, 0)
+
+ def finCommentaire(self):
+ return self.finCommentaireListe()
+
+ def ajout1Valeur(self, valeur=None):
+ # print ('ajout1Valeur plusieursBase')
+ if valeur == None:
+ return
+ liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
+ if validite == 0:
+ return
+ if liste == []:
+ return
+ listeVal = []
+ for valeur in self.listeValeursCourantes:
+ listeVal.append(valeur)
+ validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
+ liste, -1, listeVal
+ )
+ if comm2 != "" and comm != None:
+ return comm2
+ if validite:
+ self.listeValeursCourantes = self.listeValeursCourantes + listeRetour
+ if len(self.listeValeursCourantes) > self.monSimpDef.min:
+ self.node.item.setValeur(self.listeValeursCourantes)
+ self.reaffiche()
+ return None
+ else:
+ return comm2 + " " + comm
+
+ def reaffiche(self):
+ # A priori, on ne fait rien
+ pass
+
+ def ajoutNValeur(self, liste):
+ # print ('ajoutNValeur plusieursBase')
+ # ----------------------------
+ # 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
+ # chaque valeur. d ou l ajout de ajoutNTuple a politique plusieurs
+
+ listeFormatee = list(liste)
+
+ min, max = self.node.item.getMinMax()
+ if self.objSimp.valeur == None:
+ listeComplete = listeFormatee
+ else:
+ listeComplete = self.objSimp.valeur + listeFormatee
+
+ if len(listeComplete) > max:
+ texte = tr("Nombre maximum de valeurs ") + str(max) + tr(" atteint")
+ self.editor.afficheInfos(texte, Qt.red)
+ return
+
+ validite, comm, comm2, listeRetour = self.politique.ajoutNTuple(listeComplete)
+ if not validite:
+ self.editor.affiche_infos(texte, Qt.red)
+ return
+
+ # on calcule le dernier lineedit rempli avant de changer la valeur
+ if self.objSimp.valeur != None:
+ indexDernierRempli = len(self.objSimp.valeur)
+ else:
+ indexDernierRempli = 0
+
+ self.politique.recordValeur(listeComplete)
+
+ indexDernierRempli = 0
+ while indexDernierRempli < len(liste):
+ texte = liste[indexDernierRempli]
+ if indexDernierRempli < self.indexDernierLabel:
+ nomLineEdit = "lineEditVal" + str(indexDernierRempli + 1)
+ courant = getattr(self, nomLineEdit)
+ courant.setText(str(texte))
+ else:
+ self.ajoutLineEdit(texte)
+ indexDernierRempli = indexDernierRempli + 1
+
+ def changeValeur(self, changeDePlace=True, oblige=False):
+ # print ('achangeValeur plusieursBase', self)
+ # import traceback
+ # traceback.print_stack()
+ if self.inhibeChangeValeur:
+ return
+ self.inhibeChangeValeur = True
+ donneFocus = None
+ derniereValeur = None
+ self.listeValeursCourantes = []
+ fin = self.indexDernierLabel
+ if (not ("TXM" in self.objSimp.definition.type)) and not (self.dejaAverti):
+ for i in range(1, fin):
+ nomLineEdit = "lineEditVal" + str(i)
+ courant = getattr(self, nomLineEdit)
+ valeur = courant.text()
+ lval = valeur.split(",")
+ if len(lval) > 1:
+ self.dejaAverti = True
+ QMessageBox.warning(
+ self,
+ tr('"," used'),
+ 'Perhaps, character "," is used in '
+ + str(valeur)
+ + 'intead of "."',
+ )
+ break
+ # msgBox = QMessageBox()
+ # msgBox.setText("separator ',' ")
+ # msgBox.setInformativeText("Do you want to enter " + str (lval) + "?")
+ # msgBox.setInformativeText (" you want to enter " + str (lval) + "?")
+ # msgBox.setStandardButtons( QMessageBox.Ok | QMessageBox.Cancel)
+ # msgBox.setDefaultButton(QMessageBox.Ok)
+ # ret = msgBox.exec()
+ # tres dicutable 20210401 j enleve la boucle
+ # if faut remtrre self.inhibeChangeValeur si on la reactive
+ # if ret == 1024:
+ # courant.setText(lval[0])
+ # self.ajoutNValeur(lval[1:])
+ # self.listeValeursCourantes = []
+
+ for i in range(1, self.indexDernierLabel + 1):
+ nomLineEdit = "lineEditVal" + str(i)
+ courant = getattr(self, nomLineEdit)
+ valeur = courant.text()
+ if valeur != None and valeur != "":
+ commentaire = self.ajout1Valeur(valeur)
+ if commentaire != None:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ courant.setText("")
+ donneFocus = courant
+ self.reaffiche()
+ return
+ else:
+ self.editor.afficheInfos("")
+ elif donneFocus == None:
+ donneFocus = courant
+
+ nomDernierLineEdit = "lineEditVal" + str(self.indexDernierLabel)
+ dernier = getattr(self, nomDernierLineEdit)
+ derniereValeur = dernier.text()
+ if changeDePlace:
+ if donneFocus != None:
+ donneFocus.setFocus()
+ self.scrollArea.ensureWidgetVisible(donneFocus)
+ elif self.indexDernierLabel < self.monSimpDef.max:
+ self.ajoutLineEdit()
+ if self.listeValeursCourantes == []:
+ return
+ min, max = self.node.item.getMinMax()
+ if len(self.listeValeursCourantes) < self.monSimpDef.min:
+ self.editor.afficheInfos(
+ tr("nb min de valeurs : ") + str(self.monSimpDef.min)
+ )
+ if len(self.listeValeursCourantes) < min and oblige == True:
+ return
+ if len(self.listeValeursCourantes) > max:
+ return
+ retour = self.node.item.setValeur(self.listeValeursCourantes)
+ if len(self.listeValeursCourantes) == self.monSimpDef.max:
+ self.editor.afficheInfos(tr("nb max de valeurs atteint"))
+ self.setValide()
+ self.reaffiche()
+ self.inhibeChangeValeur = False
+
+ def leaveEventScrollArea(self, event):
+ # print ('achangeValeur plusieursBase')
+ self.changeValeur(changeDePlace=False)
+ QScrollArea.leaveEvent(self.scrollArea, event)
+
+
+# Avertissement quand on quitte le widget
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2020 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 Eficas
+from Extensions.i18n import tr
+from .monWidgetSimpTxt import MonWidgetSimpTxt
+from .monWidgetPlusieursBase import MonWidgetPlusieursBase
+from copy import copy, deepcopy
+from PyQt5.QtCore import Qt
+
+
+class MonWidgetPlusieursCreeUserAssd(MonWidgetPlusieursBase):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetPlusieursBase.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ self.etablitOrdre()
+ self.scrollArea.leaveEvent = self.leaveEventScrollArea
+ self.RBHaut.close()
+ self.RBBas.close()
+
+ def ajout1Valeur(self, valeur=None):
+ if not valeur in list(self.dictValeurs.keys()):
+ validite, commentaire = self.objSimp.creeUserASSDetSetValeur(valeur)
+ MonWidgetPlusieursBase.ajout1Valeur(self, valeur)
+
+ def changeValeur(self, changeDePlace=False, oblige=False):
+ # print ('dans changeValeur du CreeUserAssd', changeDePlace, self.numLineEditEnCours)
+ # import traceback
+ # traceback.print_stack()
+ self.changeUnLineEdit = False
+ valeur = self.lineEditEnCours.text()
+ if self.numLineEditEnCours in list(self.dictLE.keys()):
+ oldValeurUserAssd = self.dictLE[self.numLineEditEnCours]
+ if oldValeurUserAssd == None or oldValeurUserAssd == "":
+ enCreation = True
+ oldValeurUserAssd == True
+ else:
+ enCreation = False
+ else:
+ enCreation = True
+ oldValeurUserAssd = None
+
+ if oldValeurUserAssd and oldValeurUserAssd.nom == valeur:
+ self.selectionneNext()
+ return
+
+ if valeur != "":
+ if not enCreation:
+ validite, commentaire = self.node.item.renommeSdCreeDsListe(
+ oldValeurUserAssd, valeur
+ )
+ if commentaire != "" and not validite:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.lineEditEnCours.setText(oldValeurUserAssd.nom)
+ nomDernierLineEdit = "lineEditVal" + str(self.numLineEditEnCours + 1)
+ dernier = getattr(self, nomDernierLineEdit)
+ dernier.setFocus()
+ return
+
+ validite, objASSD, commentaire = self.objSimp.creeUserASSD(valeur)
+ if commentaire != "" and not validite:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.lineEditEnCours.setText("")
+ if objASSD:
+ objASSD.supprime(self.objSimp)
+ return
+ else:
+ validite = 1
+ objASSD = None
+ commentaire = ""
+
+ # on relit tout pour tenir compte des lignes blanches
+ oldValeur = self.objSimp.valeur
+ liste = []
+ for i in range(1, self.indexDernierLabel + 1):
+ if i == self.numLineEditEnCours and objASSD:
+ liste.append(objASSD)
+ elif self.dictLE[i] != None and self.dictLE[i] != "":
+ liste.append(self.dictLE[i])
+ validite = self.node.item.setValeur(liste)
+ if not validite:
+ self.objSimp.valeur = oldValeur
+ self.objSimp.state = "changed"
+ self.setValide()
+ if objASSD:
+ objASSD.supprime(self.objSimp)
+ self.lineEditEnCours.setText(oldValeurUserASSD.nom)
+ return
+
+ validite = self.node.item.isValid()
+ if validite:
+ self.dictLE[self.numLineEditEnCours] = objASSD
+ self.node.item.rattacheUserASSD(objASSD)
+ if self.indexDernierLabel < len(liste):
+ self.ajoutLineEdit()
+ nomDernierLineEdit = "lineEditVal" + str(self.numLineEditEnCours + 1)
+ self.listeValeursCourantes = liste
+ dernier = getattr(self, nomDernierLineEdit)
+ dernier.setFocus()
+ else:
+ self.editor.afficheInfos("ajout impossible", Qt.red)
+ if objASSD:
+ objASSD.supprime(self.objSimp)
+ self.lineEditEnCours.setText("")
+ self.parentQt.propageChange(self.objSimp.definition.type[0], self)
+
+ def selectionneDernier(self):
+ index = len(self.listeValeursCourantes)
+ self.listeAffichageWidget[index].setFocus()
+
+ def leaveEventScrollArea(self, event):
+ pass
+
+ # def echangeDeuxValeurs(self):
+ # self.changeUnLineEdit=False
+ # obj1=self.dictLE[self.num1]
+ # obj2=self.dictLE[self.num2]
+ # self.dictLE[self.num1]=obj2
+ # self.dictLE[self.num2]=obj1
+ # nomLineEdit=self.nomLine+str(self.num1)
+ # courant=getattr(self,nomLineEdit)
+ # if self.dictLE[self.num1] != None : courant.setText(self.dictLE[self.num1].nom)
+ # else : courant.setText("")
+ # nomLineEdit=self.nomLine+str(self.num2)
+ # courant=getattr(self,nomLineEdit)
+ # if self.dictLE[self.num2] != None : courant.setText(self.dictLE[self.num2].nom)
+ # else : courant.setText("")
+ # liste=[]
+ # for i in list(self.dictLE.keys()):
+ # if self.dictLE[i] != None and self.dictLE[i] != "" : liste.append(self.dictLE[i])
+ # validite=self.node.item.setValeur(liste)
+ # self.listeValeursCourantes=liste
+ # courant.setFocus(True)
+
+ def descendLesLignes(self):
+ self.changeUnLineEdit = False
+ if self.numLineEditEnCours == self.indexDernierLabel:
+ return
+ nouvelleValeur = None
+ for i in range(self.numLineEditEnCours + 1, self.indexDernierLabel):
+ valeurAGarder = self.dictLE[i]
+ self.dictLE[i] = nouvelleValeur
+ nomLineEdit = self.nomLine + str(i)
+ courant = getattr(self, nomLineEdit)
+ if nouvelleValeur != None:
+ courant.setText(nouvelleValeur.nom)
+ else:
+ courant.setText("")
+ nouvelleValeur = valeurAGarder
+
+ def moinsPushed(self):
+ if self.numLineEditEnCours == 0:
+ return
+ if self.indexDernierLabel == 0:
+ return
+ objASSD = self.dictLE[self.numLineEditEnCours]
+ if objASSD:
+ objASSD.supprime(self.objSimp)
+ self.lineEditEnCours.setText("")
+ self.dictLE[self.numLineEditEnCours] = None
+
+ for i in range(self.numLineEditEnCours, self.indexDernierLabel - 1):
+ self.dictLE[i] = self.dictLE[i + 1]
+ nomLineEdit = self.nomLine + str(i)
+ courant = getattr(self, nomLineEdit)
+ if self.dictLE[i] != None:
+ courant.setText(self.dictLE[i].nom)
+ else:
+ courant.setText("")
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+ courant = getattr(self, nomLineEdit)
+ courant.setText("")
+ self.dictLE[self.indexDernierLabel] = None
+ liste = []
+ for i in list(self.dictLE.keys()):
+ if self.dictLE[i] != None and self.dictLE[i] != "":
+ liste.append(self.dictLE[i])
+ print(liste)
+ validite = self.node.item.setValeur(liste)
+ self.listeValeursCourantes = liste
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from PyQt5.QtWidgets import QCheckBox, QScrollBar, QFrame, QApplication, QLabel
+from PyQt5.QtWidgets import QSizePolicy, QSpacerItem
+from PyQt5.QtGui import QPalette, QFont
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+
+from InterfaceGUI.QT5.feuille import Feuille
+from desWidgetPlusieursInto import Ui_WidgetPlusieursInto
+from InterfaceGUI.QT5.politiquesValidation import PolitiquePlusieurs
+from InterfaceGUI.QT5.qtSaisie import SaisieValeur
+from InterfaceGUI.QT5.gereListe import GerePlie
+from InterfaceGUI.QT5.gereListe import GereListe
+
+
+class MonWidgetPlusieursInto(Ui_WidgetPlusieursInto, Feuille, GerePlie, GereListe):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.index = 1
+ self.alpha = 0
+ self.listeCB = []
+ self.listeCbRouge = []
+ self.listeValeursCourantes = node.item.getListeValeurs()
+ if self.listeValeursCourantes == None:
+ self.listeValeursCourantes = []
+
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ GereListe.__init__(self)
+
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.CBCheck.stateChanged.connect(self.changeTout)
+
+ self.gereIconePlier()
+ self.editor.listeDesListesOuvertes.add(self.node.item)
+ self.inhibe = False
+ # self.finCommentaireListe()
+
+ if self.listeAAfficher == None or self.listeAAfficher == []:
+ spacerItem = QSpacerItem(30, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
+ self.CBLayout.addItem(spacerItem)
+ nouveauCommentaire = QLabel()
+ maPolice = QFont("Times", 16)
+ nouveauCommentaire.setFont(maPolice)
+ nouveauCommentaire.setText(tr("Pas de valeurs possibles"))
+ self.CBLayout.addWidget(nouveauCommentaire)
+ spacerItem2 = QSpacerItem(40, 70, QSizePolicy.Fixed, QSizePolicy.Minimum)
+ self.CBLayout.addItem(spacerItem2)
+
+ if len(self.listeAAfficher) < 30 and hasattr(self, "frameRecherche"):
+ self.frameRecherche.close()
+ if len(self.listeAAfficher) == len(self.listeValeursCourantes):
+ self.CBCheck.setChecked(True)
+ if len(self.listeAAfficher) < 10:
+ self.setMinimumHeight(len(self.listeAAfficher) * 22 + 55)
+ else:
+ self.setMinimumHeight(300)
+
+ # try except si la liste des possibles est vide
+ # prevoir qqchose
+ try:
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
+ except:
+ pass
+
+ def changeTout(self, int):
+ # print ('changeTout')
+ if self.inhibe:
+ return
+ self.inhibe = True
+ if not (self.CBCheck.isChecked()):
+ min, max = self.node.item.getMinMax()
+ if max < len(self.listeAAfficher):
+ commentaire = tr("impossible de tout selectionner : max =") + str(max)
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.inhibe = False
+ return
+ for i in range(len(self.listeAAfficher)):
+ nomCB = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomCB)
+ courant.setChecked(True)
+ self.CBCheck.setChecked(False)
+ else:
+ for i in range(len(self.listeAAfficher)):
+ nomCB = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomCB)
+ courant.setChecked(False)
+ self.CBCheck.setChecked(True)
+ self.inhibe = False
+ self.changeValeur()
+
+ def setValeurs(self):
+ # print ('setValeurs')
+ self.listeValeursCourantes = self.node.item.getValeur()
+ if self.listeValeursCourantes == None:
+ self.listeValeursCourantes = []
+ # print ("ds set Valeur", self.listeValeursCourantes, self.node.item.getValeur())
+ self.politique = PolitiquePlusieurs(self.node, self.editor)
+ self.vScrollBar = self.scrollArea.verticalScrollBar()
+
+ if hasattr(self.node.item.definition.validators, "set_MCSimp"):
+ obj = self.node.item.getObject()
+ self.node.item.definition.validators.set_MCSimp(obj)
+ if self.node.item.isValid() == 0:
+ liste = []
+ for item in self.listeValeursCourantes:
+ if self.node.item.definition.validators.verifItem(item) == 1:
+ liste.append(item)
+ self.listeAAfficher = self.node.item.getListePossible(liste)
+ else:
+ self.listeAAfficher = self.node.item.getListePossible([])
+ else:
+ self.listeAAfficher = self.node.item.getListePossible([])
+
+ if self.node.item.hasIntoSug():
+ self.listeAAfficher = self.node.item.getListePossibleAvecSug([])
+
+ if self.objSimp.waitAssd():
+ self.listeAAfficher = self.node.item.getSdAvantDuBonType()
+ if self.listeAAfficher == None or self.listeAAfficher == []:
+ self.listeAAfficher = []
+
+ # if len(self.listeAAfficher)*20 > 400 : self.setMinimumHeight(400)
+ # else : self.setMinimumHeight(len(self.listeAAfficher)*30)
+
+ self.PourEtreCoche = []
+ if self.objSimp.waitUserAssd():
+ for concept in self.listeValeursCourantes:
+ self.PourEtreCoche.append(concept)
+ elif self.objSimp.waitAssd():
+ for concept in self.listeValeursCourantes:
+ self.PourEtreCoche.append(concept.nom)
+ else:
+ for val in self.listeValeursCourantes:
+ self.PourEtreCoche.append(val)
+
+ maListe = []
+ for i in self.listeAAfficher:
+ maListe.append(i)
+ if self.alpha == 1:
+ maListe.sort()
+ for i in range(1, len(maListe) + 1):
+ self.ajoutCB(i)
+
+ self.inhibe = True
+ for i in range(len(maListe)):
+ nomCB = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomCB)
+ courant.setText(str(maListe[i]))
+ if maListe[i] in self.PourEtreCoche:
+ courant.setChecked(True)
+ else:
+ courant.setChecked(False)
+
+ courant.toggled.connect(self.changeValeur)
+ self.inhibe = False
+
+ self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum)
+
+ def ajoutCB(self, index, valeur=None):
+ # print ('ajoutCB')
+ nomCB = "lineEditVal" + str(index)
+ if hasattr(self, nomCB):
+ return
+ nouveauCB = QCheckBox(self.scrollArea)
+ self.CBLayout.insertWidget(index - 1, nouveauCB)
+ self.listeCB.append(nouveauCB)
+ nouveauCB.setText("")
+ if index % 2 == 1:
+ nouveauCB.setStyleSheet("background:rgb(210,210,210)")
+ else:
+ nouveauCB.setStyleSheet("background:rgb(240,240,240)")
+ self.vScrollBar.triggerAction(QScrollBar.SliderToMaximum)
+ nouveauCB.setFocus()
+ setattr(self, nomCB, nouveauCB)
+
+ def ajout1Valeur(self, valeur=None):
+ # print ('ajout1Valeur')
+ if valeur == None:
+ return
+ liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
+ if validite == 0:
+ return
+ if liste == []:
+ return
+ listeVal = []
+ for valeur in self.listeValeursCourantes:
+ listeVal.append(valeur)
+ validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
+ liste, -1, listeVal
+ )
+ if comm2 != "" and comm != None:
+ return comm2
+ if validite:
+ self.listeValeursCourantes = self.listeValeursCourantes + listeRetour
+ return None
+ else:
+ return comm2 + " " + comm
+
+ def changeValeur(self):
+ # def changeValeur(self,changeDePlace=False,oblige=True, numero=None):
+ # print ('changeValeur')
+ if self.inhibe == True:
+ return
+ if hasattr(self, "LEFiltre"):
+ self.noircirResultatFiltre()
+ self.listeValeursCourantesAvant = self.listeValeursCourantes
+ self.listeValeursCourantes = []
+
+ for i in range(1, len(self.listeAAfficher) + 1):
+ nomLineEdit = "lineEditVal" + str(i)
+ courant = getattr(self, nomLineEdit)
+ if not (courant.isChecked()):
+ continue
+ valeur = courant.text()
+ if valeur != None and valeur != "":
+ commentaire = self.ajout1Valeur(valeur)
+ if commentaire != None:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.listeValeursCourantesAvant = self.listeValeursCourantes
+ self.setValeurs()
+
+ min, max = self.node.item.getMinMax()
+ if len(self.listeValeursCourantes) < min:
+ self.editor.afficheInfos(
+ tr("Nombre minimal de valeurs : ") + str(min), Qt.red
+ )
+ elif len(self.listeValeursCourantes) > max:
+ self.editor.afficheInfos(
+ tr("Nombre maximal de valeurs : ") + str(max), Qt.red
+ )
+
+ if self.listeValeursCourantes == []:
+ self.node.item.setValeur([])
+ else:
+ self.node.item.setValeur(self.listeValeursCourantes)
+
+ # Exception pour PSEN
+ if min == 0 and self.listeValeursCourantes == []:
+ self.node.item.setValeur([])
+ self.setValide()
+
+ def prepareListeResultatFiltre(self):
+ # print ('prepareListeResultatFiltre')
+ filtre = str(self.LEFiltre.text())
+ for cb in self.listeCB:
+ texte = cb.text()
+ if texte.find(filtre) == 0:
+ palette = QPalette(Qt.red)
+ palette.setColor(QPalette.WindowText, Qt.red)
+ cb.setPalette(palette)
+ t = cb.text()
+ cb.setText(t)
+ self.listeCbRouge.append(cb)
+
+ def prepareListeResultat(self):
+ # print ('prepareListeResultat')
+ self.clearAll()
+ self.setValeurs()
+
+ def clearAll(self):
+ # print ('clearAll')
+ for cb in self.listeCB:
+ cb.setText("")
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, os
+
+# Modules Eficas
+from .feuille import Feuille
+from desWidgetPlusieursIntoOrdonne import Ui_WidgetPlusieursIntoOrdonne
+from .politiquesValidation import PolitiquePlusieurs
+from .qtSaisie import SaisieValeur
+from .gereListe import GereListe
+from .gereListe import GerePlie
+from .gereListe import LECustom
+from .gereListe import MonLabelListeClic
+from Extensions.i18n import tr
+
+from PyQt5.QtWidgets import QFrame, QApplication, QScrollBar
+from PyQt5.QtCore import QTimer, QSize, Qt
+from PyQt5.QtGui import QIcon, QPalette
+
+
+class MonWidgetPlusieursIntoOrdonne(
+ Ui_WidgetPlusieursIntoOrdonne, Feuille, GereListe, GerePlie
+):
+ def __init__(self, node, monSimpDef, nom, objSimp, parent, commande):
+ self.nomLine = "LEResultat"
+ self.listeLE = []
+ self.ouAjouter = 0
+ self.numLineEditEnCours = 0
+ self.alpha = 0
+ self.filtre = ""
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parent, commande)
+ GereListe.__init__(self)
+ # self.finCommentaireListe()
+ self.gereIconePlier()
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ try:
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
+ except:
+ # cas ou on ne peut rien ajouter
+ pass
+ self.prepareListeResultat()
+ if len(self.listeAAfficher) < 20:
+ self.frameRecherche2.close()
+ if len(self.listeAAfficher) < 20:
+ self.frameRecherche.close()
+ self.adjustSize()
+ repIcon = self.node.editor.appliEficas.repIcon
+ fichier = os.path.join(repIcon, "arrow_up.png")
+ icon = QIcon(fichier)
+ self.RBHaut.setIcon(icon)
+ self.RBHaut.setIconSize(QSize(32, 32))
+ fichier2 = os.path.join(repIcon, "arrow_down.png")
+ icon2 = QIcon(fichier2)
+ self.RBBas.setIcon(icon2)
+ 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)
+
+ self.PBClean.clicked.connect(self.cleanListeResultatFiltre)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.listeRouge = []
+
+ def prepareListeResultat(self):
+ for i in self.listeLE:
+ i.close()
+ self.listeLE = []
+ self.vScrollBar = self.scrollArea.verticalScrollBar()
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ if hasattr(self.node.item.definition.validators, "set_MCSimp"):
+ obj = self.node.item.getObject()
+ self.node.item.definition.validators.set_MCSimp(obj)
+ if self.node.item.isValid() == 0:
+ liste = []
+ for item in self.listeValeursCourantes:
+ if self.node.item.definition.validators.verifItem(item) == 1:
+ liste.append(item)
+ self.listeAAfficher = self.node.item.getListePossible(liste)
+ else:
+ self.listeAAfficher = self.node.item.getListePossible([])
+ else:
+ self.listeAAfficher = self.node.item.getListePossible(
+ self.listeValeursCourantes
+ )
+
+ if self.listeAAfficher == []:
+ self.ajoutLE(0)
+ return
+ self.filtreListe()
+ if len(self.listeAAfficher) * 20 > 400:
+ self.setMinimumHeight(400)
+ else:
+ if self.monSimpDef.min > len(self.listeAAfficher):
+ self.setMinimumHeight(self.monSimpDef.min * 30 + 300)
+ elif self.monSimpDef.max > len(self.listeAAfficher):
+ self.setMinimumHeight(400)
+ else:
+ self.setMinimumHeight(len(self.listeAAfficher) * 30 + 30)
+ self.setMinimumHeight(300)
+ self.adjustSize()
+
+ self.politique = PolitiquePlusieurs(self.node, self.editor)
+ for i in range(1, len(self.listeAAfficher) + 1):
+ self.ajoutLE(i)
+ for i in range(len(self.listeAAfficher)):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ courant.setText(str(self.listeAAfficher[i]))
+ self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum)
+ if len(self.listeAAfficher) < 15 and hasattr(self, "frameRecherche"):
+ self.frameRecherche.close()
+ if len(self.listeAAfficher) < 15 and hasattr(self, "frameRecherche2"):
+ self.frameRecherche2.close()
+
+ def setValeurs(self, first=True):
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ if first:
+ if self.monSimpDef.max == "**" or self.monSimpDef.max == float("inf"):
+ aConstruire = 7
+ else:
+ aConstruire = self.monSimpDef.max
+ if len(self.listeValeursCourantes) > aConstruire:
+ aConstruire = len(self.listeValeursCourantes)
+ self.indexDernierLabel = aConstruire
+ for i in range(1, aConstruire + 1):
+ self.ajoutLEResultat(i)
+ index = 1
+ for val in self.listeValeursCourantes:
+ nomLE = "LEResultat" + str(index)
+ courant = getattr(self, nomLE)
+ courant.setText(str(val))
+ courant.setReadOnly(True)
+ index = index + 1
+ while index < self.indexDernierLabel:
+ nomLE = "LEResultat" + str(index)
+ courant = getattr(self, nomLE)
+ courant.setText("")
+ courant.setReadOnly(True)
+ index = index + 1
+ # self.prepareListeResultat()
+
+ def moinsPushed(self):
+ self.ouAjouter = self.ouAjouter - 1
+ GereListe.moinsPushed(self)
+ self.setValeurs(first=False)
+
+ def prepareListeResultatFiltre(self):
+ for i in self.listeRouge:
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ texte = courant.text()
+ palette = QPalette(Qt.black)
+ palette.setColor(QPalette.WindowText, Qt.black)
+ courant.setPalette(palette)
+ courant.setText(texte)
+
+ self.listeRouge = []
+ filtre = str(self.LEFiltre.text())
+ if filtre == "":
+ return
+ for i in range(len(self.listeAAfficher)):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ texte = courant.text()
+ if texte.find(filtre) == 0:
+ palette = QPalette(Qt.red)
+ palette.setColor(QPalette.WindowText, Qt.red)
+ courant.setPalette(palette)
+ courant.setText(texte)
+ self.listeRouge.append(i)
+
+ def cleanListeResultatFiltre(self):
+ self.LEFiltre.setText("")
+ self.prepareListeResultatFiltre()
+
+ def ajoutLEResultat(self, index, valeur=None):
+ # print ('ajoutLEResultat', index, valeur)
+ nomLE = "LEResultat" + str(index)
+ if not (hasattr(self, nomLE)):
+ nouveauLE = LECustom(self.scrollAreaRE, self, index)
+ nouveauLE.setFrame(False)
+ self.CBChoisis.insertWidget(self.ouAjouter, nouveauLE)
+ self.ouAjouter = self.ouAjouter + 1
+ nouveauLE.setReadOnly(True)
+ if index % 2 == 1:
+ nouveauLE.setStyleSheet("background:rgb(210,210,210)")
+ else:
+ nouveauLE.setStyleSheet("background:rgb(240,240,240)")
+ self.vScrollBarRE = self.scrollAreaRE.verticalScrollBar()
+ self.vScrollBarRE.triggerAction(QScrollBar.SliderToMaximum)
+ setattr(self, nomLE, nouveauLE)
+ self.estVisibleRE = nouveauLE
+ else:
+ nouveauLE = getattr(self, nomLE)
+
+ if valeur == None:
+ nouveauLE.setText("")
+ else:
+ nouveauLE.setText(str(valeur))
+
+ def ajoutLE(self, index, valeur=None):
+ # print ('ajoutLE')
+ nomLE = "lineEditVal" + str(index)
+ nouveauLE = MonLabelListeClic(self)
+ # self.CBLayout.addWidget(nouveauLE)
+ self.CBLayout.insertWidget(index - 1, nouveauLE)
+ self.listeLE.append(nouveauLE)
+ nouveauLE.setFrameShape(QFrame.NoFrame)
+ QApplication.processEvents()
+ nouveauLE.setText("")
+ if index % 2 == 1:
+ nouveauLE.setStyleSheet("background:rgb(210,210,210)")
+ else:
+ nouveauLE.setStyleSheet("background:rgb(240,240,240)")
+ self.vScrollBar.triggerAction(QScrollBar.SliderToMaximum)
+ nouveauLE.setFocus()
+ setattr(self, nomLE, nouveauLE)
+
+ def ajoutLineEdit(self):
+ # print ('ajoutLineEdit')
+ self.indexDernierLabel = self.indexDernierLabel + 1
+ self.ajoutLEResultat(self.indexDernierLabel)
+
+ def traiteClicSurLabelListe(self, valeur):
+ if valeur == None:
+ return
+ liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
+ if validite == 0:
+ return
+ if liste == []:
+ return
+ listeVal = []
+
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ min, max = self.node.item.getMinMax()
+ if len(self.listeValeursCourantes) + 1 > max:
+ self.editor.afficheInfos(
+ tr("Nombre maximal de valeurs : ") + str(max), Qt.red
+ )
+ return
+ else:
+ self.editor.afficheInfos("")
+
+ affiche = False
+ for i in range(1, self.indexDernierLabel + 1):
+ nomLE = "LEResultat" + str(i)
+ courant = getattr(self, nomLE)
+ if str(courant.text()) == str(""):
+ courant.setText(valeur)
+ courant.setReadOnly(True)
+ affiche = True
+ self.estVisibleRE = courant
+ QTimer.singleShot(1, self.rendVisibleLigneRE)
+ break
+
+ if affiche == False:
+ self.indexDernierLabel = self.indexDernierLabel + 1
+ self.ajoutLEResultat(self.indexDernierLabel, str(valeur))
+ self.vScrollBarRE.triggerAction(QScrollBar.SliderToMaximum)
+ QTimer.singleShot(1, self.rendVisibleLigneRE)
+ self.changeValeur()
+ self.setValeurs(first=False)
+
+ def changeValeur(self, changeDePlace=False, oblige=False):
+ # def changeValeur(self,changeDePlace=False,oblige=False, numero=None):
+ # PN les 2 arg sont pour que la signature de ma fonction soit identique a monWidgetPlusieursBase
+ listeVal = []
+ for i in range(1, self.indexDernierLabel + 1):
+ nomLE = "LEResultat" + str(i)
+ courant = getattr(self, nomLE)
+ valeur = courant.text()
+ if str(valeur) == "":
+ continue
+ liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
+ listeVal.append(str(valeur))
+
+ validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
+ listeVal, -1, []
+ )
+
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ min, max = self.node.item.getMinMax()
+ if len(self.listeValeursCourantes) < min:
+ self.editor.afficheInfos(
+ tr("Nombre minimal de valeurs : ") + str(min), Qt.red
+ )
+ else:
+ self.editor.afficheInfos("")
+
+ if len(listeRetour) == 0:
+ self.node.item.setValeur(None)
+ elif validite:
+ self.node.item.setValeur(listeRetour)
+ else:
+ commentaire = comm + " " + comm2
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.setValide()
+ self.reaffiche()
+
+ #
+ def rendVisibleLigneRE(self):
+ QApplication.processEvents()
+ self.estVisibleRE.setFocus()
+ self.scrollArea.ensureWidgetVisible(self.estVisibleRE, 0, 0)
+
+ #
+ def rendVisibleLigne(self):
+ self.estVisibleRE = self.estVisible
+ # rendVisibleLigneRE()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+import types, re
+
+from PyQt5.QtWidgets import QFrame
+from PyQt5.QtCore import QTimer, QSize, Qt
+from PyQt5.QtGui import QIcon, QBrush, QColor
+
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetPlusieursPlie import Ui_WidgetPlusieursPlie
+
+from .politiquesValidation import PolitiquePlusieurs
+from .qtSaisie import SaisieValeur
+
+pattern_blanc = re.compile(r"^\s*$")
+
+
+class MonWidgetPlusieursPlie(Ui_WidgetPlusieursPlie, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print ("MonWidgetPlusieursBase", nom)
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.AAfficher = self.lineEditVal
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal)
+ if self.node.item.hasInto():
+ self.lineEditVal.setReadOnly(True)
+ self.lineEditVal.setStyleSheet("background:rgb(235,235,235);\n")
+ self.lineEditVal.setToolTip(
+ "Ensemble discret de valeurs possibles, pas de Saisie Manuelle"
+ )
+ # self.lineEditVal.setPen(QtGui.QColor(0,0,200))
+ # b=QBrush(Qt.DiagCrossPattern)
+ # b.setColor(QColor(255,100,0))
+ # self.lineEditVal.setBrush(b)
+ else:
+ self.lineEditVal.returnPressed.connect(self.valeurEntree)
+ self.BVisuListe.clicked.connect(self.selectWidgetDeplie)
+
+ def setValeurs(self):
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ if self.listeValeursCourantes != []:
+ self.lineEditVal.setText(str(self.listeValeursCourantes))
+ else:
+ self.lineEditVal.setText("")
+ self.politique = PolitiquePlusieurs(self.node, self.editor)
+ return
+
+ def selectWidgetDeplie(self):
+ self.editor.listeDesListesOuvertes.add(self.node.item)
+ self.reaffichePourDeplier()
+
+ def valeurEntree(self):
+ valeurTexte = self.lineEditVal.text()
+ # print (valeurTexte[0])
+ # print (valeurTexte[-1])
+ if valeurTexte[0] == "[" or valeurTexte[0] == "(":
+ valeurTexte = valeurTexte[1:]
+ if valeurTexte[-1] == "]" or valeurTexte[-1] == ")":
+ valeurTexte = valeurTexte[:-1]
+ # print (valeurTexte)
+ listeValeursBrutes = valeurTexte.split(",")
+ if listeValeursBrutes == [] or listeValeursBrutes == None:
+ self.lineEditVal.setText(str(self.listeValeursCourantes))
+ return
+ listeValeur = []
+ for v in listeValeursBrutes:
+ if v == None or pattern_blanc.match(v):
+ self.editor.afficheInfos(
+ str(listeValeur) + " Valeurs saisies incorrectes", Qt.red
+ )
+ return
+ liste, validite = SaisieValeur.TraiteLEValeur(self, str(v))
+ if not validite:
+ self.editor.afficheInfos(
+ str(listeValeur) + " Valeurs saisies incorrectes", Qt.red
+ )
+ return
+ listeValeur.append(liste[0])
+ validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
+ listeValeur, -1, []
+ )
+ if validite:
+ self.node.item.setValeur(listeValeur)
+ self.node.item.isValid()
+ self.setValeurs()
+ else:
+ self.editor.afficheInfos(str(listeValeur) + " " + comm, Qt.red)
+ self.lineEditVal.setText("")
+
+
+class MonWidgetPlusieursPlieASSD(MonWidgetPlusieursPlie):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetPlusieursPlie.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ self.lineEditVal.setReadOnly(True)
+
+ def setValeurs(self):
+ self.listeValeursCourantes = self.node.item.getListeValeurs()
+ self.politique = PolitiquePlusieurs(self.node, self.editor)
+ if self.listeValeursCourantes == []:
+ self.lineEditVal.setText("")
+ return
+ txt = "["
+ for elt in self.listeValeursCourantes:
+ txt = txt + (str(elt)) + ","
+ txt = txt + "]"
+ self.lineEditVal.setText(txt)
+
+ def valeurEntree(self):
+ pass
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from PyQt5.QtWidgets import QFrame, QApplication, QFrame, QWidget
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import QSize, Qt, QTimer
+
+from Extensions.i18n import tr
+
+
+from InterfaceGUI.QT5.feuille import Feuille
+from InterfaceGUI.QT5.politiquesValidation import PolitiquePlusieurs
+from InterfaceGUI.QT5.qtSaisie import SaisieValeur
+from InterfaceGUI.QT5.gereListe import GereListe
+from InterfaceGUI.QT5.gereListe import LECustom
+from Tuple2 import Ui_Tuple2
+from Tuple3 import Ui_Tuple3
+from Tuple4 import Ui_Tuple4
+from Tuple5 import Ui_Tuple5
+from Tuple6 import Ui_Tuple6
+from Tuple7 import Ui_Tuple7
+from Tuple8 import Ui_Tuple8
+from Tuple9 import Ui_Tuple9
+from Tuple10 import Ui_Tuple10
+
+
+# --------------------------
+class TupleCustom(object):
+ # --------------------------
+
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------------------------------------
+ QWidget.__init__(self, parent)
+ self.setupUi(self)
+ self.tailleTuple = tailleTuple
+ self.parent = parent
+ self.parentQt = parentQt
+ self.valeur = []
+ self.index = index
+ self.inFocusOutEvent = False
+
+ for i in range(self.tailleTuple):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ courant.num = index
+ courant.dansUnTuple = True
+ courant.returnPressed.connect(self.valueChange)
+ courant.numDsLaListe = i + 1
+ courant.tupleCustomParent = self
+ courant.parentTuple = self
+
+ def valueChange(self):
+ # ----------------------
+
+ listeVal = []
+ for i in range(self.tailleTuple):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ val = str(courant.text())
+
+ if str(val) == "" or val == None:
+ if not self.inFocusOutEvent:
+ courant.setFocus()
+ return
+
+ try:
+ valeur = eval(val, {})
+ except:
+ try:
+ d = self.parentQt.objSimp.jdc.getContexteAvant(
+ self.parentQt.objSimp.etape
+ )
+ valeur = eval(val, d)
+ except:
+ valeur = val
+ listeVal.append(valeur)
+ self.valeur = listeVal
+ self.parentQt.changeValeur()
+
+ def setValeur(self, value):
+ # ----------------------
+
+ listeVal = []
+ valeurNulle = True
+ for i in range(self.tailleTuple):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ try:
+ if str(value[i]) != "":
+ valeurNulle = False
+ except:
+ pass
+
+ try:
+ courant.setText(str(value[i]))
+ except:
+ courant.setText("")
+ val = str(courant.text())
+ try:
+ valeur = eval(val, {})
+ except:
+ try:
+ d = self.parentQt.objSimp.jdc.getContexteAvant(
+ self.parentQt.objSimp.etape
+ )
+ valeur = eval(val, d)
+ except:
+ valeur = val
+ listeVal.append(valeur)
+ if valeurNulle == True:
+ self.valeur = None
+ else:
+ self.valeur = listeVal
+
+ def getValeurbad(self):
+ # ----------------------
+ self.valeur = []
+ vide = True
+ print(self.tailleTuple)
+ for i in range(self.tailleTuple):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ self.valeur.append(courant.valeur)
+ if courant.valeur != None:
+ vide = False
+ if vide:
+ self.valeur = []
+ return self.valeur
+
+ def getValeur(self):
+ # ----------------------
+ return self.valeur
+
+ def text(self):
+ # --------------
+ return self.valeur
+
+ def setText(self, value):
+ # -----------------------
+ self.setValeur(value)
+
+ def clean(self):
+ # -------------------
+ self.valeur = None
+ for i in range(self.tailleTuple):
+ nomLE = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLE)
+ courant.setText("")
+
+ def finCommentaire(self):
+ # -------------------
+ return self.finCommentaireListe()
+
+
+# -------------------------------------------------
+class TupleCustom2(QWidget, Ui_Tuple2, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+ if self.parentQt.editor.maConfiguration.closeParenthese:
+ self.label_5.close()
+ self.label_7.close()
+
+
+# -------------------------------------------------
+class TupleCustom3(QWidget, Ui_Tuple3, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom4(QWidget, Ui_Tuple4, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom5(QWidget, Ui_Tuple5, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom6(QWidget, Ui_Tuple6, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom7(QWidget, Ui_Tuple7, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom8(QWidget, Ui_Tuple8, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom9(QWidget, Ui_Tuple9, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+
+
+# -------------------------------------------------
+class TupleCustom10(QWidget, Ui_Tuple10, TupleCustom):
+ # -------------------------------------------------
+ def __init__(self, tailleTuple, parent, parentQt, index):
+ # -------------------
+ TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
+ if self.parentQt.editor.maConfiguration.closeParenthese:
+ self.label_5.close()
+ self.label_7.close()
+
+
+# -------------------------------------------- #
+class MonWidgetPlusieursTuple(Feuille, GereListe):
+ # -------------------------------------------- #
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # -----------------------------------------------------
+
+ self.indexDernierLabel = 0
+ self.numLineEditEnCours = 0
+ self.nomLine = "TupleVal"
+ self.listeAffichageWidget = []
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ GereListe.__init__(self)
+ self.finCommentaireListe()
+ self.politique = PolitiquePlusieurs(self.node, self.editor)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+
+ if 1:
+ # Pour MT
+ repIcon = self.node.editor.appliEficas.repIcon
+ fichier = os.path.join(repIcon, "arrow_up.png")
+ icon = QIcon(fichier)
+ self.RBHaut.setIcon(icon)
+ 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(fichier3)
+ self.BSelectFichier.setIcon(icon3)
+ self.BSelectFichier.setIconSize(QSize(32, 32))
+ self.BSelectFichier.clicked.connect(self.selectInFile)
+
+ def ajoutLineEdit(self, valeur=None, inInit=False):
+ # ------------------------------------------------
+ self.indexDernierLabel = self.indexDernierLabel + 1
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+ if hasattr(self, nomLineEdit):
+ self.indexDernierLabel = self.indexDernierLabel - 1
+ return
+
+ nomCustomTuple = "TupleCustom" + str(self.nbValeurs)
+ laClasseDuTuple = globals()[nomCustomTuple]
+ nouveauLE = laClasseDuTuple(
+ self.nbValeurs, self.scrollArea, self, self.indexDernierLabel
+ )
+
+ # if self.nbValeurs == 2 : nouveauLE = TupleCustom2(self.nbValeurs,self.scrollArea,self,self.indexDernierLabel)
+ # else : nouveauLE = TupleCustom3(self.nbValeurs,self.scrollArea,self,self.indexDernierLabel)
+
+ self.verticalLayoutLE.insertWidget(self.indexDernierLabel - 1, nouveauLE)
+ setattr(self, nomLineEdit, nouveauLE)
+ if valeur != None:
+ nouveauLE.setValeur(valeur)
+
+ for i in range(self.nbValeurs):
+ num = i + 1
+ nomLineEdit = "lineEditVal" + str(num)
+ lineEditVal = getattr(nouveauLE, nomLineEdit)
+ self.listeAffichageWidget.append(lineEditVal)
+ # self.listeAffichageWidget.append(nouveauLE.lineEditVal1)
+ # self.listeAffichageWidget.append(nouveauLE.lineEditVal2)
+ # if self.nbValeurs == 3 : self.listeAffichageWidget.append(nouveauLE.lineEditVal3)
+
+ self.etablitOrdre()
+
+ # deux lignes pour que le ensureVisible fonctionne
+ self.estVisible = nouveauLE.lineEditVal1
+ if inInit == False:
+ QTimer.singleShot(1, self.rendVisibleLigne)
+
+ def etablitOrdre(self):
+ # ---------------------
+ i = 0
+ while i + 1 < len(self.listeAffichageWidget):
+ self.listeAffichageWidget[i].setFocusPolicy(Qt.StrongFocus)
+ self.setTabOrder(
+ self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
+ )
+ i = i + 1
+
+ def setValeurs(self):
+ # ---------------------
+ if self.editor.code == "PSEN":
+ self.RBListePush()
+ valeurs = self.node.item.getValeur()
+ min, max = self.node.item.getMinMax()
+ if max == "**" or max > 8:
+ aCreer = 8
+ else:
+ aCreer = max
+
+ if valeurs == () or valeurs == None:
+ for i in range(aCreer):
+ self.ajoutLineEdit(inInit=True)
+ return
+
+ for v in valeurs:
+ self.ajoutLineEdit(v, inInit=True)
+
+ for i in range(len(valeurs), aCreer):
+ self.ajoutLineEdit(inInit=True)
+
+ def rendVisibleLigne(self):
+ # -------------------------
+ QApplication.processEvents()
+ self.estVisible.setFocus(True)
+ self.scrollArea.ensureWidgetVisible(self.estVisible, 0, 0)
+
+ def changeValeur(self, changeDePlace=False, oblige=True):
+ # -----------------------------------------------------
+ # Pour compatibilite signature
+ # print ('dschangeValeur', self.indexDernierLabel)
+
+ aLeFocus = self.focusWidget()
+ listeComplete = []
+ libre = False
+ # print (self.indexDernierLabel)
+ for i in range(self.indexDernierLabel):
+ nom = self.nomLine + str(i + 1)
+ courant = getattr(self, nom)
+ valeurTuple = courant.valeur
+ if valeurTuple == None or valeurTuple == "" or valeurTuple == []:
+ libre = True
+ continue
+ validite, comm, comm2, listeRetour = self.politique.ajoutTuple(
+ valeurTuple, listeComplete
+ )
+ if not validite:
+ if comm2 != "":
+ comm += " " + comm2
+ self.editor.afficheInfos(
+ comm + " " + str(self.objSimp.definition.validators.typeDesTuples),
+ Qt.red,
+ )
+ return
+ listeComplete.append(tuple(courant.valeur))
+ # print ('listeComplete', listeComplete)
+ if listeComplete == []:
+ listeComplete = None
+ self.node.item.setValeur(listeComplete)
+
+ if changeDePlace:
+ return
+ min, max = self.node.item.getMinMax()
+ if self.indexDernierLabel == max:
+ self.editor.afficheInfos(tr("Nb maximum de valeurs atteint"))
+ if self.indexDernierLabel < max and libre == False:
+ self.ajoutLineEdit()
+ self.listeAffichageWidget[-2].setFocus(True)
+ else:
+ try:
+ QApplication.processEvents()
+ w = self.listeAffichageWidget[
+ self.listeAffichageWidget.index(aLeFocus) + 1
+ ]
+ w.setFocus(True)
+ self.scrollArea.ensureWidgetVisible(w, 0, 0)
+ except:
+ pass
+
+ def echange(self, num1, num2):
+ # on donne le focus au a celui ou on a bouge
+ # par convention le 2
+ nomLineEdit = self.nomLine + str(num1)
+ courant = getattr(self, nomLineEdit)
+ valeurAGarder = courant.getValeur()
+ nomLineEdit2 = self.nomLine + str(num2)
+ courant2 = getattr(self, nomLineEdit2)
+ courant.setText(courant2.text())
+ courant2.setText(valeurAGarder)
+ self.changeValeur(changeDePlace=True)
+ self.numLineEditEnCours = num2
+ self.lineEditEnCours = courant2
+ courant2.lineEditVal1.setFocus(True)
+
+ 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
+ # chaque valeur. d ou l ajout de ajoutNTuple a politique plusieurs
+
+ if len(liste) % self.nbValeurs != 0:
+ texte = "Nombre incorrect de valeurs"
+ self.editor.afficheInfos(tr(texte), Qt.red)
+ return
+
+ i = 0
+ longueur = len(liste) // self.nbValeurs
+ increment = self.nbValeurs
+ listeFormatee = [
+ liste[k * increment : (k + 1) * increment] for k in range(longueur)
+ ]
+ listeFormatee = tuple(listeFormatee)
+
+ min, max = self.node.item.getMinMax()
+ if self.objSimp.valeur == None:
+ listeComplete = listeFormatee
+ else:
+ listeComplete = self.objSimp.valeur + listeFormatee
+
+ if len(listeComplete) > max:
+ texte = tr("Nombre maximum de valeurs ") + str(max) + tr(" atteint")
+ self.editor.afficheInfos(texte, Qt.red)
+ return
+
+ validite, comm, comm2, listeRetour = self.politique.ajoutNTuple(listeComplete)
+ if not validite:
+ self.editor.afficheInfos(comm + comm2, Qt.red)
+ return
+
+ # on calcule le dernier lineedit rempli avant de changer la valeur
+ if self.objSimp.valeur != None:
+ indexDernierRempli = len(self.objSimp.valeur)
+ else:
+ indexDernierRempli = 0
+
+ self.politique.recordValeur(listeComplete)
+
+ while i < len(liste):
+ try:
+ t = tuple(liste[i : i + self.nbValeurs])
+ except:
+ t = tuple(liste[i : len(liste)])
+ i = i + self.nbValeurs
+ if indexDernierRempli < self.indexDernierLabel:
+ nomLEARemplir = self.nomLine + str(indexDernierRempli + 1)
+ LEARemplir = getattr(self, nomLEARemplir)
+ for n in range(self.nbValeurs):
+ nomLineEdit = "lineEditVal" + str(n + 1)
+ lineEditVal = getattr(LEARemplir, nomLineEdit)
+ lineEditVal.setText(str(t[n]))
+ else:
+ # ne pas appeler ajoutLineEdit(t,False ) pb de boucle pb du a etablitOrdre et a listeWidgetAffichage qui bouge
+ self.indexDernierLabel = self.indexDernierLabel + 1
+ nomLineEdit = self.nomLine + str(self.indexDernierLabel)
+
+ nomCustomTuple = "TupleCustom" + str(self.nbValeurs)
+ laClasseDuTuple = globals()[nomCustomTuple]
+ nouveauLE = laClasseDuTuple(
+ self.nbValeurs, self.scrollArea, self, self.indexDernierLabel
+ )
+
+ self.verticalLayoutLE.insertWidget(
+ self.indexDernierLabel - 1, nouveauLE
+ )
+ setattr(self, nomLineEdit, nouveauLE)
+ nouveauLE.setValeur(t)
+
+ for n in range(self.nbValeurs):
+ nomLineEdit = "lineEditVal" + str(n + 1)
+ lineEditVal = getattr(nouveauLE, nomLineEdit)
+ self.listeAffichageWidget.append(lineEditVal)
+ indexDernierRempli = indexDernierRempli + 1
+
+ self.etablitOrdre()
+
+ def RBListePush(self):
+ # ----------------------
+ # PN a rendre generique avec un truc tel prerempli
+ # pour l instant specifique PSEN
+
+ if self.editor.code == "VP":
+ return
+ if self.objSimp.valeur != None and self.objSimp.valeur != []:
+ return
+ if not hasattr(self.editor.readercata.cata, "sd_ligne"):
+ self.editor.readercata.cata.sd_ligne = None
+ if not hasattr(self.editor.readercata.cata, "sd_generateur"):
+ self.editor.readercata.cata.sd_generateur = None
+ if not hasattr(self.editor.readercata.cata, "sd_transfo"):
+ self.editor.readercata.cata.sd_transfo = None
+ if not hasattr(self.editor.readercata.cata, "sd_charge"):
+ self.editor.readercata.cata.sd_charge = None
+ if not hasattr(self.editor.readercata.cata, "sd_moteur"):
+ self.editor.readercata.cata.sd_moteur = None
+ if (
+ self.objSimp.definition.validators.typeDesTuples[0]
+ == self.editor.readercata.cata.sd_ligne
+ ):
+ val = []
+ if hasattr(self.objSimp.jdc, "LineDico"):
+ for k in self.objSimp.jdc.LineDico:
+ try:
+ valeur = self.objSimp.jdc.getConcept(k)
+ val.append((valeur, 0))
+ except:
+ pass
+ self.node.item.setValeur(val)
+ if (
+ self.objSimp.definition.validators.typeDesTuples[0]
+ == self.editor.readercata.cata.sd_generateur
+ ):
+ val = []
+ if hasattr(self.objSimp.jdc, "MachineDico"):
+ for k in self.objSimp.jdc.MachineDico:
+ try:
+ valeur = self.objSimp.jdc.getConcept(k)
+ val.append((valeur, 0))
+ except:
+ pass
+ self.node.item.setValeur(val)
+ if (
+ self.objSimp.definition.validators.typeDesTuples[0]
+ == self.editor.readercata.cata.sd_transfo
+ ):
+ val = []
+ if hasattr(self.objSimp.jdc, "TransfoDico"):
+ for k in self.objSimp.jdc.TransfoDico:
+ try:
+ valeur = self.objSimp.jdc.getConcept(k)
+ val.append((valeur, 0))
+ except:
+ pass
+ self.node.item.setValeur(val)
+ if (
+ self.objSimp.definition.validators.typeDesTuples[0]
+ == self.editor.readercata.cata.sd_charge
+ ):
+ val = []
+ if hasattr(self.objSimp.jdc, "LoadDico"):
+ for k in self.objSimp.jdc.LoadDico:
+ try:
+ valeur = self.objSimp.jdc.getConcept(k)
+ val.append((valeur, 0))
+ except:
+ pass
+ self.node.item.setValeur(val)
+ if (
+ self.objSimp.definition.validators.typeDesTuples[0]
+ == self.editor.readercata.cata.sd_moteur
+ ):
+ val = []
+ if hasattr(self.objSimp.jdc, "MotorDico"):
+ for k in self.objSimp.jdc.MotorDico:
+ try:
+ valeur = self.objSimp.jdc.getConcept(k)
+ val.append((valeur, 0))
+ except:
+ pass
+ self.node.item.setValeur(val)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from .feuille import Feuille
+from .monWidgetPlusieursTuple import MonWidgetPlusieursTuple
+from desWidgetPlusieursTuple import Ui_WidgetPlusieursTuple
+
+
+class MonWidgetPlusieursTuple2(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 2
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple3(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 3
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple4(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 4
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple5(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 5
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple6(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 6
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple7(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 7
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple8(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 8
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple9(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 9
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetPlusieursTuple10(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 10
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 types
+
+from PyQt5.QtCore import Qt
+from PyQt5.QtWidgets import QWidget
+
+# Modules Eficas
+
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetRadioButton import Ui_WidgetRadioButton
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+
+
+class MonWidgetRadioButtonCommun(Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.setMaxI()
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ self.dict_bouton = {}
+ self.determineChoix()
+ self.setValeursApresBouton()
+ if hasattr(self.parentQt, "commandesLayout"):
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.AAfficher = self.radioButton_1
+ self.maCommande.listeAffichageWidget.append(self.radioButton_1)
+
+ def setValeursApresBouton(self):
+ if self.objSimp.getValeur() == None:
+ return
+ valeur = self.objSimp.getValeur()
+ if not (isinstance(valeur, str)):
+ valeur = str(valeur)
+ try:
+ self.dict_bouton[valeur].setChecked(True)
+ self.dict_bouton[valeur].setFocus(True)
+ except:
+ pass
+
+ def determineChoix(self):
+ self.horizontalLayout.setAlignment(Qt.AlignLeft)
+ i = 1
+ j = len(self.maListeDeValeur)
+ if j > self.maxI:
+ print("poumbadaboum")
+ return
+ while i < j + 1:
+ nomBouton = "radioButton_" + str(i)
+ bouton = getattr(self, nomBouton)
+ valeur = self.maListeDeValeur[i - 1]
+ if not (isinstance(valeur, str)):
+ valeur = str(valeur)
+ bouton.setText(tr(valeur))
+ self.dict_bouton[valeur] = bouton
+ bouton.clicked.connect(self.boutonclic)
+ bouton.keyPressEvent = self.keyPressEvent
+ setattr(self, nomBouton, bouton)
+ i = i + 1
+ while i < self.maxI + 1:
+ nomBouton = "radioButton_" + str(i)
+ bouton = getattr(self, nomBouton)
+ bouton.close()
+ i = i + 1
+
+ def boutonclic(self):
+ for valeur in self.dict_bouton:
+ if self.dict_bouton[valeur].isChecked():
+ SaisieValeur.LEvaleurPressed(self, valeur)
+ self.reaffiche()
+
+ def keyPressEvent(self, event):
+ if event.key() == Qt.Key_Right:
+ self.selectSuivant()
+ return
+ if event.key() == Qt.Key_Left:
+ self.selectPrecedent()
+ return
+ if event.key() == Qt.Key_Return or event.key() == Qt.Key_Space:
+ self.checkFocused()
+ return
+ QWidget.keyPressEvent(self, event)
+
+ def selectSuivant(self):
+ aLeFocus = self.focusWidget()
+ nom = aLeFocus.objectName()[12:]
+ i = int(nom) + 1
+ if i == len(self.maListeDeValeur) + 1:
+ i = 1
+ nomBouton = "radioButton_" + str(i)
+ courant = getattr(self, nomBouton)
+ courant.setFocus(True)
+
+ def selectPrecedent(self):
+ aLeFocus = self.focusWidget()
+ nom = aLeFocus.objectName()[12:]
+ i = int(nom) - 1
+ if i == 0:
+ i = len(self.maListeDeValeur)
+ nomBouton = "radioButton_" + str(i)
+ courant = getattr(self, nomBouton)
+ courant.setFocus(True)
+
+ def checkFocused(self):
+ aLeFocus = self.focusWidget()
+ nom = aLeFocus.objectName()[12:]
+ i = int(nom)
+ if i > 0 and i <= len(self.maListeDeValeur):
+ nomBouton = "radioButton_" + str(i)
+ courant = getattr(self, nomBouton)
+ if not courant.isChecked():
+ courant.setChecked(True)
+ self.boutonclic()
+
+
+class MonWidgetRadioButton(Ui_WidgetRadioButton, MonWidgetRadioButtonCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print "MonWidgetRadioButton ", self
+ if type(monSimpDef.into) == types.FunctionType:
+ self.maListeDeValeur = monSimpDef.into()
+ else:
+ self.maListeDeValeur = monSimpDef.into
+
+ MonWidgetRadioButtonCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def setMaxI(self):
+ self.maxI = 3
+
+
+class MonWidgetRadioButtonSD(Ui_WidgetRadioButton, MonWidgetRadioButtonCommun):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print "dans le init de MonWidgetRadioButtonSD",self
+ self.maListeDeValeur = node.item.getSdAvantDuBonType()
+ MonWidgetRadioButtonCommun.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ def setMaxI(self):
+ self.maxI = 3
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from PyQt5.QtWidgets import QLineEdit
+from PyQt5.QtCore import Qt
+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.LESDCO.returnPressed.connect(self.LESDCOReturnPressed)
+ self.LBSDCO.itemDoubleClicked.connect(self.LBSDCODoubleClicked)
+
+ def LESDCOReturnPressed(self):
+ self.LBSDCO.clearSelection()
+ SaisieSDCO.LESDCOReturnPressed(self)
+
+ def initLBSDCO(self):
+ listeNomsSDCO = self.node.item.getSdAvantDuBonType()
+ for aSDCO in listeNomsSDCO:
+ self.LBSDCO.insertItem(1, aSDCO)
+ valeur = self.node.item.getValeur()
+ if valeur != "" and valeur != None:
+ self.LESDCO.setText(str(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.initModif()
+ anc_val = self.node.item.getValeur()
+ test_CO = self.node.item.isCO(anc_val)
+
+ valeur, validite = self.node.item.evalValeur(nomConcept)
+ test = self.node.item.setValeur(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.deleteValeurCo(valeur=anc_val)
+ self.node.item.object.etape.getType_produit(force=1)
+ self.node.item.object.etape.parent.resetContext()
+ self.LESDCO.setText(nomConcept)
+ else:
+ commentaire = self.node.item.getCr()
+ self.reset_old_valeur(anc_val, mess=mess)
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.Commentaire.setText(tr(commentaire))
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from PyQt5.QtWidgets import QLineEdit
+from PyQt5.QtCore import Qt
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetSimpBase import Ui_WidgetSimpBase
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+
+
+class MonWidgetSimpBase(Ui_WidgetSimpBase, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ if "R" or "I" in self.monSimpDef.type:
+ self.lineEditVal.setMinimumWidth(525)
+ if hasattr(self.parentQt, "commandesLayout"):
+ self.parentQt.commandesLayout.insertWidget(-1, self, 1)
+ self.setFocusPolicy(Qt.StrongFocus)
+ # si on a un heritage malencontreux
+ if hasattr(self, "lineEditVal"):
+ if monSimpDef.homo == "constant":
+ self.lineEditVal.setReadOnly(True)
+ self.lineEditVal.setStyleSheet(
+ "background:rgb(210,235,235);\n" "border:0px;"
+ )
+ else:
+ self.lineEditVal.returnPressed.connect(self.LEvaleurPressed)
+ self.AAfficher = self.lineEditVal
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal)
+ self.lineEditVal.focusInEvent = self.monFocusInEvent
+ self.lineEditVal.focusOutEvent = self.monFocusOutEvent
+
+ def monFocusInEvent(self, event):
+ self.editor.nodeEnCours = self
+ QLineEdit.focusInEvent(self.lineEditVal, event)
+
+ def monFocusOutEvent(self, event):
+ if self.oldValeurTexte != self.lineEditVal.text():
+ self.oldValeurTexte = self.lineEditVal.text()
+ self.LEvaleurPressed()
+ QLineEdit.focusOutEvent(self.lineEditVal, event)
+
+ def setValeurs(self):
+ self.oldValeurTexte = ""
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ valeur = self.node.item.getValeur()
+ valeurTexte = self.politique.getValeurTexte(valeur)
+ chaine = ""
+
+ if valeurTexte != None:
+ from decimal import Decimal
+
+ if isinstance(valeurTexte, Decimal):
+ chaine = str(valeurTexte)
+ elif repr(valeurTexte.__class__).find("PARAMETRE") > 0:
+ chaine = repr(valeur)
+ else:
+ chaine = str(valeurTexte)
+ self.oldValeurTexte = chaine
+ self.lineEditVal.setText(chaine)
+
+ def finCommentaire(self):
+ mc = self.objSimp.definition
+ d_aides = {
+ "TXM": tr("Une chaine de caracteres est attendue. "),
+ "R": tr("Un reel est attendu. "),
+ "I": tr("Un entier est attendu. "),
+ "Matrice": tr("Une Matrice est attendue. "),
+ "Fichier": tr("Un fichier est attendu. "),
+ "FichierNoAbs": tr("Un fichier est attendu. "),
+ "Repertoire": tr("Un repertoire est attendu. "),
+ "FichierOuRepertoire": tr("Un repertoire ou un fichier est attendu. "),
+ "Heure": tr("Heure sous la forme HH:MM"),
+ "Date": tr("Date sous la forme JJ/MM/AA"),
+ }
+ if mc.type[0] != type:
+ commentaire = d_aides.get(mc.type[0], tr("Type de base inconnu"))
+ else:
+ commentaire = ""
+ return commentaire
+
+ def LEvaleurPressed(self):
+ # pour les soucis d encoding
+ try:
+ if (
+ str(self.lineEditVal.text()) == ""
+ or str(self.lineEditVal.text()) == None
+ ):
+ return
+ except:
+ pass
+ SaisieValeur.LEvaleurPressed(self)
+ # self.parentQt.donneFocus()
+ self.setValeurs()
+ self.reaffiche()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from PyQt5.QtWidgets import QRadioButton
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetSimpBool import Ui_WidgetSimpBool
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+
+
+class MonWidgetSimpBool(Ui_WidgetSimpBool, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ self.RBTrue.clicked.connect(self.boutonTrueClic)
+ self.RBFalse.clicked.connect(self.boutonFalseClic)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.maCommande.listeAffichageWidget.append(self.RBTrue)
+ self.AAfficher = self.RBTrue
+
+ def setValeurs(self):
+ valeur = self.node.item.getValeur()
+ if valeur == None:
+ return
+ if valeur == True:
+ self.RBTrue.setChecked(True)
+ if valeur == False:
+ self.RBFalse.setChecked(True)
+ if self.monSimpDef.homo == "constant":
+ if valeur == True:
+ self.RBFalse.setDisabled(True)
+ else:
+ self.RBTrue.setDisabled(True)
+
+ def boutonTrueClic(self):
+ SaisieValeur.LEvaleurPressed(self, True)
+ self.reaffiche()
+
+ def boutonFalseClic(self):
+ SaisieValeur.LEvaleurPressed(self, False)
+ self.reaffiche()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import locale
+
+# Modules Eficas
+from PyQt5.QtWidgets import QLineEdit, QRadioButton
+from PyQt5.QtCore import Qt
+
+
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetSimpComplexe import Ui_WidgetSimpComplexe
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+
+
+class MonWidgetSimpComplexe(Ui_WidgetSimpComplexe, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.setFocusPolicy(Qt.StrongFocus)
+ self.LEImag.returnPressed.connect(self.LEImagRPressed)
+ self.LEReel.returnPressed.connect(self.LEReelRPressed)
+ self.RBRI.clicked.connect(self.valeurPressed)
+ self.RBMP.clicked.connect(self.valeurPressed)
+ self.maCommande.listeAffichageWidget.append(self.RBRI)
+ self.maCommande.listeAffichageWidget.append(self.RBMP)
+ self.maCommande.listeAffichageWidget.append(self.LEReel)
+ self.maCommande.listeAffichageWidget.append(self.LEImag)
+
+ def setValeurs(self):
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ valeur = self.node.item.getValeur()
+ if valeur == None or valeur == "":
+ return
+ if type(valeur) not in (list, tuple):
+ self.LEComp.setText(str(valeur))
+ commentaire = tr("complexe form deprecated, od value : ", valeur)
+ self.editor.afficheInfos(commentaire, Qt.red)
+ else:
+ typ_cplx, x1, x2 = valeur
+ self.LEReel.setText(str(x1))
+ self.LEImag.setText(str(x2))
+ if typ_cplx == "RI":
+ self.RBRI.setChecked(1)
+ else:
+ self.RBMP.setChecked(1)
+
+ # def LECompRPressed(self) :
+ # self.LEReel.clear()
+ # self.LEImag.clear()
+ # commentaire=tr("expression valide")
+ # valeur = str(self.LEComp.text())
+ # d={}
+ # if 1 :
+ # try :
+ # v=eval(valeur,d)
+ # except :
+ # commentaire=tr("expression invalide")
+ # self.editor.afficheInfos(commentaire,Qt.red)
+ # return
+ # try :
+ # i=v.imag
+ # self.editor.afficheInfos(commentaire)
+ # self.valeurPressed()
+ # except :
+ # commentaire=tr("l expression n est pas de la forme a+bj")
+ # self.editor.afficheInfos(commentaire,Qt.red)
+
+ def LEReelRPressed(self):
+ # self.LEComp.clear()
+ commentaire = tr("expression valide")
+ valeur = str(self.LEReel.text())
+ try:
+ a = locale.atof(valeur)
+ self.editor.afficheInfos(commentaire)
+ except:
+ commentaire = tr("expression invalide")
+ self.editor.afficheInfos(commentaire, Qt.red)
+ if self.LEImag.text() != "":
+ self.valeurPressed()
+ else:
+ self.LEImag.setFocus(True)
+
+ def LEImagRPressed(self):
+ commentaire = tr("expression valide")
+ valeur = str(self.LEImag.text())
+ try:
+ a = locale.atof(valeur)
+ self.editor.afficheInfos(commentaire)
+ except:
+ commentaire = tr("expression invalide")
+ self.editor.afficheInfos(commentaire, Qt.red)
+ if self.LEReel.text() != "":
+ self.valeurPressed()
+ else:
+ self.LEReel.setFocus(True)
+
+ def finCommentaire(self):
+ commentaire = "valeur de type complexe"
+ return commentaire
+
+ # def getValeurComp(self):
+ # commentaire=tr("expression valide")
+ # valeur = str(self.LEComp.text())
+ # d={}
+ # try :
+ # v=eval(valeur,d)
+ # except :
+ # commentaire=tr("expression invalide")
+ # self.editor.afficheInfos(commentaire,Qt.red)
+ # return None
+ # try :
+ # i=v.imag
+ # except :
+ # commentaire=tr("expression n est pas de la forme a+bj")
+ # self.editor.afficheInfos(commentaire,Qt.red)
+ # return None
+ # return v
+
+ def valeurPressed(self):
+ if self.LEReel.text() == "" and self.LEImag.text() == "":
+ self.LEReel.setFocus(True)
+ if self.LEReel.text() == "" and self.LEImag.text() != "":
+ self.LEReel.setFocus(True)
+ if self.LEReel.text() != "" and self.LEImag.text() == "":
+ self.LEImag.setFocus(True)
+ valeur = self.getValeurRI()
+ self.politique.recordValeur(valeur)
+ self.reaffiche()
+ self.parentQt.donneFocus()
+
+ def getValeurRI(self):
+ """
+ Retourne le complexe saisi par l'utilisateur
+ """
+ l = []
+ if self.RBMP.isChecked() == 1:
+ l.append("MP")
+ elif self.RBRI.isChecked() == 1:
+ l.append("RI")
+ else:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.RBMP.setFocus(True)
+ return None
+ try:
+ l.append(locale.atof(str(self.LEReel.text())))
+ l.append(locale.atof(str(self.LEImag.text())))
+ except:
+ return None
+ return repr(tuple(l))
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+import os, sys
+
+# Modules Eficas
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import QSize
+from Extensions.i18n import tr
+
+from desWidgetSimpFichier import Ui_WidgetSimpFichier
+from .monWidgetSimpBase import MonWidgetSimpBase
+
+
+class MonWidgetSimpFichier(Ui_WidgetSimpFichier, MonWidgetSimpBase):
+ # c est juste la taille des differents widgets de base qui change
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetSimpBase.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ if sys.platform[0:5] != "linux":
+ repIcon = self.node.editor.appliEficas.repIcon
+ fichier = os.path.join(repIcon, "file-explorer.png")
+ icon = QIcon(fichier)
+ self.BFichier.setIcon(icon)
+ self.BFichier.setIconSize(QSize(32, 32))
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from PyQt5.QtWidgets import QLineEdit
+from PyQt5.QtCore import Qt
+
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetSimpSalome import Ui_WidgetSimpSalome
+from .politiquesValidation import PolitiqueUnique
+from .qtSaisie import SaisieValeur
+
+
+class MonWidgetSimpSalome(Ui_WidgetSimpSalome, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.parentQt.commandesLayout.insertWidget(-1, self, 1)
+ self.setFocusPolicy(Qt.StrongFocus)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ self.lineEditVal.returnPressed.connect(self.LEvaleurPressed)
+ self.AAfficher = self.lineEditVal
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal)
+
+ def LEvaleurPressed(self):
+ if str(self.lineEditVal.text()) == "" or str(self.lineEditVal.text()) == None:
+ return
+ SaisieValeur.LEvaleurPressed(self)
+ self.parentQt.donneFocus()
+ self.setValeurs()
+ self.reaffiche()
+
+ def setValeurs(self):
+ valeur = self.node.item.getValeur()
+ if valeur != None:
+ self.lineEditVal.setText(str(valeur))
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+from PyQt5.QtCore import Qt
+
+# Modules Eficas
+from Extensions.i18n import tr
+
+from InterfaceGUI.QT5.feuille import Feuille
+from InterfaceGUI.QT5.politiquesValidation import PolitiqueUnique
+from InterfaceGUI.QT5.qtSaisie import SaisieValeur
+
+
+class MonWidgetSimpTuple(Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ self.setFocusPolicy(Qt.StrongFocus)
+
+ def setValeurs(self):
+ valeur = self.node.item.getValeur()
+ for i in range(self.nbValeurs):
+ nomLineEdit = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLineEdit)
+ if valeur != None:
+ courant.setText(str(valeur[i]))
+ setattr(self, nomLineEdit, courant)
+ courant.returnPressed.connect(self.valeursPressed)
+
+ def valeursPressed(self):
+ aLeFocus = self.focusWidget()
+ self.editor.afficheInfos("")
+ texteValeur = ""
+ for i in range(self.nbValeurs):
+ nomLineEdit = "lineEditVal" + str(i + 1)
+ courant = getattr(self, nomLineEdit)
+ if courant.text() == "" or courant.text() == None:
+ courant.setFocus(True)
+ return
+ s = str(courant.text())
+ if hasattr(self.objSimp.definition.validators, "typeDesTuples"):
+ if self.objSimp.definition.validators.typeDesTuples[i] == "R":
+ if s.find(".") == -1 and s.find("e") == -1 and s.find("E") == -1:
+ s = s + ".0"
+ courant.setText(s)
+ if self.objSimp.definition.validators.typeDesTuples[i] == "TXM":
+ if s[0] != '"' and s[0] != "'":
+ if s[-1] == "'":
+ s = "'" + s
+ else:
+ s = '"' + s
+ if s[-1] != '"' and s[-1] != "'":
+ if s[0] == "'":
+ s = s + "'"
+ else:
+ s = s + '"'
+ courant.setText(s)
+ texteValeur += str(courant.text())
+ # print (texteValeur)
+ if i + 1 != self.nbValeurs:
+ texteValeur += ","
+ validite, commentaire = self.politique.recordValeur(texteValeur)
+ if not validite:
+ self.editor.afficheInfos(
+ commentaire
+ + " "
+ + str(self.objSimp.definition.validators.typeDesTuples),
+ Qt.red,
+ )
+
+ # Passage au champ suivant
+ nom = aLeFocus.objectName()[11:]
+ try:
+ i = int(nom) + 1
+ except:
+ try:
+ i = i + 1
+ except:
+ return
+ if i == self.nbValeurs + 1:
+ i = 1
+ nomLineEdit = "lineEditVal" + str(i)
+ courant = getattr(self, nomLineEdit)
+ courant.setFocus(True)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+# from PyQt4.QtGui import *
+# from PyQt4.QtCore import *
+from Extensions.i18n import tr
+
+from InterfaceGUI.QT5.feuille import Feuille
+from InterfaceGUI.QT5.monWidgetSimpTuple import MonWidgetSimpTuple
+from desWidgetTuple2 import Ui_WidgetTuple2
+from desWidgetTuple3 import Ui_WidgetTuple3
+from desWidgetTuple4 import Ui_WidgetTuple4
+from desWidgetTuple5 import Ui_WidgetTuple5
+from desWidgetTuple6 import Ui_WidgetTuple6
+from desWidgetTuple7 import Ui_WidgetTuple7
+from desWidgetTuple8 import Ui_WidgetTuple8
+from desWidgetTuple9 import Ui_WidgetTuple9
+from desWidgetTuple10 import Ui_WidgetTuple10
+
+
+class MonWidgetSimpTuple2(Ui_WidgetTuple2, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 2
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ if self.objSimp.isImmuable():
+ self.lineEditVal1.setDisabled(True)
+ self.lineEditVal2.setDisabled(True)
+ self.lineEditVal1.setStyleSheet(
+ "background:rgb(244,244,244);\n" "border:0px;\n"
+ )
+ self.lineEditVal2.setStyleSheet(
+ "background:rgb(244,244,244);\n" "border:0px;\n"
+ )
+ self.lineEditVal1.setToolTip(tr("Valeur non modifiable"))
+ self.lineEditVal2.setToolTip(tr("Valeur non modifiable"))
+ else:
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
+
+
+class MonWidgetSimpTuple3(Ui_WidgetTuple3, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 3
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+ if self.objSimp.isImmuable():
+ self.lineEditVal1.setDisabled(True)
+ self.lineEditVal2.setDisabled(True)
+ self.lineEditVal3.setDisabled(True)
+ self.lineEditVal1.setStyleSheet(
+ "background:rgb(244,244,244);\n" "border:0px;\n"
+ )
+ self.lineEditVal2.setStyleSheet(
+ "background:rgb(244,244,244);\n" "border:0px;\n"
+ )
+ self.lineEditVal3.setStyleSheet(
+ "background:rgb(244,244,244);\n" "border:0px;\n"
+ )
+ self.lineEditVal1.setToolTip(tr("Valeur non modifiable"))
+ self.lineEditVal2.setToolTip(tr("Valeur non modifiable"))
+ self.lineEditVal3.setToolTip(tr("Valeur non modifiable"))
+ else:
+ self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
+
+
+class MonWidgetSimpTuple4(Ui_WidgetTuple4, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ # print (self,node,monSimpDef,nom,objSimp,parentQt,commande)
+ self.nbValeurs = 4
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetSimpTuple5(Ui_WidgetTuple5, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 5
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetSimpTuple6(Ui_WidgetTuple6, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 6
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetSimpTuple7(Ui_WidgetTuple7, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 7
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetSimpTuple8(Ui_WidgetTuple8, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 8
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetSimpTuple9(Ui_WidgetTuple9, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 9
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+
+class MonWidgetSimpTuple10(Ui_WidgetTuple10, MonWidgetSimpTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = 10
+ MonWidgetSimpTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from Extensions.i18n import tr
+
+from desWidgetSimpTxt import Ui_WidgetSimpTxt
+from .monWidgetSimpBase import MonWidgetSimpBase
+
+
+class MonWidgetSimpTxt(Ui_WidgetSimpTxt, MonWidgetSimpBase):
+ # c est juste la taille des differents widgets de base qui change
+
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ MonWidgetSimpBase.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from PyQt5.QtWidgets import QLabel, QSizePolicy, QSpacerItem
+from PyQt5.QtCore import QSize
+
+from InterfaceGUI.QT5.feuille import Feuille
+from InterfaceGUI.QT5.monWidgetPlusieursTuple import MonWidgetPlusieursTuple
+from desWidgetPlusieursTuple import Ui_WidgetPlusieursTuple
+from desWidgetTableau import Ui_WidgetTableau
+
+maxLen = 3
+
+
+class MonWidgetTableau(Ui_WidgetTableau, MonWidgetPlusieursTuple):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ self.nbValeurs = len(monSimpDef.homo)
+ MonWidgetPlusieursTuple.__init__(
+ self, node, monSimpDef, nom, objSimp, parentQt, commande
+ )
+
+ sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+
+ for i in range(len(monSimpDef.homo)):
+ nomCol = "LECol" + str(i + 1)
+ objCol = QLabel(self)
+ objCol.setMinimumSize(QSize(80, 25))
+ objCol.setText(monSimpDef.homo[i])
+ self.LATitre.addWidget(objCol)
+ setattr(self, nomCol, objCol)
+ spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
+ self.LATitre.addItem(spacerItem)
+ self.resize(self.width(), 1800)
+
+ def ajoutLineEdit(self, valeur=None, inInit=False):
+ hauteurAvant = self.frame.height()
+ MonWidgetPlusieursTuple.ajoutLineEdit(self, valeur, inInit)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+
+# 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.getValeur()
+ if valeur != "" and valeur != None:
+ self.LESDCO.setText(valeur.nom)
+ self.connect(self.LESDCO, SIGNAL("returnPressed()"), self.LESDCOReturnPressed)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 Eficas
+from Extensions.i18n import tr
+
+from .feuille import Feuille
+from desWidgetVide import Ui_WidgetVide
+from InterfaceGUI.QT5.politiquesValidation import PolitiqueUnique
+
+
+class MonWidgetVide(Ui_WidgetVide, Feuille):
+ def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
+ Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
+ self.politique = PolitiqueUnique(self.node, self.editor)
+ t = self.node.item.object.definition.type[0].__name__
+ self.lineEditVal.setText("Attend un objet de type " + t + ". Il faut en créer")
+ self.parentQt.commandesLayout.insertWidget(-1, self)
+ # PN il faut remplir le type
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+from Accas import PARAMETRE
+from Extensions.i18n import tr
+
+
+# ---------------------
+class Validation(object):
+# ---------------------
+ def __init__(self, node, parent):
+ self.node = node
+ self.parent = parent
+
+ def testeUneValeur(self, valeurentree):
+ commentaire = None
+ # import traceback
+ # traceback.print_stack()
+ valeur, validite = self.node.item.evalValeur(valeurentree)
+ if not validite:
+ commentaire = "impossible d'evaluer : %s " % repr(valeurentree)
+ return valeur, validite, commentaire
+ if self.node.item.waitTxm() and not (type(valeur) == str):
+ valeur = str(valeur)
+
+ testtype, commentaire = self.node.item.object.verifType(valeur)
+ if not testtype:
+ return valeur, 0, commentaire
+
+ valide = self.node.item.valideItem(valeur)
+ if type(valide) == tuple:
+ validite, commentaire = valide
+ else:
+ validite = valide
+ commentaire = " "
+
+ if not validite and commentaire is None:
+ commentaire = "impossible d'evaluer : %s " % repr(valeurentree)
+ # print ('ds testeUneValeur', valeur, validite, commentaire)
+ return valeur, validite, commentaire
+
+ # ----------------------------------------------------------------------------------------
+ # Methodes utilisees pour la manipulation des items en notation scientifique
+ # a mettre au point
+ # ----------------------------------------------------------------------------------------
+ def setValeurTexte(self, texteValeur):
+ try:
+ if "R" in self.node.item.object.definition.type:
+ if texteValeur[0] != "'":
+ clef = eval(texteValeur)
+ if str(clef) != str(texteValeur):
+ self.node.item.object.initModif()
+ clefobj = self.node.item.object.getNomConcept()
+ if not clefobj in self.parent.appliEficas.dict_reels:
+ self.parent.appliEficas.dict_reels[clefobj] = {}
+ self.parent.appliEficas.dict_reels[clefobj][clef] = texteValeur
+ self.parent.appliEficas.dict_reels[clefobj]
+ if clefobj == "":
+ if (
+ not self.node.item.object.etape
+ in self.parent.appliEficas.dict_reels
+ ):
+ self.parent.appliEficas.dict_reels[
+ self.node.item.object.etape
+ ] = {}
+ self.parent.appliEficas.dict_reels[
+ self.node.item.object.etape
+ ][clef] = texteValeur
+ self.node.item.object.finModif()
+ except:
+ pass
+
+ def getValeurTexte(self, valeur):
+ valeurTexte = valeur
+ if valeur == None:
+ return valeur
+ from decimal import Decimal
+
+ if isinstance(valeur, Decimal):
+ if self.node.waitTxm() and not self.isParam(valeur):
+ return "'" + str(valeur) + "'"
+ else:
+ return valeur
+ if "R" in self.node.item.object.definition.type:
+ clefobj = self.node.item.object.getNomConcept()
+ if clefobj in self.parent.appliEficas.dict_reels:
+ if valeur in self.parent.appliEficas.dict_reels[clefobj]:
+ valeurTexte = self.parent.appliEficas.dict_reels[clefobj][valeur]
+ else:
+ if (
+ str(valeur).find(".") == -1
+ and str(valeur).find("e") == -1
+ and str(valeur).find("E")
+ ):
+ # aucun '.' n'a ete trouve dans valeur --> on en rajoute un a la fin
+ if self.isParam(valeur):
+ return valeur
+ else:
+ try:
+ val2 = eval(str(valeur) + ".")
+ except:
+ pass
+ return valeurTexte
+
+ def isParam(self, valeur):
+ for param in self.node.item.jdc.params:
+ if (repr(param) == repr(valeur)) or (str(param) == str(valeur)):
+ return 1
+ return 0
+
+ def ajoutDsDictReel(self, texteValeur):
+ # le try except est necessaire pour saisir les parametres
+ # on enleve l erreur de saisie 00 pour 0
+ if str(texteValeur) == "00":
+ return
+ try:
+ if "R" in self.node.item.object.definition.type:
+ if str(texteValeur)[0] != "'":
+ clef = eval(texteValeur)
+ if str(clef) != str(texteValeur):
+ clefobj = self.node.item.object.getNomConcept()
+ if not clefobj in self.parent.appliEficas:
+ self.parent.appliEficas.dict_reels[clefobj] = {}
+ self.parent.appliEficas.dict_reels[clefobj][clef] = texteValeur
+ if clefobj == "":
+ if (
+ not self.node.item.object.etape
+ in self.parent.appliEficas.dict_reels
+ ):
+ self.parent.appliEficas.dict_reels[
+ self.node.item.object.etape
+ ] = {}
+ self.parent.appliEficas.dict_reels[
+ self.node.item.object.etape
+ ][clef] = texteValeur
+
+ except:
+ pass
+
+ def ajoutDsDictReelEtape(self):
+ try:
+ if self.node.item.object in self.parent.appliEficas.dict_reels:
+ self.parent.appliEficas.dict_reels[
+ self.node.item.sdnom
+ ] = self.parent.appliEficas.dict_reels[self.node.item.object]
+ del self.parent.appliEficas.dict_reels[self.node.item.object]
+ except:
+ pass
+
+
+# ------------------------------------
+class PolitiqueUnique(Validation):
+ # ------------------------------------
+ """
+ classe servant pour les entrees ne demandant qu un mot clef
+ """
+
+ def __init__(self, node, parent):
+ Validation.__init__(self, node, parent)
+
+ def recordValeur(self, valeurentree):
+ if self.parent.modified == "n":
+ self.parent.initModif()
+ ancienneVal = self.node.item.getValeur()
+ valeur, validite, commentaire = self.testeUneValeur(valeurentree)
+ if (
+ validite
+ and ("R" in self.node.item.object.definition.type)
+ and not (isinstance(valeur, PARAMETRE))
+ ):
+ s = valeurentree
+ if s.find(".") == -1 and s.find("e") == -1 and s.find("E") == -1:
+ s = s + "."
+ valeur, validite, commentaire = self.testeUneValeur(s)
+ if validite:
+ validite = self.node.item.setValeur(valeur)
+ if self.node.item.isValid():
+ commentaire = tr("Valeur du mot-cle enregistree")
+ # commentaire = "Valeur du mot-cle enregistree"
+ self.setValeurTexte(str(valeurentree))
+ else:
+ cr = self.node.item.getCr()
+ commentaire = tr("Valeur du mot-cle non autorisee ") + cr.getMessFatal()
+ self.node.item.setValeur(ancienneVal)
+ return validite, commentaire
+
+
+# --------------------------------------
+class PolitiquePlusieurs(Validation):
+ # --------------------------------------
+ """
+ classe servant pour les entrees ne demandant qu un mot clef
+ """
+
+ def __init__(self, node, parent):
+ # print "ds PolitiquePlusieurs"
+ self.node = node
+ self.parent = parent
+ # print self.node
+ # print self.parent
+
+ def ajoutValeurs(self, listevaleur, index, listecourante):
+ listeRetour = []
+ commentaire = "Nouvelle valeur acceptee"
+ commentaire2 = ""
+ valide = 1
+ if listevaleur == None:
+ return
+ if listevaleur == "":
+ return
+ if not (type(listevaleur) in (list, tuple)):
+ listevaleur = tuple(listevaleur)
+ # on verifie que la cardinalite max n a pas ete atteinte
+ min, max = self.node.item.getMinMax()
+ if len(listecourante) + len(listevaleur) > max:
+ commentaire = (
+ "La liste atteint le nombre maximum d'elements : "
+ + str(max)
+ + " ,ajout refuse"
+ )
+ return False, commentaire, commentaire2, listeRetour
+
+ for valeur in listevaleur:
+ # On teste le type de la valeur
+ valeurScientifique = valeur
+ valide = self.node.item.valideItem(valeur)
+ if not valide:
+ try:
+ valeur, valide = self.node.item.evalValeur(valeur)
+ valide, commentaire2 = self.node.item.object.verifType(valeur)
+ except:
+ # return testtype,commentaire,"",listeRetour
+ pass
+ if not valide:
+ if commentaire.find("On attend un chaine") > 1:
+ commentaire = (
+ "Valeur "
+ + str(valeur)
+ + " incorrecte : ajout a la liste refuse: On attend une chaine de caracteres < 8"
+ )
+ else:
+ commentaire = (
+ "Valeur "
+ + str(valeur)
+ + " incorrecte : ajout a la liste refuse"
+ )
+ if commentaire2 == "":
+ commentaire2 = self.node.item.infoErreurItem()
+ return valide, commentaire, commentaire2, listeRetour
+
+ # On valide la liste obtenue
+ encorevalide = self.node.item.valideListePartielle(valeur, listecourante)
+ if not encorevalide:
+ commentaire2 = self.node.item.infoErreurListe()
+ # On traite le cas ou la liste n est pas valide pour un pb de cardinalite
+ min, max = self.node.item.getMinMax()
+ if len(listecourante) + 1 >= max:
+ commentaire = (
+ "La liste atteint le nombre maximum d'elements : "
+ + str(max)
+ + " ,ajout refuse"
+ )
+ return valide, commentaire, commentaire2, listeRetour
+ if len(listecourante) + 1 > min:
+ commentaire = ""
+ return valide, commentaire, commentaire2, listeRetour
+ # On ajoute la valeur testee a la liste courante et a la liste acceptee
+ self.ajoutDsDictReel(valeurScientifique)
+ listecourante.insert(index, valeur)
+ index = index + 1
+ listeRetour.append(valeur)
+
+ return valide, commentaire, commentaire2, listeRetour
+
+ def ajoutTuple(self, valeurTuple, listecourante):
+ listeRetour = []
+ commentaire = "Nouvelle valeur acceptee"
+ commentaire2 = ""
+ valide = 1
+ if valeurTuple == None:
+ return
+ if valeurTuple == [""]:
+ return
+ # On teste le type de la valeur
+ valide = self.node.item.valideItem(valeurTuple)
+ if not valide:
+ try:
+ valeur, valide = self.node.item.evalValeur(valeurTuple)
+ valide = self.node.item.valideItem(valeur)
+ except:
+ pass
+ if not valide:
+ commentaire = (
+ "Valeur " + str(valeurTuple) + " incorrecte : ajout a la liste refuse"
+ )
+ commentaire2 = self.node.item.infoErreurItem()
+ return valide, commentaire, commentaire2, listeRetour
+
+ # On valide la liste obtenue
+ encorevalide = self.node.item.valideListePartielle(valeurTuple, listecourante)
+ if not encorevalide:
+ commentaire2 = self.node.item.infoErreurListe()
+ return valide, commentaire, commentaire2, listeRetour
+ listeRetour.append(valeurTuple)
+ return valide, commentaire, commentaire2, listeRetour
+
+ def ajoutNTuple(self, liste):
+ commentaire = "Nouvelles valeurs acceptee"
+ commentaire2 = ""
+ valide = self.node.item.valideListePartielle(None, liste)
+ print("uuuuuuuuuuu", valide)
+ if not valide:
+ commentaire2 = self.node.item.infoErreurListe()
+ return valide, commentaire, commentaire2
+
+ def recordValeur(self, liste, dejaValide=True):
+ ancienneVal = self.node.item.getValeur()
+ validite = self.node.item.setValeur(liste)
+ if validite:
+ self.node.item.initModif()
+ if self.node.item.isValid():
+ commentaire = tr("Valeur du mot-cle enregistree")
+ else:
+ cr = self.node.item.getCr()
+ commentaire = tr("Valeur du mot-cle non autorisee ") + cr.getMessFatal()
+ self.node.item.setValeur(ancienneVal)
+ return validite, commentaire
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2024 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
+#
+import os, sys
+#pathUi = os.path.abspath(os.path.dirname(__file__), '..', '..', 'UiQT5')
+#if not pathUi not in sys.path : sys.path.append(pathUi)
+
+from PyQt5.QtWidgets import ( QApplication, QMainWindow, QGridLayout, QBoxLayout, QMenu, QAction, QMessageBox,)
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import Qt, QSize
+
+
+from Editeur import session
+from UiQT5.myMain import Ui_Eficas
+from InterfaceGUI.QT5.viewManager import MyViewManager
+from InterfaceGUI.qtEficasSsIhm import AppliSsIhm
+
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
+from Extensions import param2
+
+
+class Appli(AppliSsIhm, Ui_Eficas, QMainWindow):
+ """
+ Class implementing the main user interface.
+ """
+
+ def __init__(
+ self,
+ code=None,
+ salome=1,
+ parent=None,
+ multi=False,
+ langue="en",
+ ssIhm=False,
+ labelCode=None,
+ GUIPath="InterfaceGUI.QT5",
+ ):
+ """
+ Constructor
+ """
+ if ssIhm == True:
+ print("mauvaise utilisation de la classe Appli. Utiliser AppliSsIm SVP")
+ exit()
+
+ AppliSsIhm.__init__(
+ self,
+ code,
+ salome,
+ parent,
+ multi=multi,
+ langue=langue,
+ ssIhm=True,
+ labelCode=labelCode,
+ )
+ QMainWindow.__init__(self, parent)
+ Ui_Eficas.__init__(self)
+
+ self.ssIhm = False
+ self.multi = multi
+ self.demande = multi # voir PSEN
+ self.GUIPath = GUIPath
+
+ if self.multi == False:
+ self.definitCode(code, None)
+ if self.code == None:
+ return
+ else:
+ self.definitCode(code, None)
+ if self.code == None:
+ return
+
+ self.suiteTelemac = False
+ if hasattr(self, "maConfiguration"):
+ if self.maConfiguration.demandeLangue:
+ from InterfaceGUI.QT5.monChoixLangue import MonChoixLangue
+
+ widgetLangue = MonChoixLangue(self)
+ ret = widgetLangue.exec_()
+ self.suiteTelemac = self.maConfiguration.suiteTelemac
+
+ if (
+ not self.salome
+ and hasattr(self, "maConfiguration")
+ and hasattr(self.maConfiguration, "lang")
+ ):
+ self.langue = self.maConfiguration.lang
+ from Extensions import localisation
+
+ app = QApplication
+ if hasattr(self, "maConfiguration"):
+ localisation.localise(
+ None,
+ self.langue,
+ translatorFichier=self.maConfiguration.translatorFichier,
+ )
+ self.setupUi(self)
+
+ # if parent != None : self.parentCentralWidget = parent.centralWidget()
+ # else : self.parentCentralWidget = None
+
+ if not self.salome:
+ if hasattr(self, "maConfiguration") and hasattr(
+ self.maConfiguration, "taille"
+ ):
+ self.taille = self.maConfiguration.taille
+ else:
+ self.taille = 1700
+
+ self.resize(self.taille, self.height())
+
+ icon = QIcon(self.repIcon + "/parametres.png")
+ self.actionParametres.setIcon(icon)
+ if hasattr(self, "maConfiguration") and self.maConfiguration.boutonDsMenuBar:
+ self.frameEntete.setMaximumSize(QSize(16777215, 100))
+ self.frameEntete.setMinimumSize(QSize(0, 100))
+ if (
+ hasattr(self, "maConfiguration")
+ and self.maConfiguration.enleverActionStructures
+ ):
+ self.enleverActionsStructures()
+ if hasattr(self, "maConfiguration") and self.maConfiguration.enleverParametres:
+ self.enleverParametres()
+ if hasattr(self, "maConfiguration") and self.maConfiguration.enleverSupprimer:
+ self.enleverSupprimer()
+
+ if hasattr(self, "frameEntete"):
+ self.myQtab.removeTab(0)
+ self.blEnteteGlob = QBoxLayout(2, self.frameEntete)
+ self.blEnteteGlob.setSpacing(0)
+ self.blEnteteGlob.setContentsMargins(0, 0, 0, 0)
+
+ self.blEntete = QBoxLayout(0)
+ self.blEntete.insertWidget(0, self.toolBar)
+ self.blEntete.insertWidget(0, self.menubar)
+ self.blEnteteGlob.insertLayout(0, self.blEntete)
+
+ if hasattr(self, "maConfiguration") and self.maConfiguration.boutonDsMenuBar:
+ self.blEnteteCommmande = QBoxLayout(0)
+ self.blEnteteCommmande.insertWidget(0, self.toolBarCommande)
+ self.toolBarCommande.setIconSize(QSize(96, 96))
+ self.blEnteteGlob.insertLayout(-1, self.blEnteteCommmande)
+ else:
+ self.toolBarCommande.close()
+
+ if (
+ hasattr(self, "maConfiguration")
+ and self.maConfiguration.closeEntete == True
+ and self.salome
+ ):
+ self.closeEntete()
+
+ eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+ self.viewmanager = MyViewManager(self)
+ self.recentMenu = QMenu(tr("&Recents"))
+ # self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
+
+ # actionARemplacer ne sert que pour l insert Menu
+ if hasattr(self, "actionARemplacer"):
+ self.menuFichier.insertMenu(self.actionARemplacer, self.recentMenu)
+ self.menuFichier.removeAction(self.actionARemplacer)
+ self.connecterSignaux()
+ self.toolBar.addSeparator()
+
+ if self.code != None:
+ self.construitMenu()
+
+ self.setWindowTitle(self.VERSION_EFICAS)
+ try:
+ # if 1 :
+ # print ('attention try devient if 1')
+ self.ouvreFichiers()
+ except EficasException as exc:
+ # except:
+ print("je suis dans le except")
+ if self.salome == 0:
+ exit()
+
+ # self.adjustSize()
+
+ def closeEntete(self):
+ self.menuBar().close()
+ self.toolBar.close()
+ self.frameEntete.close()
+
+ def definitCode(self, code, ssCode):
+ self.code = code
+ self.ssCode = ssCode
+ if self.code == None:
+ self.cleanPath()
+ from InterfaceGUI.QT5.monChoixCode import MonChoixCode
+
+ widgetChoix = MonChoixCode(self)
+ ret = widgetChoix.exec_()
+ # widgetChoix.show()
+ if self.code == None:
+ return # pour le cancel de la fenetre choix code
+ AppliSsIhm.definitCode(self, self.code, ssCode)
+
+ # PN --> pb d exception qui font planter salome
+ # plus supporte en python 3
+ # app=QApplication
+ # if hasattr(prefsCode,'encoding'):
+ # import sys
+ # reload(sys)
+ # sys.setdefaultencoding(prefsCode.encoding)
+
+ def construitMenu(self):
+ self.initPatrons()
+ self.initRecents()
+ self.initAides()
+ for intituleMenu in (
+ "menuTraduction",
+ "menuOptions",
+ "menuMesh",
+ "menuExecution",
+ "menuN1",
+ ):
+ if hasattr(self, intituleMenu):
+ menu = getattr(self, intituleMenu)
+ menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.close()
+ delattr(self, intituleMenu)
+ for intituleAction in ("actionExecution", "actionSaveRun"):
+ if hasattr(self, intituleAction):
+ action = getattr(self, intituleAction)
+ self.toolBar.removeAction(action)
+ if self.code.upper() in Appli.__dict__:
+ Appli.__dict__[self.code.upper()](
+ self,
+ )
+ if self.suiteTelemac:
+ self.lookSuiteTelemac()
+ self.metMenuAJourUtilisateurs()
+ if hasattr(self, "maConfiguration") and self.maConfiguration.ajoutExecution:
+ self.ajoutExecution()
+
+ def initAides(self):
+ # print "je passe la"
+ repAide = os.path.dirname(os.path.abspath(__file__))
+ fileName = "index.html"
+ self.docPath = repAide + "/../Aide"
+ if hasattr(self, "maConfiguration") and hasattr(
+ self.maConfiguration, "docPath"
+ ):
+ self.docPath = self.maConfiguration.docPath
+ if hasattr(self, "maConfiguration") and hasattr(
+ self.maConfiguration, "fileName"
+ ):
+ fileName = self.maConfiguration.fileName
+ self.fileDoc = os.path.join(self.docPath, fileName)
+ self.actionCode.setText(tr("Aide specifique ") + str(self.code))
+ if not os.path.isfile(self.fileDoc):
+ self.fileDoc = ""
+ self.docPath = ""
+ self.actionCode.setEnabled(False)
+ return
+
+ self.actionCode.setEnabled(True)
+ self.menuAide.addAction(self.actionCode)
+
+ def newN1(self):
+ ssCode = None
+ code = "PSEN_N1"
+ self.cleanPath()
+ dirCode = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "../..", "ProcessOutputs_Eficas")
+ )
+ sys.path.insert(0, dirCode)
+ self.code = code
+ self.definitCode(code, ssCode)
+ self.initRecents()
+ self.multi = True
+ self.demande = False
+ self.fileNew()
+
+ def newPSEN(self):
+ ssCode = None
+ code = "PSEN"
+ self.cleanPath()
+ dirCode = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "../..", code)
+ )
+ sys.path.insert(0, dirCode)
+ self.code = code
+ self.definitCode(code, ssCode)
+ self.multi = True
+ self.demande = False
+ self.fileNew()
+
+ def ajoutUQ(self):
+ AppliSsIhm.ajoutUQ(self)
+ self.menuUQ = self.menubar.addMenu(tr("Incertitude"))
+ self.actionSaveUQ = QAction(self)
+ self.actionSaveUQ.setText(
+ tr("Sauvegarde des fichiers pour l'étude incertaine")
+ )
+ self.menuUQ.addAction(self.actionSaveUQ)
+ self.actionSaveUQ.triggered.connect(self.handleSortieUQ)
+ self.actionExeUQ = QAction(self)
+ self.actionExeUQ.setText(tr("Sauvegarde et Lancement de l'étude"))
+ self.menuUQ.addAction(self.actionExeUQ)
+ self.actionExeUQ.triggered.connect(self.handleExeUQ)
+ self.actionSauvePersalys = QAction(self)
+ self.actionSauvePersalys.setText(tr("Sauvegarde du script Persalys"))
+ self.menuUQ.addAction(self.actionSauvePersalys)
+ self.actionSauvePersalys.triggered.connect(self.handleSauvePourPersalys)
+ # self.actionEnregistrer.setDisabled(True)
+ # self.actionEnregistrer_sous.setDisabled(True)
+
+ def ajoutN1(self):
+ return
+ self.menuN1 = self.menubar.addMenu(tr("Process Output"))
+ self.actionN1 = QAction(self)
+ self.actionN1.setText(tr("Process Output"))
+ self.menuN1.addAction(self.actionN1)
+ self.actionN1.triggered.connect(self.newN1)
+
+ if hasattr(self, "actionOpenProcess"):
+ return
+
+ self.actionOpenProcess = QAction(self)
+ self.actionOpenProcess.setText(tr("Open Process_Output File"))
+ self.menuN1.addAction(self.actionOpenProcess)
+ self.actionOpenProcess.triggered.connect(self.openProcess)
+
+ def ajoutExecution(self):
+ self.menuExecution = self.menubar.addMenu(tr("&Run"))
+ self.actionExecution = QAction(self)
+ if sys.platform[0:5] == "linux":
+ icon6 = QIcon(self.repIcon + "/roue.png")
+ self.actionExecution.setIcon(icon6)
+ else:
+ self.actionExecution.setText(tr("Run"))
+ self.actionExecution.setObjectName("actionExecution")
+ self.menuExecution.addAction(self.actionExecution)
+ if not (self.actionExecution in self.toolBar.actions()):
+ self.toolBar.addAction(self.actionExecution)
+ self.actionExecution.setText(tr("Run"))
+ self.actionExecution.triggered.connect(self.run)
+
+ def ajoutSauveExecution(self):
+ self.actionSaveRun = QAction(self)
+ icon7 = QIcon(self.repIcon + "/export_MAP.png")
+ self.actionSaveRun.setIcon(icon7)
+ self.actionSaveRun.setObjectName("actionSaveRun")
+ self.menuExecution.addAction(self.actionSaveRun)
+ if not (self.actionSaveRun in self.toolBar.actions()):
+ self.toolBar.addAction(self.actionSaveRun)
+ self.actionSaveRun.setText(tr("Save Run"))
+ self.actionSaveRun.triggered.connect(self.saveRun)
+
+ def griserActionsStructures(self):
+ self.actionCouper.setEnabled(False)
+ self.actionColler.setEnabled(False)
+ self.actionCopier.setEnabled(False)
+ self.actionSupprimer.setEnabled(False)
+
+ def enleverActionsStructures(self):
+ self.toolBar.removeAction(self.actionCopier)
+ self.toolBar.removeAction(self.actionColler)
+ self.toolBar.removeAction(self.actionCouper)
+ self.menuEdition.removeAction(self.actionCouper)
+ self.menuEdition.removeAction(self.actionCopier)
+ self.menuEdition.removeAction(self.actionColler)
+
+ def enleverParametres(self):
+ self.toolBar.removeAction(self.actionParametres)
+ self.menuJdC.removeAction(self.actionParametres)
+
+ def enleverSupprimer(self):
+ self.toolBar.removeAction(self.actionSupprimer)
+
+ def enlevernewInclude(self):
+ self.actionNouvel_Include.setVisible(False)
+
+ def enleverRechercherDsCatalogue(self):
+ self.actionRechercherDsCatalogue.setVisible(False)
+
+ def connectRechercherDsCatalogue(self):
+ if hasattr(self, "rechercherDejaLa"):
+ return
+ self.rechercherDejaLa = True
+ self.actionRechercherDsCatalogue.triggered.connect(
+ self.handleRechercherDsCatalogue
+ )
+
+ def ajoutSortieComplete(self):
+ if hasattr(self, "actionSortieComplete"):
+ return
+ self.actionSortieComplete = QAction(self)
+ self.actionSortieComplete.setText(tr("Sortie Complete"))
+ self.menuFichier.insertAction(
+ self.actionEnregistrer_sous, self.actionSortieComplete
+ )
+ self.actionSortieComplete.triggered.connect(self.handleSortieComplete)
+
+ def MT(self):
+ self.enlevernewInclude()
+ self.toolBar.addSeparator()
+
+ def ZCRACKS(self):
+ self.enlevernewInclude()
+ self.toolBar.addSeparator()
+ self.ajoutExecution()
+
+ self.menuOptions = self.menubar.addMenu("menuOptions")
+ self.menuOptions.addAction(self.actionParametres_Eficas)
+ self.menuOptions.setTitle(tr("Options"))
+
+ def ADAO(self):
+ self.enleverActionsStructures()
+ self.enlevernewInclude()
+
+ def ASTER(self):
+ self.menuTraduction = self.menubar.addMenu("menuTraduction")
+ self.menuTraduction.addAction(self.actionTraduitV11V12)
+ self.menuTraduction.addAction(self.actionTraduitV10V11)
+ self.menuTraduction.addAction(self.actionTraduitV9V10)
+ self.menuTraduction.setTitle(tr("Traduction"))
+
+ self.menuFichier.addAction(self.actionSauveLigne)
+
+ self.menuOptions = self.menubar.addMenu("menuOptions")
+ self.menuOptions.addAction(self.actionParametres_Eficas)
+ self.menuOptions.addAction(self.actionLecteur_Pdf)
+ self.menuOptions.setTitle(tr("Options"))
+
+ def CARMEL3D(self):
+ # if self.salome == 0 : return
+ self.enlevernewInclude()
+ self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
+ self.menuMesh.setObjectName("Mesh")
+ self.menuMesh.addAction(self.actionChercheGrpMaille)
+ # self.griserActionsStructures()
+
+ def CARMELCND(self):
+ self.enlevernewInclude()
+ self.enleverRechercherDsCatalogue()
+ self.ajoutExecution()
+ self.ajoutSauveExecution()
+ self.griserActionsStructures()
+
+ def MAP(self):
+ self.enlevernewInclude()
+ self.toolBar.addSeparator()
+ self.ajoutExecution()
+ self.ajoutSauveExecution()
+ self.menuOptions = self.menubar.addMenu("menuOptions")
+ self.menuOptions.addAction(self.actionParametres_Eficas)
+ self.menuOptions.setTitle(tr("Options"))
+
+ def MAPIDENTIFICATION(self):
+ self.enlevernewInclude()
+ self.enleverSupprimer()
+ # self.ajoutExecution()
+ self.enleverRechercherDsCatalogue()
+ self.enleverActionsStructures()
+ self.enleverParametres()
+
+ def PSEN(self):
+ try:
+ self.action_Nouveau.triggered.disconnect(self.fileNew)
+ except:
+ pass
+ try:
+ self.action_Nouveau.triggered.disconnect(self.newPSEN)
+ except:
+ pass
+
+ self.action_Nouveau.triggered.connect(self.newPSEN)
+ self.enleverActionsStructures()
+ self.enleverParametres()
+ self.enleverRechercherDsCatalogue()
+ self.enlevernewInclude()
+ self.ajoutExecution()
+ self.ajoutN1()
+ self.ajoutHelpPSEN()
+ self.ajoutIcones()
+
+ def PSEN_N1(self):
+ self.enleverActionsStructures()
+ self.enleverParametres()
+ self.enleverRechercherDsCatalogue()
+ self.enlevernewInclude()
+ self.ajoutExecution()
+ self.ajoutIcones()
+
+ def TELEMAC(self):
+ self.enleverActionsStructures()
+ self.enlevernewInclude()
+ self.connectRechercherDsCatalogue()
+ self.ajoutSortieComplete()
+
+ def lookSuiteTelemac(self):
+ self.enleverActionsStructures()
+ self.enlevernewInclude()
+ self.enleverParametres()
+ self.enleverSupprimer()
+ self.enleverRechercherDsCatalogue()
+
+ def ajoutHelpPSEN(self):
+ self.actionParametres_Eficas.setText("Help PSEN")
+ self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
+
+ def ChercheGrpMesh(self):
+ Msg, listeGroup = self.ChercheGrpMeshInSalome()
+ if Msg == None:
+ self.viewmanager.handleAjoutGroup(listeGroup)
+ else:
+ print("il faut gerer les erreurs")
+
+ def ChercheGrpMaille(self):
+ # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
+ try:
+ Msg, listeGroup = self.ChercheGrpMailleInSalome() # recherche dans Salome
+ # Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
+ except:
+ raise ValueError("Salome non ouvert")
+ if Msg == None:
+ self.viewmanager.handleAjoutGroup(listeGroup)
+ else:
+ print("il faut gerer les erreurs")
+
+ def ChercheGrp(self):
+ # Msg,listeGroup=self.ChercheGrpMailleInSalome()
+ # if Msg == None :
+ # self.viewmanager.handleAjoutGroup(listeGroup)
+ # else :
+ # print "il faut gerer "
+ pass
+
+ def ajoutIcones(self):
+ # Pour pallier les soucis de repertoire d icone
+ # print self.repIcon
+ icon = QIcon(self.repIcon + "/new_file.png")
+ self.action_Nouveau.setIcon(icon)
+ icon1 = QIcon(self.repIcon + "/ouvrir.png")
+ self.actionOuvrir.setIcon(icon1)
+ icon2 = QIcon(self.repIcon + "/save.png")
+ self.actionEnregistrer.setIcon(icon2)
+ icon6 = QIcon(self.repIcon + "/delete.png")
+ self.actionSupprimer.setIcon(icon6)
+ icon7 = QIcon(self.repIcon + "/roue.png")
+ self.actionExecution.setIcon(icon7)
+
+ def connecterSignauxQT4(self):
+ self.connect(
+ self.recentMenu, SIGNAL("aboutToShow()"), self.handleShowRecentMenu
+ )
+
+ self.connect(self.action_Nouveau, SIGNAL("triggered()"), self.fileNew)
+ self.connect(self.actionNouvel_Include, SIGNAL("triggered()"), self.newInclude)
+ self.connect(self.actionOuvrir, SIGNAL("triggered()"), self.fileOpen)
+ self.connect(self.actionEnregistrer, SIGNAL("triggered()"), self.fileSave)
+ self.connect(
+ self.actionEnregistrer_sous, SIGNAL("triggered()"), self.fileSaveAs
+ )
+ self.connect(self.actionFermer, SIGNAL("triggered()"), self.fileClose)
+ self.connect(self.actionFermer_tout, SIGNAL("triggered()"), self.fileCloseAll)
+ self.connect(self.actionQuitter, SIGNAL("triggered()"), self.fileExit)
+
+ self.connect(self.actionEficas, SIGNAL("triggered()"), self.aidePPal)
+ self.connect(self.actionVersion, SIGNAL("triggered()"), self.version)
+ self.connect(self.actionParametres, SIGNAL("triggered()"), self.gestionParam)
+
+ self.connect(self.actionCouper, SIGNAL("triggered()"), self.editCut)
+ self.connect(self.actionCopier, SIGNAL("triggered()"), self.editCopy)
+ self.connect(self.actionColler, SIGNAL("triggered()"), self.editPaste)
+ self.connect(self.actionSupprimer, SIGNAL("triggered()"), self.supprimer)
+ self.connect(self.actionRechercher, SIGNAL("triggered()"), self.rechercher)
+ self.connect(
+ self.actionDeplier_replier, SIGNAL("triggered()"), self.handleDeplier
+ )
+
+ self.connect(
+ self.actionRapport_de_Validation, SIGNAL("triggered()"), self.jdcRapport
+ )
+ self.connect(self.actionRegles_du_JdC, SIGNAL("triggered()"), self.jdcRegles)
+ self.connect(
+ self.actionFichier_Source, SIGNAL("triggered()"), self.jdcFichierSource
+ )
+ self.connect(self.actionFichier_Resultat, SIGNAL("triggered()"), self.visuJdcPy)
+
+ # Pour Aster
+ self.actionTraduitV9V10 = QAction(self)
+ self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
+ self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
+ self.actionTraduitV10V11 = QAction(self)
+ self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
+ self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
+ self.actionTraduitV11V12 = QAction(self)
+ self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
+ self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
+ self.actionSauveLigne = QAction(self)
+ self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
+
+ # self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
+ self.connect(self.actionLecteur_Pdf, SIGNAL("triggered()"), self.optionPdf)
+ self.connect(
+ self.actionTraduitV9V10, SIGNAL("triggered()"), self.traductionV9V10
+ )
+ self.connect(
+ self.actionTraduitV10V11, SIGNAL("triggered()"), self.traductionV10V11
+ )
+ self.connect(
+ self.actionTraduitV11V12, SIGNAL("triggered()"), self.traductionV11V12
+ )
+ self.connect(self.actionSauveLigne, SIGNAL("triggered()"), self.sauveLigne)
+
+ # Pour Carmel
+ self.actionChercheGrpMaille = QAction(self)
+ self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
+ self.connect(
+ self.actionChercheGrpMaille, SIGNAL("triggered()"), self.ChercheGrpMaille
+ )
+
+ # Pour CarmelCND
+ self.actionChercheGrp = QAction(self)
+ self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
+ self.connect(self.actionChercheGrp, SIGNAL("triggered()"), self.ChercheGrp)
+
+ # Pour Aide
+ self.actionCode = QAction(self)
+ self.actionCode.setText(tr("Specificites Maille"))
+ self.connect(self.actionCode, SIGNAL("triggered()"), self.aideCode)
+
+ def connecterSignaux(self):
+ self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
+ self.action_Nouveau.triggered.connect(self.fileNew)
+ self.actionNouvel_Include.triggered.connect(self.newInclude)
+ self.actionOuvrir.triggered.connect(self.fileOpen)
+ self.actionEnregistrer.triggered.connect(self.fileSave)
+ self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
+ self.actionFermer.triggered.connect(self.fileClose)
+ self.actionFermer_tout.triggered.connect(self.fileCloseAll)
+ self.actionQuitter.triggered.connect(self.fileExit)
+
+ self.actionEficas.triggered.connect(self.aidePPal)
+ self.actionVersion.triggered.connect(self.version)
+ self.actionParametres.triggered.connect(self.gestionParam)
+ self.actionCommentaire.triggered.connect(self.ajoutCommentaire)
+
+ self.actionCouper.triggered.connect(self.editCut)
+ self.actionCopier.triggered.connect(self.editCopy)
+ self.actionColler.triggered.connect(self.editPaste)
+ self.actionSupprimer.triggered.connect(self.supprimer)
+ self.actionRechercher.triggered.connect(self.rechercher)
+ self.actionDeplier_replier.triggered.connect(self.handleDeplier)
+
+ self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
+ self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
+ self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
+ self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
+ self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
+ self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
+
+ # Pour Aster
+ self.actionTraduitV9V10 = QAction(self)
+ self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
+ self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
+ self.actionTraduitV10V11 = QAction(self)
+ self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
+ self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
+ self.actionTraduitV11V12 = QAction(self)
+ self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
+ self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
+ self.actionSauveLigne = QAction(self)
+ self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
+
+ # self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
+ self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
+ self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
+ self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
+ self.actionSauveLigne.triggered.connect(self.sauveLigne)
+
+ # Pour Carmel
+ self.actionChercheGrpMaille = QAction(self)
+ self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
+
+ # Pour CarmelCND
+ self.actionChercheGrp = QAction(self)
+ self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
+ self.actionChercheGrp.triggered.connect(self.ChercheGrp)
+
+ # Pour Aide
+ self.actionCode = QAction(self)
+ self.actionCode.setText(tr("Specificites Maille"))
+ self.actionCode.triggered.connect(self.aideCode)
+
+ def handleDeplier(self):
+ self.viewmanager.handleDeplier()
+
+ def handleSortieUQ(self):
+ self.viewmanager.handleSortieUQ()
+
+ def handleExeUQ(self):
+ self.viewmanager.handleExeUQ()
+
+ def handleSauvePourPersalys(self):
+ self.viewmanager.handleSauvePourPersalys()
+
+ def ajoutCommentaire(self):
+ self.viewmanager.ajoutCommentaire()
+
+ def ouvreFichiers(self):
+ # Ouverture des fichiers de commandes donnes sur la ligne de commande
+ cwd = os.getcwd()
+ self.dir = cwd
+ for study in session.d_env.studies:
+ os.chdir(cwd)
+ d = session.getUnit(study, self)
+ self.viewmanager.handleOpen(fichier=study["comm"], units=d)
+
+ def getSource(self, file):
+ # appele par Editeur/session.py
+ import convert
+
+ p = convert.plugins["python"]()
+ p.readfile(file)
+ texte = p.convert("execnoparseur")
+ return texte
+
+ def initPatrons(self):
+ # Mise a jour du menu des fichiers recemment ouverts
+ from Editeur import listePatrons
+
+ if not (self.code in listePatrons.sous_menus):
+ if hasattr(self, "menuPatrons"):
+ self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
+ self.menuPatrons.close()
+ delattr(self, "menuPatrons")
+ return
+ if not hasattr(self, "menuPatrons"):
+ self.menuPatrons = QMenu(self.menubar)
+ self.menuPatrons.setObjectName("menuPatrons")
+ self.menubar.addAction(self.menuPatrons.menuAction())
+ self.menuPatrons.setTitle(tr("Patrons"))
+ else:
+ self.menuPatrons.clear()
+ self.listePatrons = listePatrons.listePatrons(self.code)
+ idx = 0
+ for nomSsMenu in self.listePatrons.liste:
+ ssmenu = self.menuPatrons.addMenu(nomSsMenu)
+ for fichier in self.listePatrons.liste[nomSsMenu]:
+ id = ssmenu.addAction(fichier)
+ self.ficPatrons[id] = fichier
+ self.id.triggered.connect(self.handleOpenPatrons)
+ # self.Patrons.setItemParameter(id,idx)
+ idx = idx + 1
+
+ def initRecents(self):
+ self.recent = []
+ try:
+ rep = os.path.join(os.path.expanduser("~"), ".config/Eficas", self.code)
+ monFichier = rep + "/listefichiers_" + self.code
+ index = 0
+ f = open(monFichier)
+ while index < 9:
+ ligne = f.readline()
+ if ligne != "":
+ l = (ligne.split("\n"))[0]
+ self.recent.append(l)
+ index = index + 1
+ except:
+ pass
+
+ try:
+ f.close()
+ except:
+ pass
+
+ def addToRecentList(self, fn):
+ while fn in self.recent:
+ self.recent.remove(fn)
+ self.recent.insert(0, fn)
+ if len(self.recent) > 9:
+ self.recent = self.recent[:9]
+
+ def addToRecentListQT4(self, fn):
+ """
+ Public slot to add a filename to the list of recently opened files.
+
+ @param fn name of the file to be added
+ """
+ self.recent.removeAll(fn)
+ self.recent.prepend(fn)
+ if len(self.recent) > 9:
+ self.recent = self.recent[:9]
+ index = 0
+ self.sauveRecents()
+
+ def sauveRecents(self):
+ try:
+ rep = self.maConfiguration.rep_user
+ monFichier = rep + "/listefichiers_" + self.code
+ except:
+ return
+ try:
+ f = open(monFichier, "w")
+ if len(self.recent) == 0:
+ return
+ index = 0
+ while index < len(self.recent):
+ ligne = str(self.recent[index]) + "\n"
+ f.write(ligne)
+ index = index + 1
+ except:
+ pass
+ try:
+ f.close()
+ except:
+ pass
+
+ def traductionV11V12(self):
+ from .gereTraduction import traduction
+
+ traduction(self.maConfiguration.repIni, self.viewmanager, "V11V12")
+
+ def traductionV10V11(self):
+ from .gereTraduction import traduction
+
+ traduction(self.maConfiguration.repIni, self.viewmanager, "V10V11")
+
+ def traductionV9V10(self):
+ from .gereTraduction import traduction
+
+ traduction(self.maConfiguration.repIni, self.viewmanager, "V9V10")
+
+ def version(self):
+ from .monVisu import DVisu
+
+ titre = tr("version ")
+ monVisuDialg = DVisu(parent=self, fl=0)
+ monVisuDialg.setWindowTitle(titre)
+ if self.code != None:
+ monVisuDialg.TB.setText(self.VERSION_EFICAS + tr(" pour ") + self.code)
+ else:
+ monVisuDialg.TB.setText(self.VERSION_EFICAS)
+ monVisuDialg.adjustSize()
+ monVisuDialg.show()
+
+ def aidePPal(self):
+ repAide = os.path.dirname(os.path.abspath(__file__))
+ maD = os.path.join(repAide, "..", "Doc")
+ try:
+ indexAide = os.path.join(maD, "index.html")
+ if sys.platform[0:5] == "linux":
+ cmd = "xdg-open " + indexAide
+ else:
+ cmd = "start " + indexAide
+ os.system(cmd)
+ except:
+ QMessageBox.warning(
+ self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
+ )
+
+ def aidePSEN(self):
+ repAide = os.path.dirname(os.path.abspath(__file__))
+ maD = os.path.join(repAide, "..", "Doc")
+ try:
+ indexAide = os.path.join(maD, "index.html")
+ if sys.platform[0:5] == "linux":
+ cmd = "xdg-open " + indexAide
+ else:
+ cmd = "start " + indexAide
+ os.system(cmd)
+ except:
+ QMessageBox.warning(
+ self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
+ )
+
+ def aideCode(self):
+ if self.code == None:
+ return
+ try:
+ # if 1 :
+ if sys.platform[0:5] == "linux":
+ cmd = "xdg-open " + self.fileDoc
+ else:
+ cmd = "start " + self.fileDoc
+ os.system(cmd)
+ except:
+ # else:
+ QMessageBox.warning(
+ self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
+ )
+
+ def optionEditeur(self):
+ try:
+ name = "monOptions_" + self.code
+ except:
+ QMessageBox.critical(
+ self, tr("Parametrage"), tr("Veuillez d abord choisir un code")
+ )
+ return
+ try:
+ # if 1:
+ optionCode = __import__(name)
+ except:
+ # else :
+ QMessageBox.critical(
+ self,
+ tr("Parametrage"),
+ tr("Pas de possibilite de personnalisation de la configuration "),
+ )
+ return
+ monOption = optionCode.Options(
+ parent=self, modal=0, configuration=self.maConfiguration
+ )
+ monOption.show()
+
+ def optionPdf(self):
+ from monOptionsPdf import OptionPdf
+
+ monOption = OptionPdf(parent=self, modal=0, configuration=self.maConfiguration)
+ monOption.show()
+
+ def handleSortieComplete(self):
+ return self.viewmanager.saveCompleteCurrentEditor()
+
+ def handleShowRecentMenu(self):
+ """
+ Private method to set up recent files menu.
+ """
+ self.recentMenu.clear()
+
+ for rp in self.recent:
+ id = self.recentMenu.addAction(rp)
+ self.ficRecents[id] = rp
+ id.triggered.connect(self.handleOpenRecent)
+ self.recentMenu.addSeparator()
+ self.recentMenu.addAction(tr("&Effacer"), self.handleClearRecent)
+
+ def handleOpenPatrons(self):
+ idx = self.sender()
+ fichier = (
+ self.repIni
+ + "/../Editeur/Patrons/"
+ + self.code
+ + "/"
+ + self.ficPatrons[idx]
+ )
+ self.viewmanager.handleOpen(fichier=fichier, patron=1)
+
+ def handleOpenRecent(self):
+ idx = self.sender()
+ fichier = self.ficRecents[idx]
+ self.viewmanager.handleOpen(fichier=fichier, patron=0)
+
+ def handleClearRecent(self):
+ self.recent = []
+ self.sauveRecents()
+
+ def handleRechercherDsCatalogue(self):
+ if not self.viewmanager:
+ return
+ self.viewmanager.handleRechercherDsCatalogue()
+
+ def fileNew(self):
+ try:
+ self.viewmanager.newEditor()
+ except EficasException as exc:
+ msg = str(exc)
+ if msg != "":
+ QMessageBox.warning(self, tr("Erreur"), msg)
+
+ def openProcess(self):
+ ssCode = None
+ code = "PSEN_N1"
+ self.cleanPath()
+ dirCode = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "../..", "ProcessOutputs_Eficas")
+ )
+ sys.path.insert(0, dirCode)
+ self.code = code
+ self.definitCode(code, ssCode)
+ self.multi = True
+ self.demande = False
+ self.initRecents()
+ self.fileOpen()
+
+ def fileOpen(self):
+ try:
+ self.viewmanager.handleOpen()
+ except EficasException as exc:
+ msg = str(exc)
+ if msg != "":
+ QMessageBox.warning(self, tr("Erreur"), msg)
+
+ def sauveLigne(self):
+ return self.viewmanager.sauveLigneCurrentEditor()
+
+ def fileSave(self):
+ return self.viewmanager.saveCurrentEditor()
+
+ def fileSaveAs(self):
+ return self.viewmanager.saveAsCurrentEditor()
+
+ def fileClose(self):
+ self.viewmanager.handleClose(texte="&Fermer")
+
+ def fileCloseAll(self):
+ self.viewmanager.handleCloseAll(texte="&Fermer")
+
+ def fileExit(self):
+ # On peut sortir sur Abort
+ res = self.viewmanager.handleCloseAll()
+ if res != 2:
+ self.close()
+ return res
+
+ def editCopy(self):
+ self.viewmanager.handleEditCopy()
+
+ def editCut(self):
+ self.viewmanager.handleEditCut()
+
+ def editPaste(self):
+ self.viewmanager.handleEditPaste()
+
+ def rechercher(self):
+ self.viewmanager.handleRechercher()
+
+ def run(self):
+ self.viewmanager.run()
+
+ def saveRun(self):
+ self.viewmanager.saveRun()
+
+ def supprimer(self):
+ self.viewmanager.handleSupprimer()
+
+ def jdcFichierSource(self):
+ self.viewmanager.handleViewJdcFichierSource()
+
+ def jdcRapport(self):
+ self.viewmanager.handleViewJdcRapport()
+
+ def jdcRegles(self):
+ self.viewmanager.handleViewJdcRegles()
+
+ def gestionParam(self):
+ self.viewmanager.handleGestionParam()
+
+ def visuJdcPy(self):
+ self.viewmanager.handleViewJdcPy()
+
+ def ouvreArbre(self):
+ self.viewmanager.ouvreArbre()
+
+ def fermeArbre(self):
+ self.viewmanager.fermeArbre()
+
+ def newInclude(self):
+ self.viewmanager.newIncludeEditor()
+
+ def cleanPath(self):
+ for pathCode in self.ListePathCode:
+ try:
+ aEnlever = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), "..", pathCode)
+ )
+ sys.path.remove(aEnlever)
+ except:
+ pass
+ for pathCode in self.listeAEnlever:
+ try:
+ sys.path.remove(aEnlever)
+ except:
+ pass
+
+ def closeEvent(self, event):
+ res = self.fileExit()
+ if res == 2:
+ event.ignore()
+
+ def remplitIconesCommandes(self):
+ if self.maConfiguration.boutonDsMenuBar == False:
+ return
+ if not hasattr(self, "readercata"):
+ return
+ from monLayoutBouton import MonLayoutBouton
+
+ if hasattr(self, "monLayoutBoutonRempli"):
+ return
+ self.monLayoutBoutonRempli = MonLayoutBouton(self)
+
+ def handleAjoutEtape(self, nomEtape):
+ self.viewmanager.handleAjoutEtape(nomEtape)
+
+ def metMenuAJourUtilisateurs(self):
+ self.lesFonctionsUtilisateurs = {}
+ if self.code not in self.mesScripts:
+ return
+ if not hasattr(self.mesScripts[self.code], "dict_menu"):
+ return
+ for monMenu in iter(self.mesScripts[self.code].dict_menu.items()):
+ titre, lesFonctions = monMenu
+ self.menuOptions = self.menubar.addMenu("menuOptions")
+ self.menuOptions.setTitle(tr(titre))
+ for elt in lesFonctions:
+ laFonctionUtilisateur, label, lesArguments = elt
+ action = QAction(self)
+ action.setText(label)
+ # action.triggered.connect(self.appelleFonctionUtilisateur)
+ self.menuOptions.addAction(action)
+ self.lesFonctionsUtilisateurs[action] = (
+ laFonctionUtilisateur,
+ lesArguments,
+ )
+ self.menuOptions.triggered.connect(self.handleFonctionUtilisateur)
+
+ def handleFonctionUtilisateur(self, action):
+ (laFonctionUtilisateur, lesArguments) = self.lesFonctionsUtilisateurs[action]
+ self.viewmanager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments)
+
+
+if __name__ == "__main__":
+ # Modules Eficas
+ rep = os.path.abspath(
+ os.path.join(os.path.dirname(os.path.abspath(__file__), "..", "Adao"))
+ )
+ sys.path.append(rep)
+ from Adao import prefs
+ from Adao import prefs_Adao
+
+ from Editeur import import_code
+ from Editeur import session
+
+ # Analyse des arguments de la ligne de commande
+ options = session.parse(sys.argv)
+ code = options.code
+
+ app = QApplication(sys.argv)
+ # app.setMainWidget(mw) (qt3)
+ Eficas = Appli()
+ Eficas.show()
+
+ # mw.ouvreFichiers()
+ # mw.show()
+
+ res = app.exec_()
+ sys.exit(res)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types
+from Extensions.i18n import tr
+
+from PyQt5.QtCore import Qt
+
+
+# Import des panels
+
+
+class SaisieValeur(object):
+ """
+ Classe contenant les methodes communes aux panels
+ permettant de choisir des valeurs
+ """
+
+ def __init__(self):
+ pass
+
+ 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
+
+ if valeur == None:
+ try:
+ nouvelleValeur = str(self.lineEditVal.text())
+ except UnicodeEncodeError as e:
+ self.editor.afficheInfos("pb d encoding", Qt.red)
+ validite, commentaire = self.politique.recordValeur(None)
+ self.lineEditVal.setText("")
+ self.setValide()
+ self.inSaisieValeur = False
+ return
+ else:
+ try:
+ # la 1 ligne est tres bizarre. remplacee par le 3nd le 01 10 19
+ # if hasattr(self,"lineEditVal"):self.lineEditVal.setText(tr(valeur.nom))
+ if hasattr(self, "lineEditVal"):
+ self.lineEditVal.setText(tr(valeur))
+ except:
+ if hasattr(self, "lineEditVal"):
+ self.lineEditVal.setText(valeur)
+ nouvelleValeur = valeur
+
+ if self.node.item.definition.validators != None:
+ if self.node.item.definition.validators.verifItem(nouvelleValeur) != 1:
+ commentaire = self.node.item.definition.validators.infoErreurItem()
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.inSaisieValeur = False
+ return
+
+ nouvelleValeurFormat = self.politique.getValeurTexte(nouvelleValeur)
+ validite, commentaire = self.politique.recordValeur(nouvelleValeurFormat)
+ if commentaire != "":
+ if validite:
+ self.editor.afficheCommentaire(commentaire)
+ else:
+ self.editor.afficheInfos(commentaire, Qt.red)
+ self.inSaisieValeur = False
+ self.setValide()
+
+ def TraiteLEValeur(self, valeurTraitee=None):
+ # lit la chaine entree dans le line edit
+ # et la tranforme en chaine de valeurs
+ # a traiter. renvoie eventuellement des complexes
+ listeValeurs = []
+ if valeurTraitee == None:
+ valeurBrute = str(self.LEValeur.text())
+ else:
+ valeurBrute = valeurTraitee
+ if valeurBrute == str(""):
+ return listeValeurs, 1
+
+ try:
+ valeur = eval(valeurBrute, {})
+ except:
+ valeur = valeurBrute
+
+ # pour traiter 11.0 - 30.0 pour le CIST
+ # if (valeurTraitee and (type(valeurTraitee) in types.StringTypes) and (self.node.item.waitTxm())) :
+ if (
+ valeurTraitee
+ and isinstance(valeurTraitee, str)
+ and (self.node.item.waitTxm())
+ ):
+ valeur = str(valeurTraitee)
+
+ if type(valeur) in (list, tuple):
+ if self.node.item.waitComplex():
+ indice = 0
+ while indice < len(valeur):
+ v = valeur[indice]
+
+ if v == "RI" or v == "MP":
+ try:
+ t = tuple([v, valeur[indice + 1], valeur[indice + 2]])
+ listeValeurs.append(t)
+ indice = indice + 3
+ except:
+ commentaire = tr(
+ "Veuillez entrer le complexe sous forme aster ou sous forme python"
+ )
+ self.editor.afficheInfos(commentaire)
+ return listeValeurs, 0
+
+ else: # ce n'est pas un tuple a la mode aster
+ listeValeurs.append(v)
+ indice = indice + 1
+
+ else: # on n'attend pas un complexe
+ listeValeurs = valeurBrute.split(",")
+
+ elif type(valeur) == bytes:
+ listeValeurs = valeur.split(",")
+ else:
+ # listeValeurs.append(valeurBrute)
+ listeValeurs.append(valeur)
+
+ return listeValeurs, 1
+
+
+class SaisieSDCO(object):
+ def LESDCOReturnPressed(self):
+ """
+ Lit le nom donne par l'utilisateur au concept de type CO qui doit être
+ la valeur du MCS courant et stocke cette valeur
+ """
+ self.editor.initModif()
+ anc_val = self.node.item.getValeur()
+ if anc_val != None:
+ # il faut egalement propager la destruction de l'ancien concept
+ self.node.item.deleteValeurCo(valeur=anc_val)
+ # et on force le recalcul des concepts de sortie de l'etape
+ self.node.item.object.etape.getType_produit(force=1)
+ # et le recalcul du contexte
+ self.node.item.object.etape.parent.resetContext()
+ nomConcept = str(self.LESDCO.text())
+ if nomConcept == "":
+ return
+
+ test, commentaire = self.node.item.setValeurCo(nomConcept)
+ if test:
+ commentaire = tr("Valeur du mot-clef enregistree")
+ self.node.updateNodeValid()
+ else:
+ cr = self.node.item.getCr()
+ commentaire = tr("Valeur du mot-clef non autorisee :") + cr.getMessFatal()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+# permet de lancer EFICAS en n affichant rien
+try:
+ from builtins import object
+except:
+ pass
+
+
+class appliEficasSSIhm(object):
+ def __init__(self, code):
+ self.VERSION_EFICAS = "Sans Ihm"
+ self.code = code
+ self.ssCode = None
+ self.salome = None
+ self.top = None
+ self.indice = 0
+ self.dict_reels = {}
+ self.listeAEnlever = []
+
+ name = "prefs_" + self.code
+ try:
+ prefsCode = __import__(name)
+ except:
+ name = "prefs_" + self.code.upper()
+ self.code = self.code.upper()
+ prefsCode = __import__(name)
+
+ self.repIni = prefsCode.repIni
+ self.format_fichier = "python" # par defaut
+
+ nameConf = "configuration_" + self.code
+ configuration = __import__(nameConf)
+ self.CONFIGURATION = configuration.make_config(self, prefsCode.repIni)
+
+
+class QWParentSSIhm(object):
+ def __init__(self, code, version_code):
+ self.ihm = "QT"
+ self.code = code
+ self.version_code = version_code
+ self.format_fichier = "python" # par defaut
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+
+try:
+ from builtins import object
+except:
+ pass
+
+from PyQt5.QtWidgets import QAction, QMenu, QMessageBox
+
+from Extensions.i18n import tr
+import types
+
+
+# ---------------------------#
+class PopUpMenuRacine(object):
+ # ---------------------------#
+
+ def createPopUpMenu(self):
+ # print "createPopUpMenu"
+ self.ParamApres = QAction(tr("Parametre"), self.tree)
+ self.ParamApres.triggered.connect(self.addParametersApres)
+ self.ParamApres.setStatusTip(tr("Insere un parametre"))
+ self.menu = QMenu(self.tree)
+ self.menu.addAction(self.ParamApres)
+ self.menu.setStyleSheet("background:rgb(220,220,220); ")
+
+ def addParametersApres(self):
+ item = self.tree.currentItem()
+ item.addParameters(True)
+
+
+# ---------------------------#
+class PopUpMenuNodeMinimal(object):
+ # ---------------------------#
+
+ def createPopUpMenu(self):
+ # print ("createPopUpMenu")
+ # self.appliEficas.salome=True
+ self.createActions()
+ self.menu = QMenu(self.tree)
+ # self.menu.setStyleSheet("background:rgb(235,235,235); QMenu::item:selected { background-color: red; }")
+ # ne fonctionne pas --> la ligne de commentaire devient rouge
+ self.menu.setStyleSheet("background:rgb(220,220,220); ")
+ # items du menu
+ self.menu.addAction(self.Supprime)
+ if hasattr(self.appliEficas, "mesScripts"):
+ if self.editor.code in self.editor.appliEficas.mesScripts:
+ self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
+ self.editor.code
+ ].dict_commandes
+ if (
+ self.tree.currentItem().item.getNom()
+ in self.dict_commandes_mesScripts
+ ):
+ self.ajoutScript()
+
+ def ajoutScript(self):
+ # cochon mais je n arrive pas a faire mieux avec le mecanisme de plugin
+ # a revoir avec un menu et un connect sur le triggered sur le menu ?
+ if hasattr(self.appliEficas, "mesScripts"):
+ if self.editor.code in self.editor.appliEficas.mesScripts:
+ self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
+ self.editor.code
+ ].dict_commandes
+ else:
+ return
+
+ from Extensions import jdc_include
+
+ if isinstance(self.item.jdc, jdc_include.JDC_INCLUDE):
+ return
+
+ listeCommandes = self.dict_commandes_mesScripts[
+ self.tree.currentItem().item.getNom()
+ ]
+ if type(listeCommandes) != tuple:
+ listeCommandes = (listeCommandes,)
+ numero = 0
+ for commande in listeCommandes:
+ conditionSalome = commande[3]
+ if self.appliEficas.salome == 0 and conditionSalome == True:
+ return
+ label = commande[1]
+ tip = commande[5]
+ self.action = QAction(label, self.tree)
+ self.action.setStatusTip(tip)
+ if numero == 4:
+ self.action.triggered.connect(self.appelleFonction4)
+ if numero == 3:
+ self.action.triggered.connect(self.appelleFonction3)
+ numero = 4
+ if numero == 2:
+ self.action.triggered.connect(self.appelleFonction2)
+ numero = 3
+ if numero == 1:
+ self.action.triggered.connect(self.appelleFonction1)
+ numero = 2
+ if numero == 0:
+ self.action.triggered.connect(self.appelleFonction0)
+ numero = 1
+ self.menu.addAction(self.action)
+
+ def appelleFonction0(self):
+ self.appelleFonction(0)
+
+ def appelleFonction1(self):
+ self.appelleFonction(1)
+
+ def appelleFonction2(self):
+ self.appelleFonction(2)
+
+ def appelleFonction3(self):
+ self.appelleFonction(3)
+
+ def appelleFonction4(self):
+ self.appelleFonction(4)
+
+ def appelleFonction(self, numero, nodeTraite=None):
+ if nodeTraite == None:
+ nodeTraite = self.tree.currentItem()
+ nomCmd = nodeTraite.item.getNom()
+ if hasattr(self.appliEficas, "mesScripts"):
+ if self.editor.code in self.editor.appliEficas.mesScripts:
+ self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
+ self.editor.code
+ ].dict_commandes
+ else:
+ return
+ listeCommandes = self.dict_commandes_mesScripts[nomCmd]
+ commande = listeCommandes[numero]
+ conditionValid = commande[4]
+
+ if nodeTraite.item.isValid() == 0 and conditionValid == True:
+ QMessageBox.warning(
+ None,
+ tr("item invalide"),
+ tr("l item doit etre valide"),
+ )
+ return
+ fonction = commande[0]
+ listenomparam = commande[2]
+ listeparam = []
+ for p in listenomparam:
+ if hasattr(nodeTraite, p):
+ listeparam.append(getattr(nodeTraite, p))
+ if p == "self":
+ listeparam.append(self)
+
+ try:
+ res, commentaire = fonction(listeparam)
+ if not res:
+ QMessageBox.warning(
+ None,
+ tr("echec de la fonction"),
+ tr(commentaire),
+ )
+ return
+ except:
+ pass
+
+ def createActions(self):
+ self.CommApres = QAction(tr("apres"), self.tree)
+ self.CommApres.triggered.connect(self.addCommApres)
+ self.CommApres.setStatusTip(tr("Insere un commentaire apres la commande "))
+ self.CommAvant = QAction(tr("avant"), self.tree)
+ self.CommAvant.triggered.connect(self.addCommAvant)
+ self.CommAvant.setStatusTip(tr("Insere un commentaire avant la commande "))
+
+ self.ParamApres = QAction(tr("apres"), self.tree)
+ self.ParamApres.triggered.connect(self.addParametersApres)
+ self.ParamApres.setStatusTip(tr("Insere un parametre apres la commande "))
+ self.ParamAvant = QAction(tr("avant"), self.tree)
+ self.ParamAvant.triggered.connect(self.addParametersAvant)
+ self.ParamAvant.setStatusTip(tr("Insere un parametre avant la commande "))
+
+ self.Supprime = QAction(tr("Supprimer"), self.tree)
+ self.Supprime.triggered.connect(self.supprimeNoeud)
+ self.Supprime.setStatusTip(tr("supprime le mot clef "))
+ self.Documentation = QAction(tr("Documentation"), self.tree)
+ self.Documentation.triggered.connect(self.viewDoc)
+ self.Documentation.setStatusTip(tr("documentation sur la commande "))
+
+ def supprimeNoeud(self):
+ item = self.tree.currentItem()
+ item.delete()
+
+ def viewDoc(self):
+ self.node = self.tree.currentItem()
+ cle_doc = self.node.item.getDocu()
+ if cle_doc == None:
+ QMessageBox.information(
+ self.editor,
+ tr("Documentation Vide"),
+ tr("Aucune documentation n'est associee a ce noeud"),
+ )
+ return
+ commande = self.editor.appliEficas.maConfiguration.exec_acrobat
+ try:
+ f = open(commande, "rb")
+ except:
+ texte = tr("impossible de trouver la commande ") + commande
+ QMessageBox.information(self.editor, tr("Lecteur PDF"), texte)
+ return
+ import os
+
+ if cle_doc.startswith("http:"):
+ fichier = cle_doc
+ else:
+ fichier = os.path.abspath(
+ os.path.join(self.editor.maConfiguration.path_doc, cle_doc)
+ )
+ try:
+ f = open(fichier, "rb")
+ except:
+ texte = tr("impossible d'ouvrir ") + fichier
+ QMessageBox.information(self.editor, tr("Documentation Vide"), texte)
+ return
+
+ if os.name == "nt":
+ os.spawnv(
+ os.P_NOWAIT,
+ commande,
+ (
+ commande,
+ fichier,
+ ),
+ )
+ elif os.name == "posix":
+ script = "#!/usr/bin/sh \n%s %s&" % (commande, fichier)
+ pid = os.system(script)
+
+ def addParametersApres(self):
+ item = self.tree.currentItem()
+ item.addParameters(True)
+
+ def addParametersAvant(self):
+ item = self.tree.currentItem()
+ item.addParameters(False)
+
+ def addCommApres(self):
+ item = self.tree.currentItem()
+ item.addComment(True)
+
+ def addCommAvant(self):
+ item = self.tree.currentItem()
+ item.addComment(False)
+
+ def deplieCeNiveau(self):
+ item = self.tree.currentItem()
+ item.deplieCeNiveau()
+
+
+# --------------------------------------------#
+class PopUpMenuNodePartiel(PopUpMenuNodeMinimal):
+ # ---------------------------------------------#
+ def createPopUpMenu(self):
+ PopUpMenuNodeMinimal.createPopUpMenu(self)
+ # ss-menu Comment:
+ self.commentMenu = self.menu.addMenu(tr("Commentaire"))
+ self.commentMenu.addAction(self.CommApres)
+ self.commentMenu.addAction(self.CommAvant)
+ # ss-menu Parameters:
+ self.paramMenu = self.menu.addMenu(tr("Parametre"))
+ self.paramMenu.addAction(self.ParamApres)
+ self.paramMenu.addAction(self.ParamAvant)
+ self.menu.addAction(self.Documentation)
+ self.menu.removeAction(self.Supprime)
+ self.menu.addAction(self.Supprime)
+
+
+# -----------------------------------------#
+class PopUpMenuNode(PopUpMenuNodePartiel):
+ # -----------------------------------------#
+ def createPopUpMenu(self):
+ PopUpMenuNodePartiel.createPopUpMenu(self)
+ self.Commente = QAction(tr("ce noeud"), self.tree)
+ self.Commente.triggered.connect(self.commenter)
+ self.Commente.setStatusTip(tr("commente le noeud "))
+ self.commentMenu.addAction(self.Commente)
+ self.menu.removeAction(self.Supprime)
+ self.menu.addAction(self.Supprime)
+
+ def commenter(self):
+ item = self.tree.currentItem()
+ item.commentIt()
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+
+
+try:
+ from builtins import str
+ from builtins import object
+except:
+ pass
+
+import os
+from Extensions.i18n import tr
+from PyQt5.QtWidgets import QFileDialog, QMessageBox
+from PyQt5.QtCore import QFileInfo
+
+DictExtensions = {"MAP": ".map"}
+
+
+class MyViewManager(object):
+ def __init__(self, appliEficas):
+ self.appliEficas = appliEficas
+ self.tabWidgets = []
+ self.mesIndexes = {}
+ self.appliEficas = appliEficas
+ self.editors = []
+ self.dictEditors = {}
+ self.untitledCount = 0
+ self.doubles = {}
+
+ self.myQtab = self.appliEficas.myQtab
+
+ self.myQtab.currentChanged.connect(self.indexChanged)
+ self.myQtab.tabCloseRequested.connect(self.closeTab)
+
+ def indexChanged(self):
+ index = self.myQtab.currentIndex()
+ if index in self.dictEditors:
+ editor = self.dictEditors[index]
+ if editor.jdc != None:
+ CONTEXT.unsetCurrentJdC()
+ CONTEXT.setCurrentJdC(editor.jdc)
+ self.appliEficas.maConfiguration = editor.maConfiguration
+ self.appliEficas.code = editor.maConfiguration.code
+ self.appliEficas.setWindowTitle(editor.titre)
+ self.appliEficas.construitMenu()
+
+ def handleOpen(self, fichier=None, patron=0, units=None):
+ result = None
+ if fichier is None:
+ if self.appliEficas.demande == True:
+ self.appliEficas.definitCode(None, None)
+ if self.appliEficas.code == None:
+ return
+
+ if self.appliEficas.code in DictExtensions:
+ chaine = "JDC (*" + DictExtensions[self.appliEficas.code] + ");;"
+ extensions = tr(chaine + "All Files (*)")
+ elif self.appliEficas.code == "TELEMAC":
+ extensions = tr("CAS (*.cas);;All Files (*)")
+ else:
+ extensions = tr("Fichiers JDC (*.comm);;" "Tous les Fichiers (*)")
+
+ fichier = QFileDialog.getOpenFileName(
+ self.appliEficas,
+ tr("Ouvrir Fichier"),
+ self.appliEficas.maConfiguration.savedir,
+ extensions,
+ )
+ fichier = fichier[0]
+ if len(fichier) == 0:
+ return None
+ fichier = os.path.abspath(fichier)
+ ulfile = os.path.abspath(fichier)
+ self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
+ self.appliEficas.addToRecentList(fichier)
+ maPage = self.getEditor(fichier, units=units)
+ if maPage:
+ result = maPage
+ if maPage:
+ self.myQtab.setTabText(
+ self.myQtab.indexOf(maPage), os.path.basename(fichier)
+ )
+ return result
+
+ def closeTab(self, indexAFermer):
+ self.handleClose(indexAFermer=indexAFermer)
+
+ def handleClose(self, doitSauverRecent=1, texte=tr("&Quitter"), indexAFermer=None):
+ if doitSauverRecent:
+ self.appliEficas.sauveRecents()
+ if indexAFermer == None:
+ index = self.myQtab.currentIndex()
+ else:
+ index = indexAFermer
+ if index < 0:
+ return
+ res = self.checkDirty(self.dictEditors[index], texte)
+ if res == 2:
+ return 2 # l utilisateur a annule
+ idx = index
+ while idx < len(self.dictEditors) - 1:
+ self.dictEditors[idx] = self.dictEditors[idx + 1]
+ idx = idx + 1
+ del self.dictEditors[len(self.dictEditors) - 1]
+ try:
+ del self.doubles[self.dictEditors[index]]
+ except:
+ pass
+ self.myQtab.removeTab(index)
+ return res
+
+ def run(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.run()
+
+ def saveRun(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.saveRun()
+
+ def handleCloseAll(self, texte=tr("Quitter")):
+ res = 0
+ self.appliEficas.sauveRecents()
+ while len(self.dictEditors) > 0:
+ self.myQtab.setCurrentIndex(0)
+ res = self.handleClose(0, texte)
+ if res == 2:
+ return res # l utilsateur a annule
+ return res
+
+ def handleRechercher(self):
+ # print "passage dans handleRechercher"
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleRechercher()
+
+ def handleRechercherDsCatalogue(self):
+ # print "passage dans handleRechercher"
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleRechercherDsCatalogue()
+
+ def handleDeplier(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleDeplier()
+
+ def handleEditCopy(self):
+ # print "passage dans handleEditCopy"
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleEditCopy()
+
+ def handleEditCut(self):
+ # print "passage dans handleEditCut"
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleEditCut()
+
+ def handleEditPaste(self):
+ # print "passage dans handleEditPaste"
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleEditPaste()
+
+ def handleSupprimer(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleSupprimer()
+
+ def handleAjoutEtape(self, nomEtape):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleAjoutEtape(nomEtape)
+
+ def newEditor(self, include=0):
+ if self.appliEficas.demande == True:
+ self.appliEficas.definitCode(None, None)
+ if self.appliEficas.code == None:
+ return
+ maPage = self.getEditor(include=include)
+
+ def newIncludeEditor(self):
+ self.newEditor(include=1)
+
+ def handleViewJdcFichierSource(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ self.dictEditors[index].viewJdcSource()
+
+ def ouvreArbre(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ self.dictEditors[index].ouvreArbre()
+
+ def fermeArbre(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ self.dictEditors[index].fermeArbre()
+
+ def ajoutCommentaire(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.ajoutCommentaire()
+
+ def handleViewJdcRegles(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ self.dictEditors[index].viewJdcRegles()
+
+ def handleGestionParam(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ QMessageBox.warning(
+ self.appliEficas,
+ tr("Creation Parametre indisponible"),
+ tr("les parametres sont lies a un jeu de donnees"),
+ )
+ return
+ self.dictEditors[index].gestionParam()
+
+ def handleViewJdcRapport(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ self.dictEditors[index].viewJdcRapport()
+
+ def handleViewJdcPy(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ self.dictEditors[index].viewJdcPy()
+
+ def saveCurrentEditor(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ if editor in self.doubles:
+ QMessageBox.warning(
+ None,
+ tr("Fichier Duplique"),
+ tr("Le fichier ne sera pas sauvegarde."),
+ )
+ return
+ ok, newName = editor.saveFile()
+ if ok:
+ fileName = os.path.basename(newName)
+ self.myQtab.setTabText(index, fileName)
+ return ok
+
+ def handleSortieUQ(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ ok, newName = editor.saveUQFile()
+ return ok
+
+ def handleSauvePourPersalys(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ ok = editor.sauvePourPersalys()
+ return ok
+
+ def handleExeUQ(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ ok = editor.exeUQ()
+ return ok
+
+ def saveCompleteCurrentEditor(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ ok, newName = editor.saveCompleteFile()
+ return ok
+
+ def sauveLigneCurrentEditor(self):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ if editor in self.doubles:
+ QMessageBox.warning(
+ None,
+ tr("Fichier Duplique"),
+ tr("Le fichier ne sera pas sauvegarde."),
+ )
+ return
+ ok, newName = editor.sauveLigneFile()
+ if ok:
+ fileName = os.path.basename(newName)
+ self.myQtab.setTabText(index, fileName)
+ return ok
+
+ def saveAsCurrentEditor(self):
+ index = self.myQtab.currentIndex()
+ editor = self.dictEditors[index]
+ oldName = editor.fichier
+ ok, newName = editor.saveFileAs()
+ if ok:
+ fileName = os.path.basename(newName)
+ self.myQtab.setTabText(index, fileName)
+ if editor in self.doubles:
+ if oldName != newName:
+ del self.doubles[editor]
+ return ok
+
+ def displayJDC(self, jdc, fn=None):
+ """
+ Public slot to display a file in an editor.
+ @param fn name of file to be opened
+ # insert filename into list of recently opened files
+ """
+ titre = None
+ if fn != None:
+ titre = fn.split("/")[-1]
+ editor = self.getEditor(fichier=fn, jdc=jdc, include=1)
+ self.appliEficas.addToRecentList(editor.getFileName())
+
+ def getEditor(self, fichier=None, jdc=None, units=None, include=0):
+ newWin = 0
+ double = None
+ indexEditor = 0
+ for indexEditor in self.dictEditors:
+ editor = self.dictEditors[indexEditor]
+ if self.samePath(fichier, editor.getFileName()):
+ msgBox = QMessageBox()
+ msgBox.setWindowTitle(tr("Fichier"))
+ msgBox.setText(tr("Le fichier <b>%s</b> est deja ouvert", str(fichier)))
+ msgBox.addButton(tr("&Duplication"), 0)
+ msgBox.addButton(tr("&Abandonner"), 1)
+ abort = msgBox.exec_()
+ if abort:
+ break
+ double = editor
+ else:
+ # PNPN A reflechir avec le GUIPath
+ if self.appliEficas.code == "5C":
+ from InterfaceQT5C.editor5C import JDCEditor5C
+
+ editor = JDCEditor5C(
+ self.appliEficas,
+ fichier,
+ jdc,
+ self.myQtab,
+ units=units,
+ include=include,
+ )
+ else:
+ from InterfaceGUI.QT5.editor import JDCEditor
+ editor = JDCEditor(
+ self.appliEficas,
+ fichier,
+ jdc,
+ self.myQtab,
+ units=units,
+ include=include,
+ )
+ if double != None:
+ self.doubles[editor] = double
+ if editor.jdc: # le fichier est bien un jdc
+ self.editors.append(editor)
+ newWin = 1
+ else:
+ editor.closeIt()
+
+ if newWin:
+ self.addView(editor, fichier)
+ elif editor.jdc:
+ self.myQtab.setCurrentIndex(indexEditor)
+
+ index = self.myQtab.currentIndex()
+ if index != -1:
+ self.dictEditors[index] = editor
+ return editor
+
+ def addView(self, win, fichier=None):
+ # PNPNPNPN --> a affiner
+ if fichier is None:
+ self.untitledCount += 1
+ self.myQtab.addTab(
+ win, tr("Fichier non encore nomme") + str(self.untitledCount)
+ )
+ # self.myQtab.addTab(win, str(self.appliEficas.code))
+ else:
+ liste = fichier.split("/")
+ txt = liste[-1]
+ if not QFileInfo(fichier).isWritable():
+ txt = "%s (ro)" % txt
+ self.myQtab.addTab(win, txt)
+ self.myQtab.setCurrentWidget(win)
+ self.currentEditor = win
+ win.setFocus()
+
+ def getOpenStartDir(self):
+ # PN --> Les Preferences
+ try:
+ userDir = os.path.expanduser("~/Eficas_install/")
+ return userDir
+ except:
+ return ""
+
+ def samePath(self, f1, f2):
+ """
+ compare two paths.
+ """
+ if f1 is None or f2 is None:
+ return 0
+ if os.path.normcase(os.path.normpath(f1)) == os.path.normcase(
+ os.path.normpath(f2)
+ ):
+ return 1
+ return 0
+
+ def checkDirty(self, editor, texte):
+ """
+ Private method to check dirty status and open a message window.
+
+ @param editor editor window to check
+ @return flag indicating successful reset of the dirty flag (boolean)
+ """
+ res = 1
+ if (editor.modified) and (editor in self.doubles):
+ msgBox = QMessageBox(None)
+ msgBox.setWindowTitle(tr("Fichier Duplique"))
+ msgBox.setText(tr("Le fichier ne sera pas sauvegarde."))
+ msgBox.addButton(texte, 0)
+ msgBox.addButton(tr("&Annuler"), 1)
+ res = msgBox.exec_()
+ if res == 0:
+ return 1
+ return 2
+ if editor.modified:
+ fn = editor.getFileName()
+ if fn is None:
+ fn = tr("Noname")
+ msgBox = QMessageBox(None)
+ msgBox.setWindowTitle(tr("Fichier Modifie"))
+ msgBox.setText(tr("Le fichier ne sera pas sauvegarde."))
+ msgBox.addButton(tr("&Sauvegarder"), 1)
+ msgBox.addButton(tr("&Quitter sans sauvegarder"), 0)
+ msgBox.addButton(tr("&Annuler"), 2)
+ res = msgBox.exec_()
+ if res == 2:
+ return res
+ if res == 0 and self.appliEficas.maConfiguration.afficheUQ:
+ if fn is None:
+ ret, fichier = editor.saveUQFile(self)
+ else:
+ ret, fichier = editor.saveUQFile(self, fn)
+ return 2
+ if res == 0:
+ (ok, newName) = editor.saveFile()
+ if ok:
+ fileName = os.path.basename(newName)
+ index = self.myQtab.currentIndex()
+ self.myQtab.setTabText(index, fileName)
+ return ok
+ return res
+
+ def handleAjoutGroup(self, listeGroup):
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ editor.handleAjoutGroup(listeGroup)
+
+ def handleFonctionUtilisateur(self, laFonctionUtilisateur, lesArguments):
+ # Peut-etre a blinder un peu plus sur le nb d argument
+ index = self.myQtab.currentIndex()
+ if index < 0:
+ return
+ editor = self.dictEditors[index]
+ if editor.getEtapeCourante() == None:
+ QMessageBox.information(
+ self.appliEficas,
+ tr("Selectionner une etape"),
+ tr(
+ "Le texte ne peut pas etre insere dans un fichier vide,\nCreer un materiau vide ou une zone vide et inserer le catalogue apres"
+ ),
+ )
+ return
+
+ listeParam = []
+ for p in lesArguments:
+ if hasattr(editor, p):
+ listeParam.append(getattr(editor, p))
+ if p == "editor":
+ listeParam.append(editor)
+ if p == "etapeCourante":
+ listeParam.append(editor.getEtapeCourante())
+ laFonctionUtilisateur(*listeParam)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 package contient les fonctionnalites necessaires
+ pour l'editeur graphique QT
+"""
--- /dev/null
+editorSsIhm.py: from acquiertGroupes import getGroupes
+qtEficasSsIhm.py:from getVersion import getEficasVersion
+qtEficasSsIhm.py: from Accas import eficasSalome
+readercataXML.py:from readercata import ReaderCataCommun
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import types, sys, os, re
+import subprocess
+import traceback
+
+# Modules Eficas
+
+import convert, generator
+from Editeur import session
+from Editeur import comploader
+from Editeur import Objecttreeitem
+
+DictExtensions = {"MAP": ".map", "TELEMAC": ".cas"}
+debug = False
+
+
+class JDCEditorSsIhm:
+ # ------------------- #
+ """
+ Editeur de jdc
+ """
+
+ # ---------------------------------------------
+ # Methodes Communes ou appelees depuis avec Ihm
+ # ---------------------------------------------
+
+ def __init__(self, appliEficas, fichier=None, jdc=None, units=None, include=0):
+ # -----------------------------------------------------------------------------------#
+ # paticularisee avec Ihm
+
+ if debug:
+ print("dans le init de JDCEditorSsIhm")
+ self.appliEficas = appliEficas
+ self.fichier = fichier
+ self.fichierComplet = fichier
+ if fichier != None:
+ self.extensionFichier = os.path.splitext(fichier)[1]
+ else:
+ self.extensionFichier = None
+ self.jdc = jdc
+ self.first = True
+ self.jdc_item = None
+ self.dicoNouveauxMC = {}
+ self.dicoNouveauxFact = {}
+ self.dict_reels = {}
+ self.liste_simp_reel = []
+
+ if self.appliEficas != None:
+ self.salome = self.appliEficas.salome
+ else:
+ self.salome = 0
+
+ # ces attributs sont mis a jour par definitCode appelee par newEditor
+ self.code = self.appliEficas.maConfiguration.code
+ self.maConfiguration = self.appliEficas.maConfiguration
+
+ if (
+ not hasattr(self.appliEficas, "readercata")
+ or self.appliEficas.readercata.demandeCatalogue == True
+ or self.appliEficas.multi == True
+ ):
+ if self.maConfiguration.typeDeCata == "XML":
+ from InterfaceGUI import readercataXML as readercata
+ else:
+ from InterfaceGUI import readercata
+ self.readercata = readercata.ReaderCata(self, self.appliEficas)
+ self.appliEficas.readercata = self.readercata
+ self.appliEficas.code = self.code
+ else:
+ self.readercata = self.appliEficas.readercata
+ if self.readercata.fichierCata == None:
+ return # Sortie Salome
+ if self.readercata.cata == None:
+ return # Sortie Salome
+ if self.readercata.cata == 0:
+ return # Sortie Salome
+ self.titre = self.readercata.titre
+
+ self.formatFichierOut = self.appliEficas.formatFichierOut
+ self.formatFichierIn = self.appliEficas.formatFichierIn
+
+ # if self.appliEficas.maConfiguration.dumpXSD==True : self.appliEficas.dumpXsd()
+ self.dict_reels = {}
+ self.liste_simp_reel = []
+ self.dicoNouveauxMC = {}
+ self.dicoNouveauxFact = {}
+
+ try:
+ self.maConfiguration.generator_module
+ _module = __import__(self.maConfiguration.generator_module)
+ info = _module.entryPoint()
+ generator.plugins.addEntryPoint(info)
+ except:
+ pass
+
+ try:
+ self.maConfiguration.convert_module
+ # print self.maConfiguration.convert_module
+ _module = __import__(self.maConfiguration.convert_module)
+ info = _module.entryPoint()
+ convert.plugins.addEntryPoint(info)
+ except:
+ pass
+
+ self.maConfiguration.mesGenerators = generator
+ self.maConfiguration.mesconvertisseurs = convert
+ try:
+ self.XMLGenerator = generator.plugins["xml"]()
+ except:
+ self.XMLGenerator = None
+ try:
+ self.pythonGenerator = generator.plugins["python"]()
+ except:
+ self.pythonGenerator = None
+
+ if self.formatFichierOut in generator.plugins.keys():
+ self.generator = generator.plugins[self.formatFichierOut]()
+
+ self.fileInfo = None
+ self.lastModified = 0
+
+ self.modified = False
+ self.isReadOnly = False
+
+ # ------- construction du jdc --------------
+
+ self.nouveau = 0
+ if self.fichier is not None: # fichier jdc fourni
+ if jdc == None:
+ # print ('PNPN : chgt try en if')
+ try:
+ # if 1 :
+ self.jdc = self.readFile(self.fichier)
+ except:
+ print("mauvaise lecture du fichier")
+ if self.salome:
+ try:
+ self.appliEficas.addJdcInSalome(self.fichier)
+ except:
+ print("mauvais enregistrement dans Salome")
+ else:
+ self.jdc = jdc
+
+ if self.jdc is not None and units is not None:
+ self.jdc.recorded_units = units
+ self.jdc.old_recorded_units = units
+
+ else:
+ if not self.jdc: # nouveau jdc
+ if not include:
+ self.jdc = self._newJDC(units=units)
+ else:
+ self.jdc = self._newJDCInclude(units=units)
+ self.nouveau = 1
+
+ if self.jdc:
+ self.jdc.editor = self
+ self.jdc.lang = self.appliEficas.langue
+ self.jdc.aReafficher = False
+ txt_exception = None
+ if not jdc:
+ if self.extensionFichier == ".xml":
+ if self.appliEficas.maConfiguration.withXSD:
+ self.jdc.analyseXML()
+ else:
+ print("run MDM with -x option (MDM for XML)")
+ exit()
+ else:
+ self.jdc.analyse()
+ if hasattr(self, "monConvert") and hasattr(
+ self.monConvert, "traitementApresLoad"
+ ):
+ self.monConvert.traitementApresLoad(self.jdc)
+ txt_exception = self.jdc.cr.getMessException()
+ if txt_exception:
+ self.jdc = None
+ self.informe("pb chargement jdc", txt_exception)
+
+ # -------------------------------#
+ def readFile(self, fn):
+ # --------------------------------#
+ """
+ Public slot to read the text from a file.
+ @param fn filename to read from (string or QString)
+ """
+
+ # charge un JDC
+ # paticularisee avec Ihm
+
+ fn = str(fn)
+ jdcName = os.path.basename(fn)
+
+ # Il faut convertir le contenu du fichier en fonction du format
+ formatIn = self.appliEficas.formatFichierIn
+ if self.extensionFichier == ".xml" and self.appliEficas.maConfiguration.withXSD:
+ formatIn = "xml"
+ if formatIn in convert.plugins:
+ # Le convertisseur existe on l'utilise
+ monConvert = convert.plugins[formatIn]()
+ monConvert.readfile(fn)
+
+ if monConvert.text == "":
+ self.nouveau = 1
+ # print ('PNPN --> CIST a faire')
+
+ if formatIn != "xml":
+ pareil, texteNew = self.verifieChecksum(monConvert.text)
+ if not pareil:
+ self.informe(
+ ("fichier modifie"),
+ ("Attention! fichier change hors EFICAS"),
+ False,
+ )
+ monConvert.text = texteNew
+ memeVersion, texteNew = self.verifieVersionCataDuJDC(monConvert.text)
+ if memeVersion == 0:
+ texteNew = self.traduitCatalogue(texteNew)
+ monConvert.text = texteNew
+ text = monConvert.convert("exec", self.appliEficas)
+ if not monConvert.cr.estvide():
+ self.afficheInfos("Erreur a la conversion", "red")
+ else:
+ text = monConvert.text
+ else:
+ self.afficheInfos("Type de fichier non reconnu", "red")
+ self.informe(
+ "Type de fichier non reconnu",
+ "EFICAS ne sait pas ouvrir le type de fichier "
+ + self.appliEficas.formatFichierIn,
+ )
+ return None
+
+ CONTEXT.unsetCurrentStep()
+
+ # jdc=self.readercata.cata[0].JdC(procedure=text,
+ # le jdc n est pas charge
+ if not (hasattr(self.readercata, "cata_ordonne_dico")):
+ return
+ jdc = self.readercata.cata.JdC(
+ procedure=text,
+ appliEficas=self.appliEficas,
+ cata=self.readercata.cata,
+ cata_ord_dico=self.readercata.cata_ordonne_dico,
+ nom=jdcName,
+ rep_mat=self.maConfiguration.rep_mat,
+ )
+ self.modified = False
+ self.monConvert = monConvert
+ return jdc
+
+ # --------------------------------#
+ def _newJDC(self, units=None):
+ # --------------------------------#
+ """
+ Initialise un nouveau JDC vierge
+ """
+ self.modified = 1
+ CONTEXT.unsetCurrentStep()
+
+ texte = ""
+ if self.code == "CARMELCND":
+ texte = self._newJDCCND()
+ if self.code == "ZCRACKS":
+ texte = self._newZCRACKS()
+ if self.code == "PSEN":
+ texte = self._newPSEN()
+ if self.code == "PSEN_N1":
+ texte = self._newPSEN_N1()
+
+ if hasattr(self.readercata.cata, "TEXTE_NEW_JDC"):
+ texte = self.readercata.cata.TEXTE_NEW_JDC
+
+ jdc = self.readercata.cata.JdC(
+ procedure=texte,
+ appliEficas=self.appliEficas,
+ cata=self.readercata.cata,
+ cata_ord_dico=self.readercata.cata_ordonne_dico,
+ rep_mat=self.maConfiguration.rep_mat,
+ )
+
+ jdc.lang = self.appliEficas.langue
+ if units is not None:
+ jdc.recorded_units = units
+ jdc.old_recorded_units = units
+ # chgt le 15/10/19
+ # Attention positionne contexte ?
+ # est ce qu on ne doit pas changer le format en Accas si on vient d accas ?
+ jdc.editor = self
+ return jdc
+
+ # --------------------------------#
+ def _newJDCInclude(self, units=None):
+ # --------------------------------#
+ """
+ Initialise un nouveau JDC vierge
+ """
+ import Extensions.jdc_include
+
+ JdC_aux = Extensions.jdc_include.JdC_include
+ CONTEXT.unsetCurrentStep()
+
+ # jaux=self.readercata.cata[0].JdC( procedure="",
+ jaux = self.readercata.cata.JdC(
+ procedure="",
+ appliEficas=self.appliEficas,
+ cata=self.readercata.cata,
+ cata_ord_dico=self.readercata.cata_ordonne_dico,
+ rep_mat=self.maConfiguration.rep_mat,
+ )
+ jaux.editor = self
+ jaux.analyse()
+
+ J = JdC_aux(
+ procedure="",
+ appliEficas=self.appliEficas,
+ cata=self.readercata.cata,
+ cata_ord_dico=self.readercata.cata_ordonne_dico,
+ jdc_pere=jaux,
+ rep_mat=self.maConfiguration.rep_mat,
+ )
+ J.editor = self
+ J.analyse()
+ if units is not None:
+ J.recorded_units = units
+ J.old_recorded_units = units
+ return J
+
+ # -----------------------#
+ def getSource(self, file):
+ # -----------------------#
+
+ # Il faut convertir le contenu du fichier en fonction du format
+ if self.formatFichierIn in convert.plugins:
+ # Le convertisseur existe on l'utilise
+ p = convert.plugins[self.formatFichierIn]()
+ p.readfile(file)
+ text = p.convert("execnoparseur")
+ if not p.cr.estvide():
+ self.afficheInfos("Erreur a la conversion", "red")
+ return text
+ else:
+ # Il n'existe pas c'est une erreur
+ self.afficheInfos("Type de fichier non reconnu", "red")
+ self.informe(
+ "Type de fichier non reconnu",
+ "EFICAS ne sait pas ouvrir le type de fichier "
+ + self.appliEficas.formatFichierIn,
+ )
+ return None
+
+ # ----------------------------------------------#
+ def __generateTempFilename(self, prefix, suffix):
+ # ----------------------------------------------#
+ import tempfile
+
+ (fd, filename) = tempfile.mkstemp(prefix=prefix, suffix=suffix)
+ os.close(fd)
+ return filename
+
+ # -----------------------#
+ def generDico(self):
+ # -----------------------#
+ if "dico" in generator.plugins:
+ self.generator = generator.plugins["dico"]()
+ texte_jdc = self.generator.gener(self.jdc)
+ return texte_jdc
+
+ # -----------------------#
+ def generDicoPython(self):
+ # -----------------------#
+ if "dico" in generator.plugins:
+ self.generator = generator.plugins["dico"]()
+ dico = self.generator.generDico(self.jdc)
+ return dico
+
+ # -----------------------#
+ def viewJdcSource(self):
+ # -----------------------#
+ if self.fichier == None:
+ return
+ if os.path.isfile(self.fichier):
+ f = open(self.fichier, "r")
+ texteSource = f.read()
+ f.close()
+ self._viewText(texteSource, "JDC_SOURCE")
+ else:
+ self._viewText("file doesn't exist", "JDC_SOURCE")
+
+ # -----------------------#
+ def viewJdcPy(self):
+ # -----------------------#
+ strSource = str(self.getTextJDC(self.formatFichierOut))
+ self._viewText(strSource, "JDC_RESULTAT")
+
+ # -----------------------#
+ def viewJdcRapport(self):
+ # -----------------------#
+ # on ajoute les regles
+ strRapport = str(self.jdc.report())
+ self._viewText(strRapport, "JDC_RAPPORT")
+
+ # -----------------------#
+ def viewJdcRegles(self):
+ # -----------------------#
+ # on ajoute les regles
+ texte_global, test_global = self.jdc.verifRegles()
+ self._viewText(texte_global, "JDC_REGLES")
+
+ # -----------------------#
+ def getJdcRapport(self):
+ # -----------------------#
+ # on ajoute les regles
+ strRapport = str(self.jdc.report())
+ return strRapport
+
+ # ---------------------#
+ def getFileName(self):
+ # ---------------------#
+ return self.fichier
+
+ # -------------------#
+ def initModif(self):
+ # -------------------#
+ """
+ Met l'attribut modified a 'o' : utilise par Eficas pour savoir
+ si un JDC doit etre sauvegarde avant destruction ou non
+ """
+ self.modified = True
+
+ # --------------------------------------------------#
+ def writeFile(self, fn, txt=None, formatLigne="beautifie"):
+ # --------------------------------------------------#
+ """
+ Public slot to write the text to a file.
+
+ @param fn filename to write to string
+ @return flag indicating success
+ """
+
+ fn = str(fn)
+
+ if txt == None:
+ txt = self.getTextJDC(self.formatFichierOut, formatLigne=formatLigne)
+ eol = "\n"
+ if len(txt) >= len(eol):
+ if txt[-len(eol) :] != eol:
+ txt += eol
+ else:
+ txt += eol
+ txt = self.ajoutVersionCataDsJDC(txt)
+ if self.code != "PSEN" and self.code != "PSEN_N1":
+ checksum = self.getChecksum(txt)
+ else:
+ checksum = ""
+ txt = txt + checksum
+ if self.code == "TELEMAC":
+ return 1
+ try:
+ f = open(fn, "w")
+ f.write(txt)
+ f.close()
+ return 1
+ except IOError as why:
+ print(
+ "Sauvegarde du Fichier",
+ "Le fichier" + str(fn) + "n a pas pu etre sauvegarde :",
+ str(why),
+ )
+ self.afficheInfos(
+ "Le fichier" + str(fn) + "n a pas pu etre sauvegarde ", "red"
+ )
+ return 0
+
+ # -----------------------------------------------------------#
+ def getTextJDC(self, format=None, pourRun=0, formatLigne="beautifie"):
+ # -----------------------------------------------------------#
+ if self.code == "MAP" and not (format in generator.plugins):
+ format = "MAP"
+ if format == None:
+ format = self.formatFichierOut
+ if format in generator.plugins:
+ # Le generateur existe on l'utilise
+ self.generator = generator.plugins[format]()
+ try:
+ jdc_formate = self.generator.gener(
+ self.jdc,
+ format=formatLigne,
+ config=self.appliEficas.maConfiguration,
+ appliEficas=self.appliEficas,
+ )
+ if pourRun:
+ jdc_formate = self.generator.textePourRun
+ if self.code == "TELEMAC":
+ jdc_formate = self.generator.texteDico
+ except ValueError as e:
+ self.informe("Erreur a la generation", str(e), "red")
+ return
+
+ if not self.generator.cr.estvide():
+ self.informe(
+ "Erreur a la generation",
+ "EFICAS ne sait pas convertir ce JDC",
+ "red",
+ )
+ return ""
+ else:
+ return jdc_formate
+ else:
+ # Il n'existe pas c'est une erreur
+ self.informe("Format inconnu", self.format + " non reconnu")
+ return ""
+
+ # ------------------------------#
+ def verifieChecksum(self, text):
+ # ------------------------------#
+ # Attention : souci sous Windows
+ #
+ indexDeb = text.find("#CHECKSUM:")
+ if indexDeb < 0:
+ return 1, text
+ indexFin = text.find(":FIN CHECKSUM")
+ checkAvant = text[indexDeb : indexFin + 13]
+ textJDC = text[0:indexDeb] + text[indexFin + 13 : -1]
+ if self.code != "PSEN" and self.code != "PSEN_N1":
+ checksum = self.getChecksum(textJDC)
+ pareil = checkAvant == checksum
+ else:
+ pareil = 1
+ return pareil, textJDC
+
+ # ---------------------------#
+ def getChecksum(self, texte):
+ # ---------------------------#
+ try:
+ import hashlib
+
+ newtexte = texte.replace('"', '\\"')
+ hash_checksum = hashlib.md5()
+ hash_checksum.update(newtexte.encode("utf-8"))
+ checksum = hash_checksum.hexdigest()
+ ligne = "#CHECKSUM:" + checksum + ":FIN CHECKSUM"
+ except:
+ try:
+ newtexte = texte.replace('"', '\\"')
+ commande = 'echo "' + newtexte + '"|md5sum'
+ a = os.popen(commande)
+ checksum = a.read()
+ a.close()
+ except:
+ checksum = "Fichier trop long \n"
+ ligne = "#CHECKSUM:" + checksum[0:-1] + ":FIN CHECKSUM"
+ return ligne
+
+ # ----------------------#
+ def getDico(self):
+ # ---------------------#
+ if "dicoImbrique" in generator.plugins:
+ self.generator = generator.plugins["dicoImbrique"]()
+ # print (self.generator)
+ jdc_formate = self.generator.gener(self.jdc)
+ dico = self.generator.Dico
+ return dico
+ else:
+ self.afficheInfos(
+ tr("Format %s non reconnu", "Dictionnaire Imbrique"), "red"
+ )
+ return ""
+
+ # -----------------------------------------#
+ def chercheGroupes(self):
+ # -----------------------------------------#
+ listeMA, listeNO = self.getTextJDC("GroupMA")
+ return listeMA, listeNO
+
+ # -----------------------------------------#
+ def chercheDico(self):
+ # -----------------------------------------#
+ dicoCourant = {}
+ format = self.appliEficas.formatFichierOut
+ if format in generator.plugins:
+ # Le generateur existe on l'utilise
+ self.generator = generator.plugins[format]()
+ jdc_formate = self.generator.gener(
+ self.jdc, format="beautifie", config=self.appliEficas.maConfiguration
+ )
+ dicoCourant = self.generator.dico
+ return dicoCourant
+
+ # -----------------------------------------------------------------#
+ def saveFileLegerAs(self, fileName=None):
+ # -----------------------------------------------------------------#
+ if fileName != None:
+ self.fichier = fileName
+ return self.saveFileLeger(fileName)
+ return self.saveFileLeger()
+
+ # -----------------------------------------------------------------#
+ def saveFileComplet(self, fichier=None, formatLigne="beautifie"):
+ # -----------------------------------------------------------------#
+ fn = fichier
+ self.generator = generator.plugins[self.format]()
+ print(self.generator)
+ if hasattr(self.generator, "writeComplet"):
+ self.generator.writeComplet(
+ fichier,
+ self.jdc,
+ config=self.appliEficas.maConfiguration,
+ appliEficas=self.appliEficas,
+ )
+
+ # -----------------------------------#
+ def saveUQFile(self, fichier=None):
+ # ------------------------------------#
+ if fichier == None:
+ self.informe("Sauvegarde", "nom de fichier obligatoire pour sauvegarde")
+ return 0, None
+ self.fichier = fichier
+ self.generator = generator.plugins["UQ"]()
+ ret, comm = self.generator.creeNomsFichiers(fichier)
+ # print (ret,comm)
+ if not ret:
+ self.informe("Sauvegarde UQ", self.generator.commentaire)
+ return ret, None
+ ret = self.generator.gener(self.jdc)
+ if not ret:
+ self.informe("Sauvegarde UQ", self.generator.commentaire)
+ return ret, None
+ if ret == 2:
+ self.informe("Sauvegarde UQ", self.generator.commentaire, critique=False)
+ self.modified = False
+ return 1, fichier
+ ret = self.generator.writeUQ(fichier)
+ if not ret:
+ self.informe("Sauvegarde UQ", self.generator.commentaire)
+ else:
+ self.informe(
+ "Sauvegarde UQ",
+ "Sauvegardes des fichiers .comm, _det.comm effectuées.\n"
+ "Création des fichiers _UQ.py et _@det.comm.",
+ critique=False,
+ )
+ self.modified = False
+ return ret, fichier
+
+ # ------------------------------------------#
+ def sauvePourPersalys(self, fichier=None):
+ # -------------------------------------------#
+ if fichier == None:
+ self.informe(
+ "Sauvegarde Etude Persalys",
+ "nom de fichier obligatoire pour sauvegarde",
+ )
+ return 0, None
+ self.generator = generator.plugins["UQ"]()
+ ret, comm = self.generator.creeNomsFichiers(fichier)
+ if not ret:
+ self.informe("Sauvegarde Etude Persalys", self.generator.commentaire)
+ fichierPersalys = self.generator.fichierUQExe
+ ret = self.generator.gener(self.jdc)
+ if not ret:
+ self.informe("Sauvegarde Etude Persalys", self.generator.commentaire)
+ return ret, None
+ txt = self.generator.txtScriptPersalys.split(
+ "################ CUT THE FILE HERE IF YOU WANT TO IMPORT IT IN THE SALOME PERSALYS MODULE ################"
+ )[0]
+ try:
+ with open(fichierPersalys, "w") as f:
+ f.write(txt)
+ f.close()
+ self.informe(
+ "Sauvegarde Etude Persalys",
+ "Le fichier " + str(fichierPersalys) + " a été sauvegardé",
+ critique=False,
+ )
+ return 1, " "
+ except IOError as why:
+ self.informe(
+ "Sauvegarde Etude Persalys",
+ "Le fichier " + str(fichierPersalys) + " n a pas pu etre sauvegardé",
+ )
+ return 0, str(why)
+
+ # -----------------------------------------------#
+ def exeUQ(self, fichier=None, path=None):
+ # ------------------------------------------------#
+ self.informe("Pas prevu pour l instant")
+ return ret, None
+
+ # ---------------------------------------------
+ # Methodes Surchargees par avecIhm
+ # ---------------------------------------------
+
+ # --------------------------------#
+ def ajoutCommentaire(self):
+ # --------------------------------#
+ print("pas programme sans Ihm")
+ print("prevenir la maintenance du besoin")
+
+ # --------------------------------------#
+ def informe(self, titre, txt, critique=True):
+ # --------------------------------------#
+ # methode differenre avec et sans ihm
+ if critique:
+ print("!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ print(titre)
+ print(txt)
+ if critique:
+ print("!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+
+ # --------------------------------------#
+ def afficheInfos(self, txt, couleur=None):
+ # --------------------------------------#
+ # methode differenre avec et sans ihm
+ print(txt)
+
+ # -----------------------------------------------------------------------#
+ def _viewText(self, txt, caption="FILE_VIEWER", largeur=1200, hauteur=600):
+ # --------------------------------------------------------------------#
+ print("_____________________________")
+ print(txt)
+ print("_____________________________")
+
+ # -----------------------------------------------------------------#
+ def saveFile(self, fichier, formatLigne="beautifie"):
+ # -----------------------------------------------------------------#
+ """
+ Public slot to save the text to a file.
+
+ @param path directory to save the file in (string or QString)
+ @return tuple of two values (boolean, string) giving a success indicator and
+ the name of the saved file
+ """
+
+ self.fichierOut = fichier
+ if not (self.writeFile(fichier, formatLigne=formatLigne)):
+ return (0, None)
+ if self.jdc.cata.modeleMetier and self.jdc.isValid():
+ if self.generator != self.XMLGenerator:
+ self.XMLGenerator.gener(self.jdc)
+ self.XMLGenerator.writeDefault(fichier)
+ return (1, self.fichier)
+ if self.jdc.isValid() and hasattr(self.generator, "writeDefault"):
+ self.generator.writeDefault(fichier)
+ elif self.code == "TELEMAC" and hasattr(self.generator, "writeDefault"):
+ self.generator.writeDefault(fichier)
+ self.modified = 0
+ return (1, self.fichier)
+
+ #
+
+ # ----------------------------------------------#
+ def sauveLigneFile(self):
+ # ----------------------------------------------#
+ self.modified = 1
+ return self.saveFile(formatLigne="Ligne")
+
+ # -----------------------------------#
+ def updateJdc(self, itemApres, texte):
+ # ------------------------------------#
+ # ajoute une etape de JdC a partir d un texte
+ monItem = itemApres
+ etape = monItem.item.object
+ CONTEXT.setCurrentStep(etape)
+ etape.buildIncludeInclude(texte)
+ self.tree.racine.buildChildren()
+
+ # -----------------------------------#
+ def updateJdcEtape(self, itemApres, texte):
+ # ------------------------------------#
+ # ajoute une etape de JdC a partir d un texte
+ monItem = itemApres
+ etape = monItem.item.object
+ CONTEXT.set_current_step(etape)
+ try:
+ ok = etape.build_includeEtape(texte)
+ except:
+ ok = 0
+ if not ok:
+ QMessageBox.information(
+ self, tr("Import texte"), tr("Impossible d importer le texte")
+ )
+ self.tree.racine.build_children()
+ return ok
+
+ # -------------------------------------#
+ def deleteEtape(self, etape):
+ # -------------------------------------#
+ # dans le JDC
+ self.jdc.suppentite(etape)
+
+ # -------------------------------------#
+ def deleteMC(self, etape, MCFils, listeAvant=()):
+ # -------------------------------------#
+ # dans le JDC
+ ouChercher = etape
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if monMC != None:
+ ouChercher.suppentite(monMC)
+ ouChercher.state = "changed"
+ ouChercher.isvalid()
+
+ # --------------------------------------------------------#
+ def ajoutMC(self, etape, MCFils, valeurs, listeAvant=()):
+ # --------------------------------------------------------#
+ # dans le JDC
+ debug = False
+ if debug:
+ print("ajoutMC", etape, MCFils, valeurs, listeAvant)
+ ouChercher = etape
+ if debug:
+ print(ouChercher)
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if monMC == None:
+ monMC = ouChercher.addEntite(MCFils)
+ monMC.valeur = valeurs
+ monMC.val = valeurs
+ monMC.state = "changed"
+ monMC.isvalid()
+ return 1
+
+ # --------------------------------------------------------#
+ def ajoutMCinMCFactUnique(self, etape, MCFils, valeurs, listeAvant=()):
+ # Attention si +sieursMCFACT
+ # --------------------------------------------------------#
+ # dans le JDC
+ debug = False
+ if debug:
+ print("ajoutMC", etape, MCFils, valeurs, listeAvant)
+ ouChercher = etape
+ if debug:
+ print(ouChercher)
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ # Attention si +sieursMCFACT
+ ouChercher = ouChercher[0]
+ if debug:
+ print(ouChercher)
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if monMC == None:
+ monMC = ouChercher.addEntite(MCFils)
+ monMC.valeur = valeurs
+ monMC.val = valeurs
+ monMC.state = "changed"
+ monMC.isValid()
+ return 1
+
+ # ----------------------------------------------#
+ def ajoutMCFact(self, etape, MCFils, listeAvant=()):
+ # ----------------------------------------------#
+ # dans le JDC
+ ouChercher = etape
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ monMC = etape.getChild(ouChercher, restreint="oui")
+ if monMC == None:
+ monMC = ouChercher.addEntite(MCFils)
+ monMC.isvalid()
+
+ # -----------------------------------------------------------------#
+ def setValeurMCSimpInEtape(self, etape, listeAvant, valeur):
+ # -----------------------------------------------------------------#
+ # pour VP
+ monObj = etape
+ for mot in listeAvant:
+ monObj = monObj.getChild(mot, restreint="oui")
+ if monObj == None:
+ return False
+ if monObj == None:
+ return False
+ if monObj.valeur != valeur:
+ # PNPN le setValeur fait des bugs --> pourquoi
+ # monObj.setValeur(valeur)
+ monObj.valeur = valeur
+ monObj.isValid()
+ return True
+
+ # -------------------------------------------------#
+ def getValeur(self, nomEtape, MCFils, listeAvant=()):
+ # -------------------------------------------------#
+ # dans le JDC
+
+ debug = 0
+ ouChercher = None
+ for e in self.jdc.etapes:
+ if e.nom == nomEtape:
+ ouChercher = e
+ break
+ if debug:
+ print("etape trouvee", ouChercher)
+ if ouChercher == None:
+ return None
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ if debug:
+ print(mot, ouChercher)
+ if ouChercher == None:
+ return None
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if debug:
+ print("monMC", monMC)
+ if monMC == None:
+ return None
+ return monMC.valeur
+
+ # -------------------------------------------------#
+ def getMCDsEtape(self, etape, MCFils, listeAvant=()):
+ # -------------------------------------------------#
+ # dans le JDC
+
+ if etape == None:
+ return None
+ ouChercher = etape
+ debug = 0
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ if debug:
+ print(mot, ouChercher)
+ if ouChercher == None:
+ return None
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if debug:
+ print("monMC", monMC)
+ return monMC
+
+ # -----------------------------------------------------------#
+ def setValeur(self, nomEtape, MCFils, valeur, listeAvant=()):
+ # --------------------------------------------------------#
+ # dans le JDC
+
+ ouChercher = None
+ for e in self.jdc.etapes:
+ if e.nom == nomEtape:
+ ouChercher = e
+ break
+ if ouChercher == None:
+ return None
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ # print (mot, ouChercher)
+ if ouChercher == None:
+ return None
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ monMC.set_valeur(valeur)
+ monMC.isvalid()
+
+ # -----------------------------------------------------------#
+ def changeIntoMC(self, etape, MCFils, valeurs, listeAvant=()):
+ # -----------------------------------------------------------#
+ # dans le JDC
+ ouChercher = etape
+ if isinstance(etape, str):
+ ouChercher = None
+ for e in self.jdc.etapes:
+ if e.nom == etape:
+ ouChercher = e
+ break
+ if ouChercher == None:
+ return
+
+ for mot in listeAvant:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ if ouChercher == None:
+ return
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if monMC == None:
+ monMC = ouChercher.addEntite(MCFils)
+
+ monMC.definition.into = valeurs
+ from Noyau.N_VALIDATOR import IntoProtocol
+
+ monMC.definition.intoProto = IntoProtocol(
+ "into",
+ into=monMC.definition.into,
+ val_min=monMC.definition.val_min,
+ val_max=monMC.definition.val_max,
+ )
+ monMC.state = "changed"
+ monMC.isvalid()
+
+ # -------------------------------------------------------------------#
+ def reCalculeValiditeMCApresChgtInto(self, nomEtape, MCFils, listeAvant=()):
+ # -------------------------------------------------------------------#
+ # dans le JDC
+ for e in self.jdc.etapes:
+ if e.nom == nomEtape:
+ ouChercher = e
+ break
+
+ for mot in listeAvant:
+ try:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ # Le mot clef n est pas la
+ except:
+ return 0
+ try:
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ # Le mot clef n est pas la
+ except:
+ return 0
+ if monMC == None:
+ return 0
+
+ if hasattr(monMC.definition, "into"):
+ if type(monMC.definition.into) == types.FunctionType:
+ maListeDeValeur = monMC.definition.into()
+ else:
+ maListeDeValeur = monMC.definition.into
+ else:
+ return 0
+
+ monMC.state = "changed"
+ return 1
+
+ def dumpXsd(self, avecEltAbstrait=False):
+ # -----------------------------------------#
+ if not self.readercata.cata:
+ return
+ texteXSD = self.readercata.cata.JdC.dumpXsd(avecEltAbstrait)
+ return texteXSD
+
+ def dumpStructure(self):
+ # ----------------------------#
+ texteStructure = self.readercata.cata.JdC.dumpStructure()
+ return texteStructure
+
+ def dumpGitStringFormat(self):
+ # ----------------------------#
+ texteGitStringFormat = self.readercata.cata.JdC.dumpGitStringFormat()
+ return texteGitStringFormat
+
+ # -------------------------------------#
+ def changeDefautDefMC(self, nomEtape, listeMC, valeurs):
+ # -------------------------------------#
+ # dans le MDD
+
+ # if isinstance (etape, str):
+ # for e in self.jdc.etapes:
+ # if e.nom == etape : etape=e; break
+ # if etape == None : return
+ definitionEtape = getattr(self.jdc.cata, nomEtape)
+ # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
+ ouChercher = definitionEtape
+ if len(listeMC) > 1:
+ for mc in listeMC[0:-1]:
+ mcfact = ouChercher.entites[mc]
+ ouChercher = mcfact
+
+ mcAccas = ouChercher.entites[listeMC[-1]]
+ mcAccas.defaut = valeurs
+ return 1
+
+ # ------------------------------------------------#
+ def changeIntoDefMC(self, etape, listeMC, valeurs, rechercheParNom=False):
+ # ------------------------------------------------#
+ # dans le MDD
+ # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
+ # definitionEtape=getattr(self.jdc.cata,nomEtape)
+ print("changeIntoDefMC ", etape, listeMC, valeurs)
+ # ouChercher = getattr(self.jdc.cata, etape.nom)
+ if rechercheParNom:
+ ouChercher = getattr(self.jdc.cata, etape)
+ else:
+ ouChercher = getattr(self.jdc.cata, etape.nom)
+
+ # if len(listeMC) > 1 :
+ # for mc in listeMC[0:-1]:
+ # mcfact=ouChercher.entites[mc]
+ # ouChercher=mcfact
+ # mcAccas=ouChercher.entites[listeMC[-1]]
+
+ for mc in listeMC:
+ mcAccas = ouChercher.entites[mc]
+ ouChercher = mcAccas
+ if ouChercher == None:
+ return 0
+
+ if hasattr(mcAccas, "into"):
+ oldValeurs = mcAccas.into
+ else:
+ oldValeurs = None
+
+ if oldValeurs == valeurs:
+ return 1
+ mcAccas.into = valeurs
+ from Noyau.N_VALIDATOR import IntoProtocol
+
+ mcAccas.intoProto = IntoProtocol(
+ "into", into=valeurs, val_min=mcAccas.val_min, val_max=mcAccas.val_max
+ )
+ return 1
+
+ # -------------------------------------------------------------#
+ def deleteDefinitionMC(self, etape, listeAvant, nomDuMC):
+ # -------------------------------------------------------------#
+ # dans le MDD
+ # print 'in deleteDefinitionMC', etape,listeAvant,nomDuMC
+ if isinstance(etape, str):
+ for e in self.jdc.etapes:
+ if e.nom == etape:
+ etape = e
+ break
+ if etape == None:
+ return
+ # definitionEtape=getattr(self.jdc.cata[0],etape)
+ definitionEtape = getattr(self.jdc.cata, etape)
+ ouChercher = definitionEtape
+ for k in listeAvant:
+ ouChercher = ouChercher.entites[k]
+ MCADetruire = ouChercher.entites[nomDuMC]
+ ouChercher.ordreMC.remove(nomDuMC)
+ print("remove de ", nomDuMC)
+ del ouChercher.entites[nomDuMC]
+ del self.dicoNouveauxMC[nomDuMC]
+
+ # -------------------------------------------------------------#
+ def ajoutDefinitionMC(self, nomEtape, listeAvant, nomDuMC, typ, **args):
+ # -------------------------------------------------------------#
+ # dans le MDD
+ # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
+ definitionEtape = getattr(self.jdc.cata, nomEtape)
+ ouChercher = definitionEtape
+ for k in listeAvant:
+ ouChercher = ouChercher.entites[k]
+ from Accas import A_SIMP
+
+ Nouveau = A_SIMP.SIMP(typ, **args)
+ Nouveau.pere = ouChercher
+ Nouveau.nom = nomDuMC
+ # Nouveau.ordreMC=[]
+ ouChercher.entites[nomDuMC] = Nouveau
+ ouChercher.ordreMC.append(nomDuMC)
+ # print ('ajout de ', nomDuMC)
+ # traceback.print_stack()
+ # ajout CIST sauvegarde
+ if nomDuMC in self.dicoNouveauxMC:
+ del self.dicoNouveauxMC[nomDuMC]
+ self.dicoNouveauxMC[nomDuMC] = (
+ "ajoutDefinitionMC",
+ nomEtape,
+ listeAvant,
+ nomDuMC,
+ typ,
+ args,
+ )
+ # print self.dicoNouveauxMC
+
+ # ---------------------------------------------------------------------#
+ def ajoutDefinitionMCFact(self, nomEtape, listeAvant, nomDuMC, listeMC, **args):
+ # ---------------------------------------------------------------------#
+ # dans le MDD
+ print("ajoutDefinitionMCFact", nomDuMC)
+ # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
+ definitionEtape = getattr(self.jdc.cata, nomEtape)
+ ouChercher = definitionEtape
+ for k in listeAvant:
+ ouChercher = ouChercher.entites[k]
+ from Accas import A_SIMP
+
+ for mc in listeMC:
+ nomMC = mc[0]
+ typMC = mc[1]
+ argsMC = mc[2]
+ nouveauMC = A_SIMP.SIMP(typMC, **argsMC)
+ nouveauMC.nom = nomMC
+ args[nomMC] = nouveauMC
+ from Accas import A_FACT
+
+ nouveauFact = A_FACT.FACT(**args)
+ nouveauFact.pere = ouChercher
+ nouveauFact.nom = nomDuMC
+ from Editeur.autre_analyse_cata import traite_entite
+
+ traite_entite(nouveauFact, [])
+ ouChercher.entites[nomDuMC] = nouveauFact
+ ouChercher.ordreMC.append(nomDuMC)
+ self.dicoNouveauxFact[nomDuMC] = (
+ "ajoutDefinitionMC",
+ nomEtape,
+ listeAvant,
+ nomDuMC,
+ listeMC,
+ args,
+ )
+ # print self.dicoNouveauxMC
+
+ # ----------------------------------------------------#
+
+ # ----------------------------------------------------#
+ def changeIntoMCandSet(self, etape, listeMC, into, valeurs):
+ # ----------------------------------------------------#
+ # dans le MDD et le JDC
+
+ self.changeIntoDefMC(etape, listeMC, into)
+
+ if isinstance(etape, str):
+ for e in self.jdc.etapes:
+ if e.nom == etape:
+ etape = e
+ break
+ if etape == None:
+ return
+
+ ouChercher = etape
+ for mot in listeMC[:-1]:
+ ouChercher = ouChercher.getChild(mot, restreint="oui")
+ if ouChercher == None:
+ return
+ MCFils = listeMC[-1]
+ monMC = ouChercher.getChild(MCFils, restreint="oui")
+ if monMC == None:
+ monMC = etape.addEntite(MCFils)
+
+ monMC.definition.into = into
+ monMC.valeur = valeurs
+ monMC.val = valeurs
+ monMC.state = "changed"
+ monMC.isvalid()
+
+ # -------------------------------------#
+ def ajoutVersionCataDsJDC(self, txt):
+ # -------------------------------------#
+ # if not hasattr(self.readercata.cata[0],'VERSION_CATALOGUE'): return txt
+ if not hasattr(self.readercata.cata, "VERSION_CATALOGUE"):
+ return txt
+ ligneVersion = (
+ "#VERSION_CATALOGUE:"
+ + self.readercata.cata.VERSION_CATALOGUE
+ + ":FIN VERSION_CATALOGUE\n"
+ )
+ texte = txt + ligneVersion
+ return texte
+
+ # -------------------------------------#
+ def verifieVersionCataDuJDC(self, text):
+ # -------------------------------------#
+ memeVersion = False
+ indexDeb = text.find("#VERSION_CATALOGUE:")
+ indexFin = text.find(":FIN VERSION_CATALOGUE")
+ if indexDeb < 0:
+ self.versionCataDuJDC = "sans"
+ textJDC = text
+ else:
+ self.versionCataDuJDC = text[indexDeb + 19 : indexFin]
+ textJDC = text[0:indexDeb] + text[indexFin + 23 : -1]
+
+ self.versionCata = "sans"
+ if hasattr(self.readercata.cata, "VERSION_CATALOGUE"):
+ self.versionCata = self.readercata.cata.VERSION_CATALOGUE
+
+ if self.versionCata == self.versionCataDuJDC:
+ memeVersion = True
+ return memeVersion, textJDC
+
+ # -------------------------------#
+ def traduitCatalogue(self, texte):
+ # -------------------------------#
+ nomTraducteur = (
+ "traduit"
+ + self.readercata.code
+ + self.versionCataDuJDC
+ + "To"
+ + self.versionCata
+ )
+ sys.path.append(
+ os.path.abspath(
+ os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), "../Traducteur"
+ )
+ )
+ )
+ try:
+ traducteur = __import__(nomTraducteur)
+ monTraducteur = traducteur.MonTraducteur(texte)
+ nouveauTexte = monTraducteur.traduit()
+ return nouveauTexte
+ except:
+ return texte
+
+ # Methodes a resorber
+ # il faut mettre a jour les catalogues avec
+ # TEXTE_NEW_JDC
+ #
+
+ # ---------------------------#
+ def _new_CF(self):
+ # ---------------------------#
+ texte = "CONDUITE_FORCEE();"
+ return texte
+
+ # ---------------------------#
+ def _newPSEN(self):
+ # ---------------------------#
+ texte = "DIRECTORY() ; PSSE_PARAMETERS() ; SIMULATION() ; sansnom=DISTRIBUTION() ; sansnom=DISTRIBUTION() ; CORRELATION() ;"
+ # texte=""
+ return texte
+
+ # ---------------------------#
+ def _newPSEN_N1(self):
+ # ---------------------------#
+ texte = "CASE_SELECTION();N_PROCESSING_OPTIONS();CONTINGENCY_OPTIONS();CONTINGENCY_SELECTION();\nCONTINGENCY_PROCESSING(); "
+ # texte="CONTINGENCY_SELECTION();\nCONTINGENCY_PROCESSING(); "
+ return texte
+
+ # ---------------------------#
+ def _newZCRACKS(self):
+ # ---------------------------#
+ texte = "MAILLAGES();REMESHING();"
+ return texte
+
+ # ---------------------------#
+ def _newJDCCND(self):
+ # ---------------------------#
+ extensions = tr("Fichiers Med (*.med);;" "Tous les Fichiers (*)")
+
+ # if self.salome == 0 :
+ QMessageBox.information(
+ self, tr("Fichier Med"), tr("Veuillez selectionner un fichier Med")
+ )
+ QSfichier = QFileDialog.getOpenFileName(
+ self.appliEficas, caption="Fichier Med", filter=extensions
+ )
+ QSfichier = QSfichier[0]
+ self.fichierMED = QSfichier
+ from Extension.acquiertGroupes import getGroupes
+
+ erreur, self.listeGroupes, self.nomMaillage, self.dicoCoord = getGroupes(
+ self.fichierMED
+ )
+ if erreur != "":
+ print("a traiter")
+ texteComm = (
+ "COMMENTAIRE(u'Cree - fichier : "
+ + self.fichierMED
+ + " - Nom Maillage : "
+ + self.nomMaillage
+ + "');\nPARAMETRES()\n"
+ )
+ texteSources = ""
+ texteCond = ""
+ texteNoCond = ""
+ texteVcut = ""
+ texteZs = ""
+ for groupe in self.listeGroupes:
+ if groupe[0:8] == "CURRENT_":
+ texteSources += groupe[8:] + "=SOURCE("
+ texteSources += "VecteurDirecteur=(1.0,2.0,3.0,),);\n"
+ if groupe[0:5] == "COND_":
+ texteCond += groupe[5:] + "=CONDUCTEUR();\n"
+ if groupe[0:7] == "NOCOND_":
+ texteNoCond += groupe[7:] + "=NOCOND();\n"
+ if groupe[0:5] == "VCUT_":
+ texteVcut += "V_" + groupe[5:] + "=VCUT();\n"
+ if groupe[0:3] == "ZS_":
+ texteZs += groupe[3:] + "=ZS();\n"
+ texte = texteComm + texteSources + texteCond + texteNoCond + texteVcut + texteZs
+ self.newTexteCND = texte
+ self.modified = 1
+ return texte
+
+ # ------------------#
+ def insertInDB(self):
+ # -------------------#
+ debug = True
+ if debug:
+ print("insertInDB ", self.jdc, self.readercata.cata)
+ texte = self.jdc.prepareInsertInDB()
+ if debug:
+ print(texte)
+
+ def dumpStringDataBase(self, nomDataBaseACreer=None):
+ # --------------------------------------------------#
+ texteStringDataBase = self.readercata.cata.JdC.dumpStringDataBase(
+ nomDataBaseACreer
+ )
+ return texteStringDataBase
+
+
+if __name__ == "__main__":
+ print("a faire")
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+# Management of EFICAS version numbering.
+# A version has at least major and minor numbers, for easier comparison.
+
+__version = {"major": 9, "minor": 11}
+
+
+def getEficasVersion():
+ """
+ Return the EFICAS current version number.
+ """
+ return "%s.%s" % (getMajor(), getMinor())
+
+def getSalomeVersion():
+ """
+ Return the SALOME version number to which current EFICAS version is related.
+ """
+ return getEficasVersion()
+
+def getMajor():
+ return __version["major"]
+
+def getMinor():
+ return __version["minor"]
+
+def getBaseVersion():
+ """
+ Returns [ major, minor ] array of integers.
+ """
+ return [getMajor(), getMinor()]
+
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2024 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
+#
+import os, sys
+
+from Extensions.eficas_exception import EficasException
+from Extensions import param2
+from InterfaceGUI.getVersion import getEficasVersion
+from viewManagerSsIhm import MyViewManagerSsIhm
+from Editeur import session
+
+
+class AppliSsIhm:
+ """
+ Class implementing the main user interface.
+ """
+
+ def __init__(
+ self,
+ code=None,
+ salome=1,
+ parent=None,
+ multi=False,
+ langue="fr",
+ ssIhm=True,
+ labelCode=None,
+ genereXSD=False,
+ versionCode=None,
+ ssCode=None,
+ fichierCata=None,
+ GUIDir=None,
+ ):
+ """
+ Constructor
+ """
+ version = getEficasVersion()
+ self.VERSION_EFICAS = "Eficas QT5 Salome " + version
+ self.labelCode = labelCode
+ if not GUIDir:
+ self.GUIDir = "InterfaceQT4"
+ else:
+ self.GUIDir = GUIDir
+
+ self.salome = salome
+ self.ssIhm = True
+ self.code = code
+ self.genereXSD = genereXSD
+ self.versionCode = versionCode
+ self.ssCode = ssCode
+
+ self.dict_reels = {}
+ self.fichierIn = None
+ self.fichierOut = None
+
+ self.recent = []
+ self.ficRecents = {}
+ self.mesScripts = {}
+ self.listeAEnlever = []
+ self.ListePathCode = [
+ "Adao",
+ "ADAO",
+ "Carmel3D",
+ "Telemac",
+ "CF",
+ "MAP",
+ "ZCracks",
+ "SEP",
+ "SPECA",
+ "PSEN_Eficas",
+ "PSEN_N1",
+ ]
+ self.listeCode = [
+ "Adao",
+ "ADAO",
+ "Carmel3D",
+ "Telemac",
+ "CF",
+ "MAP",
+ "ZCracks",
+ "SEP",
+ "SPECA",
+ "PSEN_Eficas",
+ "PSEN_N1",
+ ]
+ self.repIcon = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), "..", "Editeur", "icons"
+ )
+
+ if fichierCata == None:
+ self.fichierCata = session.d_env.fichierCata
+ else:
+ self.fichierCata = fichierCata
+ if session.d_env.labelCode:
+ self.labelCode = session.d_env.labelCode
+ self.withXSD = session.d_env.withXSD
+
+ if self.salome:
+ try:
+ from Accas import eficasSalome
+ Accas.SalomeEntry = eficasSalome.SalomeEntry
+ except:
+ print("eficas hors salome")
+
+ self.multi = multi
+ if self.multi:
+ print("pas de multi sans ihm")
+
+ if langue == "fr":
+ self.langue = langue
+ else:
+ self.langue = "ang"
+
+ if self.multi == False:
+ self.definitCode(code, ssCode)
+ if code == None:
+ return
+
+ self.suiteTelemac = False
+ self.viewmanager = MyViewManagerSsIhm(self)
+ self.withUQ = False
+
+ def ajoutUQ(self):
+ self.withUQ = True
+ self.formatFichierIn = "pythonUQ" # par defaut
+
+ def definitCode(self, code, ssCode):
+ self.code = code
+ self.ssCode = ssCode
+ if self.code == None:
+ return # pour le cancel de la fenetre choix code
+
+ try:
+ name = "prefs_" + self.code
+ prefsCode = __import__(name)
+ self.repIni = prefsCode.repIni
+ except:
+ self.repIni = os.path.dirname(os.path.abspath(__file__))
+
+ if ssCode != None:
+ self.formatFichierOut = ssCode # par defaut
+ prefsCode.NAME_SCHEME = ssCode
+ else:
+ self.formatFichierIn = "python" # par defaut
+ self.formatFichierOut = "python" # par defaut
+
+ nameConf = "configuration_" + self.code
+ try:
+ configuration = __import__(nameConf)
+ self.maConfiguration = configuration.make_config(self, self.repIni)
+ except:
+ from InterfaceQT4.configuration import makeConfig
+
+ # self.maConfiguration = configuration.makeConfig(self,prefsCode.repIni)
+ self.maConfiguration = makeConfig(self, self.repIni)
+
+ if hasattr(self, "maConfiguration") and self.maConfiguration.translatorFichier:
+ from Extensions import localisation
+
+ localisation.localise(
+ None,
+ self.langue,
+ translatorFichier=self.maConfiguration.translatorFichier,
+ )
+ if self.withXSD:
+ self.maConfiguration.withXSD = True
+
+ def getSource(self, file):
+ # appele par Editeur/session.py
+ import convert
+
+ p = convert.plugins["python"]()
+ p.readfile(file)
+ texte = p.convert("execnoparseur")
+ return texte
+
+ def initEditor(self, fichier=None, jdc=None, units=None, include=0):
+ if (hasattr(self, "editor")) and self.editor != None:
+ print("un seul editeur par application")
+ sys.exit()
+ self.editor = self.viewmanager.getNewEditorNormal()
+
+ def initEditorNormal(self, fichier=None, jdc=None, units=None, include=0):
+ if (hasattr(self, "editor")) and self.editor != None:
+ print("un seul editeur par application")
+ sys.Exit()
+ # self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
+ self.editor = self.viewmanager.getNewEditorNormal()
+
+ def fileNew(self):
+ self.editor = self.initEditor()
+
+ def getEditor(self):
+ if (hasattr(self, "editor")) and self.editor != None:
+ return self.editor
+ self.initEditor()
+ return self.editor
+
+ def fileOpen(self, fichier):
+ fichierIn = os.path.abspath(fichier)
+ try:
+ monEditor = self.viewmanager.handleOpen(fichierIn)
+ except EficasException as exc:
+ print("poum")
+ monEditor = None
+ return monEditor
+
+ def fileSave(self):
+ if self.editor == None:
+ return False
+ ok, newName = editor.saveFileAs()
+ print("ok, newName ", ok, newName)
+
+ def fileSaveAs(self, fileName):
+ if self.editor == None:
+ return False
+ ok = editor.saveFileAs()
+ print("ok ", ok)
+
+ def dumpXsd(self, avecEltAbstrait=False):
+ currentCata = CONTEXT.getCurrentCata()
+ texteXSD = currentCata.dumpXsd(avecEltAbstrait)
+ return texteXSD
+ # if self.maConfiguration.afficheIhm==False : exit()
+ # else : return texteXSD
+
+
+# ,self.fileSaveAs
+# ,self.fileClose
+# ,self.fileExit
+# ,self.jdcRapport
+# ,self.jdcRegles
+# ,self.jdcFichierSource
+# ,self.visuJdcPy
+
+
+if __name__ == "__main__":
+ # Modules Eficas
+ monEficas = AppliSsIhm(code="Adao", salome=0, labelCode="V83")
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 lire un catalogue et a construire
+ un objet CataItem pour Eficas.
+ Il s'appuie sur la classe READERCATA
+"""
+# Modules Python
+import os, sys
+
+# Modules Eficas
+from Noyau.N_CR import CR
+from Editeur.catadesc import CatalogDescription
+
+import analyse_catalogue
+import analyse_catalogue_initial
+import autre_analyse_cata
+import uiinfo
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
+
+
+# -------------------------------
+class ReaderCataCommun(object):
+ # -------------------------------
+
+ def askChoixCatalogue(self, cataListeChoix):
+ # ____________________________________________
+ """
+ Ouvre une fenetre de selection du catalogue dans le cas où plusieurs
+ ont ete definis dans Accas/editeur.ini
+ """
+ try:
+ from PyQt5.QtWidgets import QDialog
+ except:
+ print("Pas de choix interactif sans qt")
+ return
+
+ code = getattr(self.appliEficas.maConfiguration, "code", None)
+ if code != None:
+ title = tr("Choix d une version du code ") + str(code)
+ else:
+ title = tr("Choix d une version ")
+
+ from InterfaceGUI.QT5.monChoixCata import MonChoixCata
+
+ widgetChoix = MonChoixCata(
+ self.appliEficas, [cata.labelCode for cata in cataListeChoix], title
+ )
+ ret = widgetChoix.exec_()
+
+ lab = str(self.VERSION_EFICAS) + " "
+ lab += tr(" pour ")
+ lab += str(self.code)
+ lab += tr(" avec le catalogue ")
+ if ret == QDialog.Accepted:
+ cata = cataListeChoix[widgetChoix.CBChoixCata.currentIndex()]
+ self.fichierCata = cata.fichierCata
+ self.labelCode = cata.labelCode
+ self.appliEficas.formatFichierOut = cata.formatFichierOut
+ self.appliEficas.formatFichierIn = cata.formatFichierIn
+ lab += self.labelCode
+ self.appliEficas.setWindowTitle(lab)
+ widgetChoix.close()
+ else:
+ widgetChoix.close()
+ raise EficasException()
+
+ def choisitCata(self):
+ # ____________________
+
+ listeCataPossibles = []
+ #self.commandesOrdreCatalogue = []
+
+ listeTousLesCatas = []
+ for catalogue in self.appliEficas.maConfiguration.catalogues:
+ if isinstance(catalogue, CatalogDescription):
+ listeTousLesCatas.append(catalogue)
+ elif isinstance(catalogue, tuple):
+ listeTousLesCatas.append(CatalogDescription.createFromTuple(catalogue))
+ else:
+ print(("Catalog description cannot be interpreted: ", catalogue))
+
+ if self.labelCode is None:
+ listeCataPossibles = listeTousLesCatas
+ else:
+ for catalogue in listeTousLesCatas:
+ if catalogue.code == self.code and catalogue.ssCode == self.ssCode:
+ listeCataPossibles.append(catalogue)
+
+ if len(listeCataPossibles) == 0:
+ try:
+ QMessageBox.critical(
+ self.QWParent,
+ tr("Import du catalogue"),
+ tr("Pas de catalogue defini pour le code ") + self.code,
+ )
+ except:
+ print("Pas de catalogue defini pour le code " + self.code)
+ if self.appliEficas.salome == 0:
+ sys.exit(1)
+ self.appliEficas.close()
+ return
+
+ if self.labelCode is not None:
+ # La version a ete fixee
+ for cata in listeCataPossibles:
+ if self.labelCode == cata.labelCode:
+ self.fichierCata = cata.fichierCata
+ self.labelCode = cata.labelCode
+ self.appliEficas.formatFichierOut = cata.formatFichierOut
+ self.appliEficas.formatFichierIn = cata.formatFichierIn
+ else:
+ cataChoiceList = []
+ for cata in listeCataPossibles:
+ if cata.selectable:
+ if cata.default:
+ cataChoiceList.insert(0, cata)
+ else:
+ cataChoiceList.append(cata)
+
+ # le catalogue est fixe dans la ligne de commande
+ if self.appliEficas.fichierCata != None:
+ trouve = False
+ for catalogue in listeTousLesCatas:
+ if os.path.abspath(catalogue.fichierCata) == (
+ os.path.abspath(self.appliEficas.fichierCata)
+ ):
+ listeCataPossibles = (catalogue,)
+ trouve = True
+ break
+ if not trouve:
+ catalogue = CatalogDescription.createFromTuple(
+ (
+ self.code,
+ self.code,
+ self.appliEficas.fichierCata,
+ "python",
+ "python",
+ )
+ )
+ listeCataPossibles = (catalogue,)
+
+ if len(listeCataPossibles) == 0:
+ try:
+ from PyQt5.QtWidgets import QMessageBox, QDialog
+
+ QMessageBox.critical(
+ self.QWParent,
+ tr("Import du catalogue"),
+ tr("Pas de catalogue defini pour le code ") + self.code,
+ )
+ except:
+ print("Pas de catalogue defini pour le code " + self.code)
+ self.appliEficas.close()
+ if self.appliEficas.salome == 0:
+ sys.exit(1)
+ return
+
+ # le label est fixe dans la ligne de commande
+ if self.labelCode is not None:
+ # La version a ete fixee
+ for cata in listeCataPossibles:
+ if self.labelCode == cata.labelCode:
+ self.fichierCata = cata.fichierCata
+ self.appliEficas.formatFichierIn = cata.formatFichierIn
+ self.appliEficas.formatFichierOut = cata.formatFichierOut
+ else:
+ cataListeChoix = []
+ for cata in listeCataPossibles:
+ if cata.default:
+ cataListeChoix.insert(0, cata)
+ else:
+ cataListeChoix.append(cata)
+
+ if len(cataListeChoix) == 0:
+ try:
+ from PyQt5.QtWidgets import QMessageBox
+
+ QMessageBox.critical(
+ self.QWParent,
+ tr("Import du catalogue"),
+ tr("Aucun catalogue trouve"),
+ )
+ except:
+ print("Pas de catalogue defini pour le code " + self.code)
+ self.appliEficas.close()
+ if self.appliEficas.salome == 0:
+ sys.exit(1)
+
+ elif len(cataListeChoix) == 1:
+ self.fichierCata = cataListeChoix[0].fichierCata
+ self.labelCode = cataListeChoix[0].labelCode
+ self.appliEficas.formatFichierOut = cataListeChoix[0].formatFichierOut
+ self.appliEficas.formatFichierIn = cataListeChoix[0].formatFichierIn
+
+ else:
+ # plusieurs catalogues sont disponibles : il faut demander a l'utilisateur
+ # lequel il veut utiliser ...
+ if self.appliEficas.ssIhm:
+ print("Unable to know which catafile is choosen")
+ exit()
+ self.askChoixCatalogue(cataListeChoix)
+ self.demandeCatalogue = True
+
+ if self.fichierCata == None:
+ if self.appliEficas.salome == 0:
+ print(
+ (
+ "Pas de catalogue pour code %s, version %s"
+ % (self.code, self.labelCode)
+ )
+ )
+ sys.exit(1)
+ else:
+ self.appliEficas.close()
+ return
+
+
+# ------------------------------------
+class ReaderCata(ReaderCataCommun):
+ # ------------------------------------
+
+ def __init__(self, QWParent, appliEficas):
+ # _______________________________________
+
+ self.QWParent = QWParent
+ self.appliEficas = self.QWParent.appliEficas
+ self.VERSION_EFICAS = self.appliEficas.VERSION_EFICAS
+ self.demandeCatalogue = False
+ self.code = self.appliEficas.code
+ self.titre = self.appliEficas.code
+ self.ssCode = self.appliEficas.ssCode
+ # on positionne par defaut mais est-ce vraiment necessaire
+ self.appliEficas.formatFichierIn = "python"
+ self.appliEficas.formatFichierOut = "python"
+ self.labelCode = self.appliEficas.labelCode
+ self.fichierCata = self.appliEficas.fichierCata
+ self.openCata()
+ self.traiteIcones()
+ self.cataitem = None
+ self.creeDicoInverse()
+ if self.code == "TELEMAC":
+ self.creeDicoCasToCata()
+
+ def openCata(self):
+ """
+ Ouvre le catalogue standard du code courant, cad le catalogue present
+ dans le repertoire Cata
+ """
+ # import du catalogue
+ if self.fichierCata == None:
+ self.choisitCata()
+
+ self.cata = self.importCata(self.fichierCata)
+ if self.code == "NonConnu":
+ self.code = self.cata.JdC.code
+ modeleMetier = None
+ dicoEltDif = {}
+ if not (self.appliEficas.genereXSD):
+ if self.appliEficas.maConfiguration.withXSD or self.appliEficas.withXSD:
+ try:
+ import pyxb
+ except:
+ self.QWParent.informe(
+ "environnement", "please source pyxb environment"
+ )
+ exit()
+ try:
+ nomCataXsd = os.path.splitext(os.path.basename(self.fichierCata))[0]
+ fichierCataTrunc = os.path.splitext(
+ os.path.basename(self.fichierCata)
+ )[0]
+ nomCataXsd = fichierCataTrunc + "_driver"
+
+ if os.path.dirname(self.fichierCata) == "":
+ pathCata = "./raw/" + nomCataXsd + ".py"
+ else:
+ pathCata = (
+ os.path.dirname(self.fichierCata)
+ + "/raw/"
+ + nomCataXsd
+ + ".py"
+ )
+
+ self.cata.fileModeleMetier = (
+ os.path.dirname(self.fichierCata)
+ + "/raw/"
+ + nomCataXsd
+ + ".xsd"
+ )
+ import imp
+
+ modeleMetier = imp.load_source(nomCataXsd, pathCata)
+ # print ('nomCataXsd , pathCata ',nomCataXsd,pathCata)
+ try:
+ # if 1 :
+ # monObjetAnnotation = getattr(modeleMetier,'PNEFdico_'+self.code)
+ monObjetAnnotation = getattr(modeleMetier, "PNEFdico")
+ texte = monObjetAnnotation.__doc__
+ except:
+ texte = None
+ if texte != None and texte != "":
+ l = {}
+ texte = "dicoEltDif = " + texte
+ exec(texte, globals(), l)
+ dicoEltDif = l["dicoEltDif"]
+ # print ('dans readerCata _________', dicoEltDif)
+
+ except:
+ if self.appliEficas.ssIhm == False:
+ print("______________ poum import cata_genere ")
+ self.QWParent.informe(
+ "XSD driver", "unable to load xsd driver", critique=False
+ )
+ modeleMetier = None
+
+ self.cata.DicoNomTypeDifferentNomElt = dicoEltDif
+
+ if hasattr(self.cata, "implement"):
+ self.cata.JdC.implement = self.cata.implement
+ else:
+ self.cata.JdC.implement = ""
+ if hasattr(self.cata, "importedBy"):
+ self.cata.JdC.importedBy = self.cata.importedBy
+ else:
+ self.cata.JdC.importedBy = []
+ self.cata.JdC.labelCode = self.labelCode
+ if not (hasattr(self.cata, "dict_condition")):
+ self.cata.dict_condition = {}
+
+ # pointeur pour le dumpXSD
+ self.cata.JdC.cata = self.cata
+
+ self.cata.modeleMetier = modeleMetier
+ if not self.cata:
+ # try:
+ # from PyQt5.QtWidgets import QMessageBox, QDialog
+ # QMessageBox.critical( self.QWParent, tr("Import du catalogue"),tr("Impossible d'importer le catalogue ")+ self.fichierCata)
+ # except :
+ # print ("Impossible d'importer le catalogue "+ self.fichierCata)
+ self.QWParent.informe(
+ "Catalogue", "Impossible d'importer le catalogue " + self.fichierCata
+ )
+ self.appliEficas.close()
+ if self.appliEficas.salome == 0:
+ sys.exit(1)
+ #
+ # analyse du catalogue (ordre des mots-cles)
+ #
+ # retrouveOrdreCataStandard fait une analyse textuelle du catalogue
+ # remplace par retrouveOrdreCataStandardAutre qui utilise une numerotation
+ # des mots cles a la creation
+ # print (dir(self.cata))
+ self.retrouveOrdreCataStandardAutre()
+ if self.appliEficas.maConfiguration.modeNouvCommande == "initial":
+ self.retrouveOrdreCataStandard()
+ if hasattr(self.cata, "ordreDesCommandes"):
+ self.ordreDesCommandes = self.cata.ordreDesCommandes
+ else:
+ self.ordreDesCommandes = None
+
+ if hasattr(self.cata, "Classement_Commandes_Ds_Arbre"):
+ self.Classement_Commandes_Ds_Arbre = self.cata.Classement_Commandes_Ds_Arbre
+ else:
+ self.Classement_Commandes_Ds_Arbre = ()
+ if hasattr(self.cata, "enum"):
+ try:
+ _temp = __import__(
+ self.cata.enum,
+ globals(),
+ locals(),
+ ["DicoEnumCasFrToEnumCasEn", "TelemacdicoEn"],
+ 0,
+ )
+ self.DicoEnumCasFrToEnumCasEn = _temp.DicoEnumCasFrToEnumCasEn
+ self.TelemacdicoEn = _temp.TelemacdicoEn
+ except:
+ pass
+
+ # print self.cata.ordreDesCommandes
+
+ #
+ # analyse des donnees liees l'IHM : UIinfo
+ #
+ uiinfo.traite_UIinfo(self.cata)
+
+ #
+ # traitement des clefs documentaires
+ #
+
+ self.titre = (
+ self.VERSION_EFICAS
+ + " "
+ + tr(" avec le catalogue ")
+ + os.path.basename(self.fichierCata)
+ )
+ if self.appliEficas.ssIhm == False:
+ self.appliEficas.setWindowTitle(self.titre)
+ self.appliEficas.titre = self.titre
+ self.QWParent.titre = self.titre
+
+ # incertitude --> change le convert
+ if hasattr(self.cata, "avecIncertitude"):
+ self.appliEficas.ajoutUQ()
+ if hasattr(self.cata, "modifieCatalogueDeterministe"):
+ self.cata.modifieCatalogueDeterministe(self.cata)
+
+ def importCata(self, cata):
+ """
+ Realise l'import du catalogue dont le chemin d'acces est donne par cata
+ """
+ nom_cata = os.path.splitext(os.path.basename(cata))[0]
+ rep_cata = os.path.dirname(cata)
+ sys.path[:0] = [rep_cata]
+ self.appliEficas.listeAEnlever.append(rep_cata)
+
+ # PNPNPN pas propre __ A reflechir
+ if "cata_Vimmp" in list(sys.modules.keys()):
+ del sys.modules["cata_Vimmp"]
+
+ if nom_cata in list(sys.modules.keys()):
+ del sys.modules[nom_cata]
+
+ for k in sys.modules:
+ if k[0 : len(nom_cata) + 1] == nom_cata + ".":
+ del sys.modules[k]
+
+ mesScriptsNomFichier = "mesScripts_" + self.code.upper()
+ try:
+ self.appliEficas.mesScripts[self.code] = __import__(mesScriptsNomFichier)
+ except:
+ pass
+
+ # if 1 :
+ try:
+ o = __import__(nom_cata)
+ return o
+ except Exception as e:
+ self.QWParent.informe("catalog python", "unable to load catalog file")
+ import traceback
+
+ traceback.print_exc()
+ return 0
+
+ def retrouveOrdreCataStandardAutre(self):
+ """
+ Construit une structure de donnees dans le catalogue qui permet
+ a EFICAS de retrouver l'ordre des mots-cles dans le texte du catalogue.
+ Pour chaque entite du catlogue on cree une liste de nom ordreMC qui
+ contient le nom des mots cles dans le bon ordre
+ """
+ (
+ self.cata_ordonne_dico,
+ self.appliEficas.liste_simp_reel,
+ ) = autre_analyse_cata.analyseCatalogue(self.cata)
+ # print ('_________________________________________', self)
+ # print (self.cata_ordonne_dico)
+ # self.appliEficas.liste_simp_reel = ()
+ # self.cata_ordonne_dico = {}
+
+ def retrouveOrdreCataStandard(self):
+ """
+ Retrouve l'ordre des mots-cles dans le catalogue, cad :
+ Attention s appuie sur les commentaires
+ """
+ nom_cata = os.path.splitext(os.path.basename(self.fichierCata))[0]
+ rep_cata = os.path.dirname(self.fichierCata)
+ self.commandesOrdreCatalogue = analyse_catalogue_initial.analyseCatalogue( self.fichierCata)
+ # print self.commandesOrdreCatalogue
+
+ def traiteIcones(self):
+ if self.appliEficas.maConfiguration.ficIcones == None:
+ return
+ try:
+ ficIcones = self.appliEficas.maConfiguration.ficIcones
+ fichierIcones = __import__(ficIcones, globals(), locals(), [], 0)
+ self.appliEficas.maConfiguration.dicoIcones = (
+ fichierIcones.dicoDesIcones.dicoIcones
+ )
+ self.appliEficas.maConfiguration.dicoImages = (
+ fichierIcones.dicoDesIcones.dicoImages
+ )
+ except:
+ print("Pas de fichier associe contenant des liens sur les icones ")
+ self.appliEficas.maConfiguration.dicoIcones = {}
+
+ def creeDicoInverse(self):
+ self.dicoInverse = {}
+ self.dicoMC = {}
+ if not self.cata:
+ return
+ listeEtapes = self.cata.JdC.commandes
+ for e in self.cata.JdC.commandes:
+ self.traiteEntite(e)
+
+ def creeDicoCasToCata(self):
+ if hasattr(self.cata, "dicoCasEn"):
+ _temp = __import__(
+ self.cata.dicoCasEn, globals(), locals(), ["DicoCasEnToCata"], 0
+ )
+ if self.appliEficas.langue == "ang":
+ self.dicoCasToCata = _temp.dicoCasEnToCata
+ else:
+ self.dicoCasToCata = _temp.dicoCasFrToCata
+
+ def traiteEntite(self, e):
+ boolIn = 0
+ for nomFils, fils in list(e.entites.items()):
+ self.dicoMC[nomFils] = fils
+ self.traiteEntite(fils)
+ boolIn = 1
+ if boolIn == 0:
+ liste = []
+ moi = e
+ while hasattr(moi, "pere"):
+ liste.append((moi.nom, moi))
+ moi = moi.pere
+ liste.append((moi.nom, moi))
+ self.dicoInverse[e.nom] = liste
+ self.dicoInverse[tr(e.nom)] = liste
+
+ def creeRubrique(self, e, dico, niveau):
+ from Accas import A_BLOC
+
+ decale = niveau * " "
+ # if niveau != 0 :
+ # if isinstance(e,A_BLOC.BLOC): print decale, e.condition
+ # else : print decale, e. nom
+ for nom, fils in list(e.entites.items()):
+ if list(fils.entites.items()) != []:
+ self.creeRubrique(fils, dico, niveau + 1)
+ # else : print (niveau+1)*" ", nom
+
+ # def dumpToXsdEficas(self):
+ # Pas sur qu on ait jamais besoin de cela
+ # pass
+ # from Efi2Xsd import readerEfficas
+ # newSchema= xml = open('Cata_MED_FAM.xml').read()
+ # SchemaMed = efficas.CreateFromDocument(xml)
+ # SchemaMed.alimenteCata(self.cata)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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 SERVAIT a lire un catalogue et a construire
+ un objet CataItem pour Eficas.
+ Il s'appuie sur la classe READERCATA
+ OBSOLETE
+"""
+import autre_analyse_cata
+import uiinfo
+
+
+# Modules Eficas
+
+from monChoixCata import MonChoixCata
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
+#from Efi2Xsd import readerEfiXsd
+from autre_analyse_cata import analyseCatalogue
+
+
+from readercata import ReaderCataCommun
+
+
+class ReaderCata(ReaderCataCommun):
+ def __init__(self, QWParent, appliEficas):
+ self.QWParent = QWParent
+ self.appliEficas = appliEficas
+ self.VERSION_EFICAS = self.appliEficas.VERSION_EFICAS
+ self.code = self.appliEficas.code
+ self.ssCode = self.appliEficas.ssCode
+ # PN ?? bizarre le 22/04/20
+ self.appliEficas.formatfichierOut = "python"
+ self.appliEficas.formatfichierIn = "xml"
+ self.modeNouvCommande = self.appliEficas.maConfiguration.modeNouvCommande
+ self.labelCode = self.appliEficas.labelCode
+ self.version_cata = None
+ self.ficCata = None
+ self.OpenCata()
+ self.cataitem = None
+ self.titre = "Eficas XML"
+ self.ordreDesCommandes = None
+ self.Classement_Commandes_Ds_Arbre = ()
+ self.demandeCatalogue = False
+
+ # self.traiteIcones()
+ # self.creeDicoInverse()
+
+ def OpenCata(self):
+ # self.ficCata = 'Cata_MED_FAM.xml'
+ # xml = open('/home/A96028/QT5GitEficasTravail/eficas/Med/Cata_MED_FAM.xml').read()
+ # xml = open('/home/A96028/QT5GitEficasTravail/eficas/CataTestXSD/cata_test1.xml').read()
+ self.choisitCata()
+ xml = open(self.ficCata).read()
+ SchemaMed = readerEfiXsd.efficas.CreateFromDocument(xml)
+ SchemaMed.exploreCata()
+ self.cata = SchemaMed
+ uiinfo.traite_UIinfo(self.cata)
+ #self.commandesOrdreCatalogue = []
+ self.cata_ordonne_dico, self.appliEficas.liste_simp_reel = autre_analyse_cata.analyseCatalogue(self.cata)
+ self.liste_groupes = None
+
+ def dumpToXml(self):
+ # pour compatibilite
+ pass
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2024 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
+#
+
+import os
+from Extensions.i18n import tr
+
+
+# --------------------------------
+class JdcSsIhmHandler(object):
+ # --------------------------------
+ # retourne a l utilisateur
+
+ def __init__(self, viewManager):
+ # --------------------------------------
+ self.viewManagerSsIhm = viewManager
+
+ def viewJdcPy(self):
+ # ---------------------
+ self.viewManagerSsIhm.handleViewJdcPy(self)
+
+ def viewJdcSource(self):
+ # ---------------------
+ self.viewManagerSsIhm.handleViewJdcSource(self)
+
+ def getFileName(self):
+ # ---------------------
+ self.viewManagerSsIhm.getFileName(self)
+
+ def viewJdcRapport(self):
+ # ---------------------
+ self.viewManagerSsIhm.handleViewJdcRapport(self)
+
+ def getJdcRapport(self):
+ # ---------------------
+ return self.viewManagerSsIhm.handleGetJdcRapport(self)
+
+ def getDicoPython(self):
+ # -------------------------
+ return self.viewManagerSsIhm.generDico(self)
+
+ def isJdcValid(self):
+ # -------------------------
+ return self.viewManagerSsIhm.isJdcValid(self)
+
+ def fileSaveAs(self, fileName):
+ # -------------------------
+ return self.viewManagerSsIhm.fileSaveAs(self, fileName)
+
+ def fileLegerSaveAs(self, fileName):
+ # -----------------------------------
+ return self.viewManagerSsIhm.fileLegerSaveAs(self, fileName)
+
+ def handleSortieUQ(self, fileName):
+ # -----------------------------------
+ return self.viewManagerSsIhm.handleSortieUQ(self, fileName)
+
+ def handleExeUQ(self, fileName):
+ # -----------------------------------
+ # est-ce que cela a un sens de faire l exe hors IHM ?
+ return self.viewManagerSsIhm.handleExeUQ(self, fileName)
+
+
+# --------------------------------
+class MyViewManagerSsIhm(object):
+ # --------------------------------
+ # Symetrique de ViewManager mais pas d heritage entre les 2
+ # dans le viewManager pas de souci pour savoir qui est le jdc sur lequel on travaille
+ # ici en revanche.... c est moins sur . voir avec le fichier
+
+ # --------------------------------
+ def __init__(self, appliEficas):
+ # --------------------------------
+ self.appliEficas = appliEficas
+ self.tabWidgets = []
+ self.mesIndexes = {}
+ self.dictEditors = {}
+ self.untitledCount = 0
+ self.doubles = {}
+
+ # ------------------------------------------------------
+ def handleOpen(self, fichier=None, units=None):
+ # ------------------------------------------------------
+ result = None
+ if fichier is None:
+ print("nom de fichier obligatoire")
+ return None
+
+ for handler in self.dictEditors:
+ editor = self.dictEditors[handler]
+ if self.samePath(fichier, editor.getFileName()):
+ print("fichier deja ouvert . pas de nouvel editor")
+ return handler
+
+ monNewHandler = self.getNewEditor(fichier, units)
+ return monNewHandler
+
+ # ----------------------------------------------------------------------
+ def getNewEditor(self, fichier=None, jdc=None, units=None, include=0):
+ # ----------------------------------------------------------------------
+ # il faudrait decider entre e handler ou non
+ # le cas d usage n est pas tout a fait identique :
+ # avec handler pour les utilisateurs avance
+ # sans pour les utilisateurs encore plus ancvances et les tests
+
+ from editorSsIhm import JDCEditorSsIhm
+
+ editor = JDCEditorSsIhm(
+ self.appliEficas, fichier, jdc, units=units, include=include
+ )
+
+ if editor.jdc: # le fichier est bien un jdc
+ monHandler = JdcSsIhmHandler(self)
+ self.dictEditors[monHandler] = editor
+ return monHandler
+ else:
+ print("impossible de construire le jdc")
+ return None
+
+ # --------------------------------------------------------------------------------
+ def getNewEditorNormal(self, fichier=None, jdc=None, units=None, include=0):
+ # --------------------------------------------------------------------------------
+
+ from editorSsIhm import JDCEditorSsIhm
+
+ editor = JDCEditorSsIhm(
+ self.appliEficas, fichier, jdc, units=units, include=include
+ )
+ self.editor = editor
+ return editor
+
+ # -----------------------------
+ def samePath(self, f1, f2):
+ # ------------------------------
+ """
+ compare two paths.
+ """
+ if f1 is None or f2 is None:
+ return 0
+ if os.path.normcase(os.path.normpath(f1)) == os.path.normcase(
+ os.path.normpath(f2)
+ ):
+ return 1
+ return 0
+
+ # ---------------------------------
+ def handleViewJdcPy(self, handler):
+ # ---------------------------------
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ self.dictEditors[handler].viewJdcPy()
+
+ # ---------------------------------
+ def getFileName(self, handler):
+ # ---------------------------------
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ return self.dictEditors[handler].getFileName()
+
+ # ---------------------------------------------
+ def handleViewJdcSource(self, handler):
+ # ---------------------------------------------
+ print(handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ self.dictEditors[handler].viewJdcSource()
+
+ # ---------------------------------------------
+ def handleViewJdcRapport(self, handler):
+ # ---------------------------------------------
+ print(handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ self.dictEditors[handler].viewJdcRapport()
+
+ # ---------------------------------------------
+ def handleGetJdcRapport(self, handler):
+ # ---------------------------------------------
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ return self.dictEditors[handler].getJdcRapport()
+
+ # ---------------------------------------------
+ def handleViewJdcRapport(self, handler):
+ # ---------------------------------------------
+ print(handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ self.dictEditors[handler].viewJdcRapport()
+
+ # ---------------------------------------------
+ def generDico(self, handler):
+ # ---------------------------------------------
+ print(handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ return self.dictEditors[handler].generDico()
+
+ # ---------------------------------------------
+ def isJdcValid(self, handler):
+ # ---------------------------------------------
+ print(handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ return self.dictEditors[handler].jdc.isValid()
+
+ # ---------------------------------------------
+ def fileSaveAs(self, handler, fileName):
+ # ---------------------------------------------
+ print(handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ return self.dictEditors[handler].saveFile(fileName)
+
+ # ---------------------------------------------
+ def fileLegerSaveAs(self, handler, fileName):
+ # ---------------------------------------------
+ # print (handler)
+ if not (handler in self.dictEditors):
+ print("editor non trouve")
+ return
+ self.dictEditors[handler].saveFileLegerAs(fileName)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 package contient les fonctionnalites necessaires
- pour l'editeur graphique QT
-"""
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import re
-import types, sys, os
-import traceback
-from . import typeNode
-
-
-from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QApplication, QMessageBox
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-from .gereRegles import GereRegles
-from .monChoixCommande import MonChoixCommande
-
-
-# ------------------------------------------
-class JDCTree(QTreeWidget, GereRegles):
-# ------------------------------------------
-
- def __init__(self, jdc_item, QWParent):
- # ----------------------------------------
- self.editor = QWParent
- self.plie = False
- if self.editor.widgetTree != None:
- QTreeWidget.__init__(self, self.editor.widgetTree)
- self.editor.verticalLayout_2.addWidget(self)
- if self.editor.enteteQTree == "complet":
- self.headerItem().setText(0, "Commande ")
- self.headerItem().setText(1, "Concept/Valeur")
- else:
- self.headerItem().setText(0, "Commande ")
- self.setColumnWidth(0, 200)
- self.setExpandsOnDoubleClick(False)
- self.setSelectionMode(3)
- else:
- QTreeWidget.__init__(self, None)
- self.item = jdc_item
- self.tree = self
- self.appliEficas = self.editor.appliEficas
- self.childrenComplete = []
- self.racine = self.item.itemNode(self, self.item)
-
- self.itemCourant = None
-
- self.itemClicked.connect(self.handleOnItem)
- self.itemCollapsed.connect(self.handleCollapsedItem)
- self.itemExpanded.connect(self.handleExpandedItem)
-
- self.node_selected = self.racine
- self.inhibeExpand = True
- self.expandItem(self.racine)
- self.inhibeExpand = False
- if self.racine.children != []:
- if self.editor.maConfiguration.afficheCommandesPliees:
- self.racine.children[0].plieToutEtReaffiche()
- else:
- self.racine.children[0].deplieToutEtReaffiche()
- self.racine.children[0].fenetre.donnePremier()
- else:
- self.racine.affichePanneau()
-
- def contextMenuEvent(self, event):
- # ---------------------------------
- coord = event.globalPos()
- item = self.currentItem()
- self.handleContextMenu(item, coord)
-
- def handleContextMenu(self, item, coord):
- # -------------------------------------
- """
- Private slot to show the context menu of the listview.
-
- @param itm the selected listview item (QListWidgetItem)
- @param coord the position of the mouse pointer (QPoint)
- Attention : existeMenu permet de savoir si un menu est associe a cet item
- """
- print("handleContextMenu")
- if item == None:
- return
- self.itemCourant = item
- if item.existeMenu == 0:
- return
-
- if item.menu == None:
- item.createPopUpMenu()
- if item.menu != None:
- # PNPN reflechir a qqchose de generique pour remplacer cette fonctionnalite
- # if item.item.getNom() == "DISTRIBUTION" and item.item.isValid() :
- # item.Graphe.setEnabled(1)
- item.menu.exec_(coord)
-
- def handleCollapsedItem(self, item):
- # ----------------------------------
- # print ("dans CollapsedItem", self.inhibeExpand )
- if self.inhibeExpand == True:
- return
-
- # On traite le cas de l item non selectionne
- self.itemCourant = item
- itemParent = item
- while not (hasattr(itemParent, "getPanel")):
- itemParent = itemParent.treeParent
- if self.tree.node_selected != itemParent:
- item.setExpanded(False)
- return
-
- item.setPlie()
- item.plieToutEtReaffiche()
- item.select()
-
- def handleExpandedItem(self, item):
- # ----------------------------------
- # print ("handleExpandedItem pour ", item.item.nom, self.inhibeExpand)
- # import traceback
- # traceback.print_stack()
- if self.inhibeExpand == True:
- return
-
- self.itemCourant = item
- self.inhibeExpand = True
- itemParent = item
- while not (hasattr(itemParent, "getPanel")):
- if itemParent.plie == True:
- itemParent.setDeplie()
- itemParent = itemParent.treeParent
- if self.tree.node_selected != itemParent:
- item.setExpanded(True)
- self.inhibeExpand = False
- return
- item.deplieToutEtReaffiche()
- self.inhibeExpand = False
-
- def handleOnItem(self, item, int):
- # ----------------------------------
- # print ("je passe dans handleOnItem pour ",self, item.item.nom, item, item.item, item.item.getLabelText())
-
- from InterfaceQT4 import composimp
-
- self.inhibeExpand = True
- self.itemCourant = item
- itemParent = item
- itemAvant = item
-
- # PN : 22 juil 2021 --> bizarre ce itemAvant Verifier le while
- while not (hasattr(itemParent, "getPanel")):
- if itemParent.plie == True:
- itemParent.setDeplie()
- itemAvant = itemParent
- itemParent = itemParent.treeParent
-
- if itemParent.fenetre != self.editor.fenetreCentraleAffichee:
- estUneFeuille = isinstance(item, composimp.Node)
- # il faut afficher le parent
- # Attention - Specification particuliere pour MT qui permet de nn afficher qu 1 niveau
- # le catalogue contient cette indication dans fenetreIhm
- if estUneFeuille and itemParent.fenetreIhm == "deplie1Niveau":
- if item == itemParent:
- itemParent.affichePanneau()
- else:
- itemAvant.afficheCeNiveau()
- elif estUneFeuille:
- itemParent.affichePanneau()
- elif self.editor.maConfiguration.afficheCommandesPliees:
- itemParent.plieToutEtReafficheSaufItem(item)
- else:
- itemParent.affichePanneau()
-
- elif (isinstance(item, composimp.Node)) and item.fenetre:
- item.fenetre.rendVisible()
- elif itemParent != item:
- self.tree.handleExpandedItem(item)
-
- # aide
- try:
- fr = item.item.getFr()
- chaineDecoupee = fr.split("\n")
- if len(chaineDecoupee) > 3:
- txt = (
- "\n".join(chaineDecoupee[0:2])
- + "...\nfull help : double clicked on validity chip of "
- + str(item.item.nom)
- + " in central widget"
- )
- else:
- txt = fr
- if self.editor:
- self.editor.afficheCommentaire(str(txt))
- except:
- pass
-
- item.select()
- self.inhibeExpand = False
-
- def choisitPremier(self, name):
- # ----------------------------
- self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
- self.racine.fenetre.close()
- new_node = self.racine.appendBrother(name, "after")
-
-
-# type de noeud
-COMMENT = "COMMENTAIRE"
-PARAMETERS = "PARAMETRE"
-
-
-# ------------------------------------------
-class JDCNode(QTreeWidgetItem, GereRegles):
-# ------------------------------------------
- def __init__(self, treeParent, item, itemExpand=False, ancien=False):
- # ----------------------------------------------------------------------
- # print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, self)
- # self.a=0
-
- self.item = item
- self.vraiParent = treeParent
- self.treeParent = treeParent
- self.tree = self.treeParent.tree
- self.editor = self.treeParent.editor
- self.appliEficas = treeParent.appliEficas
- self.JESUISOFF = 0
- self.firstAffiche = True
- self.childrenComplete = []
- self.item._object.node = self
-
- from InterfaceQT4 import compocomm
- from InterfaceQT4 import compoparam
- from InterfaceQT4 import composimp
-
- if isinstance(self.item, compocomm.COMMTreeItem):
- name = tr("Commentaire")
- elif isinstance(self.item, compoparam.PARAMTreeItem):
- name = tr(str(item.getLabelText()[0]))
- else:
- name = tr(item.getLabelText()[0])
- if item.nom != tr(item.nom):
- name = str(tr(item.nom) + " :")
- value = tr(str(item.getText()))
-
- # si specialisation de la fenetre
- if self.item.object.definition == None:
- self.fenetreIhm = None
- # Cas des listes de mots_clefs
- else:
- self.fenetreIhm = self.item.object.definition.fenetreIhm
-
- if self.editor.enteteQTree == "complet":
- mesColonnes = (name, value)
- else:
- mesColonnes = (name,)
-
- if self.treeParent.plie == True:
- self.plie = True
- self.appartientAUnNoeudPlie = True
- if self.treeParent.item.isMCList():
- self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
- else:
- self.plie = False
- self.appartientAUnNoeudPlie = False
-
- # if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
-
- if ancien and itemExpand:
- self.plie = False
- if ancien and not itemExpand:
- self.plie = True
- if isinstance(self.item, composimp.SIMPTreeItem):
- self.plie = False
-
- from InterfaceQT4 import compobloc
- from InterfaceQT4 import compomclist
-
- ajoutAuParentduNoeud = 0
- self.treeParent = treeParent
- while isinstance(self.treeParent, compobloc.Node) or (
- isinstance(self.treeParent, compomclist.Node)
- and self.treeParent.item.isMCList()
- ):
- self.treeParent.childrenComplete.append(self)
- self.treeParent = self.treeParent.vraiParent
- self.treeParent.childrenComplete.append(self)
-
- if (
- isinstance(self, compobloc.Node)
- or (isinstance(self, compomclist.Node) and self.item.isMCList())
- or (
- hasattr(self.item.parent, "inhibeValidator")
- and isinstance(self, compomclist.Node)
- and self.item.parent.inhibeValidator
- )
- or (
- isinstance(self, composimp.Node)
- and self.item.definition.statut in ("c", "d")
- )
- ):
- # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
- QTreeWidgetItem.__init__(self, None, mesColonnes)
- else:
- QTreeWidgetItem.__init__(self, self.treeParent, mesColonnes)
-
- self.setToolTip(0, self.item.getFr())
- self.setToolTip(1, self.item.getFr())
- repIcon = self.appliEficas.repIcon
-
- couleur = self.item.getIconName()
- monIcone = QIcon(repIcon + "/" + couleur + ".png")
-
- self.setIcon(0, monIcone)
-
- self.children = []
- self.buildChildren()
- self.menu = None
- self.existeMenu = 1
-
- self.item.connect("valid", self.onValid, ())
- self.item.connect("supp", self.onSupp, ())
- self.item.connect("add", self.onAdd, ())
- self.item.connect("redessine", self.onRedessine, ())
-
- self.state = ""
- self.fenetre = None
- try:
- if self.item.getObject().isBLOC():
- self.setExpanded(True)
- self.plie = False
- except:
- pass
-
- def buildChildren(self, posInsertion=10000):
- # ------------------------------------------
- """Construit la liste des enfants de self"""
- """ Se charge de remettre les noeuds Expanded dans le meme etat """
- # print ("*********** buildChildren ",self,self.item, self.item.nom)
- # print (poum)
-
- self.listeItemExpanded = []
- self.listeItemPlie = []
-
- for enfant in self.childrenComplete:
- if enfant.plie:
- self.listeItemPlie.append(enfant.item)
- else:
- self.listeItemExpanded.append(enfant.item)
-
- for enfant in self.childrenComplete:
- parent = enfant.treeParent
- parent.removeChild(enfant)
- enfant.JESUISOFF = 1
-
- self.children = []
- self.childrenComplete = []
- sublist = self.item._getSubList()
- ind = 0
-
- for item in sublist:
- itemExpand = False
- ancien = False
- if item in self.listeItemExpanded:
- itemExpand = True
- ancien = True
- if item in self.listeItemPlie:
- itemExpand = False
- ancien = True
- nouvelItem = item.itemNode(self, item, itemExpand, ancien)
- self.children.append(nouvelItem)
-
- # print ("fin *********** buildChildren ",self,self.item, self.item.nom, self.children)
-
- def chercheNoeudCorrespondant(self, objSimp):
- # -------------------------------------------
- sublist = self.item._getSubList()
- for node in self.childrenComplete:
- if node.item.object == objSimp:
- return node
- return None
-
- def afficheCeNiveau(self):
- # -------------------------
- # print ('afficheCeNiveau pour ', self.item.nom, self.item.getLabelText())
- for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
- widget = self.editor.widgetCentraleLayout.itemAt(indiceWidget)
- self.editor.widgetCentraleLayout.removeItem(widget)
- if self.editor.fenetreCentraleAffichee != None:
- self.editor.widgetCentraleLayout.removeWidget(
- self.editor.fenetreCentraleAffichee
- )
- self.editor.fenetreCentraleAffichee.setParent(None)
- self.editor.fenetreCentraleAffichee.close()
- self.editor.fenetreCentraleAffichee.deleteLater()
-
- from monWidgetNiveauFact import MonWidgetNiveauFact, MonWidgetNiveauFactTableau
-
- maDefinition = self.item.get_definition()
- monObjet = self.item.object
- if maDefinition.fenetreIhm == "Tableau":
- self.maFenetreCadre = MonWidgetNiveauFactTableau(
- self, self.editor, maDefinition, monObjet
- )
- else:
- self.maFenetreCadre = MonWidgetNiveauFact(
- self, self.editor, maDefinition, monObjet
- )
-
- self.fenetre = self.maFenetreCadre
- self.editor.widgetCentraleLayout.addWidget(self.maFenetreCadre)
- self.editor.fenetreCentraleAffichee = self.maFenetreCadre
- self.select()
- # print ('fin afficheCeNiveau pour ', self.item.nom)
-
- def getPanelModifie(self):
- # -------------------------
-
- if self.fenetreIhm == None:
- return None
- if self.fenetreIhm == "deplie1Niveau":
- from InterfaceQT4.monWidgetCommandeDeplie1Niveau import (
- MonWidgetCommandeDeplie1Niveau,
- )
-
- return MonWidgetCommandeDeplie1Niveau(self, self.editor, self.item.object)
- return None
-
- def affichePanneau(self):
- # -------------------------
- # print ('_________________ds affichePanneau pour', self.item.nom)
- # pour l instant pas d inactif
- if not (self.item.isActif()):
- from .monWidgetInactif import MonWidgetInactif
-
- self.fenetre = MonWidgetInactif(self, self.editor)
- else:
- itemParent = self
- while not (hasattr(itemParent, "getPanel")):
- itemParent = itemParent.treeParent
- if itemParent != self:
- # print ('j appelle affichePanneau pour ', itemParent.item.nom , 'par', self.item.nom)
- itemParent.affichePanneau()
- # print ('fin _________________ds affichePanneau pour', self.item.nom)
- return
-
- self.fenetre = self.getPanelModifie()
- if self.fenetre == None:
- self.fenetre = self.getPanel()
- self.editor.restoreSplitterSizes()
-
- for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
- widget = self.editor.widgetCentraleLayout.itemAt(indiceWidget)
- self.editor.widgetCentraleLayout.removeItem(widget)
-
- # ceinture et bretelle
- # print 'old fenetre = ',self.editor.fenetreCentraleAffichee
- if self.editor.fenetreCentraleAffichee != None:
- try:
- self.editor.widgetCentraleLayout.removeWidget(
- self.editor.fenetreCentraleAffichee
- )
- self.editor.fenetreCentraleAffichee.setParent(None)
- self.editor.fenetreCentraleAffichee.close()
- self.editor.fenetreCentraleAffichee.deleteLater()
- # print ('en sortie du try sur la vieille fenetre')
- except:
- pass
-
- self.editor.widgetCentraleLayout.addWidget(self.fenetre)
- # print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
- self.editor.fenetreCentraleAffichee = self.fenetre
- self.tree.node_selected = self
-
- if self.editor.first:
- if not (isinstance(self.fenetre, MonChoixCommande)):
- self.editor.first = False
- self.tree.inhibeExpand = True
- self.tree.expandItem(self)
- self.tree.inhibeExpand = False
- # print( '_________________fin affichePanneau pour', self.item.nom)
-
- def createPopUpMenu(self):
- # -------------------------
- # implemente dans les noeuds derives si necessaire
- self.existeMenu = 0
-
- def commentIt(self):
- # -------------------------
- """
- Cette methode a pour but de commentariser la commande pointee par self
- """
- # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
- # (commentariser) un commentaire.
- try:
- pos = self.treeParent.children.index(self)
- commande_comment = self.item.getObjetCommentarise()
- # On signale a l editeur du panel (le JDCDisplay) une modification
- self.editor.initModif()
- self.treeParent.buildChildren()
- self.treeParent.children[pos].select()
- self.treeParent.children[pos].affichePanneau()
- except Exception as e:
- traceback.print_exc()
- QMessageBox.critical(self.editor, "TOO BAD", str(e))
-
- def unCommentIt(self):
- # -------------------------
- """
- Realise la decommentarisation de self
- """
- try:
- pos = self.treeParent.children.index(self)
- commande, nom = self.item.unComment()
- self.editor.initModif()
- self.treeParent.buildChildren()
- self.treeParent.children[pos].select()
- self.treeParent.children[pos].affichePanneau()
- except Exception as e:
- QMessageBox.critical(self.editor, "Erreur !", str(e))
-
- def addComment(self, after=True):
- # -----------------------------------
- """
- Ajoute un commentaire a l'interieur du JDC :
- """
- self.editor.initModif()
- if after:
- pos = "after"
- else:
- pos = "before"
- return self.appendBrother(COMMENT, pos)
-
- def addParameters(self, after=True):
- # -------------------------------------
- """
- Ajoute un parametre a l'interieur du JDC :
- """
- self.editor.initModif()
- if after:
- pos = "after"
- else:
- pos = "before"
- child = self.appendBrother(PARAMETERS, pos)
- return child
-
- def select(self):
- # ------------------
- """
- Rend le noeud courant (self) selectionne et deselectionne
- tous les autres
- """
- # print "select pour", self.item.nom
- for item in self.tree.selectedItems():
- item.setSelected(0)
- self.tree.setCurrentItem(self)
-
- # ------------------------------------------------------------------
- # Methodes de creation et destruction de noeuds
- # ------------------------------------------------------------------
-
- def appendBrother(self, name, pos="after", plier=False):
- # ----------------------------------------------------
- """
- Permet d'ajouter un objet frere a l'objet associe au noeud self
- par defaut on l'ajoute immediatement apres
- Methode externe
- """
- self.editor.initModif()
-
- from InterfaceQT4 import compojdc
-
- if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(
- name, pos
- ):
- return 0
-
- if self.treeParent != self.vraiParent:
- index = self.vraiParent.children.index(self)
- if pos == "before":
- index = index
- elif pos == "after":
- index = index + 1
- return self.vraiParent.appendChild(name, pos=index, plier=plier)
- else:
- index = self.treeParent.children.index(self)
- if pos == "before":
- index = index
- elif pos == "after":
- index = index + 1
- else:
- print(pos, tr(" n'est pas un index valide pour appendBrother"))
- return 0
- return self.treeParent.appendChild(name, pos=index, plier=plier)
-
- def verifiePosition(self, name, pos, aLaRacine=False):
- # ----------------------------------------------------
- if name not in self.editor.readercata.Classement_Commandes_Ds_Arbre:
- return True
- indexName = self.editor.readercata.Classement_Commandes_Ds_Arbre.index(name)
-
- etapes = self.item.getJdc().etapes
- if etapes == []:
- return True
-
- if aLaRacine == False:
- indexOu = etapes.index(self.item.object)
- else:
- indexOu = 0
-
- if pos == "after":
- indexOu = indexOu + 1
- for e in etapes[:indexOu]:
- nom = e.nom
- if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre:
- continue
- indexEtape = self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
- if indexEtape > indexName:
- comment = (
- tr("le mot clef ") + name + tr(" doit etre insere avant ") + nom
- )
- QMessageBox.information(
- None,
- tr("insertion impossible"),
- comment,
- )
- return False
- for e in etapes[indexOu:]:
- nom = e.nom
- if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre:
- continue
- indexEtape = self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
- if indexEtape < indexName:
- comment = (
- tr("le mot clef ") + name + tr(" doit etre insere apres ") + nom
- )
- QMessageBox.information(
- None,
- tr("insertion impossible"),
- comment,
- )
- return False
- return True
-
- def appendChild(self, name, pos=None, plier=False):
- # ------------------------------------------------
- """
- Methode pour ajouter un objet fils a l'objet associe au noeud self.
- On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
- ou en position intermediaire.
- Si pos vaut None, on le place a la position du catalogue.
- """
- # print ("************** appendChild ",self.item.getLabelText(), pos, plier)
- # import traceback
- # traceback.print_stack()
-
- self.editor.initModif()
- if pos == "first":
- index = 0
- elif pos == "last":
- index = len(self.children)
- elif type(pos) == int:
- index = pos # position fixee
- elif type(pos) == object:
- index = (
- self.item.getIndex(pos) + 1
- ) # pos est un item. Il faut inserer name apres pos
- elif type(name) == object:
- index = self.item.getIndexChild(name.nom)
- else:
- index = self.item.getIndexChild(name)
-
- # si on essaye d inserer a la racine
- if isinstance(self.treeParent, JDCTree) and index == 0:
- verifiePosition = self.verifiePosition(name, "first", aLaRacine=True)
- if not verifiePosition:
- return 0
-
- self.tree.inhibeExpand = True
- obj = self.item.addItem(name, index) # emet le signal 'add'
- if obj is None:
- obj = 0
- if obj == 0:
- return 0
-
- try:
- # if 1 :
- child = self.children[index]
- if plier == True:
- child.setPlie()
- else:
- child.setDeplie()
- except:
- child = self.children[index]
-
- try:
- if len(obj) > 1:
- self.buildChildren()
- except:
- pass
-
- self.tree.inhibeExpand = False
- # print (" fin append child")
- return child
-
- def deplace(self):
- # -----------------
- self.editor.initModif()
- index = self.treeParent.children.index(self) - 1
- if index < 0:
- index = 0
- ret = self.treeParent.item.deplaceEntite(self.item.getObject())
-
- def delete(self):
- # ----------------
- """
- Methode externe pour la destruction de l'objet associe au noeud
- """
- self.editor.initModif()
- index = self.vraiParent.children.index(self) - 1
- if index < 0:
- index = 0
-
- recalcule = 0
- if self.item.nom == "VARIABLE":
- recalcule = 1
- jdc = self.item.jdc
-
- ret, commentaire = self.vraiParent.item.suppItem(self.item)
- if ret == 0:
- self.editor.afficheInfos(commentaire, Qt.red)
- else:
- self.editor.afficheInfos(commentaire)
- self.treeParent.buildChildren()
- if self.treeParent.childrenComplete:
- toselect = self.treeParent.childrenComplete[index]
- else:
- toselect = self.treeParent
-
- if recalcule:
- jdc.recalculeEtatCorrelation()
- if ret == 0:
- if self.treeParent.childrenComplete:
- notdeleted = self.treeParent.childrenComplete[index + 1]
- notdeleted.select()
- else:
- toselect.select()
-
- from InterfaceQT4 import compojdc
-
- # cas ou on detruit dans l arbre sans affichage
- if isinstance(self.treeParent, compojdc.Node):
- toselect.affichePanneau()
- else:
- if self.treeParent.fenetre == None:
- return
- # print "J appelle reaffiche de browser apres delete"
- self.treeParent.fenetre.reaffiche(toselect)
-
- def deleteMultiple(self, liste=()):
- # --------------------------------
- """
- Methode externe pour la destruction d une liste de noeud
- """
- from InterfaceQT4 import compojdc
-
- self.editor.initModif()
- index = 9999
- recalcule = 0
- jdc = self.treeParent
- parentPosition = jdc
- while not (isinstance(jdc, compojdc.Node)):
- jdc = jdc.treeParent
- for noeud in liste:
- if not (isinstance(noeud.treeParent, compojdc.Node)):
- continue
- if noeud.item.nom == "VARIABLE":
- recalcule = 1
- if noeud.treeParent.children.index(noeud) < index:
- index = noeud.treeParent.children.index(noeud)
- if index < 0:
- index = 0
-
- # Cas ou on detruit dans une ETape
- if index == 9999:
- parentPosition = self.treeParent
- while not (isinstance(parentPosition, compojdc.Node)):
- index = parentPosition.treeParent.children.index(parentPosition)
- parentPosition = parentPosition.treeParent
-
- for noeud in liste:
- noeud.treeParent.item.suppItem(noeud.item)
-
- jdc.buildChildren()
- if recalcule:
- jdc.recalculeEtatCorrelation()
- try:
- toselect = parentPosition.children[index]
- except:
- toselect = jdc
- toselect.select()
- toselect.affichePanneau()
-
- #
- # ------------------------------------------------------------------
-
- def onValid(self):
- # -----------------
- # print ("onValid pour ", self.item.nom)
- if self.JESUISOFF == 1:
- return
-
- if hasattr(self, "fenetre") and self.fenetre:
- try:
- self.fenetre.setValide()
- except:
- pass
-
- # PNPN lignes suivantes a repenser
- if (
- self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION"
- ) and self.item.isValid():
- self.item.jdc.recalculeEtatCorrelation()
- if hasattr(self.item, "forceRecalcul"):
- self.forceRecalculChildren(self.item.forceRecalcul)
- self.editor.initModif()
-
- self.updateNodeValid()
- self.updateNodeLabel()
- self.updateNodeTexte()
-
- def onAdd(self, object):
- # ----------------------
- # print ("onAdd pour ", self.item.nom, object)
- if self.JESUISOFF == 1:
- return
- self.editor.initModif()
- self.buildChildren()
- if hasattr(self.item, "jdc"):
- self.item.jdc.aReafficher = True
-
- def onSupp(self, object):
- # -----------------------
- # print ("onSup pour ", self.item.nom, object)
- # import traceback
- # traceback.print_stack()
- if self.JESUISOFF == 1:
- return
- self.editor.initModif()
- self.buildChildren()
- if hasattr(self.item, "jdc"):
- self.item.jdc.aReafficher = True
-
- def onRedessine(self):
- # ---------------------
- # print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!je passe dans onRedessine pour', self.item.nom)
- self.affichePanneau()
-
- def updateNodeValid(self):
- # -----------------------
- """Cette methode remet a jour la validite du noeud (icone)
- Elle appelle isValid
- """
- repIcon = self.appliEficas.repIcon
- couleur = self.item.getIconName()
- monIcone = QIcon(repIcon + "/" + couleur + ".png")
- self.setIcon(0, monIcone)
-
- def updateNodeLabel(self):
- # -------------------------
- """Met a jour le label du noeud"""
- # print ("NODE updateNodeLabel", self.item.getLabelText())
- labeltext, fonte, couleur = self.item.getLabelText()
- # PNPN a reflechir
- if self.item.nom != tr(self.item.nom):
- labeltext = str(tr(self.item.nom) + " :")
- self.setText(0, tr(labeltext))
-
- def updateNodeLabelInBlack(self):
- # -------------------------------
- if hasattr(self.appliEficas, "noeudColore"):
- self.appliEficas.noeudColore.setForeground(0, Qt.black)
- self.appliEficas.noeudColore.updateNodeLabel
-
- def updateNodeLabelInBlue(self):
- # -------------------------------
- if hasattr(self.appliEficas, "noeudColore"):
- self.appliEficas.noeudColore.setForeground(0, Qt.black)
- self.setForeground(0, Qt.blue)
- labeltext, fonte, couleur = self.item.getLabelText()
- if self.item.nom != tr(self.item.nom):
- labeltext = str(tr(self.item.nom) + " :")
- self.setText(0, labeltext)
- self.appliEficas.noeudColore = self
-
- def updatePlusieursNodeLabelInBlue(self, liste):
- # ----------------------------------------------
- if hasattr(self.appliEficas, "listeNoeudsColores"):
- for noeud in self.appliEficas.listeNoeudsColores:
- noeud.setTextColor(0, Qt.black)
- noeud.updateNodeLabel()
- self.appliEficas.listeNoeudsColores = []
- for noeud in liste:
- noeud.setTextColor(0, Qt.blue)
- labeltext, fonte, couleur = noeud.item.getLabelText()
- if item.nom != tr(item.nom):
- labeltext = str(tr(item.nom) + " :")
- noeud.setText(0, labeltext)
- self.appliEficas.listeNoeudsColores.append(noeud)
-
- def updateNodeTexteInBlack(self):
- # --------------------------------
- """Met a jour les noms des SD et valeurs des mots-cles"""
- self.setTextColor(1, Qt.black)
- value = tr(str(self.item.getText()))
- self.setText(1, value)
-
- def updateNodeTexte(self):
- # ----------------------------
- """Met a jour les noms des SD et valeurs des mots-cles"""
- value = tr(str(self.item.getText()))
- self.setText(1, value)
-
- def updateNodeTexteInBlue(self):
- # --------------------------------
- self.setTextColor(1, Qt.blue)
- value = tr(str(self.item.getText()))
- self.setText(1, value)
-
- def updateNodes(self):
- # --------------------------------
- # print 'NODE updateNodes', self.item.getLabelText()
- self.buildChildren()
-
- def updateValid(self):
- # ----------------------
- """Cette methode a pour but de mettre a jour la validite du noeud
- et de propager la demande de mise a jour a son parent
- """
- # print "NODE updateValid", self.item.getLabelText()
- self.updateNodeValid()
- try:
- self.treeParent.updateValid()
- except:
- pass
-
- def updateTexte(self):
- # ----------------------
- """Met a jour les noms des SD et valeurs des mots-cles"""
- # print "NODE updateTexte", self.item.getLabelText()
- self.updateNodeTexte()
- if self.isExpanded():
- for child in self.children:
- if child.isHidden() == false:
- child.updateTexte()
-
- def forceRecalculChildren(self, niveau):
- # --------------------------------------
- if self.state == "recalcule":
- self.state = ""
- return
- self.state = "recalcule"
- if hasattr(self.item, "object"):
- self.item.object.state = "modified"
- for child in self.children:
- if niveau > 0:
- child.forceRecalculChildren(niveau - 1)
-
- def doPaste(self, node_selected, pos="after"):
- # --------------------------------------------
- """
- Declenche la copie de l'objet item avec pour cible
- l'objet passe en argument : node_selected
- """
- objet_a_copier = self.item.getCopieObjet()
- child = node_selected.doPasteCommande(objet_a_copier, pos)
- if self.editor.fenetreCentraleAffichee:
- self.editor.fenetreCentraleAffichee.node.affichePanneau()
- self.updateNodeLabelInBlack()
- return child
-
- def doPasteCommande(self, objet_a_copier, pos="after"):
- # -----------------------------------------------------
- """
- Realise la copie de l'objet passe en argument qui est necessairement
- un onjet
- """
- child = None
- try:
- # if 1 :
- child = self.appendBrother(objet_a_copier, pos)
- except:
- pass
- return child
-
- def doPastePremier(self, objet_a_copier):
- # ---------------------------------------
- """
- Realise la copie de l'objet passe en argument (objet_a_copier)
- """
- objet = objet_a_copier.item.getCopieObjet()
- child = self.appendChild(objet, pos="first")
- return child
-
- def plieToutEtReafficheSaufItem(self, itemADeplier):
- # ---------------------------------------------------
- self.inhibeExpand = True
- from InterfaceQT4 import compojdc
-
- if isinstance(self, compojdc.Node):
- self.affichePanneau()
- self.inhibeExpand = False
- return
- self.editor.deplier = False
- for item in self.children:
- # il ne faut pas plier les blocs
- from InterfaceQT4 import compobloc
-
- if isinstance(item, compobloc.Node):
- continue
- item.setPlie()
- if item == itemADeplier:
- itemADeplier.setDeplie()
- self.affichePanneau()
- self.inhibeExpand = False
-
- def plieToutEtReaffiche(self):
- # -----------------------------
- # print ('plieToutEtReaffiche', self.item.getNom())
- from InterfaceQT4 import compojdc
-
- if isinstance(self, compojdc.Node):
- self.affichePanneau()
- return
- self.inhibeExpand = True
- self.editor.deplier = False
- for item in self.children:
- # il ne faut pas plier les blocs
- from InterfaceQT4 import compobloc
-
- if isinstance(item, compobloc.Node):
- continue
- item.setPlie()
- self.affichePanneau()
- # print ("fin plieToutEtReaffiche", self.item.getNom())
-
- def deplieToutEtReaffiche(self):
- # -----------------------------
- self.editor.deplier = True
- for item in self.children:
- item.setDeplie()
- self.affichePanneau()
-
- def setPlie(self):
- # -----------------
- # print "je mets inhibeExpand a true dans setPlie"
- # print ("je suis dans plieTout", self.item.getNom())
- from . import compojdc
-
- if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(
- self.treeParent, compojdc.Node
- ):
- return
- self.tree.inhibeExpand = True
- self.tree.collapseItem(self)
- self.setPlieChildren()
- self.tree.inhibeExpand = False
- # print "je mets inhibeExpand a false dans setPlie"
-
- # on ne plie pas au niveau 1
- # self.plie=False
- # for item in self.children :
- # item.appartientAUnNoeudPlie=False
-
- def setPlieChildren(self):
- # -----------------------------
- self.plie = True
- from InterfaceQT4 import composimp
-
- if isinstance(self, composimp.Node):
- return
- for c in self.children:
- c.setPlieChildren()
- # print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0]
- c.appartientAUnNoeudPlie = True
- c.plie = True
- # print "dans setPlieChildren plie", c.item.nom
- # 01/2018 PNPN : boucle sur MT __ La ligne suivante ne me semble pas necessaire
- # if not (isinstance(c,composimp.Node)) :c.setExpanded(False)
-
- # Pour les blocs et les motcles list
- # on affiche un niveau de plus
- from InterfaceQT4 import compobloc
- from InterfaceQT4 import compomclist
-
- if isinstance(self, compobloc.Node) or (
- isinstance(self, compomclist.Node) and self.item.isMCList()
- ):
- niveauPere = self.treeParent
- while isinstance(niveauPere, compobloc.Node) or (
- isinstance(niveauPere, compomclist.Node) and niveauPere.item.isMCList()
- ):
- niveauPere = niveauPere.treeParent
- for c in self.children:
- c.appartientAUnNoeudPlie = niveauPere.appartientAUnNoeudPlie
- # print ("dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie)
- c.setExpanded(False)
-
- def setDeplie(self):
- # -----------------------------
- # print "dans setPlieChildren pour", self.item.nom
- # print "je mets inhibeExpand a true dans setDeplie"
- self.tree.inhibeExpand = True
- self.plie = False
- self.tree.expandItem(self)
- self.setDeplieChildren()
- self.tree.inhibeExpand = False
- # print "je mets inhibeExpand a false dans setDePlie"
-
- def setDeplieChildren(self):
- # -----------------------------
- # print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.getLabelText()
- for c in self.children:
- c.setDeplieChildren()
- # print "dans setDeplieChildren ", c.item.nom
- c.appartientAUnNoeudPlie = False
- c.setExpanded(True)
- c.plie = False
-
- def selectAvant(self):
- # -----------------------------
- i = self.item.jdc.etapes.index(self.item.object)
- try:
- cherche = self.item.jdc.etapes[i - 1]
- except:
- cherche = self.item.jdc.etapes[-1]
- node = None
- for i in self.tree.racine.children:
- if i.item.object == cherche:
- node = i
- break
- if node:
- node.affichePanneau()
- node.select()
-
- def selectApres(self):
- # ---------------------
- i = self.item.jdc.etapes.index(self.item.object)
- try:
- cherche = self.item.jdc.etapes[i + 1]
- except:
- cherche = self.item.jdc.etapes[0]
- node = None
- for i in self.tree.racine.children:
- if i.item.object == cherche:
- node = i
- break
- if node:
- node.affichePanneau()
- node.select()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from Editeur import Objecttreeitem
-
-from . import compofact
-from . import browser
-from . import typeNode
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNodeMinimal):
- def createPopUpMenu(self):
- typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
-
- def getPanelGroupe(self, parentQt, commande):
- maDefinition = self.item.get_definition()
- monObjet = self.item.object
- monNom = self.item.nom
- maCommande = commande
- if hasattr(parentQt, "niveau"):
- self.niveau = parentQt.niveau + 1
- else:
- self.niveau = 1
- from .monWidgetBloc import MonWidgetBloc
-
- widget = MonWidgetBloc(
- self, self.editor, parentQt, maDefinition, monObjet, self.niveau, maCommande
- )
-
-
-class BLOCTreeItem(compofact.FACTTreeItem):
- itemNode = Node
-
- def isCopiable(self):
- return 0
-
-
-import Accas
-
-treeitem = BLOCTreeItem
-objet = Accas.MCBLOC
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-from Editeur import Objecttreeitem
-from . import browser
-from . import typeNode
-from Extensions.i18n import tr
-from Extensions.eficas_exception import EficasException
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNodePartiel):
- def getPanel(self):
- """ """
- from .monWidgetCommentaire import MonWidgetCommentaire
-
- return MonWidgetCommentaire(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
- from PyQt5.QtWidgets import QAction
-
- self.Decommente = QAction(tr("decommenter"), self.tree)
- self.Decommente.triggered.connect(self.decommenter)
- self.Decommente.setStatusTip(tr("Decommente la commande "))
-
- if hasattr(self.item, "unComment"):
- self.menu.addAction(self.Decommente)
-
- def decommenter(self):
- item = self.tree.currentItem()
- item.unCommentIt()
-
- def updateNodeLabel(self):
- """ """
- debComm = self.item.getText()
- self.setText(1, tr(debComm))
-
-
-class COMMTreeItem(Objecttreeitem.ObjectTreeItem):
- itemNode = Node
-
- def init(self):
- self.setFunction = self.setValeur
-
- def getIconName(self):
- """
- Retourne le nom de l'icone associee au noeud qui porte self,
- dependant de la validite de l'objet
- NB : un commentaire est toujours valide ...
- """
- return "ast-white-percent"
-
- def getLabelText(self):
- """Retourne 3 valeurs :
- - le texte a afficher dans le noeud representant l'item
- - la fonte dans laquelle afficher ce texte
- - la couleur du texte
- """
- return tr("Commentaire"), None, None
-
- def getValeur(self):
- """
- Retourne la valeur de l'objet Commentaire cad son texte
- """
- return self.object.getValeur() or ""
-
- def getText(self):
- texte = self.object.valeur
- texte = texte.split("\n")[0]
- if len(texte) < 25:
- return texte
- else:
- return texte[0:24]
-
- def setValeur(self, valeur):
- """
- Affecte valeur a l'objet COMMENTAIRE
- """
- self.object.setValeur(valeur)
-
- def getSubList(self):
- """
- Retourne la liste des fils de self
- """
- return []
-
- def getObjetCommentarise(self):
- """
- La methode getObjetCommentarise() de la classe compocomm.COMMTreeItem
- surcharge la methode getObjetCommentarise de la classe Objecttreeitem.ObjectTreeItem
- elle a pour but d'empecher l'utilisateur final de commentariser un commentaire.
- """
- raise EficasException("Impossible de commentariser un commentaire")
-
-
-import Extensions
-
-treeitem = COMMTreeItem
-objet = Extensions.commentaire.COMMENTAIRE
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import traceback
-
-from Editeur import Objecttreeitem
-from Extensions.eficas_exception import EficasException
-from . import compocomm
-
-
-class COMMANDE_COMMTreeItem(Objecttreeitem.ObjectTreeItem):
- itemNode = compocomm.Node
-
- def init(self):
- self.setFunction = self.setValeur
-
- def getIconName(self):
- """
- Retourne le nom de l'icone associee au noeud qui porte self,
- dependant de la validite de l'objet
- NB : une commande commentarisee est toujours valide ...
- """
- if self.isValid():
- return "ast-green-percent"
- else:
- return "ast-red-percent"
-
- def getLabelText(self):
- """Retourne 3 valeurs :
- - le texte a afficher dans le noeud representant l'item
- - la fonte dans laquelle afficher ce texte
- - la couleur du texte
- """
- return "commentaire"
-
- def getValeur(self):
- """
- Retourne la valeur de la commande commentarisee cad son texte
- """
- return self.object.getValeur() or ""
-
- def getText(self):
- texte = self.object.valeur
- texte = texte.split("\n")[0]
- if len(texte) < 25:
- return texte
- else:
- return texte[0:24]
-
- def setValeur(self, valeur):
- """
- Afefcte valeur a l'objet commande commentarisee
- """
- self.object.setValeur(valeur)
-
- def getSubList(self):
- """
- Retourne la liste des fils de self
- """
- return []
-
- def unComment(self):
- """
- Demande a l'objet commande commentarisee de se decommentariser.
- Si l'operation s'effectue correctement, retourne l'objet commande
- et eventuellement le nom de la sd produite, sinon leve une exception
- """
- try:
- commande, nom = self.object.unComment()
- # self.parent.children[pos].select()
- except Exception as e:
- traceback.print_exc()
- raise EficasException(e)
- return commande, nom
-
-
-import Accas
-
-treeitem = COMMANDE_COMMTreeItem
-objet = Accas.COMMANDE_COMM
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from InterfaceQT4 import browser
-from InterfaceQT4 import typeNode
-from Extensions.i18n import tr
-
-from Editeur import Objecttreeitem
-import traceback
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNodePartiel):
- def getPanelGroupe(self, parentQt, commande):
- # ----------------------------------------
- maDefinition = self.item.get_definition()
- monObjet = self.item.object
- monNom = self.item.nom
- maCommande = commande
- if hasattr(parentQt, "niveau"):
- self.niveau = parentQt.niveau + 1
- else:
- self.niveau = 1
- if hasattr(self, "plie") and self.plie == True:
- from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
-
- widget = MonWidgetFactPlie(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche:
- self.firstAffiche = False
- self.setPlie()
- from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
-
- widget = MonWidgetFactPlie(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- else:
- from InterfaceQT4.monWidgetFact import MonWidgetFact
-
- widget = MonWidgetFact(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- return widget
-
- def createPopUpMenu(self):
- # ------------------------
- typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
-
-
-class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
- itemNode = Node
-
- def isExpandable(self):
- # ----------------------
- return 1
-
- def getText(self):
- # ----------------
- return ""
-
- def getLabelText(self):
- # ----------------------
- """Retourne 3 valeurs :
- - le texte à afficher dans le noeud representant l'item
- - la fonte dans laquelle afficher ce texte
- - la couleur du texte
- """
- # None --> fonte et couleur par defaut
- if not (hasattr(self.object, "getLabelText")):
- return self.object.nom, None, None
- return self.object.getLabelText(), None, None
-
- def isValid(self):
- # ----------------
- return self.object.isValid()
-
- def isCopiable(self):
- # ----------------
- return 1
-
- def getIconName(self):
- # ----------------
- if self.object.isValid():
- return "ast-green-los"
- elif self.object.isOblig():
- return "ast-red-los"
- else:
- return "ast-yel-los"
-
- # PNPN ????
- # def keys(self):
- # keys=self.object.mc_dict
- # return keys
-
- def getSubList(self):
- # ----------------
- """
- Reactualise la liste des items fils stockes dans self.sublist
- """
- liste = self.object.mcListe
- sublist = [None] * len(liste)
- # suppression des items lies aux objets disparus
- for item in self.sublist:
- old_obj = item.getObject()
- if old_obj in liste:
- pos = liste.index(old_obj)
- sublist[pos] = item
- else:
- pass # objets supprimes ignores
- # ajout des items lies aux nouveaux objets
- pos = 0
- for obj in liste:
- if sublist[pos] is None:
- # nouvel objet : on cree un nouvel item
- def setFunction(value, object=obj):
- object.setval(value)
-
- item = self.makeObjecttreeitem(
- self.appliEficas, obj.nom + " : ", obj, setFunction
- )
- sublist[pos] = item
- pos = pos + 1
-
- self.sublist = sublist
- return self.sublist
-
- def addItem(self, name, pos):
- objet = self.object.addEntite(name, pos)
- return objet
-
- def suppItem(self, item):
- """
- Cette methode a pour fonction de supprimer l'item passee en argument
- des fils de l'item FACT qui est son pere
- - item = item du MOCLE a supprimer du MOCLE pere
- - item.getObject() = MCSIMP ou MCBLOC
- """
- itemobject = item.getObject()
- if itemobject.isOblig():
- return (0, tr("Impossible de supprimer un mot-cle obligatoire "))
-
- if self.object.suppEntite(itemobject):
- message = tr("Mot-cle %s supprime") + itemobject.nom
- return (1, message)
- else:
- return (0, tr("Pb interne : impossible de supprimer ce mot-cle"))
-
-
-import Accas
-
-objet = Accas.MCFACT
-treeitem = FACTTreeItem
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 contient les classes permettant de definir les objets graphiques
-representant un objet de type FORMULE, cad le panneau et l'item de l'arbre
-d'EFICAS
-"""
-
-from . import compooper
-from . import browser
-from . import typeNode
-
-
-class FormuleNode(browser.JDCNode, typeNode.PopUpMenuNode):
- def getPanel(self):
- from .monWidgetFormule import MonWidgetFormule
-
- return MonWidgetFormule(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
-
-class FORMULETreeItem(compooper.EtapeTreeItem):
- """
- Classe servant a definir l'item porte par le noeud de l'arbre d'EFICAS
- qui represente la FORMULE
- """
-
- itemNode = FormuleNode
-
- def init(self):
- self.setFunction = self.setValeur
-
- # ---------------------------------------------------------------------------
- # API de FORMULE pour l'arbre
- # ---------------------------------------------------------------------------
- def getSubList(self):
- """
- Retourne la liste des fils de self
- On considere que FORMULE n'a pas de fils
- --> modification par rapport a MACRO classique
- """
- # dans EFICAS on ne souhaite pas afficher les mots-cles fils de FORMULE
- # de facon traditionnelle
- return []
-
- def getIconName(self):
- """
- Retourne le nom de l'icone a afficher dans l'arbre
- Ce nom depend de la validite de l'objet
- """
- if self.object.isActif():
- if self.object.isValid():
- return "ast-green-square"
- else:
- return "ast-red-square"
- else:
- return "ast-white-text"
-
- def getLabelText(self):
- """Retourne 3 valeurs :
- - le texte a afficher dans le noeud representant l'item
- - la fonte dans laquelle afficher ce texte
- - la couleur du texte
- """
- return self.labeltext, None, None
- # if self.object.isActif():
- # None --> fonte et couleur par defaut
- # return tr(self.labeltext),None,None
- # else:
- # return tr(self.labeltext),None,None
- # return self.labeltext,fontes.standard_italique,None
-
- # ---------------------------------------------------------------------------
- # Methodes permettant la modification et la lecture des attributs
- # du parametre = API graphique de la FORMULE pour Panel et EFICAS
- # ---------------------------------------------------------------------------
-
- def getNom(self):
- """
- Retourne le nom de la FORMULE
- """
- return self.object.getNom()
-
- def getType(self):
- """
- Retourne le type de la valeur retournee par la FORMULE
- """
- return self.object.type_retourne
-
- def getArgs(self):
- """
- Retourne les arguments de la FORMULE
- """
- args = ""
- for mot in self.object.mcListe:
- if mot.nom == "NOM_PARA":
- args = mot.valeur
- break
- if args:
- if args[0] == "(" and args[-1] == ")":
- args = args[1:-1]
- # transforme en tuple si ce n est pas deja le casa
- try:
- args = args.split(",")
- except:
- pass
- return args
-
- def getCorps(self):
- """
- Retourne le corps de la FORMULE
- """
- corps = ""
- for mot in self.object.mcListe:
- if mot.nom == "VALE":
- corps = mot.valeur
- break
- return corps
-
- def getListeTypesAutorises(self):
- """
- Retourne la liste des types autorises pour les valeurs de sortie
- d'une FORMULE
- """
- return self.object.l_types_autorises
-
- def saveFormule(self, new_nom, new_typ, new_arg, new_exp):
- """
- Verifie si (new_nom,new_typ,new_arg,new_exp) definit bien une FORMULE
- licite :
- - si oui, stocke ces parametres comme nouveaux parametres de la
- FORMULE courante et retourne 1
- - si non, laisse les parametres anciens de la FORMULE inchanges et
- retourne 0
- """
- test, erreur = self.object.verifFormule_python(
- formule=(new_nom, new_typ, new_arg, new_exp)
- )
- if test:
- # la formule est bien correcte : on sauve les nouveaux parametres
- test = self.object.updateFormulePython(
- formule=(new_nom, new_typ, new_exp, new_arg)
- )
- return test, erreur
-
- # ---------------------------------------------------------------------------
- # Acces aux methodes de verification de l'objet FORM_ETAPE
- # ---------------------------------------------------------------------------
-
- def verifNom(self, nom):
- """
- Lance la verification du nom passe en argument
- """
- return self.object.verifNom(nom)
-
- def verifArguments(self, arguments):
- """
- Lance la verification des arguments passes en argument
- """
- return self.object.verifArguments("(" + arguments + ")")
-
- def verifFormule(self, formule):
- """
- Lance la verification de FORMULE passee en argument
- """
- return self.object.verifFormule(formule=formule)
-
- def verifFormule_python(self, formule):
- """
- Lance la verification de FORMULE passee en argument
- """
- return self.object.verifFormule_python(formule=formule)
-
-
-import Accas
-
-treeitem = FORMULETreeItem
-objet = Accas.FORM_ETAPE
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from Editeur import Objecttreeitem
-from . import browser
-from . import typeNode
-from Extensions.i18n import tr
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuRacine):
- def getPanel(self):
- from .monChoixCommande import MonChoixCommande
- return MonChoixCommande(self, self.item, self.editor)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuRacine.createPopUpMenu(self)
-
- def addParameters(self, apres):
- param = self.appendChild("PARAMETRE", pos=0)
- return param
-
-
-class JDCTreeItem(Objecttreeitem.ObjectTreeItem):
- itemNode = Node
-
- def isExpandable(self):
- return 1
-
- def getText(self):
- return " "
-
- def getLabelText(self):
- # None --> fonte et couleur par defaut
- return tr(self.object.nom), None, None
-
- def getJdc(self):
- """
- Retourne l'objet pointe par self
- """
- return self.object
-
- def getIconName(self):
- if self.object.isValid():
- return "ast-green-square"
- else:
- return "ast-red-square"
-
- # def keys(self):
- # if self.object.etapes_niveaux != []:
- # return range(len(self.object.etapes_niveaux))
- # else:
- # return range(len(self.object.etapes))
-
- def addItem(self, name, pos):
- cmd = self._object.addEntite(name, pos)
- return cmd
-
- def suppItem(self, item):
- # item = item de l'ETAPE a supprimer du JDC
- # item.getObject() = ETAPE ou COMMENTAIRE
- # self.object = JDC
-
- itemobject = item.getObject()
- if self.object.suppEntite(itemobject):
- if itemobject.nature == "COMMENTAIRE":
- message = tr("Commentaire supprime")
- else:
- message = tr("Commande %s supprimee", itemobject.nom)
- return 1, message
- else:
- message = tr("Pb interne : impossible de supprimer cet objet")
- return 0, message
-
- def getSubList(self):
- """
- Retourne la liste des items fils de l'item jdc.
- Cette liste est conservee et mise a jour a chaque appel
- """
- if self.object.etapes_niveaux != []:
- liste = self.object.etapes_niveaux
- else:
- liste = self.object.etapes
- sublist = [None] * len(liste)
- # suppression des items lies aux objets disparus
- for item in self.sublist:
- old_obj = item.getObject()
- if old_obj in liste:
- pos = liste.index(old_obj)
- sublist[pos] = item
- else:
- pass # objets supprimes ignores
- # ajout des items lies aux nouveaux objets
- pos = 0
- for obj in liste:
- if sublist[pos] is None:
- # nouvel objet : on cree un nouvel item
- item = self.makeObjecttreeitem(self.appliEficas, obj.nom + " : ", obj)
- sublist[pos] = item
- pos = pos + 1
-
- self.sublist = sublist
- return self.sublist
-
- def getLNomsEtapes(self):
- """Retourne la liste des noms des etapes de self.object"""
- return self.object.getLNomsEtapes()
-
- def getListeCmd(self):
- listeCmd = self.object.niveau.definition.getListeCmd()
- return listeCmd
-
-
-import Accas
-
-treeitem = JDCTreeItem
-objet = Accas.JDC
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 os, sys
-import types
-import traceback
-
-# Modules Eficas
-from Editeur import Objecttreeitem
-from Extensions.i18n import tr
-from InterfaceQT4 import compooper
-from InterfaceQT4 import browser
-from InterfaceQT4 import typeNode
-
-
-class MACRONode(browser.JDCNode, typeNode.PopUpMenuNode):
- def getPanel(self):
- from .monWidgetCommande import MonWidgetCommande
-
- return MonWidgetCommande(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
-
-# def view3D(self) :
-# from Editeur import TroisDPal
-# troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
-# troisD.envoievisu()
-
-
-class MACROTreeItem(compooper.EtapeTreeItem):
- # """ Cette classe herite d'une grande partie des comportements
- # de la classe compooper.EtapeTreeItem
- # """
- itemNode = MACRONode
-
-
-# ------------------------------------
-# Classes necessaires a INCLUDE
-# ------------------------------------
-
-
-class INCLUDETreeItemBase(MACROTreeItem):
- def __init__(self, appliEficas, labeltext, object, setFunction):
- MACROTreeItem.__init__(self, appliEficas, labeltext, object, setFunction)
-
- def isCopiable(self):
- return 0
-
-
-class INCLUDENode(browser.JDCNode, typeNode.PopUpMenuNode):
- def getPanel(self):
- from .monWidgetCommande import MonWidgetCommande
-
- return MonWidgetCommande(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
- def makeEdit(self): # ,appliEficas,node
- if self.item.object.text_converted == 0:
- # Le texte du fichier inclus n'a pas pu etre converti par le module convert
- msg = tr(
- "Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n"
- )
- msg = msg + self.item.object.text_error
- return
-
- if not hasattr(self.item.object, "jdc_aux") or self.item.object.jdc_aux is None:
- # L'include n'est pas initialise
- self.item.object.buildInclude(None, "")
-
- # On cree un nouvel onglet dans le bureau
- self.editor.vm.displayJDC(
- self.item.object.jdc_aux, self.item.object.jdc_aux.nom
- )
-
-
-class INCLUDETreeItem(INCLUDETreeItemBase):
- itemNode = INCLUDENode
-
-
-# ------------------------------------
-# Classes necessaires a POURSUITE
-# ------------------------------------
-
-
-class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
- def getPanel(self):
- from .monWidgetCommande import MonWidgetCommande
-
- return MonWidgetCommande(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
- def makeEdit(self): # ,appliEficas,node
- if self.item.object.text_converted == 0:
- msg = tr(
- "Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n"
- )
- msg = msg + self.item.object.text_error
- return
-
- if not hasattr(self.item.object, "jdc_aux") or self.item.object.jdc_aux is None:
- text = """DEBUT()
- FIN()"""
- self.object.buildPoursuite(None, text)
-
- # On cree un nouvel onglet dans le bureau
- self.editor.vm.displayJDC(
- self.item.object.jdc_aux, self.item.object.jdc_aux.nom
- )
-
-
-class POURSUITETreeItem(INCLUDETreeItemBase):
- itemNode = POURSUITENode
-
-
-# ----------------------------------------
-# Classes necessaires a INCLUDE MATERIAU
-# ----------------------------------------
-
-
-class MATERIAUNode(MACRONode):
- def getPanel(self):
- from .monWidgetCommande import MonWidgetCommande
-
- return MonWidgetCommande(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
- def makeView(self):
- if (
- hasattr(self.item.object, "fichier_ini")
- and self.item.object.fichier_ini == None
- ):
- QMessageBox.information(
- self,
- tr("Include vide"),
- tr("L'include doit etre correctement initialise pour etre visualise"),
- )
- return
- f = open(self.item.object.fichier_ini, "rb")
- texte = f.read()
- f.close()
- from desVisu import DVisu
-
- monVisuDialg = DVisu(parent=self.editor.appliEficas, fl=0)
- monVisuDialg.TB.setText(texte)
- monVisuDialg.show()
-
-
-class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
- itemNode = MATERIAUNode
-
-
-# ------------------------------------
-# TreeItem
-# ------------------------------------
-
-
-def treeitem(appliEficas, labeltext, object, setFunction=None):
- """Factory qui retourne l'item adapte au type de macro :
- INCLUDE, POURSUITE, MACRO
- """
- if object.nom == "INCLUDE_MATERIAU":
- return INCLUDE_MATERIAUTreeItem(appliEficas, labeltext, object, setFunction)
- elif object.nom == "INCLUDE" or object.nom == "DICTDATA":
- return INCLUDETreeItem(appliEficas, labeltext, object, setFunction)
- elif object.nom == "POURSUITE":
- return POURSUITETreeItem(appliEficas, labeltext, object, setFunction)
- else:
- return MACROTreeItem(appliEficas, labeltext, object, setFunction)
-
-
-import Accas
-
-objet = Accas.MACRO_ETAPE
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-
-import types
-import traceback
-
-from . import compofact
-from . import browser
-from . import typeNode
-from Extensions.i18n import tr
-
-from Editeur import Objecttreeitem
-from Noyau.N_OBJECT import ErrorObj
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNodeMinimal):
- def createPopUpMenu(self):
- typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
-
- def getPanelGroupe(self, parentQt, commande):
- maDefinition = self.item.get_definition()
- monObjet = self.item.object
- monNom = self.item.nom
- maCommande = commande
- if hasattr(parentQt, "niveau"):
- self.niveau = parentQt.niveau + 1
- else:
- self.niveau = 1
- # attention si l objet est une mclist on utilise bloc
- if not (monObjet.isMCList()):
- if hasattr(self, "plie") and self.plie == True:
- from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
-
- widget = MonWidgetFactPlie(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche:
- self.firstAffiche = False
- self.setPlie()
- from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
-
- widget = MonWidgetFactPlie(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- else:
- from InterfaceQT4.monWidgetFact import MonWidgetFact
-
- widget = MonWidgetFact(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- else:
- from InterfaceQT4.monWidgetBloc import MonWidgetBloc
-
- widget = MonWidgetBloc(
- self,
- self.editor,
- parentQt,
- maDefinition,
- monObjet,
- self.niveau,
- maCommande,
- )
- return widget
-
- def doPaste(self, node_selected, pos):
- objet_a_copier = self.item.getCopieObjet()
- # before est un effet de bord heureux sur l index
- child = self.appendBrother(objet_a_copier, "before")
- if self.editor.fenetreCentraleAffichee:
- self.editor.fenetreCentraleAffichee.node.affichePanneau()
- self.update_NodeLabelInBlack()
- self.parent().buildChildren()
- return child
-
-
-class MCListTreeItem(Objecttreeitem.SequenceTreeItem, compofact.FACTTreeItem):
- """La classe MCListTreeItem joue le role d'un adaptateur pour les objets
- du noyau Accas instances de la classe MCLIST.
- Elle adapte ces objets pour leur permettre d'etre integres en tant que
- noeuds dans un arbre graphique (voir treewidget.py et ObjectTreeItem.py).
- Cette classe delegue les appels de methode et les acces
- aux attributs a l'objet du noyau soit manuellement soit
- automatiquement (voir classe Delegate et attribut object).
- """
-
- itemNode = Node
-
- def init(self):
- # Si l'objet Accas (MCList) a moins d'un mot cle facteur
- # on utilise directement ce mot cle facteur comme delegue
- self.updateDelegate()
-
- def updateDelegate(self):
- if len(self._object) > 1:
- self.setDelegate(self._object)
- else:
- self.setDelegate(self._object.data[0])
-
- def panel(self, jdcdisplay, pane, node):
- """Retourne une instance de l'objet panneau associe a l'item (self)
- Si la liste ne contient qu'un mot cle facteur, on utilise le panneau
- FACTPanel.
- Si la liste est plus longue on utilise le panneau MCLISTPanel.
- """
- if len(self._object) > 1:
- return MCLISTPanel(jdcdisplay, pane, node)
- elif isinstance(self._object.data[0], ErrorObj):
- return compoerror.ERRORPanel(jdcdisplay, pane, node)
- else:
- return compofact.FACTPanel(jdcdisplay, pane, node)
-
- def isExpandable(self):
- if len(self._object) > 1:
- return Objecttreeitem.SequenceTreeItem.isExpandable(self)
- else:
- return compofact.FACTTreeItem.isExpandable(self)
-
- def getSubList(self):
- self.updateDelegate()
- if len(self._object) <= 1:
- self._object.data[0].alt_parent = self._object
- return compofact.FACTTreeItem.getSubList(self)
-
- liste = self._object.data
- sublist = [None] * len(liste)
- # suppression des items lies aux objets disparus
- for item in self.sublist:
- old_obj = item.getObject()
- if old_obj in liste:
- pos = liste.index(old_obj)
- sublist[pos] = item
- else:
- pass # objets supprimes ignores
- # ajout des items lies aux nouveaux objets
- pos = 0
- for obj in liste:
- if sublist[pos] is None:
- # nouvel objet : on cree un nouvel item
- def setFunction(value, object=obj):
- object = value
-
- item = self.makeObjecttreeitem(
- self.appliEficas, obj.nom + " : ", obj, setFunction
- )
- sublist[pos] = item
- # Attention : on ajoute une information supplementaire pour l'actualisation de
- # la validite. L'attribut parent d'un MCFACT pointe sur le parent de la MCLISTE
- # et pas sur la MCLISTE elle meme ce qui rompt la chaine de remontee des
- # informations de validite. alt_parent permet de remedier a ce defaut.
- obj.alt_parent = self._object
- pos = pos + 1
-
- self.sublist = sublist
- return self.sublist
-
- def getIconName(self):
- if self._object.isValid():
- return "ast-green-los"
- elif self._object.isOblig():
- return "ast-red-los"
- else:
- return "ast-yel-los"
-
- def getDocu(self):
- """Retourne la clef de doc de l'objet pointe par self"""
- return self.object.getDocu()
-
- def isCopiable(self):
- if len(self._object) > 1:
- return Objecttreeitem.SequenceTreeItem.isCopiable(self)
- else:
- return compofact.FACTTreeItem.isCopiable(self)
-
- def isMCFact(self):
- """
- Retourne 1 si l'objet pointe par self est un MCFact, 0 sinon
- """
- return len(self._object) <= 1
-
- def isMCList(self):
- """
- Retourne 1 si l'objet pointe par self est une MCList, 0 sinon
- """
- return len(self._object) > 1
-
- def getCopieObjet(self):
- return self._object.data[0].copy()
-
- def addItem(self, obj, pos):
- # print "compomclist.addItem",obj,pos
- if len(self._object) <= 1:
- return compofact.FACTTreeItem.addItem(self, obj, pos)
-
- o = self.object.addEntite(obj, pos)
- return o
-
- def suppItem(self, item):
- """
- Retire un objet MCFACT de la MCList (self.object)
- """
- # print "compomclist.suppItem",item
- obj = item.getObject()
- if len(self._object) <= 1:
- return compofact.FACTTreeItem.suppItem(self, item)
-
- if self.object.suppEntite(obj):
- if len(self._object) == 1:
- self.updateDelegate()
- message = "Mot-clef " + obj.nom + " supprime"
- return (1, message)
- else:
- return (0, tr("Impossible de supprimer ce mot-clef"))
-
-
-import Accas
-
-objet = Accas.MCList
-
-
-def treeitem(appliEficas, labeltext, object, setFunction):
- """Factory qui produit un objet treeitem adapte a un objet
- Accas.MCList (attribut objet de ce module)
- """
- return MCListTreeItem(appliEficas, labeltext, object, setFunction)
+++ /dev/null
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2024 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
-#
-from builtins import str
-import os
-import tempfile
-
-from Extensions.i18n import tr
-from Extensions.eficas_exception import EficasException
-
-from Editeur import Objecttreeitem
-from . import browser
-from . import typeNode
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNode):
- def select(self):
- browser.JDCNode.select(self)
- self.treeParent.tree.openPersistentEditor(self, 1)
- self.monWidgetNom = self.treeParent.tree.itemWidget(self, 1)
- self.monWidgetNom.returnPressed.connect(self.nomme)
- if self.item.getIconName() == "ast-red-square":
- self.monWidgetNom.setDisabled(True)
- # else : self.monWidgetNom.setFocus() ;self.monWidgetNom.setDisabled(False)
-
- def nomme(self):
- nom = str(self.monWidgetNom.text())
- self.editor.initModif()
- test, mess = self.item.nommeSd(nom)
- if test == 0:
- self.editor.afficheInfos(mess, "red")
- old = self.item.getText()
- self.monWidgetNom.setText(old)
- else:
- self.editor.afficheCommentaire(tr("Nommage du concept effectue"))
- self.onValid()
- try:
- self.fenetre.LENom.setText(nom)
- except:
- pass
-
- def getPanel(self):
- from .monWidgetCommande import MonWidgetCommande
-
- return MonWidgetCommande(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
-
-# def view3D(self) :
-# from Editeur import TroisDPal
-# troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
-# troisD.envoievisu()
-
-
-class EtapeTreeItem(Objecttreeitem.ObjectTreeItem):
- """La classe EtapeTreeItem est un adaptateur des objets ETAPE du noyau
- Accas. Elle leur permet d'etre affichés comme des noeuds
- d'un arbre graphique.
- Cette classe a entre autres deux attributs importants :
- - _object qui est un pointeur vers l'objet du noyau
- - object qui pointe vers l'objet auquel sont délégués les
- appels de méthode et les acces aux attributs
- Dans le cas d'une ETAPE, _object et object pointent vers le
- meme objet.
- """
-
- itemNode = Node
-
- def isExpandable(self):
- return 1
-
- def getIconName(self):
- """
- Retourne le nom de l'icone a afficher dans l'arbre
- Ce nom depend de la validite de l'objet
- """
- if not self.object.isActif():
- return "ast-white-square"
- elif self.object.isValid():
- return "ast-green-square"
- else:
- valid = self.validChild()
- valid = valid * self.validRegles("non")
- if self.reste_val != {}:
- valid = 0
- if valid == 0:
- return "ast-red-square"
- else:
- try:
- # on traite ici le cas d include materiau
- # print self.object.definition.nom
- if self.object.fichier_ini != self.object.nom_mater:
- return "ast-red-square"
- except:
- pass
- return "ast-yellow-square"
-
- def getLabelText(self):
- """Retourne 3 valeurs :
- - le texte a afficher dans le noeud représentant l'item
- - la fonte dans laquelle afficher ce texte
- - la couleur du texte
- """
- return self.labeltext, None, None
- # if self.object.isActif():
- # None --> fonte et couleur par défaut
- # return self.labeltext,None,None
- # else:
- # return self.labeltext, None, None #CS_pbruno todo
-
- # def get_objet(self,name) :
- # for v in self.object.mcListe:
- # if v.nom == name : return v
- # return None
-
- # def getType_sd_prod(self):
- # """
- # Retourne le nom du type du concept résultat de l'étape
- # """
- # sd_prod=self.object.getType_produit()
- # if sd_prod:
- # return sd_prod.__name__
- # else:
- # return ""
-
- def addItem(self, name, pos):
- mcent = self._object.addEntite(name, pos)
- return mcent
-
- def suppItem(self, item):
- # item : item du MOCLE de l'ETAPE a supprimer
- # item.getObject() = MCSIMP, MCFACT, MCBLOC ou MCList
- itemobject = item.getObject()
- if itemobject.isOblig():
- return (0, tr("Impossible de supprimer un mot-clef obligatoire "))
- if self.object.suppEntite(itemobject):
- message = tr("Mot-clef %s supprime ", itemobject.nom)
- return (1, message)
- else:
- return (0, tr("Pb interne : impossible de supprimer ce mot-clef"))
-
- def getText(self):
- try:
- return self.object.getSdname()
- except:
- return ""
-
- # PNPN ????
- # def keys(self):
- # keys=self.object.mc_dict
- # return keys
-
- def getSubList(self):
- """
- Reactualise la liste des items fils stockes dans self.sublist
- """
- if self.isActif():
- liste = self.object.mcListe
- else:
- liste = []
-
- sublist = [None] * len(liste)
- # suppression des items lies aux objets disparus
- for item in self.sublist:
- old_obj = item.getObject()
- if old_obj in liste:
- pos = liste.index(old_obj)
- sublist[pos] = item
- else:
- pass # objets supprimes ignores
-
- # ajout des items lies aux nouveaux objets
- pos = 0
- for obj in liste:
- if sublist[pos] is None:
- # nouvel objet : on cree un nouvel item
- def setFunction(value, object=obj):
- object.setval(value)
-
- item = self.makeObjecttreeitem(
- self.appliEficas, obj.nom + " : ", obj, setFunction
- )
- sublist[pos] = item
- pos = pos + 1
-
- self.sublist = sublist
- return self.sublist
-
- def isValid(self):
- return self.object.isValid()
-
- def isCopiable(self):
- """
- Retourne 1 si l'objet est copiable, 0 sinon
- """
- return 1
-
- def updateDeplace(self, item):
- if item.sd and item.sd.nom:
- self.object.sd = item.sd
- self.object.sd.nom = item.sd.nom
-
- def update(self, item):
- if item.sd and item.sd.nom:
- self.nommeSd(item.sd.nom)
-
- def nommeSd(self, nom):
- """Lance la méthode de nommage de la SD"""
- oldnom = ""
- if self.object.sd != None:
- oldnom = self.object.sd.nom
- test, mess = self.object.nommeSd(nom)
- if test:
- self.object.parent.resetContext()
- if test and oldnom in self.appliEficas.dict_reels:
- self.appliEficas.dict_reels[nom] = self.appliEficas.dict_reels[oldnom]
- return test, mess
-
- def isReentrant(self):
- return self.object.isReentrant()
-
- def getNomsSdOperReentrant(self):
- return self.object.getNomsSdOperReentrant()
-
- def getObjetCommentarise(self):
- """
- Cette méthode retourne un objet commentarisé
- représentatif de self.object
- """
- # Format de fichier utilisé
- format = self.appliEficas.formatFichierIn
- return self.object.getObjetCommentarise(format)
-
- def getObjetCommentarise_BAK(self):
- """
- Cette méthode retourne un objet commentarisé
- représentatif de self.object
- """
- import generator, Accas
-
- # Format de fichier utilisé
- format = self.appliEficas.format_fichier
- g = generator.plugins[format]()
- texte_commande = g.gener(self.object, format="beautifie")
- # Il faut enlever la premiere ligne vide de texte_commande que
- # rajoute le generator
- rebut, texte_commande = texte_commande.split("\n", 1)
- # on construit l'objet COMMANDE_COMM repésentatif de self mais non
- # enregistré dans le jdc
- commande_comment = Accas.COMMANDE_COMM(
- texte=texte_commande, reg="non", parent=self.object.parent
- )
- commande_comment.niveau = self.object.niveau
- commande_comment.jdc = commande_comment.parent = self.object.jdc
-
- pos = self.object.parent.etapes.index(self.object)
- parent = self.object.parent
- self.object.parent.suppEntite(self.object)
- parent.addEntite(commande_comment, pos)
-
- return commande_comment
-
-
-import Accas
-
-treeitem = EtapeTreeItem
-objet = Accas.ETAPE
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 contient les classes permettant de definir les objets graphiques
- representant un objet de type PARAMETRE, cad le panneau et l'item de l'arbre
- d'EFICAS
-"""
-# import modules Python
-import types
-from Extensions.i18n import tr
-
-# import modules EFICAS
-from Editeur import Objecttreeitem
-from . import browser
-from . import typeNode
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNodePartiel):
- def getPanel(self):
- """ """
- from .monWidgetParam import MonWidgetParam
-
- return MonWidgetParam(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
- self.menu.removeAction(self.Documentation)
-
- def doPaste(self, node_selected, pos="after"):
- return None
-
-
-class PARAMTreeItem(Objecttreeitem.ObjectTreeItem):
- """
- Classe servant a definir l'item porte par le noeud de l'arbre d'EFICAS
- qui represente le PARAMETRE
- """
-
- itemNode = Node
-
- def init(self):
- self.setFunction = self.setValeur
-
- # ---------------------------------------------------------------------------
- # API du PARAMETRE pour l'arbre
- # ---------------------------------------------------------------------------
-
- def getIconName(self):
- """
- Retourne le nom de l'icone associee au noeud qui porte self,
- dependant de la validite de l'objet
- NB : un PARAMETRE est toujours valide ...
- """
- if self.isActif():
- if self.isValid():
- return "ast-green-square"
- else:
- return "ast-red-square"
- else:
- return "ast-white-square"
-
- def getLabelText(self):
- """Retourne 3 valeurs :
- - le texte a afficher dans le noeud representant l'item
- - la fonte dans laquelle afficher ce texte
- - la couleur du texte
- """
- return tr("PARAMETRE"), None, None
-
- def getText(self):
- """
- Retourne le texte a afficher apres le nom de la commande (ici apres 'parametre')
- Ce texte est tronque a 25 caracteres
- """
- texte = self.object.nom + "=" + str(self.object.valeur)
- if type(self.object.valeur) == list:
- texte = self.nom + " = ["
- for l in self.object.valeur:
- texte = texte + str(l) + ","
- texte = texte[0:-1] + "]"
- texte = texte.split("\n")[0]
- if len(texte) < 25:
- return texte
- else:
- return texte[0:24] + "..."
-
- def getSubList(self):
- """
- Retourne la liste des fils de self
- """
- return []
-
- # ---------------------------------------------------------------------------
- # Methodes permettant la modification et la lecture des attributs
- # du parametre = API graphique du PARAMETRE pour Panel et EFICAS
- # ---------------------------------------------------------------------------
-
- def getValeur(self):
- """
- Retourne la valeur de l'objet PARAMETRE cad son texte
- """
- if self.object.valeur is None:
- return ""
- else:
- return self.object.valeur
-
- def getNom(self):
- """
- Retourne le nom du parametre
- """
- return self.object.nom
-
- def setValeur(self, new_valeur):
- """
- Affecte valeur a l'objet PARAMETRE
- """
- self.object.setValeur(new_valeur)
-
- def setNom(self, new_nom):
- """
- Renomme le parametre
- """
- self.object.setNom(new_nom)
- # self.object.setAttribut('nom',new_nom)
-
- def getFr(self):
- """
- Retourne le fr associe au parametre, cad la bulle d'aide pour EFICAS
- """
- return tr("Definition d'un parametre")
-
-
-import Extensions.parametre
-
-treeitem = PARAMTreeItem
-objet = Extensions.parametre.PARAMETRE
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from Editeur import Objecttreeitem
-from . import compooper
-from . import browser
-from . import typeNode
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNode):
- def getPanel(self):
- # print "getPanel de compoproc"
- from .monWidgetCommande import MonWidgetCommande
-
- return MonWidgetCommande(self, self.editor, self.item.object)
-
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
-
-
-class ProcEtapeTreeItem(compooper.EtapeTreeItem):
- itemNode = Node
-
-
-import Accas
-
-treeitem = ProcEtapeTreeItem
-objet = Accas.PROC_ETAPE
+++ /dev/null
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2024 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 types, os
-
-from copy import copy, deepcopy
-import traceback
-from InterfaceQT4 import typeNode
-
-# Modules Eficas
-from Editeur import Objecttreeitem
-from InterfaceQT4 import browser
-from Noyau.N_CR import justifyText
-from Accas import SalomeEntry
-from Accas import ASSD
-from Accas import UserASSD
-from Accas import UserASSDMultiple
-
-
-class Node(browser.JDCNode, typeNode.PopUpMenuNodeMinimal):
- def createPopUpMenu(self):
- typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
-
- def getPanelGroupe(self, parentQt, maCommande):
- # print (self,self.item.nom, )
- maDefinition = self.item.get_definition()
- monObjet = self.item.object
- monNom = self.item.nom
-
- # le mot clef est cache ou cache avec defaut
- if maDefinition.statut in ("c", "d"):
- return None
- # label informatif
- if monObjet.isInformation():
- from InterfaceQT4.monWidgetInfo import MonWidgetInfo
-
- widget = MonWidgetInfo(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- self.widget = widget
- return widget
-
- # Attention l ordre des if est important
- # Attention il faut gerer les blocs et les facteurs
- # a gerer comme dans composimp
- # Gestion des matrices
- if self.item.waitMatrice():
- from InterfaceQT4.monWidgetMatrice import MonWidgetMatrice
-
- widget = MonWidgetMatrice(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- self.widget = widget
- return widget
-
- # print "____________________________", monNom, self.item.waitCo()
- # print "____________________________", monNom, self.item.waitAssd()
- # Gestion d'une seule valeur (eventuellement un tuple ou un complexe)
- if maDefinition.into != [] and maDefinition.into != None:
- if type(maDefinition.into) == types.FunctionType:
- monInto = maDefinition.into()
- else:
- monInto = maDefinition.into
-
- if maDefinition.max == 1:
- # A verifier
- if maDefinition.intoSug != [] and maDefinition.intoSug != None:
- from InterfaceQT4.monWidgetCBIntoSug import MonWidgetCBIntoSug
-
- widget = MonWidgetCBIntoSug(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif maDefinition.into != [] and maDefinition.into != None:
- if maDefinition.fenetreIhm == "menuDeroulant":
- from InterfaceQT4.monWidgetCB import MonWidgetCB
-
- widget = MonWidgetCB(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif len(monInto) < 4:
- from InterfaceQT4.monWidgetRadioButton import MonWidgetRadioButton
-
- widget = MonWidgetRadioButton(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif len(monInto) < 7:
- from InterfaceQT4.monWidget4a6RadioButton import (
- MonWidget4a6RadioButton,
- )
-
- widget = MonWidget4a6RadioButton(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetCB import MonWidgetCB
-
- widget = MonWidgetCB(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.waitBool():
- from InterfaceQT4.monWidgetSimpBool import MonWidgetSimpBool
-
- widget = MonWidgetSimpBool(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif self.item.waitFichier():
- from InterfaceQT4.monWidgetSimpFichier import MonWidgetSimpFichier
-
- widget = MonWidgetSimpFichier(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- # PNPNPN - a faire
- elif self.item.waitDate():
- from InterfaceQT4.monWidgetDate import MonWidgetDate
-
- widget = MonWidgetDate(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif self.item.waitHeure():
- from InterfaceQT4.monWidgetHeure import MonWidgetHeure
-
- widget = MonWidgetHeure(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.waitTuple():
- num = self.item.object.definition.type[0].ntuple
- nomDeLaClasse = "MonWidgetSimpTuple" + str(num)
- nomDuFichier = "InterfaceQT4.monWidgetSimpTupleN"
- try:
- # if 1 :
- _temp = __import__(
- nomDuFichier, globals(), locals(), [nomDeLaClasse], 0
- )
- # print (_temp)
- MonWidgetSimpTuple = getattr(_temp, nomDeLaClasse)
- # print (MonWidgetSimpTuple)
- except:
- print("Pas de Tuple de longueur : ", num)
- # print ("Prevenir la maintenance ")
- widget = MonWidgetSimpTuple(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.waitComplex():
- from InterfaceQT4.monWidgetSimpComplexe import MonWidgetSimpComplexe
-
- widget = MonWidgetSimpComplexe(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.waitCo():
- if len(self.item.getSdAvantDuBonType()) == 0:
- from InterfaceQT4.monWidgetUniqueSDCO import MonWidgetUniqueSDCO
-
- widget = MonWidgetUniqueSDCO(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetSDCOInto import MonWidgetSDCOInto
-
- widget = MonWidgetSDCOInto(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif self.item.waitAssd():
- # PN - pour ne pas appeller trop souvent self.item.getSdAvantDuBonType()
- if not (self.item.waitUserAssdOrAssdMultipleEnCreation()):
- maListe = self.item.getSdAvantDuBonType()
- if self.item.waitUserAssdOrAssdMultipleEnCreation():
- from InterfaceQT4.monWidgetCreeUserAssd import MonWidgetCreeUserAssd
-
- widget = MonWidgetCreeUserAssd(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- # elif len(self.item.getSdAvantDuBonType()) == 0 :
- elif len(maListe) == 0:
- from InterfaceQT4.monWidgetVide import MonWidgetVide
-
- widget = MonWidgetVide(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- # elif len(self.item.getSdAvantDuBonType()) < 4 :
- elif len(maListe) < 4:
- from InterfaceQT4.monWidgetRadioButton import MonWidgetRadioButtonSD
-
- widget = MonWidgetRadioButtonSD(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- # elif len(self.item.getSdAvantDuBonType()) < 7 :
- elif len(maListe) < 7:
- from InterfaceQT4.monWidget4a6RadioButton import (
- MonWidget4a6RadioButtonSD,
- )
-
- widget = MonWidget4a6RadioButtonSD(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetCB import MonWidgetCBSD
-
- widget = MonWidgetCBSD(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.waitSalome() and self.editor.salome:
- from InterfaceQT4.monWidgetSimpSalome import MonWidgetSimpSalome
-
- widget = MonWidgetSimpSalome(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.waitTxm():
- from InterfaceQT4.monWidgetSimpTxt import MonWidgetSimpTxt
-
- widget = MonWidgetSimpTxt(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetSimpBase import MonWidgetSimpBase
-
- widget = MonWidgetSimpBase(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- # Gestion des listes
- else:
- if maDefinition.intoSug != [] and maDefinition.intoSug != None:
- if self.item in self.editor.listeDesListesOuvertes or not (
- self.editor.afficheListesPliees
- ):
- from InterfaceQT4.monWidgetIntoSug import MonWidgetIntoSug
-
- widget = MonWidgetIntoSug(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetPlusieursPlie import (
- MonWidgetPlusieursPlie,
- )
-
- widget = MonWidgetPlusieursPlie(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- # if maDefinition.into != [] and maDefinition.into != None:
- # Attention pas fini --> on attend une liste de ASSD avec ordre
- elif self.item.waitAssd() and self.item.isListSansOrdreNiDoublon():
- listeAAfficher = self.item.getSdAvantDuBonType()
- if len(listeAAfficher) == 0:
- from InterfaceQT4.monWidgetVide import MonWidgetVide
-
- widget = MonWidgetVide(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetPlusieursInto import (
- MonWidgetPlusieursInto,
- )
-
- widget = MonWidgetPlusieursInto(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif (
- self.item.waitAssd()
- and not self.item.waitUserAssdOrAssdMultipleEnCreation()
- ):
- listeAAfficher = self.item.getSdAvantDuBonType()
- # a changer selon UserASSD ou UserASSDMultiple
- mctype = maDefinition.type[0]
- 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
- )
- )
- if enable_salome_selection:
- from InterfaceQT4.monWidgetPlusieursBase import (
- MonWidgetPlusieursBase,
- )
-
- widget = MonWidgetPlusieursBase(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif len(listeAAfficher) == 0:
- from InterfaceQT4.monWidgetVide import MonWidgetVide
-
- widget = MonWidgetVide(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif self.item in self.editor.listeDesListesOuvertes or not (
- self.editor.afficheListesPliees
- ):
- from InterfaceQT4.monWidgetPlusieursASSDIntoOrdonne import (
- MonWidgetPlusieursASSDIntoOrdonne,
- )
-
- widget = MonWidgetPlusieursASSDIntoOrdonne(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetPlusieursPlie import (
- MonWidgetPlusieursPlieASSD,
- )
-
- widget = MonWidgetPlusieursPlieASSD(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif self.item.waitTuple():
- if self.item.object.definition.fenetreIhm == "Tableau":
- from InterfaceQT4.monWidgetTableau import MonWidgetTableau
-
- widget = MonWidgetTableau(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- num = self.item.object.definition.type[0].ntuple
- nomDeLaClasse = "MonWidgetPlusieursTuple" + str(num)
- nomDuFichier = "InterfaceQT4.monWidgetPlusieursTupleN"
- try:
- _temp = __import__(
- nomDuFichier, globals(), locals(), [nomDeLaClasse], 0
- )
- MonWidgetPlusieursTuple = getattr(_temp, nomDeLaClasse)
- except:
- print("Pas de Tuple de longueur : ", num)
- print("Prevenir la maintenance ")
- widget = MonWidgetPlusieursTuple(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- elif self.item.hasInto():
- if self.item.isListSansOrdreNiDoublon():
- if self.item in self.editor.listeDesListesOuvertes or not (
- self.editor.afficheListesPliees
- ):
- from InterfaceQT4.monWidgetPlusieursInto import (
- MonWidgetPlusieursInto,
- )
-
- widget = MonWidgetPlusieursInto(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetPlusieursPlie import (
- MonWidgetPlusieursPlie,
- )
-
- widget = MonWidgetPlusieursPlie(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- if self.item in self.editor.listeDesListesOuvertes or not (
- self.editor.afficheListesPliees
- ):
- from InterfaceQT4.monWidgetPlusieursIntoOrdonne import (
- MonWidgetPlusieursIntoOrdonne,
- )
-
- widget = MonWidgetPlusieursIntoOrdonne(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetPlusieursPlie import (
- MonWidgetPlusieursPlie,
- )
-
- widget = MonWidgetPlusieursPlie(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- if self.item.waitUserAssdOrAssdMultipleEnCreation():
- from InterfaceQT4.monWidgetPlusieursCreeUserAssd import (
- MonWidgetPlusieursCreeUserAssd,
- )
-
- widget = MonWidgetPlusieursCreeUserAssd(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- elif self.item in self.editor.listeDesListesOuvertes or not (
- self.editor.afficheListesPliees
- ):
- from InterfaceQT4.monWidgetPlusieursBase import (
- MonWidgetPlusieursBase,
- )
-
- widget = MonWidgetPlusieursBase(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
- else:
- from InterfaceQT4.monWidgetPlusieursPlie import (
- MonWidgetPlusieursPlie,
- )
-
- widget = MonWidgetPlusieursPlie(
- self, maDefinition, monNom, monObjet, parentQt, maCommande
- )
-
- self.widget = widget
- return widget
-
-
-class SIMPTreeItem(Objecttreeitem.AtomicObjectTreeItem):
- itemNode = Node
-
- def init(self):
- self.expandable = 0
-
- # -----------------------------------------------
- #
- # Methodes liees aux informations sur le Panel
- # ou au mot-clef simple
- #
- # -----------------------------------------------
- # isList
- # hasInto
- # getMinMax
- # getMultiplicite
- # getIntervalle
- # getListeValeurs
- # getListePossible
-
- def isList(self):
- """
- Cette methode indique si le mot cle simple attend une liste (valeur de retour 1)
- ou s'il n'en attend pas (valeur de retour 0)
-
- Deux cas principaux peuvent se presenter : avec validateurs ou bien sans.
- Dans le cas sans validateur, l'information est donnee par l'attribut max
- de la definition du mot cle.
- Dans le cas avec validateur, il faut combiner l'information precedente avec
- celle issue de l'appel de la methode isList sur le validateur.On utilisera
- l'operateur ET pour effectuer cette combinaison (AndVal).
- """
- is_a_list = 0
- min, max = self.getMinMax()
- assert min <= max
- if max > 1:
- is_a_list = 1
- # Dans le cas avec validateurs, pour que le mot cle soit considere
- # comme acceptant une liste, il faut que max soit superieur a 1
- # ET que la methode isList du validateur retourne 1. Dans les autres cas
- # on retournera 0 (n'attend pas de liste)
- if self.definition.validators:
- is_a_list = self.definition.validators.isList() * is_a_list
- return is_a_list
-
- def isListSansOrdreNiDoublon(self):
- if self.definition.homo == "SansOrdreNiDoublon":
- return 1
- return 0
-
- def hasInto(self):
- """
- Cette methode indique si le mot cle simple propose un choix (valeur de retour 1)
- ou s'il n'en propose pas (valeur de retour 0)
-
- Deux cas principaux peuvent se presenter : avec validateurs ou bien sans.
- Dans le cas sans validateur, l'information est donnee par l'attribut into
- de la definition du mot cle.
- Dans le cas avec validateurs, pour que le mot cle soit considere
- comme proposant un choix, il faut que into soit present OU
- que la methode hasInto du validateur retourne 1. Dans les autres cas
- on retournera 0 (ne propose pas de choix)
- """
- has_an_into = 0
- if self.definition.into:
- has_an_into = 1
- elif self.definition.validators:
- has_an_into = self.definition.validators.hasInto()
- return has_an_into
-
- def hasIntoSug(self):
- if self.definition.intoSug:
- return 1
- return 0
-
- def getMinMax(self):
- """Retourne les valeurs min et max de la definition de object"""
- return self.object.getMinMax()
-
- def getMultiplicite(self):
- """A preciser.
- Retourne la multiplicite des valeurs affectees a l'objet
- represente par l'item. Pour le moment retourne invariablement 1.
- """
- return 1
-
- def getIntervalle(self):
- """
- Retourne le domaine de valeur attendu par l'objet represente
- par l'item.
- """
- return self.object.getintervalle()
-
- def getListeValeurs(self):
- """Retourne la liste des valeurs de object"""
- valeurs = self.object.getListeValeurs()
- try:
- if "R" in self.object.definition.type:
- clef = self.object.getNomConcept()
- if clef in self.appliEficas.dict_reels:
- if type(valeurs) == tuple:
- valeurs_reelles = []
- for val in valeurs:
- if val in self.appliEficas.dict_reels[clef]:
- valeurs_reelles.append(
- self.appliEficas.dict_reels[clef][val]
- )
- else:
- valeurs_reelles.append(val)
- else:
- if valeurs in self.appliEficas.dict_reels[clef]:
- valeurs_reelles = self.appliEficas.dict_reels[clef][valeurs]
- valeurs = valeurs_reelles
- except:
- pass
- return valeurs
-
- def getListePossible(self, listeActuelle=[]):
- if hasattr(self.definition.validators, "into"):
- valeurspossibles = self.definition.validators.into
- else:
- valeurspossibles = self.get_definition().into
-
- if listeActuelle == []:
- return valeurspossibles
-
- # On ne garde que les items valides
- listevalideitem = []
- if type(valeurspossibles) in (list, tuple):
- pass
- else:
- valeurspossibles = (valeurspossibles,)
- for item in valeurspossibles:
- encorevalide = self.valideItem(item)
- if encorevalide:
- listevalideitem.append(item)
-
- # on ne garde que les choix possibles qui passent le test de valideListePartielle
- listevalideliste = []
- for item in listevalideitem:
- encorevalide = self.valideListePartielle(item, listeActuelle)
- if encorevalide:
- listevalideliste.append(item)
- # print listevalideliste
- return listevalideliste
-
- def getListePossibleAvecSug(self, listeActuelle=[]):
- if hasattr(self.definition, "intoSug"):
- valeurspossibles = self.definition.intoSug
- else:
- return listeActuelle
-
- if listeActuelle == []:
- return valeurspossibles
- valeurspossibles = valeurspossibles + listeActuelle
-
- # On ne garde que les items valides
- listevalideitem = []
- if type(valeurspossibles) in (list, tuple):
- pass
- else:
- valeurspossibles = (valeurspossibles,)
- for item in valeurspossibles:
- encorevalide = self.valideItem(item)
- if encorevalide:
- listevalideitem.append(item)
-
- # on ne garde que les choix possibles qui passent le test de valideListePartielle
- listevalideliste = []
- for item in listevalideitem:
- encorevalide = self.valideListePartielle(item, listeActuelle)
- if encorevalide:
- listevalideliste.append(item)
- return listevalideliste
-
- def getListeParamPossible(self):
- liste_param = []
- l1, l2 = self.jdc.getParametresFonctionsAvantEtape(self.getEtape())
- for param in self.object.jdc.params:
- if param.nom not in l1:
- continue
- encorevalide = self.valideItem(param.valeur)
- if encorevalide:
- type_param = param.valeur.__class__.__name__
- for typ in self.definition.type:
- if typ == "R":
- liste_param.append(param)
- if typ == "I" and type_param == "int":
- liste_param.append(param)
- if typ == "TXM" and type_param == "str":
- liste_param.append(repr(param))
- if ("grma" in repr(typ)) and type_param == "str":
- liste_param.append(param.nom)
- return liste_param
-
- # --------------------------------------------------
- #
- # Methodes liees a la validite des valeurs saisies
- #
- # ---------------------------------------------------
- # valideItem
- # valideListePartielle
- # valideListeComplete
- # infoErreurItem
- # infoErreurListe
- # isInIntervalle
- # isValid
-
- def valideItem(self, item):
- """
- La validation est realisee directement par l'objet
- """
- return self.object.valideItem(item)
-
- def valideListePartielle(self, item, listecourante):
- # On protege la liste en entree en la copiant
- valeur = list(listecourante)
- if item:
- valeur.append(item)
- return self.object.validValeurPartielle(valeur)
-
- def valideListeComplete(self, valeur):
- return self.object.validValeur(valeur)
-
- def infoErreurItem(self):
- commentaire = ""
- if self.definition.validators:
- commentaire = self.definition.validators.infoErreurItem()
- return commentaire
-
- def aide(self):
- commentaire = ""
- if self.definition.validators:
- commentaire = self.definition.validators.aide()
- return commentaire
-
- def infoErreurListe(self):
- commentaire = ""
- if self.definition.validators:
- commentaire = self.definition.validators.infoErreurListe()
- return commentaire
-
- def isInIntervalle(self, valeur):
- """
- Retourne 1 si la valeur est dans l'intervalle permis par
- l'objet represente par l'item.
- """
- return self.valideItem(valeur)
-
- def isValid(self):
- valide = self.object.isValid()
- return valide
-
- # --------------------------------------------------
- #
- # Autres ...
- #
- # ---------------------------------------------------
- # getIconName
- # getText
- # setValeurCo
- # getSdAvantDuBonType
-
- def getIconName(self):
- if self.appliEficas.maConfiguration.differencieSiDefaut and self.isValid():
- if self.object.definition.defaut != None:
- if self.object.valeur == self.object.definition.defaut:
- return "ast-green-dark-ball"
- if self.object.definition.max > 1 and list(self.object.valeur) == list(
- self.object.definition.defaut
- ):
- return "ast-green-dark-ball"
- return "ast-green-ball"
- elif self.isValid():
- return "ast-green-ball"
- elif self.object.isOblig():
- return "ast-red-ball"
- else:
- return "ast-yel-ball"
-
- def getText(self):
- """
- Classe SIMPTreeItem
- Retourne le texte a afficher dans l'arbre representant la valeur de l'objet
- pointe par self
- """
- if (
- self.waitUserAssdMultiple()
- or self.object.waitUserAssd()
- or self.object.waitAssd()
- ):
- return self.object.valeur
- # if self.object.valeur != None : return self.object.valeur.nom
- # else : return ""
- text = self.object.getText()
- if text == None:
- text = ""
- return text
-
- def setValeurCo(self, nomCo):
- """
- Affecte au MCS pointe par self l'objet de type CO et de nom nom_co
- """
- ret = self.object.setValeurCo(nomCo)
- # print "setValeurCo",ret
- return ret
-
- def getSdAvantDuBonType(self):
- """
- 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
- """
- # A changer pour tenir compte des UserASSDMultiple
- # ici on passe par parent pour avoir le bon type
- # if self.waitUserAssdMultiple() :
- # l=self.object.parent.getSdCreeParObjetAvecFiltre(self.object)
- # return l
- if self.waitUserAssdMultiple():
- l = self.object.getUserAssdPossible()
- return l
- a = self.object.etape.parent.getSdAvantDuBonType(
- self.object.etape, self.object.definition.type
- )
- 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"
- )
- return a
-
- def deleteValeurCo(self, valeur=None):
- """
- Supprime la valeur du mot cle (de type CO)
- il faut propager la destruction aux autres etapes
- """
- if not valeur:
- valeur = self.object.valeur
- # XXX faut il vraiment appeler delSdprod ???
- # self.object.etape.parent.delSdprod(valeur)
- self.object.etape.parent.deleteConcept(valeur)
-
- # -----------------------------------------------
- #
- # Methodes liees au type de l objet attendu
- #
- # -----------------------------------------------
- # waitCo
- # waitGeom
- # waitComplex
- # waitReel
- # waitAssd
- # getType
-
- def waitCo(self):
- """
- Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un objet de type ASSD qui n'existe pas encore (type CO()),
- 0 sinon
- """
- return self.object.waitCo()
-
- def waitFichier(self):
- maDefinition = self.object.definition
- try:
- if ("Repertoire" in maDefinition.type[0]) or (
- "Fichier" in maDefinition.type[0]
- ):
- return 1
- except:
- return 0
-
- def waitGeom(self):
- """
- Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un objet GEOM, 0 sinon
- """
- return self.object.waitGeom()
-
- def waitTxm(self):
- return self.object.waitTxm()
-
- def waitComplex(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un complexe, 0 sinon"""
- if "C" in self.object.definition.type:
- return 1
- else:
- return 0
-
- def waitReel(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un reel, 0 sinon"""
- if "R" in self.object.definition.type:
- return 1
- else:
- return 0
-
- def waitTuple(self):
- return self.object.waitTuple()
-
- def waitDate(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un reel, 0 sinon"""
- if "DateHHMMAAAA" in self.object.definition.type:
- return 1
- else:
- return 0
-
- def waitHeure(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un reel, 0 sinon"""
- if "HeureHHMMSS" in self.object.definition.type:
- return 1
- else:
- return 0
-
- def waitTuple(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un Tuple, 0 sinon"""
- for ss_type in self.object.definition.type:
- if repr(ss_type).find("Tuple") != -1:
- return 1
- return 0
-
- def waitMatrice(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un Tuple, 0 sinon"""
- # il faut trouver autre chose que ce find!!!
- for ss_type in self.object.definition.type:
- # if repr(ss_type).find('Matrice') != -1 :
- if hasattr(ss_type, "typElt"):
- return 1
- return 0
-
- def waitAssd(self):
- """Methode booleenne qui retourne 1 si l'objet pointe par self
- attend un objet de type ASSD ou derive, 0 sinon"""
- return self.object.waitAssd()
-
- def waitAssdOrTypeBase(self):
- boo = 0
- if len(self.object.definition.type) > 1:
- if self.waitReel():
- boo = 1
- if "I" in self.object.definition.type:
- boo = 1
- return boo
-
- def waitSalome(self):
- monType = self.object.definition.type[0]
- if "grma" in repr(monType):
- return True
- if "grno" in repr(monType):
- return True
- try:
- if issubclass(monType, SalomeEntry):
- return True
- except:
- pass
- return False
-
- def getType(self):
- """
- Retourne le type de valeur attendu par l'objet represente par l'item.
- """
- return self.object.getType()
-
- # -----------------------------------------------------
- #
- # Methodes liees a l evaluation de la valeur saisie
- #
- # -----------------------------------------------------
- # evalValeur
- # evalValeurItem
- # isCO
- # traiteReel
-
- def evalValeur(self, valeur):
- """Lance l'interpretation de 'valeur' (chaine de caracteres) comme valeur de self :
- - retourne l'objet associe si on a pu interpreter (entier, reel, ASSD,...)
- - retourne 'valeur' (chaine de caracteres) sinon
- """
- newvaleur = self.evalVal(valeur)
- return newvaleur, 1
-
- def evalValeurItem(self, valeur):
- """Lance l'interpretation de 'valeur' qui doit ne pas etre un tuple
- - va retourner la valeur de retour et la validite
- selon le type de l objet attendu
- - traite les reels et les parametres
- """
- # print "evalValeurItem",valeur
- if valeur == None or valeur == "":
- return None, 0
- validite = 1
- if self.waitReel():
- valeurinter = self.traiteReel(valeur)
- if valeurinter != None:
- valeurretour, validite = self.object.evalValeur(valeurinter)
- else:
- valeurretour, validite = self.object.evalValeur(valeur)
- elif self.waitGeom():
- valeurretour, validite = valeur, 1
- else:
- valeurretour, validite = self.object.evalValeur(valeur)
-
- if validite == 0:
- if (type(valeur) == bytes or type(valeur) == str) and self.object.waitTxm():
- essai_valeur = "'" + valeur + "'"
- valeurretour, validite = self.object.evalValeur(essai_valeur)
-
- if hasattr(valeurretour, "__class__"):
- # if valeurretour.__class__.__name__ in ('PARAMETRE','PARAMETRE_EVAL'):
- if valeurretour.__class__.__name__ in ("PARAMETRE",):
- validite = 1
-
- # if self.waitCo():
- # CCAR : il ne faut pas essayer de creer un concept
- # il faut simplement en chercher un existant ce qui a du etre fait par self.object.evalValeur(valeur)
- # try:
- # valeurretour=Accas.CO(valeur)
- # except:
- # valeurretour=None
- # validite=0
- # on est dans le cas ou on a evalue et ou on n'aurait pas du
- if self.object.waitTxm():
- if type(valeurretour) != bytes:
- valeurretour = str(valeur)
- validite = 1
- return valeurretour, validite
-
- def isCO(self, valeur=None):
- """
- Indique si valeur est un concept produit de la macro
- Cette methode n'a de sens que pour un MCSIMP d'une MACRO
- Si valeur vaut None on teste la valeur du mot cle
- """
- # Pour savoir si un concept est un nouveau concept de macro
- # on regarde s'il est present dans l'attribut sdprods de l'etape
- # ou si son nom de classe est CO.
- # Il faut faire les 2 tests car une macro non valide peut etre
- # dans un etat pas tres catholique avec des CO pas encore types
- # et donc pas dans sdprods (resultat d'une exception dans typeSDProd)
- if not valeur:
- valeur = self.object.valeur
- if valeur in self.object.etape.sdprods:
- return 1
- # if type(valeur) is not types.InstanceType:return 0
- if type(valeur) is not object:
- return 0
- if valeur.__class__.__name__ == "CO":
- return 1
- return 0
-
- def isParam(self, valeur):
- for param in self.jdc.params:
- if repr(param) == valeur:
- return 1
- return 0
-
- def traiteReel(self, valeur):
- """
- Cette fonction a pour but de rajouter le '.' en fin de chaine pour un reel
- ou de detecter si on fait reference a un concept produit par DEFI_VALEUR
- ou un EVAL ...
- """
- valeur = valeur.strip()
- liste_reels = self.getSdAvantDuBonType()
- if valeur in liste_reels:
- return valeur
- if len(valeur) >= 3:
- if valeur[0:4] == "EVAL":
- # on a trouve un EVAL --> on retourne directement la valeur
- return valeur
- if valeur.find(".") == -1:
- # aucun '.' n'a ete trouve dans valeur --> on en rajoute un a la fin
- if self.isParam(valeur):
- return valeur
- else:
- if valeur.find("e") != -1:
- # Notation scientifique ?
- try:
- r = eval(valeur)
- return valeur
- except:
- return None
- else:
- return valeur + "."
- else:
- return valeur
-
-
-import Accas
-
-treeitem = SIMPTreeItem
-objet = Accas.MCSIMP
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 pour charger les parametres de configuration d'EFICAS
-"""
-import os, sys, types, re
-import traceback
-from Extensions.i18n import tr
-
-
-class configBase(object):
- # -------------------------------
- def __init__(self, appliEficas, repIni):
- # -------------------------------
-
- # Classe de base permettant de lire, afficher
- # et sauvegarder les fichiers utilisateurs
- # On a deux directories : la directory generale (Repertoire d install + Nom du code
- # Par exemple : ~/Install_Eficas/EficasV1_14/Openturns_Wrapper
- # et la directorie de l utilisateur
- # HOME/.Eficas_Openturns
- # Le fichier prefs.py va etre lu dans la directory generale
- # puis surcharge eventuellement par celui contenu dans ${PREFS_CATA_$CODE}
- # par celui de l utilisateur
- # le fichier de catalogue va etre lu dans la directory de l utilisateur s il exite
- # dans le fichier general sinon
-
- self.appliEficas = appliEficas
- self.code = appliEficas.code
- self.salome = appliEficas.salome
- if self.salome:
- self.name = "editeur_salome.ini"
- else:
- self.name = "editeur.ini"
- self.rep_mat = None
- self.repIni = repIni
-
- if self.code == None:
- self.code = ""
- self.rep_user = os.path.join(
- os.path.expanduser("~"), ".config/Eficas", self.code
- )
- # else :
- # self.rep_user = os.path.join('C:/','.config/Eficas',self.code)
-
- self.setValeursParDefaut()
-
- if self.code != "":
- self.lectureFichierIniStandard()
- self.lectureFichierIniIntegrateur()
- self.lectureFichierIniUtilisateur()
-
- if self.boutonDsMenuBar:
- self.closeAutreCommande = True
- self.closeFrameRechercheCommande = True
-
- # Particularite des schemas MAP
- if hasattr(self, "make_ssCode"):
- self.make_ssCode(self.ssCode)
-
- if not os.path.isdir(self.savedir):
- self.savedir = os.path.join(
- os.path.expanduser("~"), ".config/Eficas", self.code
- )
-
- def setValeursParDefaut(self):
- # -----------------------------
-
- # Valeurs par defaut
- if not os.path.isdir(self.rep_user):
- os.makedirs(self.rep_user)
- self.path_doc = os.path.abspath(os.path.join(self.repIni, "..", "Doc"))
- self.exec_acrobat = "acroread"
- nomDir = "Eficas_" + self.code
- self.savedir = os.path.abspath(os.path.join(os.path.expanduser("~"), nomDir))
- # if sys.platform[0:5]=="linux" :
- # self.savedir = os.path.abspath(os.path.join(os.environ['HOME'],nomDir))
- # else:
- # self.savedir = os.path.abspath('C:/')
- self.modeNouvCommande = "initial"
- self.affiche = "alpha"
- self.closeAutreCommande = False
- self.closeFrameRechercheCommande = False
- self.closeFrameRechercheCommandeSurPageDesCommandes = False
- self.closeEntete = False
- self.closeArbre = False
- self.demandeLangue = False
- self.suiteTelemac = False
- self.nombreDeBoutonParLigne = 0
- self.translatorFichier = None
- self.dicoImages = {}
- self.dicoIcones = {}
- self.afficheCommandesPliees = True
- self.afficheFirstPlies = False
- self.simpleClic = False
- self.afficheOptionnelVide = False
- self.afficheListesPliees = True
- self.boutonDsMenuBar = False
- self.ficIcones = None
- self.repIcones = None
- self.differencieSiDefaut = False
- self.typeDeCata = "Python"
- self.closeParenthese = False
- self.closeOptionnel = False
- self.afficheFactOptionnel = False
- self.enleverActionStructures = False
- self.enleverPoubellePourCommande = False
- self.enleverParametres = False
- self.enleverSupprimer = False
- self.ajoutExecution = False
- self.utilParExtensions = []
- self.rendVisiblesLesCaches = False
- self.pasDeMCOptionnels = False
-
- self.dumpXSD = False
- self.withXSD = False
- self.afficheIhm = True
-
- # self.afficheUQ=False
- self.afficheUQ = True
-
- # --------------------------------------
- def lectureFichierIniStandard(self):
- # --------------------------------------
-
- name = "prefs_" + self.appliEficas.code
- try:
- prefsCode = __import__(name)
- except:
- self.catalogues = []
- print("pas de fichier de prefs")
- return
- for k in dir(prefsCode):
- if k[0:1] != "__" and k[-1:-2] != "__":
- valeur = getattr(prefsCode, k)
- setattr(self, k, valeur)
-
- # --------------------------------------
- def lectureFichierIniIntegrateur(self):
- # --------------------------------------
- # Verifie l'existence du fichier "standard"
- # appelle la lecture de ce fichier
- clef = "PREFS_CATA_" + self.code
- try:
- repIntegrateur = os.path.abspath(os.environ[clef])
- except:
- return
-
- fic_ini_integrateur = os.path.join(repIntegrateur, self.name)
- if not os.path.isfile(fic_ini_integrateur):
- return
- with open(fic_ini_integrateur) as fd:
- txt = fd.read()
- d = locals()
- try:
- exec(txt, d)
- except:
- try:
- from PyQt5.QtWidgets import QMessageBox
-
- QMessageBox.critical(
- None,
- tr("Import du fichier de Configuration"),
- tr(
- "Erreur a la lecture du fichier de configuration %s ",
- str(fic_ini_integrateur),
- ),
- )
- except:
- print(
- "Erreur a la lecture du fichier de configuration %s ",
- str(fic_ini_integrateur),
- )
- return
- self.labels_eficas.append("rep_aide")
- for k in self.labels_eficas:
- try:
- setattr(self, k, d[k])
- except:
- pass
- # Glut pour les repertoires materiaux
- # et pour la doc
- for k in d:
- if (k[0:8] == "rep_mat_") or (k[0:8] == "rep_doc_"):
- setattr(self, k, d[k])
-
- # --------------------------------------
- def lectureFichierIniUtilisateur(self):
- # --------------------------------------
- # Surcharge les parametres standards par les parametres utilisateur s'ils existent
- self.fic_ini_utilisateur = os.path.join(self.rep_user, self.name)
- if not os.path.isfile(self.fic_ini_utilisateur):
- return
- with open(fic_ini_utilisateur) as fd:
- txt = fd.read()
- d = locals()
- try:
- exec(txt, d)
- except:
- l = traceback.format_exception(
- sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
- )
- try:
- from PyQt5.QtWidgets import QMessageBox
-
- QMessageBox.critical(
- None,
- tr("Import du fichier de Configuration"),
- tr(
- "Erreur a la lecture du fichier de configuration %s ",
- str(fic_ini_integrateur),
- ),
- )
- except:
- print(
- "Erreur a la lecture du fichier de configuration %s ",
- str(fic_ini_integrateur),
- )
- for k in self.labels_user:
- try:
- setattr(self, k, d[k])
- except:
- pass
- for k in d:
- if (k[0:8] == "rep_mat_") or (k[0:8] == "rep_doc_"):
- setattr(self, k, d[k])
-
- # --------------------------------------
- def saveParams(self):
- # --------------------------------------
- # sauvegarde
- # les nouveaux parametres dans le fichier de configuration utilisateur
- #
- texte = ""
- for clef in self.labels_user:
- if hasattr(self, clef):
- valeur = getattr(self, clef)
- texte = texte + clef + " = " + repr(valeur) + "\n"
- # Glut pour les repertoires materiaux
- # et pour la doc
- for k in dir(self):
- if (k[0:8] == "rep_mat_") or (k[0:8] == "rep_doc_"):
- valeur = getattr(self, k)
- texte = texte + k + " = " + repr(valeur) + "\n"
-
- f = open(self.fic_ini_utilisateur, "w+")
- f.write(texte)
- f.close()
-
-
-#
-
-
-def makeConfig(appliEficas, rep):
- return configBase(appliEficas, rep)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-
-import types, sys, os, re
-import subprocess
-
-from PyQt5.QtWidgets import QWidget, QMessageBox, QFileDialog, QApplication, QSplitter, QLabel
-from PyQt5.QtGui import QPalette, QFont
-from PyQt5.QtCore import QProcess, QFileInfo, QTimer, Qt, QDir, QSize, QProcessEnvironment
-
-import traceback
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from Editeur import session
-from Editeur import comploader
-from Editeur import Objecttreeitem
-from InterfaceQT4 import browser
-
-from desBaseWidget import Ui_baseWidget
-from InterfaceQT4.monViewTexte import ViewText
-from monWidgetCreeParam import MonWidgetCreeParam
-
-DictExtensions = {"MAP": ".map", "TELEMAC": ".cas"}
-debug = False
-
-
-from InterfaceQT4.editorSsIhm import JDCEditorSsIhm
-
-
-class JDCEditor(JDCEditorSsIhm, Ui_baseWidget, QWidget):
-# -------------------------------------------------- #
- """
- Editeur de jdc
- """
-
- # ----------------------------------------
- # Methodes faisant appel a ssIhm
- # ----------------------------------------
-
- def __init__( self, appliEficas, fichier=None, jdc=None, QWParent=None, units=None, include=0):
- # ------------------------------------------------------------------------------------------------
-
- QWidget.__init__(self, None)
- self.setupUi(self)
-
- self.inhibeSplitter = 0
- self.widgetOptionnel = None
- self.fenetreCentraleAffichee = None
- self.dejaDansPlieTout = False
- self.listeDesListesOuvertes = set()
- if appliEficas != None and hasattr(appliEficas, "statusBar"):
- self.sb = appliEficas.statusBar()
- else:
- self.sb = None
- self.QWParent = QWParent
-
- JDCEditorSsIhm.__init__(self, appliEficas, fichier, jdc, units, include)
- if self.jdc:
- comploader.chargerComposants(self.appliEficas.GUIPath)
- self.jdc_item = Objecttreeitem.makeObjecttreeitem(self, "nom", self.jdc)
-
- # Particularites IHM : met la fenetre a jour
- self.initSplitterSizes()
-
- self.afficheListesPliees = self.maConfiguration.afficheListesPliees
- if self.code in ["MAP", "CARMELCND", "PSEN"]:
- self.maConfiguration.afficheCommandesPliees = False
-
- if self.maConfiguration.closeArbre:
- self.fermeArbre()
- if self.maConfiguration.closeOptionnel:
- self.fermeOptionnel()
- if self.maConfiguration.boutonDsMenuBar:
- self.appliEficas.remplitIconesCommandes()
-
- self.formatFichierOut = self.appliEficas.formatFichierOut
- self.formatFichierIn = self.appliEficas.formatFichierIn
-
- self.node_selected = []
- self.deplier = True
- self.message = ""
- self.afficheApresInsert = False
- if self.maConfiguration.closeArbre:
- self.afficheApresInsert = True
- if self.code in ["Adao", "ADAO", "MAP"]:
- self.afficheApresInsert = True
- if self.code in [ "TELEMAC", ]:
- self.enteteQTree = "premier"
- else:
- self.enteteQTree = "complet"
- if self.code in ["Adao", "ADAO", "TELEMAC", "VP"]:
- self.affichePlie = True
- else:
- self.affichePlie = False
-
- #self.commandesOrdreCatalogue = self.readercata.commandesOrdreCatalogue
-
- if self.appliEficas.readercata.demandeCatalogue == True:
- nomFichierTranslation = (
- "translatorFichier" + "_" + str(self.appliEficas.readercata.labelCode)
- )
- if hasattr(self.appliEficas.maConfiguration, nomFichierTranslation):
- translatorFichier = getattr(
- self.appliEficas.maConfiguration, nomFichierTranslation
- )
- from Extensions import localisation
-
- localisation.localise(
- None, self.appliEficas.langue, translatorFichier=translatorFichier
- )
-
- if self.jdc_item and self.appliEficas.ssIhm == False:
- self.tree = browser.JDCTree(self.jdc_item, self)
- self.appliEficas.construitMenu()
-
- self.adjustSize()
-
- # -------------------------------#
- def readFile(self, fn):
- # --------------------------------#
- """
- Public slot to read the text from a file.
- @param fn filename to read from (string or QString)
- """
-
- jdc = JDCEditorSsIhm.readFile(self, fn)
-
- # Particularites IHM : met le titre de la fenetre a jour
- # qApp.restoreOverrideCursor()
- if self.fileInfo != None:
- self.lastModified = self.fileInfo.lastModified()
- nouveauTitre = self.titre + " " + os.path.basename(self.fichier)
- self.appliEficas.setWindowTitle(nouveauTitre)
-
- return jdc
-
- # ---------------------------------------------
- # Methodes Inchangees
- # ---------------------------------------------
- # _newJDC
- # _newJDCInclude
- # __generateTempFilename
- # getSource
- # generDico
- # viewJdcSource
- # viewJdcPy
- # viewJdcRapport
- # getFileName
- # initModif
- # writeFile
- # getTextJDC
- # verifieChecksum
- # getChecksum
- # getDico
- # chercheGroupes
- # chercheDico
- # saveFileLegerAs
-
- # ---------------------------------------------
- # Methodes Surchargees
- # ---------------------------------------------
-
- # -----------------------------------------------------------------------#
- def _viewText(self, txt, caption="FILE_VIEWER", largeur=1200, hauteur=600):
- # --------------------------------------------------------------------#
- w = ViewText(self.QWParent, self, caption, txt, largeur, hauteur)
- w.show()
-
- # --------------------------------#
- def informe(self, titre, txt, critique=True):
- # --------------------------------#
- if critique:
- self.afficheInfos(tr(txt), Qt.red)
- QMessageBox.critical(self, tr(titre), tr(txt))
- else:
- QMessageBox.warning(self, tr(titre), tr(txt))
-
- # --------------------------------#
- def ajoutCommentaire(self):
- # --------------------------------#
- if self.tree.selectedItems() == []:
- QMessageBox.warning(
- self,
- tr("Pas de noeud selectionne"),
- tr(
- "Selectionnez un Noeud \nLe commentaire sera place apres le noeud selectionne"
- ),
- )
- return
- noeudAvantCommentaire = self.tree.selectedItems()[0]
- if noeudAvantCommentaire == self.tree.racine:
- self.tree.racine.appendChild("COMMENTAIRE", pos=0)
- return
- noeudAvantCommentaire.addComment(True)
-
- # -----------------------------------------------------------------------------------------------#
- def _viewTextExecute(
- self, txt, prefix, suffix, fichierExe=None, shell="sh", texteCommande=None
- ):
- # ----------------------------------------------------------------------------------------------#
- self.myWidget = ViewText(self.QWParent)
- self.myWidget.setWindowTitle("execution")
- self.myWidget.view.setFont(QFont("Monospace"))
- self.monExe = QProcess(self.myWidget)
- pid = self.monExe.pid()
- if not fichierExe and txt:
- fichierExe = self.generateTempFilename(prefix, suffix=".sh")
- f = open(fichierExe, "self.myWidget")
- f.write(txt)
- f.close()
- self.monExe.readyReadStandardOutput.connect(self.readFromStdOut)
- self.monExe.readyReadStandardError.connect(self.readFromStdErr)
- if texteCommande != None:
- exe = texteCommande
- else:
- exe = shell + " " + fichierExe
- monEnv = QProcessEnvironment.systemEnvironment()
- monEnv.insert("COLUMNS", "500")
- self.monExe.setProcessEnvironment(monEnv)
- self.monExe.start(exe)
- self.monExe.closeWriteChannel()
- self.myWidget.exec_()
- if self.monExe != None:
- self.monExe.readyReadStandardOutput.disconnect()
- self.monExe.readyReadStandardError.disconnect()
- if txt:
- commande = "rm " + fichierExe
- os.system(commande)
- return 1
-
- def readFromStdErr(self):
- a = self.monExe.readAllStandardError()
- chaine = str(a.data(), encoding="utf-8")
- self.myWidget.view.append(chaine)
- # self.myWidget.view.append(str(a.data()))
-
- def readFromStdOut(self):
- a = self.monExe.readAllStandardOutput()
- chaine = str(a.data(), encoding="utf-8")
- self.myWidget.view.append(chaine)
-
- # self.wmyWidget.view.append(str(a.data()))
-
- # -----------------------#
- def gestionParam(self):
- # -----------------------#
- w = MonWidgetCreeParam(self)
- w.show()
-
- # ----------------#
- def closeIt(self):
- # ----------------#
- """
- Public method called by the viewmanager to finally get rid of us.
- """
- if self.jdc:
- self.jdc.supprime()
- self.close()
-
- # ----------------------------------------------#
- def afficheInfos(self, message, couleur=Qt.black):
- # ----------------------------------------------#
- if couleur == "red":
- couleur = Qt.red
- if self.sb:
- mapalette = self.sb.palette()
- mapalette.setColor(QPalette.WindowText, couleur)
- self.sb.setPalette(mapalette)
- self.sb.showMessage(message, 4000)
- self.couleur = couleur
-
- # ------------------------------#
- def afficheAlerte(self, titre, message):
- # ------------------------------#
- # appele par I_MACRO_ETAPE
- QMessageBox.information(self, titre, message)
-
- # -----------------------------------#
- def afficheCommentaire(self, message):
- # -----------------------------------#
- self.labelCommentaire.setText(message)
- QTimer.singleShot(6000, self.rendInvisible)
-
- # ----------------------#
- def rendInvisible(self):
- # ----------------------#
- self.labelCommentaire.setText("")
-
- # ---------------------------------------#
- def chercheNoeudSelectionne(self, copie=1):
- # ---------------------------------------#
- """
- appele par Cut et Copy pour positionner self.node_selected
- """
- self.node_selected = []
- if len(self.tree.selectedItems()) == 0:
- return
- self.node_selected = self.tree.selectedItems()
-
- # ---------------------#
- def handleSupprimer(self):
- # ---------------------#
- self.chercheNoeudSelectionne()
- if len(self.node_selected) == 0:
- return
- self.QWParent.noeud_a_editer = []
- if self.node_selected[0] == self.tree.racine:
- return
- if len(self.node_selected) == 1:
- self.node_selected[0].delete()
- else:
- self.node_selected[0].deleteMultiple(self.node_selected)
-
- # ---------------------#
- def handleRechercher(self):
- # ---------------------#
- from .monRecherche import DRecherche
-
- monRechercheDialg = DRecherche(parent=self, fl=0)
- monRechercheDialg.show()
-
- # --------------------------------#
- def handleRechercherDsCatalogue(self):
- # -----------------------------#
- from .monRechercheCatalogue import DRechercheCatalogue
-
- monRechercheDialg = DRechercheCatalogue(self.QWParent, self)
- monRechercheDialg.show()
-
- # ---------------------#
- def handleDeplier(self):
- # ---------------------#
- if self.tree == None:
- return
- # self.tree.collapseAll()
- if self.deplier:
- # print "je plie"
- self.tree.expandItem(self.tree.topLevelItem(0))
- self.deplier = False
- if self.fenetreCentraleAffichee != None:
- if hasattr(self.fenetreCentraleAffichee.node, "plieToutEtReaffiche"):
- self.fenetreCentraleAffichee.node.plieToutEtReaffiche()
- else:
- # print "je deplie"
- self.tree.expandItem(self.tree.topLevelItem(0))
- self.deplier = True
- if self.fenetreCentraleAffichee != None:
- if hasattr(self.fenetreCentraleAffichee.node, "deplieToutEtReaffiche"):
- self.fenetreCentraleAffichee.node.deplieToutEtReaffiche()
-
- # ---------------------#
- def handleEditCut(self):
- # ---------------------#
- """
- Stocke dans Eficas.noeud_a_editer le noeud a couper
- """
- # print "handleEditCut"
- self.chercheNoeudSelectionne()
- self.QWParent.edit = "couper"
- self.QWParent.noeud_a_editer = self.node_selected
-
- # -----------------------#
- def handleEditCopy(self):
- # -----------------------#
- """
- Stocke dans Eficas.noeud_a_editer le noeud a copier
- """
- self.chercheNoeudSelectionne()
- if len(self.node_selected) == 0:
- return
- if len(self.node_selected) == 1:
- self.node_selected[0].updateNodeLabelInBlue()
- else:
- self.node_selected[0].updatePlusieursNodeLabelInBlue(self.node_selected)
- self.QWParent.edit = "copier"
- self.QWParent.noeud_a_editer = self.node_selected
-
- # ------------------------#
- def handleEditPaste(self):
- # ------------------------#
- """
- Lance la copie de l'objet place dans self.QWParent.noeud_a_editer
- Ne permet que la copie d'objets de type Commande ou MCF
- """
- self.chercheNoeudSelectionne()
- if (not (hasattr(self.QWParent, "noeud_a_editer"))) or len(
- self.QWParent.noeud_a_editer
- ) == 0:
- QMessageBox.information(
- self,
- tr("Copie impossible"),
- tr("Veuillez selectionner un objet a copier"),
- )
- return
- if len(self.node_selected) != 1:
- QMessageBox.information(
- self,
- tr("Copie impossible"),
- tr(
- "Veuillez selectionner un seul objet : la copie se fera apres le noeud selectionne"
- ),
- )
- return
- noeudOuColler = self.node_selected[0]
-
- if len(self.QWParent.noeud_a_editer) != 1:
- # self.handleEditPasteMultiple()
- QMessageBox.information(
- self, tr("Copie impossible"), tr("Aucun Objet n a ete copie ou coupe")
- )
- return
-
- noeudACopier = self.QWParent.noeud_a_editer[0]
-
- if self.QWParent.edit != "couper":
- # print (noeudOuColler.item.parent.getChild(noeudOuColler.item.nom))
- try:
- if noeudOuColler == self.tree.racine:
- child = noeudOuColler.doPastePremier(noeudACopier)
- else:
- child = noeudACopier.doPaste(noeudOuColler, "after")
-
- if child == None or child == 0:
- QMessageBox.critical(
- self,
- tr("Copie refusee"),
- tr("Eficas n a pas reussi a copier l objet"),
- )
- self.message = ""
- self.afficheInfos("Copie refusee", Qt.red)
- if noeudACopier.treeParent.editor != noeudOuColler.treeParent.editor:
- try:
- nom = noeudACopier.item.sd.nom
- child.item.nommeSd(nom)
- except:
- pass
- return
- self.initModif()
- child.select()
- except:
- traceback.print_exc()
- QMessageBox.critical(
- self, tr("Copie refusee"), tr("Copie refusee pour ce type d objet")
- )
- self.message = ""
- self.afficheInfos("Copie refusee", Qt.red)
- return
-
- # il faut declarer le JDCDisplay_courant modifie
- # suppression eventuelle du noeud selectionne
- # si possible on renomme l objet comme le noeud couper
-
- if self.QWParent.edit == "couper":
- if noeudACopier.treeParent.editor != noeudOuColler.treeParent.editor:
- QMessageBox.critical(
- self,
- tr("Deplacement refuse"),
- tr(
- "Deplacement refuse entre 2 fichiers. Seule la copie est autorisee "
- ),
- )
-
- # if 1:
- try:
- # indexNoeudACopier=noeudACopier.treeParent.children.index(noeudACopier)
- indexNoeudACopier = self.getTreeIndex(noeudACopier)
- noeudACopier.treeParent.item.deplaceEntite(
- indexNoeudACopier, indexNoeudOuColler, pos
- )
- noeudACopier.treeParent.buildChildren()
-
- # else:
- except:
- pass
- self.QWParent.noeud_a_editer = []
-
- # on rend la copie a nouveau possible en liberant le flag edit
- self.QWParent.edit = "copier"
- noeudACopier.select()
-
- # ----------------------------------#
- def handleDeplaceMultiple(self):
- # ----------------------------------#
- pass
-
- # ----------------------------------#
- def handleEditPasteMultiple(self):
- # ----------------------------------#
-
- # On ne garde que les niveaux "Etape"
- # On insere dans l'ordre du JDC
- listeNoeudsACouper = []
- listeIndex = []
- listeChild = []
- listeItem = []
- from InterfaceQT4 import compojdc
-
- noeudOuColler = self.node_selected[0]
- if not (isinstance(noeudOuColler.treeParent, compojdc.Node)):
- QMessageBox.information(
- self,
- tr(
- "Copie impossible a cet endroit",
- ),
- tr(
- "Veuillez selectionner une commande, un parametre, un commentaire ou une macro"
- ),
- )
- return
- indexNoeudOuColler = noeudOuColler.treeParent.children.index(noeudOuColler)
-
- for noeud in self.QWParent.noeud_a_editer:
- if not (isinstance(noeud.treeParent, compojdc.Node)):
- continue
- indexInTree = noeud.treeParent.children.index(noeud)
- indice = 0
- for index in listeIndex:
- if index < indexInTree:
- indice = indice + 1
- listeIndex.insert(indice, indexInTree)
- listeNoeudsACouper.insert(indice, noeud)
-
- noeudJdc = noeudOuColler.treeParent
- dejaCrees = 0
- # on les cree a l'envers parcequ'on ajoute a NoeudOuColler
- listeIndex.reverse()
- for index in listeIndex:
- indexTravail = index
- if indexNoeudOuColler < index:
- indexTravail = indexTravail + dejaCrees
- noeudOuColler = noeudJdc.children[indexNoeudOuColler]
- noeud = noeudJdc.children[indexTravail]
- child = noeud.doPaste(noeudOuColler)
- listeChild.append(child)
- dejaCrees = dejaCrees + 1
-
- self.QWParent.noeud_a_editer = []
- for i in range(len(listeIndex)):
- noeud = noeudJdc.children[indexNoeudOuColler + 1 + i]
- self.QWParent.noeud_a_editer.append(noeud)
-
- listeASupprimer = []
- if self.QWParent.edit != "couper":
- return
-
- for index in listeIndex:
- indexTravail = index
- if indexNoeudOuColler < index:
- indexTravail = indexTravail + (len(listeIndex))
- noeud = noeudJdc.children[indexTravail]
-
- listeItem.append(noeud.item)
- listeASupprimer.append(noeud)
-
- for i in range(len(listeChild)):
- self.tree.item.suppItem(listeItem[i])
- listeChild[i].item.update(listeItem[i])
-
- self.QWParent.noeud_a_editer = []
-
- # ----------------------------------#
- def handleAjoutEtape(self, nomEtape):
- # ----------------------------------#
- self.chercheNoeudSelectionne()
- if len(self.node_selected) == 0 or self.node_selected[0] == self.tree.racine:
- nodeOuAjouter = self.tree.racine
- nouveau = nodeOuAjouter.appendChild(nomEtape, pos="first")
- else:
- nodeOuAjouter = self.node_selected[0]
- if nodeOuAjouter != self.tree.racine:
- while nodeOuAjouter.treeParent != self.tree.racine:
- nodeOuAjouter = nodeOuAjouter.treeParent
- nouveau = nodeOuAjouter.appendBrother(nomEtape)
- try:
- self.node_selected[0].setSelected(False)
- except:
- pass
- nouveau.setSelected(True)
- nouveau.affichePanneau()
-
- # ---------------------------#
- def getFileVariable(self):
- # ---------------------------#
- titre = tr("Choix d'un fichier XML")
- texte = tr("Le fichier contient une commande MODEL\n")
- texte = texte + tr(
- "Donnez le nom du fichier XML qui contient la description des variables"
- )
- QMessageBox.information(self, titre, tr(texte))
-
- fichier = QFileDialog.getOpenFileName(
- self.appliEficas,
- tr("Ouvrir Fichier"),
- self.appliEficas.maConfiguration.savedir,
- tr("Wrapper Files (*.xml);;" "All Files (*)"),
- )
- return fichier
-
- # ------------#
- def run(self):
- # ------------#
- fonction = "run" + self.code
- if fonction in JDCEditor.__dict__:
- JDCEditor.__dict__[fonction](
- self,
- )
-
- # ------------#
- def saveRun(self):
- # ------------#
- fonction = "saveRun" + self.code
- if fonction in JDCEditor.__dict__:
- JDCEditor.__dict__[fonction](
- self,
- )
-
- # ---------------------------------------------
- # Methodes Non Crees dans ssIHM
- # ---------------------------------------------
- # ---------------#
- def runVP(self):
- # ---------------#
- texte = self.getTextJDC("MAPVp", pourRun=1)
- print(texte)
-
- # ---------------#
- def runMAP(self):
- # ---------------#
-
- if not (self.jdc.isValid()):
- QMessageBox.critical(
- self,
- tr("Execution impossible "),
- tr("le JDC doit etre valide pour une execution MAP"),
- )
- return
- if len(self.jdc.etapes) != 1:
- QMessageBox.critical(
- self,
- tr("Execution impossible "),
- tr("le JDC doit contenir un et un seul composant"),
- )
- return
- if self.modified or self.fichier == None:
- self.fichierMapInput = self.generateTempFilename(
- prefix="map_run", suffix=".map"
- )
- texte = self.getTextJDC("MAP")
- self.writeFile(self.fichierMapInput, txt=texte)
- else:
- self.fichierMapInput = self.fichier
- composant = self.jdc.etapes[0].nom.lower()[0:-5]
-
- # :TRICKY: to determine if a component requires SALOME, loads the component from Eficas catalog
- # then instantiate corresponding class and call getUseSalome() method
- try:
- from mapengine.spec import factory
-
- mapComponent = factory.new(composant)[0]
-
- command = "map"
- if mapComponent.getUseSalome():
- command += " -r sappli"
- textePython = (
- command + " run -n " + composant + " -i " + self.fichierMapInput
- )
-
- # textePython="ls -l"
- self._viewTextExecute(textePython, "map_run", ".sh")
- # try:
- # commande="rm "+self.fichierMapInput
- # os.system(commande)
- # except :
- # pass
- except Exception as e:
- print((traceback.print_exc()))
-
- # -------------------#
- def runZCRACKS(self):
- # -------------------#
- if not (self.jdc.isValid()):
- QMessageBox.critical(
- self,
- tr("Execution impossible "),
- tr("le JDC doit etre valide pour une execution "),
- )
- return
- if self.modified or self.fichier == None:
- # if 1:
- self.fichierZcracksInput = self.generateTempFilename(
- prefix="zcracks_run", suffix=".z7p"
- )
- texte = self.getTextJDC("ZCRACKS", pourRun=1)
- self.writeFile(self.fichierZcracksInput, txt=texte)
- else:
- self.fichierZcracksInput = self.fichier
- try:
- # commande ="Zrun -zp "
- commande = "more "
- textePython = commande + self.fichierZcracksInput
- self._viewTextExecute(textePython, "run_zcracks", ".sh")
- except Exception as e:
- print((traceback.print_exc()))
-
- # -------------------#
- def runCARMELCND(self):
- # -------------------#
- # if not(self.jdc.isValid()):
- # QMessageBox.critical( self, tr( "Execution impossible "),tr("le JDC doit etre valide pour une execution "))
- # return
- if self.modified or self.fichier == None:
- QMessageBox.critical(
- self,
- tr("Execution impossible "),
- tr("Sauvegarder SVP avant l'execution "),
- )
- return
- if not hasattr(self, "generator"):
- texte = self.getTextJDC(self.formatFichierOut)
- from PrepareRunCarmel import prepareRunCarmel
-
- fichierGenerique = os.path.basename(self.fichier).split(".")[0]
- repMed = os.path.dirname(self.fichier)
- repExeCarmel = self.generator.get_repExeCarmel()
- textePython = prepareRunCarmel(repExeCarmel, repMed, fichierGenerique)
- nomFichier = self.generateTempFilename("carmel_run", suffix=".sh")
- f = open(nomFichier, "w")
- f.write(textePython)
- f.close()
- commande = "xterm -e sh " + nomFichier + "\n"
- os.system(commande)
-
- # -------------------#
- def runCarmelCS(self):
- # -------------------#
- try:
- commande = "runSession pilotyacsCS.py"
- os.system(commande)
- except Exception as e:
- print((traceback.print_exc()))
-
- # -----------------------------------------------------#
- def determineNomFichier(self, path, extension):
- # -----------------------------------------------------#
- if self.appliEficas.code in DictExtensions:
- chaine1 = (
- DictExtensions[self.appliEficas.code]
- + " (*."
- + DictExtensions[self.appliEficas.code]
- + ");;"
- )
- extensions = tr(chaine1 + "All Files (*)")
- else:
- extensions = tr("JDC (*.comm);;" "All Files (*)")
-
- if self.appliEficas.code == "MAP":
- extensions = extensions + ";; Run (*.input);;"
-
- fn = QFileDialog.getSaveFileName(
- self,
- tr("sauvegarde"),
- path,
- extensions,
- None,
- QFileDialog.DontConfirmOverwrite,
- )
- if fn == None:
- return (0, None)
- fn = fn[0]
- if fn == "":
- return (0, None)
-
- ext = QFileInfo(fn).suffix()
- if ext == "":
- fn += extension
-
- if QFileInfo(fn).exists():
- msgBox = QMessageBox(self)
- msgBox.setWindowTitle(tr("Sauvegarde du Fichier"))
- msgBox.setText(tr("Le fichier") + " " + str(fn) + " " + tr("existe deja"))
- msgBox.addButton(tr("&Ecraser"), 0)
- msgBox.addButton(tr("&Abandonner"), 1)
- abort = msgBox.exec_()
- if abort == 1:
- return (0, "")
- return (1, fn)
-
- # -----------------#
- def saveRunMAP(self):
- # -----------------#
- extension = ".input"
- if not (self.jdc.isValid()):
- QMessageBox.critical(
- self,
- tr("Sauvegarde de l'input impossible "),
- tr("Un JdC valide est necessaire pour creer un .input"),
- )
- return
- try:
- composant = self.jdc.etapes[0].nom.lower()[0:-5]
- except:
- QMessageBox.critical(
- self,
- tr("Sauvegarde de l'input impossible "),
- tr("Choix du composant obligatoire"),
- )
- return
- if hasattr(self.maConfiguration, "savedir"):
- path = self.maConfiguration.savedir
- else:
- path = "C:/"
-
- monNomFichier = ""
- if self.fichier is not None and self.fichier != "":
- maBase = str(QFileInfo(self.fichier).baseName()) + ".input"
- monPath = str(QFileInfo(self.fichier).absolutePath())
- monNomFichier = os.path.join(monPath, maBase)
- elif hasattr(self, "monNomFichierInput"):
- monNomFichier = self.monNomFichierInput
-
- monDialog = QFileDialog(self.appliEficas)
- monDialog.setDirectory(path)
- monDialog.setWindowTitle("Save")
-
- for c in monDialog.children():
- if isinstance(c, QDialogButtonBox):
- for b in c.children():
- if isinstance(b, QPushButton):
- avant = b.text()
- if avant == "&Open":
- b.setText("Save")
- mesFiltres = "input Map (*.input);;All Files (*)"
- monDialog.setNameFilters(mesFiltres)
- if monNomFichier != "":
- monDialog.selectFile(monNomFichier)
- BOk = monDialog.exec_()
- if BOk == 0:
- return
- fn = str(monDialog.selectedFiles()[0])
- if fn == "" or fn == None:
- return
- if not fn.endswith(".input"):
- fn += ".input"
- self.monNomFichierInput = fn
-
- if (
- not hasattr(self, "fichierMapInput")
- or not self.fichierMapInput
- or not os.path.exists(self.fichierMapInput)
- ):
- self.fichierMapInput = self.generateTempFilename(
- prefix="map_run", suffix=".map"
- )
- texte = self.getTextJDC("MAP")
- self.writeFile(self.fichierMapInput, txt=texte)
-
- cmd = (
- "map gen -t dat -n "
- + composant
- + " -i "
- + self.fichierMapInput
- + " -o "
- + fn
- )
- p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
- (output, err) = p.communicate()
-
- # -----------------#
- def saveRunPSEN(self):
- # -----------------#
- # print ("saveRunPSEN")
- self.saveFile()
-
- # -----------------------------------------#
- def handleAjoutGroup(self, listeGroup):
- # -----------------------------------------#
- try:
- # if 1:
- from ajoutGroupe import handleAjoutGroupFiltre
-
- # print listeGroup
- handleAjoutGroupFiltre(self, listeGroup)
- # print "apres handleAjoutGroupFiltre"
- except:
- # else :
- pass
-
- # -----------------------------------------------------------------#
- def saveCompleteFile(self, path=None, saveas=0, formatLigne="beautifie"):
- # -----------------------------------------------------------------#
- extension = ".casR"
- fn = self.fichierComplet
- # saveas=True # Pour forcer le nom
- self.generator = self.maConfiguration.mesGenerators.plugins[
- self.formatFichierOut
- ]()
- if self.fichierComplet is None or saveas:
- if path is None:
- path = self.maConfiguration.savedir
- bOK, fn = self.determineNomFichier(path, extension)
- if bOK == 0:
- return (0, None)
- if fn == None:
- return (0, None)
- if fn == "":
- return (0, None)
-
- ulfile = os.path.abspath(fn)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- fn = QDir.toNativeSeparators(fn)
-
- self.fichierComplet = os.path.splitext(fn)[0] + extension
-
- if hasattr(self.generator, "writeComplet"):
- self.generator.writeComplet(
- self.fichierComplet,
- self.jdc,
- config=self.appliEficas.maConfiguration,
- appliEficas=self.appliEficas,
- )
-
- if self.salome:
- self.appliEficas.addJdcInSalome(self.fichierComplet)
-
- self.modified = 0
- nouveauTitre = (
- self.titre + " " + str(os.path.basename(self.fichierComplet))
- )
- self.appliEficas.setWindowTitle(nouveauTitre)
- return (1, self.fichierComplet)
-
- # -----------------------------------------------------------------#
- def saveFile(self, path=None, saveas=0, formatLigne="beautifie"):
- # -----------------------------------------------------------------#
- """
- Public slot to save the text to a file.
-
- @param path directory to save the file in (string or QString)
- @return tuple of two values (boolean, string) giving a success indicator and
- the name of the saved file
- """
-
- self.modified = 1
- if not self.modified and not saveas:
- return (0, None) # do nothing if text wasn't changed
-
- if self.appliEficas.code in DictExtensions:
- extension = DictExtensions[self.appliEficas.code]
- else:
- extension = ".comm"
-
- newName = None
- fn = self.fichier
- if self.fichier is None or saveas:
- if path is None:
- path = self.maConfiguration.savedir
- bOK, fn = self.determineNomFichier(path, extension)
- if bOK == 0:
- return (0, None)
- if fn == None:
- return (0, None)
- if fn == "":
- return (0, None)
-
- ulfile = os.path.abspath(fn)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- fn = QDir.toNativeSeparators(fn)
- newName = fn
-
- if not (self.writeFile(fn, formatLigne=formatLigne)):
- return (0, None)
- self.fichier = fn
- self.modified = False
- if self.fileInfo is None or saveas:
- self.fileInfo = QFileInfo(self.fichier)
- self.fileInfo.setCaching(0)
- self.lastModified = self.fileInfo.lastModified()
- if newName is not None:
- self.appliEficas.addToRecentList(newName)
- self.tree.racine.item.getObject().nom = os.path.basename(newName)
- self.tree.racine.updateNodeLabel()
-
- if self.jdc.cata.modeleMetier:
- self.jdc.toXml(self.fichier)
- if self.jdc.cata.modeleMetier and self.jdc.isValid():
- if self.generator != self.XMLGenerator:
- self.XMLGenerator.gener(self.jdc)
- self.XMLGenerator.writeDefault(fn)
-
- if self.jdc.isValid() != 0 and hasattr(self.generator, "writeDefault"):
- # if hasattr(self.generator, "writeDefault"):
- self.generator.writeDefault(fn)
- elif self.code == "TELEMAC" and hasattr(self.generator, "writeDefault"):
- msgBox = QMessageBox(None)
- msgBox.setWindowTitle(tr("Fichier .cas invalide / incomplet"))
- msgBox.setText(tr("Le fichier .cas est invalide / incomplet"))
- msgBox.addButton(tr("&Sauvegarder"), 1)
- msgBox.addButton(tr("&Quitter sans sauvegarder"), 0)
- msgBox.addButton(tr("&Annuler"), 2)
- res = msgBox.exec_()
- if res == 0:
- self.generator.writeDefault(fn)
- return (1, self.fichier)
- if res == 2:
- return (0, None)
- if self.appliEficas.salome:
- self.appliEficas.close()
- else:
- sys.exit(1)
-
- if self.salome:
- self.appliEficas.addJdcInSalome(self.fichier)
- self.modified = 0
- nouveauTitre = (
- self.titre + " " + str(os.path.basename(self.fichier))
- )
- self.appliEficas.setWindowTitle(nouveauTitre)
-
- return (1, self.fichier)
-
- # -------------------------------------------#
- def sauvePourPersalys(self, fichier=None):
- # -------------------------------------------#
- if self.jdc.isValid() == 0:
- self.informe(
- "Fichier invalide/incomplet",
- "Impossible de sauvegarder l étude Persalys",
- critique=False,
- )
- return
- if self.fichier is None:
- if path is None:
- path = self.maConfiguration.savedir
- bOK, fn = self.determineNomFichier(path, "comm")
- if bOK == 0:
- return (0, None)
- if fn == None:
- return (0, None)
- if fn == "":
- return (0, None)
- ulfile = os.path.abspath(fn)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- fn = QDir.toNativeSeparators(fn)
- self.fichier = fn
- else:
- fn = self.fichier
- ret, comm = JDCEditorSsIhm.sauvePourPersalys(self, fn)
- if not ret:
- if not comm:
- comm = "Impossible de sauvegarder l étude Persalys"
- self.informe(" invalide/incomplet", comm, critique=False)
- return
-
- # -----------------------------------------------#
- def saveUQFile(self, fichier=None, path=None):
- # ------------------------------------------------#
- if self.fichier is None:
- if path is None:
- path = self.maConfiguration.savedir
- bOK, fn = self.determineNomFichier(path, "comm")
- if bOK == 0:
- return (0, None)
- if fn == None:
- return (0, None)
- if fn == "":
- return (0, None)
- ulfile = os.path.abspath(fn)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- print(fn)
- fn = QDir.toNativeSeparators(fn)
- self.fichier = fn
- else:
- fn = self.fichier
-
- if self.jdc.isValid() == 0:
- msgBox = QMessageBox(None)
- msgBox.setWindowTitle(tr("Fichier invalide / incomplet"))
- msgBox.setText(
- tr(
- "Le fichier .comm est invalide / incomplet \n Seuls les .comm et _det.comm seront sauvegardes"
- )
- )
- msgBox.addButton(tr("&Sauvegarder les .comm et _det.comm"), 0)
- msgBox.addButton(tr("&Quitter sans sauvegarder"), 1)
- msgBox.addButton(tr("&Annuler"), 2)
- res = msgBox.exec_()
- if res == 2:
- return (0, None)
- if res == 0:
- ret, fichier = JDCEditorSsIhm.saveUQFile(self, fn)
- if ret:
- self.fichier = fichier
- if self.salome and ret:
- self.appliEficas.addJdcInSalome(self.fichier)
- return (1, self.fichier)
- if self.appliEficas.salome:
- self.appliEficas.close()
- else:
- sys.exit(1)
-
- ret, comm = JDCEditorSsIhm.saveUQFile(self, fn)
- if not ret:
- if comm:
- titre = "Probleme de sauvegarde des fichiers"
- texte = "Impossible de sauvegarder {}".format(fn)
- QMessageBox.information(self, titre, texte)
- return (0, self.fichier)
- return (1, self.fichier)
-
- # -----------------------------------------------#
- def exeUQ(self, fichier=None, path=None):
- # ------------------------------------------------#
- # if self.modified or not self.fichier :
- sauvegarde, fichier = self.saveUQFile()
- if not sauvegarde:
- return 0
- # texteCommande=' export COLUMNS=200;'
- try:
- virtual_env = os.environ["VIRTUAL_ENV"]
- except:
- titre = "Probleme d'environnement"
- texte = "La variable d'environnement VIRTUAL_ENV n'est pas positionnée"
- QMessageBox.information(self, titre, texte)
- return False
-
- texteCommande = (
- os.path.join(os.environ["VIRTUAL_ENV"], "bin/salome")
- + " start -k -t python3 "
- + os.path.join(
- self.generator.cheminFichierComm, self.generator.fichierUQExe
- )
- )
- # self._viewTextExecute(None,None,None, fichierExe=self.generator.fichierUQExe, shell='python3')
- # self._viewTextExecute('ls -l /tmp','essaiLs','.sh',)
- # self._viewTextExecute(None,None,None, fichierExe='/home/A96028/QT5Dev/eficasRN/ReacteurNumerique/a.py',shell='python3',)
- self._viewTextExecute(None, None, None, texteCommande=texteCommande)
- return True
-
- # ----------------------------------------------#
- def sauveLigneFile(self):
- # ----------------------------------------------#
- self.modified = 1
- return self.saveFile(formatLigne="Ligne")
-
- # ----------------------------------------------#
- def saveFileAs(self, path=None, fileName=None):
- # ----------------------------------------------#
- """
- Public slot to save a file with a new name.
-
- @param path directory to save the file in (string or QString)
- @return tuple of two values (boolean, string) giving a success indicator and
- the name of the saved file
- """
- if fileName != None:
- self.fichier = fileName
- return self.saveFile()
- return self.saveFile(path, 1, "beautifie")
-
- # ---------------------------------------------#
- def getFile(self, unite=None, fic_origine=""):
- # ---------------------------------------------#
- # appele par I_JDC
- ulfile = None
- jdcText = ""
-
- titre = ""
-
- if unite:
- titre = tr("Choix unite %d ", unite)
- texte = (
- tr("Le fichier %s contient une commande INCLUDE \n", str(fic_origine))
- + "\n"
- )
- texte = (
- texte
- + tr("Donnez le nom du fichier correspondant a l unite logique ")
- + repr(unite)
- )
- labeltexte = tr("Fichier pour unite ") + repr(unite)
- else:
- titre = tr("Choix d'un fichier de poursuite")
- texte = tr("Le fichier %s contient une commande POURSUITE\n", fic_origine)
- texte = texte + tr(
- "Donnez le nom du fichier dont vous \n voulez faire une poursuite"
- )
-
- QMessageBox.information(self, titre, texte)
- fn = QFileDialog.getOpenFileName(
- self.appliEficas, titre, self.appliEficas.maConfiguration.savedir
- )
-
- # ce retour est impose par le getFile d'I_JDC
- if fn == "":
- return None, " "
- if not fn:
- return (0, " ")
- fn = fn[0]
-
- ulfile = os.path.abspath(fn)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
-
- # On utilise le convertisseur defini par formatFichierIn
- source = self.getSource(ulfile)
- if source:
- # On a reussia convertir le fichier self.ulfile
- jdcText = source
- else:
- # Une erreur a ete rencontree
- jdcText = ""
- return ulfile, jdcText
-
- # -----------------------------------#
- def updateJdc(self, etape, texte):
- # ------------------------------------#
- # ajoute une etape de JdC a partir d un texte
- CONTEXT.setCurrentStep(etape)
- etape.buildIncludeEtape(texte)
- if not (etape.text_included_converted):
- QMessageBox.information(
- self, tr("Impossible d importer le texte"), etape.text_included_error
- )
-
- self.tree.racine.buildChildren()
-
- # -----------------------------------#
- def updateJdcEtape(self, itemApres, texte):
- # ------------------------------------#
- # ajoute une etape de JdC a partir d un texte
- monItem = itemApres
- etape = monItem.item.object
-
- CONTEXT.setCurrentStep(etape)
- try:
- ok = etape.buildIncludeEtape(texte)
- except:
- ok = 0
- if not ok:
- QMessageBox.information(
- self, tr("Import texte"), tr("Impossible d importer le texte")
- )
- self.tree.racine.buildChildren()
- return ok
-
- # -------------------------------------------#
- def updateJdcAfterEtape(self, etape, texte):
- # --------------------------------------------#
- # ajoute une etape de JdC a partir d un texte
- CONTEXT.setCurrentStep(etape)
- try:
- ok = etape.buildIncludeEtape(texte, doitEtreValide=0)
- except:
- ok = 0
- if not ok:
- QMessageBox.information(
- self, tr("Import texte"), tr("Impossible d importer le texte")
- )
- self.tree.racine.buildChildren()
- return ok
-
- # -------------------------------------#
- def deleteEtape(self, etape):
- # -------------------------------------#
- # dans le JDC
- self.jdc.suppEntite(etape)
-
- # -----------------------------------------
- def initSplitterSizes(self, nbWidget=3):
- # -----------------------------------------
- # print ("je passe ds initSplitterSizes", nbWidget)
-
- if self.code in ["Adao", "ADAO", "MAP"]:
- self.splitterSizes3 = [1, 1550, 300]
- # elif self.code in [ 'MAP'] : self.splitterSizes3=[700,300]
- else:
- self.splitterSizes3 = [150, 1000, 300]
-
- if self.code in ["Adao", "ADAO", "MAP"]:
- self.splitterSizes2 = [5, 1500]
- else:
- self.splitterSizes2 = [300, 1000]
-
- # -----------------------------------------
- def restoreSplitterSizes(self, nbWidget=3):
- # ----------------------------------------
-
- # traceback.print_stack()
- # print ("je passe ds restoreSplitterSizes")
- if not (hasattr(self, "splitter")):
- return
- if nbWidget == 2:
- newSizes = self.splitterSizes2
- if nbWidget == 3:
- newSizes = self.splitterSizes3
- # self.inhibeSplitter = 1
- # print (newSizes)
- self.splitter.setSizes(newSizes)
- # self.inhibeSplitter = 0
- QApplication.processEvents()
- # seule la fentetre du milieu est necessaire
- self.splitter.widget(1).resizeEvent = self.saveSplitterSizes
-
- # -----------------------------------------
- def saveSplitterSizes(self, event):
- # -----------------------------------------
- # print ("je passe ds saveSplitterSizes")
- if self.inhibeSplitter:
- return
- if self.widgetOptionnel == None:
- self.splitterSizes2 = self.splitter.sizes()[0:2]
- else:
- self.splitterSizes3 = self.splitter.sizes()[0:3]
-
- # ------------------------
- def fermeOptionnel(self):
- # ------------------------
- if self.widgetOptionnel == None:
- return
-
- self.inhibeSplitter = 1
- self.widgetOptionnel.setParent(None)
- self.widgetOptionnel.close()
- self.widgetOptionnel.deleteLater()
- self.widgetOptionnel = None
- self.inhibeSplitter = 0
- self.restoreSplitterSizes(2)
-
- # ------------------------
- def ajoutOptionnel(self):
- # ------------------------
- # if len(self.splitterSizes) == 2 : self.splitterSizes.append(self.oldSizeWidgetOptionnel)
- # else : self.splitterSizes[2] = self.oldSizeWidgetOptionnel # ceinture pour les close bizarres
- # self.splitterSizes[1] = self.splitterSizes[1] - self.splitterSizes[2]
-
- self.restoreSplitterSizes(3)
-
- # ------------------------
- def fermeArbre(self):
- # ------------------------
- # print (self.widgetTree)
- self.oldWidgetTree = self.widgetTree
- self.widgetTree.hide()
- # self.widgetTree=None
-
- # ------------------------
- def ouvreArbre(self):
- # ------------------------
- # print ('je passe la')
- # print (self.widgetTree)
- # self.widgetTree=self.oldWidgetTree
- self.widgetTree.show()
- # self.restoreSplitterSizes(3)
-
- # -----------------------
- def getEtapeCourante(self):
- # -----------------------
- if len(self.tree.selectedItems()) != 1:
- return None
- etape = self.tree.selectedItems()[0].item.object.getEtape()
- return etape
-
- # -----------------------------
- def getTreeIndex(self, noeud):
- # ----------------------------
- indexNoeud = -1
- if noeud in noeud.treeParent.children:
- indexNoeud = noeud.treeParent.children.index(noeud)
- else:
- if hasattr(noeud, "vraiParent"):
- noeudVrai = noeud
- noeudVraiParent = noeud.vraiParent
- while noeudVraiParent != noeud.treeParent and hasattr(
- noeudVraiParent, "vraiParent"
- ):
- noeudVrai = noeudVraiParent
- noeudVraiParent = noeudVraiParent.vraiParent
- pass
- if noeudVraiParent == noeud.treeParent:
- indexNoeud = noeud.treeParent.children.index(noeudVrai)
- pass
- pass
- pass
- return indexNoeud
-
- # -------------------# Pour execution avec output et error dans le bash
- def runPSEN(self):
- # -------------------#
-
- # if self.modified or self.fichier==None : self.saveFile()
- self.saveFile()
-
- # lancement avec le .bat
- path1 = os.path.abspath(
- os.path.join(os.path.abspath(__file__), "../", "../", "PSEN_Eficas", "PSEN")
- )
- WrapperFilePath = os.path.join(path1, "PSSEWrapper.py")
- import subprocess
-
- p = subprocess.Popen(["python", WrapperFilePath])
- (out, err) = p.communicate()
- print(out)
- print(err)
-
- # -------------------# Pour execution avec output et error dans le bash
- def runPSEN_N1(self):
- # -------------------#
-
- self.saveFile()
- path1 = os.path.abspath(
- os.path.join(
- os.path.abspath(__file__),
- "../",
- "../",
- "ProcessOutputs_Eficas",
- "TreatOutputs",
- )
- )
- sys.path.append(path1)
-
- if not (self.jdc.isValid()):
- QMessageBox.information(
- self, tr("Unvalid JDC"), tr("incorrect keywords will be ignored")
- )
- if "dicoImbrique" in generator.plugins:
- self.generator = generator.plugins["dicoImbrique"]()
- jdc_formate = self.generator.gener(self.jdc)
- dico = self.generator.Dico
-
- ###to delete
- # fileDico = r'C:\Logiciels DER\PSEN_V16\Code\ProcessOutputs_Eficas\TreatOutputs\dicoN1.py'
- fileDico = os.path.join(
- path1, "dicoN1.py"
- ) # r'C:\Logiciels DER\PSEN_V16\Code\ProcessOutputs_Eficas\TreatOutputs\dicoN1.py'
- f = open(str(fileDico), "w")
- f.write("Dico =" + str(dico))
- f.close()
- ###
-
- print("in runPSEN_N1", dico)
- print(dico)
- from Run import run
-
- run(dico)
- # res,txt_exception=run(dico)
- # if res : QMessageBox.information( self, tr("fin de script run"), txt_exception)
- # else : QMessageBox.critical( self, tr("Erreur fatale script run"), txt_exception)
-
- # -------------------# Pour execution avec output et error dans le bash
- def process_N1(self):
- # -------------------#
-
- path1 = os.path.abspath(
- os.path.join(
- os.path.abspath(__file__),
- "../",
- "../",
- "ProcessOutputs_Eficas",
- "TreatOutputs",
- )
- )
- sys.path.append(path1)
-
- if "dicoImbrique" in generator.plugins:
- self.generator = generator.plugins["dicoImbrique"]()
- jdc_formate = self.generator.gener(self.jdc)
- dico = self.getDico() # generator.Dico
-
- for k in dico["CONTINGENCY_PROCESSING"]:
- # print (k)
- if (
- k[0:19] == "Component_List_For_"
- or k[0:21] == "Contingency_List_For_"
- ):
- newK = k.replace("__", " ")
- l = "'" + str(newK) + "'"
- dico["CONTINGENCY_PROCESSING"][l] = dico["CONTINGENCY_PROCESSING"][
- k
- ]
- del dico["CONTINGENCY_PROCESSING"][k]
-
- ###to delete
- fileDico = os.path.join(path1, "dicoN1_process.py")
- f = open(str(fileDico), "w")
- f.write("Dico =" + str(dico))
- f.close()
- ###
- return dico
-
- # return self.getDico()
-
- # -------------------# Pour execution avec output et error dans le bash
- def process_VP(self):
- # -------------------#
- if "dicoImbrique" in generator.plugins:
- self.generator = generator.plugins["dicoImbrique"]()
- jdc_formate = self.generator.gener(self.jdc)
- dico = self.getDico() # generator.Dico
- return dico
-
-
-if __name__ == "__main__":
- print("in main")
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, sys, os, re
-import subprocess
-import traceback
-
-# Modules Eficas
-
-import convert, generator
-from Editeur import session
-from Editeur import comploader
-from Editeur import Objecttreeitem
-
-DictExtensions = {"MAP": ".map", "TELEMAC": ".cas"}
-debug = False
-
-
-class JDCEditorSsIhm:
- # ------------------- #
- """
- Editeur de jdc
- """
-
- # ---------------------------------------------
- # Methodes Communes ou appelees depuis avec Ihm
- # ---------------------------------------------
-
- def __init__(self, appliEficas, fichier=None, jdc=None, units=None, include=0):
- # -----------------------------------------------------------------------------------#
- # paticularisee avec Ihm
-
- if debug:
- print("dans le init de JDCEditorSsIhm")
- self.appliEficas = appliEficas
- self.fichier = fichier
- self.fichierComplet = fichier
- if fichier != None:
- self.extensionFichier = os.path.splitext(fichier)[1]
- else:
- self.extensionFichier = None
- self.jdc = jdc
- self.first = True
- self.jdc_item = None
- self.dicoNouveauxMC = {}
- self.dicoNouveauxFact = {}
- self.dict_reels = {}
- self.liste_simp_reel = []
-
- if self.appliEficas != None:
- self.salome = self.appliEficas.salome
- else:
- self.salome = 0
-
- # ces attributs sont mis a jour par definitCode appelee par newEditor
- self.code = self.appliEficas.maConfiguration.code
- self.maConfiguration = self.appliEficas.maConfiguration
-
- if (
- not hasattr(self.appliEficas, "readercata")
- or self.appliEficas.readercata.demandeCatalogue == True
- or self.appliEficas.multi == True
- ):
- if self.maConfiguration.typeDeCata == "XML":
- from InterfaceQT4 import readercataXML as readercata
- else:
- from InterfaceQT4 import readercata
- self.readercata = readercata.ReaderCata(self, self.appliEficas)
- self.appliEficas.readercata = self.readercata
- self.appliEficas.code = self.code
- else:
- self.readercata = self.appliEficas.readercata
- if self.readercata.fichierCata == None:
- return # Sortie Salome
- if self.readercata.cata == None:
- return # Sortie Salome
- if self.readercata.cata == 0:
- return # Sortie Salome
- self.titre = self.readercata.titre
-
- self.formatFichierOut = self.appliEficas.formatFichierOut
- self.formatFichierIn = self.appliEficas.formatFichierIn
-
- # if self.appliEficas.maConfiguration.dumpXSD==True : self.appliEficas.dumpXsd()
- self.dict_reels = {}
- self.liste_simp_reel = []
- self.dicoNouveauxMC = {}
- self.dicoNouveauxFact = {}
-
- try:
- self.maConfiguration.generator_module
- _module = __import__(self.maConfiguration.generator_module)
- info = _module.entryPoint()
- generator.plugins.addEntryPoint(info)
- except:
- pass
-
- try:
- self.maConfiguration.convert_module
- # print self.maConfiguration.convert_module
- _module = __import__(self.maConfiguration.convert_module)
- info = _module.entryPoint()
- convert.plugins.addEntryPoint(info)
- except:
- pass
-
- self.maConfiguration.mesGenerators = generator
- self.maConfiguration.mesconvertisseurs = convert
- try:
- self.XMLGenerator = generator.plugins["xml"]()
- except:
- self.XMLGenerator = None
- try:
- self.pythonGenerator = generator.plugins["python"]()
- except:
- self.pythonGenerator = None
-
- if self.formatFichierOut in generator.plugins.keys():
- self.generator = generator.plugins[self.formatFichierOut]()
-
- self.fileInfo = None
- self.lastModified = 0
-
- self.modified = False
- self.isReadOnly = False
-
- # ------- construction du jdc --------------
-
- self.nouveau = 0
- if self.fichier is not None: # fichier jdc fourni
- if jdc == None:
- # print ('PNPN : chgt try en if')
- try:
- # if 1 :
- self.jdc = self.readFile(self.fichier)
- except:
- print("mauvaise lecture du fichier")
- if self.salome:
- try:
- self.appliEficas.addJdcInSalome(self.fichier)
- except:
- print("mauvais enregistrement dans Salome")
- else:
- self.jdc = jdc
-
- if self.jdc is not None and units is not None:
- self.jdc.recorded_units = units
- self.jdc.old_recorded_units = units
-
- else:
- if not self.jdc: # nouveau jdc
- if not include:
- self.jdc = self._newJDC(units=units)
- else:
- self.jdc = self._newJDCInclude(units=units)
- self.nouveau = 1
-
- if self.jdc:
- self.jdc.editor = self
- self.jdc.lang = self.appliEficas.langue
- self.jdc.aReafficher = False
- txt_exception = None
- if not jdc:
- if self.extensionFichier == ".xml":
- if self.appliEficas.maConfiguration.withXSD:
- self.jdc.analyseXML()
- else:
- print("run MDM with -x option (MDM for XML)")
- exit()
- else:
- self.jdc.analyse()
- if hasattr(self, "monConvert") and hasattr(
- self.monConvert, "traitementApresLoad"
- ):
- self.monConvert.traitementApresLoad(self.jdc)
- txt_exception = self.jdc.cr.getMessException()
- if txt_exception:
- self.jdc = None
- self.informe("pb chargement jdc", txt_exception)
-
- # -------------------------------#
- def readFile(self, fn):
- # --------------------------------#
- """
- Public slot to read the text from a file.
- @param fn filename to read from (string or QString)
- """
-
- # charge un JDC
- # paticularisee avec Ihm
-
- fn = str(fn)
- jdcName = os.path.basename(fn)
-
- # Il faut convertir le contenu du fichier en fonction du format
- formatIn = self.appliEficas.formatFichierIn
- if self.extensionFichier == ".xml" and self.appliEficas.maConfiguration.withXSD:
- formatIn = "xml"
- if formatIn in convert.plugins:
- # Le convertisseur existe on l'utilise
- monConvert = convert.plugins[formatIn]()
- monConvert.readfile(fn)
-
- if monConvert.text == "":
- self.nouveau = 1
- # print ('PNPN --> CIST a faire')
-
- if formatIn != "xml":
- pareil, texteNew = self.verifieChecksum(monConvert.text)
- if not pareil:
- self.informe(
- ("fichier modifie"),
- ("Attention! fichier change hors EFICAS"),
- False,
- )
- monConvert.text = texteNew
- memeVersion, texteNew = self.verifieVersionCataDuJDC(monConvert.text)
- if memeVersion == 0:
- texteNew = self.traduitCatalogue(texteNew)
- monConvert.text = texteNew
- text = monConvert.convert("exec", self.appliEficas)
- if not monConvert.cr.estvide():
- self.afficheInfos("Erreur a la conversion", "red")
- else:
- text = monConvert.text
- else:
- self.afficheInfos("Type de fichier non reconnu", "red")
- self.informe(
- "Type de fichier non reconnu",
- "EFICAS ne sait pas ouvrir le type de fichier "
- + self.appliEficas.formatFichierIn,
- )
- return None
-
- CONTEXT.unsetCurrentStep()
-
- # jdc=self.readercata.cata[0].JdC(procedure=text,
- # le jdc n est pas charge
- if not (hasattr(self.readercata, "cata_ordonne_dico")):
- return
- jdc = self.readercata.cata.JdC(
- procedure=text,
- appliEficas=self.appliEficas,
- cata=self.readercata.cata,
- cata_ord_dico=self.readercata.cata_ordonne_dico,
- nom=jdcName,
- rep_mat=self.maConfiguration.rep_mat,
- )
- self.modified = False
- self.monConvert = monConvert
- return jdc
-
- # --------------------------------#
- def _newJDC(self, units=None):
- # --------------------------------#
- """
- Initialise un nouveau JDC vierge
- """
- self.modified = 1
- CONTEXT.unsetCurrentStep()
-
- texte = ""
- if self.code == "CARMELCND":
- texte = self._newJDCCND()
- if self.code == "ZCRACKS":
- texte = self._newZCRACKS()
- if self.code == "PSEN":
- texte = self._newPSEN()
- if self.code == "PSEN_N1":
- texte = self._newPSEN_N1()
-
- if hasattr(self.readercata.cata, "TEXTE_NEW_JDC"):
- texte = self.readercata.cata.TEXTE_NEW_JDC
-
- jdc = self.readercata.cata.JdC(
- procedure=texte,
- appliEficas=self.appliEficas,
- cata=self.readercata.cata,
- cata_ord_dico=self.readercata.cata_ordonne_dico,
- rep_mat=self.maConfiguration.rep_mat,
- )
-
- jdc.lang = self.appliEficas.langue
- if units is not None:
- jdc.recorded_units = units
- jdc.old_recorded_units = units
- # chgt le 15/10/19
- # Attention positionne contexte ?
- # est ce qu on ne doit pas changer le format en Accas si on vient d accas ?
- jdc.editor = self
- return jdc
-
- # --------------------------------#
- def _newJDCInclude(self, units=None):
- # --------------------------------#
- """
- Initialise un nouveau JDC vierge
- """
- import Extensions.jdc_include
-
- JdC_aux = Extensions.jdc_include.JdC_include
- CONTEXT.unsetCurrentStep()
-
- # jaux=self.readercata.cata[0].JdC( procedure="",
- jaux = self.readercata.cata.JdC(
- procedure="",
- appliEficas=self.appliEficas,
- cata=self.readercata.cata,
- cata_ord_dico=self.readercata.cata_ordonne_dico,
- rep_mat=self.maConfiguration.rep_mat,
- )
- jaux.editor = self
- jaux.analyse()
-
- J = JdC_aux(
- procedure="",
- appliEficas=self.appliEficas,
- cata=self.readercata.cata,
- cata_ord_dico=self.readercata.cata_ordonne_dico,
- jdc_pere=jaux,
- rep_mat=self.maConfiguration.rep_mat,
- )
- J.editor = self
- J.analyse()
- if units is not None:
- J.recorded_units = units
- J.old_recorded_units = units
- return J
-
- # -----------------------#
- def getSource(self, file):
- # -----------------------#
-
- # Il faut convertir le contenu du fichier en fonction du format
- if self.formatFichierIn in convert.plugins:
- # Le convertisseur existe on l'utilise
- p = convert.plugins[self.formatFichierIn]()
- p.readfile(file)
- text = p.convert("execnoparseur")
- if not p.cr.estvide():
- self.afficheInfos("Erreur a la conversion", "red")
- return text
- else:
- # Il n'existe pas c'est une erreur
- self.afficheInfos("Type de fichier non reconnu", "red")
- self.informe(
- "Type de fichier non reconnu",
- "EFICAS ne sait pas ouvrir le type de fichier "
- + self.appliEficas.formatFichierIn,
- )
- return None
-
- # ----------------------------------------------#
- def __generateTempFilename(self, prefix, suffix):
- # ----------------------------------------------#
- import tempfile
-
- (fd, filename) = tempfile.mkstemp(prefix=prefix, suffix=suffix)
- os.close(fd)
- return filename
-
- # -----------------------#
- def generDico(self):
- # -----------------------#
- if "dico" in generator.plugins:
- self.generator = generator.plugins["dico"]()
- texte_jdc = self.generator.gener(self.jdc)
- return texte_jdc
-
- # -----------------------#
- def generDicoPython(self):
- # -----------------------#
- if "dico" in generator.plugins:
- self.generator = generator.plugins["dico"]()
- dico = self.generator.generDico(self.jdc)
- return dico
-
- # -----------------------#
- def viewJdcSource(self):
- # -----------------------#
- if self.fichier == None:
- return
- if os.path.isfile(self.fichier):
- f = open(self.fichier, "r")
- texteSource = f.read()
- f.close()
- self._viewText(texteSource, "JDC_SOURCE")
- else:
- self._viewText("file doesn't exist", "JDC_SOURCE")
-
- # -----------------------#
- def viewJdcPy(self):
- # -----------------------#
- strSource = str(self.getTextJDC(self.formatFichierOut))
- self._viewText(strSource, "JDC_RESULTAT")
-
- # -----------------------#
- def viewJdcRapport(self):
- # -----------------------#
- # on ajoute les regles
- strRapport = str(self.jdc.report())
- self._viewText(strRapport, "JDC_RAPPORT")
-
- # -----------------------#
- def viewJdcRegles(self):
- # -----------------------#
- # on ajoute les regles
- texte_global, test_global = self.jdc.verifRegles()
- self._viewText(texte_global, "JDC_REGLES")
-
- # -----------------------#
- def getJdcRapport(self):
- # -----------------------#
- # on ajoute les regles
- strRapport = str(self.jdc.report())
- return strRapport
-
- # ---------------------#
- def getFileName(self):
- # ---------------------#
- return self.fichier
-
- # -------------------#
- def initModif(self):
- # -------------------#
- """
- Met l'attribut modified a 'o' : utilise par Eficas pour savoir
- si un JDC doit etre sauvegarde avant destruction ou non
- """
- self.modified = True
-
- # --------------------------------------------------#
- def writeFile(self, fn, txt=None, formatLigne="beautifie"):
- # --------------------------------------------------#
- """
- Public slot to write the text to a file.
-
- @param fn filename to write to string
- @return flag indicating success
- """
-
- fn = str(fn)
-
- if txt == None:
- txt = self.getTextJDC(self.formatFichierOut, formatLigne=formatLigne)
- eol = "\n"
- if len(txt) >= len(eol):
- if txt[-len(eol) :] != eol:
- txt += eol
- else:
- txt += eol
- txt = self.ajoutVersionCataDsJDC(txt)
- if self.code != "PSEN" and self.code != "PSEN_N1":
- checksum = self.getChecksum(txt)
- else:
- checksum = ""
- txt = txt + checksum
- if self.code == "TELEMAC":
- return 1
- try:
- f = open(fn, "w")
- f.write(txt)
- f.close()
- return 1
- except IOError as why:
- print(
- "Sauvegarde du Fichier",
- "Le fichier" + str(fn) + "n a pas pu etre sauvegarde :",
- str(why),
- )
- self.afficheInfos(
- "Le fichier" + str(fn) + "n a pas pu etre sauvegarde ", "red"
- )
- return 0
-
- # -----------------------------------------------------------#
- def getTextJDC(self, format=None, pourRun=0, formatLigne="beautifie"):
- # -----------------------------------------------------------#
- if self.code == "MAP" and not (format in generator.plugins):
- format = "MAP"
- if format == None:
- format = self.formatFichierOut
- if format in generator.plugins:
- # Le generateur existe on l'utilise
- self.generator = generator.plugins[format]()
- try:
- jdc_formate = self.generator.gener(
- self.jdc,
- format=formatLigne,
- config=self.appliEficas.maConfiguration,
- appliEficas=self.appliEficas,
- )
- if pourRun:
- jdc_formate = self.generator.textePourRun
- if self.code == "TELEMAC":
- jdc_formate = self.generator.texteDico
- except ValueError as e:
- self.informe("Erreur a la generation", str(e), "red")
- return
-
- if not self.generator.cr.estvide():
- self.informe(
- "Erreur a la generation",
- "EFICAS ne sait pas convertir ce JDC",
- "red",
- )
- return ""
- else:
- return jdc_formate
- else:
- # Il n'existe pas c'est une erreur
- self.informe("Format inconnu", self.format + " non reconnu")
- return ""
-
- # ------------------------------#
- def verifieChecksum(self, text):
- # ------------------------------#
- # Attention : souci sous Windows
- #
- indexDeb = text.find("#CHECKSUM:")
- if indexDeb < 0:
- return 1, text
- indexFin = text.find(":FIN CHECKSUM")
- checkAvant = text[indexDeb : indexFin + 13]
- textJDC = text[0:indexDeb] + text[indexFin + 13 : -1]
- if self.code != "PSEN" and self.code != "PSEN_N1":
- checksum = self.getChecksum(textJDC)
- pareil = checkAvant == checksum
- else:
- pareil = 1
- return pareil, textJDC
-
- # ---------------------------#
- def getChecksum(self, texte):
- # ---------------------------#
- try:
- import hashlib
-
- newtexte = texte.replace('"', '\\"')
- hash_checksum = hashlib.md5()
- hash_checksum.update(newtexte.encode("utf-8"))
- checksum = hash_checksum.hexdigest()
- ligne = "#CHECKSUM:" + checksum + ":FIN CHECKSUM"
- except:
- try:
- newtexte = texte.replace('"', '\\"')
- commande = 'echo "' + newtexte + '"|md5sum'
- a = os.popen(commande)
- checksum = a.read()
- a.close()
- except:
- checksum = "Fichier trop long \n"
- ligne = "#CHECKSUM:" + checksum[0:-1] + ":FIN CHECKSUM"
- return ligne
-
- # ----------------------#
- def getDico(self):
- # ---------------------#
- if "dicoImbrique" in generator.plugins:
- self.generator = generator.plugins["dicoImbrique"]()
- # print (self.generator)
- jdc_formate = self.generator.gener(self.jdc)
- dico = self.generator.Dico
- return dico
- else:
- self.afficheInfos(
- tr("Format %s non reconnu", "Dictionnaire Imbrique"), "red"
- )
- return ""
-
- # -----------------------------------------#
- def chercheGroupes(self):
- # -----------------------------------------#
- listeMA, listeNO = self.getTextJDC("GroupMA")
- return listeMA, listeNO
-
- # -----------------------------------------#
- def chercheDico(self):
- # -----------------------------------------#
- dicoCourant = {}
- format = self.appliEficas.formatFichierOut
- if format in generator.plugins:
- # Le generateur existe on l'utilise
- self.generator = generator.plugins[format]()
- jdc_formate = self.generator.gener(
- self.jdc, format="beautifie", config=self.appliEficas.maConfiguration
- )
- dicoCourant = self.generator.dico
- return dicoCourant
-
- # -----------------------------------------------------------------#
- def saveFileLegerAs(self, fileName=None):
- # -----------------------------------------------------------------#
- if fileName != None:
- self.fichier = fileName
- return self.saveFileLeger(fileName)
- return self.saveFileLeger()
-
- # -----------------------------------------------------------------#
- def saveFileComplet(self, fichier=None, formatLigne="beautifie"):
- # -----------------------------------------------------------------#
- fn = fichier
- self.generator = generator.plugins[self.format]()
- print(self.generator)
- if hasattr(self.generator, "writeComplet"):
- self.generator.writeComplet(
- fichier,
- self.jdc,
- config=self.appliEficas.maConfiguration,
- appliEficas=self.appliEficas,
- )
-
- # -----------------------------------#
- def saveUQFile(self, fichier=None):
- # ------------------------------------#
- if fichier == None:
- self.informe("Sauvegarde", "nom de fichier obligatoire pour sauvegarde")
- return 0, None
- self.fichier = fichier
- self.generator = generator.plugins["UQ"]()
- ret, comm = self.generator.creeNomsFichiers(fichier)
- # print (ret,comm)
- if not ret:
- self.informe("Sauvegarde UQ", self.generator.commentaire)
- return ret, None
- ret = self.generator.gener(self.jdc)
- if not ret:
- self.informe("Sauvegarde UQ", self.generator.commentaire)
- return ret, None
- if ret == 2:
- self.informe("Sauvegarde UQ", self.generator.commentaire, critique=False)
- self.modified = False
- return 1, fichier
- ret = self.generator.writeUQ(fichier)
- if not ret:
- self.informe("Sauvegarde UQ", self.generator.commentaire)
- else:
- self.informe(
- "Sauvegarde UQ",
- "Sauvegardes des fichiers .comm, _det.comm effectuées.\n"
- "Création des fichiers _UQ.py et _@det.comm.",
- critique=False,
- )
- self.modified = False
- return ret, fichier
-
- # ------------------------------------------#
- def sauvePourPersalys(self, fichier=None):
- # -------------------------------------------#
- if fichier == None:
- self.informe(
- "Sauvegarde Etude Persalys",
- "nom de fichier obligatoire pour sauvegarde",
- )
- return 0, None
- self.generator = generator.plugins["UQ"]()
- ret, comm = self.generator.creeNomsFichiers(fichier)
- if not ret:
- self.informe("Sauvegarde Etude Persalys", self.generator.commentaire)
- fichierPersalys = self.generator.fichierUQExe
- ret = self.generator.gener(self.jdc)
- if not ret:
- self.informe("Sauvegarde Etude Persalys", self.generator.commentaire)
- return ret, None
- txt = self.generator.txtScriptPersalys.split(
- "################ CUT THE FILE HERE IF YOU WANT TO IMPORT IT IN THE SALOME PERSALYS MODULE ################"
- )[0]
- try:
- with open(fichierPersalys, "w") as f:
- f.write(txt)
- f.close()
- self.informe(
- "Sauvegarde Etude Persalys",
- "Le fichier " + str(fichierPersalys) + " a été sauvegardé",
- critique=False,
- )
- return 1, " "
- except IOError as why:
- self.informe(
- "Sauvegarde Etude Persalys",
- "Le fichier " + str(fichierPersalys) + " n a pas pu etre sauvegardé",
- )
- return 0, str(why)
-
- # -----------------------------------------------#
- def exeUQ(self, fichier=None, path=None):
- # ------------------------------------------------#
- self.informe("Pas prevu pour l instant")
- return ret, None
-
- # ---------------------------------------------
- # Methodes Surchargees par avecIhm
- # ---------------------------------------------
-
- # --------------------------------#
- def ajoutCommentaire(self):
- # --------------------------------#
- print("pas programme sans Ihm")
- print("prevenir la maintenance du besoin")
-
- # --------------------------------------#
- def informe(self, titre, txt, critique=True):
- # --------------------------------------#
- # methode differenre avec et sans ihm
- if critique:
- print("!!!!!!!!!!!!!!!!!!!!!!!!!!!")
- print(titre)
- print(txt)
- if critique:
- print("!!!!!!!!!!!!!!!!!!!!!!!!!!!")
-
- # --------------------------------------#
- def afficheInfos(self, txt, couleur=None):
- # --------------------------------------#
- # methode differenre avec et sans ihm
- print(txt)
-
- # -----------------------------------------------------------------------#
- def _viewText(self, txt, caption="FILE_VIEWER", largeur=1200, hauteur=600):
- # --------------------------------------------------------------------#
- print("_____________________________")
- print(txt)
- print("_____________________________")
-
- # -----------------------------------------------------------------#
- def saveFile(self, fichier, formatLigne="beautifie"):
- # -----------------------------------------------------------------#
- """
- Public slot to save the text to a file.
-
- @param path directory to save the file in (string or QString)
- @return tuple of two values (boolean, string) giving a success indicator and
- the name of the saved file
- """
-
- self.fichierOut = fichier
- if not (self.writeFile(fichier, formatLigne=formatLigne)):
- return (0, None)
- if self.jdc.cata.modeleMetier and self.jdc.isValid():
- if self.generator != self.XMLGenerator:
- self.XMLGenerator.gener(self.jdc)
- self.XMLGenerator.writeDefault(fichier)
- return (1, self.fichier)
- if self.jdc.isValid() and hasattr(self.generator, "writeDefault"):
- self.generator.writeDefault(fichier)
- elif self.code == "TELEMAC" and hasattr(self.generator, "writeDefault"):
- self.generator.writeDefault(fichier)
- self.modified = 0
- return (1, self.fichier)
-
- #
-
- # ----------------------------------------------#
- def sauveLigneFile(self):
- # ----------------------------------------------#
- self.modified = 1
- return self.saveFile(formatLigne="Ligne")
-
- # -----------------------------------#
- def updateJdc(self, itemApres, texte):
- # ------------------------------------#
- # ajoute une etape de JdC a partir d un texte
- monItem = itemApres
- etape = monItem.item.object
- CONTEXT.setCurrentStep(etape)
- etape.buildIncludeInclude(texte)
- self.tree.racine.buildChildren()
-
- # -----------------------------------#
- def updateJdcEtape(self, itemApres, texte):
- # ------------------------------------#
- # ajoute une etape de JdC a partir d un texte
- monItem = itemApres
- etape = monItem.item.object
- CONTEXT.set_current_step(etape)
- try:
- ok = etape.build_includeEtape(texte)
- except:
- ok = 0
- if not ok:
- QMessageBox.information(
- self, tr("Import texte"), tr("Impossible d importer le texte")
- )
- self.tree.racine.build_children()
- return ok
-
- # -------------------------------------#
- def deleteEtape(self, etape):
- # -------------------------------------#
- # dans le JDC
- self.jdc.suppentite(etape)
-
- # -------------------------------------#
- def deleteMC(self, etape, MCFils, listeAvant=()):
- # -------------------------------------#
- # dans le JDC
- ouChercher = etape
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if monMC != None:
- ouChercher.suppentite(monMC)
- ouChercher.state = "changed"
- ouChercher.isvalid()
-
- # --------------------------------------------------------#
- def ajoutMC(self, etape, MCFils, valeurs, listeAvant=()):
- # --------------------------------------------------------#
- # dans le JDC
- debug = False
- if debug:
- print("ajoutMC", etape, MCFils, valeurs, listeAvant)
- ouChercher = etape
- if debug:
- print(ouChercher)
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if monMC == None:
- monMC = ouChercher.addEntite(MCFils)
- monMC.valeur = valeurs
- monMC.val = valeurs
- monMC.state = "changed"
- monMC.isvalid()
- return 1
-
- # --------------------------------------------------------#
- def ajoutMCinMCFactUnique(self, etape, MCFils, valeurs, listeAvant=()):
- # Attention si +sieursMCFACT
- # --------------------------------------------------------#
- # dans le JDC
- debug = False
- if debug:
- print("ajoutMC", etape, MCFils, valeurs, listeAvant)
- ouChercher = etape
- if debug:
- print(ouChercher)
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- # Attention si +sieursMCFACT
- ouChercher = ouChercher[0]
- if debug:
- print(ouChercher)
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if monMC == None:
- monMC = ouChercher.addEntite(MCFils)
- monMC.valeur = valeurs
- monMC.val = valeurs
- monMC.state = "changed"
- monMC.isValid()
- return 1
-
- # ----------------------------------------------#
- def ajoutMCFact(self, etape, MCFils, listeAvant=()):
- # ----------------------------------------------#
- # dans le JDC
- ouChercher = etape
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- monMC = etape.getChild(ouChercher, restreint="oui")
- if monMC == None:
- monMC = ouChercher.addEntite(MCFils)
- monMC.isvalid()
-
- # -----------------------------------------------------------------#
- def setValeurMCSimpInEtape(self, etape, listeAvant, valeur):
- # -----------------------------------------------------------------#
- # pour VP
- monObj = etape
- for mot in listeAvant:
- monObj = monObj.getChild(mot, restreint="oui")
- if monObj == None:
- return False
- if monObj == None:
- return False
- if monObj.valeur != valeur:
- # PNPN le setValeur fait des bugs --> pourquoi
- # monObj.setValeur(valeur)
- monObj.valeur = valeur
- monObj.isValid()
- return True
-
- # -------------------------------------------------#
- def getValeur(self, nomEtape, MCFils, listeAvant=()):
- # -------------------------------------------------#
- # dans le JDC
-
- debug = 0
- ouChercher = None
- for e in self.jdc.etapes:
- if e.nom == nomEtape:
- ouChercher = e
- break
- if debug:
- print("etape trouvee", ouChercher)
- if ouChercher == None:
- return None
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- if debug:
- print(mot, ouChercher)
- if ouChercher == None:
- return None
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if debug:
- print("monMC", monMC)
- if monMC == None:
- return None
- return monMC.valeur
-
- # -------------------------------------------------#
- def getMCDsEtape(self, etape, MCFils, listeAvant=()):
- # -------------------------------------------------#
- # dans le JDC
-
- if etape == None:
- return None
- ouChercher = etape
- debug = 0
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- if debug:
- print(mot, ouChercher)
- if ouChercher == None:
- return None
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if debug:
- print("monMC", monMC)
- return monMC
-
- # -----------------------------------------------------------#
- def setValeur(self, nomEtape, MCFils, valeur, listeAvant=()):
- # --------------------------------------------------------#
- # dans le JDC
-
- ouChercher = None
- for e in self.jdc.etapes:
- if e.nom == nomEtape:
- ouChercher = e
- break
- if ouChercher == None:
- return None
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- # print (mot, ouChercher)
- if ouChercher == None:
- return None
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- monMC.set_valeur(valeur)
- monMC.isvalid()
-
- # -----------------------------------------------------------#
- def changeIntoMC(self, etape, MCFils, valeurs, listeAvant=()):
- # -----------------------------------------------------------#
- # dans le JDC
- ouChercher = etape
- if isinstance(etape, str):
- ouChercher = None
- for e in self.jdc.etapes:
- if e.nom == etape:
- ouChercher = e
- break
- if ouChercher == None:
- return
-
- for mot in listeAvant:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- if ouChercher == None:
- return
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if monMC == None:
- monMC = ouChercher.addEntite(MCFils)
-
- monMC.definition.into = valeurs
- from Noyau.N_VALIDATOR import IntoProtocol
-
- monMC.definition.intoProto = IntoProtocol(
- "into",
- into=monMC.definition.into,
- val_min=monMC.definition.val_min,
- val_max=monMC.definition.val_max,
- )
- monMC.state = "changed"
- monMC.isvalid()
-
- # -------------------------------------------------------------------#
- def reCalculeValiditeMCApresChgtInto(self, nomEtape, MCFils, listeAvant=()):
- # -------------------------------------------------------------------#
- # dans le JDC
- for e in self.jdc.etapes:
- if e.nom == nomEtape:
- ouChercher = e
- break
-
- for mot in listeAvant:
- try:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- # Le mot clef n est pas la
- except:
- return 0
- try:
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- # Le mot clef n est pas la
- except:
- return 0
- if monMC == None:
- return 0
-
- if hasattr(monMC.definition, "into"):
- if type(monMC.definition.into) == types.FunctionType:
- maListeDeValeur = monMC.definition.into()
- else:
- maListeDeValeur = monMC.definition.into
- else:
- return 0
-
- monMC.state = "changed"
- return 1
-
- def dumpXsd(self, avecEltAbstrait=False):
- # -----------------------------------------#
- if not self.readercata.cata:
- return
- texteXSD = self.readercata.cata.JdC.dumpXsd(avecEltAbstrait)
- return texteXSD
-
- def dumpStructure(self):
- # ----------------------------#
- texteStructure = self.readercata.cata.JdC.dumpStructure()
- return texteStructure
-
- def dumpGitStringFormat(self):
- # ----------------------------#
- texteGitStringFormat = self.readercata.cata.JdC.dumpGitStringFormat()
- return texteGitStringFormat
-
- # -------------------------------------#
- def changeDefautDefMC(self, nomEtape, listeMC, valeurs):
- # -------------------------------------#
- # dans le MDD
-
- # if isinstance (etape, str):
- # for e in self.jdc.etapes:
- # if e.nom == etape : etape=e; break
- # if etape == None : return
- definitionEtape = getattr(self.jdc.cata, nomEtape)
- # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
- ouChercher = definitionEtape
- if len(listeMC) > 1:
- for mc in listeMC[0:-1]:
- mcfact = ouChercher.entites[mc]
- ouChercher = mcfact
-
- mcAccas = ouChercher.entites[listeMC[-1]]
- mcAccas.defaut = valeurs
- return 1
-
- # ------------------------------------------------#
- def changeIntoDefMC(self, etape, listeMC, valeurs, rechercheParNom=False):
- # ------------------------------------------------#
- # dans le MDD
- # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
- # definitionEtape=getattr(self.jdc.cata,nomEtape)
- print("changeIntoDefMC ", etape, listeMC, valeurs)
- # ouChercher = getattr(self.jdc.cata, etape.nom)
- if rechercheParNom:
- ouChercher = getattr(self.jdc.cata, etape)
- else:
- ouChercher = getattr(self.jdc.cata, etape.nom)
-
- # if len(listeMC) > 1 :
- # for mc in listeMC[0:-1]:
- # mcfact=ouChercher.entites[mc]
- # ouChercher=mcfact
- # mcAccas=ouChercher.entites[listeMC[-1]]
-
- for mc in listeMC:
- mcAccas = ouChercher.entites[mc]
- ouChercher = mcAccas
- if ouChercher == None:
- return 0
-
- if hasattr(mcAccas, "into"):
- oldValeurs = mcAccas.into
- else:
- oldValeurs = None
-
- if oldValeurs == valeurs:
- return 1
- mcAccas.into = valeurs
- from Noyau.N_VALIDATOR import IntoProtocol
-
- mcAccas.intoProto = IntoProtocol(
- "into", into=valeurs, val_min=mcAccas.val_min, val_max=mcAccas.val_max
- )
- return 1
-
- # -------------------------------------------------------------#
- def deleteDefinitionMC(self, etape, listeAvant, nomDuMC):
- # -------------------------------------------------------------#
- # dans le MDD
- # print 'in deleteDefinitionMC', etape,listeAvant,nomDuMC
- if isinstance(etape, str):
- for e in self.jdc.etapes:
- if e.nom == etape:
- etape = e
- break
- if etape == None:
- return
- # definitionEtape=getattr(self.jdc.cata[0],etape)
- definitionEtape = getattr(self.jdc.cata, etape)
- ouChercher = definitionEtape
- for k in listeAvant:
- ouChercher = ouChercher.entites[k]
- MCADetruire = ouChercher.entites[nomDuMC]
- ouChercher.ordreMC.remove(nomDuMC)
- print("remove de ", nomDuMC)
- del ouChercher.entites[nomDuMC]
- del self.dicoNouveauxMC[nomDuMC]
-
- # -------------------------------------------------------------#
- def ajoutDefinitionMC(self, nomEtape, listeAvant, nomDuMC, typ, **args):
- # -------------------------------------------------------------#
- # dans le MDD
- # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
- definitionEtape = getattr(self.jdc.cata, nomEtape)
- ouChercher = definitionEtape
- for k in listeAvant:
- ouChercher = ouChercher.entites[k]
- from Accas import A_SIMP
-
- Nouveau = A_SIMP.SIMP(typ, **args)
- Nouveau.pere = ouChercher
- Nouveau.nom = nomDuMC
- # Nouveau.ordreMC=[]
- ouChercher.entites[nomDuMC] = Nouveau
- ouChercher.ordreMC.append(nomDuMC)
- # print ('ajout de ', nomDuMC)
- # traceback.print_stack()
- # ajout CIST sauvegarde
- if nomDuMC in self.dicoNouveauxMC:
- del self.dicoNouveauxMC[nomDuMC]
- self.dicoNouveauxMC[nomDuMC] = (
- "ajoutDefinitionMC",
- nomEtape,
- listeAvant,
- nomDuMC,
- typ,
- args,
- )
- # print self.dicoNouveauxMC
-
- # ---------------------------------------------------------------------#
- def ajoutDefinitionMCFact(self, nomEtape, listeAvant, nomDuMC, listeMC, **args):
- # ---------------------------------------------------------------------#
- # dans le MDD
- print("ajoutDefinitionMCFact", nomDuMC)
- # definitionEtape=getattr(self.jdc.cata[0],nomEtape)
- definitionEtape = getattr(self.jdc.cata, nomEtape)
- ouChercher = definitionEtape
- for k in listeAvant:
- ouChercher = ouChercher.entites[k]
- from Accas import A_SIMP
-
- for mc in listeMC:
- nomMC = mc[0]
- typMC = mc[1]
- argsMC = mc[2]
- nouveauMC = A_SIMP.SIMP(typMC, **argsMC)
- nouveauMC.nom = nomMC
- args[nomMC] = nouveauMC
- from Accas import A_FACT
-
- nouveauFact = A_FACT.FACT(**args)
- nouveauFact.pere = ouChercher
- nouveauFact.nom = nomDuMC
- from Editeur.autre_analyse_cata import traite_entite
-
- traite_entite(nouveauFact, [])
- ouChercher.entites[nomDuMC] = nouveauFact
- ouChercher.ordreMC.append(nomDuMC)
- self.dicoNouveauxFact[nomDuMC] = (
- "ajoutDefinitionMC",
- nomEtape,
- listeAvant,
- nomDuMC,
- listeMC,
- args,
- )
- # print self.dicoNouveauxMC
-
- # ----------------------------------------------------#
-
- # ----------------------------------------------------#
- def changeIntoMCandSet(self, etape, listeMC, into, valeurs):
- # ----------------------------------------------------#
- # dans le MDD et le JDC
-
- self.changeIntoDefMC(etape, listeMC, into)
-
- if isinstance(etape, str):
- for e in self.jdc.etapes:
- if e.nom == etape:
- etape = e
- break
- if etape == None:
- return
-
- ouChercher = etape
- for mot in listeMC[:-1]:
- ouChercher = ouChercher.getChild(mot, restreint="oui")
- if ouChercher == None:
- return
- MCFils = listeMC[-1]
- monMC = ouChercher.getChild(MCFils, restreint="oui")
- if monMC == None:
- monMC = etape.addEntite(MCFils)
-
- monMC.definition.into = into
- monMC.valeur = valeurs
- monMC.val = valeurs
- monMC.state = "changed"
- monMC.isvalid()
-
- # -------------------------------------#
- def ajoutVersionCataDsJDC(self, txt):
- # -------------------------------------#
- # if not hasattr(self.readercata.cata[0],'VERSION_CATALOGUE'): return txt
- if not hasattr(self.readercata.cata, "VERSION_CATALOGUE"):
- return txt
- ligneVersion = (
- "#VERSION_CATALOGUE:"
- + self.readercata.cata.VERSION_CATALOGUE
- + ":FIN VERSION_CATALOGUE\n"
- )
- texte = txt + ligneVersion
- return texte
-
- # -------------------------------------#
- def verifieVersionCataDuJDC(self, text):
- # -------------------------------------#
- memeVersion = False
- indexDeb = text.find("#VERSION_CATALOGUE:")
- indexFin = text.find(":FIN VERSION_CATALOGUE")
- if indexDeb < 0:
- self.versionCataDuJDC = "sans"
- textJDC = text
- else:
- self.versionCataDuJDC = text[indexDeb + 19 : indexFin]
- textJDC = text[0:indexDeb] + text[indexFin + 23 : -1]
-
- self.versionCata = "sans"
- if hasattr(self.readercata.cata, "VERSION_CATALOGUE"):
- self.versionCata = self.readercata.cata.VERSION_CATALOGUE
-
- if self.versionCata == self.versionCataDuJDC:
- memeVersion = True
- return memeVersion, textJDC
-
- # -------------------------------#
- def traduitCatalogue(self, texte):
- # -------------------------------#
- nomTraducteur = (
- "traduit"
- + self.readercata.code
- + self.versionCataDuJDC
- + "To"
- + self.versionCata
- )
- sys.path.append(
- os.path.abspath(
- os.path.join(
- os.path.dirname(os.path.abspath(__file__)), "../Traducteur"
- )
- )
- )
- try:
- traducteur = __import__(nomTraducteur)
- monTraducteur = traducteur.MonTraducteur(texte)
- nouveauTexte = monTraducteur.traduit()
- return nouveauTexte
- except:
- return texte
-
- # Methodes a resorber
- # il faut mettre a jour les catalogues avec
- # TEXTE_NEW_JDC
- #
-
- # ---------------------------#
- def _new_CF(self):
- # ---------------------------#
- texte = "CONDUITE_FORCEE();"
- return texte
-
- # ---------------------------#
- def _newPSEN(self):
- # ---------------------------#
- texte = "DIRECTORY() ; PSSE_PARAMETERS() ; SIMULATION() ; sansnom=DISTRIBUTION() ; sansnom=DISTRIBUTION() ; CORRELATION() ;"
- # texte=""
- return texte
-
- # ---------------------------#
- def _newPSEN_N1(self):
- # ---------------------------#
- texte = "CASE_SELECTION();N_PROCESSING_OPTIONS();CONTINGENCY_OPTIONS();CONTINGENCY_SELECTION();\nCONTINGENCY_PROCESSING(); "
- # texte="CONTINGENCY_SELECTION();\nCONTINGENCY_PROCESSING(); "
- return texte
-
- # ---------------------------#
- def _newZCRACKS(self):
- # ---------------------------#
- texte = "MAILLAGES();REMESHING();"
- return texte
-
- # ---------------------------#
- def _newJDCCND(self):
- # ---------------------------#
- extensions = tr("Fichiers Med (*.med);;" "Tous les Fichiers (*)")
-
- # if self.salome == 0 :
- QMessageBox.information(
- self, tr("Fichier Med"), tr("Veuillez selectionner un fichier Med")
- )
- QSfichier = QFileDialog.getOpenFileName(
- self.appliEficas, caption="Fichier Med", filter=extensions
- )
- QSfichier = QSfichier[0]
- self.fichierMED = QSfichier
- from acquiertGroupes import getGroupes
-
- erreur, self.listeGroupes, self.nomMaillage, self.dicoCoord = getGroupes(
- self.fichierMED
- )
- if erreur != "":
- print("a traiter")
- texteComm = (
- "COMMENTAIRE(u'Cree - fichier : "
- + self.fichierMED
- + " - Nom Maillage : "
- + self.nomMaillage
- + "');\nPARAMETRES()\n"
- )
- texteSources = ""
- texteCond = ""
- texteNoCond = ""
- texteVcut = ""
- texteZs = ""
- for groupe in self.listeGroupes:
- if groupe[0:8] == "CURRENT_":
- texteSources += groupe[8:] + "=SOURCE("
- texteSources += "VecteurDirecteur=(1.0,2.0,3.0,),);\n"
- if groupe[0:5] == "COND_":
- texteCond += groupe[5:] + "=CONDUCTEUR();\n"
- if groupe[0:7] == "NOCOND_":
- texteNoCond += groupe[7:] + "=NOCOND();\n"
- if groupe[0:5] == "VCUT_":
- texteVcut += "V_" + groupe[5:] + "=VCUT();\n"
- if groupe[0:3] == "ZS_":
- texteZs += groupe[3:] + "=ZS();\n"
- texte = texteComm + texteSources + texteCond + texteNoCond + texteVcut + texteZs
- self.newTexteCND = texte
- self.modified = 1
- return texte
-
- # ------------------#
- def insertInDB(self):
- # -------------------#
- debug = True
- if debug:
- print("insertInDB ", self.jdc, self.readercata.cata)
- texte = self.jdc.prepareInsertInDB()
- if debug:
- print(texte)
-
- def dumpStringDataBase(self, nomDataBaseACreer=None):
- # --------------------------------------------------#
- texteStringDataBase = self.readercata.cata.JdC.dumpStringDataBase(
- nomDataBaseACreer
- )
- return texteStringDataBase
-
-
-if __name__ == "__main__":
- print("a faire")
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 sys, os
-
-repIni = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
-ihmQTDir = os.path.join(repIni, "UiQT5")
-editeurDir = os.path.join(repIni, "Editeur")
-ihmDir = os.path.join(repIni, "InterfaceQT4")
-
-if ihmDir not in sys.path:
- sys.path.append(ihmDir)
-if ihmQTDir not in sys.path:
- sys.path.append(ihmQTDir)
-if editeurDir not in sys.path:
- sys.path.append(editeurDir)
-
-if sys.version_info[0] < 3:
- print("Must be using Python 3")
- sys.exit()
-
-
-def lanceEficas(code=None, multi=False, langue="en", labelCode=None):
- # -------------------------------------------------------------------
- """
- Lance l'appli EFICAS avec Ihm
- """
- try:
- from PyQt5.QtWidgets import QApplication
- except:
- print("Please, set qt environment")
- return
-
- from Editeur import session
-
- options = session.parse(sys.argv)
- if options.code != None:
- code = options.code
-
- from InterfaceQT4.qtEficas import Appli
-
- app = QApplication(sys.argv)
-
- Eficas = Appli(code=code, salome=0, multi=multi, langue=langue, labelCode=labelCode)
- Eficas.show()
-
- res = app.exec_()
- sys.exit(res)
-
-
-def getEficasSsIhm(
- code=None,
- multi=False,
- langue="en",
- ssCode=None,
- labelCode=None,
- forceXML=False,
- genereXSD=False,
- fichierCata=None,
-):
- # -------------------------------------------------------------------------------------------------------------------------
- """
- Lance l'appli EFICAS sans Ihm
- """
- from Editeur import session
-
- options = session.parse(sys.argv)
- if options.code != None:
- code = options.code
- if forceXML:
- options.withXSD = True
-
- from InterfaceQT4.qtEficasSsIhm import AppliSsIhm
-
- Eficas = AppliSsIhm(
- code=code,
- salome=0,
- multi=multi,
- langue=langue,
- ssCode=ssCode,
- labelCode=labelCode,
- genereXSD=genereXSD,
- fichierCata=fichierCata,
- )
- return Eficas
-
-
-def genereXSD(code=None):
- # ------------------------
- from Editeur import session
-
- options = session.parse(sys.argv)
- if code != None:
- options.code = code
- if options.fichierCata == None:
- print("Use -c cata_name.py")
- return
-
- monEficasSsIhm = getEficasSsIhm(code=options.code, genereXSD=True)
- monEditor = monEficasSsIhm.getEditor()
- # texteXSD=monEficasSsIhm.dumpXsd(avecEltAbstrait=options.avecEltAbstrait)
- texteXSD = monEditor.dumpXsd(avecEltAbstrait=options.avecEltAbstrait)
-
- fichierCataTrunc = os.path.splitext(os.path.basename(options.fichierCata))[0]
- # if fichierCataTrunc[0:4] in ('cata','Cata'): fichierCataTrunc=fichierCataTrunc[4:]
- # if fichierCataTrunc[0] in ('_','-') : fichierCataTrunc=fichierCataTrunc[1:]
- fileXSD = fichierCataTrunc + ".xsd"
-
- f = open(str(fileXSD), "w")
- f.write(str(texteXSD))
-
-
-def genereXML(code=None):
- # -----------------------
- from Editeur import session
-
- options = session.parse(sys.argv)
- if code != None:
- options.code = code
- if options.fichierCata == None:
- print("Use -c cata_name.py")
- return
- try:
- fichier = options.comm[0]
- except:
- fichier = None
- if fichier == None:
- print("comm file is needed")
- return
-
- monEficasSsIhm = getEficasSsIhm(code=options.code, forceXML=True)
-
- from .editorSsIhm import JDCEditorSsIhm
-
- monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier)
- if options.fichierXMLOut == None:
- fichierXMLOut = fichier[: fichier.rfind(".")] + ".xml"
- else:
- fichierXMLOut = options.fichierXMLOut
- if not (monEditeur.jdc.isValid()):
- print("Fichier comm is not valid")
- return
- # print ('Fichier comm is not valid')
- monEditeur.XMLgenerator.gener(monEditeur.jdc)
- monEditeur.XMLgenerator.writeDefault(fichierXMLOut)
-
-
-def genereStructure(code=None):
- # ------------------------------
- from Editeur import session
-
- options = session.parse(sys.argv)
- if code != None:
- options.code = code
- if options.fichierCata == None:
- print("Use -c cata_name.py")
- return
-
- monEficasSsIhm = getEficasSsIhm(code=options.code, genereXSD=True)
- monEditor = monEficasSsIhm.getEditor()
- texteStructure = monEditor.dumpStructure()
-
- fichierCataTrunc = os.path.splitext(os.path.basename(options.fichierCata))[0]
- fileStructure = fichierCataTrunc + ".txt"
- f = open(str(fileStructure), "w")
- f.write(str(texteStructure))
- f.close()
-
-
-def validateDataSet(code=None):
- # ------------------------------
- from Editeur import session
-
- options = session.parse(sys.argv)
- if code != None:
- options.code = code
- if options.fichierCata == None:
- print("Use -c cata_name.py")
- return
- fichier = options.comm[0]
- if fichier == None:
- print("comm file is needed")
- return
- from .editorSsIhm import JDCEditorSsIhm
-
- monEficasSsIhm = getEficasSsIhm(code=options.code)
- monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier)
- if not (monEditeur.jdc.isValid()):
- print(monEditeur.getJdcRapport())
- else:
- print("Jdc is valid")
- return monEditeur.jdc.isValid()
-
-
-def validateFonction(laFonction, debug=False):
- # -------------------------------
- # ici un singleton pour avoir l editor, le catalogue et...
- monEficasSsIhm = getEficasSsIhm(code="Essai")
- monEditor = monEficasSsIhm.getEditor()
- print("_______ validateFonction", laFonction, laFonction.__name__)
- from functools import wraps
- from collections import OrderedDict
- from inspect import getargspec
-
- @wraps(laFonction)
- def fonctionValidee(*args, **kwargs):
- laFonctionName = laFonction.__name__
- if debug:
- print(
- "Appel {} avec args={} et kwargs={}".format(
- laFonction.__name__, args, kwargs
- )
- )
- laDefDeLaFonctionDansAccas = getattr(monEditor.readercata.cata, laFonctionName)
- objConstruit = laDefDeLaFonctionDansAccas.makeObjetPourVerifSignature(
- *args, **kwargs
- )
- if objConstruit.isValid():
- ret = laFonction(*args, **kwargs)
- return ret
- else:
- print("mauvais arguments")
- print(objConstruit.CR())
- return None
-
- return fonctionValidee
-
- # maClasseAccas=getattr(self.cata,objEtape.monNomClasseAccas)
- return fonctionValidee
-
- return laFonction
-
-
-def createFromDocumentAccas(fichierCata=None, fichier=None, code=None):
- # ------------------------------------------------------------
- if fichier == None:
- print("file is needed")
- return None
- if fichierCata == None:
- print("cata file is needed")
- return None
-
- from Noyau.N_OBJECT import activeSurcharge
-
- activeSurcharge()
-
- from .editorSsIhm import JDCEditorSsIhm
-
- monEficasSsIhm = getEficasSsIhm(code="Essai", fichierCata=fichierCata)
- monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier)
- return monEditeur.jdc
- # from Noyau
-
-
-# --------------------------- toutes les fonctions après sont obseletes
-def lanceEficas_ssIhm(
- code=None, fichier=None, ssCode=None, version=None, debug=False, langue="en"
-):
- """
- Lance l'appli EFICAS SsIhm
- """
- # Analyse des arguments de la ligne de commande
- print("deprecated")
- from Editeur import session
-
- options = session.parse(sys.argv)
- if version != None and options.version == None:
- options.version = version
- if fichier == None:
- fichier = options.comm[0]
- if code == None:
- code = options.code
-
- from .qtEficas import Appli
-
- Eficas = Appli(code=code, salome=0, ssCode=ssCode, ssIhm=True, langue=langue)
-
- from .ssIhm import QWParentSSIhm
-
- parent = QWParentSSIhm(code, Eficas, version)
-
- from . import readercata
-
- if not hasattr(Eficas, "readercata"):
- monreadercata = readercata.ReaderCata(parent, Eficas)
- Eficas.readercata = monreadercata
-
- from .editor import JDCEditor
-
- monEditeur = JDCEditor(Eficas, fichier)
- return monEditeur
-
-
-def lanceEficas_ssIhm_chercheGroupes(
- code=None, fichier=None, ssCode=None, version=None
-):
- print("deprecated")
- monEditeur = lanceEficas_ssIhm(code, fichier, ssCode, version)
- print((monEditeur.chercheGroupes()))
-
-
-def lanceEficas_ssIhm_cherche_cr(code=None, fichier=None, ssCode=None, version=None):
- print("deprecated")
- monEditeur = lanceEficas_ssIhm(code, fichier, ssCode, version)
- print((monEditeur.jdc.cr))
-
-
-def lanceEficas_ssIhm_reecrit(
- code=None,
- fichier=None,
- ssCode=None,
- version=None,
- ou=None,
- cr=False,
- debug=False,
- leger=False,
- langue="ang",
-):
- print("deprecated")
- # print 'lanceEficas_ssIhm_reecrit', fichier
- monEditeur = lanceEficas_ssIhm(code, fichier, ssCode, version, langue=langue)
- if ou == None:
- fileName = fichier.split(".")[0] + "_reecrit.comm"
- fn = fichier.split(".")[0] + "_cr.txt"
- else:
- f = fichier.split(".")[0] + "_reecrit.comm"
- f1 = os.path.basename(f)
- fn = fichier.split(".")[0] + "_cr.txt"
- f2 = os.path.basename(fn)
- fileName = os.path.join(ou, f1)
- fileCr = os.path.join(ou, f2)
- debut = False
- if debug:
- import cProfile, pstats, StringIO
-
- pr = cProfile.Profile()
- pr.enable()
- monEditeur.saveFileAs(fileName=fileName)
- pr.disable()
- s = StringIO.StringIO()
- sortby = "cumulative"
- ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
- ps.print_stats()
- print(s.getValue())
-
- elif not leger:
- monEditeur.saveFileAs(fileName=fileName)
- else:
- monEditeur.saveFileLegerAs(fileName=fileName)
- if cr:
- f = open(fileCr, "w")
- f.write(str(monEditeur.jdc.report()))
- f.close()
-
-
-def lanceEficas_param(
- code="Adao", fichier=None, version="V0", macro="ASSIMILATION_STUDY"
-):
- """
- Lance l'appli EFICAS pour trouver les noms des groupes
- """
- print("deprecated")
- # Analyse des arguments de la ligne de commande
- from Editeur import session
-
- options = session.parse(sys.argv)
-
- from .qtEficas import Appli
-
- from .ssIhm import QWParentSSIhm
-
- Eficas = QWParentSSIhm(code, version)
-
- from . import readercata
-
- if not hasattr(Eficas, "readercata"):
- monreadercata = readercata.ReaderCata(parent, Eficas)
- Eficas.readercata = monreadercata
-
- from .editor import JDCEditor
-
- monEditeur = JDCEditor(Eficas, fichier)
- texte = loadJDC(fichier)
- parameters = getJdcParameters(texte, macro)
- return parameters
-
-
-def getJdcParameters(jdc, macro):
- """
- This function converts the data from the specified macro of the
- specified jdc text to a python dictionnary whose keys are the
- names of the data of the macro.
- """
- print("deprecated")
- context = {}
- source = "def args_to_dict(**kwargs): return kwargs \n"
- source += "%s = _F = args_to_dict \n" % macro
- source += "parameters=" + jdc + " \n"
- source += "context['parameters'] = parameters \n"
- code = compile(source, "file.py", "exec")
- eval(code)
- parameters = context["parameters"]
- return parameters
-
-
-def loadJDC(filename):
- """
- This function loads the text from the specified JdC file. A JdC
- file is the persistence file of Eficas (*.comm).
- """
- print("deprecated")
- fcomm = open(filename, "r")
- jdc = ""
- for line in fcomm.readlines():
- if not (line[0] == "#"):
- jdc += "%s" % line
-
- # Warning, we have to make sure that the jdc comes as a simple
- # string without any extra spaces/newlines
- return jdc.strip()
-
-
-if __name__ == "__main__":
- import sys
-
- sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "..")))
- lanceEficas(code=None, multi=True)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-import traceback
-
-from PyQt5.QtWidgets import QToolButton, QWidget, QMessageBox
-from PyQt5.QtGui import QFont, QFontMetrics, QFontInfo, QPalette
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-
-from .gereIcones import ContientIcones
-from .gereIcones import FacultatifOuOptionnel
-from .qtSaisie import SaisieValeur
-
-nomMax = 230
-
-
-# empirique les metrics ne fonctionnent pas
-# ---------------------------------------------------------------------- #
-class Feuille(QWidget, ContientIcones, SaisieValeur, FacultatifOuOptionnel):
- # --------------------------------------------------------------------- #
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print ("Feuille", monSimpDef,nom,objSimp)
- QWidget.__init__(self, None)
- self.node = node
- self.node.fenetre = self
-
- # on se positionne pour les icones
- # os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__))))
- self.setupUi(self)
- self.prendLeFocus = 0
-
- # maPolice= QFont("Times", 10)
- # self.setFont(maPolice)
- # self.setFocusPolicy(Qt.StrongFocus)
-
- self.parentQt = parentQt
- self.editor = self.node.editor
- self.appliEficas = self.editor.appliEficas
- self.repIcon = self.appliEficas.repIcon
- self.monSimpDef = monSimpDef
- self.nom = nom
- self.objSimp = objSimp
- self.node.fenetre = self
- self.maCommande = commande
-
- self.aRedimensionner = 0
- self.setSuggestion()
- self.setValeurs()
- self.setNom()
- self.setValide()
- self.setIconePoubelle()
- self.setIconesFichier()
- self.setIconesSalome()
- self.setIconesGenerales()
- self.setCommentaire()
- self.setZoneInfo()
- self.setUnite()
- # inhibition incertitude
- self.inhibeSignal = False
- self.setUQ()
-
- def setUnite(self):
- if self.monSimpDef.unite == None:
- if hasattr(self, "lineEditUnite"):
- self.lineEditUnite.setText(" ")
- else:
- if hasattr(self, "lineEditUnite"):
- self.lineEditUnite.setText(self.monSimpDef.unite)
- else:
- self.editor.informe(
- "Erreur de Catalogue",
- "Champ Unite non prevu pour "
- + self.nom
- + " correction du catalogue souhaitable, prevenez la maintenance",
- False,
- )
-
- def setUQ(self):
- if not (self.editor.appliEficas.maConfiguration.afficheUQ) and hasattr(
- self, "checkBoxUQ"
- ):
- self.checkBoxUQ.close()
- return
- if not self.objSimp.UQPossible() and hasattr(self, "checkBoxUQ"):
- self.checkBoxUQ.close()
- return
- if not self.objSimp.UQPossible():
- return
- if hasattr(self, "checkBoxUQ"):
- if self.objSimp.isUQActivate():
- self.checkBoxUQ.setChecked(True)
- else:
- self.checkBoxUQ.setChecked(False)
- self.checkBoxUQ.toggled.connect(self.setEnabledUQ)
-
- def setEnabledUQ(self):
- if self.inhibeSignal:
- self.inhibeSignal = False
- return
- if self.checkBoxUQ.isChecked():
- if self.objSimp.etape.nature == "OPERATEUR" and not (self.objSimp.etape.sd):
- QMessageBox.warning(
- self,
- tr("Attention"),
- tr(
- "Il faut d abord nommer "
- + self.objSimp.etape.nom
- + " avant de pourvoir choisir des variables incertaines"
- ),
- )
- self.inhibeSignal = True
- self.checkBoxUQ.setCheckState(False)
- return
- self.objSimp.lieVariableUQ()
- else:
- ret = self.objSimp.delieVariableUQ()
- if not ret:
- QMessageBox.warning(
- self,
- tr("Variable associée non trouvée "),
- tr("prevenez la maintenance"),
- )
- else:
- etape = self.objSimp.getJdcRoot().getEtapesByName(
- "ExpressionIncertitude"
- )[0]
- etape.node.buildChildren()
-
- def setNom(self):
- self.debutToolTip = ""
- nomTraduit = tr(self.objSimp.nom)
- # metrix= QFontMetrics(self.label.font())
- # maxLongueur = self.label.width() - 2
- # print ('______________________')
- # print (nomTraduit)
- # print (self.label.font().pixelSize())
- # longueur2 = metrix.boundingRect(nomTraduit).width()
- longueur = QFontMetrics(self.label.font()).width(nomTraduit)
- if longueur >= nomMax:
- nouveauNom = self.formate(nomTraduit)
- self.label.setText(nouveauNom)
- else:
- self.label.setText(nomTraduit)
- # clidedText = metrics.elidedText(text, Qt.ElideRight, label.width());
- # if (clippedText != nomTraduit): self.label.setToolTip(nomTraduit)
- # self.label.setText(clippedText)
-
- # def agrandit(self):
- # inutile pour certains widgets
- # if self.height() < 40 :
- # self.setMinimumHeight(50)
- # self.resize(self.width(),200)
-
- # def mousePressEvent(self, event):
- # print 'mousePressEvent'
- # import inspect
- # print (inspect.getmro(self.__class__))
- # self.__class__.mousePressEvent(self, event)
-
- def setValeurs(self):
- # print "passe dans setValeurs pour ", self.objSimp.nom
- # print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
- pass
-
- def finCommentaire(self):
- return ""
-
- def finCommentaireListe(self):
- commentaire = ""
- mc = self.node.item.get_definition()
- d_aides = {
- "TXM": "chaines de caracteres",
- "R": "reels",
- "I": "entiers",
- "C": "complexes",
- }
- type = mc.type[0]
- if not type in d_aides:
- if mc.min == mc.max:
- commentaire = tr("Entrez ") + str(mc.min) + tr(" valeurs ") + "\n"
- else:
- if mc.max != "**":
- commentaire = (
- tr("entre ")
- + str(mc.min)
- + tr(" et ")
- + str(mc.max)
- + tr(" valeurs ")
- + "\n"
- )
- else:
- commentaire = ""
- else:
- if mc.min == mc.max:
- commentaire = (
- tr("Entrez ") + str(mc.min) + " " + tr(d_aides[type]) + "\n"
- )
- elif mc.max == float("inf"):
- commentaire = (
- tr("Entrez une liste de ") + " " + tr(d_aides[type]) + "\n"
- )
- else:
- commentaire = (
- tr("Entrez entre ")
- + "\n"
- + str(mc.min)
- + (" et ")
- + str(mc.max)
- + " "
- + tr(d_aides[type])
- + "\n"
- )
- aideval = self.node.item.aide()
- commentaire = commentaire + tr(aideval)
- return str(commentaire)
-
- def setSuggestion(self):
- if self.monSimpDef.getSug() != None and self.monSimpDef.getSug() != "":
- suggere = (
- str('<html><head/><body><p><span style=" font-size:8pt;">suggestion : ')
- + str(self.monSimpDef.getSug())
- + "</span></p></body></html>"
- )
- if hasattr(self, "lineEditVal"):
- self.lineEditVal.setToolTip(suggere)
-
- def setCommentaire(self):
- c = self.debutToolTip
- # if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
- self.aide = c
- if self.objSimp.getFr() != None and self.objSimp.getFr() != "":
- # c2 = '<html><head/><body><p>'+c+self.objSimp.getFr().decode('latin-1','replace')+"</p></body></html>"
- c2 = "<html><head/><body><p>" + c + self.objSimp.getFr()
- # c2 = '<html><head/><body><p>'+c+self.objSimp.getFr()+"</p></body></html>"
- self.label.setToolTip(c2)
- # self.aide=self.objSimp.getFr().decode('latin-1','ignore')+" "+c
- self.aide = self.objSimp.getFr() + " " + c
- else:
- c += self.finCommentaire()
- if c != "" and c != None:
- self.aide = c
- # c=str('<html><head/><body><p><span style=" font-size:8pt; ">')+c+"</span></p></body></html>"
- c = str("<html><head/><body><p>") + c + "</p></body></html>"
- self.label.setToolTip(c)
-
- if self.editor.maConfiguration.differencieSiDefaut:
- self.label.setToolTip(
- "defaut : " + tr(str(self.node.item.object.definition.defaut))
- )
-
- def showEvent(self, event):
- if self.prendLeFocus == 1:
- self.activateWindow()
- "il faut deriver le showEvent pour", self.nom
- self.prendLeFocus = 0
- QWidget.showEvent(self, event)
-
- def aideALaSaisie(self):
- mc = self.node.item.get_definition()
- mctype = mc.type[0]
- d_aides = {
- "TXM": tr("chaine de caracteres"),
- "R": tr("reel"),
- "I": tr("entier"),
- "C": tr("complexe"),
- "Matrice": tr("Matrice"),
- "Fichier": tr("fichier"),
- "FichierNoAbs": tr("fichier existant"),
- "Repertoire": tr("repertoire"),
- }
-
- if mc.min == mc.max:
- commentaire = tr("Entrez ") + " " + str(mc.min) + " "
- else:
- commentaire = (
- tr("Entrez entre ") + str(mc.min) + tr(" et ") + str(mc.max) + " "
- )
-
- try:
- if issubclass(mctype, object):
- ctype = getattr(mctype, "help_message", tr("Type de base inconnu"))
- else:
- ctype = d_aides.get(mctype, tr("Type de base inconnu"))
- except:
- ctype = d_aides.get(mctype, tr("Type de base inconnu"))
- if ctype == tr("Type de base inconnu") and "Tuple" in str(mctype):
- ctype = str(mctype)
- if ctype == tr("Type de base inconnu") and "bool" in str(mctype):
- ctype = "bool"
-
- if mc.max != 1:
- if ctype == "chaine de caractere" and mc.max > 1:
- ctype = "chaines de caractere"
- else:
- ctype = ctype + "s"
- commentaire += ctype
- if mc.max != 1:
- commentaire += "s"
- return commentaire
-
- def setZoneInfo(self):
- # info=str(self.nom)+' '
- # if self.monSimpDef.getFr() != None and self.monSimpDef.getFr() != "": info+=self.monSimpDef.getSug() +" "
- # if self.monSimpDef.getSug() != None and self.monSimpDef.getSug() != "": info+="Valeur suggeree : "self.monSimpDef.getSug()
- pass
-
- def reaffiche(self):
- if self.editor.jdc.aReafficher == True:
- self.parentQt.reaffiche()
-
- # PN PN PN pas satisfaisant
- # nodeAVoir=self.parentQt.node.chercheNoeudCorrespondant(self.objSimp)
- # print nodeAVoir.fenetre
- # print "nodeAVoir.fenetre.isVisible()", nodeAVoir.fenetre.isVisible()
- # if nodeAVoir.fenetre.isVisible() : return
- # self.editor.fenetreCentraleAffichee.rendVisibleNoeud(nodeAVoir)
- # nodeAVoir.fenetre.setFocus()
- # return # on est bien postionne
-
- if self.objSimp.isValid() and hasattr(self, "AAfficher"):
- nodeAVoir = self.parentQt.node.chercheNoeudCorrespondant(self.objSimp)
- try:
- index = (
- self.editor.fenetreCentraleAffichee.listeAffichageWidget.index(
- nodeAVoir.fenetre.AAfficher
- )
- )
- if (
- index
- == len(self.editor.fenetreCentraleAffichee.listeAffichageWidget)
- - 1
- ):
- try:
- nodeAVoir.fenetre.setValeursApresBouton()
- except:
- pass
- else:
- self.editor.fenetreCentraleAffichee.afficheSuivant(
- nodeAVoir.fenetre.AAfficher
- )
- except:
- pass
- else:
- if self.objSimp.isValid() and hasattr(self, "AAfficher"):
- try:
- self.setValeursApresBouton()
- except:
- pass
- self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
- else:
- if hasattr(self, "AAfficher"):
- self.AAfficher.setFocus(7)
-
- def reaffichePourDeplier(self):
- self.parentQt.reaffiche()
-
- def rendVisible(self):
- pass
-
- # def enterEvent(self,event):
- # print "je passe dans enterEvent", self.nom
- # QWidget.enterEvent(self,event)
-
- def traiteClicSurLabel(self, texte):
- # aide=self.aide.encode('latin-1', 'ignore').decode('latin-1')+"\n"+self.aideALaSaisie().encode('latin-1', 'ignore').decode('latin-1')
- try:
- aide = self.aide + "\n" + self.aideALaSaisie()
- except:
- aide = self.aideALaSaisie()
- self.editor.afficheCommentaire(aide)
-
- def formate(self, t):
- l = len(t) // 2
- newText = t[0:l] + "-\n" + t[l:]
- return newText
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os, re, sys
-import traceback
-import inspect
-
-from PyQt5.QtWidgets import QMessageBox, QFileDialog, QMenu, QPushButton, QTreeView, QListView, QAbstractItemView
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import QFileInfo, Qt, QSize, QVariant
-
-
-from Extensions.i18n import tr
-
-listeSuffixe = ("bmp", "png", "jpg", "txt", "med")
-
-
-class FacultatifOuOptionnel(object):
-#-----------------------------------
- """ Gere les boutons """
- def setReglesEtAide(self):
- listeRegles = ()
- try:
- listeRegles = self.node.item.getRegles()
- except:
- pass
- if hasattr(self, "RBRegle"):
- if listeRegles == ():
- self.RBRegle.close()
- else:
- icon3 = QIcon(self.repIcon + "/lettreRblanc30.png")
- self.RBRegle.setIcon(icon3)
- self.RBRegle.clicked.connect(self.viewRegles)
-
- cle_doc = None
- if not hasattr(self, "RBInfo"):
- return
- icon = QIcon(self.repIcon + "/point-interrogation30.png")
- self.RBInfo.setIcon(icon)
-
- from .monWidgetCommande import MonWidgetCommande
- if isinstance(self, MonWidgetCommande) and self.editor.code == "MAP":
- self.cle_doc = self.chercheDocMAP()
- else:
- self.cle_doc = self.node.item.getDocu()
- if self.cle_doc == None:
- self.RBInfo.close()
- else:
- self.RBInfo.clicked.connect(self.viewDoc)
-
- def chercheDocMAP(self):
- try:
- clef = self.editor.maConfiguration.adresse + "/"
- except:
- return None
- for k in self.editor.readercata.cata.JdC.dict_groupes:
- if self.obj.nom in self.editor.readercata.cata.JdC.dict_groupes[k]:
- clef += k
- break
- clef += (
- "/"
- + self.obj.nom[0:-5].lower()
- + "/spec_"
- + self.obj.nom[0:-5].lower()
- + ".html"
- )
-
- return clef
-
- def viewDoc(self):
- try:
- if sys.platform[0:5] == "linux":
- cmd = "xdg-open " + self.cle_doc
- else:
- cmd = "start " + self.cle_doc
- os.system(cmd)
- except:
- QMessageBox.warning(
- self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
- )
-
- def viewRegles(self):
- self.node.appellebuildLBRegles()
-
- def setIconePoubelle(self):
- if not (hasattr(self, "RBPoubelle")):
- return
-
- if self.node.item.object.isOblig() and not (
- hasattr(self.node.item.object, "isDeletable")
- ):
- icon = QIcon(self.repIcon + "/deleteRondVide.png")
- self.RBPoubelle.setIcon(icon)
- return
- icon = QIcon(self.repIcon + "/deleteRond.png")
- self.RBPoubelle.setIcon(icon)
- self.RBPoubelle.clicked.connect(self.aDetruire)
-
- def setIconesSalome(self):
- if not (hasattr(self, "RBSalome")):
- return
- from Accas import SalomeEntry
-
- mc = self.node.item.get_definition()
- mctype = mc.type[0]
- 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
- )
- )
-
- if enable_salome_selection:
- icon = QIcon(self.repIcon + "/flecheSalome.png")
- self.RBSalome.setIcon(icon)
- self.RBSalome.pressed.connect(self.BSalomePressed)
-
- # PNPN --> Telemac A revoir surement
- # cela ou le catalogue grpma ou salomeEntry
- if not (("grma" in repr(mctype)) or ("grno" in repr(mctype))) or not (
- self.editor.salome
- ):
- if hasattr(self, "RBSalomeVue"):
- self.RBSalomeVue.close()
- else:
- icon1 = QIcon(self.repIcon + "/eye.png")
- self.RBSalomeVue.setIcon(icon1)
- self.RBSalomeVue.clicked.connect(self.BView2DPressed)
- else:
- self.RBSalome.close()
- self.RBSalomeVue.close()
-
- def setIconesFichier(self):
- if not (hasattr(self, "BFichier")):
- return
- mc = self.node.item.get_definition()
- mctype = mc.type[0]
- if mctype == "FichierOuRepertoire":
- self.BFichierOuRepertoire = self.BFichier
- self.BFichierOuRepertoire.clicked.connect(self.BFichierOuRepertoirePressed)
- self.BVisuFichier.close()
- elif mctype == "Repertoire":
- self.BRepertoire = self.BFichier
- self.BRepertoire.clicked.connect(self.BRepertoirePressed)
- self.BVisuFichier.close()
- else:
- self.BFichier.clicked.connect(self.BFichierPressed)
- self.BVisuFichier.clicked.connect(self.BFichierVisu)
-
- def setIconesGenerales(self):
- repIcon = self.node.editor.appliEficas.repIcon
- if hasattr(self, "BVisuListe"):
- fichier = os.path.join(repIcon, "plusnode.png")
- icon = QIcon(fichier)
- self.BVisuListe.setIcon(icon)
- if hasattr(self, "RBDeplie"):
- fichier = os.path.join(repIcon, "plusnode.png")
- icon = QIcon(fichier)
- self.RBDeplie.setIcon(icon)
- if hasattr(self, "RBPlie"):
- fichier = os.path.join(repIcon, "minusnode.png")
- icon = QIcon(fichier)
- self.RBPlie.setIcon(icon)
- if hasattr(self, "BVisuFichier"):
- fichier = os.path.join(repIcon, "visuFichier.png")
- icon = QIcon(fichier)
- self.BVisuFichier.setIcon(icon)
-
- def setRun(self):
- if hasattr(self.editor.appliEficas, "mesScripts"):
- if self.editor.code in self.editor.appliEficas.mesScripts:
- self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
- self.editor.code
- ].dict_commandes
- if self.obj.nom in self.dict_commandes_mesScripts:
- self.ajoutScript()
- icon = QIcon(self.repIcon + "/roue.png")
- if hasattr(self, "RBRun"):
- self.RBRun.setIcon(icon)
- return
- if hasattr(self, "RBRun"):
- self.RBRun.close()
- if hasattr(self, "CBScripts"):
- self.CBScripts.close()
-
- def aDetruire(self):
- self.node.delete()
-
- def setValide(self):
- if not (hasattr(self, "RBValide")):
- return
- couleur = self.node.item.getIconName()
- monIcone = QIcon(self.repIcon + "/" + couleur + ".png")
- self.RBValide.setIcon(monIcone)
-
- # il faut chercher la bonne fenetre
- def rendVisible(self):
- # print "je passe par rendVisible de FacultatifOuOptionnel"
- # print self
- # print self.node.fenetre
- # print "return pour etre sure"
- return
- # PNPN
- newNode = self.node.treeParent.chercheNoeudCorrespondant(self.node.item.object)
- # print newNode
- self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(
- newNode.fenetre
- )
- # newNode.fenetre.setFocus()
-
- def ajoutScript(self):
- if not hasattr(self, "CBScripts"):
- return # Cas des Widgets Plies
- self.dictCommandes = {}
- listeCommandes = self.dict_commandes_mesScripts[self.obj.nom]
- if type(listeCommandes) != tuple:
- listeCommandes = (listeCommandes,)
- i = 0
- for commande in listeCommandes:
- conditionSalome = commande[3]
- if self.appliEficas.salome == 0 and conditionSalome == True:
- continue
- self.CBScripts.addItem(commande[1])
- self.dictCommandes[commande[1]] = i
- i = i + 1
- self.CBScripts.activated.connect(self.choixSaisi)
-
- def choixSaisi(self):
- fction = str(self.CBScripts.currentText())
- numero = self.dictCommandes[fction]
- self.node.appelleFonction(numero, nodeTraite=self.node)
- # self.reaffiche()
-
-
-class ContientIcones(object):
- def BFichierVisu(self):
- fichier = self.lineEditVal.text()
- if fichier == None or str(fichier) == "":
- return
- from .monViewTexte import ViewText
-
- try:
- if sys.platform[0:5] == "linux":
- # cmd="xdg-open "+ str(fichier)
- # changer pour marcher dans l'EDC
- # cmd="gedit "+ str(fichier)
- from os.path import splitext
-
- fileName, extension = splitext(fichier)
- if (
- extension
- in self.parentQt.editor.appliEficas.maConfiguration.utilParExtensions
- ):
- cmd = (
- self.parentQt.editor.appliEficas.maConfiguration.utilParExtensions[
- extension
- ]
- + " "
- + str(fichier)
- )
- else:
- cmd = "xdg-open " + str(fichier)
- os.system(cmd)
- else:
- os.startfile(str(fichier))
- except:
- try:
- fp = open(fichier)
- txt = fp.read()
- nomFichier = QFileInfo(fichier).baseName()
- maVue = ViewText(self, entete=nomFichier)
- maVue.setText(txt)
- maVue.show()
- fp.close()
- except:
- QMessageBox.warning(
- None,
- tr("Visualisation Fichier "),
- tr("Impossibilite d'afficher le Fichier"),
- )
-
- def BFichierPressed(self):
- mctype = self.node.item.get_definition().type
- if len(mctype) > 1:
- filters = mctype[1]
- elif hasattr(mctype[0], "filters"):
- filters = mctype[0].filters
- else:
- filters = ""
- if len(mctype) > 2 and mctype[2] == "Sauvegarde":
- fichier = QFileDialog.getSaveFileName(
- self.appliEficas,
- tr("Use File"),
- self.appliEficas.maConfiguration.savedir,
- filters,
- )
- else:
- # print(filters)
- fichier = QFileDialog.getOpenFileName(
- self.appliEficas,
- tr("Ouvrir Fichier"),
- self.appliEficas.maConfiguration.savedir,
- filters,
- )
-
- fichier = fichier[0]
- if not (fichier == ""):
- ulfile = os.path.abspath(fichier)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- self.lineEditVal.setText(fichier)
- self.editor.afficheCommentaire(tr("Fichier selectionne"))
- self.LEvaleurPressed()
- if QFileInfo(fichier).suffix() in listeSuffixe:
- self.image = fichier
- if not hasattr(self, "BSelectInFile"):
- try:
- self.BSelectInFile = QPushButton(self)
- self.BSelectInFile.setMinimumSize(QSize(140, 40))
- self.BSelectInFile.setObjectName("BSelectInFile")
- self.gridLayout.addWidget(self.BSelectInFile, 1, 1, 1, 1)
- self.BSelectInFile.setText(tr("Selection"))
- self.BSelectInFile.clicked.connect(self.BSelectInFilePressed)
- except:
- pass
- else:
- self.BSelectInFile.setVisible(1)
-
- elif hasattr(self, "BSelectInFile"):
- self.BSelectInFile.setVisible(0)
-
- def BFichierOuRepertoirePressed(self):
- self.fileName = ""
- self.file_dialog = QFileDialog()
- self.file_dialog.setFileMode(QFileDialog.Directory)
- self.file_dialog.setFileMode(QFileDialog.Directory | QFileDialog.ExistingFiles)
- self.file_dialog.setOption(QFileDialog.DontUseNativeDialog, True)
- self.file_dialog.setWindowTitle("Choose File or Directory")
- self.explore(self.file_dialog)
- self.file_dialog.exec_()
- if self.fileName == "":
- return
- self.lineEditVal.setText(self.fileName)
- self.LEvaleurPressed()
-
- def explore(self, widget):
- for c in widget.children():
- if isinstance(c, QTreeView):
- c.clicked.connect(self.changeBoutonOpen)
- self.monTreeView = c
- try:
- if c.text() == "&Open":
- self.monBoutonOpen = c
- except:
- pass
- self.explore(c)
-
- def changeBoutonOpen(self):
- self.monBoutonOpen.setEnabled(True)
- self.monBoutonOpen.setText("Choose")
- self.monBoutonOpen.clicked.connect(self.monBoutonOpenClicked)
- index = self.monTreeView.currentIndex()
- self.fileName2 = self.monTreeView.model().data(index)
-
- def monBoutonOpenClicked(self):
- try:
- self.fileName = self.file_dialog.selectedFiles()[0]
- except:
- self.fileName = self.file_dialog.directory().absolutePath()
- self.file_dialog.close()
- self.file_dialog = None
-
- def BRepertoirePressed(self):
- directory = QFileDialog.getExistingDirectory(
- self.appliEficas,
- directory=self.appliEficas.maConfiguration.savedir,
- options=QFileDialog.ShowDirsOnly,
- )
-
- if not (directory == ""):
- absdir = os.path.abspath(directory)
- self.appliEficas.maConfiguration.savedir = os.path.dirname(absdir)
- self.lineEditVal.setText(directory)
- self.LEvaleurPressed()
-
- def BSelectInFilePressed(self):
- from monSelectImage import MonSelectImage
-
- MonSelectImage(file=self.image, parent=self).show()
-
- def BSalomePressed(self):
- self.editor.afficheCommentaire("")
- selection = []
- commentaire = ""
- genea = self.node.item.getGenealogie()
- kwType = self.node.item.get_definition().type[0]
- for e in genea:
- if "GROUP_NO" in e:
- kwType = "GROUP_NO"
- if "GROUP_MA" in e:
- kwType = "GROUP_MA"
-
- if "grno" in repr(kwType):
- kwType = "GROUP_NO"
- if "grma" in repr(kwType):
- kwType = "GROUP_MA"
-
- if kwType in ("GROUP_NO", "GROUP_MA"):
- selection, commentaire = self.appliEficas.selectGroupFromSalome(
- kwType, editor=self.editor
- )
-
- mc = self.node.item.get_definition()
-
- if isinstance(mc.type, tuple) and len(mc.type) > 1 and "(*.med)" in mc.type[1]:
- selection, commentaire = self.appliEficas.selectMeshFile(editor=self.editor)
- # print selection, commentaire
- if commentaire != "":
- QMessageBox.warning(
- None,
- tr("Export Med vers Fichier "),
- tr("Impossibilite d exporter le Fichier"),
- )
- return
- else:
- self.lineEditVal.setText(str(selection))
- return
-
- from Accas import SalomeEntry
-
- if inspect.isclass(kwType) and issubclass(kwType, SalomeEntry):
- selection, commentaire = self.appliEficas.selectEntryFromSalome(
- kwType, editor=self.editor
- )
-
- if commentaire != "":
- self.editor.afficheInfos(tr(str(commentaire)))
- if selection == []:
- return
-
- min, max = self.node.item.getMinMax()
- if max > 1:
- self.ajoutNValeur(selection)
- return
-
- monTexte = ""
- for geomElt in selection:
- monTexte = geomElt + ","
- monTexte = monTexte[0:-1]
- self.lineEditVal.setText(str(monTexte))
- self.LEvaleurPressed()
-
- def BView2DPressed(self):
- try:
- # cas d un Simp de base
- valeur = self.lineEditVal.text()
- except:
- valeur = self.textSelected
- valeur = str(valeur)
- if valeur == str(""):
- return
- if valeur:
- ok, msgError = self.appliEficas.displayShape(valeur)
- if not ok:
- self.editor.afficheInfos(msgError, Qt.red)
-
- def BParametresPressed(self):
- liste = self.node.item.getListeParamPossible()
- from monListeParamPanel import MonListeParamPanel
-
- MonListeParamPanel(liste=liste, parent=self).show()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-import traceback
-
-
-from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog, QMessageBox
-from PyQt5.QtCore import QEvent, Qt, QTimer
-from PyQt5.QtGui import QIcon, QPalette
-
-from Extensions.i18n import tr
-from InterfaceQT4.monViewTexte import ViewText
-
-
-# ---------------------- #
-class LECustom(QLineEdit):
- # ---------------------- #
- def __init__(self, parent, parentQt, i):
- """
- Constructor
- """
- QLineEdit.__init__(self, parent)
-
- self.parentQt = parentQt
- self.num = i
- self.dansUnTuple = False
- self.numDsLaListe = -1
- self.parentTuple = None
- self.valeur = None
- self.aEuLeFocus = 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")
- QLineEdit.focusInEvent(self, event)
-
- def focusOutEvent(self, event):
- # print ('focusOutEvent', self.aEuLeFocus)
- 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()
- QLineEdit.focusOutEvent(self, event)
-
- def litValeur(self):
- # print ("dans litValeur de LECustom")
- self.aEuLeFocus = False
- val = str(self.text())
- 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
- )
- valeur = eval(val, d)
- except:
- valeur = val
- self.valeur = valeur
- # print ('self.valeur', self.valeur)
-
- def clean(self):
- self.setText("")
-
- def getValeur(self):
- # return self.text()
- self.litValeur()
- return self.valeur
-
- def setValeur(self, valeur):
- self.setText(valeur)
-
-
-# --------------------------- #
-class LECustomTuple(LECustom):
- # --------------------------- #
- def __init__(self, parent):
- # index sera mis a jour par TupleCustom
- parentQt = parent.parent().parent().parent()
- LECustom.__init__(self, parent, parentQt, 0)
- # print (dir(self))
-
-
-# ---------------------------- #
-class MonLabelListeClic(QLabel):
- # ---------------------------- #
- def __init__(self, parent):
- QLabel.__init__(self, parent)
- self.parent = parent
-
- def event(self, event):
- if event.type() == QEvent.MouseButtonRelease:
- self.texte = self.text()
- self.parent.traiteClicSurLabelListe(self.texte)
- return QLabel.event(self, event)
-
-
-# ------------- #
-class GereListe(object):
- # ------------- #
- def __init__(self):
- self.connecterSignaux()
-
- def connecterSignaux(self):
- if hasattr(self, "RBHaut"):
- self.RBHaut.clicked.connect(self.hautPushed)
- self.RBBas.clicked.connect(self.basPushed)
- self.RBMoins.clicked.connect(self.moinsPushed)
- self.RBPlus.clicked.connect(self.plusPushed)
- self.RBVoisListe.clicked.connect(self.voisListePushed)
- if hasattr(self, "PBAlpha"):
- self.PBCata.clicked.connect(self.cataPushed)
- self.PBAlpha.clicked.connect(self.alphaPushed)
- self.PBFind.clicked.connect(self.findPushed)
- self.LEFiltre.returnPressed.connect(self.LEFiltreReturnPressed)
- if hasattr(self, "PBValideFeuille"):
- self.PBValideFeuille.clicked.connect(self.changeValeur)
-
- def filtreListe(self):
- l = []
- if self.filtre != "":
- for i in self.listeAAfficher:
- if i.find(self.filtre) == 0:
- l.append(i)
- self.listeAAfficher = l
- if self.alpha:
- self.listeAAfficher.sort()
-
- def LEFiltreReturnPressed(self):
- self.filtre = self.LEFiltre.text()
- self.prepareListeResultatFiltre()
-
- def findPushed(self):
- self.filtre = self.LEFiltre.text()
- self.prepareListeResultatFiltre()
-
- def alphaPushed(self):
- # print "alphaPushed" ,self.alpha
- if self.alpha == 1:
- return
- self.alpha = 1
- self.prepareListeResultat()
-
- def cataPushed(self):
- if self.alpha == 0:
- return
- self.alpha = 0
- self.prepareListeResultat()
-
- def hautPushed(self):
- # print ('hautPushed')
- if self.numLineEditEnCours == 0:
- return
- if self.numLineEditEnCours == 1:
- return
- else:
- numEchange = self.numLineEditEnCours - 1
- self.echange(self.numLineEditEnCours, numEchange)
- self.lineEditEnCours.setFocus(True)
- self.scrollArea.ensureWidgetVisible(self.lineEditEnCours)
-
- def basPushed(self):
- # print ('hautPushed')
- if self.numLineEditEnCours == 0:
- return
- if self.numLineEditEnCours == self.indexDernierLabel:
- return
- else:
- numEchange = self.numLineEditEnCours + 1
- self.echange(self.numLineEditEnCours, numEchange)
- self.lineEditEnCours.setFocus(True)
- self.scrollArea.ensureWidgetVisible(self.lineEditEnCours)
-
- def echange(self, num1, num2):
- # on donne le focus au a celui ou on a bouge
- # par convention le 2
- # print ('echange')
- nomLineEdit = self.nomLine + str(num1)
- # print (nomLineEdit)
- courant = getattr(self, nomLineEdit)
- valeurAGarder = courant.text()
- nomLineEdit2 = self.nomLine + str(num2)
- # print (nomLineEdit2)
- courant2 = getattr(self, nomLineEdit2)
- courant.setText(courant2.text())
- courant2.setText(valeurAGarder)
- # pour monWidgetCreeUserAssd
- self.num1 = num1
- self.num2 = num2
- self.changeValeur(changeDePlace=False)
- self.numLineEditEnCours = num2
- self.lineEditEnCours = courant2
- self.lineEditEnCours.setFocus(True)
-
- def moinsPushed(self):
- # on supprime le dernier
- # print ('moinsPushed')
- if self.numLineEditEnCours == 0:
- return
- if self.indexDernierLabel == 0:
- return
- if self.numLineEditEnCours == self.indexDernierLabel:
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
- courant = getattr(self, nomLineEdit)
- courant.clean()
- else:
- for i in range(self.numLineEditEnCours, self.indexDernierLabel):
- aRemonter = i + 1
- nomLineEdit = self.nomLine + str(aRemonter)
- courant = getattr(self, nomLineEdit)
- valeurARemonter = courant.getValeur()
- nomLineEdit = self.nomLine + str(i)
- courant = getattr(self, nomLineEdit)
- if valeurARemonter != None:
- courant.setValeur(valeurARemonter)
- else:
- courant.clean()
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
- courant = getattr(self, nomLineEdit)
- courant.clean()
- self.changeValeur(changeDePlace=False, oblige=True)
- self.setValide()
-
- def plusPushed(self):
- # print ('plusPushed gereliste')
- if self.indexDernierLabel == self.monSimpDef.max:
- if len(self.listeValeursCourantes) < self.monSimpDef.max:
- self.chercheLigneVide()
- else:
- self.editor.afficheInfos(
- "nb max de valeurs : " + str(self.monSimpDef.max) + " atteint",
- Qt.red,
- )
- return
- self.ajoutLineEdit()
- self.descendLesLignes()
- self.chercheLigneVide()
- QTimer.singleShot(1, self.rendVisibleLigne)
-
- def chercheLigneVide(self):
- # print ('chercheLigneVide')
- for i in range(self.indexDernierLabel):
- nomLineEdit = self.nomLine + str(i + 1)
- courant = getattr(self, nomLineEdit)
- valeur = courant.getValeur()
- if valeur == "" or valeur == None:
- courant.setFocus(True)
- self.estVisible = courant
-
- def descendLesLignes(self):
- # print ('descendLesLignes')
- if self.numLineEditEnCours == self.indexDernierLabel:
- return
- nomLineEdit = self.nomLine + str(self.numLineEditEnCours + 1)
- courant = getattr(self, nomLineEdit)
- valeurADescendre = courant.getValeur()
- courant.clean()
- for i in range(self.numLineEditEnCours + 1, self.indexDernierLabel):
- aDescendre = i + 1
- nomLineEdit = self.nomLine + str(aDescendre)
- courant = getattr(self, nomLineEdit)
- valeurAGarder = courant.getValeur()
- courant.setValeur(valeurADescendre)
- valeurADescendre = valeurAGarder
- self.changeValeur(changeDePlace=False)
- if hasattr(self, "lineEditEnCours"):
- self.scrollArea.ensureWidgetVisible(self.lineEditEnCours)
-
- def voisListePushed(self):
- texteValeurs = ""
- for v in self.node.item.getListeValeurs():
- texteValeurs += str(v) + ", "
- entete = "Valeurs pour " + self.nom
- f = ViewText(self, self.editor, entete, texteValeurs[0:-2])
- f.show()
-
- def selectInFile(self):
- init = str(self.editor.maConfiguration.savedir)
- fn = QFileDialog.getOpenFileName(
- self.node.appliEficas,
- tr("Fichier de donnees"),
- init,
- tr(
- "Tous les Fichiers (*)",
- ),
- )
- fn = fn[0]
- if fn == None:
- return
- if fn == "":
- return
- ulfile = os.path.abspath(fn)
- self.editor.maConfiguration.savedir = os.path.split(ulfile)[0]
-
- from .monSelectVal import MonSelectVal
-
- MonSelectVal(file=fn, parent=self).show()
-
- def noircirResultatFiltre(self):
- filtre = str(self.LEFiltre.text())
- for cb in self.listeCbRouge:
- palette = QPalette(Qt.red)
- palette.setColor(QPalette.WindowText, Qt.black)
- cb.setPalette(palette)
- t = cb.text()
- cb.setText(t)
- self.LEFiltre.setText("")
- self.listeCbRouge = []
-
-
-# ----------- #
-class GerePlie(object):
- # ----------- #
-
- def gereIconePlier(self):
- if not (hasattr(self, "BFermeListe")):
- return
- self.editor.listeDesListesOuvertes.add(self.node.item)
- repIcon = self.node.editor.appliEficas.repIcon
- if not (self.editor.afficheListesPliees):
- fichier = os.path.join(repIcon, "empty.png")
- icon = QIcon(fichier)
- self.BFermeListe.setIcon(icon)
- return
- fichier = os.path.join(repIcon, "minusnode.png")
- icon = QIcon(fichier)
- self.BFermeListe.setIcon(icon)
- self.BFermeListe.clicked.connect(self.selectWidgetPlie)
-
- def selectWidgetPlie(self):
- self.editor.listeDesListesOuvertes.remove(self.node.item)
- self.reaffichePourDeplier()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-import traceback
-
-from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog, QWidget
-from PyQt5.QtCore import QEvent, Qt, QTimer
-from PyQt5.QtGui import QIcon, QPalette
-
-from Extensions.i18n import tr
-from InterfaceQT4.monViewTexte import ViewText
-
-
-# ---------------------- #
-class LECustom(QLineEdit):
- # ---------------------- #
- def __init__(self, parent, parentQt, i):
- """
- Constructor
- """
- QLineEdit.__init__(self, parent)
-
- self.valeur = None
- self.aEuLeFocus = False
- self.parentQt = parentQt
- self.parent = parent
- self.num = i
- self.dansUnTuple = False
- self.numDsLaListe = -1
- self.returnPressed.connect(self.litValeur)
-
- def focusInEvent(self, event):
- # print ("dans focusInEvent de LECustom",self.parentQt)
- print("dans focusInEvent de LECustom", self.num, self.numDsLaListe)
- 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")
- QLineEdit.focusInEvent(self, event)
-
- def focusOutEvent(self, event):
- # print ("dans focusOutEvent de LECustom",self.num,self.numDsLaListe, self.aEuLeFocus)
- 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()
- QLineEdit.focusOutEvent(self, event)
-
- def litValeur(self):
- self.aEuLeFocus = False
- val = str(self.text())
- 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
- )
- valeur = eval(val, d)
- except:
- valeur = val
-
- self.valeur = valeur
-
- def clean(self):
- self.setText("")
-
- def getValeur(self):
- return self.text()
-
- def setValeur(self, valeur):
- self.setText(valeur)
- self.valeur = valeur
-
- # def leaveEvent(self,event):
- # ne sert a rien. quand on modifie la valeur on prend le focus
-
-
-# --------------------------- #
-class LECustomTuple(LECustom):
- # --------------------------- #
- def __init__(self, parent):
- # index sera mis a jour par TupleCustom
- parentQt = parent.parent().parent().parent()
- LECustom.__init__(self, parent, parentQt, 0)
- # print (dir(self))
-
-
-# ---------------------------- #
-class MonLabelListeClic(QLabel):
- # ---------------------------- #
- def __init__(self, parent):
- QLabel.__init__(self, parent)
- self.parent = parent
-
- def event(self, event):
- if event.type() == QEvent.MouseButtonRelease:
- self.texte = self.text()
- self.parent.traiteClicSurLabelListe(self.texte)
- return QLabel.event(self, event)
-
-
-# ------------- #
-class GereListe(object):
- # ------------- #
-
- def __init__(self):
- self.aEuLeFocus = False
- self.connecterSignaux()
-
- def leaveEvent(self, event):
- if self.aEuLeFocus:
- print("appel de changeValeur")
- self.changeValeur()
- self.aEuLeFocus = False
- QWidget.leaveEvent(self, event)
-
- def connecterSignaux(self):
- if hasattr(self, "RBHaut"):
- self.RBHaut.clicked.connect(self.hautPushed)
- self.RBBas.clicked.connect(self.basPushed)
- self.RBMoins.clicked.connect(self.moinsPushed)
- self.RBPlus.clicked.connect(self.plusPushed)
- self.RBVoisListe.clicked.connect(self.voisListePushed)
- if hasattr(self, "PBAlpha"):
- self.PBCata.clicked.connect(self.cataPushed)
- self.PBAlpha.clicked.connect(self.alphaPushed)
- self.PBFind.clicked.connect(self.findPushed)
- self.LEFiltre.returnPressed.connect(self.LEFiltreReturnPressed)
-
- def filtreListe(self):
- l = []
- if self.filtre != "":
- for i in self.listeAAfficher:
- if i.find(self.filtre) == 0:
- l.append(i)
- self.listeAAfficher = l
- if self.alpha:
- self.listeAAfficher.sort()
-
- def LEFiltreReturnPressed(self):
- self.filtre = self.LEFiltre.text()
- self.prepareListeResultatFiltre()
-
- def findPushed(self):
- self.filtre = self.LEFiltre.text()
- self.prepareListeResultatFiltre()
-
- def alphaPushed(self):
- # print "alphaPushed" ,self.alpha
- if self.alpha == 1:
- return
- self.alpha = 1
- self.prepareListeResultat()
-
- def cataPushed(self):
- if self.alpha == 0:
- return
- self.alpha = 0
- self.prepareListeResultat()
-
- def hautPushed(self):
- if self.numLineEditEnCours == 1:
- return
- else:
- numEchange = self.numLineEditEnCours - 1
- self.echange(self.numLineEditEnCours, numEchange)
- self.LineEditEnCours.setFocus(True)
- self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
-
- def basPushed(self):
- if self.numLineEditEnCours == self.indexDernierLabel:
- return
- else:
- numEchange = self.numLineEditEnCours + 1
- self.echange(self.numLineEditEnCours, numEchange)
- self.LineEditEnCours.setFocus(True)
- self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
-
- def echange(self, num1, num2):
- # on donne le focus au a celui ou on a bouge
- # par convention le 2
- nomLineEdit = self.nomLine + str(num1)
- # print nomLineEdit
- courant = getattr(self, nomLineEdit)
- valeurAGarder = courant.text()
- nomLineEdit2 = self.nomLine + str(num2)
- # print nomLineEdit2
- courant2 = getattr(self, nomLineEdit2)
- courant.setText(courant2.text())
- courant2.setText(valeurAGarder)
- self.changeValeur(changeDePlace=False)
- self.numLineEditEnCours = num2
- self.LineEditEnCours = courant2
- self.LineEditEnCours.setFocus(True)
-
- def moinsPushed(self):
- # on supprime le dernier
- if self.numLineEditEnCours == 0:
- return
- if self.indexDernierLabel == 0:
- return
- if self.numLineEditEnCours == self.indexDernierLabel:
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
- courant = getattr(self, nomLineEdit)
- courant.clean()
- else:
- for i in range(self.numLineEditEnCours, self.indexDernierLabel):
- aRemonter = i + 1
- nomLineEdit = self.nomLine + str(aRemonter)
- courant = getattr(self, nomLineEdit)
- valeurARemonter = courant.getValeur()
- nomLineEdit = self.nomLine + str(i)
- courant = getattr(self, nomLineEdit)
- if valeurARemonter != None:
- courant.setValeur(valeurARemonter)
- else:
- courant.clean()
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
- courant = getattr(self, nomLineEdit)
- courant.clean()
- self.changeValeur(changeDePlace=False, oblige=True)
- self.setValide()
-
- def plusPushed(self):
- if self.indexDernierLabel == self.monSimpDef.max:
- if len(self.listeValeursCourantes) < self.monSimpDef.max:
- self.chercheLigneVide()
- else:
- self.editor.afficheInfos(
- "nb max de valeurs : " + str(self.monSimpDef.max) + " atteint",
- Qt.red,
- )
- return
- self.ajoutLineEdit()
- self.descendLesLignes()
- self.chercheLigneVide()
- QTimer.singleShot(1, self.rendVisibleLigne)
-
- def chercheLigneVide(self):
- for i in range(self.indexDernierLabel):
- nomLineEdit = self.nomLine + str(i + 1)
- courant = getattr(self, nomLineEdit)
- valeur = courant.getValeur()
- if valeur == "":
- courant.setFocus(True)
- self.estVisible = courant
- return
-
- def descendLesLignes(self):
- if self.numLineEditEnCours == self.indexDernierLabel:
- return
- nomLineEdit = self.nomLine + str(self.numLineEditEnCours + 1)
- courant = getattr(self, nomLineEdit)
- valeurADescendre = courant.getValeur()
- courant.clean()
- for i in range(self.numLineEditEnCours + 1, self.indexDernierLabel):
- aDescendre = i + 1
- nomLineEdit = self.nomLine + str(aDescendre)
- courant = getattr(self, nomLineEdit)
- valeurAGarder = courant.getValeur()
- courant.setValeur(valeurADescendre)
- valeurADescendre = valeurAGarder
- self.changeValeur(changeDePlace=False)
- if hasattr(self, "LineEditEnCours"):
- self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
-
- def voisListePushed(self):
- texteValeurs = ""
- for v in self.node.item.getListeValeurs():
- texteValeurs += str(v) + ", "
- entete = "Valeurs pour " + self.nom
- f = ViewText(self, self.editor, entete, texteValeurs[0:-2])
- f.show()
-
- def selectInFile(self):
- init = str(self.editor.maConfiguration.savedir)
- fn = QFileDialog.getOpenFileName(
- self.node.appliEficas,
- tr("Fichier de donnees"),
- init,
- tr(
- "Tous les Fichiers (*)",
- ),
- )
- fn = fn[0]
- if fn == None:
- return
- if fn == "":
- return
- import six
- ulfile = os.path.abspath(six.text_type(fn))
- self.editor.maConfiguration.savedir = os.path.split(ulfile)[0]
-
- from .monSelectVal import MonSelectVal
-
- MonSelectVal(file=fn, parent=self).show()
-
- def noircirResultatFiltre(self):
- filtre = str(self.LEFiltre.text())
- for cb in self.listeCbRouge:
- palette = QPalette(Qt.red)
- palette.setColor(QPalette.WindowText, Qt.black)
- cb.setPalette(palette)
- t = cb.text()
- cb.setText(t)
- self.LEFiltre.setText("")
- self.listeCbRouge = []
-
-
-# ----------- #
-class GerePlie(object):
- # ----------- #
-
- def gereIconePlier(self):
- if not (hasattr(self, "BFermeListe")):
- return
- self.editor.listeDesListesOuvertes.add(self.node.item)
- repIcon = self.node.editor.appliEficas.repIcon
- if not (self.editor.afficheListesPliees):
- fichier = os.path.join(repIcon, "empty.png")
- icon = QIcon(fichier)
- self.BFermeListe.setIcon(icon)
- return
- fichier = os.path.join(repIcon, "minusnode.png")
- icon = QIcon(fichier)
- self.BFermeListe.setIcon(icon)
- self.BFermeListe.clicked.connect(self.selectWidgetPlie)
-
- def selectWidgetPlie(self):
- self.editor.listeDesListesOuvertes.remove(self.node.item)
- self.reaffichePourDeplier()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from PyQt5.QtCore import Qt
-from .monViewRegles import ViewRegles
-from Extensions.i18n import tr
-
-
-class GereRegles(object):
- def appellebuildLBRegles(self):
- from .browser import JDCTree
-
- if isinstance(self, JDCTree):
- self.appellebuildLBReglesForJdC()
- else:
- self.appellebuildLBReglesForCommand()
- self.buildLBRegles(self.listeRegles, self.listeNomsEtapes)
- self.afficheRegles()
-
- def appellebuildLBReglesForCommand(self):
- self.listeRegles = self.item.getRegles()
- self.listeNomsEtapes = self.item.getMcPresents()
-
- def appellebuildLBReglesForJdC(self):
- self.listeRegles = self.item.getRegles()
- self.listeNomsEtapes = self.item.getLNomsEtapes()
-
- def buildLBRegles(self, listeRegles, listeNomsEtapes):
- self.liste = []
- if len(listeRegles) > 0:
- for regle in listeRegles:
- texteRegle = regle.getText()
- texteMauvais, test = regle.verif(listeNomsEtapes)
- for ligne in texteRegle.split("\n"):
- if ligne == "":
- continue
- if ligne[0] == "\t":
- ligne = " " + ligne[1:]
- if test:
- self.liste.append((ligne, Qt.black))
- else:
- self.liste.append((ligne, Qt.red))
- self.liste.append(("", Qt.red))
- if self.liste == []:
- self.liste.append(
- ("pas de regle de construction pour ce jeu de commandes", Qt.black)
- )
-
- def afficheRegles(self):
- titre = "Regles pour " + self.item.nom
- w = ViewRegles(self.editor, self.liste, titre)
- w.exec_()
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-import os
-from PyQt5.QtWidgets import QFileDialog, QApplication
-from Extensions.i18n import tr
-
-
-def traduction(directPath, editor, version):
- if version == "V9V10":
- from Traducteur import traduitV9V10
-
- suffixe = "v10.comm"
- if version == "V10V11":
- from Traducteur import traduitV10V11
-
- suffixe = "v11.comm"
- if version == "V11V12":
- from Traducteur import traduitV11V12
-
- suffixe = "v12.comm"
-
- fn = QFileDialog.getOpenFileName(
- editor.appliEficas,
- tr("Traduire Fichier"),
- directPath,
- tr("Fichiers JDC (*.comm);;" "Tous les Fichiers (*)"),
- )
-
- fn = fn[0]
- FichieraTraduire = str(fn)
- if FichieraTraduire == "" or FichieraTraduire == ():
- return
- i = FichieraTraduire.rfind(".")
- Feuille = FichieraTraduire[0:i]
- FichierTraduit = Feuille + suffixe
-
- i = Feuille.rfind("/")
- directLog = Feuille[0:i]
- log = directLog + "/convert.log"
- os.system("rm -rf " + log)
- os.system("rm -rf " + FichierTraduit)
-
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
- if version == "V9V10":
- traduitV9V10.traduc(FichieraTraduire, FichierTraduit, log)
- if version == "V10V11":
- traduitV10V11.traduc(FichieraTraduire, FichierTraduit, log)
- if version == "V11V12":
- traduitV11V12.traduc(FichieraTraduire, FichierTraduit, log)
- QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
-
- Entete = tr("Fichier Traduit : %s\n\n", str(FichierTraduit))
- if os.stat(log)[6] != 0:
- f = open(log)
- texte = f.read()
- f.close()
- else:
- texte = Entete
- commande = "diff " + FichieraTraduire + " " + FichierTraduit + " >/dev/null"
- try:
- if os.system(commande) == 0:
- texte = texte + tr(
- "Pas de difference entre le fichier origine et le fichier traduit"
- )
- except:
- pass
-
- from .monVisu import DVisu
-
- titre = "conversion de " + FichieraTraduire
- monVisuDialg = DVisu(parent=editor.appliEficas, fl=0)
- monVisuDialg.setWindowTitle(titre)
- monVisuDialg.TB.setText(texte)
- monVisuDialg.show()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-# Management of EFICAS version numbering.
-# A version has at least major and minor numbers, for easier comparison.
-
-__version = {"major": 9, "minor": 11}
-
-
-def getEficasVersion():
- """
- Return the EFICAS current version number.
- """
- return "%s.%s" % (getMajor(), getMinor())
-
-def getSalomeVersion():
- """
- Return the SALOME version number to which current EFICAS version is related.
- """
- return getEficasVersion()
-
-def getMajor():
- return __version["major"]
-
-def getMinor():
- return __version["minor"]
-
-def getBaseVersion():
- """
- Returns [ major, minor ] array of integers.
- """
- return [getMajor(), getMinor()]
-
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from PyQt5.QtWidgets import QWidget, QSpacerItem, QSizePolicy
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-
-from .gereIcones import FacultatifOuOptionnel
-import traceback
-
-
-# Import des panels
-
-
-class Groupe(QWidget, FacultatifOuOptionnel):
- """ """
-
- def __init__(self, node, editor, parentQt, definition, obj, niveau, commande=None):
- # print ("groupe : ",self.node.item.nom," ",self.node.fenetre)
- QWidget.__init__(self, None)
- self.node = node
- self.node.fenetre = self
- self.setupUi(self)
- self.editor = editor
- self.obj = obj
- self.niveau = niveau
- self.definition = definition
- self.parentQt = parentQt
- self.maCommande = commande
- self.listeFocus = []
- self.appliEficas = self.editor.appliEficas
- self.repIcon = self.appliEficas.repIcon
- self.jdc = self.node.item.getJdc()
- self.setIconePoubelle()
- self.setIconesGenerales()
- self.setRun()
- self.setValide()
- self.setReglesEtAide()
- self.afficheMots()
- self.listeMCAAjouter = []
- self.dictMCVenantDesBlocs = {}
- if hasattr(self, "RBDeplie"):
- self.RBDeplie.clicked.connect(self.setDeplie)
- if hasattr(self, "RBPlie"):
- self.RBPlie.clicked.connect(self.setPlie)
-
- self.setAcceptDrops(True)
- # if hasattr (self, 'commandesLayout'):
- # print (' j ajoute un spacer dans ', self.node.item.nom)
- # spacerItem = QSpacerItem(20, 5, QSizePolicy.Minimum, QSizePolicy.Expanding)
- # self.commandesLayout.addItem(spacerItem)
-
- def donneFocus(self):
- for fenetre in self.listeFocus:
- if fenetre == None:
- return
- if fenetre.node.item.isValid() == 0:
- fenetre.prendLeFocus = 1
- fenetre.hide()
- fenetre.show()
-
- def afficheMots(self):
- # print ("ds afficheMots ",self.node.item.nom,self.node.plie)
- for node in self.node.children:
- # non return mais continue car il faut tenir compte des blocs
- if node.appartientAUnNoeudPlie == True:
- continue
- widget = node.getPanelGroupe(self, self.maCommande)
- # print ("widget pour ", node.item.nom, widget)
- self.listeFocus.append(node.fenetre)
- # print "fin pour " , self.node.item.nom
-
- def calculOptionnel(self):
- self.listeMc = []
- self.listeMcRegle = []
- self.dictToolTipMc = {}
- genea = self.obj.getGenealogie()
- # Attention : les mots clefs listes (+sieurs fact )
- # n ont pas toutes ces methodes
- try:
- # if 1 :
- self.listeMc = self.obj.getListeMcOrdonnee(
- genea, self.jdc.cata_ordonne_dico
- )
- listeNomsPresents = self.obj.dictMcPresents()
- for regle in self.obj.getRegles():
- (monToolTip, regleOk) = regle.verif(listeNomsPresents)
- if regleOk:
- continue
- for mc in regle.mcs:
- self.listeMcRegle.append(mc)
- self.dictToolTipMc[mc] = monToolTip
- except:
- # print ('in except')
- # print (self)
- return
-
- def afficheOptionnel(self):
- if self.editor.maConfiguration.closeOptionnel:
- return
- liste, liste_rouge = self.ajouteMCOptionnelDesBlocs()
- self.monOptionnel = self.editor.widgetOptionnel
- self.monOptionnel.afficheOptionnel(liste, liste_rouge, self)
-
- def ajouteMCOptionnelDesBlocs(self):
- self.dictMCVenantDesBlocs = {}
- i = 0
- self.calculOptionnel()
- liste = self.listeMc
- liste_rouge = self.listeMcRegle
- for MC in self.listeMc:
- self.dictMCVenantDesBlocs[MC] = self
- # ce cas est le cas machine tournant sr le plie
- try:
- while i < self.commandesLayout.count():
- from .monWidgetBloc import MonWidgetBloc
-
- widget = self.commandesLayout.itemAt(i).widget()
- i = i + 1
- if not (isinstance(widget, MonWidgetBloc)):
- continue
- widget.calculOptionnel()
- listeW, listeW_rouge = widget.ajouteMCOptionnelDesBlocs()
- for MC in widget.dictMCVenantDesBlocs:
- if MC in self.dictMCVenantDesBlocs:
- print("Pb Sur les MC")
- else:
- self.dictMCVenantDesBlocs[MC] = widget.dictMCVenantDesBlocs[MC]
- liste = liste + listeW
- liste_rouge = liste_rouge + listeW_rouge
- except:
- pass
- return (liste, liste_rouge)
-
- def reaffiche(self, nodeAVoir=None):
- # print "dans reaffiche de groupe.py", nodeAVoir
- self.parentQt.reaffiche(nodeAVoir)
-
- def recalculeListeMC(self, listeMC):
- # print "pas si peu utile"
- # on ajoute et on enleve
- listeNode = []
- for name in listeMC:
- nodeAEnlever = self.node.appendChild(name)
- if nodeAEnlever.item.isMCList():
- nodeAEnlever = nodeAEnlever.children[-1]
- listeNode.append(nodeAEnlever)
- self.afficheOptionnel()
- self.monOptionnel.affiche(self.listeMc)
- if len(listeNode) == 0:
- return
- if len(listeNode) == 1:
- listeNode[0].delete()
- self.editor.afficheInfos("")
- return
- for noeud in listeNode:
- noeud.treeParent.item.suppItem(noeud.item)
- noeud.treeParent.buildChildren()
- self.editor.afficheInfos("")
-
- def ajoutMC(self, texteListeNom):
- listeNom = texteListeNom.split("+")[1:]
- firstNode = None
- for nom in listeNom:
- if nom not in self.dictMCVenantDesBlocs:
- # print "bizarre, bizarre"
- self.editor.initModif()
- nouveau = self.node.appendChild(nom)
- else:
- self.editor.initModif()
- widget = self.dictMCVenantDesBlocs[nom]
- nouveau = widget.node.appendChild(nom)
- if firstNode == None:
- firstNode = nouveau
- if nouveau == None or nouveau == 0:
- self.editor.afficheInfos(
- tr("insertion impossible a cet endroit pour " + nom), Qt.red
- )
- try:
- self.reaffiche(firstNode)
- if firstNode != None and firstNode != 0 and firstNode.item != None:
- firstNode.select()
- except:
- pass
-
- def setPlie(self):
- self.node.setPlie()
- self.reaffiche(self.node)
-
- def setDeplie(self):
- # print ('je passe ds setDeplie de groupe', self.obj.nom)
- self.node.firstDeplie = False
- self.node.setDeplie()
- self.reaffiche(self.node)
-
- def traiteClicSurLabel(self, texte):
- if self.editor.code != "CARMELCND":
- self.afficheOptionnel()
- try:
- fr = self.node.item.getFr()
- self.editor.afficheCommentaire(str(fr))
- except:
- pass
-
- def propageChange(self, leType, donneLefocus):
- self.parentQt.propageChange(leType, donneLefocus)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-import re
-import os
-
-from PyQt5.QtWidgets import QToolButton, QToolTip
-from Extensions.i18n import tr
-
-class MonBoutonValide(QToolButton):
- def __init__(self, parent):
- QToolButton.__init__(self, parent)
- while not (hasattr(parent, "node")):
- parent = parent.parent()
- self.parent = parent
-
- def mouseDoubleClickEvent(self, event):
- # print "dans mouseDoubleClickEvent"
- strAide = self.parent.node.item.object.getFr()
- if hasattr(self.parent.node.item.object.definition, "defaut"):
- strAide += "\ndefaut : \n" + str(
- self.parent.node.item.object.definition.defaut
- )
- strRapport = str(self.parent.node.item.object.report())
- self.parent.editor._viewText(strAide + "\n" + strRapport, "JDC_RAPPORT")
-
- def mousePressEvent(self, event):
- # print "dans mousePressEvent"
- if self.parent.node.item.object.isValid():
- myToolTip = tr("objet valide")
- if self.parent.editor.maConfiguration.differencieSiDefaut:
- if hasattr(self.parent.node.item.object.definition, "defaut"):
- if (
- self.parent.node.item.object.valeur
- != self.parent.node.item.object.definition.defaut
- ):
- myToolTip += "\ndefaut : \n" + str(
- self.parent.node.item.object.definition.defaut
- )
-
- QToolTip.showText(event.globalPos(), myToolTip)
- else:
- t = ""
- texte = self.parent.node.item.object.report().report()
- deb = 1
- for l in texte.split("\n")[2:-2]:
- if re.match("^[\t !]*$", l):
- continue
- if re.match("^ *Fin Mot-cl", l):
- continue
- if re.match("^ *D?but Mot-cl", l):
- continue
- if re.match("^ *Mot-cl", l):
- continue
- l = l.replace("!", "")
- if deb:
- deb = 0
- t = l
- else:
- t = t + "\n" + l
- myToolTip = tr(t)
- QToolTip.showText(event.globalPos(), myToolTip)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from desChoixCata import Ui_DChoixCata
-from PyQt5.QtWidgets import QDialog
-from Extensions.i18n import tr
-
-# Import des panels
-class MonChoixCata(Ui_DChoixCata, QDialog):
- """ """
-
- def __init__(self, QWparent, listeCata, title=None):
- QDialog.__init__(self, QWparent)
- self.setModal(True)
- self.setupUi(self)
- self.CBChoixCata.addItems(listeCata)
- self.TLNb.setText(
- tr("%d versions du catalogue sont disponibles", len(listeCata))
- )
- if title is not None:
- self.setWindowTitle(tr(title))
- self.buttonOk.clicked.connect(self.cataChoisi)
- self.buttonCancel.clicked.connect(self.sortSansChoix)
-
- def sortSansChoix(self):
- QDialog.reject(self)
-
- def cataChoisi(self):
- QDialog.accept(self)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-
-import os, sys, re
-from desChoixCode import Ui_ChoixCode
-from PyQt5.QtWidgets import QDialog, QRadioButton, QGroupBox, QButtonGroup
-from PyQt5.QtGui import QPalette
-from PyQt5.QtCore import QProcess, QFileInfo, Qt, QSize
-
-
-# Import des panels
-
-
-class MonChoixCode(Ui_ChoixCode, QDialog):
- """
- Classe definissant le panel associe aux mots-cles qui demandent
- a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
- discretes
- """
-
- def __init__(self, appliEficas=None):
- QDialog.__init__(self, parent=appliEficas, flags=Qt.Window)
- self.setModal(True)
- self.setupUi(self)
- self.appliEficas = appliEficas
- self.verifieInstall()
- self.code = None
- self.buttonBox.accepted.disconnect(self.accept)
- self.buttonBox.accepted.connect(self.choisitCode)
-
- # self.pB_OK.clicked.connect(self.choisitCode)
- # self.pB_cancel.clicked.connect(self.sortie)
-
- def sortie(self):
- QDialog.reject(self)
-
- def verifieInstall(self):
- self.groupCodes = QButtonGroup(self.groupBox)
- vars = list(os.environ.items())
- listeCode = ("Telemac", "ReacteurNumerique", "Adao")
- for code in listeCode:
- dirCode = os.path.abspath(
- os.path.join(os.path.abspath(__file__), "../..", code)
- )
- try:
- l = os.listdir(dirCode)
- bouton = QRadioButton(self.groupBox)
- bouton.setText(code)
- self.groupCodes.addButton(bouton)
- self.vlBouton.insertWidget(0, bouton)
- except:
- clef = "PREFS_CATA_" + code
- try:
- repIntegrateur = os.path.abspath(os.environ[clef])
- l = os.listdir(repIntegrateur)
- bouton = QRadioButton(self.groupBox)
- bouton.setText(code)
- bouton.show()
- self.groupCodes.addButton(bouton)
- except:
- pass
- listeCodesIntegrateur = []
- for k, v in vars:
- if re.search("^PREFS_CATA_", k) != None and k[11:] not in listeCode:
- listeCodesIntegrateur.append(k[11:])
- for code in listeCodesIntegrateur:
- try:
- clef = "PREFS_CATA_" + code
- repIntegrateur = os.path.abspath(os.environ[clef])
- l = os.listdir(repIntegrateur)
- bouton = QRadioButton(self)
- bouton.setText(code)
- bouton.show()
- self.groupCodes.addButton(bouton)
- except:
- pass
- self.appliEficas.listeCode = self.appliEficas.listeCode + listeCodesIntegrateur
-
- def choisitCode(self):
- bouton = self.groupCodes.checkedButton()
- if bouton == None:
- return
- code = str(bouton.text())
- codeUpper = code.upper()
- self.appliEficas.code = codeUpper
- try:
- dirCode = os.path.abspath(
- os.path.join(os.path.abspath(__file__), "../..", code)
- )
- l = os.listdir(dirCode)
- sys.path.insert(0, dirCode)
- except:
- clef = "PREFS_CATA_" + code
- repIntegrateur = os.path.abspath(os.environ[clef])
- l = os.listdir(repIntegrateur)
- sys.path.insert(0, repIntegrateur)
- self.close()
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from desChoixCommandes import Ui_ChoixCommandes
-from PyQt5.QtWidgets import QWidget, QButtonGroup, QRadioButton, QLabel, QPushButton, QGridLayout
-from PyQt5.QtGui import QIcon, QPixmap
-from PyQt5.QtCore import QSize, QRect
-
-from Extensions.i18n import tr
-import os
-
-
-class MonChoixCommande(Ui_ChoixCommandes, QWidget):
- """ """
-
- def __init__(self, node, jdc_item, editor):
- QWidget.__init__(self, parent=None)
- self.setupUi(self)
-
- self.repIcon = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), "..", "Editeur", "icons"
- )
- iconeFile = os.path.join(self.repIcon, "lettreRblanc30.png")
- icon = QIcon(iconeFile)
- self.RBRegle.setIcon(icon)
- self.RBRegle.setIconSize(QSize(21, 31))
-
- self.item = jdc_item
- self.node = node
- self.editor = editor
- self.simpleClic = self.editor.maConfiguration.simpleClic
- self.jdc = self.item.object.getJdcRoot()
- debutTitre = self.editor.titre
- self.listeWidget = []
- self.dicoCmd = {}
- if self.editor.fichier != None:
- nouveauTitre = debutTitre + " " + os.path.basename(self.editor.fichier)
- else:
- nouveauTitre = debutTitre
- self.editor.appliEficas.setWindowTitle(nouveauTitre)
-
- self.RBalpha.clicked.connect(self.afficheAlpha)
- self.RBGroupe.clicked.connect(self.afficheGroupe)
- self.RBOrdre.clicked.connect(self.afficheOrdre)
- self.RBClear.clicked.connect(self.clearFiltre)
- self.RBCasse.toggled.connect(self.ajouteRadioButtons)
- self.LEFiltre.returnPressed.connect(self.ajouteRadioButtons)
- self.LEFiltre.textChanged.connect(self.ajouteRadioButtons)
-
- if self.node.tree.item.getRegles() == ():
- self.RBRegle.close()
- self.labelRegle.close()
- else:
- self.RBRegle.clicked.connect(self.afficheRegle)
-
- if self.editor.readercata.ordreDesCommandes == None:
- self.RBOrdre.close()
-
- # self.editor.labelCommentaire.setText("")
- if self.editor.widgetOptionnel != None:
- self.editor.fermeOptionnel()
- self.editor.widgetOptionnel = None
- self.name = None
-
- self.boolAlpha = 0
- self.boolGroupe = 0
- self.boolOrdre = 0
- if self.editor.maConfiguration.affiche == "alpha":
- self.boolAlpha == 1
- self.RBalpha.setChecked(True)
- self.afficheAlpha()
- elif self.editor.maConfiguration.affiche == "groupe":
- self.boolGroupe == 1
- self.RBGroupe.setChecked(True)
- self.afficheGroupe()
- elif self.editor.maConfiguration.affiche == "ordre":
- self.boolOrdre == 1
- self.RBOrdre.setChecked(True)
- self.afficheOrdre()
- if (
- self.editor.maConfiguration.closeFrameRechercheCommandeSurPageDesCommandes
- == True
- ):
- self.frameAffichage.close()
-
- if self.editor.widgetTree != None:
- self.editor.restoreSplitterSizes(2)
- else:
- self.editor.restoreSplitterSizes(3)
-
- def afficheRegle(self):
- self.node.tree.appellebuildLBRegles()
-
- def afficheAlpha(self):
- self.boolAlpha = 1
- self.boolGroupe = 0
- self.boolOrdre = 0
- self.ajouteRadioButtons()
-
- def afficheGroupe(self):
- self.boolAlpha = 0
- self.boolGroupe = 1
- self.boolOrdre = 0
- self.ajouteRadioButtons()
-
- def afficheOrdre(self):
- self.boolAlpha = 0
- self.boolGroupe = 0
- self.boolOrdre = 1
- self.ajouteRadioButtons()
-
- def insereNoeudApresClick(self, event):
- # print self.editor.Classement_Commandes_Ds_Arbre
- # if self.editor.Classement_Commandes_Ds_Arbre!= () : self.chercheOu()
- # print ('dans insereNoeudApresClick')
- nodeCourrant = self.node.tree.currentItem()
- if nodeCourrant == None:
- nodeCourrant = self.node.tree.racine
- if self.name != None:
- plier = self.editor.maConfiguration.afficheCommandesPliees
- if nodeCourrant == self.node:
- nouveau = self.node.appendChild(self.name, "first", plier)
- else:
- nouveau = nodeCourrant.appendBrother(self.name, plier=plier)
- else:
- nouveau = 0
- # on n a pas insere le noeud
- if nouveau == 0: return
-
- nouveau.setDeplie()
- # if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
- if self.editor.afficheApresInsert == True:
- # if self.editor.affichePlie==True: nouveau.plieToutEtReaffiche()
- if self.editor.maConfiguration.afficheCommandesPliees == True:
- nouveau.plieToutEtReaffiche()
- else:
- nouveau.deplieToutEtReaffiche()
- nouveau.fenetre.donnePremier()
- # nouveau.deplieToutEtReaffiche()
- else:
- self.node.setSelected(False)
- nouveau.setSelected(True)
- self.node.tree.setCurrentItem(nouveau)
- if event != None:
- event.accept()
-
- def creeListeCommande(self, filtre):
- listeGroupes, dictGroupes = self.jdc.getGroups()
- sensibleALaCasse = self.RBCasse.isChecked()
- if "CACHE" in dictGroupes:
- aExclure = list(dictGroupes["CACHE"])
- else:
- aExclure = []
- listeACreer = []
- listeEtapesDejaPresentes = []
- if self.editor.maConfiguration.rendVisiblesLesCaches:
- for e in self.jdc.etapes:
- listeEtapesDejaPresentes.append(e.nom)
- for c in aExclure:
- if c not in listeEtapesDejaPresentes:
- aExclure.remove(c)
- # for e in self.jdc.etapes:
- # print (e.nom)
- # print (e.definition.repetable)
- # if e.definition.repetable == 'n' : aExclure.append(e.nom)
- # print (aExclure)
- for l in self.jdc.getListeCmd():
- if l not in aExclure:
- if sensibleALaCasse and (filtre != None and not filtre in l):
- continue
- if (
- (not sensibleALaCasse)
- and filtre != None
- and (not filtre in l)
- and (not filtre.upper() in l)
- ):
- continue
- listeACreer.append(l)
- return listeACreer
-
- def ajouteRadioButtons(self):
- if self.editor.maConfiguration.nombreDeBoutonParLigne != 0:
- self.ajoutePushButtons()
- return
- # print 'ds ajouteRadioButtons'
- filtre = str(self.LEFiltre.text())
- if filtre == str(""):
- filtre = None
- if hasattr(self, "buttonGroup"):
- for b in self.buttonGroup.buttons():
- self.buttonGroup.removeButton(b)
- b.setParent(None)
- b.close()
- else:
- self.buttonGroup = QButtonGroup()
- for w in self.listeWidget:
- w.setParent(None)
- w.close()
- self.listeWidget = []
- if self.boolAlpha == 1:
- liste = self.creeListeCommande(filtre)
- for cmd in liste:
- self.dicoCmd[tr(cmd)] = cmd
- rbcmd = QRadioButton(tr(cmd))
- self.buttonGroup.addButton(rbcmd)
- self.commandesLayout.addWidget(rbcmd)
- # if self.simpleClic : rbcmd.mouseReleaseEvent=self.insereNoeudApresClick
- # else : rbcmd.mouseDoubleClickEvent=self.insereNoeudApresClick
- # self.buttonGroup.buttonClicked.connect(self.rbClique)
- if not (self.simpleClic):
- rbcmd.mouseDoubleClickEvent = self.insereNoeudApresClick
- if self.simpleClic:
- self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
- else:
- self.buttonGroup.buttonClicked.connect(self.rbClique)
- elif self.boolGroupe == 1:
- listeGroupes, dictGroupes = self.jdc.getGroups()
- for grp in listeGroupes:
- if grp == "CACHE":
- continue
- label = QLabel(self)
- text = tr(
- '<html><head/><body><p><span style=" font-weight:600;">Groupe : '
- + tr(grp)
- + "</span></p></body></html>"
- )
- label.setText(text)
- self.listeWidget.append(label)
- aAjouter = 1
- sensibleALaCasse = self.RBCasse.isChecked()
- for cmd in dictGroupes[grp]:
- if sensibleALaCasse and (filtre != None and not filtre in cmd):
- continue
- if (
- (not sensibleALaCasse)
- and filtre != None
- and (not filtre in cmd)
- and (not filtre.upper() in cmd)
- ):
- continue
- if aAjouter == 1:
- self.commandesLayout.addWidget(label)
- aAjouter = 0
- self.dicoCmd[tr(cmd)] = cmd
- rbcmd = QRadioButton(tr(cmd))
- self.buttonGroup.addButton(rbcmd)
- self.commandesLayout.addWidget(rbcmd)
- if not (self.simpleClic):
- rbcmd.mouseDoubleClickEvent = self.insereNoeudApresClick
- if self.simpleClic:
- self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
- else:
- self.buttonGroup.buttonClicked.connect(self.rbClique)
- label2 = QLabel(self)
- label2.setText(" ")
- self.listeWidget.append(label2)
- self.commandesLayout.addWidget(label2)
- elif self.boolOrdre == 1:
- listeFiltre = self.creeListeCommande(filtre)
- liste = []
- if self.editor.readercata.ordreDesCommandes == None:
- ordreDesCommandes = listeFiltre
- else:
- ordreDesCommandes = self.editor.readercata.ordreDesCommandes
- for cmd in ordreDesCommandes:
- if cmd in listeFiltre:
- liste.append(cmd)
- for cmd in liste:
- self.dicoCmd[tr(cmd)] = cmd
- rbcmd = QRadioButton(tr(cmd))
- self.buttonGroup.addButton(rbcmd)
- self.commandesLayout.addWidget(rbcmd)
- if not (self.simpleClic):
- rbcmd.mouseDoubleClickEvent = self.insereNoeudApresClick
- if self.simpleClic:
- self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
- else:
- self.buttonGroup.buttonClicked.connect(self.rbClique)
-
- def ajoutePushButtons(self):
- if hasattr(self, "buttonGroup"):
- for b in self.buttonGroup.buttons():
- self.buttonGroup.removeButton(b)
- b.setParent(None)
- b.close()
- else:
- self.buttonGroup = QButtonGroup()
- self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
- for w in self.listeWidget:
- w.setParent(None)
- w.close()
- self.listeWidget = []
-
- if not hasattr(self, "maGrilleBouton"):
- # self.commandesLayout.close()
- self.maGrilleBouton = QGridLayout()
- self.maGrilleBouton.setSpacing(20)
- self.verticalLayout.addLayout(self.maGrilleBouton)
- col = -1
- ligne = 0
-
- if self.boolAlpha == 1:
- liste = self.creeListeCommande(None)
- elif self.boolOrdre:
- liste = self.creeListeCommande(None)
- listeFiltre = self.creeListeCommande(None)
- liste = []
- if self.editor.readercata.ordreDesCommandes == None:
- ordreDesCommandes = listeFiltre
- else:
- ordreDesCommandes = self.editor.readercata.ordreDesCommandes
- for cmd in ordreDesCommandes:
- if cmd in listeFiltre:
- liste.append(cmd)
- elif self.boolGroupe:
- # On considere que cela n a pas de sens de filtrer sur les groupes ou ?
- return
- for cmd in liste:
- col = col + 1
- if col == self.editor.maConfiguration.nombreDeBoutonParLigne:
- col = 0
- ligne = ligne + 1
- self.dicoCmd[tr(cmd)] = cmd
- rbcmd = QPushButton(tr(cmd))
- rbcmd.setGeometry(QRect(40, 20, 211, 71))
- rbcmd.setMaximumSize(QSize(250, 81))
- rbcmd.setStyleSheet(
- "background-color : rgb(66, 165, 238);\n"
- "/*border-style : outset;*/\n"
- "border-radius : 20px;\n"
- "border-width : 30 px;\n"
- "border-color : beige;\n"
- "text-align : center"
- )
- # print ('self.editor.maConfiguration.dicoImages', self.editor.maConfiguration.dicoImages)
- if cmd in self.editor.maConfiguration.dicoImages:
- fichier = self.editor.maConfiguration.dicoImages[cmd]
- icon = QIcon()
- icon.addPixmap(QPixmap(fichier), QIcon.Normal, QIcon.Off)
- rbcmd.setIcon(icon)
- rbcmd.setIconSize(QSize(48, 48))
-
- self.buttonGroup.addButton(rbcmd)
- self.maGrilleBouton.addWidget(rbcmd, ligne, col)
-
- def clearFiltre(self):
- self.LEFiltre.setText("")
- self.ajouteRadioButtons()
-
- def rbCliqueEtInsere(self, id):
- self.rbClique(id)
- self.insereNoeudApresClick(None)
-
- def rbClique(self, id):
- try:
- self.name = self.dicoCmd[id.text()]
- except:
- try:
- self.name = self.dicoCmd[str(id.text())]
- except:
- print("pb d accent : contacter la maintenance")
-
- definitionEtape = getattr(self.jdc.cata, self.name)
- # commentaire=getattr(definitionEtape,self.jdc.lang)
- try:
- commentaire = getattr(definitionEtape, self.jdc.lang)
- except:
- try:
- commentaire = getattr(definitionEtape, "ang")
- except:
- commentaire = ""
- self.editor.afficheCommentaire(commentaire)
-
- def setValide(self):
- # PNPN a priori pas d icone mais peut-etre a faire
- pass
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-
-import os, sys, re
-from desChoixLangue import Ui_ChoixLangue
-
-from PyQt5.QtWidgets import QDialog, QRadioButton, QGroupBox, QButtonGroup
-from PyQt5.QtGui import QPalette
-from PyQt5.QtCore import QProcess, QFileInfo, Qt, QSize
-
-
-# Import des panels
-
-
-class MonChoixLangue(Ui_ChoixLangue, QDialog):
- """
- Classe definissant le panel associe aux mots-cles qui demandent
- a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
- discretes
- """
-
- def __init__(self, appliEficas=None):
- QDialog.__init__(self, appliEficas)
- self.setModal(True)
- self.setupUi(self)
- self.appliEficas = appliEficas
- self.installLangue()
- self.code = None
- self.pB_OK.clicked.connect(self.choisitLangue)
-
- def installLangue(self):
- if self.appliEficas.langue == "fr":
- self.rbFrancais.setChecked(True)
- else:
- self.rbEnglish.setChecked(True)
-
- def choisitLangue(self):
- if self.rbFrancais.isChecked():
- self.appliEficas.langue = "fr"
- else:
- self.appliEficas.langue = "ang"
- self.close()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-from PyQt5.QtCore import Qt
-
-
-# Modules Eficas
-from .qtSaisie import SaisieValeur
-from monPlusieursBasePanel import MonPlusieursBasePanel
-
-from Extensions.i18n import tr
-
-# Import des panels
-
-
-class MonFonctionPanel(MonPlusieursBasePanel):
- # Classe definissant le panel associee aux mots-cles qui demandent
- # a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
- # discretes
- def __init__(self, node, parent=None, name=None, fl=0):
- # print "MonFonctionPanel"
- self.node = node
- self.setNbValeurs()
- MonPlusieursBasePanel.__init__(self, node, parent, name, fl)
-
- def setNbValeurs(self):
- self.nbValeurs = 1
- if self.node.item.waitTuple() == 1:
- for a in self.node.item.definition.type:
- try:
- self.nbValeurs = a.ntuple
- break
- except:
- pass
- genea = self.node.item.getGenealogie()
- self.nbValeursASaisir = self.nbValeurs
- if "VALE" in genea:
- self.nbValeurs = 2
- if "VALE_C" in genea:
- self.nbValeurs = 3
-
- def decoupeListeValeurs(self, liste):
- # decoupe la liste des valeurs en n ( les x puis les y)
- l_valeurs = []
- if len(liste) % self.nbValeursASaisir != 0 and (len(liste) % self.nbValeurs):
- message = tr(
- "La cardinalite n'est pas correcte, la derniere valeur est ignoree"
- )
- self.editor.afficheInfos(message, Qt.red)
- i = 0
- while i < len(liste):
- try:
- t = tuple(liste[i : i + self.nbValeurs])
- i = i + self.nbValeurs
- except:
- t = tuple(liste[i : len(liste)])
- l_valeurs.append(t)
- return l_valeurs
-
- def buildLBValeurs(self, listeValeurs=None):
- self.LBValeurs.clear()
- if listeValeurs == None:
- listeValeurs = self.node.item.getListeValeurs()
- if self.node.item.waitTuple() == 1:
- listeATraiter = listeValeurs
- for valeur in listeATraiter:
- str_valeur = str(valeur)
- self.LBValeurs.addItem(str_valeur)
- else:
- for valeur in self.decoupeListeValeurs(listeValeurs):
- if type(valeur) == tuple:
- TupleEnTexte = "("
- for val in valeur:
- TupleEnTexte = (
- TupleEnTexte
- + str(self.politique.getValeurTexte(val))
- + ", "
- )
- TupleEnTexte = TupleEnTexte[0:-2] + ")"
- self.LBValeurs.addItem(TupleEnTexte)
- else:
- self.LBValeurs.addItem(str(valeur))
-
- def ajout1Valeur(self, liste=[]):
- # Pour etre appele a partir du Panel Importer (donc plusieurs fois par AjouterNValeur)
- validite = 1
- if liste == []:
- if self.node.item.waitTuple() == 1:
- liste = SaisieValeur.TraiteLEValeurTuple(self)
- if liste == [""]:
- return
- else:
- liste, validite = SaisieValeur.TraiteLEValeur(self)
- if validite == 0:
- return
- if liste == []:
- return
-
- if self.node.item.waitTuple() == 1 and len(liste) != self.nbValeurs:
- commentaire = str(liste)
- commentaire += tr(" n est pas un tuple de ")
- commentaire += str(self.nbValeursASaisir)
- commentaire += tr(" valeurs")
- self.LEValeur.setText(str(liste))
- self.editor.afficheInfos(commentaire, Qt.red)
- return
-
- if self.node.item.waitTuple() == 1:
- liste2 = tuple(liste)
- liste = liste2
-
- index = self.LBValeurs.currentRow()
- if (self.LBValeurs.isItemSelected(self.LBValeurs.item(index)) == 0) and (
- index > 0
- ):
- index = 0
- else:
- index = self.LBValeurs.currentRow() + 1
- indexListe = index * self.nbValeurs
- if index == 0:
- indexListe = len(self.listeValeursCourantes)
-
- listeVal = []
- for valeur in self.listeValeursCourantes:
- listeVal.append(valeur)
- if self.node.item.waitTuple() == 1:
- indexListe = index
- validite, comm, comm2, listeRetour = self.politique.ajoutTuple(
- liste, index, listeVal
- )
- else:
- validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
- liste, index, listeVal
- )
- self.Commentaire.setText(tr(comm2))
- if not validite:
- self.editor.afficheInfos(comm, Qt.red)
- else:
- self.LEValeur.setText("")
- l1 = self.listeValeursCourantes[:indexListe]
- l3 = self.listeValeursCourantes[indexListe:]
- if self.node.item.waitTuple() == 1:
- listeATraiter = listeRetour
- else:
- listeATraiter = self.decoupeListeValeurs(listeRetour)
- for valeur in listeATraiter:
- if type(valeur) == tuple:
- TupleEnTexte = "("
- for val in valeur:
- TupleEnTexte = (
- TupleEnTexte
- + str(self.politique.getValeurTexte(val))
- + ", "
- )
- str_valeur = TupleEnTexte[0:-2] + ")"
- else:
- str_valeur = str(valeur)
- self.LBValeurs.insertItem(index, str_valeur)
- item = self.LBValeurs.item(index)
- item.setSelected(1)
- self.LBValeurs.setCurrentItem(item)
- index = index + 1
- self.listeValeursCourantes = l1 + listeRetour + l3
- self.buildLBValeurs(self.listeValeursCourantes)
-
- def ajoutNValeur(self, liste):
- if len(liste) % self.nbValeurs != 0:
- texte = "Nombre de valeur incorrecte"
- # self.Commentaire.setText(texte)
- self.editor.afficheInfos(texte, Qt.red)
- return
- listeDecoupee = self.decoupeListeValeurs(liste)
- for vals in listeDecoupee:
- self.ajout1Valeur(vals)
-
- def sup1Valeur(self):
- index = self.LBValeurs.currentRow()
- if index == None:
- return
- removed_item = self.LBValeurs.takeItem(index)
- text = removed_item.text()[1:-1] # Remove the parenthesis
- self.LEValeur.setText(text)
- listeVal = []
- indexInterdit = []
- for i in range(self.nbValeurs):
- indexAOter = index * self.nbValeurs + i
- indexInterdit.append(indexAOter)
- if self.node.item.waitTuple() == 1:
- indexInterdit = [index]
-
- i = 0
- for valeur in self.listeValeursCourantes:
- if not (i in indexInterdit):
- listeVal.append(valeur)
- i = i + 1
- self.listeValeursCourantes = listeVal
- listeValeurs = self.listeValeursCourantes
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-
-from PyQt5.QtWidgets import QCheckBox, QWidget, QLabel, QPushButton
-from PyQt5.QtCore import Qt, QRect
-from PyQt5.QtGui import QPalette
-
-from Extensions.i18n import tr
-from desGroupeOptionnel import Ui_groupeOptionnel
-from desPBOptionnelMT import Ui_customPB
-
-
-# Import des panels
-
-
-class MonRBButtonCustom(QCheckBox):
- def __init__(self, texte, monOptionnel, parent=None, couleur=None):
- QCheckBox.__init__(self, tr(texte), parent)
- self.mousePressed = True
- self.monOptionnel = monOptionnel
- self.setToolTip(tr("clicker: affichage aide, double-click: ajout"))
- if couleur != None:
- mapalette = self.palette()
- mapalette.setColor(QPalette.WindowText, couleur)
- mapalette.setColor(QPalette.Base, Qt.green)
- self.setPalette(mapalette)
- self.setText(tr(texte))
- try:
- monToolTip = monOptionnel.parentMC.dictToolTipMc[texte]
- self.setToolTip(monToolTip)
- except:
- pass
-
- def mouseDoubleClickEvent(self, event):
- # print "dans mouseDoubleClickEvent", self
- if self not in self.monOptionnel.dicoCb:
- event.accept()
- return
- listeCheckedMC = "+" + self.monOptionnel.dicoCb[self]
- self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
- event.accept()
-
- def mousePressEvent(self, event):
- if not (event.button() != Qt.RightButton):
- event.accept()
- return
- if self.monOptionnel.cbPressed != None:
- self.monOptionnel.cbPressed.setChecked(False)
- self.monOptionnel.cbPressed = self
- if self.mousePressed == False:
- self.mousePressed = True
- else:
- self.mousePressed = False
- self.ajoutAideMC()
- QCheckBox.mousePressEvent(self, event)
- event.accept()
-
- def ajoutAideMC(self):
- try:
- maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
- maLangue = self.monOptionnel.parentMC.jdc.lang
- if hasattr(maDefinition, maLangue):
- self.monAide = getattr(
- maDefinition, self.monOptionnel.parentMC.jdc.lang
- )
- else:
- self.monAide = ""
- except:
- self.monAide = ""
- self.monOptionnel.parentMC.editor.afficheCommentaire(self.monAide)
-
-
-class MonPBButtonCustom(QWidget, Ui_customPB):
- def __init__(self, texte, monOptionnel, parent=None, couleur=None):
- QWidget.__init__(self)
- self.setupUi(self)
- if couleur != None:
- self.monPb.setText(texte)
- self.monPb.setStyleSheet(
- "QPushButton {background-color: #A3C1DA; color: red;}"
- )
- # mapalette=self.monPb.palette()
- # mapalette.setColor( QPalette.ButtonText, Qt.red )
- # self.monPb.setPalette( mapalette )
- self.monPb.update()
- # self.update()
- try:
- monToolTip = monOptionnel.parentMC.dictToolTipMc[texte]
- self.monPb.setToolTip(monToolTip)
- except:
- pass
- self.monPb.setText(texte)
- self.monPb.clicked.connect(self.ajoutMC)
-
- self.texte = texte
- self.monOptionnel = monOptionnel
- self.definitAideMC()
- self.setToolTip(self.monAide)
-
- def ajoutMC(self):
- listeCheckedMC = "+" + self.monOptionnel.dicoCb[self]
- self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
-
- def definitAideMC(self):
- try:
- maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
- maLangue = self.monOptionnel.parentMC.jdc.lang
- if hasattr(maDefinition, maLangue):
- self.monAide = getattr(
- maDefinition, self.monOptionnel.parentMC.jdc.lang
- )
- except:
- self.monAide = ""
-
-
-class MonGroupeOptionnel(QWidget, Ui_groupeOptionnel):
- """ """
-
- def __init__(self, liste, liste_rouge, parentQt, parentMC):
- # print ("dans init de monWidgetOptionnel ", parentQt, liste,parentMC)
- QWidget.__init__(self, None)
- self.setupUi(self)
- self.listeChecked = []
- self.dicoCb = {}
- self.mousePressed = False
- self.cbPressed = None
- self.cb = None
- self.parentQt = parentQt
- self.parentMC = parentMC
-
- if liste != []:
- self.affiche(liste, liste_rouge)
- self.afficheTitre()
- elif self.parentQt.parentQt.maConfiguration.afficheOptionnelVide != False:
- self.afficheTitre()
- self.MCOptionnelLayout.insertWidget(0, QLabel(tr("Pas de MC Optionnel")))
- else:
- self.frameLabelMC.close()
- # print "dans fin de monWidgetOptionnel ", parentQt
-
- def afficheTitre(self):
- labeltext, fonte, couleur = self.parentMC.node.item.getLabelText()
- # print (labeltext)
- l = tr(labeltext)
- li = []
- while len(l) > 25:
- li.append(l[0:24])
- l = l[24:]
- li.append(l)
- texte = ""
- for l in li:
- texte += l + "\n"
- texte = texte[0:-1]
- self.MCLabel.setText(texte)
-
- def affiche(self, liste, liste_rouge):
- # print ("dans Optionnel ____ affiche", liste,liste_rouge)
- self.dicoCb = {}
- liste.reverse()
- for mot in liste:
- # if mot in liste_rouge : print ('je dois afficher en rouge' , mot)
- couleur = None
- if mot in liste_rouge:
- couleur = Qt.red
- if self.parentQt.parentQt.maConfiguration.simpleClic == False:
- cb = MonRBButtonCustom(mot, self, couleur=couleur)
- cb.clicked.connect(cb.ajoutAideMC)
- else:
- cb = MonPBButtonCustom(mot, self, couleur=couleur)
-
- self.MCOptionnelLayout.insertWidget(0, cb)
- self.dicoCb[cb] = mot
- self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import os
-
-from PyQt5.QtWidgets import QLabel, QFrame
-from PyQt5.QtCore import QEvent
-from Extensions.i18n import tr
-
-
-class MonLabelClic(QLabel):
- def __init__(self, parent):
- QLabel.__init__(self, parent)
- # Pas propre mais impossible de faire fonctionner isinstance sur Groupe, MonWidgetCommande
- # PNPNPN ? a ameliorer
- if isinstance(parent, QFrame):
- parent = parent.parent()
- while not (hasattr(parent, "traiteClicSurLabel")):
- try:
- parent = parent.parent()
- except:
- print("pb avec MonLabelClic")
- break
- self.parent = parent
-
- def event(self, event):
- if event.type() == QEvent.MouseButtonRelease:
- self.texte = self.text()
- self.parent.traiteClicSurLabel(self.texte)
- return QLabel.event(self, event)
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from PyQt5.QtWidgets import QButtonGroup, QToolButton
-from PyQt5.QtGui import QIcon, QPixmap
-from Extensions.i18n import tr
-
-
-# ----------------------
-class MonLayoutBouton:
- # ----------------------
-
- # -------------------------------
- def __init__(self, appliEficas):
- # -------------------------------
-
- self.appliEficas = appliEficas
- self.buttonGroup = QButtonGroup()
-
- for etape in self.appliEficas.readercata.cata.JdC.commandes:
- nomEtape = etape.nom
- toolButton = QToolButton(self.appliEficas.toolBarCommande)
- icon = QIcon()
- if nomEtape in self.appliEficas.maConfiguration.dicoIcones:
- fichier = self.appliEficas.maConfiguration.dicoIcones[nomEtape]
- icon.addPixmap(QPixmap(fichier), QIcon.Normal, QIcon.Off)
- toolButton.setIcon(icon)
- else:
- try:
- label = nomEtape[0:3]
- except:
- label = nomEtape
- toolButton.setText(label)
-
- action = self.appliEficas.toolBarCommande.addWidget(toolButton)
- action.setVisible(True)
- toolButton.setObjectName(nomEtape)
- toolButton.setToolTip(tr(nomEtape))
- self.buttonGroup.addButton(toolButton)
-
- self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
-
- def rbCliqueEtInsere(self, id):
- self.appliEficas.handleAjoutEtape(id.objectName())
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from desRecherche import Ui_desRecherche
-from PyQt5.QtWidgets import QDialog
-from PyQt5.QtCore import Qt
-
-
-# Import des panels
-class DRecherche(Ui_desRecherche, QDialog):
- """ """
-
- def __init__(self, parent=None, name=None, fl=0):
- QDialog.__init__(self, parent)
- self.parentQT = parent
- self.tree = self.parentQT.tree
- self.setupUi(self)
- self.PBSuivant.setDefault(True)
- self.PBSuivant.setAutoDefault(False)
- self.PBSuivant.clicked.connect(self.suivantClicked)
- self.LERecherche.returnPressed.connect(self.recherche)
- self.surLigne = 0
- self.listeTrouvee = ()
- self.nodeSurligne = None
-
- def suivantClicked(self):
- # if self.motAChercher!=self.LERecherche.text(): self.recherche()
- if self.listeTrouvee == {}:
- return
- if self.surLigne > len(self.listeTrouvee) - 1:
- return
- if self.nodeSurligne != None:
- self.nodeSurligne.updateNodeTexteInBlack()
- # self.listeTrouvee[self.surLigne].updateNodeTexteInBlue()
- # self.nodeSurligne=self.listeTrouvee[self.surLigne]
- self.listeTrouvee[self.surLigne].select()
- self.listeTrouvee[self.surLigne].affichePanneau()
- self.surLigne = self.surLigne + 1
- self.PBSuivant.setFocus()
- if self.surLigne == len(self.listeTrouvee):
- self.surLigne = 0
-
- def recherche(self):
- self.motAChercher = self.LERecherche.text()
- self.listeTrouvee = self.tree.findItems(
- self.motAChercher, Qt.MatchContains | Qt.MatchRecursive, 0
- )
- self.surLigne = 0
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from desRechercheCatalogue import Ui_desRechercheCatalogue
-from PyQt5.QtWidgets import QDialog, QCompleter
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-
-# Import des panels
-
-
-class DRechercheCatalogue(Ui_desRechercheCatalogue, QDialog):
- """ """
-
- def __init__(self, parent, editor):
- QDialog.__init__(self, parent)
- # self.setModal(True)
- self.setupUi(self)
- self.editor = editor
- self.CBRecherche.setEditable(True)
- self.CBRecherche.lineEdit().returnPressed.connect(self.rechercheCB)
- self.CBRecherche.currentIndexChanged.connect(self.rechercheCB)
- self.CBRecherche.currentTextChanged.connect(self.rechercheCB)
-
- self.initRecherche()
-
- def initRecherche(self):
- listeChoix = list(self.editor.readercata.dicoInverse.keys())
- self.CBRecherche.addItem("")
- for choix in listeChoix:
- self.CBRecherche.addItem(choix)
- monCompleteur = QCompleter(listeChoix, self)
- monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
- self.CBRecherche.setCompleter(monCompleteur)
-
- def rechercheCB(self):
- motAChercher = self.CBRecherche.lineEdit().text()
- self.recherche(motAChercher)
-
- def recherche(self, motAChercher):
- if str(motAChercher) == "" or str(motAChercher) == None:
- return
- if str(motAChercher) not in self.editor.readercata.dicoInverse:
- return
- try:
- # if 1 :
- genea = self.editor.readercata.dicoInverse[str(motAChercher)]
- listeGenea = []
- for t in genea:
- listeGenea.append(t[0])
- listeGenea.reverse()
- texte = ""
- i = 0
- for mc in listeGenea:
- ligne = i * " " + str(mc) + " / " + tr(str(mc)) + "\n"
- i = i + 1
- texte += ligne
- self.teGenea.setText(texte)
- self.teDoc.setText(getattr(genea[0][1], self.editor.appliEficas.langue))
-
- except:
- pass
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from desSelectVal import Ui_DSelVal
-from Extensions.i18n import tr
-
-from PyQt5.QtWidgets import QDialog, QFileDialog, QMessageBox
-from PyQt5.QtCore import QTimer, Qt
-from PyQt5.QtGui import QPalette
-
-
-class DSelVal(Ui_DSelVal, QDialog):
- def __init__(self, parent, modal):
- QDialog.__init__(self, parent)
- self.setupUi(self)
-
-
-class MonSelectVal(DSelVal):
- """
- Classe definissant le panel associe aux mots-cles qui demandent
- a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
- discretes
- """
-
- def __init__(self, file, parent, name=None, fl=0):
- # print "MonSelectVal"
- self.parent = parent
- DSelVal.__init__(self, parent, 0)
- self.separateur = " "
- self.texte = " "
- self.textTraite = ""
- self.file = str(file)
- self.readVal()
- self.initVal()
- self.connecterSignaux()
-
- def connecterSignaux(self):
- self.Bespace.clicked.connect(self.selectEsp)
- self.BpointVirgule.clicked.connect(self.selectPoint)
- self.Bvirgule.clicked.connect(self.selectVir)
- self.BImportSel.clicked.connect(self.BImportSelPressed)
- self.BImportTout.clicked.connect(self.BImportToutPressed)
- self.parent.editor.sb.messageChanged.connect(self.messageAChanger)
-
- def connecterSignauxQT4(self):
- self.connect(self.Bespace, SIGNAL("clicked()"), self.selectEsp)
- self.connect(self.BpointVirgule, SIGNAL("clicked()"), self.selectPoint)
- self.connect(self.Bvirgule, SIGNAL("clicked()"), self.selectVir)
- self.connect(self.BImportSel, SIGNAL("clicked()"), self.BImportSelPressed)
- self.connect(self.BImportTout, SIGNAL("clicked()"), self.BImportToutPressed)
- self.connect(
- self.parent.editor.sb,
- SIGNAL("messageChanged(QString)"),
- self.messageAChanger,
- )
-
- def messageAChanger(self):
- message = self.parent.editor.sb.currentMessage()
- mapalette = self.sb.palette()
- mapalette.setColor(QPalette.Text, Qt.red)
- self.sb.setPalette(mapalette)
- self.sb.setText(message)
- QTimer.singleShot(3000, self.efface)
-
- def efface(self):
- self.sb.setText("")
-
- def readVal(self):
- if self.file == "":
- return
- try:
- f = open(self.file, "r")
- self.texte = f.read()
- f.close()
- except:
- QMessageBox.warning(
- self, tr("Fichier Indisponible"), tr("Lecture impossible")
- )
- self.texte = ""
- return
-
- def initVal(self):
- self.TBtext.clear()
- self.TBtext.setText(self.texte)
-
- def selectEsp(self):
- self.separateur = " "
-
- def selectVir(self):
- self.separateur = ","
-
- def selectPoint(self):
- self.separateur = ";"
-
- def BImportSelPressed(self):
- texte = self.TBtext.textCursor().selectedText()
- textTraite = texte.replace("\u2029", "\n")
- self.textTraite = str(textTraite)
- self.traitement()
-
- def BImportToutPressed(self):
- self.textTraite = self.texte
- self.traitement()
-
- def traitement(self):
- if self.textTraite == "":
- return
- if self.textTraite[-1] == "\n":
- self.textTraite = self.textTraite[0:-1]
- self.textTraite = self.textTraite.replace("\n", self.separateur)
- liste1 = self.textTraite.split(self.separateur)
- liste = []
- for val in liste1:
- if val != "" and val != " " and val != self.separateur:
- val = str(val)
- try:
- # if 1 :
- val2 = eval(val, {})
- liste.append(val2)
- except:
- pass
- self.parent.ajoutNValeur(liste)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-import traceback
-
-from Extensions.i18n import tr
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QDialog, QListWidgetItem
-from desViewRegles import Ui_viewRegles
-
-
-# ------------------------------------ #
-class ViewRegles(Ui_viewRegles, QDialog):
- # ------------------------------------ #
- """
- Classe permettant la visualisation de texte
- """
-
- def __init__(self, parent, liste, entete=None):
- QDialog.__init__(self, parent)
- self.setupUi(self)
- self.setModal(False)
- self.bclose.clicked.connect(self.close)
-
- if entete != None:
- self.setWindowTitle(entete)
- for ligne in liste:
- texte = ligne[0]
- couleur = ligne[1]
- if couleur == Qt.black:
- self.LBRegles.addItem(texte)
- else:
- monItem = QListWidgetItem(texte)
- monItem.setForeground(Qt.red)
- self.LBRegles.addItem(monItem)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-import traceback
-
-from Extensions.i18n import tr
-
-from PyQt5.QtWidgets import QDialog, QMessageBox, QFileDialog
-from PyQt5.QtCore import QSize
-from desViewTexte import Ui_dView
-
-
-# ------------------------------- #
-class ViewText(Ui_dView, QDialog):
- # ------------------------------- #
- """
- Classe permettant la visualisation de texte
- """
-
- def __init__(
- self, parent, editor=None, entete=None, texte=None, largeur=600, hauteur=600
- ):
- QDialog.__init__(self, parent)
- self.editor = editor
- self.setupUi(self)
-
- self.resize(QSize(largeur, hauteur).expandedTo(self.minimumSizeHint()))
- self.bclose.clicked.connect(self.close)
- self.bsave.clicked.connect(self.saveFile)
-
- if entete != None:
- self.setWindowTitle(entete)
- if entete != None:
- self.setText(texte)
-
- def setText(self, txt):
- self.view.setText(txt)
-
- def saveFile(self):
- # recuperation du nom du fichier
- if self.editor != None:
- dir = self.editor.appliEficas.maConfiguration.savedir
- else:
- dir = "/tmp"
- fn = QFileDialog.getSaveFileName(None, tr("Sauvegarder le fichier"), dir)
- fn = fn[0]
- if fn == "":
- return
- if fn == None:
- return (0, None)
-
- ulfile = os.path.abspath(fn)
- if self.editor != None:
- self.editor.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- try:
- f = open(fn, "w")
- f.write(str(self.view.toPlainText()))
- f.close()
- return 1
- except IOError as why:
- QMessageBox.critical(
- self,
- tr("Sauvegarder le fichier"),
- tr("Le fichier")
- + str(fn)
- + tr("n a pas pu etre sauvegarde : ")
- + str(why),
- )
- return
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-
-from desVisu import Ui_DVisu
-from PyQt5.QtWidgets import QDialog
-
-
-# Import des panels
-class DVisu(Ui_DVisu, QDialog):
- """ """
-
- def __init__(self, parent=None, name=None, fl=0):
- QDialog.__init__(self, parent)
- self.setModal(True)
- self.setupUi(self)
-
- def on_buttonCancel_clicked(self):
- QDialog.reject(self)
-
- def on_buttonOk_clicked(self):
- QDialog.accept(self)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from .monWidgetRadioButton import MonWidgetRadioButtonCommun
-from desWidget4a6RadioButton import Ui_Widget4a6RadioButton
-
-
-class MonWidget4a6RadioButton(Ui_Widget4a6RadioButton, MonWidgetRadioButtonCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print "dans le init de MonWidget4a6RadioButton",self
- if type(monSimpDef.into) == types.FunctionType:
- self.maListeDeValeur = monSimpDef.into()
- else:
- self.maListeDeValeur = monSimpDef.into
- MonWidgetRadioButtonCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def setMaxI(self):
- self.maxI = 6
-
-
-class MonWidget4a6RadioButtonSD(Ui_Widget4a6RadioButton, MonWidgetRadioButtonCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print "dans le init de MonWidget4a6RadioButton",self
- self.maListeDeValeur = node.item.getSdAvantDuBonType()
- MonWidgetRadioButtonCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def setMaxI(self):
- self.maxI = 6
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from .monWidgetRadioButton import MonWidgetRadioButtonCommun
-from desWidget4a6RadioButton import Ui_Widget4a6RadioButton
-
-
-class MonWidget4a6RadioButtonSD(Ui_Widget4a6RadioButton, MonWidgetRadioButtonCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print "dans le init de MonWidget4a6RadioButton",self
- self.maListeDeValeur = node.item.getSdAvantDuBonType()
- MonWidgetRadioButtonCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def setMaxI(self):
- self.maxI = 6
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-
-from desWidgetBloc import Ui_WidgetBloc
-from .groupe import Groupe
-from Extensions.i18n import tr
-
-# Import des panels
-class MonWidgetBloc(Ui_WidgetBloc, Groupe):
- """ """
-
- def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
- # print ("bloc : ",node.item.nom)
- Groupe.__init__(self, node, editor, parentQt, definition, obj, niveau, commande)
- # if self.editor.maConfiguration.afficheCommandesPliees ==True: self.node.plieToutEtReaffiche()
- self.parentQt.commandesLayout.insertWidget(-1, self, 1)
-
- def afficheOptionnel(self):
- return
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from InterfaceQT4.feuille import Feuille
-from desWidgetCB import Ui_WidgetCB
-from InterfaceQT4.politiquesValidation import PolitiqueUnique
-from InterfaceQT4.qtSaisie import SaisieValeur
-
-from PyQt5.QtWidgets import QComboBox, QCompleter
-from PyQt5.QtCore import Qt, QEvent
-
-
-class MonWidgetCBCommun(Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.politique = PolitiqueUnique(self.node, self.editor)
- self.determineChoix()
- self.setValeursApresBouton()
- self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
- self.CBChoix.wheelEvent = self.wheelEvent
- if hasattr(self.parentQt, "commandesLayout"):
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.maCommande.listeAffichageWidget.append(self.CBChoix)
- self.AAfficher = self.CBChoix
-
- def setValeursApresBouton(self):
- # print (self.objSimp.getValeur())
- if (
- self.node.item.definition.homo == "constant"
- and self.objSimp.getValeur() == None
- ):
- self.CBChoix.addItem(tr("Choisir dans la partie probabiliste"))
- self.CBChoix.setCurrentIndex(
- self.CBChoix.findText(tr("Choisir dans la partie probabiliste"))
- )
- self.CBChoix.setEnabled(0)
- return
- if self.objSimp.getValeur() == None:
- self.CBChoix.setCurrentIndex(-1)
- self.CBChoix.lineEdit().setText(tr("Select"))
- return
- valeur = self.objSimp.getValeur()
- if not (type(valeur) == str):
- valeur = str(valeur)
- self.CBChoix.setCurrentIndex(self.CBChoix.findText(valeur))
-
- def determineChoix(self):
- listeChoix = []
- if self.maListeDeValeur == None:
- self.maListeDeValeur = []
- for choix in self.maListeDeValeur:
- if not (type(choix) == str):
- choix = str(choix)
- listeChoix.append(choix)
- self.CBChoix.addItem(choix)
- if self.node.item.definition.homo == "constant":
- self.CBChoix.setEnabled(0)
- if self.objSimp.getValeur() != None:
- self.CBChoix.setStyleSheet(
- (
- "\n"
- "QComboBox {\n"
- " border: 1px solid gray;\n"
- " background: rgb(0,255,0);\n"
- " color: rgb(24,24,7);\n"
- " }\n"
- "QComboBox::drop-down {\n"
- " image: none; \n"
- " }"
- )
- )
- else:
- self.CBChoix.setEditable(True)
- monCompleteur = QCompleter(listeChoix, self)
- monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
- self.CBChoix.setCompleter(monCompleteur)
-
- def choixSaisi(self):
- self.CBChoix.lineEdit().setStyleSheet(
- (
- "\n"
- "QLineEdit {\n"
- " font : italic ;\n"
- " background: rgb(235,235,235);\n"
- " }"
- )
- )
- valeur = str(self.CBChoix.currentText())
- SaisieValeur.LEvaleurPressed(self, valeur)
- self.reaffiche()
-
- def wheelEvent(self, event):
- # Sinon poum sur les fenetres trop longues
- # lorsque la widget attrape le wheelevent
- event.ignore()
-
-
-class MonWidgetCB(Ui_WidgetCB, MonWidgetCBCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.maListeDeValeur = monSimpDef.into
- MonWidgetCBCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetCBSD(Ui_WidgetCB, MonWidgetCBCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.maListeDeValeur = node.item.getSdAvantDuBonType()
- MonWidgetCBCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-from desWidgetCBIntoSug import Ui_WidgetCBIntoSug
-
-from PyQt5.QtWidgets import QComboBox, QCompleter
-from PyQt5.QtCore import Qt
-
-from monWidgetCB import MonWidgetCBCommun
-from monWidgetIntoSug import GereAjoutDsPossible
-
-
-class MonWidgetCBIntoSug(MonWidgetCBCommun, Ui_WidgetCBIntoSug, GereAjoutDsPossible):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.maListeDeValeur = monSimpDef.into
- if node.item.hasIntoSug():
- self.maListeDeValeur = node.item.getListePossibleAvecSug([])
- if hasattr(node.item, "suggestion"):
- self.maListeDeValeur += node.item.suggestion
- MonWidgetCBCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
-
- def ajouteValeurPossible(self, valeur):
- self.CBChoix.addItem(valeur)
- # on ne sait pas si on a deja ajouté une valeur
- try:
- self.node.item.suggestion.append(valeur)
- except:
- self.node.item.suggestion = (valeur,)
- self.lineEditVal.setText("")
- self.CBChoix.setCurrentIndex(self.CBChoix.findText(valeur))
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetCB import Ui_WidgetCB
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-
-
-from PyQt5.QtWidgets import QComboBox, QCompleter
-
-
-class MonWidgetCB(Ui_WidgetCB, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.politique = PolitiqueUnique(self.node, self.editor)
- self.determineChoix()
- self.setValeursApresBouton()
- self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
-
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.maCommande.listeAffichageWidget.append(self.CBChoix)
- # print self.objSimp.isOblig()
-
- def setValeursApresBouton(self):
- if self.objSimp.getValeur() == None:
- self.CBChoix.setCurrentIndex(-1)
- return
- valeur = self.objSimp.getValeur()
- if not (type(valeur) == str):
- valeur = str(valeur)
- self.CBChoix.setCurrentIndex(self.CBChoix.findText(valeur))
-
- def determineChoix(self):
- self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
-
- for choix in self.monSimpDef.into:
- if not (type(choix) == str):
- choix = str(choix)
- self.CBChoix.currentIndexChanged.connect(self.choixSaisi)
- self.CBChoix.addItem(choix)
- self.CBChoix.setEditable(True)
- monCompleteur = QCompleter(listeChoix, self)
- monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
- self.CBChoix.setCompleter(monCompleteur)
-
- def choixSaisi(self):
- valeur = str(self.CBChoix.currentText())
- SaisieValeur.LEvaleurPressed(self, valeur)
- self.reaffiche()
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-import types
-
-from desWidgetCommande import Ui_WidgetCommande
-from .groupe import Groupe
-from .gereIcones import FacultatifOuOptionnel
-
-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
-
-
-from Extensions.i18n import tr
-import Accas
-import os
-
-
-# Import des panels
-
-
-class MonWidgetCommande(Ui_WidgetCommande, Groupe):
- """ """
-
- def __init__(self, node, editor, etape):
- self.listeAffichageWidget = []
- self.inhibe = 0
- self.ensure = 0
- editor.inhibeSplitter = 1
- Groupe.__init__(self, node, editor, None, etape.definition, etape, 1, self)
- spacerItem = QSpacerItem(21, 500, QSizePolicy.Expanding, QSizePolicy.Expanding)
- self.verticalLayoutCommande.addItem(spacerItem)
- editor.inhibeSplitter = 0
-
- # Gestion du nom de L OPER si il est nomme
- if not (hasattr(etape.definition, "sd_prod")) or (
- etape.definition.sd_prod == None
- ):
- self.LENom.close()
- elif (
- hasattr(etape.definition, "sd_prod")
- and type(etape.definition.sd_prod) == types.FunctionType
- ):
- self.LENom.close()
- elif (
- (hasattr(etape, "sdnom"))
- and etape.sdnom != "sansnom"
- and etape.sdnom != None
- ):
- self.LENom.setText(etape.sdnom)
- else:
- self.LENom.setText("")
- if hasattr(self, "LENom"):
- self.LENom.returnPressed.connect(self.nomChange)
- self.racine = self.node.tree.racine
- if self.node.item.getIconName() == "ast-red-square":
- self.LENom.setDisabled(True)
-
- # Gestion de la doc de l objet
- if node.item.getFr() != "":
- self.labelDoc.setText(node.item.getFr())
- nouvelleSize = self.frameAffichage.height() + 60
- self.frameAffichage.setMinimumHeight(nouvelleSize)
- self.frameAffichage.resize(self.frameAffichage.width(), nouvelleSize)
- else:
- self.labelDoc.close()
-
- # Gestion du nom de l etape
- maPolice = QFont(
- "Times",
- 10,
- )
- self.setFont(maPolice)
- self.labelNomCommande.setText(tr(self.obj.nom))
-
- # Gestion du Frame d affichage des autres commandes
- if self.editor.maConfiguration.closeAutreCommande == True:
- self.closeAutreCommande()
- else:
- self.bCatalogue.clicked.connect(self.afficheCatalogue)
- self.bAvant.clicked.connect(self.afficheAvant)
- self.bApres.clicked.connect(self.afficheApres)
-
- if self.editor.maConfiguration.closeFrameRechercheCommande == True:
- self.frameAffichage.close()
- self.closeAutreCommande()
-
- self.setAcceptDrops(True)
- self.etablitOrdre()
-
- if self.editor.maConfiguration.enleverPoubellePourCommande:
- self.RBPoubelle.close() # JDC Fige
-
- if self.editor.maConfiguration.pasDeMCOptionnels:
- return # Pas de MC Optionnels pour Carmel
-
- from .monWidgetOptionnel import MonWidgetOptionnel
-
- if self.editor.widgetOptionnel != None:
- self.monOptionnel = self.editor.widgetOptionnel
- else:
- self.editor.inhibeSplitter = 1
- self.monOptionnel = MonWidgetOptionnel(self.editor)
- self.editor.widgetOptionnel = self.monOptionnel
- self.editor.splitter.addWidget(self.monOptionnel)
- self.editor.ajoutOptionnel()
- self.editor.inhibeSplitter = 0
- self.monOptionnel = self.editor.widgetOptionnel
- self.afficheOptionnel()
-
- # print "fin init de widget Commande"
-
- def closeAutreCommande(self):
- self.bCatalogue.close()
- self.bAvant.close()
- self.bApres.close()
-
- def donnePremier(self):
- # print "dans donnePremier"
- QApplication.processEvents()
- if self.listeAffichageWidget != []:
- self.listeAffichageWidget[0].setFocus(7)
- QApplication.processEvents()
- # print self.focusWidget()
-
- def focusNextPrevChild(self, next):
- # on s assure que ce n est pas un chgt de fenetre
- # print "je passe dans focusNextPrevChild"
- if self.editor.fenetreCentraleAffichee != self:
- return True
- f = self.focusWidget()
- if f not in self.listeAffichageWidget:
- i = 0
- while not hasattr(f, "AAfficher"):
- if f == None:
- i = -1
- break
- f = f.parentWidget()
- if hasattr(f, "AAfficher"):
- f = f.AAfficher
- if i != -1:
- i = self.listeAffichageWidget.index(f)
- else:
- i = self.listeAffichageWidget.index(f)
- if (i == len(self.listeAffichageWidget) - 1) and next and not self.inhibe:
- try:
- self.listeAffichageWidget[1].setFocus(7)
- w = self.focusWidget()
- self.inhibe = 1
- w.focusPreviousChild()
- self.inhibe = 0
- return True
- except:
- pass
- # print self.listeAffichageWidget
- # print "souci ds focusNextPrevChild"
- if i == 0 and next == False and not self.inhibe:
- if hasattr(self.editor.fenetreCentraleAffichee, "scrollArea"):
- self.editor.fenetreCentraleAffichee.scrollArea.ensureWidgetVisible(
- self.listeAffichageWidget[-1]
- )
- self.listeAffichageWidget[-2].setFocus(7)
- self.inhibe = 1
- w = self.focusWidget()
- w.focusNextChild()
- self.inhibe = 0
- return True
- if i == 0 and next == True and not self.inhibe:
- self.listeAffichageWidget[0].setFocus(7)
- self.inhibe = 1
- w = self.focusWidget()
- w.focusNextChild()
- self.inhibe = 0
- return True
- if i > 0 and next == False and not self.inhibe:
- if isinstance(self.listeAffichageWidget[i - 1], QRadioButton):
- self.listeAffichageWidget[i - 1].setFocus(7)
- return True
- return QWidget.focusNextPrevChild(self, next)
-
- def etablitOrdre(self):
- i = 0
- while i + 1 < len(self.listeAffichageWidget):
- self.setTabOrder(
- self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
- )
- i = i + 1
- # si on boucle on perd l'ordre
-
- def afficheSuivant(self, f):
- # print ('ds afficheSuivant')
- try:
- i = self.listeAffichageWidget.index(f)
- next = i + 1
- except:
- next = 1
- if next == len(self.listeAffichageWidget):
- next = 0
- # self.f=next
- # QTimer.singleShot(1, self.rendVisible)
- try:
- self.listeAffichageWidget[next].setFocus(7)
- except:
- pass
-
- def nomChange(self):
- nom = str(self.LENom.text())
- nom = nom.strip()
- if nom == "":
- return # si pas de nom, on ressort sans rien faire
- test, mess = self.node.item.nommeSd(nom)
- self.editor.afficheCommentaire(mess)
-
- # Notation scientifique
- if test:
- from .politiquesValidation import Validation
-
- validation = Validation(self.node, self.editor)
- validation.ajoutDsDictReelEtape()
-
- def afficheOptionnel(self):
- # N a pas de parentQt. doit donc etre redefini
- if self.editor.maConfiguration.closeOptionnel:
- self.editor.fermeOptionnel()
- liste, liste_rouge = self.ajouteMCOptionnelDesBlocs()
- # print "dans afficheOptionnel", self.monOptionnel
- # dans le cas ou l insertion n a pas eu leiu (souci d ordre par exemple)
- # if self.monOptionnel == None : return
- self.monOptionnel.parentCommande = self
- self.monOptionnel.titre(self.obj.nom)
- self.monGroupe = self.monOptionnel.afficheOptionnel(liste, liste_rouge, self)
-
- def focusInEvent(self, event):
- # print "je mets a jour dans focusInEvent de monWidget Commande "
- self.afficheOptionnel()
-
- def reaffiche(self, nodeAVoir=None):
- # Attention delicat. les appels de fonctions ne semblent pas pouvoir etre supprimes!
- self.avantH = (
- self.editor.fenetreCentraleAffichee.scrollAreaCommandes.horizontalScrollBar().sliderPosition()
- )
- self.avantV = (
- self.editor.fenetreCentraleAffichee.scrollAreaCommandes.verticalScrollBar().sliderPosition()
- )
- self.inhibeExpand = True
- # Attention : lorsqu'on reconstruit l arbre au milieu par une fonction siValide (exemple dans UQ)
- # alors self.node.item.node est different de self.node
- # il faut regarder si la Widget utililse self.node a d autres endroits
- self.node.item.node.affichePanneau()
- # QTimer.singleShot(1, self.recentre)
- if nodeAVoir != None and nodeAVoir != 0:
- self.f = nodeAVoir.fenetre
- if self.f == None:
- newNode = nodeAVoir.treeParent.chercheNoeudCorrespondant(
- nodeAVoir.item.object
- )
- self.f = newNode.fenetre
- if self.f != None and self.f.isVisible():
- self.inhibeExpand = False
- return
- if self.f != None:
- self.rendVisible()
- else:
- self.recentre()
- else:
- self.recentre()
- self.inhibeExpand = False
-
- def recentre(self):
- QApplication.processEvents()
- s = self.editor.fenetreCentraleAffichee.scrollAreaCommandes
- s.horizontalScrollBar().setSliderPosition(self.avantH)
- s.verticalScrollBar().setSliderPosition(self.avantV)
-
- def rendVisible(self):
- QApplication.processEvents()
- self.f.setFocus(7)
- self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(
- self.f
- )
-
- def afficheCatalogue(self):
- if self.editor.widgetOptionnel != None:
- self.monOptionnel.hide()
- self.racine.affichePanneau()
- if self.node:
- self.node.select()
- else:
- self.racine.select()
-
- def afficheApres(self):
- self.node.selectApres()
-
- def afficheAvant(self):
- self.node.selectAvant()
-
- def setValide(self):
- if not (hasattr(self, "RBValide")):
- return
- icon = QIcon()
- if self.node.item.object.isValid():
- icon = QIcon(self.repIcon + "/ast-green-ball.png")
- else:
- icon = QIcon(self.repIcon + "/ast-red-ball.png")
- nomIcone = self.node.item.getIconName()
- if nomIcone == "ast-yellow-square":
- icon = QIcon(self.repIcon + "/ast-yel-ball.png")
- if nomIcone == "ast-red-square":
- self.LENom.setDisabled(True)
-
- self.LENom.setDisabled(False)
- self.RBValide.setIcon(icon)
-
- def propageChange(self, typeChange, donneLeFocus):
- aReecrire = self.propageChangeEnfant(self.node.item.object, typeChange)
- if aReecrire:
- self.node.affichePanneau()
- if hasattr(donneLeFocus.node.fenetre, "selectionneDernier"):
- QApplication.processEvents()
- self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(
- donneLeFocus.node.fenetre
- )
- donneLeFocus.node.fenetre.selectionneDernier()
-
- def propageChangeEnfant(self, mc, typeChange):
- for enfant in mc.mcListe:
- if enfant.nature == "MCSIMP":
- if enfant.waitUserAssd():
- if enfant.definition.type[0] == typeChange:
- return True
- else:
- if enfant.nature == "MCList":
- enfant = enfant[0]
- if self.propageChangeEnfant(enfant, typeChange):
- return True
- return False
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-import types, os
-import traceback
-
-from PyQt5.QtGui import QIcon
-from InterfaceQT4.monWidgetCommande import MonWidgetCommande
-from PyQt5.QtWidgets import QSpacerItem, QSizePolicy
-
-
-class MonWidgetCommandeDeplie1Niveau(MonWidgetCommande):
- # Attention au MCLIST qui ne sont pas des MCFACT
- # il faut donc surcharger un certain nb de fonction ici pour eux
-
- def __init__(self, node, editor, etape):
- # print ("debut de ---------------------- init de MonWidgetCommandeDeplie1Niveau ",node.item.nom)
- MonWidgetCommande.__init__(self, node, editor, etape)
- self.node.plieToutEtReaffiche = self.plieToutEtReaffiche
- spacerItem = QSpacerItem(21, 600, QSizePolicy.Expanding, QSizePolicy.Expanding)
- self.verticalLayoutCommande.addItem(spacerItem)
-
- def afficheMots(self):
- # Attention
- # Attention --> cette methode surcharge les methodes des Nodes Fils
- # Attention
- # print ("debut de ---------------------- ds afficheMots de MonWidgetCommandeDeplie1Niveau ",self.node.item.nom)
- # traceback.print_stack()
- repIcon = self.editor.appliEficas.repIcon
- fichier = os.path.join(repIcon, "deleteRondVide.png")
- icon = QIcon(fichier)
- for node in self.node.children:
- node.plie = True
- node.setPlieChildren()
- if node.appartientAUnNoeudPlie == True:
- continue
-
- node.plieToutEtReaffiche = self.plieToutEtReaffiche
- node.deplieToutEtReaffiche = self.deplieToutEtReaffiche
- node.affichePanneau = self.affichePanneau
- node.getPanel = self.getPanel
-
- widget = node.getPanelGroupe(self, self.maCommande)
- self.listeFocus.append(node.fenetre)
-
- try:
- node.fenetre.RBDeplie.setCheckable(False)
- node.fenetre.RBDeplie.setEnabled(False)
- node.fenetre.RBDeplie.setIcon(icon)
- except:
- pass
-
- if node.item.object.isMCList():
- node.setDeplie = self.setDepliePourMCList
-
- for c in node.children:
- c.setDeplie = self.setDepliePourNode
- c.plieToutEtReaffiche = self.plieToutEtReaffiche
- c.deplieToutEtReaffiche = self.deplieToutEtReaffiche
- c.getPanel = self.getPanel
- c.affichePanneau = self.affichePanneau
- try:
- c.fenetre.RBDeplie.setCheckable(False)
- c.fenetre.RBDeplie.setEnabled(False)
- c.fenetre.RBDeplie.setIcon(icon)
- except:
- pass
- else:
- node.setDeplie = self.setDepliePourNode
-
- # print ("fin ------------------------ afficheMots de MonWidgetCommandeDeplie1Niveau ",self.node.item.nom)
-
- def afficheSuivant(self, aAfficher):
- fenetre = self.node.tree.itemCourant.fenetre
- fenetre.afficheSuivant(aAfficher)
-
- def setDepliePourNode(self):
- noeudCourant = self.node.tree.itemCourant
- noeudCourant.setDeplieChildren()
- if self.editor.fenetreCentraleAffichee == noeudCourant.fenetre:
- return
- noeudCourant.afficheCeNiveau()
- pass
-
- # -------------------------------------------- Methodes qui surchargent les noeuds fils
-
- def setDepliePourMCList(self):
- # print ('je surcharge setDeplie pour MCList')
- pass
-
- def setPlieChildren(self):
- # print ('je surcharge setPlieChildren')
- pass
-
- def setDeplieChildren(self):
- # print ('je surcharge setDeplieChildren')
- pass
-
- def plieToutEtReaffiche(self):
- # print ('je surcharge plieToutEtReaffiche', self.node.item.nom)
- pass
-
- def deplieToutEtReaffiche(self):
- # print ('je surcharge deplieToutEtReaffiche', self.node.tree.itemCourant.item.getLabelText())
- pass
-
- def plieToutEtReafficheSaufItem(self):
- # print ('je surcharge plieToutEtReaffiche', self.node.tree.itemCourant.item.getLabelText())
- pass
-
- def affichePanneau(self):
- # print ('je surcharge affichePanneau', self.node.tree.itemCourant.item.getLabelText())
- node = self.node.tree.itemCourant
- while (
- not (hasattr(node, "fenetreIhm"))
- or node.treeParent.fenetreIhm != "deplie1Niveau"
- ):
- node = node.treeParent
- self.node.tree.setCurrentItem(node)
-
- item = node.item
- if (
- item.getLabelText()[0]
- == self.editor.fenetreCentraleAffichee.labelNomCommande.text()
- ):
- return
- node.setDeplieChildren()
- node.afficheCeNiveau()
- self.editor.fenetreCentraleAffichee.labelNomCommande.setText(
- item.getLabelText()[0]
- )
- self.editor.fenetreCentraleAffichee.labelDoc.setText(item.getFr())
-
- def getPanel(self):
- # print ('surcharge ds getPanel')
- pass
+++ /dev/null
-# Copyright (C) 2007-2024 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
-# Modules Eficas
-
-from PyQt5.QtWidgets import QWidget
-from PyQt5.QtCore import Qt
-
-from desWidgetCommentaire import Ui_WidgetCommentaire
-from .gereIcones import FacultatifOuOptionnel
-from Extensions.i18n import tr
-import Accas
-import os
-
-
-# Import des panels
-
-
-class MonWidgetCommentaire(QWidget, Ui_WidgetCommentaire, FacultatifOuOptionnel):
- """ """
-
- def __init__(self, node, editor, commentaire):
- QWidget.__init__(self, None)
- self.node = node
- self.node.fenetre = self
- self.setupUi(self)
- self.editor = editor
- self.appliEficas = self.editor.appliEficas
- self.repIcon = self.appliEficas.repIcon
- self.setIconePoubelle()
- self.remplitTexte()
- self.monOptionnel = None
-
- self.commentaireTE.textChanged.connect(self.TexteCommentaireEntre)
- if self.editor.code in ["MAP", "CARMELCND"]:
- self.bCatalogue.close()
- else:
- self.bCatalogue.clicked.connect(self.afficheCatalogue)
- if self.editor.code in ["Adao", "MAP", "ADAO"]:
- self.bAvant.close()
- self.bApres.close()
- else:
- self.bAvant.clicked.connect(self.afficheAvant)
- self.bApres.clicked.connect(self.afficheApres)
- self.editor.fermeOptionnel()
-
- def afficheApres(self):
- self.node.selectApres()
-
- def afficheAvant(self):
- self.node.selectAvant()
-
- def afficheCatalogue(self):
- self.node.tree.racine.affichePanneau()
- if self.node:
- self.node.select()
- else:
- self.node.tree.racine.select()
-
- def remplitTexte(self):
- texte = self.node.item.getValeur()
- self.commentaireTE.setText(texte)
- if self.editor.code == "CARMELCND" and texte[0:16] == "Cree - fichier :":
- self.commentaireTE.setReadOnly(True)
- self.commentaireTE.setStyleSheet(
- "background:rgb(244,244,244);\n" "border:0px;\n"
- )
- self.commentaireTE.setToolTip(tr("Valeur non modifiable"))
- else:
- self.commentaireTE.setReadOnly(False)
-
- def donnePremier(self):
- self.commentaireTE.setFocus(7)
-
- def TexteCommentaireEntre(self):
- texte = str(self.commentaireTE.toPlainText())
- self.editor.initModif()
- self.node.item.setValeur(texte)
- self.node.updateNodeTexte()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os, re
-pattern_name = re.compile(r"^[^\d\W]\w*\Z")
-
-# Modules Eficas
-
-from PyQt5.QtWidgets import QDialog, QMessageBox
-from PyQt5.QtCore import Qt
-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
- self.editor.afficheInfos("")
- QDialog.__init__(self, editor)
- self.setupUi(self)
- self.connecterSignaux()
- self.dejaExistant = 0
- self.listeTousParam = self.editor.jdc.params
- self.dictListe = {}
- self.initToutesVal()
-
- def connecterSignauxQT4(self):
- self.connect(
- self.lineEditVal, SIGNAL("returnPressed()"), self.lineEditValReturnPressed
- )
- self.connect(
- self.lineEditNom, SIGNAL("returnPressed()"), self.lineEditNomReturnPressed
- )
-
- def connecterSignaux(self):
- self.lineEditVal.returnPressed.connect(self.lineEditValReturnPressed)
- self.lineEditNom.returnPressed.connect(self.lineEditNomReturnPressed)
- self.LBParam.itemDoubleClicked.connect(self.paramClicked)
-
- def paramClicked(self, item):
- if self.editor.nodeEnCours == None:
- QMessageBox.warning(
- self, tr("Pas de Mot-Clef"), tr("Attention! selectionnez un mot-clef")
- )
- return
- param = self.dictListe[item.text()]
- self.editor.nodeEnCours.lineEditVal.setText(param)
- self.editor.nodeEnCours.LEvaleurPressed()
-
- 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.setNom(nom)
- # PN self.val permet d entrer du texte
- param.item.setValeur(self.val)
- param.updateNodeTexte()
- param.updateNodeValid()
- self.LBParam.addItem((repr(param.item.object)))
- self.dictListe[repr(param.item.object)] = param.item.object.nom
- self.lineEditVal.setText("")
- self.lineEditNom.setText("")
- self.lineEditNom.setFocus(True)
-
- def lineEditValReturnPressed(self):
- qtVal = self.lineEditVal.text()
- valString = str(self.lineEditVal.text())
- self.val = ""
- contexte = {}
- exec("from math import *", contexte)
- jdc = self.editor.jdc
- if jdc == None:
- self.editor.afficheInfos(
- tr(
- "La Creation de parametre n est possible que dans un jeu de donnees"
- ),
- Qt.red,
- )
- return
-
- for p in jdc.params:
- try:
- tp = p.nom + "=" + str(repr(p.valeur))
- exec(tp, contexte)
- except:
- pass
- monTexte = "monParam=" + valString
- try:
- exec(monTexte, contexte)
- self.val = valString
- except:
- try:
- monTexte = "monParam='" + valString + "'"
- self.val = "'" + valString + "'"
- except:
- self.editor.afficheInfos(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.afficheInfos(commentaire, Qt.red)
- for p in self.editor.jdc.params:
- if p.nom == nom:
- commentaire = nom + tr(" existe deja\n ")
- self.editor.afficheInfos(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((repr(param)))
- self.dictListe[repr(param)] = param.nom
-
- 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()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-from .monWidgetSimpTxt import MonWidgetSimpTxt
-from .monWidgetPlusieursBase import MonWidgetPlusieursBase
-from copy import copy, deepcopy
-from PyQt5.QtCore import Qt
-
-
-class MonWidgetCreeUserAssd(MonWidgetSimpTxt):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetSimpTxt.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- # self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
-
- def LEvaleurPressed(self):
- try:
- if (
- str(self.lineEditVal.text()) == ""
- or str(self.lineEditVal.text()) == None
- ):
- return
- except:
- pass
- valeurEntree = str(self.lineEditVal.text())
- if valeurEntree == self.oldValeurTexte:
- return
- if self.oldValeurTexte == "":
- enCreation = True
- else:
- enCreation = False
- if enCreation:
- validite, commentaire = self.objSimp.creeUserASSDetSetValeur(valeurEntree)
- else:
- validite, commentaire = self.objSimp.renommeSdCree(valeurEntree)
- if not enCreation:
- self.node.updateNodeTexte()
- # PNPNPN -- signal update sur les fils ou ?
- if commentaire != "":
- if validite:
- self.editor.afficheCommentaire(commentaire)
- self.oldValeurTexte = self.lineEditVal.text()
- else:
- self.editor.afficheInfos(commentaire, Qt.red)
- self.lineEditVal.setText("")
- self.oldValeurTexte = ""
- self.parentQt.propageChange(self.objSimp.definition.type[0], self)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from .monWidgetSimpTuple import MonWidgetSimpTuple
-from desWidgetDate import Ui_WidgetDate
-
-
-class MonWidgetDate(Ui_WidgetDate, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 3
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- if self.objSimp.isImmuable():
- self.lineEditVal1.setDisabled(True)
- self.lineEditVal2.setDisabled(True)
- self.lineEditVal3.setDisabled(True)
- self.lineEditVal1.setStyleSheet(
- QString.fromUtf8("background:rgb(244,244,244);\n" "border:0px;\n")
- )
- self.lineEditVal2.setStyleSheet(
- QString.fromUtf8("background:rgb(244,244,244);\n" "border:0px;\n")
- )
- self.lineEditVal3.setStyleSheet(
- QString.fromUtf8("background:rgb(244,244,244);\n" "border:0px;\n")
- )
- self.lineEditVal1.setToolTip(tr("Valeur non modifiable"))
- self.lineEditVal2.setToolTip(tr("Valeur non modifiable"))
- self.lineEditVal3.setToolTip(tr("Valeur non modifiable"))
- else:
- self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
- # self.maCommande.listeAffichageWidget.append(self.lineEditVal2)
- # self.maCommande.listeAffichageWidget.append(self.lineEditVal3)
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-from PyQt5.QtCore import Qt, QTimer
-from PyQt5.QtWidgets import QWidget
-
-from .groupe import Groupe
-from desWidgetFact import Ui_WidgetFact
-from Extensions.i18n import tr
-
-# Import des panels
-
-
-# PN 18 mai 2020 : affiche systematique des optionnels
-class MonWidgetFactCommun(Groupe):
- """ """
-
- def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
- # print ("fact : ",node.item.nom)
- Groupe.__init__(self, node, editor, parentQt, definition, obj, niveau, commande)
- labeltext, fonte, couleur = self.node.item.getLabelText()
- self.GroupBox.setText(tr(labeltext))
- # self.GroupBox.setTextInteractionFlags(Qt.TextSelectableByMouse)
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.doitAfficherOptionnel = True
- min, max = obj.getMinMax()
- if max > 1 and hasattr(self, "RBPlus"):
- self.RBPlus.clicked.connect(self.ajouteMCParPB)
- if max < 2 and hasattr(self, "RBPlus"):
- self.RBPlus.close()
- if (
- max > 2
- and obj.alt_parent.nature == "MCList"
- and len(obj.alt_parent) >= max
- and hasattr(self, "RBPlus")
- ):
- self.RBPlus.close()
-
- if max > 2 and definition.statut == "cache" and hasattr(self, "RBPlus"):
- self.RBPlus.close()
-
- def enterEvent(self, event):
- # print "enterEvent ", self.node.item.getLabelText()[0]
- self.doitAfficherOptionnel = True
- QWidget.enterEvent(self, event)
- QTimer.singleShot(500, self.delayAffiche)
-
- def leaveEvent(self, event):
- # print "leaveEvent", self.node.item.getLabelText()[0]
- # self.doitAfficherOptionnel=False
- QWidget.leaveEvent(self, event)
-
- def delayAffiche(self):
- # print "delayAffiche, self.doitAfficherOptionnel = ", self.doitAfficherOptionnel
- if self.doitAfficherOptionnel and self.editor.code != "CARMELCND":
- self.afficheOptionnel()
-
- def ajouteMCParPB(self):
- texteListeNom = "+" + self.obj.nom
- parentOuAjouter = self.parentQt
- from .monWidgetBloc import MonWidgetBloc
-
- while parentOuAjouter and isinstance(parentOuAjouter, MonWidgetBloc):
- parentOuAjouter = parentOuAjouter.parentQt
- parentOuAjouter.ajoutMC(texteListeNom)
-
-
-# def reaffiche(self, nodeAVoir=None):
-# print ('ds reaffiche : ', self.obj.nom, self.node.firstDeplie)
-# if self.node.editor.maConfiguration.afficheFirstPlies and self.node.firstDeplie:
-# self.node.firstDeplie =False
-# self.node.setPlie()
-# Groupe.reaffiche(self,nodeAVoir)
-
-
-class MonWidgetFact(Ui_WidgetFact, MonWidgetFactCommun):
- # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1):
- # MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn)
- def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
- MonWidgetFactCommun.__init__(
- self, node, editor, parentQt, definition, obj, niveau, commande
- )
-
-
-class MonWidgetFactTableau(Ui_WidgetFact, MonWidgetFactCommun):
- # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1):
- # MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn)
- def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
- MonWidgetFactCommun.__init__(
- self, node, editor, parentQt, definition, obj, niveau, commande
- )
- MonWidgetFactTableau.__init__(
- self, node, editor, parentQt, definition, obj, niveau, commande
- )
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-from desWidgetFactPlie import Ui_WidgetFactPlie
-from .groupe import Groupe
-from Extensions.i18n import tr
-
-class MonWidgetFactPlie(Ui_WidgetFactPlie, Groupe):
- """ """
-
- # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=-1):
- def __init__(self, node, editor, parentQt, definition, obj, niveau, commande):
- # print "fact plie : ",node.item.nom
- node.fenetreAAfficher = self
- Groupe.__init__(self, node, editor, parentQt, definition, obj, niveau, commande)
- self.groupBox.setText(self.node.item.getLabelText()[0])
- self.parentQt.commandesLayout.insertWidget(-1, self)
-
- def traiteClicSurLabel(self, texte):
- return
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-from desWidgetFormule import Ui_WidgetFormule
-from .gereIcones import FacultatifOuOptionnel
-
-from PyQt5.QtWidgets import QWidget
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import Qt
-
-
-from Extensions.i18n import tr
-import Accas
-import os
-
-
-# Import des panels
-
-
-class MonWidgetFormule(QWidget, Ui_WidgetFormule, FacultatifOuOptionnel):
- """ """
-
- def __init__(self, node, editor, etape):
- # print "MonWidgetFormule ", self
- QWidget.__init__(self, None)
- self.node = node
- self.node.fenetre = self
- self.editor = editor
- self.appliEficas = self.editor.appliEficas
- self.repIcon = self.appliEficas.repIcon
- self.setupUi(self)
-
- self.setIconePoubelle()
- self.setIconesGenerales()
- self.setValeurs()
- self.setValide()
-
- if self.editor.code in ["MAP", "CARMELCND"]:
- self.bCatalogue.close()
- else:
- self.bCatalogue.clicked.connect(self.afficheCatalogue)
- if self.editor.code in ["Adao", "MAP", "ADAO"]:
- self.bAvant.close()
- self.bApres.close()
- else:
- self.bAvant.clicked.connect(self.afficheAvant)
- self.bApres.clicked.connect(self.afficheApres)
- self.LENom.returnPressed.connect(self.nomChange)
- self.LENomFormule.returnPressed.connect(self.nomFormuleSaisi)
- self.LENomsArgs.returnPressed.connect(self.argsSaisis)
- self.LECorpsFormule.returnPressed.connect(self.FormuleSaisie)
-
- self.racine = self.node.tree.racine
- self.monOptionnel = None
- self.editor.fermeOptionnel()
- # print "fin init de widget Commande"
-
- def donnePremier(self):
- self.listeAffichageWidget[0].setFocus(7)
-
- def setValeurs(self):
- self.LENomFormule.setText(self.node.item.getNom())
- self.LECorpsFormule.setText(self.node.item.getCorps())
- texte_args = ""
- if self.node.item.getArgs() != None:
- for i in self.node.item.getArgs():
- if texte_args != "":
- texte_args = texte_args + ","
- texte_args = texte_args + i
- self.LENomsArgs.setText(texte_args)
-
- def nomChange(self):
- nom = str(self.LENom.text())
- self.LENomFormule.setText(nom)
- self.nomFormuleSaisi()
-
- def afficheCatalogue(self):
- if self.editor.widgetOptionnel != None:
- self.monOptionnel.hide()
- self.racine.affichePanneau()
- if self.node:
- self.node.select()
- else:
- self.racine.select()
-
- def afficheApres(self):
- self.node.selectApres()
-
- def afficheAvant(self):
- self.node.selectAvant()
-
- def setValide(self):
- if not (hasattr(self, "RBValide")):
- return
- icon = QIcon()
- if self.node.item.object.isValid():
- icon = QIcon(self.repIcon + "/ast-green-ball.png")
- else:
- icon = QIcon(self.repIcon + "/ast-red-ball.png")
- if self.node.item.getIconName() == "ast-yellow-square":
- icon = QIcon(self.repIcon + "/ast-yel-ball.png")
- self.RBValide.setIcon(icon)
-
- def nomFormuleSaisi(self):
- nomFormule = str(self.LENomFormule.text())
- if nomFormule == "":
- return
- self.LENom.setText(nomFormule)
- test, erreur = self.node.item.verifNom(nomFormule)
- if test:
- commentaire = nomFormule + tr(" est un nom valide pour une FORMULE")
- self.editor.afficheInfos(commentaire)
- else:
- commentaire = nomFormule + tr(" n'est pas un nom valide pour une FORMULE")
- self.editor.afficheInfos(commentaire, Qt.red)
- return
- if str(self.LENomsArgs.text()) != "" and str(self.LECorpsFormule.text()) != "":
- self.BOkPressedFormule()
- self.LENomsArgs.setFocus(7)
-
- def argsSaisis(self):
- arguments = str(self.LENomsArgs.text())
- if arguments == "":
- return
- test, erreur = self.node.item.verifArguments(arguments)
- if test:
- commentaire = tr("Argument(s) valide(s) pour une FORMULE")
- self.editor.afficheInfos(commentaire)
- else:
- commentaire = tr("Argument(s) invalide(s) pour une FORMULE")
- self.editor.afficheInfos(commentaire, Qt.red)
- if (
- str(self.LECorpsFormule.text()) != ""
- and str(self.LENomFormule.text()) != ""
- ):
- self.BOkPressedFormule()
- self.LECorpsFormule.setFocus(7)
-
- def FormuleSaisie(self):
- nomFormule = str(self.LENomFormule.text())
- arguments = str(self.LENomsArgs.text())
- expression = str(self.LECorpsFormule.text())
- if expression == "":
- return
- test, erreur = self.node.item.verifFormule_python(
- (nomFormule, "REEL", arguments, expression)
- )
-
- if test:
- commentaire = tr("Corps de FORMULE valide")
- self.editor.afficheInfos(commentaire)
- else:
- commentaire = tr("Corps de FORMULE invalide")
- self.editor.afficheInfos(commentaire, Qt.red)
- if str(self.LENomsArgs.text()) != "" and str(self.LENomFormule.text()) != "":
- self.BOkPressedFormule()
-
- def BOkPressedFormule(self):
- # print dir(self)
- # if self.parent.modified == 'n' : self.parent.initModif()
-
- nomFormule = str(self.LENomFormule.text())
- test, erreur = self.node.item.verifNom(nomFormule)
- if not test:
- self.editor.afficheInfos(erreur, Qt.red)
- return
-
- arguments = str(self.LENomsArgs.text())
- test, erreur = self.node.item.verifArguments(arguments)
- if not test:
- self.editor.afficheInfos(erreur, Qt.red)
- return
-
- expression = str(self.LECorpsFormule.text())
- test, erreur = self.node.item.verifFormule_python(
- (nomFormule, "REEL", arguments, expression)
- )
- if not test:
- self.editor.afficheInfos(erreur, Qt.red)
- return
-
- test = self.node.item.object.updateFormulePython(
- formule=(nomFormule, "REEL", arguments, expression)
- )
- test, erreur = self.node.item.saveFormule(
- nomFormule, "REEL", arguments, expression
- )
- if test:
- self.node.onValid()
- self.node.update_valid()
- commentaire = "Formule saisie"
- self.editor.afficheInfos(commentaire)
- else:
- commentaire = "Formule incorrecte : " + erreur
- self.editor.afficheInfos(commentaire, Qt.red)
- self.editor.initModif()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from .monWidgetSimpBase import MonWidgetSimpBase
-from desWidgetHeure import Ui_WidgetHeure
-
-
-class MonWidgetHeure(Ui_WidgetHeure, MonWidgetSimpBase):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetSimpBase.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-
-from PyQt5.QtWidgets import QWidget
-
-from Extensions.i18n import tr
-from desWidgetInactif import Ui_WidgetInactif
-import Accas
-import os
-
-
-# Import des panels
-
-
-class MonWidgetInactif(QWidget, Ui_WidgetInactif):
- """ """
-
- def __init__(self, node, editor):
- QWidget.__init__(self, None)
- self.node = node
- self.editor = editor
- self.setupUi(self)
- from .monWidgetOptionnel import MonWidgetOptionnel
-
- if self.editor.widgetOptionnel != None:
- self.monOptionnel = self.editor.widgetOptionnel
- else:
- self.monOptionnel = MonWidgetOptionnel(self)
- self.editor.widgetOptionnel = self.monOptionnel
- self.editor.splitter.addWidget(self.monOptionnel)
- self.editor.restoreSplitterSizes()
- self.afficheOptionnel()
- self.bAvant.clicked.connect(self.afficheAvant)
- self.bApres.clicked.connect(self.afficheApres)
- self.bCatalogue.clicked.connect(self.afficheCatalogue)
- self.labelNomCommande.setText(tr(self.node.item.nom))
- self.labelNomCommande.setEnabled(False)
-
- def traiteClicSurLabel(self):
- pass
-
- def donnePremier(self):
- pass
-
- def setValide(self):
- pass
-
- def afficheOptionnel(self):
- # N a pas de parentQt. doit donc etre redefini
- if self.editor.maConfiguration.closeOptionnel:
- return
- liste = []
- # print "dans afficheOptionnel", self.monOptionnel
- # dans le cas ou l insertion n a pas eu leiu (souci d ordre par exemple)
- # if self.monOptionnel == None : return
- self.monOptionnel.parentMC = self
- self.monOptionnel.afficheOptionnelVide()
-
- def afficheCatalogue(self):
- if self.editor.widgetOptionnel != None:
- self.monOptionnel.hide()
- self.node.tree.racine.affichePanneau()
- self.node.tree.racine.select()
-
- def afficheApres(self):
- self.node.selectApres()
-
- def afficheAvant(self):
- self.node.selectAvant()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os
-
-# Modules Eficas
-from PyQt5.QtWidgets import QWidget
-from Extensions.i18n import tr
-
-from desWidgetInformation import Ui_WidgetInformative
-
-
-class MonWidgetInfo(Ui_WidgetInformative, QWidget):
- # c est juste la taille des differents widgets de base qui change
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- QWidget.__init__(self, None)
- self.setupUi(self)
- valeur = node.item.getValeur()
- self.lineEditVal.setText(str(valeur))
- self.lineEditVal.setReadOnly(True)
- parentQt.commandesLayout.insertWidget(-1, self)
-
- commande.listeAffichageWidget.append(self.lineEditVal)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os
-
-# Modules Eficas
-from PyQt5.QtWidgets import QCheckBox, QScrollBar, QFrame, QApplication, QLabel
-from PyQt5.QtWidgets import QSizePolicy, QSpacerItem
-from PyQt5.QtGui import QPalette, QFont
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-
-from desWidgetIntoSug import Ui_WidgetIntoSug
-from monWidgetPlusieursInto import MonWidgetPlusieursInto
-
-
-class GereAjoutDsPossible:
- def LEValeurAjouteDsPossible(self):
- text = str(self.lineEditVal.text())
- if text == "":
- return
- # il faudrait essauer d en obtenir un reel, un tuple ou ...
- # si cela est utilise pour autre chose que Telemac
- # tout devrait etre fait ici
- if not isinstance(text, str):
- self.lineEditVal.setText("")
- return
- if self.node.item.hasIntoSug():
- self.maListeDeValeur = list(self.node.item.getListePossibleAvecSug([]))
- self.maListeDeValeur.insert(0, text)
- else:
- try:
- self.monSimpDef.intoSug.insert(0, text)
- except:
- self.monSimpDef.intoSug = list(self.monSimpDef.intoSug)
- self.monSimpDef.intoSug.insert(0, text)
- # selon si on est une liste ou un combo
- try:
- self.ajouteValeurPossible(text)
- except:
- self.setValeurs()
-
-
-class MonWidgetIntoSug(Ui_WidgetIntoSug, MonWidgetPlusieursInto, GereAjoutDsPossible):
- # Attention Attention
- # cette wdget ne fonctionne actuellement que pour Telemac
- # on attend du texte . on n essaye pas de transformer
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetPlusieursInto.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os, sys
-
-# Modules Eficas
-from Extensions.i18n import tr
-from .feuille import Feuille
-from Extensions.eficas_exception import EficasException
-
-
-from desWidgetMatrice import Ui_desWidgetMatrice
-
-from PyQt5.QtCore import QSize, Qt
-from PyQt5.QtWidgets import QTableWidgetItem, QTableWidget
-from PyQt5.QtGui import QIcon, QColor
-from PyQt5.QtWidgets import QMessageBox
-
-
-class MonWidgetMatrice(Ui_desWidgetMatrice, Feuille):
- # c est juste la taille des differents widgets de base qui change
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.monType = self.node.item.object.definition.type[0]
- parentQt.commandesLayout.insertWidget(-1, self)
- self.nbLigs = 0
- self.nbCols = 0
- self.creeColonnes()
- self.connecterSignaux()
- self.initialValeur()
-
- def connecterSignaux(self):
- self.TBMatrice.itemChanged.connect(self.itemChanged)
- self.PBrefresh.clicked.connect(self.acceptVal)
- self.TBMatrice.focusOutEvent = self.monFocusOutEvent
-
- def monFocusOutEvent(self, event):
- self.acceptVal()
- QTableWidget.focusOutEvent(self.TBMatrice, event)
-
- def itemChanged(self):
- monItem = self.TBMatrice.currentItem()
- if monItem == None:
- return
- texte = monItem.text()
- if texte == "":
- return
- boolOk, commentaire = self.monType.verifItem(texte, self.node.item.object)
- if not boolOk:
- 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):
- if self.monType.methodeCalculTaille != None:
- try:
- MonWidgetMatrice.__dict__[self.monType.methodeCalculTaille](*(self,))
- except:
- QMessageBox.critical(
- self,
- tr("Mauvaise execution "),
- tr("impossible d executer la methode ")
- + self.monType.methodeCalculTaille,
- )
- return
- else:
- self.nbLigs = self.monType.nbLigs
- self.nbCols = self.monType.nbCols
- self.TBMatrice.setColumnCount(self.nbCols)
- self.TBMatrice.setRowCount(self.nbLigs)
- if self.nbLigs < 15:
- taille = 50
- else:
- taille = 40
- 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.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):
- liste = self.node.item.getValeur()
- if liste == None:
- return
- dejaAffiche = 0
- if (len(liste)) != self.nbLigs:
- QMessageBox.critical(
- self,
- tr("Mauvaise dimension de matrice"),
- tr("le nombre de ligne n est pas egal a ") + str(self.nbLigs),
- )
- return
- for i in range(self.nbLigs):
- inter = liste[i]
- if (len(inter)) != self.nbCols:
- QMessageBox.critical(
- self,
- tr("Mauvaise dimension de matrice"),
- tr("le nombre de colonne n est pas egal a ") + str(self.nbCols),
- )
- 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 = []
- for i in range(self.nbLigs):
- listeCol = []
- for j in range(self.nbCols):
- monItem = self.TBMatrice.item(i, j)
- if monItem:
- texte = monItem.text()
- else:
- texte = ""
- if texte != "":
- val = self.monType.convertItem(texte)
- else:
- val = None
- listeCol.append(val)
- liste.append(listeCol)
- self.node.item.setValeur(liste)
-
-
-class MonWidgetMatriceOT(MonWidgetMatrice):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- monWidgetMatrice.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def connecterSignaux(self):
- self.TBMatrice.itemChanged.connect(self.itemChanged)
- self.PBrefresh.clicked.connect(self.afficheEntete)
-
- def afficheEntete(self):
- self.objSimp.changeEnteteMatrice()
- self.TBMatrice.clear()
- if self.node.item.getValeur() == None:
- self.initialSsValeur()
- else:
- try:
- self.initialValeur()
- except:
- self.initialSsValeur()
- self.node.item.object.state = "changed"
- self.node.item.object.parent.state = "changed"
- self.setValide()
- self.parentQt.setValide()
- self.node.item.jdc.isValid()
-
- def itemChanged(self):
- monItem = self.TBMatrice.currentItem()
- if monItem == None:
- return
- texte = monItem.text()
- if texte == "":
- return
- try:
- val = float(str(texte))
- ok = True
- except:
- ok = False
- if ok == False:
- self.editor.afficheInfos(tr("Entrer un float SVP"), Qt.red)
- monItem.setText("")
- return
- if self.monType.valSup != None:
- if val > self.monType.valSup:
- self.editor.afficheInfos(
- tr("Entrer un float inferieur a ") + repr(self.monType.valSup),
- Qt.red,
- )
- monItem.setText("")
- return
- if self.monType.valMin != None:
- if val < self.monType.valMin:
- self.editor.afficheInfos(
- tr("Entrer un float superieur a ") + repr(self.monType.valMin),
- Qt.red,
- )
- monItem.setText("")
- return
- self.editor.afficheInfos("")
- if self.monType.structure != None:
- MonWidgetMatrice.__dict__[self.monType.structure](*(self,))
- self.acceptVal()
-
- def creeColonnes(self):
- if self.monType.methodeCalculTaille != None:
- try:
- MonWidgetMatrice.__dict__[self.monType.methodeCalculTaille](*(self,))
- except:
- QMessageBox.critical(
- self,
- tr("Mauvaise execution "),
- tr("impossible d executer la methode ")
- + self.monType.methodeCalculTaille,
- )
- return
- else:
- self.nbLigs = self.monType.nbLigs
- self.nbCols = self.monType.nbCols
-
- def nbDeVariables(self):
- # uniquement pour OT
- jdc = self.node.item.object.jdc
- etape = self.node.item.object.etape
- self.listeVariables = jdc.getVariables(etape)
- if self.listeVariables == []:
- QMessageBox.critical(
- self, tr("Mauvaise Commande "), tr("Aucune variable connue")
- )
- return
- self.TBMatrice.setColumnCount(len(self.listeVariables))
- self.TBMatrice.setRowCount(len(self.listeVariables))
- self.nbLigs = len(self.listeVariables)
- self.nbCols = len(self.listeVariables)
-
- def initialSsValeur(self):
- # uniquement pour OT
- self.listeVariables = []
- for row in range(self.nbLigs):
- for column in range(self.nbCols):
- if row == column:
- initialFloat = 1
- else:
- initialFloat = 0
- self.TBMatrice.setItem(row, column, QTableWidgetItem(str(initialFloat)))
- header = []
- for var in liste[0]:
- header.append(str(var))
- self.TBMatrice.setVerticalHeaderLabels(header)
- self.TBMatrice.setHorizontalHeaderLabels(header)
-
- def nbDeVariables(self):
- # uniquement pour OT
- jdc = self.node.item.object.jdc
- etape = self.node.item.object.etape
- self.listeVariables = jdc.getVariables(etape)
- if self.listeVariables == []:
- QMessageBox.critical(
- self,
- tr("Mauvaise Commande "),
- tr("Aucune variable connue. Entrez les variables avant la matrice"),
- )
- return
- self.TBMatrice.setColumnCount(len(self.listeVariables))
- self.TBMatrice.setRowCount(len(self.listeVariables))
- self.nbLigs = len(self.listeVariables)
- self.nbCols = len(self.listeVariables)
-
- def initialValeur(self):
- # uniquement pour OT
- liste = self.node.item.getValeur()
- dejaAffiche = 0
- if (len(liste)) != self.nbLigs + 1:
- QMessageBox.critical(
- self,
- tr("Mauvaise dimension de matrice"),
- tr("le nombre de ligne n est pas egal a ") + str(self.nbLigs),
- )
- raise EficasException("dimension")
- for i in range(self.nbLigs):
- inter = liste[i + 1]
- if (len(inter)) != self.nbCols:
- QMessageBox.critical(
- self,
- tr("Mauvaise dimension de matrice"),
- tr("le nombre de colonne n est pas egal a ") + str(self.nbCols),
- )
- raise EficasException("dimension")
- for j in range(self.nbCols):
- self.TBMatrice.setItem(i, j, QTableWidgetItem(str(liste[i][j])))
- header = []
- for var in liste[0]:
- header.append(str(var))
- self.TBMatrice.setVerticalHeaderLabels(header)
- self.TBMatrice.setHorizontalHeaderLabels(header)
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-import types, os
-
-from PyQt5.QtWidgets import QWidget
-from PyQt5.QtGui import QIcon
-
-from desWidgetNiveauFact import Ui_WidgetNiveauFact
-from InterfaceQT4.monWidgetOptionnel import MonWidgetOptionnel
-from InterfaceQT4.groupe import Groupe
-
-from Extensions.i18n import tr
-
-class MonWidgetNiveauFact(Ui_WidgetNiveauFact, Groupe):
- """ """
-
- def __init__(self, node, editor, definition, obj):
- self.listeAffichageWidget = []
- self.listeBoutonAChanger = []
- Groupe.__init__(self, node, editor, None, definition, obj, 1, self)
- from InterfaceQT4 import composimp
-
- if isinstance(self.node, composimp.Node):
- widget = self.node.getPanelGroupe(self, self.maCommande)
- self.listeBoutonAChanger.append(widget.RBValide)
- self.afficheOptionnel()
- self.inhibe = False
- self.labelDoc.setText(self.node.item.getFr())
- self.labelNomCommande.setText(self.node.item.getLabelText()[0])
-
- def reaffiche(self, nodeAVoir=None):
- self.node.setDeplieChildren()
- self.node.afficheCeNiveau()
- self.editor.fenetreCentraleAffichee.labelDoc.setText(self.node.item.getFr())
- self.editor.fenetreCentraleAffichee.labelNomCommande.setText(
- self.node.item.getLabelText()[0]
- )
-
- def getPanel(self):
- # necessaire pour handleOnItem de browser.py
- # non appele
- pass
-
- def donnePremier(self):
- # print "dans donnePremier"
- QApplication.processEvents()
- if self.listeAffichageWidget != []:
- self.listeAffichageWidget[0].setFocus(7)
- QApplication.processEvents()
- # print self.focusWidget()
-
- def focusNextPrevChild(self, next):
- # on s assure que ce n est pas un chgt de fenetre
- # print "je passe dans focusNextPrevChild"
- if self.editor.fenetreCentraleAffichee != self:
- return True
- f = self.focusWidget()
-
- if f not in self.listeAffichageWidget:
- i = 0
- while not hasattr(f, "AAfficher"):
- if f == None:
- i = -1
- break
- f = f.parentWidget()
- if hasattr(f, "AAfficher"):
- f = f.AAfficher
- if i != -1:
- i = self.listeAffichageWidget.index(f)
- else:
- i = self.listeAffichageWidget.index(f)
- if (i == len(self.listeAffichageWidget) - 1) and next and not self.inhibe:
- try:
- self.listeAffichageWidget[1].setFocus(7)
- w = self.focusWidget()
- self.inhibe = 1
- w.focusPreviousChild()
- self.inhibe = 0
- return True
- except:
- pass
-
- if i == 0 and next == False and not self.inhibe:
- if hasattr(self.editor.fenetreCentraleAffichee, "scrollArea"):
- self.editor.fenetreCentraleAffichee.scrollArea.ensureWidgetVisible(
- self.listeAffichageWidget[-1]
- )
- self.listeAffichageWidget[-2].setFocus(7)
- self.inhibe = 1
- w = self.focusWidget()
- w.focusNextChild()
- self.inhibe = 0
- return True
-
- if i == 0 and next == True and not self.inhibe:
- self.listeAffichageWidget[0].setFocus(7)
- self.inhibe = 1
- w = self.focusWidget()
- w.focusNextChild()
- self.inhibe = 0
- return True
-
- if i > 0 and next == False and not self.inhibe:
- if isinstance(self.listeAffichageWidget[i - 1], QRadioButton):
- self.listeAffichageWidget[i - 1].setFocus(7)
- return True
- return QWidget.focusNextPrevChild(self, next)
-
- def etablitOrdre(self):
- # si on boucle on perd l'ordre
- i = 0
- while i + 1 < len(self.listeAffichageWidget):
- self.setTabOrder(
- self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
- )
- i = i + 1
-
- def afficheSuivant(self, f):
- # print ('ds afficheSuivant')
- try:
- i = self.listeAffichageWidget.index(f)
- next = i + 1
- except:
- next = 1
- if next == len(self.listeAffichageWidget):
- next = 0
- try:
- self.listeAffichageWidget[next].setFocus(7)
- except:
- pass
-
- def afficheOptionnel(self):
- # N a pas de parentQt. doit donc etre redefini
- # print ('ds afficheOptionnel')
- if self.editor.maConfiguration.closeOptionnel:
- return
- if self.editor.widgetOptionnel != None:
- self.monOptionnel = self.editor.widgetOptionnel
- else:
- self.editor.inhibeSplitter = 1
- self.monOptionnel = MonWidgetOptionnel(self.editor)
- self.editor.widgetOptionnel = self.monOptionnel
- self.editor.splitter.addWidget(self.monOptionnel)
- self.editor.ajoutOptionnel()
- self.editor.inhibeSplitter = 0
- self.monOptionnel.vireTous()
-
- liste, liste_rouge = self.ajouteMCOptionnelDesBlocs()
- self.monOptionnel.parentCommande = self
- self.monOptionnel.titre(self.obj.nom)
- self.monGroupe = self.monOptionnel.afficheOptionnel(liste, liste_rouge, self)
-
- def setValide(self):
- Groupe.setValide(self)
- for bouton in self.listeBoutonAChanger:
- couleur = self.node.item.getIconName()
- monIcone = QIcon(self.repIcon + "/" + couleur + ".png")
- bouton.setIcon(monIcone)
-
-
-class MonWidgetNiveauFactTableau(MonWidgetNiveauFact):
- def __init__(self, node, editor, definition, obj):
- MonWidgetNiveauFact.__init__(self, node, editor, definition, obj)
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-
-from PyQt5.QtWidgets import QCheckBox, QWidget
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-from desWidgetOptionnel import Ui_WidgetOptionnel
-from .monGroupeOptionnel import MonGroupeOptionnel
-
-
-# Import des panels
-class MonWidgetOptionnel(QWidget, Ui_WidgetOptionnel):
- def __init__(self, parentQt):
- # print ("dans init de monWidgetOptionnel ", parentQt )
- QWidget.__init__(self, None)
- self.setupUi(self)
- self.dicoMCWidgetOptionnel = {}
- self.parentQt = parentQt
-
- def afficheOptionnel(self, liste, liste_rouge, MC):
- # print ('afficheOptionnel MonWidgetOptionnel',self, liste,MC.node.item.nom)
- self.vireLesAutres(MC)
-
- if MC.node.item.nom in self.dicoMCWidgetOptionnel:
- # print (MC.node.item.nom)
- self.dicoMCWidgetOptionnel[MC.node.item.nom].close()
- self.dicoMCWidgetOptionnel[MC.node.item.nom].setParent(None)
- self.dicoMCWidgetOptionnel[MC.node.item.nom].deleteLater()
- del self.dicoMCWidgetOptionnel[MC.node.item.nom]
- if liste == []:
- return
- groupe = MonGroupeOptionnel(liste, liste_rouge, self, MC)
- self.groupesOptionnelsLayout.insertWidget(0, groupe)
- self.dicoMCWidgetOptionnel[MC.node.item.nom] = groupe
- return groupe
-
- def vireLesAutres(self, MC):
- # print( "je passe dans vireLesAutres")
- genea = MC.obj.getGenealogie()
- # print (genea)
- for k in list(self.dicoMCWidgetOptionnel.keys()):
- # print (k)
- # if k not in genea : print ( k)
- if k not in genea:
- self.dicoMCWidgetOptionnel[k].close()
- del self.dicoMCWidgetOptionnel[k]
- # print( "fin vireLesAutres")
-
- def vireTous(self):
- for k in list(self.dicoMCWidgetOptionnel.keys()):
- self.dicoMCWidgetOptionnel[k].close()
- del self.dicoMCWidgetOptionnel[k]
-
- def afficheOptionnelVide(self):
- self.GeneaLabel.setText("")
- for k in list(self.dicoMCWidgetOptionnel.keys()):
- self.dicoMCWidgetOptionnel[k].close()
- del self.dicoMCWidgetOptionnel[k]
-
- def titre(self, MC):
- if (
- self.parentCommande.node.editor.maConfiguration.closeFrameRechercheCommande
- == True
- ):
- self.frameLabelCommande.close()
- return
- labeltext, fonte, couleur = self.parentCommande.node.item.getLabelText()
- l = tr(labeltext)
- li = []
- while len(l) > 25:
- li.append(l[0:24])
- l = l[24:]
- li.append(l)
- texte = ""
- for l in li:
- texte += l + "\n"
- texte = texte[0:-2]
- self.GeneaLabel.setText(tr("Options pour \n") + texte)
+++ /dev/null
-# Copyright (C) 2007-2024 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
-#
-
-import os, re
-import types
-
-from desWidgetParam import Ui_WidgetParam
-from InterfaceQT4.gereIcones import FacultatifOuOptionnel
-from PyQt5.QtWidgets import QWidget, QMessageBox
-from PyQt5.QtGui import QIcon
-
-from Extensions.i18n import tr
-from Extensions.eficas_exception import EficasException
-
-pattern_name = re.compile(r"^[^\d\W]\w*\Z")
-
-class MonWidgetParam(QWidget, Ui_WidgetParam, FacultatifOuOptionnel):
- """ """
-
- def __init__(self, node, editor, commentaire):
- QWidget.__init__(self, None)
- self.node = node
- self.node.fenetre = self
- self.setupUi(self)
- self.editor = editor
- self.appliEficas = self.editor.appliEficas
- self.repIcon = self.appliEficas.repIcon
-
- self.setIconePoubelle()
- if not (self.node.item.object.isValid()):
- icon = QIcon(self.repIcon + "/ast-red-ball.png")
- self.RBValide.setIcon(icon)
-
- self.remplit()
- # if self.editor.code in ['MAP','CARMELCND','CF'] : self.bCatalogue.close()
- if self.editor.code in ["MAP", "CARMELCND"]:
- self.bCatalogue.close()
- else:
- self.bCatalogue.clicked.connect(self.afficheCatalogue)
-
- self.lineEditVal.returnPressed.connect(self.LEvaleurPressed)
- self.lineEditNom.returnPressed.connect(self.LENomPressed)
- self.bAvant.clicked.connect(self.afficheAvant)
- self.bApres.clicked.connect(self.afficheApres)
- self.bVerifie.clicked.connect(self.verifiePressed)
-
- self.editor.fermeOptionnel()
-
- def afficheCatalogue(self):
- self.node.tree.racine.affichePanneau()
- if self.node:
- self.node.select()
- else:
- self.node.tree.racine.select()
-
- def remplit(self):
- nom = self.node.item.getNom()
- self.lineEditNom.setText(nom)
-
- valeur = self.node.item.getValeur()
- if valeur == None:
- self.lineEditVal.clear()
- elif type(valeur) == list:
- texte = "["
- for l in valeur:
- texte = texte + str(l) + ","
- texte = texte[0:-1] + "]"
- self.lineEditVal.setText(texte)
- else:
- self.lineEditVal.setText(str(valeur))
-
- def donnePremier(self):
- self.lineEditVal.setFocus(7)
-
- def LEvaleurPressed(self):
- if self.verifiePressed() == False:
- QMessageBox.warning(
- self, tr("Modification Impossible"), tr("le parametre n'est pas valide")
- )
- nom = str(self.lineEditNom.text())
- val = str(self.lineEditVal.text())
- self.node.item.setNom(nom)
- self.node.item.setValeur(val)
- self.node.updateTexte()
-
- def LENomPressed(self):
- self.LEvaleurPressed()
-
- def verifiePressed(self):
- nomString = str(self.lineEditNom.text())
- if not pattern_name.match(nomString):
- self.LECommentaire.setText(
- nomString + tr(" n est pas un identifiant correct")
- )
- return False
-
- valString = str(self.lineEditVal.text())
-
- contexte = {}
- exec("from math import *", contexte)
- jdc = self.node.item.getJdc()
- for p in jdc.params:
- try:
- tp = p.nom + "=" + str(repr(p.valeur))
- exec(tp, contexte)
- except exc:
- pass
-
- monTexte = nomString + "=" + valString
- try:
- exec(monTexte, contexte)
- except (
- ValueError,
- TypeError,
- NameError,
- RuntimeError,
- ZeroDivisionError,
- ) as exc:
- self.LECommentaire.setText(tr("Valeur incorrecte: ") + str(exc))
- return False
- except:
- self.LECommentaire.setText(tr("Valeur incorrecte "))
- return False
-
- self.LECommentaire.setText(tr("Valeur correcte "))
- return True
-
- def afficheApres(self):
- self.node.selectApres()
-
- def afficheAvant(self):
- self.node.selectAvant()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from Extensions.i18n import tr
-from .monWidgetPlusieursIntoOrdonne import MonWidgetPlusieursIntoOrdonne
-from .politiquesValidation import PolitiquePlusieurs
-
-from six.moves import range
-from PyQt5.QtWidgets import QScrollBar
-
-
-class MonWidgetPlusieursASSDIntoOrdonne(MonWidgetPlusieursIntoOrdonne):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.numLineEditEnCours = 0
- MonWidgetPlusieursIntoOrdonne.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def prepareListeResultat(self):
- for i in self.listeLE:
- i.close()
- self.listeLE = []
- self.vScrollBar = self.scrollArea.verticalScrollBar()
- self.listeAAfficher = self.node.item.getSdAvantDuBonType()
-
- if len(self.listeAAfficher) == 0:
- self.ajoutLE(0)
- return
-
- if len(self.listeAAfficher) * 30 > 400:
- self.resize(self.width(), 200)
- else:
- self.resize(self.width(), len(self.listeAAfficher) * 30)
- self.politique = PolitiquePlusieurs(self.node, self.editor)
- for i in range(1, len(self.listeAAfficher) + 1):
- self.ajoutLE(i)
- for i in range(len(self.listeAAfficher)):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- courant.setText(str(self.listeAAfficher[i]))
- self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types, os
-from PyQt5.QtGui import QIcon
-from PyQt5.QtWidgets import QApplication, QMessageBox, QScrollArea
-from PyQt5.QtCore import QTimer, QSize, Qt
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from InterfaceQT4.feuille import Feuille
-from desWidgetPlusieursBase import Ui_WidgetPlusieursBase
-from InterfaceQT4.politiquesValidation import PolitiquePlusieurs
-from InterfaceQT4.qtSaisie import SaisieValeur
-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
-
-
-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.dictLE = {}
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- GereListe.__init__(self)
- self.gereIconePlier()
- self.BSelectFichier.clicked.connect(self.selectInFile)
-
- repIcon = self.node.editor.appliEficas.repIcon
- fichier = os.path.join(repIcon, "arrow_up.png")
- icon = QIcon(fichier)
- self.RBHaut.setIcon(icon)
- 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)
- 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)
-
- 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.setMinimumHeight(hauteurMax)
- self.finCommentaireListe()
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
- self.AAfficher = self.lineEditVal1
- self.inInit = False
- # PNPN a completer __ si tuple le type des tuples sinon le tuple
- # trop moche
- # self.monCommentaireLabel.setText(self.finCommentaireListe())
- self.monCommentaireLabel.setText("")
- self.scrollArea.leaveEvent = self.leaveEventScrollArea
- self.inhibeChangeValeur = False
- self.dejaAverti = False
-
- 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)
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- index = 1
- for valeur in self.listeValeursCourantes:
- val = self.politique.getValeurTexte(valeur)
- nomLineEdit = "lineEditVal" + str(index)
- if hasattr(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))
- self.dictLE[index] = 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,
- ):
- # print ('ajoutLineEdit plusieursBase')
- # print ('self.indexDernierLabel', self.indexDernierLabel)
- self.indexDernierLabel = self.indexDernierLabel + 1
- nomLineEdit = "lineEditVal" + str(self.indexDernierLabel)
- if hasattr(self, nomLineEdit):
- self.indexDernierLabel = self.indexDernierLabel - 1
- return
- nouveauLE = LECustom(self.scrollArea, self, self.indexDernierLabel)
- self.verticalLayoutLE.insertWidget(self.indexDernierLabel - 1, nouveauLE)
- nouveauLE.setText("")
- if self.indexDernierLabel % 2 == 1:
- nouveauLE.setStyleSheet("background:rgb(210,210,210)")
- else:
- nouveauLE.setStyleSheet("background:rgb(235,235,235)")
- nouveauLE.setFrame(False)
- nouveauLE.returnPressed.connect(self.changeValeur)
-
- setattr(self, nomLineEdit, nouveauLE)
- self.listeAffichageWidget.append(nouveauLE)
- self.etablitOrdre()
- if valeur != None:
- nouveauLE.setText(str(valeur))
- self.dictLE[self.indexDernierLabel] = valeur
- else:
- self.dictLE[self.indexDernierLabel] = None
- # deux lignes pour que le ensureVisible fonctionne
- self.estVisible = nouveauLE
- if self.inInit == False:
- QTimer.singleShot(1, self.rendVisibleLigne)
-
- def etablitOrdre(self):
- i = 0
- while i + 1 < len(self.listeAffichageWidget):
- self.listeAffichageWidget[i].setFocusPolicy(Qt.StrongFocus)
- self.setTabOrder(
- self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
- )
- i = i + 1
- # si on boucle on perd l'ordre
-
- def rendVisibleLigne(self):
- QApplication.processEvents()
- self.estVisible.setFocus()
- self.scrollArea.ensureWidgetVisible(self.estVisible, 0, 0)
-
- def finCommentaire(self):
- return self.finCommentaireListe()
-
- def ajout1Valeur(self, valeur=None):
- # print ('ajout1Valeur plusieursBase')
- if valeur == None:
- return
- liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
- if validite == 0:
- return
- if liste == []:
- return
- listeVal = []
- for valeur in self.listeValeursCourantes:
- listeVal.append(valeur)
- validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
- liste, -1, listeVal
- )
- if comm2 != "" and comm != None:
- return comm2
- if validite:
- self.listeValeursCourantes = self.listeValeursCourantes + listeRetour
- if len(self.listeValeursCourantes) > self.monSimpDef.min:
- self.node.item.setValeur(self.listeValeursCourantes)
- self.reaffiche()
- return None
- else:
- return comm2 + " " + comm
-
- def reaffiche(self):
- # A priori, on ne fait rien
- pass
-
- def ajoutNValeur(self, liste):
- # print ('ajoutNValeur plusieursBase')
- # ----------------------------
- # 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
- # chaque valeur. d ou l ajout de ajoutNTuple a politique plusieurs
-
- listeFormatee = list(liste)
-
- min, max = self.node.item.getMinMax()
- if self.objSimp.valeur == None:
- listeComplete = listeFormatee
- else:
- listeComplete = self.objSimp.valeur + listeFormatee
-
- if len(listeComplete) > max:
- texte = tr("Nombre maximum de valeurs ") + str(max) + tr(" atteint")
- self.editor.afficheInfos(texte, Qt.red)
- return
-
- validite, comm, comm2, listeRetour = self.politique.ajoutNTuple(listeComplete)
- if not validite:
- self.editor.affiche_infos(texte, Qt.red)
- return
-
- # on calcule le dernier lineedit rempli avant de changer la valeur
- if self.objSimp.valeur != None:
- indexDernierRempli = len(self.objSimp.valeur)
- else:
- indexDernierRempli = 0
-
- self.politique.recordValeur(listeComplete)
-
- indexDernierRempli = 0
- while indexDernierRempli < len(liste):
- texte = liste[indexDernierRempli]
- if indexDernierRempli < self.indexDernierLabel:
- nomLineEdit = "lineEditVal" + str(indexDernierRempli + 1)
- courant = getattr(self, nomLineEdit)
- courant.setText(str(texte))
- else:
- self.ajoutLineEdit(texte)
- indexDernierRempli = indexDernierRempli + 1
-
- def changeValeur(self, changeDePlace=True, oblige=False):
- # print ('achangeValeur plusieursBase', self)
- # import traceback
- # traceback.print_stack()
- if self.inhibeChangeValeur:
- return
- self.inhibeChangeValeur = True
- donneFocus = None
- derniereValeur = None
- self.listeValeursCourantes = []
- fin = self.indexDernierLabel
- if (not ("TXM" in self.objSimp.definition.type)) and not (self.dejaAverti):
- for i in range(1, fin):
- nomLineEdit = "lineEditVal" + str(i)
- courant = getattr(self, nomLineEdit)
- valeur = courant.text()
- lval = valeur.split(",")
- if len(lval) > 1:
- self.dejaAverti = True
- QMessageBox.warning(
- self,
- tr('"," used'),
- 'Perhaps, character "," is used in '
- + str(valeur)
- + 'intead of "."',
- )
- break
- # msgBox = QMessageBox()
- # msgBox.setText("separator ',' ")
- # msgBox.setInformativeText("Do you want to enter " + str (lval) + "?")
- # msgBox.setInformativeText (" you want to enter " + str (lval) + "?")
- # msgBox.setStandardButtons( QMessageBox.Ok | QMessageBox.Cancel)
- # msgBox.setDefaultButton(QMessageBox.Ok)
- # ret = msgBox.exec()
- # tres dicutable 20210401 j enleve la boucle
- # if faut remtrre self.inhibeChangeValeur si on la reactive
- # if ret == 1024:
- # courant.setText(lval[0])
- # self.ajoutNValeur(lval[1:])
- # self.listeValeursCourantes = []
-
- for i in range(1, self.indexDernierLabel + 1):
- nomLineEdit = "lineEditVal" + str(i)
- courant = getattr(self, nomLineEdit)
- valeur = courant.text()
- if valeur != None and valeur != "":
- commentaire = self.ajout1Valeur(valeur)
- if commentaire != None:
- self.editor.afficheInfos(commentaire, Qt.red)
- courant.setText("")
- donneFocus = courant
- self.reaffiche()
- return
- else:
- self.editor.afficheInfos("")
- elif donneFocus == None:
- donneFocus = courant
-
- nomDernierLineEdit = "lineEditVal" + str(self.indexDernierLabel)
- dernier = getattr(self, nomDernierLineEdit)
- derniereValeur = dernier.text()
- if changeDePlace:
- if donneFocus != None:
- donneFocus.setFocus()
- self.scrollArea.ensureWidgetVisible(donneFocus)
- elif self.indexDernierLabel < self.monSimpDef.max:
- self.ajoutLineEdit()
- if self.listeValeursCourantes == []:
- return
- min, max = self.node.item.getMinMax()
- if len(self.listeValeursCourantes) < self.monSimpDef.min:
- self.editor.afficheInfos(
- tr("nb min de valeurs : ") + str(self.monSimpDef.min)
- )
- if len(self.listeValeursCourantes) < min and oblige == True:
- return
- if len(self.listeValeursCourantes) > max:
- return
- retour = self.node.item.setValeur(self.listeValeursCourantes)
- if len(self.listeValeursCourantes) == self.monSimpDef.max:
- self.editor.afficheInfos(tr("nb max de valeurs atteint"))
- self.setValide()
- self.reaffiche()
- self.inhibeChangeValeur = False
-
- def leaveEventScrollArea(self, event):
- # print ('achangeValeur plusieursBase')
- self.changeValeur(changeDePlace=False)
- QScrollArea.leaveEvent(self.scrollArea, event)
-
-
-# Avertissement quand on quitte le widget
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2020 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 Eficas
-from Extensions.i18n import tr
-from .monWidgetSimpTxt import MonWidgetSimpTxt
-from .monWidgetPlusieursBase import MonWidgetPlusieursBase
-from copy import copy, deepcopy
-from PyQt5.QtCore import Qt
-
-
-class MonWidgetPlusieursCreeUserAssd(MonWidgetPlusieursBase):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetPlusieursBase.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- self.etablitOrdre()
- self.scrollArea.leaveEvent = self.leaveEventScrollArea
- self.RBHaut.close()
- self.RBBas.close()
-
- def ajout1Valeur(self, valeur=None):
- if not valeur in list(self.dictValeurs.keys()):
- validite, commentaire = self.objSimp.creeUserASSDetSetValeur(valeur)
- MonWidgetPlusieursBase.ajout1Valeur(self, valeur)
-
- def changeValeur(self, changeDePlace=False, oblige=False):
- # print ('dans changeValeur du CreeUserAssd', changeDePlace, self.numLineEditEnCours)
- # import traceback
- # traceback.print_stack()
- self.changeUnLineEdit = False
- valeur = self.lineEditEnCours.text()
- if self.numLineEditEnCours in list(self.dictLE.keys()):
- oldValeurUserAssd = self.dictLE[self.numLineEditEnCours]
- if oldValeurUserAssd == None or oldValeurUserAssd == "":
- enCreation = True
- oldValeurUserAssd == True
- else:
- enCreation = False
- else:
- enCreation = True
- oldValeurUserAssd = None
-
- if oldValeurUserAssd and oldValeurUserAssd.nom == valeur:
- self.selectionneNext()
- return
-
- if valeur != "":
- if not enCreation:
- validite, commentaire = self.node.item.renommeSdCreeDsListe(
- oldValeurUserAssd, valeur
- )
- if commentaire != "" and not validite:
- self.editor.afficheInfos(commentaire, Qt.red)
- self.lineEditEnCours.setText(oldValeurUserAssd.nom)
- nomDernierLineEdit = "lineEditVal" + str(self.numLineEditEnCours + 1)
- dernier = getattr(self, nomDernierLineEdit)
- dernier.setFocus()
- return
-
- validite, objASSD, commentaire = self.objSimp.creeUserASSD(valeur)
- if commentaire != "" and not validite:
- self.editor.afficheInfos(commentaire, Qt.red)
- self.lineEditEnCours.setText("")
- if objASSD:
- objASSD.supprime(self.objSimp)
- return
- else:
- validite = 1
- objASSD = None
- commentaire = ""
-
- # on relit tout pour tenir compte des lignes blanches
- oldValeur = self.objSimp.valeur
- liste = []
- for i in range(1, self.indexDernierLabel + 1):
- if i == self.numLineEditEnCours and objASSD:
- liste.append(objASSD)
- elif self.dictLE[i] != None and self.dictLE[i] != "":
- liste.append(self.dictLE[i])
- validite = self.node.item.setValeur(liste)
- if not validite:
- self.objSimp.valeur = oldValeur
- self.objSimp.state = "changed"
- self.setValide()
- if objASSD:
- objASSD.supprime(self.objSimp)
- self.lineEditEnCours.setText(oldValeurUserASSD.nom)
- return
-
- validite = self.node.item.isValid()
- if validite:
- self.dictLE[self.numLineEditEnCours] = objASSD
- self.node.item.rattacheUserASSD(objASSD)
- if self.indexDernierLabel < len(liste):
- self.ajoutLineEdit()
- nomDernierLineEdit = "lineEditVal" + str(self.numLineEditEnCours + 1)
- self.listeValeursCourantes = liste
- dernier = getattr(self, nomDernierLineEdit)
- dernier.setFocus()
- else:
- self.editor.afficheInfos("ajout impossible", Qt.red)
- if objASSD:
- objASSD.supprime(self.objSimp)
- self.lineEditEnCours.setText("")
- self.parentQt.propageChange(self.objSimp.definition.type[0], self)
-
- def selectionneDernier(self):
- index = len(self.listeValeursCourantes)
- self.listeAffichageWidget[index].setFocus()
-
- def leaveEventScrollArea(self, event):
- pass
-
- # def echangeDeuxValeurs(self):
- # self.changeUnLineEdit=False
- # obj1=self.dictLE[self.num1]
- # obj2=self.dictLE[self.num2]
- # self.dictLE[self.num1]=obj2
- # self.dictLE[self.num2]=obj1
- # nomLineEdit=self.nomLine+str(self.num1)
- # courant=getattr(self,nomLineEdit)
- # if self.dictLE[self.num1] != None : courant.setText(self.dictLE[self.num1].nom)
- # else : courant.setText("")
- # nomLineEdit=self.nomLine+str(self.num2)
- # courant=getattr(self,nomLineEdit)
- # if self.dictLE[self.num2] != None : courant.setText(self.dictLE[self.num2].nom)
- # else : courant.setText("")
- # liste=[]
- # for i in list(self.dictLE.keys()):
- # if self.dictLE[i] != None and self.dictLE[i] != "" : liste.append(self.dictLE[i])
- # validite=self.node.item.setValeur(liste)
- # self.listeValeursCourantes=liste
- # courant.setFocus(True)
-
- def descendLesLignes(self):
- self.changeUnLineEdit = False
- if self.numLineEditEnCours == self.indexDernierLabel:
- return
- nouvelleValeur = None
- for i in range(self.numLineEditEnCours + 1, self.indexDernierLabel):
- valeurAGarder = self.dictLE[i]
- self.dictLE[i] = nouvelleValeur
- nomLineEdit = self.nomLine + str(i)
- courant = getattr(self, nomLineEdit)
- if nouvelleValeur != None:
- courant.setText(nouvelleValeur.nom)
- else:
- courant.setText("")
- nouvelleValeur = valeurAGarder
-
- def moinsPushed(self):
- if self.numLineEditEnCours == 0:
- return
- if self.indexDernierLabel == 0:
- return
- objASSD = self.dictLE[self.numLineEditEnCours]
- if objASSD:
- objASSD.supprime(self.objSimp)
- self.lineEditEnCours.setText("")
- self.dictLE[self.numLineEditEnCours] = None
-
- for i in range(self.numLineEditEnCours, self.indexDernierLabel - 1):
- self.dictLE[i] = self.dictLE[i + 1]
- nomLineEdit = self.nomLine + str(i)
- courant = getattr(self, nomLineEdit)
- if self.dictLE[i] != None:
- courant.setText(self.dictLE[i].nom)
- else:
- courant.setText("")
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
- courant = getattr(self, nomLineEdit)
- courant.setText("")
- self.dictLE[self.indexDernierLabel] = None
- liste = []
- for i in list(self.dictLE.keys()):
- if self.dictLE[i] != None and self.dictLE[i] != "":
- liste.append(self.dictLE[i])
- print(liste)
- validite = self.node.item.setValeur(liste)
- self.listeValeursCourantes = liste
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from PyQt5.QtWidgets import QCheckBox, QScrollBar, QFrame, QApplication, QLabel
-from PyQt5.QtWidgets import QSizePolicy, QSpacerItem
-from PyQt5.QtGui import QPalette, QFont
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-
-from InterfaceQT4.feuille import Feuille
-from desWidgetPlusieursInto import Ui_WidgetPlusieursInto
-from InterfaceQT4.politiquesValidation import PolitiquePlusieurs
-from InterfaceQT4.qtSaisie import SaisieValeur
-from InterfaceQT4.gereListe import GerePlie
-from InterfaceQT4.gereListe import GereListe
-
-
-class MonWidgetPlusieursInto(Ui_WidgetPlusieursInto, Feuille, GerePlie, GereListe):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.index = 1
- self.alpha = 0
- self.listeCB = []
- self.listeCbRouge = []
- self.listeValeursCourantes = node.item.getListeValeurs()
- if self.listeValeursCourantes == None:
- self.listeValeursCourantes = []
-
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- GereListe.__init__(self)
-
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.CBCheck.stateChanged.connect(self.changeTout)
-
- self.gereIconePlier()
- self.editor.listeDesListesOuvertes.add(self.node.item)
- self.inhibe = False
- # self.finCommentaireListe()
-
- if self.listeAAfficher == None or self.listeAAfficher == []:
- spacerItem = QSpacerItem(30, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
- self.CBLayout.addItem(spacerItem)
- nouveauCommentaire = QLabel()
- maPolice = QFont("Times", 16)
- nouveauCommentaire.setFont(maPolice)
- nouveauCommentaire.setText(tr("Pas de valeurs possibles"))
- self.CBLayout.addWidget(nouveauCommentaire)
- spacerItem2 = QSpacerItem(40, 70, QSizePolicy.Fixed, QSizePolicy.Minimum)
- self.CBLayout.addItem(spacerItem2)
-
- if len(self.listeAAfficher) < 30 and hasattr(self, "frameRecherche"):
- self.frameRecherche.close()
- if len(self.listeAAfficher) == len(self.listeValeursCourantes):
- self.CBCheck.setChecked(True)
- if len(self.listeAAfficher) < 10:
- self.setMinimumHeight(len(self.listeAAfficher) * 22 + 55)
- else:
- self.setMinimumHeight(300)
-
- # try except si la liste des possibles est vide
- # prevoir qqchose
- try:
- self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
- except:
- pass
-
- def changeTout(self, int):
- # print ('changeTout')
- if self.inhibe:
- return
- self.inhibe = True
- if not (self.CBCheck.isChecked()):
- min, max = self.node.item.getMinMax()
- if max < len(self.listeAAfficher):
- commentaire = tr("impossible de tout selectionner : max =") + str(max)
- self.editor.afficheInfos(commentaire, Qt.red)
- self.inhibe = False
- return
- for i in range(len(self.listeAAfficher)):
- nomCB = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomCB)
- courant.setChecked(True)
- self.CBCheck.setChecked(False)
- else:
- for i in range(len(self.listeAAfficher)):
- nomCB = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomCB)
- courant.setChecked(False)
- self.CBCheck.setChecked(True)
- self.inhibe = False
- self.changeValeur()
-
- def setValeurs(self):
- # print ('setValeurs')
- self.listeValeursCourantes = self.node.item.getValeur()
- if self.listeValeursCourantes == None:
- self.listeValeursCourantes = []
- # print ("ds set Valeur", self.listeValeursCourantes, self.node.item.getValeur())
- self.politique = PolitiquePlusieurs(self.node, self.editor)
- self.vScrollBar = self.scrollArea.verticalScrollBar()
-
- if hasattr(self.node.item.definition.validators, "set_MCSimp"):
- obj = self.node.item.getObject()
- self.node.item.definition.validators.set_MCSimp(obj)
- if self.node.item.isValid() == 0:
- liste = []
- for item in self.listeValeursCourantes:
- if self.node.item.definition.validators.verifItem(item) == 1:
- liste.append(item)
- self.listeAAfficher = self.node.item.getListePossible(liste)
- else:
- self.listeAAfficher = self.node.item.getListePossible([])
- else:
- self.listeAAfficher = self.node.item.getListePossible([])
-
- if self.node.item.hasIntoSug():
- self.listeAAfficher = self.node.item.getListePossibleAvecSug([])
-
- if self.objSimp.waitAssd():
- self.listeAAfficher = self.node.item.getSdAvantDuBonType()
- if self.listeAAfficher == None or self.listeAAfficher == []:
- self.listeAAfficher = []
-
- # if len(self.listeAAfficher)*20 > 400 : self.setMinimumHeight(400)
- # else : self.setMinimumHeight(len(self.listeAAfficher)*30)
-
- self.PourEtreCoche = []
- if self.objSimp.waitUserAssd():
- for concept in self.listeValeursCourantes:
- self.PourEtreCoche.append(concept)
- elif self.objSimp.waitAssd():
- for concept in self.listeValeursCourantes:
- self.PourEtreCoche.append(concept.nom)
- else:
- for val in self.listeValeursCourantes:
- self.PourEtreCoche.append(val)
-
- maListe = []
- for i in self.listeAAfficher:
- maListe.append(i)
- if self.alpha == 1:
- maListe.sort()
- for i in range(1, len(maListe) + 1):
- self.ajoutCB(i)
-
- self.inhibe = True
- for i in range(len(maListe)):
- nomCB = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomCB)
- courant.setText(str(maListe[i]))
- if maListe[i] in self.PourEtreCoche:
- courant.setChecked(True)
- else:
- courant.setChecked(False)
-
- courant.toggled.connect(self.changeValeur)
- self.inhibe = False
-
- self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum)
-
- def ajoutCB(self, index, valeur=None):
- # print ('ajoutCB')
- nomCB = "lineEditVal" + str(index)
- if hasattr(self, nomCB):
- return
- nouveauCB = QCheckBox(self.scrollArea)
- self.CBLayout.insertWidget(index - 1, nouveauCB)
- self.listeCB.append(nouveauCB)
- nouveauCB.setText("")
- if index % 2 == 1:
- nouveauCB.setStyleSheet("background:rgb(210,210,210)")
- else:
- nouveauCB.setStyleSheet("background:rgb(240,240,240)")
- self.vScrollBar.triggerAction(QScrollBar.SliderToMaximum)
- nouveauCB.setFocus()
- setattr(self, nomCB, nouveauCB)
-
- def ajout1Valeur(self, valeur=None):
- # print ('ajout1Valeur')
- if valeur == None:
- return
- liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
- if validite == 0:
- return
- if liste == []:
- return
- listeVal = []
- for valeur in self.listeValeursCourantes:
- listeVal.append(valeur)
- validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
- liste, -1, listeVal
- )
- if comm2 != "" and comm != None:
- return comm2
- if validite:
- self.listeValeursCourantes = self.listeValeursCourantes + listeRetour
- return None
- else:
- return comm2 + " " + comm
-
- def changeValeur(self):
- # def changeValeur(self,changeDePlace=False,oblige=True, numero=None):
- # print ('changeValeur')
- if self.inhibe == True:
- return
- if hasattr(self, "LEFiltre"):
- self.noircirResultatFiltre()
- self.listeValeursCourantesAvant = self.listeValeursCourantes
- self.listeValeursCourantes = []
-
- for i in range(1, len(self.listeAAfficher) + 1):
- nomLineEdit = "lineEditVal" + str(i)
- courant = getattr(self, nomLineEdit)
- if not (courant.isChecked()):
- continue
- valeur = courant.text()
- if valeur != None and valeur != "":
- commentaire = self.ajout1Valeur(valeur)
- if commentaire != None:
- self.editor.afficheInfos(commentaire, Qt.red)
- self.listeValeursCourantesAvant = self.listeValeursCourantes
- self.setValeurs()
-
- min, max = self.node.item.getMinMax()
- if len(self.listeValeursCourantes) < min:
- self.editor.afficheInfos(
- tr("Nombre minimal de valeurs : ") + str(min), Qt.red
- )
- elif len(self.listeValeursCourantes) > max:
- self.editor.afficheInfos(
- tr("Nombre maximal de valeurs : ") + str(max), Qt.red
- )
-
- if self.listeValeursCourantes == []:
- self.node.item.setValeur([])
- else:
- self.node.item.setValeur(self.listeValeursCourantes)
-
- # Exception pour PSEN
- if min == 0 and self.listeValeursCourantes == []:
- self.node.item.setValeur([])
- self.setValide()
-
- def prepareListeResultatFiltre(self):
- # print ('prepareListeResultatFiltre')
- filtre = str(self.LEFiltre.text())
- for cb in self.listeCB:
- texte = cb.text()
- if texte.find(filtre) == 0:
- palette = QPalette(Qt.red)
- palette.setColor(QPalette.WindowText, Qt.red)
- cb.setPalette(palette)
- t = cb.text()
- cb.setText(t)
- self.listeCbRouge.append(cb)
-
- def prepareListeResultat(self):
- # print ('prepareListeResultat')
- self.clearAll()
- self.setValeurs()
-
- def clearAll(self):
- # print ('clearAll')
- for cb in self.listeCB:
- cb.setText("")
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types, os
-
-# Modules Eficas
-from .feuille import Feuille
-from desWidgetPlusieursIntoOrdonne import Ui_WidgetPlusieursIntoOrdonne
-from .politiquesValidation import PolitiquePlusieurs
-from .qtSaisie import SaisieValeur
-from .gereListe import GereListe
-from .gereListe import GerePlie
-from .gereListe import LECustom
-from .gereListe import MonLabelListeClic
-from Extensions.i18n import tr
-
-from PyQt5.QtWidgets import QFrame, QApplication, QScrollBar
-from PyQt5.QtCore import QTimer, QSize, Qt
-from PyQt5.QtGui import QIcon, QPalette
-
-
-class MonWidgetPlusieursIntoOrdonne(
- Ui_WidgetPlusieursIntoOrdonne, Feuille, GereListe, GerePlie
-):
- def __init__(self, node, monSimpDef, nom, objSimp, parent, commande):
- self.nomLine = "LEResultat"
- self.listeLE = []
- self.ouAjouter = 0
- self.numLineEditEnCours = 0
- self.alpha = 0
- self.filtre = ""
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parent, commande)
- GereListe.__init__(self)
- # self.finCommentaireListe()
- self.gereIconePlier()
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- try:
- self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
- except:
- # cas ou on ne peut rien ajouter
- pass
- self.prepareListeResultat()
- if len(self.listeAAfficher) < 20:
- self.frameRecherche2.close()
- if len(self.listeAAfficher) < 20:
- self.frameRecherche.close()
- self.adjustSize()
- repIcon = self.node.editor.appliEficas.repIcon
- fichier = os.path.join(repIcon, "arrow_up.png")
- icon = QIcon(fichier)
- self.RBHaut.setIcon(icon)
- self.RBHaut.setIconSize(QSize(32, 32))
- fichier2 = os.path.join(repIcon, "arrow_down.png")
- icon2 = QIcon(fichier2)
- self.RBBas.setIcon(icon2)
- 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)
-
- self.PBClean.clicked.connect(self.cleanListeResultatFiltre)
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.listeRouge = []
-
- def prepareListeResultat(self):
- for i in self.listeLE:
- i.close()
- self.listeLE = []
- self.vScrollBar = self.scrollArea.verticalScrollBar()
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- if hasattr(self.node.item.definition.validators, "set_MCSimp"):
- obj = self.node.item.getObject()
- self.node.item.definition.validators.set_MCSimp(obj)
- if self.node.item.isValid() == 0:
- liste = []
- for item in self.listeValeursCourantes:
- if self.node.item.definition.validators.verifItem(item) == 1:
- liste.append(item)
- self.listeAAfficher = self.node.item.getListePossible(liste)
- else:
- self.listeAAfficher = self.node.item.getListePossible([])
- else:
- self.listeAAfficher = self.node.item.getListePossible(
- self.listeValeursCourantes
- )
-
- if self.listeAAfficher == []:
- self.ajoutLE(0)
- return
- self.filtreListe()
- if len(self.listeAAfficher) * 20 > 400:
- self.setMinimumHeight(400)
- else:
- if self.monSimpDef.min > len(self.listeAAfficher):
- self.setMinimumHeight(self.monSimpDef.min * 30 + 300)
- elif self.monSimpDef.max > len(self.listeAAfficher):
- self.setMinimumHeight(400)
- else:
- self.setMinimumHeight(len(self.listeAAfficher) * 30 + 30)
- self.setMinimumHeight(300)
- self.adjustSize()
-
- self.politique = PolitiquePlusieurs(self.node, self.editor)
- for i in range(1, len(self.listeAAfficher) + 1):
- self.ajoutLE(i)
- for i in range(len(self.listeAAfficher)):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- courant.setText(str(self.listeAAfficher[i]))
- self.vScrollBar.triggerAction(QScrollBar.SliderToMinimum)
- if len(self.listeAAfficher) < 15 and hasattr(self, "frameRecherche"):
- self.frameRecherche.close()
- if len(self.listeAAfficher) < 15 and hasattr(self, "frameRecherche2"):
- self.frameRecherche2.close()
-
- def setValeurs(self, first=True):
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- if first:
- if self.monSimpDef.max == "**" or self.monSimpDef.max == float("inf"):
- aConstruire = 7
- else:
- aConstruire = self.monSimpDef.max
- if len(self.listeValeursCourantes) > aConstruire:
- aConstruire = len(self.listeValeursCourantes)
- self.indexDernierLabel = aConstruire
- for i in range(1, aConstruire + 1):
- self.ajoutLEResultat(i)
- index = 1
- for val in self.listeValeursCourantes:
- nomLE = "LEResultat" + str(index)
- courant = getattr(self, nomLE)
- courant.setText(str(val))
- courant.setReadOnly(True)
- index = index + 1
- while index < self.indexDernierLabel:
- nomLE = "LEResultat" + str(index)
- courant = getattr(self, nomLE)
- courant.setText("")
- courant.setReadOnly(True)
- index = index + 1
- # self.prepareListeResultat()
-
- def moinsPushed(self):
- self.ouAjouter = self.ouAjouter - 1
- GereListe.moinsPushed(self)
- self.setValeurs(first=False)
-
- def prepareListeResultatFiltre(self):
- for i in self.listeRouge:
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- texte = courant.text()
- palette = QPalette(Qt.black)
- palette.setColor(QPalette.WindowText, Qt.black)
- courant.setPalette(palette)
- courant.setText(texte)
-
- self.listeRouge = []
- filtre = str(self.LEFiltre.text())
- if filtre == "":
- return
- for i in range(len(self.listeAAfficher)):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- texte = courant.text()
- if texte.find(filtre) == 0:
- palette = QPalette(Qt.red)
- palette.setColor(QPalette.WindowText, Qt.red)
- courant.setPalette(palette)
- courant.setText(texte)
- self.listeRouge.append(i)
-
- def cleanListeResultatFiltre(self):
- self.LEFiltre.setText("")
- self.prepareListeResultatFiltre()
-
- def ajoutLEResultat(self, index, valeur=None):
- # print ('ajoutLEResultat', index, valeur)
- nomLE = "LEResultat" + str(index)
- if not (hasattr(self, nomLE)):
- nouveauLE = LECustom(self.scrollAreaRE, self, index)
- nouveauLE.setFrame(False)
- self.CBChoisis.insertWidget(self.ouAjouter, nouveauLE)
- self.ouAjouter = self.ouAjouter + 1
- nouveauLE.setReadOnly(True)
- if index % 2 == 1:
- nouveauLE.setStyleSheet("background:rgb(210,210,210)")
- else:
- nouveauLE.setStyleSheet("background:rgb(240,240,240)")
- self.vScrollBarRE = self.scrollAreaRE.verticalScrollBar()
- self.vScrollBarRE.triggerAction(QScrollBar.SliderToMaximum)
- setattr(self, nomLE, nouveauLE)
- self.estVisibleRE = nouveauLE
- else:
- nouveauLE = getattr(self, nomLE)
-
- if valeur == None:
- nouveauLE.setText("")
- else:
- nouveauLE.setText(str(valeur))
-
- def ajoutLE(self, index, valeur=None):
- # print ('ajoutLE')
- nomLE = "lineEditVal" + str(index)
- nouveauLE = MonLabelListeClic(self)
- # self.CBLayout.addWidget(nouveauLE)
- self.CBLayout.insertWidget(index - 1, nouveauLE)
- self.listeLE.append(nouveauLE)
- nouveauLE.setFrameShape(QFrame.NoFrame)
- QApplication.processEvents()
- nouveauLE.setText("")
- if index % 2 == 1:
- nouveauLE.setStyleSheet("background:rgb(210,210,210)")
- else:
- nouveauLE.setStyleSheet("background:rgb(240,240,240)")
- self.vScrollBar.triggerAction(QScrollBar.SliderToMaximum)
- nouveauLE.setFocus()
- setattr(self, nomLE, nouveauLE)
-
- def ajoutLineEdit(self):
- # print ('ajoutLineEdit')
- self.indexDernierLabel = self.indexDernierLabel + 1
- self.ajoutLEResultat(self.indexDernierLabel)
-
- def traiteClicSurLabelListe(self, valeur):
- if valeur == None:
- return
- liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
- if validite == 0:
- return
- if liste == []:
- return
- listeVal = []
-
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- min, max = self.node.item.getMinMax()
- if len(self.listeValeursCourantes) + 1 > max:
- self.editor.afficheInfos(
- tr("Nombre maximal de valeurs : ") + str(max), Qt.red
- )
- return
- else:
- self.editor.afficheInfos("")
-
- affiche = False
- for i in range(1, self.indexDernierLabel + 1):
- nomLE = "LEResultat" + str(i)
- courant = getattr(self, nomLE)
- if str(courant.text()) == str(""):
- courant.setText(valeur)
- courant.setReadOnly(True)
- affiche = True
- self.estVisibleRE = courant
- QTimer.singleShot(1, self.rendVisibleLigneRE)
- break
-
- if affiche == False:
- self.indexDernierLabel = self.indexDernierLabel + 1
- self.ajoutLEResultat(self.indexDernierLabel, str(valeur))
- self.vScrollBarRE.triggerAction(QScrollBar.SliderToMaximum)
- QTimer.singleShot(1, self.rendVisibleLigneRE)
- self.changeValeur()
- self.setValeurs(first=False)
-
- def changeValeur(self, changeDePlace=False, oblige=False):
- # def changeValeur(self,changeDePlace=False,oblige=False, numero=None):
- # PN les 2 arg sont pour que la signature de ma fonction soit identique a monWidgetPlusieursBase
- listeVal = []
- for i in range(1, self.indexDernierLabel + 1):
- nomLE = "LEResultat" + str(i)
- courant = getattr(self, nomLE)
- valeur = courant.text()
- if str(valeur) == "":
- continue
- liste, validite = SaisieValeur.TraiteLEValeur(self, str(valeur))
- listeVal.append(str(valeur))
-
- validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
- listeVal, -1, []
- )
-
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- min, max = self.node.item.getMinMax()
- if len(self.listeValeursCourantes) < min:
- self.editor.afficheInfos(
- tr("Nombre minimal de valeurs : ") + str(min), Qt.red
- )
- else:
- self.editor.afficheInfos("")
-
- if len(listeRetour) == 0:
- self.node.item.setValeur(None)
- elif validite:
- self.node.item.setValeur(listeRetour)
- else:
- commentaire = comm + " " + comm2
- self.editor.afficheInfos(commentaire, Qt.red)
- self.setValide()
- self.reaffiche()
-
- #
- def rendVisibleLigneRE(self):
- QApplication.processEvents()
- self.estVisibleRE.setFocus()
- self.scrollArea.ensureWidgetVisible(self.estVisibleRE, 0, 0)
-
- #
- def rendVisibleLigne(self):
- self.estVisibleRE = self.estVisible
- # rendVisibleLigneRE()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-import types, re
-
-from PyQt5.QtWidgets import QFrame
-from PyQt5.QtCore import QTimer, QSize, Qt
-from PyQt5.QtGui import QIcon, QBrush, QColor
-
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetPlusieursPlie import Ui_WidgetPlusieursPlie
-
-from .politiquesValidation import PolitiquePlusieurs
-from .qtSaisie import SaisieValeur
-
-pattern_blanc = re.compile(r"^\s*$")
-
-
-class MonWidgetPlusieursPlie(Ui_WidgetPlusieursPlie, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print ("MonWidgetPlusieursBase", nom)
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.AAfficher = self.lineEditVal
- self.maCommande.listeAffichageWidget.append(self.lineEditVal)
- if self.node.item.hasInto():
- self.lineEditVal.setReadOnly(True)
- self.lineEditVal.setStyleSheet("background:rgb(235,235,235);\n")
- self.lineEditVal.setToolTip(
- "Ensemble discret de valeurs possibles, pas de Saisie Manuelle"
- )
- # self.lineEditVal.setPen(QtGui.QColor(0,0,200))
- # b=QBrush(Qt.DiagCrossPattern)
- # b.setColor(QColor(255,100,0))
- # self.lineEditVal.setBrush(b)
- else:
- self.lineEditVal.returnPressed.connect(self.valeurEntree)
- self.BVisuListe.clicked.connect(self.selectWidgetDeplie)
-
- def setValeurs(self):
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- if self.listeValeursCourantes != []:
- self.lineEditVal.setText(str(self.listeValeursCourantes))
- else:
- self.lineEditVal.setText("")
- self.politique = PolitiquePlusieurs(self.node, self.editor)
- return
-
- def selectWidgetDeplie(self):
- self.editor.listeDesListesOuvertes.add(self.node.item)
- self.reaffichePourDeplier()
-
- def valeurEntree(self):
- valeurTexte = self.lineEditVal.text()
- # print (valeurTexte[0])
- # print (valeurTexte[-1])
- if valeurTexte[0] == "[" or valeurTexte[0] == "(":
- valeurTexte = valeurTexte[1:]
- if valeurTexte[-1] == "]" or valeurTexte[-1] == ")":
- valeurTexte = valeurTexte[:-1]
- # print (valeurTexte)
- listeValeursBrutes = valeurTexte.split(",")
- if listeValeursBrutes == [] or listeValeursBrutes == None:
- self.lineEditVal.setText(str(self.listeValeursCourantes))
- return
- listeValeur = []
- for v in listeValeursBrutes:
- if v == None or pattern_blanc.match(v):
- self.editor.afficheInfos(
- str(listeValeur) + " Valeurs saisies incorrectes", Qt.red
- )
- return
- liste, validite = SaisieValeur.TraiteLEValeur(self, str(v))
- if not validite:
- self.editor.afficheInfos(
- str(listeValeur) + " Valeurs saisies incorrectes", Qt.red
- )
- return
- listeValeur.append(liste[0])
- validite, comm, comm2, listeRetour = self.politique.ajoutValeurs(
- listeValeur, -1, []
- )
- if validite:
- self.node.item.setValeur(listeValeur)
- self.node.item.isValid()
- self.setValeurs()
- else:
- self.editor.afficheInfos(str(listeValeur) + " " + comm, Qt.red)
- self.lineEditVal.setText("")
-
-
-class MonWidgetPlusieursPlieASSD(MonWidgetPlusieursPlie):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetPlusieursPlie.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- self.lineEditVal.setReadOnly(True)
-
- def setValeurs(self):
- self.listeValeursCourantes = self.node.item.getListeValeurs()
- self.politique = PolitiquePlusieurs(self.node, self.editor)
- if self.listeValeursCourantes == []:
- self.lineEditVal.setText("")
- return
- txt = "["
- for elt in self.listeValeursCourantes:
- txt = txt + (str(elt)) + ","
- txt = txt + "]"
- self.lineEditVal.setText(txt)
-
- def valeurEntree(self):
- pass
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from PyQt5.QtWidgets import QFrame, QApplication, QFrame, QWidget
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import QSize, Qt, QTimer
-
-from Extensions.i18n import tr
-
-
-from InterfaceQT4.feuille import Feuille
-from InterfaceQT4.politiquesValidation import PolitiquePlusieurs
-from InterfaceQT4.qtSaisie import SaisieValeur
-from InterfaceQT4.gereListe import GereListe
-from InterfaceQT4.gereListe import LECustom
-from Tuple2 import Ui_Tuple2
-from Tuple3 import Ui_Tuple3
-from Tuple4 import Ui_Tuple4
-from Tuple5 import Ui_Tuple5
-from Tuple6 import Ui_Tuple6
-from Tuple7 import Ui_Tuple7
-from Tuple8 import Ui_Tuple8
-from Tuple9 import Ui_Tuple9
-from Tuple10 import Ui_Tuple10
-
-
-# --------------------------
-class TupleCustom(object):
- # --------------------------
-
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------------------------------------
- QWidget.__init__(self, parent)
- self.setupUi(self)
- self.tailleTuple = tailleTuple
- self.parent = parent
- self.parentQt = parentQt
- self.valeur = []
- self.index = index
- self.inFocusOutEvent = False
-
- for i in range(self.tailleTuple):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- courant.num = index
- courant.dansUnTuple = True
- courant.returnPressed.connect(self.valueChange)
- courant.numDsLaListe = i + 1
- courant.tupleCustomParent = self
- courant.parentTuple = self
-
- def valueChange(self):
- # ----------------------
-
- listeVal = []
- for i in range(self.tailleTuple):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- val = str(courant.text())
-
- if str(val) == "" or val == None:
- if not self.inFocusOutEvent:
- courant.setFocus()
- return
-
- try:
- valeur = eval(val, {})
- except:
- try:
- d = self.parentQt.objSimp.jdc.getContexteAvant(
- self.parentQt.objSimp.etape
- )
- valeur = eval(val, d)
- except:
- valeur = val
- listeVal.append(valeur)
- self.valeur = listeVal
- self.parentQt.changeValeur()
-
- def setValeur(self, value):
- # ----------------------
-
- listeVal = []
- valeurNulle = True
- for i in range(self.tailleTuple):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- try:
- if str(value[i]) != "":
- valeurNulle = False
- except:
- pass
-
- try:
- courant.setText(str(value[i]))
- except:
- courant.setText("")
- val = str(courant.text())
- try:
- valeur = eval(val, {})
- except:
- try:
- d = self.parentQt.objSimp.jdc.getContexteAvant(
- self.parentQt.objSimp.etape
- )
- valeur = eval(val, d)
- except:
- valeur = val
- listeVal.append(valeur)
- if valeurNulle == True:
- self.valeur = None
- else:
- self.valeur = listeVal
-
- def getValeurbad(self):
- # ----------------------
- self.valeur = []
- vide = True
- print(self.tailleTuple)
- for i in range(self.tailleTuple):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- self.valeur.append(courant.valeur)
- if courant.valeur != None:
- vide = False
- if vide:
- self.valeur = []
- return self.valeur
-
- def getValeur(self):
- # ----------------------
- return self.valeur
-
- def text(self):
- # --------------
- return self.valeur
-
- def setText(self, value):
- # -----------------------
- self.setValeur(value)
-
- def clean(self):
- # -------------------
- self.valeur = None
- for i in range(self.tailleTuple):
- nomLE = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLE)
- courant.setText("")
-
- def finCommentaire(self):
- # -------------------
- return self.finCommentaireListe()
-
-
-# -------------------------------------------------
-class TupleCustom2(QWidget, Ui_Tuple2, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
- if self.parentQt.editor.maConfiguration.closeParenthese:
- self.label_5.close()
- self.label_7.close()
-
-
-# -------------------------------------------------
-class TupleCustom3(QWidget, Ui_Tuple3, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom4(QWidget, Ui_Tuple4, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom5(QWidget, Ui_Tuple5, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom6(QWidget, Ui_Tuple6, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom7(QWidget, Ui_Tuple7, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom8(QWidget, Ui_Tuple8, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom9(QWidget, Ui_Tuple9, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
-
-
-# -------------------------------------------------
-class TupleCustom10(QWidget, Ui_Tuple10, TupleCustom):
- # -------------------------------------------------
- def __init__(self, tailleTuple, parent, parentQt, index):
- # -------------------
- TupleCustom.__init__(self, tailleTuple, parent, parentQt, index)
- if self.parentQt.editor.maConfiguration.closeParenthese:
- self.label_5.close()
- self.label_7.close()
-
-
-# -------------------------------------------- #
-class MonWidgetPlusieursTuple(Feuille, GereListe):
- # -------------------------------------------- #
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # -----------------------------------------------------
-
- self.indexDernierLabel = 0
- self.numLineEditEnCours = 0
- self.nomLine = "TupleVal"
- self.listeAffichageWidget = []
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- GereListe.__init__(self)
- self.finCommentaireListe()
- self.politique = PolitiquePlusieurs(self.node, self.editor)
- self.parentQt.commandesLayout.insertWidget(-1, self)
-
- if 1:
- # Pour MT
- repIcon = self.node.editor.appliEficas.repIcon
- fichier = os.path.join(repIcon, "arrow_up.png")
- icon = QIcon(fichier)
- self.RBHaut.setIcon(icon)
- 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(fichier3)
- self.BSelectFichier.setIcon(icon3)
- self.BSelectFichier.setIconSize(QSize(32, 32))
- self.BSelectFichier.clicked.connect(self.selectInFile)
-
- def ajoutLineEdit(self, valeur=None, inInit=False):
- # ------------------------------------------------
- self.indexDernierLabel = self.indexDernierLabel + 1
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
- if hasattr(self, nomLineEdit):
- self.indexDernierLabel = self.indexDernierLabel - 1
- return
-
- nomCustomTuple = "TupleCustom" + str(self.nbValeurs)
- laClasseDuTuple = globals()[nomCustomTuple]
- nouveauLE = laClasseDuTuple(
- self.nbValeurs, self.scrollArea, self, self.indexDernierLabel
- )
-
- # if self.nbValeurs == 2 : nouveauLE = TupleCustom2(self.nbValeurs,self.scrollArea,self,self.indexDernierLabel)
- # else : nouveauLE = TupleCustom3(self.nbValeurs,self.scrollArea,self,self.indexDernierLabel)
-
- self.verticalLayoutLE.insertWidget(self.indexDernierLabel - 1, nouveauLE)
- setattr(self, nomLineEdit, nouveauLE)
- if valeur != None:
- nouveauLE.setValeur(valeur)
-
- for i in range(self.nbValeurs):
- num = i + 1
- nomLineEdit = "lineEditVal" + str(num)
- lineEditVal = getattr(nouveauLE, nomLineEdit)
- self.listeAffichageWidget.append(lineEditVal)
- # self.listeAffichageWidget.append(nouveauLE.lineEditVal1)
- # self.listeAffichageWidget.append(nouveauLE.lineEditVal2)
- # if self.nbValeurs == 3 : self.listeAffichageWidget.append(nouveauLE.lineEditVal3)
-
- self.etablitOrdre()
-
- # deux lignes pour que le ensureVisible fonctionne
- self.estVisible = nouveauLE.lineEditVal1
- if inInit == False:
- QTimer.singleShot(1, self.rendVisibleLigne)
-
- def etablitOrdre(self):
- # ---------------------
- i = 0
- while i + 1 < len(self.listeAffichageWidget):
- self.listeAffichageWidget[i].setFocusPolicy(Qt.StrongFocus)
- self.setTabOrder(
- self.listeAffichageWidget[i], self.listeAffichageWidget[i + 1]
- )
- i = i + 1
-
- def setValeurs(self):
- # ---------------------
- if self.editor.code == "PSEN":
- self.RBListePush()
- valeurs = self.node.item.getValeur()
- min, max = self.node.item.getMinMax()
- if max == "**" or max > 8:
- aCreer = 8
- else:
- aCreer = max
-
- if valeurs == () or valeurs == None:
- for i in range(aCreer):
- self.ajoutLineEdit(inInit=True)
- return
-
- for v in valeurs:
- self.ajoutLineEdit(v, inInit=True)
-
- for i in range(len(valeurs), aCreer):
- self.ajoutLineEdit(inInit=True)
-
- def rendVisibleLigne(self):
- # -------------------------
- QApplication.processEvents()
- self.estVisible.setFocus(True)
- self.scrollArea.ensureWidgetVisible(self.estVisible, 0, 0)
-
- def changeValeur(self, changeDePlace=False, oblige=True):
- # -----------------------------------------------------
- # Pour compatibilite signature
- # print ('dschangeValeur', self.indexDernierLabel)
-
- aLeFocus = self.focusWidget()
- listeComplete = []
- libre = False
- # print (self.indexDernierLabel)
- for i in range(self.indexDernierLabel):
- nom = self.nomLine + str(i + 1)
- courant = getattr(self, nom)
- valeurTuple = courant.valeur
- if valeurTuple == None or valeurTuple == "" or valeurTuple == []:
- libre = True
- continue
- validite, comm, comm2, listeRetour = self.politique.ajoutTuple(
- valeurTuple, listeComplete
- )
- if not validite:
- if comm2 != "":
- comm += " " + comm2
- self.editor.afficheInfos(
- comm + " " + str(self.objSimp.definition.validators.typeDesTuples),
- Qt.red,
- )
- return
- listeComplete.append(tuple(courant.valeur))
- # print ('listeComplete', listeComplete)
- if listeComplete == []:
- listeComplete = None
- self.node.item.setValeur(listeComplete)
-
- if changeDePlace:
- return
- min, max = self.node.item.getMinMax()
- if self.indexDernierLabel == max:
- self.editor.afficheInfos(tr("Nb maximum de valeurs atteint"))
- if self.indexDernierLabel < max and libre == False:
- self.ajoutLineEdit()
- self.listeAffichageWidget[-2].setFocus(True)
- else:
- try:
- QApplication.processEvents()
- w = self.listeAffichageWidget[
- self.listeAffichageWidget.index(aLeFocus) + 1
- ]
- w.setFocus(True)
- self.scrollArea.ensureWidgetVisible(w, 0, 0)
- except:
- pass
-
- def echange(self, num1, num2):
- # on donne le focus au a celui ou on a bouge
- # par convention le 2
- nomLineEdit = self.nomLine + str(num1)
- courant = getattr(self, nomLineEdit)
- valeurAGarder = courant.getValeur()
- nomLineEdit2 = self.nomLine + str(num2)
- courant2 = getattr(self, nomLineEdit2)
- courant.setText(courant2.text())
- courant2.setText(valeurAGarder)
- self.changeValeur(changeDePlace=True)
- self.numLineEditEnCours = num2
- self.lineEditEnCours = courant2
- courant2.lineEditVal1.setFocus(True)
-
- 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
- # chaque valeur. d ou l ajout de ajoutNTuple a politique plusieurs
-
- if len(liste) % self.nbValeurs != 0:
- texte = "Nombre incorrect de valeurs"
- self.editor.afficheInfos(tr(texte), Qt.red)
- return
-
- i = 0
- longueur = len(liste) // self.nbValeurs
- increment = self.nbValeurs
- listeFormatee = [
- liste[k * increment : (k + 1) * increment] for k in range(longueur)
- ]
- listeFormatee = tuple(listeFormatee)
-
- min, max = self.node.item.getMinMax()
- if self.objSimp.valeur == None:
- listeComplete = listeFormatee
- else:
- listeComplete = self.objSimp.valeur + listeFormatee
-
- if len(listeComplete) > max:
- texte = tr("Nombre maximum de valeurs ") + str(max) + tr(" atteint")
- self.editor.afficheInfos(texte, Qt.red)
- return
-
- validite, comm, comm2, listeRetour = self.politique.ajoutNTuple(listeComplete)
- if not validite:
- self.editor.afficheInfos(comm + comm2, Qt.red)
- return
-
- # on calcule le dernier lineedit rempli avant de changer la valeur
- if self.objSimp.valeur != None:
- indexDernierRempli = len(self.objSimp.valeur)
- else:
- indexDernierRempli = 0
-
- self.politique.recordValeur(listeComplete)
-
- while i < len(liste):
- try:
- t = tuple(liste[i : i + self.nbValeurs])
- except:
- t = tuple(liste[i : len(liste)])
- i = i + self.nbValeurs
- if indexDernierRempli < self.indexDernierLabel:
- nomLEARemplir = self.nomLine + str(indexDernierRempli + 1)
- LEARemplir = getattr(self, nomLEARemplir)
- for n in range(self.nbValeurs):
- nomLineEdit = "lineEditVal" + str(n + 1)
- lineEditVal = getattr(LEARemplir, nomLineEdit)
- lineEditVal.setText(str(t[n]))
- else:
- # ne pas appeler ajoutLineEdit(t,False ) pb de boucle pb du a etablitOrdre et a listeWidgetAffichage qui bouge
- self.indexDernierLabel = self.indexDernierLabel + 1
- nomLineEdit = self.nomLine + str(self.indexDernierLabel)
-
- nomCustomTuple = "TupleCustom" + str(self.nbValeurs)
- laClasseDuTuple = globals()[nomCustomTuple]
- nouveauLE = laClasseDuTuple(
- self.nbValeurs, self.scrollArea, self, self.indexDernierLabel
- )
-
- self.verticalLayoutLE.insertWidget(
- self.indexDernierLabel - 1, nouveauLE
- )
- setattr(self, nomLineEdit, nouveauLE)
- nouveauLE.setValeur(t)
-
- for n in range(self.nbValeurs):
- nomLineEdit = "lineEditVal" + str(n + 1)
- lineEditVal = getattr(nouveauLE, nomLineEdit)
- self.listeAffichageWidget.append(lineEditVal)
- indexDernierRempli = indexDernierRempli + 1
-
- self.etablitOrdre()
-
- def RBListePush(self):
- # ----------------------
- # PN a rendre generique avec un truc tel prerempli
- # pour l instant specifique PSEN
-
- if self.editor.code == "VP":
- return
- if self.objSimp.valeur != None and self.objSimp.valeur != []:
- return
- if not hasattr(self.editor.readercata.cata, "sd_ligne"):
- self.editor.readercata.cata.sd_ligne = None
- if not hasattr(self.editor.readercata.cata, "sd_generateur"):
- self.editor.readercata.cata.sd_generateur = None
- if not hasattr(self.editor.readercata.cata, "sd_transfo"):
- self.editor.readercata.cata.sd_transfo = None
- if not hasattr(self.editor.readercata.cata, "sd_charge"):
- self.editor.readercata.cata.sd_charge = None
- if not hasattr(self.editor.readercata.cata, "sd_moteur"):
- self.editor.readercata.cata.sd_moteur = None
- if (
- self.objSimp.definition.validators.typeDesTuples[0]
- == self.editor.readercata.cata.sd_ligne
- ):
- val = []
- if hasattr(self.objSimp.jdc, "LineDico"):
- for k in self.objSimp.jdc.LineDico:
- try:
- valeur = self.objSimp.jdc.getConcept(k)
- val.append((valeur, 0))
- except:
- pass
- self.node.item.setValeur(val)
- if (
- self.objSimp.definition.validators.typeDesTuples[0]
- == self.editor.readercata.cata.sd_generateur
- ):
- val = []
- if hasattr(self.objSimp.jdc, "MachineDico"):
- for k in self.objSimp.jdc.MachineDico:
- try:
- valeur = self.objSimp.jdc.getConcept(k)
- val.append((valeur, 0))
- except:
- pass
- self.node.item.setValeur(val)
- if (
- self.objSimp.definition.validators.typeDesTuples[0]
- == self.editor.readercata.cata.sd_transfo
- ):
- val = []
- if hasattr(self.objSimp.jdc, "TransfoDico"):
- for k in self.objSimp.jdc.TransfoDico:
- try:
- valeur = self.objSimp.jdc.getConcept(k)
- val.append((valeur, 0))
- except:
- pass
- self.node.item.setValeur(val)
- if (
- self.objSimp.definition.validators.typeDesTuples[0]
- == self.editor.readercata.cata.sd_charge
- ):
- val = []
- if hasattr(self.objSimp.jdc, "LoadDico"):
- for k in self.objSimp.jdc.LoadDico:
- try:
- valeur = self.objSimp.jdc.getConcept(k)
- val.append((valeur, 0))
- except:
- pass
- self.node.item.setValeur(val)
- if (
- self.objSimp.definition.validators.typeDesTuples[0]
- == self.editor.readercata.cata.sd_moteur
- ):
- val = []
- if hasattr(self.objSimp.jdc, "MotorDico"):
- for k in self.objSimp.jdc.MotorDico:
- try:
- valeur = self.objSimp.jdc.getConcept(k)
- val.append((valeur, 0))
- except:
- pass
- self.node.item.setValeur(val)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from .feuille import Feuille
-from .monWidgetPlusieursTuple import MonWidgetPlusieursTuple
-from desWidgetPlusieursTuple import Ui_WidgetPlusieursTuple
-
-
-class MonWidgetPlusieursTuple2(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 2
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple3(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 3
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple4(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 4
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple5(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 5
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple6(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 6
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple7(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 7
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple8(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 8
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple9(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 9
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetPlusieursTuple10(Ui_WidgetPlusieursTuple, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 10
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 types
-
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QWidget
-
-# Modules Eficas
-
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetRadioButton import Ui_WidgetRadioButton
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-
-
-class MonWidgetRadioButtonCommun(Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.setMaxI()
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.politique = PolitiqueUnique(self.node, self.editor)
- self.dict_bouton = {}
- self.determineChoix()
- self.setValeursApresBouton()
- if hasattr(self.parentQt, "commandesLayout"):
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.AAfficher = self.radioButton_1
- self.maCommande.listeAffichageWidget.append(self.radioButton_1)
-
- def setValeursApresBouton(self):
- if self.objSimp.getValeur() == None:
- return
- valeur = self.objSimp.getValeur()
- if not (isinstance(valeur, str)):
- valeur = str(valeur)
- try:
- self.dict_bouton[valeur].setChecked(True)
- self.dict_bouton[valeur].setFocus(True)
- except:
- pass
-
- def determineChoix(self):
- self.horizontalLayout.setAlignment(Qt.AlignLeft)
- i = 1
- j = len(self.maListeDeValeur)
- if j > self.maxI:
- print("poumbadaboum")
- return
- while i < j + 1:
- nomBouton = "radioButton_" + str(i)
- bouton = getattr(self, nomBouton)
- valeur = self.maListeDeValeur[i - 1]
- if not (isinstance(valeur, str)):
- valeur = str(valeur)
- bouton.setText(tr(valeur))
- self.dict_bouton[valeur] = bouton
- bouton.clicked.connect(self.boutonclic)
- bouton.keyPressEvent = self.keyPressEvent
- setattr(self, nomBouton, bouton)
- i = i + 1
- while i < self.maxI + 1:
- nomBouton = "radioButton_" + str(i)
- bouton = getattr(self, nomBouton)
- bouton.close()
- i = i + 1
-
- def boutonclic(self):
- for valeur in self.dict_bouton:
- if self.dict_bouton[valeur].isChecked():
- SaisieValeur.LEvaleurPressed(self, valeur)
- self.reaffiche()
-
- def keyPressEvent(self, event):
- if event.key() == Qt.Key_Right:
- self.selectSuivant()
- return
- if event.key() == Qt.Key_Left:
- self.selectPrecedent()
- return
- if event.key() == Qt.Key_Return or event.key() == Qt.Key_Space:
- self.checkFocused()
- return
- QWidget.keyPressEvent(self, event)
-
- def selectSuivant(self):
- aLeFocus = self.focusWidget()
- nom = aLeFocus.objectName()[12:]
- i = int(nom) + 1
- if i == len(self.maListeDeValeur) + 1:
- i = 1
- nomBouton = "radioButton_" + str(i)
- courant = getattr(self, nomBouton)
- courant.setFocus(True)
-
- def selectPrecedent(self):
- aLeFocus = self.focusWidget()
- nom = aLeFocus.objectName()[12:]
- i = int(nom) - 1
- if i == 0:
- i = len(self.maListeDeValeur)
- nomBouton = "radioButton_" + str(i)
- courant = getattr(self, nomBouton)
- courant.setFocus(True)
-
- def checkFocused(self):
- aLeFocus = self.focusWidget()
- nom = aLeFocus.objectName()[12:]
- i = int(nom)
- if i > 0 and i <= len(self.maListeDeValeur):
- nomBouton = "radioButton_" + str(i)
- courant = getattr(self, nomBouton)
- if not courant.isChecked():
- courant.setChecked(True)
- self.boutonclic()
-
-
-class MonWidgetRadioButton(Ui_WidgetRadioButton, MonWidgetRadioButtonCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print "MonWidgetRadioButton ", self
- if type(monSimpDef.into) == types.FunctionType:
- self.maListeDeValeur = monSimpDef.into()
- else:
- self.maListeDeValeur = monSimpDef.into
-
- MonWidgetRadioButtonCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def setMaxI(self):
- self.maxI = 3
-
-
-class MonWidgetRadioButtonSD(Ui_WidgetRadioButton, MonWidgetRadioButtonCommun):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print "dans le init de MonWidgetRadioButtonSD",self
- self.maListeDeValeur = node.item.getSdAvantDuBonType()
- MonWidgetRadioButtonCommun.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- def setMaxI(self):
- self.maxI = 3
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from PyQt5.QtWidgets import QLineEdit
-from PyQt5.QtCore import Qt
-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.LESDCO.returnPressed.connect(self.LESDCOReturnPressed)
- self.LBSDCO.itemDoubleClicked.connect(self.LBSDCODoubleClicked)
-
- def LESDCOReturnPressed(self):
- self.LBSDCO.clearSelection()
- SaisieSDCO.LESDCOReturnPressed(self)
-
- def initLBSDCO(self):
- listeNomsSDCO = self.node.item.getSdAvantDuBonType()
- for aSDCO in listeNomsSDCO:
- self.LBSDCO.insertItem(1, aSDCO)
- valeur = self.node.item.getValeur()
- if valeur != "" and valeur != None:
- self.LESDCO.setText(str(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.initModif()
- anc_val = self.node.item.getValeur()
- test_CO = self.node.item.isCO(anc_val)
-
- valeur, validite = self.node.item.evalValeur(nomConcept)
- test = self.node.item.setValeur(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.deleteValeurCo(valeur=anc_val)
- self.node.item.object.etape.getType_produit(force=1)
- self.node.item.object.etape.parent.resetContext()
- self.LESDCO.setText(nomConcept)
- else:
- commentaire = self.node.item.getCr()
- self.reset_old_valeur(anc_val, mess=mess)
- self.editor.afficheInfos(commentaire, Qt.red)
- self.Commentaire.setText(tr(commentaire))
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from PyQt5.QtWidgets import QLineEdit
-from PyQt5.QtCore import Qt
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetSimpBase import Ui_WidgetSimpBase
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-
-
-class MonWidgetSimpBase(Ui_WidgetSimpBase, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- if "R" or "I" in self.monSimpDef.type:
- self.lineEditVal.setMinimumWidth(525)
- if hasattr(self.parentQt, "commandesLayout"):
- self.parentQt.commandesLayout.insertWidget(-1, self, 1)
- self.setFocusPolicy(Qt.StrongFocus)
- # si on a un heritage malencontreux
- if hasattr(self, "lineEditVal"):
- if monSimpDef.homo == "constant":
- self.lineEditVal.setReadOnly(True)
- self.lineEditVal.setStyleSheet(
- "background:rgb(210,235,235);\n" "border:0px;"
- )
- else:
- self.lineEditVal.returnPressed.connect(self.LEvaleurPressed)
- self.AAfficher = self.lineEditVal
- self.maCommande.listeAffichageWidget.append(self.lineEditVal)
- self.lineEditVal.focusInEvent = self.monFocusInEvent
- self.lineEditVal.focusOutEvent = self.monFocusOutEvent
-
- def monFocusInEvent(self, event):
- self.editor.nodeEnCours = self
- QLineEdit.focusInEvent(self.lineEditVal, event)
-
- def monFocusOutEvent(self, event):
- if self.oldValeurTexte != self.lineEditVal.text():
- self.oldValeurTexte = self.lineEditVal.text()
- self.LEvaleurPressed()
- QLineEdit.focusOutEvent(self.lineEditVal, event)
-
- def setValeurs(self):
- self.oldValeurTexte = ""
- self.politique = PolitiqueUnique(self.node, self.editor)
- valeur = self.node.item.getValeur()
- valeurTexte = self.politique.getValeurTexte(valeur)
- chaine = ""
-
- if valeurTexte != None:
- from decimal import Decimal
-
- if isinstance(valeurTexte, Decimal):
- chaine = str(valeurTexte)
- elif repr(valeurTexte.__class__).find("PARAMETRE") > 0:
- chaine = repr(valeur)
- else:
- chaine = str(valeurTexte)
- self.oldValeurTexte = chaine
- self.lineEditVal.setText(chaine)
-
- def finCommentaire(self):
- mc = self.objSimp.definition
- d_aides = {
- "TXM": tr("Une chaine de caracteres est attendue. "),
- "R": tr("Un reel est attendu. "),
- "I": tr("Un entier est attendu. "),
- "Matrice": tr("Une Matrice est attendue. "),
- "Fichier": tr("Un fichier est attendu. "),
- "FichierNoAbs": tr("Un fichier est attendu. "),
- "Repertoire": tr("Un repertoire est attendu. "),
- "FichierOuRepertoire": tr("Un repertoire ou un fichier est attendu. "),
- "Heure": tr("Heure sous la forme HH:MM"),
- "Date": tr("Date sous la forme JJ/MM/AA"),
- }
- if mc.type[0] != type:
- commentaire = d_aides.get(mc.type[0], tr("Type de base inconnu"))
- else:
- commentaire = ""
- return commentaire
-
- def LEvaleurPressed(self):
- # pour les soucis d encoding
- try:
- if (
- str(self.lineEditVal.text()) == ""
- or str(self.lineEditVal.text()) == None
- ):
- return
- except:
- pass
- SaisieValeur.LEvaleurPressed(self)
- # self.parentQt.donneFocus()
- self.setValeurs()
- self.reaffiche()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from PyQt5.QtWidgets import QRadioButton
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetSimpBool import Ui_WidgetSimpBool
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-
-
-class MonWidgetSimpBool(Ui_WidgetSimpBool, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.politique = PolitiqueUnique(self.node, self.editor)
- self.RBTrue.clicked.connect(self.boutonTrueClic)
- self.RBFalse.clicked.connect(self.boutonFalseClic)
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.maCommande.listeAffichageWidget.append(self.RBTrue)
- self.AAfficher = self.RBTrue
-
- def setValeurs(self):
- valeur = self.node.item.getValeur()
- if valeur == None:
- return
- if valeur == True:
- self.RBTrue.setChecked(True)
- if valeur == False:
- self.RBFalse.setChecked(True)
- if self.monSimpDef.homo == "constant":
- if valeur == True:
- self.RBFalse.setDisabled(True)
- else:
- self.RBTrue.setDisabled(True)
-
- def boutonTrueClic(self):
- SaisieValeur.LEvaleurPressed(self, True)
- self.reaffiche()
-
- def boutonFalseClic(self):
- SaisieValeur.LEvaleurPressed(self, False)
- self.reaffiche()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import locale
-
-# Modules Eficas
-from PyQt5.QtWidgets import QLineEdit, QRadioButton
-from PyQt5.QtCore import Qt
-
-
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetSimpComplexe import Ui_WidgetSimpComplexe
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-
-
-class MonWidgetSimpComplexe(Ui_WidgetSimpComplexe, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.setFocusPolicy(Qt.StrongFocus)
- self.LEImag.returnPressed.connect(self.LEImagRPressed)
- self.LEReel.returnPressed.connect(self.LEReelRPressed)
- self.RBRI.clicked.connect(self.valeurPressed)
- self.RBMP.clicked.connect(self.valeurPressed)
- self.maCommande.listeAffichageWidget.append(self.RBRI)
- self.maCommande.listeAffichageWidget.append(self.RBMP)
- self.maCommande.listeAffichageWidget.append(self.LEReel)
- self.maCommande.listeAffichageWidget.append(self.LEImag)
-
- def setValeurs(self):
- self.politique = PolitiqueUnique(self.node, self.editor)
- valeur = self.node.item.getValeur()
- if valeur == None or valeur == "":
- return
- if type(valeur) not in (list, tuple):
- self.LEComp.setText(str(valeur))
- commentaire = tr("complexe form deprecated, od value : ", valeur)
- self.editor.afficheInfos(commentaire, Qt.red)
- else:
- typ_cplx, x1, x2 = valeur
- self.LEReel.setText(str(x1))
- self.LEImag.setText(str(x2))
- if typ_cplx == "RI":
- self.RBRI.setChecked(1)
- else:
- self.RBMP.setChecked(1)
-
- # def LECompRPressed(self) :
- # self.LEReel.clear()
- # self.LEImag.clear()
- # commentaire=tr("expression valide")
- # valeur = str(self.LEComp.text())
- # d={}
- # if 1 :
- # try :
- # v=eval(valeur,d)
- # except :
- # commentaire=tr("expression invalide")
- # self.editor.afficheInfos(commentaire,Qt.red)
- # return
- # try :
- # i=v.imag
- # self.editor.afficheInfos(commentaire)
- # self.valeurPressed()
- # except :
- # commentaire=tr("l expression n est pas de la forme a+bj")
- # self.editor.afficheInfos(commentaire,Qt.red)
-
- def LEReelRPressed(self):
- # self.LEComp.clear()
- commentaire = tr("expression valide")
- valeur = str(self.LEReel.text())
- try:
- a = locale.atof(valeur)
- self.editor.afficheInfos(commentaire)
- except:
- commentaire = tr("expression invalide")
- self.editor.afficheInfos(commentaire, Qt.red)
- if self.LEImag.text() != "":
- self.valeurPressed()
- else:
- self.LEImag.setFocus(True)
-
- def LEImagRPressed(self):
- commentaire = tr("expression valide")
- valeur = str(self.LEImag.text())
- try:
- a = locale.atof(valeur)
- self.editor.afficheInfos(commentaire)
- except:
- commentaire = tr("expression invalide")
- self.editor.afficheInfos(commentaire, Qt.red)
- if self.LEReel.text() != "":
- self.valeurPressed()
- else:
- self.LEReel.setFocus(True)
-
- def finCommentaire(self):
- commentaire = "valeur de type complexe"
- return commentaire
-
- # def getValeurComp(self):
- # commentaire=tr("expression valide")
- # valeur = str(self.LEComp.text())
- # d={}
- # try :
- # v=eval(valeur,d)
- # except :
- # commentaire=tr("expression invalide")
- # self.editor.afficheInfos(commentaire,Qt.red)
- # return None
- # try :
- # i=v.imag
- # except :
- # commentaire=tr("expression n est pas de la forme a+bj")
- # self.editor.afficheInfos(commentaire,Qt.red)
- # return None
- # return v
-
- def valeurPressed(self):
- if self.LEReel.text() == "" and self.LEImag.text() == "":
- self.LEReel.setFocus(True)
- if self.LEReel.text() == "" and self.LEImag.text() != "":
- self.LEReel.setFocus(True)
- if self.LEReel.text() != "" and self.LEImag.text() == "":
- self.LEImag.setFocus(True)
- valeur = self.getValeurRI()
- self.politique.recordValeur(valeur)
- self.reaffiche()
- self.parentQt.donneFocus()
-
- def getValeurRI(self):
- """
- Retourne le complexe saisi par l'utilisateur
- """
- l = []
- if self.RBMP.isChecked() == 1:
- l.append("MP")
- elif self.RBRI.isChecked() == 1:
- l.append("RI")
- else:
- self.editor.afficheInfos(commentaire, Qt.red)
- self.RBMP.setFocus(True)
- return None
- try:
- l.append(locale.atof(str(self.LEReel.text())))
- l.append(locale.atof(str(self.LEImag.text())))
- except:
- return None
- return repr(tuple(l))
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-import os, sys
-
-# Modules Eficas
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import QSize
-from Extensions.i18n import tr
-
-from desWidgetSimpFichier import Ui_WidgetSimpFichier
-from .monWidgetSimpBase import MonWidgetSimpBase
-
-
-class MonWidgetSimpFichier(Ui_WidgetSimpFichier, MonWidgetSimpBase):
- # c est juste la taille des differents widgets de base qui change
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetSimpBase.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- if sys.platform[0:5] != "linux":
- repIcon = self.node.editor.appliEficas.repIcon
- fichier = os.path.join(repIcon, "file-explorer.png")
- icon = QIcon(fichier)
- self.BFichier.setIcon(icon)
- self.BFichier.setIconSize(QSize(32, 32))
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from PyQt5.QtWidgets import QLineEdit
-from PyQt5.QtCore import Qt
-
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetSimpSalome import Ui_WidgetSimpSalome
-from .politiquesValidation import PolitiqueUnique
-from .qtSaisie import SaisieValeur
-
-
-class MonWidgetSimpSalome(Ui_WidgetSimpSalome, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.parentQt.commandesLayout.insertWidget(-1, self, 1)
- self.setFocusPolicy(Qt.StrongFocus)
- self.politique = PolitiqueUnique(self.node, self.editor)
- self.lineEditVal.returnPressed.connect(self.LEvaleurPressed)
- self.AAfficher = self.lineEditVal
- self.maCommande.listeAffichageWidget.append(self.lineEditVal)
-
- def LEvaleurPressed(self):
- if str(self.lineEditVal.text()) == "" or str(self.lineEditVal.text()) == None:
- return
- SaisieValeur.LEvaleurPressed(self)
- self.parentQt.donneFocus()
- self.setValeurs()
- self.reaffiche()
-
- def setValeurs(self):
- valeur = self.node.item.getValeur()
- if valeur != None:
- self.lineEditVal.setText(str(valeur))
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-from PyQt5.QtCore import Qt
-
-# Modules Eficas
-from Extensions.i18n import tr
-
-from InterfaceQT4.feuille import Feuille
-from InterfaceQT4.politiquesValidation import PolitiqueUnique
-from InterfaceQT4.qtSaisie import SaisieValeur
-
-
-class MonWidgetSimpTuple(Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.politique = PolitiqueUnique(self.node, self.editor)
- self.parentQt.commandesLayout.insertWidget(-1, self)
- self.setFocusPolicy(Qt.StrongFocus)
-
- def setValeurs(self):
- valeur = self.node.item.getValeur()
- for i in range(self.nbValeurs):
- nomLineEdit = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLineEdit)
- if valeur != None:
- courant.setText(str(valeur[i]))
- setattr(self, nomLineEdit, courant)
- courant.returnPressed.connect(self.valeursPressed)
-
- def valeursPressed(self):
- aLeFocus = self.focusWidget()
- self.editor.afficheInfos("")
- texteValeur = ""
- for i in range(self.nbValeurs):
- nomLineEdit = "lineEditVal" + str(i + 1)
- courant = getattr(self, nomLineEdit)
- if courant.text() == "" or courant.text() == None:
- courant.setFocus(True)
- return
- s = str(courant.text())
- if hasattr(self.objSimp.definition.validators, "typeDesTuples"):
- if self.objSimp.definition.validators.typeDesTuples[i] == "R":
- if s.find(".") == -1 and s.find("e") == -1 and s.find("E") == -1:
- s = s + ".0"
- courant.setText(s)
- if self.objSimp.definition.validators.typeDesTuples[i] == "TXM":
- if s[0] != '"' and s[0] != "'":
- if s[-1] == "'":
- s = "'" + s
- else:
- s = '"' + s
- if s[-1] != '"' and s[-1] != "'":
- if s[0] == "'":
- s = s + "'"
- else:
- s = s + '"'
- courant.setText(s)
- texteValeur += str(courant.text())
- # print (texteValeur)
- if i + 1 != self.nbValeurs:
- texteValeur += ","
- validite, commentaire = self.politique.recordValeur(texteValeur)
- if not validite:
- self.editor.afficheInfos(
- commentaire
- + " "
- + str(self.objSimp.definition.validators.typeDesTuples),
- Qt.red,
- )
-
- # Passage au champ suivant
- nom = aLeFocus.objectName()[11:]
- try:
- i = int(nom) + 1
- except:
- try:
- i = i + 1
- except:
- return
- if i == self.nbValeurs + 1:
- i = 1
- nomLineEdit = "lineEditVal" + str(i)
- courant = getattr(self, nomLineEdit)
- courant.setFocus(True)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-# from PyQt4.QtGui import *
-# from PyQt4.QtCore import *
-from Extensions.i18n import tr
-
-from InterfaceQT4.feuille import Feuille
-from InterfaceQT4.monWidgetSimpTuple import MonWidgetSimpTuple
-from desWidgetTuple2 import Ui_WidgetTuple2
-from desWidgetTuple3 import Ui_WidgetTuple3
-from desWidgetTuple4 import Ui_WidgetTuple4
-from desWidgetTuple5 import Ui_WidgetTuple5
-from desWidgetTuple6 import Ui_WidgetTuple6
-from desWidgetTuple7 import Ui_WidgetTuple7
-from desWidgetTuple8 import Ui_WidgetTuple8
-from desWidgetTuple9 import Ui_WidgetTuple9
-from desWidgetTuple10 import Ui_WidgetTuple10
-
-
-class MonWidgetSimpTuple2(Ui_WidgetTuple2, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 2
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- if self.objSimp.isImmuable():
- self.lineEditVal1.setDisabled(True)
- self.lineEditVal2.setDisabled(True)
- self.lineEditVal1.setStyleSheet(
- "background:rgb(244,244,244);\n" "border:0px;\n"
- )
- self.lineEditVal2.setStyleSheet(
- "background:rgb(244,244,244);\n" "border:0px;\n"
- )
- self.lineEditVal1.setToolTip(tr("Valeur non modifiable"))
- self.lineEditVal2.setToolTip(tr("Valeur non modifiable"))
- else:
- self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
-
-
-class MonWidgetSimpTuple3(Ui_WidgetTuple3, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 3
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
- if self.objSimp.isImmuable():
- self.lineEditVal1.setDisabled(True)
- self.lineEditVal2.setDisabled(True)
- self.lineEditVal3.setDisabled(True)
- self.lineEditVal1.setStyleSheet(
- "background:rgb(244,244,244);\n" "border:0px;\n"
- )
- self.lineEditVal2.setStyleSheet(
- "background:rgb(244,244,244);\n" "border:0px;\n"
- )
- self.lineEditVal3.setStyleSheet(
- "background:rgb(244,244,244);\n" "border:0px;\n"
- )
- self.lineEditVal1.setToolTip(tr("Valeur non modifiable"))
- self.lineEditVal2.setToolTip(tr("Valeur non modifiable"))
- self.lineEditVal3.setToolTip(tr("Valeur non modifiable"))
- else:
- self.maCommande.listeAffichageWidget.append(self.lineEditVal1)
-
-
-class MonWidgetSimpTuple4(Ui_WidgetTuple4, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- # print (self,node,monSimpDef,nom,objSimp,parentQt,commande)
- self.nbValeurs = 4
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetSimpTuple5(Ui_WidgetTuple5, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 5
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetSimpTuple6(Ui_WidgetTuple6, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 6
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetSimpTuple7(Ui_WidgetTuple7, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 7
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetSimpTuple8(Ui_WidgetTuple8, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 8
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetSimpTuple9(Ui_WidgetTuple9, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 9
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
-
-class MonWidgetSimpTuple10(Ui_WidgetTuple10, MonWidgetSimpTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = 10
- MonWidgetSimpTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from Extensions.i18n import tr
-
-from desWidgetSimpTxt import Ui_WidgetSimpTxt
-from .monWidgetSimpBase import MonWidgetSimpBase
-
-
-class MonWidgetSimpTxt(Ui_WidgetSimpTxt, MonWidgetSimpBase):
- # c est juste la taille des differents widgets de base qui change
-
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- MonWidgetSimpBase.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from PyQt5.QtWidgets import QLabel, QSizePolicy, QSpacerItem
-from PyQt5.QtCore import QSize
-
-from InterfaceQT4.feuille import Feuille
-from InterfaceQT4.monWidgetPlusieursTuple import MonWidgetPlusieursTuple
-from desWidgetPlusieursTuple import Ui_WidgetPlusieursTuple
-from desWidgetTableau import Ui_WidgetTableau
-
-maxLen = 3
-
-
-class MonWidgetTableau(Ui_WidgetTableau, MonWidgetPlusieursTuple):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- self.nbValeurs = len(monSimpDef.homo)
- MonWidgetPlusieursTuple.__init__(
- self, node, monSimpDef, nom, objSimp, parentQt, commande
- )
-
- sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
-
- for i in range(len(monSimpDef.homo)):
- nomCol = "LECol" + str(i + 1)
- objCol = QLabel(self)
- objCol.setMinimumSize(QSize(80, 25))
- objCol.setText(monSimpDef.homo[i])
- self.LATitre.addWidget(objCol)
- setattr(self, nomCol, objCol)
- spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
- self.LATitre.addItem(spacerItem)
- self.resize(self.width(), 1800)
-
- def ajoutLineEdit(self, valeur=None, inInit=False):
- hauteurAvant = self.frame.height()
- MonWidgetPlusieursTuple.ajoutLineEdit(self, valeur, inInit)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-
-# 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.getValeur()
- if valeur != "" and valeur != None:
- self.LESDCO.setText(valeur.nom)
- self.connect(self.LESDCO, SIGNAL("returnPressed()"), self.LESDCOReturnPressed)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 Eficas
-from Extensions.i18n import tr
-
-from .feuille import Feuille
-from desWidgetVide import Ui_WidgetVide
-from InterfaceQT4.politiquesValidation import PolitiqueUnique
-
-
-class MonWidgetVide(Ui_WidgetVide, Feuille):
- def __init__(self, node, monSimpDef, nom, objSimp, parentQt, commande):
- Feuille.__init__(self, node, monSimpDef, nom, objSimp, parentQt, commande)
- self.politique = PolitiqueUnique(self.node, self.editor)
- t = self.node.item.object.definition.type[0].__name__
- self.lineEditVal.setText("Attend un objet de type " + t + ". Il faut en créer")
- self.parentQt.commandesLayout.insertWidget(-1, self)
- # PN il faut remplir le type
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-from Accas import PARAMETRE
-from Extensions.i18n import tr
-
-
-# ---------------------
-class Validation(object):
-# ---------------------
- def __init__(self, node, parent):
- self.node = node
- self.parent = parent
-
- def testeUneValeur(self, valeurentree):
- commentaire = None
- # import traceback
- # traceback.print_stack()
- valeur, validite = self.node.item.evalValeur(valeurentree)
- if not validite:
- commentaire = "impossible d'evaluer : %s " % repr(valeurentree)
- return valeur, validite, commentaire
- if self.node.item.waitTxm() and not (type(valeur) == str):
- valeur = str(valeur)
-
- testtype, commentaire = self.node.item.object.verifType(valeur)
- if not testtype:
- return valeur, 0, commentaire
-
- valide = self.node.item.valideItem(valeur)
- if type(valide) == tuple:
- validite, commentaire = valide
- else:
- validite = valide
- commentaire = " "
-
- if not validite and commentaire is None:
- commentaire = "impossible d'evaluer : %s " % repr(valeurentree)
- # print ('ds testeUneValeur', valeur, validite, commentaire)
- return valeur, validite, commentaire
-
- # ----------------------------------------------------------------------------------------
- # Methodes utilisees pour la manipulation des items en notation scientifique
- # a mettre au point
- # ----------------------------------------------------------------------------------------
- def setValeurTexte(self, texteValeur):
- try:
- if "R" in self.node.item.object.definition.type:
- if texteValeur[0] != "'":
- clef = eval(texteValeur)
- if str(clef) != str(texteValeur):
- self.node.item.object.initModif()
- clefobj = self.node.item.object.getNomConcept()
- if not clefobj in self.parent.appliEficas.dict_reels:
- self.parent.appliEficas.dict_reels[clefobj] = {}
- self.parent.appliEficas.dict_reels[clefobj][clef] = texteValeur
- self.parent.appliEficas.dict_reels[clefobj]
- if clefobj == "":
- if (
- not self.node.item.object.etape
- in self.parent.appliEficas.dict_reels
- ):
- self.parent.appliEficas.dict_reels[
- self.node.item.object.etape
- ] = {}
- self.parent.appliEficas.dict_reels[
- self.node.item.object.etape
- ][clef] = texteValeur
- self.node.item.object.finModif()
- except:
- pass
-
- def getValeurTexte(self, valeur):
- valeurTexte = valeur
- if valeur == None:
- return valeur
- from decimal import Decimal
-
- if isinstance(valeur, Decimal):
- if self.node.waitTxm() and not self.isParam(valeur):
- return "'" + str(valeur) + "'"
- else:
- return valeur
- if "R" in self.node.item.object.definition.type:
- clefobj = self.node.item.object.getNomConcept()
- if clefobj in self.parent.appliEficas.dict_reels:
- if valeur in self.parent.appliEficas.dict_reels[clefobj]:
- valeurTexte = self.parent.appliEficas.dict_reels[clefobj][valeur]
- else:
- if (
- str(valeur).find(".") == -1
- and str(valeur).find("e") == -1
- and str(valeur).find("E")
- ):
- # aucun '.' n'a ete trouve dans valeur --> on en rajoute un a la fin
- if self.isParam(valeur):
- return valeur
- else:
- try:
- val2 = eval(str(valeur) + ".")
- except:
- pass
- return valeurTexte
-
- def isParam(self, valeur):
- for param in self.node.item.jdc.params:
- if (repr(param) == repr(valeur)) or (str(param) == str(valeur)):
- return 1
- return 0
-
- def ajoutDsDictReel(self, texteValeur):
- # le try except est necessaire pour saisir les parametres
- # on enleve l erreur de saisie 00 pour 0
- if str(texteValeur) == "00":
- return
- try:
- if "R" in self.node.item.object.definition.type:
- if str(texteValeur)[0] != "'":
- clef = eval(texteValeur)
- if str(clef) != str(texteValeur):
- clefobj = self.node.item.object.getNomConcept()
- if not clefobj in self.parent.appliEficas:
- self.parent.appliEficas.dict_reels[clefobj] = {}
- self.parent.appliEficas.dict_reels[clefobj][clef] = texteValeur
- if clefobj == "":
- if (
- not self.node.item.object.etape
- in self.parent.appliEficas.dict_reels
- ):
- self.parent.appliEficas.dict_reels[
- self.node.item.object.etape
- ] = {}
- self.parent.appliEficas.dict_reels[
- self.node.item.object.etape
- ][clef] = texteValeur
-
- except:
- pass
-
- def ajoutDsDictReelEtape(self):
- try:
- if self.node.item.object in self.parent.appliEficas.dict_reels:
- self.parent.appliEficas.dict_reels[
- self.node.item.sdnom
- ] = self.parent.appliEficas.dict_reels[self.node.item.object]
- del self.parent.appliEficas.dict_reels[self.node.item.object]
- except:
- pass
-
-
-# ------------------------------------
-class PolitiqueUnique(Validation):
- # ------------------------------------
- """
- classe servant pour les entrees ne demandant qu un mot clef
- """
-
- def __init__(self, node, parent):
- Validation.__init__(self, node, parent)
-
- def recordValeur(self, valeurentree):
- if self.parent.modified == "n":
- self.parent.initModif()
- ancienneVal = self.node.item.getValeur()
- valeur, validite, commentaire = self.testeUneValeur(valeurentree)
- if (
- validite
- and ("R" in self.node.item.object.definition.type)
- and not (isinstance(valeur, PARAMETRE))
- ):
- s = valeurentree
- if s.find(".") == -1 and s.find("e") == -1 and s.find("E") == -1:
- s = s + "."
- valeur, validite, commentaire = self.testeUneValeur(s)
- if validite:
- validite = self.node.item.setValeur(valeur)
- if self.node.item.isValid():
- commentaire = tr("Valeur du mot-cle enregistree")
- # commentaire = "Valeur du mot-cle enregistree"
- self.setValeurTexte(str(valeurentree))
- else:
- cr = self.node.item.getCr()
- commentaire = tr("Valeur du mot-cle non autorisee ") + cr.getMessFatal()
- self.node.item.setValeur(ancienneVal)
- return validite, commentaire
-
-
-# --------------------------------------
-class PolitiquePlusieurs(Validation):
- # --------------------------------------
- """
- classe servant pour les entrees ne demandant qu un mot clef
- """
-
- def __init__(self, node, parent):
- # print "ds PolitiquePlusieurs"
- self.node = node
- self.parent = parent
- # print self.node
- # print self.parent
-
- def ajoutValeurs(self, listevaleur, index, listecourante):
- listeRetour = []
- commentaire = "Nouvelle valeur acceptee"
- commentaire2 = ""
- valide = 1
- if listevaleur == None:
- return
- if listevaleur == "":
- return
- if not (type(listevaleur) in (list, tuple)):
- listevaleur = tuple(listevaleur)
- # on verifie que la cardinalite max n a pas ete atteinte
- min, max = self.node.item.getMinMax()
- if len(listecourante) + len(listevaleur) > max:
- commentaire = (
- "La liste atteint le nombre maximum d'elements : "
- + str(max)
- + " ,ajout refuse"
- )
- return False, commentaire, commentaire2, listeRetour
-
- for valeur in listevaleur:
- # On teste le type de la valeur
- valeurScientifique = valeur
- valide = self.node.item.valideItem(valeur)
- if not valide:
- try:
- valeur, valide = self.node.item.evalValeur(valeur)
- valide, commentaire2 = self.node.item.object.verifType(valeur)
- except:
- # return testtype,commentaire,"",listeRetour
- pass
- if not valide:
- if commentaire.find("On attend un chaine") > 1:
- commentaire = (
- "Valeur "
- + str(valeur)
- + " incorrecte : ajout a la liste refuse: On attend une chaine de caracteres < 8"
- )
- else:
- commentaire = (
- "Valeur "
- + str(valeur)
- + " incorrecte : ajout a la liste refuse"
- )
- if commentaire2 == "":
- commentaire2 = self.node.item.infoErreurItem()
- return valide, commentaire, commentaire2, listeRetour
-
- # On valide la liste obtenue
- encorevalide = self.node.item.valideListePartielle(valeur, listecourante)
- if not encorevalide:
- commentaire2 = self.node.item.infoErreurListe()
- # On traite le cas ou la liste n est pas valide pour un pb de cardinalite
- min, max = self.node.item.getMinMax()
- if len(listecourante) + 1 >= max:
- commentaire = (
- "La liste atteint le nombre maximum d'elements : "
- + str(max)
- + " ,ajout refuse"
- )
- return valide, commentaire, commentaire2, listeRetour
- if len(listecourante) + 1 > min:
- commentaire = ""
- return valide, commentaire, commentaire2, listeRetour
- # On ajoute la valeur testee a la liste courante et a la liste acceptee
- self.ajoutDsDictReel(valeurScientifique)
- listecourante.insert(index, valeur)
- index = index + 1
- listeRetour.append(valeur)
-
- return valide, commentaire, commentaire2, listeRetour
-
- def ajoutTuple(self, valeurTuple, listecourante):
- listeRetour = []
- commentaire = "Nouvelle valeur acceptee"
- commentaire2 = ""
- valide = 1
- if valeurTuple == None:
- return
- if valeurTuple == [""]:
- return
- # On teste le type de la valeur
- valide = self.node.item.valideItem(valeurTuple)
- if not valide:
- try:
- valeur, valide = self.node.item.evalValeur(valeurTuple)
- valide = self.node.item.valideItem(valeur)
- except:
- pass
- if not valide:
- commentaire = (
- "Valeur " + str(valeurTuple) + " incorrecte : ajout a la liste refuse"
- )
- commentaire2 = self.node.item.infoErreurItem()
- return valide, commentaire, commentaire2, listeRetour
-
- # On valide la liste obtenue
- encorevalide = self.node.item.valideListePartielle(valeurTuple, listecourante)
- if not encorevalide:
- commentaire2 = self.node.item.infoErreurListe()
- return valide, commentaire, commentaire2, listeRetour
- listeRetour.append(valeurTuple)
- return valide, commentaire, commentaire2, listeRetour
-
- def ajoutNTuple(self, liste):
- commentaire = "Nouvelles valeurs acceptee"
- commentaire2 = ""
- valide = self.node.item.valideListePartielle(None, liste)
- print("uuuuuuuuuuu", valide)
- if not valide:
- commentaire2 = self.node.item.infoErreurListe()
- return valide, commentaire, commentaire2
-
- def recordValeur(self, liste, dejaValide=True):
- ancienneVal = self.node.item.getValeur()
- validite = self.node.item.setValeur(liste)
- if validite:
- self.node.item.initModif()
- if self.node.item.isValid():
- commentaire = tr("Valeur du mot-cle enregistree")
- else:
- cr = self.node.item.getCr()
- commentaire = tr("Valeur du mot-cle non autorisee ") + cr.getMessFatal()
- self.node.item.setValeur(ancienneVal)
- return validite, commentaire
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2024 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
-#
-import os, sys
-
-from PyQt5.QtWidgets import (
- QApplication,
- QMainWindow,
- QGridLayout,
- QBoxLayout,
- QMenu,
- QAction,
- QMessageBox,
-)
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import Qt, QSize
-
-
-from Editeur import session
-from myMain import Ui_Eficas
-from InterfaceQT4.viewManager import MyViewManager
-from InterfaceQT4.qtEficasSsIhm import AppliSsIhm
-
-from Extensions.i18n import tr
-from Extensions.eficas_exception import EficasException
-from Extensions import param2
-
-
-class Appli(AppliSsIhm, Ui_Eficas, QMainWindow):
- """
- Class implementing the main user interface.
- """
-
- def __init__(
- self,
- code=None,
- salome=1,
- parent=None,
- multi=False,
- langue="en",
- ssIhm=False,
- labelCode=None,
- GUIPath="InterfaceQT4",
- ):
- """
- Constructor
- """
- if ssIhm == True:
- print("mauvaise utilisation de la classe Appli. Utiliser AppliSsIm SVP")
- exit()
-
- AppliSsIhm.__init__(
- self,
- code,
- salome,
- parent,
- multi=multi,
- langue=langue,
- ssIhm=True,
- labelCode=labelCode,
- )
- QMainWindow.__init__(self, parent)
- Ui_Eficas.__init__(self)
-
- self.ssIhm = False
- self.multi = multi
- self.demande = multi # voir PSEN
- self.GUIPath = GUIPath
-
- if self.multi == False:
- self.definitCode(code, None)
- if self.code == None:
- return
- else:
- self.definitCode(code, None)
- if self.code == None:
- return
-
- self.suiteTelemac = False
- if hasattr(self, "maConfiguration"):
- if self.maConfiguration.demandeLangue:
- from InterfaceQT4.monChoixLangue import MonChoixLangue
-
- widgetLangue = MonChoixLangue(self)
- ret = widgetLangue.exec_()
- self.suiteTelemac = self.maConfiguration.suiteTelemac
-
- if (
- not self.salome
- and hasattr(self, "maConfiguration")
- and hasattr(self.maConfiguration, "lang")
- ):
- self.langue = self.maConfiguration.lang
- from Extensions import localisation
-
- app = QApplication
- if hasattr(self, "maConfiguration"):
- localisation.localise(
- None,
- self.langue,
- translatorFichier=self.maConfiguration.translatorFichier,
- )
- self.setupUi(self)
-
- # if parent != None : self.parentCentralWidget = parent.centralWidget()
- # else : self.parentCentralWidget = None
-
- if not self.salome:
- if hasattr(self, "maConfiguration") and hasattr(
- self.maConfiguration, "taille"
- ):
- self.taille = self.maConfiguration.taille
- else:
- self.taille = 1700
-
- self.resize(self.taille, self.height())
-
- icon = QIcon(self.repIcon + "/parametres.png")
- self.actionParametres.setIcon(icon)
- if hasattr(self, "maConfiguration") and self.maConfiguration.boutonDsMenuBar:
- self.frameEntete.setMaximumSize(QSize(16777215, 100))
- self.frameEntete.setMinimumSize(QSize(0, 100))
- if (
- hasattr(self, "maConfiguration")
- and self.maConfiguration.enleverActionStructures
- ):
- self.enleverActionsStructures()
- if hasattr(self, "maConfiguration") and self.maConfiguration.enleverParametres:
- self.enleverParametres()
- if hasattr(self, "maConfiguration") and self.maConfiguration.enleverSupprimer:
- self.enleverSupprimer()
-
- if hasattr(self, "frameEntete"):
- self.myQtab.removeTab(0)
- self.blEnteteGlob = QBoxLayout(2, self.frameEntete)
- self.blEnteteGlob.setSpacing(0)
- self.blEnteteGlob.setContentsMargins(0, 0, 0, 0)
-
- self.blEntete = QBoxLayout(0)
- self.blEntete.insertWidget(0, self.toolBar)
- self.blEntete.insertWidget(0, self.menubar)
- self.blEnteteGlob.insertLayout(0, self.blEntete)
-
- if hasattr(self, "maConfiguration") and self.maConfiguration.boutonDsMenuBar:
- self.blEnteteCommmande = QBoxLayout(0)
- self.blEnteteCommmande.insertWidget(0, self.toolBarCommande)
- self.toolBarCommande.setIconSize(QSize(96, 96))
- self.blEnteteGlob.insertLayout(-1, self.blEnteteCommmande)
- else:
- self.toolBarCommande.close()
-
- if (
- hasattr(self, "maConfiguration")
- and self.maConfiguration.closeEntete == True
- and self.salome
- ):
- self.closeEntete()
-
- eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
- self.viewmanager = MyViewManager(self)
- self.recentMenu = QMenu(tr("&Recents"))
- # self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
-
- # actionARemplacer ne sert que pour l insert Menu
- if hasattr(self, "actionARemplacer"):
- self.menuFichier.insertMenu(self.actionARemplacer, self.recentMenu)
- self.menuFichier.removeAction(self.actionARemplacer)
- self.connecterSignaux()
- self.toolBar.addSeparator()
-
- if self.code != None:
- self.construitMenu()
-
- self.setWindowTitle(self.VERSION_EFICAS)
- try:
- # if 1 :
- # print ('attention try devient if 1')
- self.ouvreFichiers()
- except EficasException as exc:
- # except:
- print("je suis dans le except")
- if self.salome == 0:
- exit()
-
- # self.adjustSize()
-
- def closeEntete(self):
- self.menuBar().close()
- self.toolBar.close()
- self.frameEntete.close()
-
- def definitCode(self, code, ssCode):
- self.code = code
- self.ssCode = ssCode
- if self.code == None:
- self.cleanPath()
- from InterfaceQT4.monChoixCode import MonChoixCode
-
- widgetChoix = MonChoixCode(self)
- ret = widgetChoix.exec_()
- # widgetChoix.show()
- if self.code == None:
- return # pour le cancel de la fenetre choix code
- AppliSsIhm.definitCode(self, self.code, ssCode)
-
- # PN --> pb d exception qui font planter salome
- # plus supporte en python 3
- # app=QApplication
- # if hasattr(prefsCode,'encoding'):
- # import sys
- # reload(sys)
- # sys.setdefaultencoding(prefsCode.encoding)
-
- def construitMenu(self):
- self.initPatrons()
- self.initRecents()
- self.initAides()
- for intituleMenu in (
- "menuTraduction",
- "menuOptions",
- "menuMesh",
- "menuExecution",
- "menuN1",
- ):
- if hasattr(self, intituleMenu):
- menu = getattr(self, intituleMenu)
- menu.setAttribute(Qt.WA_DeleteOnClose)
- menu.close()
- delattr(self, intituleMenu)
- for intituleAction in ("actionExecution", "actionSaveRun"):
- if hasattr(self, intituleAction):
- action = getattr(self, intituleAction)
- self.toolBar.removeAction(action)
- if self.code.upper() in Appli.__dict__:
- Appli.__dict__[self.code.upper()](
- self,
- )
- if self.suiteTelemac:
- self.lookSuiteTelemac()
- self.metMenuAJourUtilisateurs()
- if hasattr(self, "maConfiguration") and self.maConfiguration.ajoutExecution:
- self.ajoutExecution()
-
- def initAides(self):
- # print "je passe la"
- repAide = os.path.dirname(os.path.abspath(__file__))
- fileName = "index.html"
- self.docPath = repAide + "/../Aide"
- if hasattr(self, "maConfiguration") and hasattr(
- self.maConfiguration, "docPath"
- ):
- self.docPath = self.maConfiguration.docPath
- if hasattr(self, "maConfiguration") and hasattr(
- self.maConfiguration, "fileName"
- ):
- fileName = self.maConfiguration.fileName
- self.fileDoc = os.path.join(self.docPath, fileName)
- self.actionCode.setText(tr("Aide specifique ") + str(self.code))
- if not os.path.isfile(self.fileDoc):
- self.fileDoc = ""
- self.docPath = ""
- self.actionCode.setEnabled(False)
- return
-
- self.actionCode.setEnabled(True)
- self.menuAide.addAction(self.actionCode)
-
- def newN1(self):
- ssCode = None
- code = "PSEN_N1"
- self.cleanPath()
- dirCode = os.path.abspath(
- os.path.join(os.path.abspath(__file__), "../..", "ProcessOutputs_Eficas")
- )
- sys.path.insert(0, dirCode)
- self.code = code
- self.definitCode(code, ssCode)
- self.initRecents()
- self.multi = True
- self.demande = False
- self.fileNew()
-
- def newPSEN(self):
- ssCode = None
- code = "PSEN"
- self.cleanPath()
- dirCode = os.path.abspath(
- os.path.join(os.path.abspath(__file__), "../..", code)
- )
- sys.path.insert(0, dirCode)
- self.code = code
- self.definitCode(code, ssCode)
- self.multi = True
- self.demande = False
- self.fileNew()
-
- def ajoutUQ(self):
- AppliSsIhm.ajoutUQ(self)
- self.menuUQ = self.menubar.addMenu(tr("Incertitude"))
- self.actionSaveUQ = QAction(self)
- self.actionSaveUQ.setText(
- tr("Sauvegarde des fichiers pour l'étude incertaine")
- )
- self.menuUQ.addAction(self.actionSaveUQ)
- self.actionSaveUQ.triggered.connect(self.handleSortieUQ)
- self.actionExeUQ = QAction(self)
- self.actionExeUQ.setText(tr("Sauvegarde et Lancement de l'étude"))
- self.menuUQ.addAction(self.actionExeUQ)
- self.actionExeUQ.triggered.connect(self.handleExeUQ)
- self.actionSauvePersalys = QAction(self)
- self.actionSauvePersalys.setText(tr("Sauvegarde du script Persalys"))
- self.menuUQ.addAction(self.actionSauvePersalys)
- self.actionSauvePersalys.triggered.connect(self.handleSauvePourPersalys)
- # self.actionEnregistrer.setDisabled(True)
- # self.actionEnregistrer_sous.setDisabled(True)
-
- def ajoutN1(self):
- return
- self.menuN1 = self.menubar.addMenu(tr("Process Output"))
- self.actionN1 = QAction(self)
- self.actionN1.setText(tr("Process Output"))
- self.menuN1.addAction(self.actionN1)
- self.actionN1.triggered.connect(self.newN1)
-
- if hasattr(self, "actionOpenProcess"):
- return
-
- self.actionOpenProcess = QAction(self)
- self.actionOpenProcess.setText(tr("Open Process_Output File"))
- self.menuN1.addAction(self.actionOpenProcess)
- self.actionOpenProcess.triggered.connect(self.openProcess)
-
- def ajoutExecution(self):
- self.menuExecution = self.menubar.addMenu(tr("&Run"))
- self.actionExecution = QAction(self)
- if sys.platform[0:5] == "linux":
- icon6 = QIcon(self.repIcon + "/roue.png")
- self.actionExecution.setIcon(icon6)
- else:
- self.actionExecution.setText(tr("Run"))
- self.actionExecution.setObjectName("actionExecution")
- self.menuExecution.addAction(self.actionExecution)
- if not (self.actionExecution in self.toolBar.actions()):
- self.toolBar.addAction(self.actionExecution)
- self.actionExecution.setText(tr("Run"))
- self.actionExecution.triggered.connect(self.run)
-
- def ajoutSauveExecution(self):
- self.actionSaveRun = QAction(self)
- icon7 = QIcon(self.repIcon + "/export_MAP.png")
- self.actionSaveRun.setIcon(icon7)
- self.actionSaveRun.setObjectName("actionSaveRun")
- self.menuExecution.addAction(self.actionSaveRun)
- if not (self.actionSaveRun in self.toolBar.actions()):
- self.toolBar.addAction(self.actionSaveRun)
- self.actionSaveRun.setText(tr("Save Run"))
- self.actionSaveRun.triggered.connect(self.saveRun)
-
- def griserActionsStructures(self):
- self.actionCouper.setEnabled(False)
- self.actionColler.setEnabled(False)
- self.actionCopier.setEnabled(False)
- self.actionSupprimer.setEnabled(False)
-
- def enleverActionsStructures(self):
- self.toolBar.removeAction(self.actionCopier)
- self.toolBar.removeAction(self.actionColler)
- self.toolBar.removeAction(self.actionCouper)
- self.menuEdition.removeAction(self.actionCouper)
- self.menuEdition.removeAction(self.actionCopier)
- self.menuEdition.removeAction(self.actionColler)
-
- def enleverParametres(self):
- self.toolBar.removeAction(self.actionParametres)
- self.menuJdC.removeAction(self.actionParametres)
-
- def enleverSupprimer(self):
- self.toolBar.removeAction(self.actionSupprimer)
-
- def enlevernewInclude(self):
- self.actionNouvel_Include.setVisible(False)
-
- def enleverRechercherDsCatalogue(self):
- self.actionRechercherDsCatalogue.setVisible(False)
-
- def connectRechercherDsCatalogue(self):
- if hasattr(self, "rechercherDejaLa"):
- return
- self.rechercherDejaLa = True
- self.actionRechercherDsCatalogue.triggered.connect(
- self.handleRechercherDsCatalogue
- )
-
- def ajoutSortieComplete(self):
- if hasattr(self, "actionSortieComplete"):
- return
- self.actionSortieComplete = QAction(self)
- self.actionSortieComplete.setText(tr("Sortie Complete"))
- self.menuFichier.insertAction(
- self.actionEnregistrer_sous, self.actionSortieComplete
- )
- self.actionSortieComplete.triggered.connect(self.handleSortieComplete)
-
- def MT(self):
- self.enlevernewInclude()
- self.toolBar.addSeparator()
-
- def ZCRACKS(self):
- self.enlevernewInclude()
- self.toolBar.addSeparator()
- self.ajoutExecution()
-
- self.menuOptions = self.menubar.addMenu("menuOptions")
- self.menuOptions.addAction(self.actionParametres_Eficas)
- self.menuOptions.setTitle(tr("Options"))
-
- def ADAO(self):
- self.enleverActionsStructures()
- self.enlevernewInclude()
-
- def ASTER(self):
- self.menuTraduction = self.menubar.addMenu("menuTraduction")
- self.menuTraduction.addAction(self.actionTraduitV11V12)
- self.menuTraduction.addAction(self.actionTraduitV10V11)
- self.menuTraduction.addAction(self.actionTraduitV9V10)
- self.menuTraduction.setTitle(tr("Traduction"))
-
- self.menuFichier.addAction(self.actionSauveLigne)
-
- self.menuOptions = self.menubar.addMenu("menuOptions")
- self.menuOptions.addAction(self.actionParametres_Eficas)
- self.menuOptions.addAction(self.actionLecteur_Pdf)
- self.menuOptions.setTitle(tr("Options"))
-
- def CARMEL3D(self):
- # if self.salome == 0 : return
- self.enlevernewInclude()
- self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
- self.menuMesh.setObjectName("Mesh")
- self.menuMesh.addAction(self.actionChercheGrpMaille)
- # self.griserActionsStructures()
-
- def CARMELCND(self):
- self.enlevernewInclude()
- self.enleverRechercherDsCatalogue()
- self.ajoutExecution()
- self.ajoutSauveExecution()
- self.griserActionsStructures()
-
- def MAP(self):
- self.enlevernewInclude()
- self.toolBar.addSeparator()
- self.ajoutExecution()
- self.ajoutSauveExecution()
- self.menuOptions = self.menubar.addMenu("menuOptions")
- self.menuOptions.addAction(self.actionParametres_Eficas)
- self.menuOptions.setTitle(tr("Options"))
-
- def MAPIDENTIFICATION(self):
- self.enlevernewInclude()
- self.enleverSupprimer()
- # self.ajoutExecution()
- self.enleverRechercherDsCatalogue()
- self.enleverActionsStructures()
- self.enleverParametres()
-
- def PSEN(self):
- try:
- self.action_Nouveau.triggered.disconnect(self.fileNew)
- except:
- pass
- try:
- self.action_Nouveau.triggered.disconnect(self.newPSEN)
- except:
- pass
-
- self.action_Nouveau.triggered.connect(self.newPSEN)
- self.enleverActionsStructures()
- self.enleverParametres()
- self.enleverRechercherDsCatalogue()
- self.enlevernewInclude()
- self.ajoutExecution()
- self.ajoutN1()
- self.ajoutHelpPSEN()
- self.ajoutIcones()
-
- def PSEN_N1(self):
- self.enleverActionsStructures()
- self.enleverParametres()
- self.enleverRechercherDsCatalogue()
- self.enlevernewInclude()
- self.ajoutExecution()
- self.ajoutIcones()
-
- def TELEMAC(self):
- self.enleverActionsStructures()
- self.enlevernewInclude()
- self.connectRechercherDsCatalogue()
- self.ajoutSortieComplete()
-
- def lookSuiteTelemac(self):
- self.enleverActionsStructures()
- self.enlevernewInclude()
- self.enleverParametres()
- self.enleverSupprimer()
- self.enleverRechercherDsCatalogue()
-
- def ajoutHelpPSEN(self):
- self.actionParametres_Eficas.setText("Help PSEN")
- self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
-
- def ChercheGrpMesh(self):
- Msg, listeGroup = self.ChercheGrpMeshInSalome()
- if Msg == None:
- self.viewmanager.handleAjoutGroup(listeGroup)
- else:
- print("il faut gerer les erreurs")
-
- def ChercheGrpMaille(self):
- # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
- try:
- Msg, listeGroup = self.ChercheGrpMailleInSalome() # recherche dans Salome
- # Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
- except:
- raise ValueError("Salome non ouvert")
- if Msg == None:
- self.viewmanager.handleAjoutGroup(listeGroup)
- else:
- print("il faut gerer les erreurs")
-
- def ChercheGrp(self):
- # Msg,listeGroup=self.ChercheGrpMailleInSalome()
- # if Msg == None :
- # self.viewmanager.handleAjoutGroup(listeGroup)
- # else :
- # print "il faut gerer "
- pass
-
- def ajoutIcones(self):
- # Pour pallier les soucis de repertoire d icone
- # print self.repIcon
- icon = QIcon(self.repIcon + "/new_file.png")
- self.action_Nouveau.setIcon(icon)
- icon1 = QIcon(self.repIcon + "/ouvrir.png")
- self.actionOuvrir.setIcon(icon1)
- icon2 = QIcon(self.repIcon + "/save.png")
- self.actionEnregistrer.setIcon(icon2)
- icon6 = QIcon(self.repIcon + "/delete.png")
- self.actionSupprimer.setIcon(icon6)
- icon7 = QIcon(self.repIcon + "/roue.png")
- self.actionExecution.setIcon(icon7)
-
- def connecterSignauxQT4(self):
- self.connect(
- self.recentMenu, SIGNAL("aboutToShow()"), self.handleShowRecentMenu
- )
-
- self.connect(self.action_Nouveau, SIGNAL("triggered()"), self.fileNew)
- self.connect(self.actionNouvel_Include, SIGNAL("triggered()"), self.newInclude)
- self.connect(self.actionOuvrir, SIGNAL("triggered()"), self.fileOpen)
- self.connect(self.actionEnregistrer, SIGNAL("triggered()"), self.fileSave)
- self.connect(
- self.actionEnregistrer_sous, SIGNAL("triggered()"), self.fileSaveAs
- )
- self.connect(self.actionFermer, SIGNAL("triggered()"), self.fileClose)
- self.connect(self.actionFermer_tout, SIGNAL("triggered()"), self.fileCloseAll)
- self.connect(self.actionQuitter, SIGNAL("triggered()"), self.fileExit)
-
- self.connect(self.actionEficas, SIGNAL("triggered()"), self.aidePPal)
- self.connect(self.actionVersion, SIGNAL("triggered()"), self.version)
- self.connect(self.actionParametres, SIGNAL("triggered()"), self.gestionParam)
-
- self.connect(self.actionCouper, SIGNAL("triggered()"), self.editCut)
- self.connect(self.actionCopier, SIGNAL("triggered()"), self.editCopy)
- self.connect(self.actionColler, SIGNAL("triggered()"), self.editPaste)
- self.connect(self.actionSupprimer, SIGNAL("triggered()"), self.supprimer)
- self.connect(self.actionRechercher, SIGNAL("triggered()"), self.rechercher)
- self.connect(
- self.actionDeplier_replier, SIGNAL("triggered()"), self.handleDeplier
- )
-
- self.connect(
- self.actionRapport_de_Validation, SIGNAL("triggered()"), self.jdcRapport
- )
- self.connect(self.actionRegles_du_JdC, SIGNAL("triggered()"), self.jdcRegles)
- self.connect(
- self.actionFichier_Source, SIGNAL("triggered()"), self.jdcFichierSource
- )
- self.connect(self.actionFichier_Resultat, SIGNAL("triggered()"), self.visuJdcPy)
-
- # Pour Aster
- self.actionTraduitV9V10 = QAction(self)
- self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
- self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
- self.actionTraduitV10V11 = QAction(self)
- self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
- self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
- self.actionTraduitV11V12 = QAction(self)
- self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
- self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
- self.actionSauveLigne = QAction(self)
- self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
-
- # self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
- self.connect(self.actionLecteur_Pdf, SIGNAL("triggered()"), self.optionPdf)
- self.connect(
- self.actionTraduitV9V10, SIGNAL("triggered()"), self.traductionV9V10
- )
- self.connect(
- self.actionTraduitV10V11, SIGNAL("triggered()"), self.traductionV10V11
- )
- self.connect(
- self.actionTraduitV11V12, SIGNAL("triggered()"), self.traductionV11V12
- )
- self.connect(self.actionSauveLigne, SIGNAL("triggered()"), self.sauveLigne)
-
- # Pour Carmel
- self.actionChercheGrpMaille = QAction(self)
- self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
- self.connect(
- self.actionChercheGrpMaille, SIGNAL("triggered()"), self.ChercheGrpMaille
- )
-
- # Pour CarmelCND
- self.actionChercheGrp = QAction(self)
- self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
- self.connect(self.actionChercheGrp, SIGNAL("triggered()"), self.ChercheGrp)
-
- # Pour Aide
- self.actionCode = QAction(self)
- self.actionCode.setText(tr("Specificites Maille"))
- self.connect(self.actionCode, SIGNAL("triggered()"), self.aideCode)
-
- def connecterSignaux(self):
- self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
- self.action_Nouveau.triggered.connect(self.fileNew)
- self.actionNouvel_Include.triggered.connect(self.newInclude)
- self.actionOuvrir.triggered.connect(self.fileOpen)
- self.actionEnregistrer.triggered.connect(self.fileSave)
- self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
- self.actionFermer.triggered.connect(self.fileClose)
- self.actionFermer_tout.triggered.connect(self.fileCloseAll)
- self.actionQuitter.triggered.connect(self.fileExit)
-
- self.actionEficas.triggered.connect(self.aidePPal)
- self.actionVersion.triggered.connect(self.version)
- self.actionParametres.triggered.connect(self.gestionParam)
- self.actionCommentaire.triggered.connect(self.ajoutCommentaire)
-
- self.actionCouper.triggered.connect(self.editCut)
- self.actionCopier.triggered.connect(self.editCopy)
- self.actionColler.triggered.connect(self.editPaste)
- self.actionSupprimer.triggered.connect(self.supprimer)
- self.actionRechercher.triggered.connect(self.rechercher)
- self.actionDeplier_replier.triggered.connect(self.handleDeplier)
-
- self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
- self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
- self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
- self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
- self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
- self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
-
- # Pour Aster
- self.actionTraduitV9V10 = QAction(self)
- self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
- self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
- self.actionTraduitV10V11 = QAction(self)
- self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
- self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
- self.actionTraduitV11V12 = QAction(self)
- self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
- self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
- self.actionSauveLigne = QAction(self)
- self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
-
- # self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
- self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
- self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
- self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
- self.actionSauveLigne.triggered.connect(self.sauveLigne)
-
- # Pour Carmel
- self.actionChercheGrpMaille = QAction(self)
- self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
-
- # Pour CarmelCND
- self.actionChercheGrp = QAction(self)
- self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
- self.actionChercheGrp.triggered.connect(self.ChercheGrp)
-
- # Pour Aide
- self.actionCode = QAction(self)
- self.actionCode.setText(tr("Specificites Maille"))
- self.actionCode.triggered.connect(self.aideCode)
-
- def handleDeplier(self):
- self.viewmanager.handleDeplier()
-
- def handleSortieUQ(self):
- self.viewmanager.handleSortieUQ()
-
- def handleExeUQ(self):
- self.viewmanager.handleExeUQ()
-
- def handleSauvePourPersalys(self):
- self.viewmanager.handleSauvePourPersalys()
-
- def ajoutCommentaire(self):
- self.viewmanager.ajoutCommentaire()
-
- def ouvreFichiers(self):
- # Ouverture des fichiers de commandes donnes sur la ligne de commande
- cwd = os.getcwd()
- self.dir = cwd
- for study in session.d_env.studies:
- os.chdir(cwd)
- d = session.getUnit(study, self)
- self.viewmanager.handleOpen(fichier=study["comm"], units=d)
-
- def getSource(self, file):
- # appele par Editeur/session.py
- import convert
-
- p = convert.plugins["python"]()
- p.readfile(file)
- texte = p.convert("execnoparseur")
- return texte
-
- def initPatrons(self):
- # Mise a jour du menu des fichiers recemment ouverts
- from Editeur import listePatrons
-
- if not (self.code in listePatrons.sous_menus):
- if hasattr(self, "menuPatrons"):
- self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
- self.menuPatrons.close()
- delattr(self, "menuPatrons")
- return
- if not hasattr(self, "menuPatrons"):
- self.menuPatrons = QMenu(self.menubar)
- self.menuPatrons.setObjectName("menuPatrons")
- self.menubar.addAction(self.menuPatrons.menuAction())
- self.menuPatrons.setTitle(tr("Patrons"))
- else:
- self.menuPatrons.clear()
- self.listePatrons = listePatrons.listePatrons(self.code)
- idx = 0
- for nomSsMenu in self.listePatrons.liste:
- ssmenu = self.menuPatrons.addMenu(nomSsMenu)
- for fichier in self.listePatrons.liste[nomSsMenu]:
- id = ssmenu.addAction(fichier)
- self.ficPatrons[id] = fichier
- self.id.triggered.connect(self.handleOpenPatrons)
- # self.Patrons.setItemParameter(id,idx)
- idx = idx + 1
-
- def initRecents(self):
- self.recent = []
- try:
- rep = os.path.join(os.path.expanduser("~"), ".config/Eficas", self.code)
- monFichier = rep + "/listefichiers_" + self.code
- index = 0
- f = open(monFichier)
- while index < 9:
- ligne = f.readline()
- if ligne != "":
- l = (ligne.split("\n"))[0]
- self.recent.append(l)
- index = index + 1
- except:
- pass
-
- try:
- f.close()
- except:
- pass
-
- def addToRecentList(self, fn):
- while fn in self.recent:
- self.recent.remove(fn)
- self.recent.insert(0, fn)
- if len(self.recent) > 9:
- self.recent = self.recent[:9]
-
- def addToRecentListQT4(self, fn):
- """
- Public slot to add a filename to the list of recently opened files.
-
- @param fn name of the file to be added
- """
- self.recent.removeAll(fn)
- self.recent.prepend(fn)
- if len(self.recent) > 9:
- self.recent = self.recent[:9]
- index = 0
- self.sauveRecents()
-
- def sauveRecents(self):
- try:
- rep = self.maConfiguration.rep_user
- monFichier = rep + "/listefichiers_" + self.code
- except:
- return
- try:
- f = open(monFichier, "w")
- if len(self.recent) == 0:
- return
- index = 0
- while index < len(self.recent):
- ligne = str(self.recent[index]) + "\n"
- f.write(ligne)
- index = index + 1
- except:
- pass
- try:
- f.close()
- except:
- pass
-
- def traductionV11V12(self):
- from .gereTraduction import traduction
-
- traduction(self.maConfiguration.repIni, self.viewmanager, "V11V12")
-
- def traductionV10V11(self):
- from .gereTraduction import traduction
-
- traduction(self.maConfiguration.repIni, self.viewmanager, "V10V11")
-
- def traductionV9V10(self):
- from .gereTraduction import traduction
-
- traduction(self.maConfiguration.repIni, self.viewmanager, "V9V10")
-
- def version(self):
- from .monVisu import DVisu
-
- titre = tr("version ")
- monVisuDialg = DVisu(parent=self, fl=0)
- monVisuDialg.setWindowTitle(titre)
- if self.code != None:
- monVisuDialg.TB.setText(self.VERSION_EFICAS + tr(" pour ") + self.code)
- else:
- monVisuDialg.TB.setText(self.VERSION_EFICAS)
- monVisuDialg.adjustSize()
- monVisuDialg.show()
-
- def aidePPal(self):
- repAide = os.path.dirname(os.path.abspath(__file__))
- maD = os.path.join(repAide, "..", "Doc")
- try:
- indexAide = os.path.join(maD, "index.html")
- if sys.platform[0:5] == "linux":
- cmd = "xdg-open " + indexAide
- else:
- cmd = "start " + indexAide
- os.system(cmd)
- except:
- QMessageBox.warning(
- self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
- )
-
- def aidePSEN(self):
- repAide = os.path.dirname(os.path.abspath(__file__))
- maD = os.path.join(repAide, "..", "Doc")
- try:
- indexAide = os.path.join(maD, "index.html")
- if sys.platform[0:5] == "linux":
- cmd = "xdg-open " + indexAide
- else:
- cmd = "start " + indexAide
- os.system(cmd)
- except:
- QMessageBox.warning(
- self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
- )
-
- def aideCode(self):
- if self.code == None:
- return
- try:
- # if 1 :
- if sys.platform[0:5] == "linux":
- cmd = "xdg-open " + self.fileDoc
- else:
- cmd = "start " + self.fileDoc
- os.system(cmd)
- except:
- # else:
- QMessageBox.warning(
- self, tr("Aide Indisponible"), tr("l'aide n est pas installee ")
- )
-
- def optionEditeur(self):
- try:
- name = "monOptions_" + self.code
- except:
- QMessageBox.critical(
- self, tr("Parametrage"), tr("Veuillez d abord choisir un code")
- )
- return
- try:
- # if 1:
- optionCode = __import__(name)
- except:
- # else :
- QMessageBox.critical(
- self,
- tr("Parametrage"),
- tr("Pas de possibilite de personnalisation de la configuration "),
- )
- return
- monOption = optionCode.Options(
- parent=self, modal=0, configuration=self.maConfiguration
- )
- monOption.show()
-
- def optionPdf(self):
- from monOptionsPdf import OptionPdf
-
- monOption = OptionPdf(parent=self, modal=0, configuration=self.maConfiguration)
- monOption.show()
-
- def handleSortieComplete(self):
- return self.viewmanager.saveCompleteCurrentEditor()
-
- def handleShowRecentMenu(self):
- """
- Private method to set up recent files menu.
- """
- self.recentMenu.clear()
-
- for rp in self.recent:
- id = self.recentMenu.addAction(rp)
- self.ficRecents[id] = rp
- id.triggered.connect(self.handleOpenRecent)
- self.recentMenu.addSeparator()
- self.recentMenu.addAction(tr("&Effacer"), self.handleClearRecent)
-
- def handleOpenPatrons(self):
- idx = self.sender()
- fichier = (
- self.repIni
- + "/../Editeur/Patrons/"
- + self.code
- + "/"
- + self.ficPatrons[idx]
- )
- self.viewmanager.handleOpen(fichier=fichier, patron=1)
-
- def handleOpenRecent(self):
- idx = self.sender()
- fichier = self.ficRecents[idx]
- self.viewmanager.handleOpen(fichier=fichier, patron=0)
-
- def handleClearRecent(self):
- self.recent = []
- self.sauveRecents()
-
- def handleRechercherDsCatalogue(self):
- if not self.viewmanager:
- return
- self.viewmanager.handleRechercherDsCatalogue()
-
- def fileNew(self):
- try:
- self.viewmanager.newEditor()
- except EficasException as exc:
- msg = str(exc)
- if msg != "":
- QMessageBox.warning(self, tr("Erreur"), msg)
-
- def openProcess(self):
- ssCode = None
- code = "PSEN_N1"
- self.cleanPath()
- dirCode = os.path.abspath(
- os.path.join(os.path.abspath(__file__), "../..", "ProcessOutputs_Eficas")
- )
- sys.path.insert(0, dirCode)
- self.code = code
- self.definitCode(code, ssCode)
- self.multi = True
- self.demande = False
- self.initRecents()
- self.fileOpen()
-
- def fileOpen(self):
- try:
- self.viewmanager.handleOpen()
- except EficasException as exc:
- msg = str(exc)
- if msg != "":
- QMessageBox.warning(self, tr("Erreur"), msg)
-
- def sauveLigne(self):
- return self.viewmanager.sauveLigneCurrentEditor()
-
- def fileSave(self):
- return self.viewmanager.saveCurrentEditor()
-
- def fileSaveAs(self):
- return self.viewmanager.saveAsCurrentEditor()
-
- def fileClose(self):
- self.viewmanager.handleClose(texte="&Fermer")
-
- def fileCloseAll(self):
- self.viewmanager.handleCloseAll(texte="&Fermer")
-
- def fileExit(self):
- # On peut sortir sur Abort
- res = self.viewmanager.handleCloseAll()
- if res != 2:
- self.close()
- return res
-
- def editCopy(self):
- self.viewmanager.handleEditCopy()
-
- def editCut(self):
- self.viewmanager.handleEditCut()
-
- def editPaste(self):
- self.viewmanager.handleEditPaste()
-
- def rechercher(self):
- self.viewmanager.handleRechercher()
-
- def run(self):
- self.viewmanager.run()
-
- def saveRun(self):
- self.viewmanager.saveRun()
-
- def supprimer(self):
- self.viewmanager.handleSupprimer()
-
- def jdcFichierSource(self):
- self.viewmanager.handleViewJdcFichierSource()
-
- def jdcRapport(self):
- self.viewmanager.handleViewJdcRapport()
-
- def jdcRegles(self):
- self.viewmanager.handleViewJdcRegles()
-
- def gestionParam(self):
- self.viewmanager.handleGestionParam()
-
- def visuJdcPy(self):
- self.viewmanager.handleViewJdcPy()
-
- def ouvreArbre(self):
- self.viewmanager.ouvreArbre()
-
- def fermeArbre(self):
- self.viewmanager.fermeArbre()
-
- def newInclude(self):
- self.viewmanager.newIncludeEditor()
-
- def cleanPath(self):
- for pathCode in self.ListePathCode:
- try:
- aEnlever = os.path.abspath(
- os.path.join(os.path.dirname(__file__), "..", pathCode)
- )
- sys.path.remove(aEnlever)
- except:
- pass
- for pathCode in self.listeAEnlever:
- try:
- sys.path.remove(aEnlever)
- except:
- pass
-
- def closeEvent(self, event):
- res = self.fileExit()
- if res == 2:
- event.ignore()
-
- def remplitIconesCommandes(self):
- if self.maConfiguration.boutonDsMenuBar == False:
- return
- if not hasattr(self, "readercata"):
- return
- from monLayoutBouton import MonLayoutBouton
-
- if hasattr(self, "monLayoutBoutonRempli"):
- return
- self.monLayoutBoutonRempli = MonLayoutBouton(self)
-
- def handleAjoutEtape(self, nomEtape):
- self.viewmanager.handleAjoutEtape(nomEtape)
-
- def metMenuAJourUtilisateurs(self):
- self.lesFonctionsUtilisateurs = {}
- if self.code not in self.mesScripts:
- return
- if not hasattr(self.mesScripts[self.code], "dict_menu"):
- return
- for monMenu in iter(self.mesScripts[self.code].dict_menu.items()):
- titre, lesFonctions = monMenu
- self.menuOptions = self.menubar.addMenu("menuOptions")
- self.menuOptions.setTitle(tr(titre))
- for elt in lesFonctions:
- laFonctionUtilisateur, label, lesArguments = elt
- action = QAction(self)
- action.setText(label)
- # action.triggered.connect(self.appelleFonctionUtilisateur)
- self.menuOptions.addAction(action)
- self.lesFonctionsUtilisateurs[action] = (
- laFonctionUtilisateur,
- lesArguments,
- )
- self.menuOptions.triggered.connect(self.handleFonctionUtilisateur)
-
- def handleFonctionUtilisateur(self, action):
- (laFonctionUtilisateur, lesArguments) = self.lesFonctionsUtilisateurs[action]
- self.viewmanager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments)
-
-
-if __name__ == "__main__":
- # Modules Eficas
- rep = os.path.abspath(
- os.path.join(os.path.dirname(os.path.abspath(__file__), "..", "Adao"))
- )
- sys.path.append(rep)
- from Adao import prefs
- from Adao import prefs_Adao
-
- from Editeur import import_code
- from Editeur import session
-
- # Analyse des arguments de la ligne de commande
- options = session.parse(sys.argv)
- code = options.code
-
- app = QApplication(sys.argv)
- # app.setMainWidget(mw) (qt3)
- Eficas = Appli()
- Eficas.show()
-
- # mw.ouvreFichiers()
- # mw.show()
-
- res = app.exec_()
- sys.exit(res)
+++ /dev/null
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2024 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
-#
-import os, sys
-
-from Extensions.eficas_exception import EficasException
-from Extensions import param2
-from InterfaceQT4.getVersion import getEficasVersion
-from InterfaceQT4.viewManagerSsIhm import MyViewManagerSsIhm
-from Editeur import session
-
-
-class AppliSsIhm:
- """
- Class implementing the main user interface.
- """
-
- def __init__(
- self,
- code=None,
- salome=1,
- parent=None,
- multi=False,
- langue="fr",
- ssIhm=True,
- labelCode=None,
- genereXSD=False,
- versionCode=None,
- ssCode=None,
- fichierCata=None,
- GUIDir=None,
- ):
- """
- Constructor
- """
- version = getEficasVersion()
- self.VERSION_EFICAS = "Eficas QT5 Salome " + version
- self.labelCode = labelCode
- if not GUIDir:
- self.GUIDir = "InterfaceQT4"
- else:
- self.GUIDir = GUIDir
-
- self.salome = salome
- self.ssIhm = True
- self.code = code
- self.genereXSD = genereXSD
- self.versionCode = versionCode
- self.ssCode = ssCode
-
- self.dict_reels = {}
- self.fichierIn = None
- self.fichierOut = None
-
- self.recent = []
- self.ficRecents = {}
- self.mesScripts = {}
- self.listeAEnlever = []
- self.ListePathCode = [
- "Adao",
- "ADAO",
- "Carmel3D",
- "Telemac",
- "CF",
- "MAP",
- "ZCracks",
- "SEP",
- "SPECA",
- "PSEN_Eficas",
- "PSEN_N1",
- ]
- self.listeCode = [
- "Adao",
- "ADAO",
- "Carmel3D",
- "Telemac",
- "CF",
- "MAP",
- "ZCracks",
- "SEP",
- "SPECA",
- "PSEN_Eficas",
- "PSEN_N1",
- ]
- self.repIcon = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), "..", "Editeur", "icons"
- )
-
- if fichierCata == None:
- self.fichierCata = session.d_env.fichierCata
- else:
- self.fichierCata = fichierCata
- if session.d_env.labelCode:
- self.labelCode = session.d_env.labelCode
- self.withXSD = session.d_env.withXSD
-
- if self.salome:
- import Accas
-
- try:
- import eficasSalome
-
- Accas.SalomeEntry = eficasSalome.SalomeEntry
- except:
- print("eficas hors salome")
-
- self.multi = multi
- if self.multi:
- print("pas de multi sans ihm")
-
- if langue == "fr":
- self.langue = langue
- else:
- self.langue = "ang"
-
- if self.multi == False:
- self.definitCode(code, ssCode)
- if code == None:
- return
-
- self.suiteTelemac = False
- self.viewmanager = MyViewManagerSsIhm(self)
- self.withUQ = False
-
- def ajoutUQ(self):
- self.withUQ = True
- self.formatFichierIn = "pythonUQ" # par defaut
-
- def definitCode(self, code, ssCode):
- self.code = code
- self.ssCode = ssCode
- if self.code == None:
- return # pour le cancel de la fenetre choix code
-
- try:
- name = "prefs_" + self.code
- prefsCode = __import__(name)
- self.repIni = prefsCode.repIni
- except:
- self.repIni = os.path.dirname(os.path.abspath(__file__))
-
- if ssCode != None:
- self.formatFichierOut = ssCode # par defaut
- prefsCode.NAME_SCHEME = ssCode
- else:
- self.formatFichierIn = "python" # par defaut
- self.formatFichierOut = "python" # par defaut
-
- nameConf = "configuration_" + self.code
- try:
- configuration = __import__(nameConf)
- self.maConfiguration = configuration.make_config(self, self.repIni)
- except:
- from InterfaceQT4.configuration import makeConfig
-
- # self.maConfiguration = configuration.makeConfig(self,prefsCode.repIni)
- self.maConfiguration = makeConfig(self, self.repIni)
-
- if hasattr(self, "maConfiguration") and self.maConfiguration.translatorFichier:
- from Extensions import localisation
-
- localisation.localise(
- None,
- self.langue,
- translatorFichier=self.maConfiguration.translatorFichier,
- )
- if self.withXSD:
- self.maConfiguration.withXSD = True
-
- def getSource(self, file):
- # appele par Editeur/session.py
- import convert
-
- p = convert.plugins["python"]()
- p.readfile(file)
- texte = p.convert("execnoparseur")
- return texte
-
- def initEditor(self, fichier=None, jdc=None, units=None, include=0):
- if (hasattr(self, "editor")) and self.editor != None:
- print("un seul editeur par application")
- sys.exit()
- self.editor = self.viewmanager.getNewEditorNormal()
-
- def initEditorNormal(self, fichier=None, jdc=None, units=None, include=0):
- if (hasattr(self, "editor")) and self.editor != None:
- print("un seul editeur par application")
- sys.Exit()
- # self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
- self.editor = self.viewmanager.getNewEditorNormal()
-
- def fileNew(self):
- self.editor = self.initEditor()
-
- def getEditor(self):
- if (hasattr(self, "editor")) and self.editor != None:
- return self.editor
- self.initEditor()
- return self.editor
-
- def fileOpen(self, fichier):
- fichierIn = os.path.abspath(fichier)
- try:
- monEditor = self.viewmanager.handleOpen(fichierIn)
- except EficasException as exc:
- print("poum")
- monEditor = None
- return monEditor
-
- def fileSave(self):
- if self.editor == None:
- return False
- ok, newName = editor.saveFileAs()
- print("ok, newName ", ok, newName)
-
- def fileSaveAs(self, fileName):
- if self.editor == None:
- return False
- ok = editor.saveFileAs()
- print("ok ", ok)
-
- def dumpXsd(self, avecEltAbstrait=False):
- currentCata = CONTEXT.getCurrentCata()
- texteXSD = currentCata.dumpXsd(avecEltAbstrait)
- return texteXSD
- # if self.maConfiguration.afficheIhm==False : exit()
- # else : return texteXSD
-
-
-# ,self.fileSaveAs
-# ,self.fileClose
-# ,self.fileExit
-# ,self.jdcRapport
-# ,self.jdcRegles
-# ,self.jdcFichierSource
-# ,self.visuJdcPy
-
-
-if __name__ == "__main__":
- # Modules Eficas
- monEficas = AppliSsIhm(code="Adao", salome=0, labelCode="V83")
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-import types
-from Extensions.i18n import tr
-
-from PyQt5.QtCore import Qt
-
-
-# Import des panels
-
-
-class SaisieValeur(object):
- """
- Classe contenant les methodes communes aux panels
- permettant de choisir des valeurs
- """
-
- def __init__(self):
- pass
-
- 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
-
- if valeur == None:
- try:
- nouvelleValeur = str(self.lineEditVal.text())
- except UnicodeEncodeError as e:
- self.editor.afficheInfos("pb d encoding", Qt.red)
- validite, commentaire = self.politique.recordValeur(None)
- self.lineEditVal.setText("")
- self.setValide()
- self.inSaisieValeur = False
- return
- else:
- try:
- # la 1 ligne est tres bizarre. remplacee par le 3nd le 01 10 19
- # if hasattr(self,"lineEditVal"):self.lineEditVal.setText(tr(valeur.nom))
- if hasattr(self, "lineEditVal"):
- self.lineEditVal.setText(tr(valeur))
- except:
- if hasattr(self, "lineEditVal"):
- self.lineEditVal.setText(valeur)
- nouvelleValeur = valeur
-
- if self.node.item.definition.validators != None:
- if self.node.item.definition.validators.verifItem(nouvelleValeur) != 1:
- commentaire = self.node.item.definition.validators.infoErreurItem()
- self.editor.afficheInfos(commentaire, Qt.red)
- self.inSaisieValeur = False
- return
-
- nouvelleValeurFormat = self.politique.getValeurTexte(nouvelleValeur)
- validite, commentaire = self.politique.recordValeur(nouvelleValeurFormat)
- if commentaire != "":
- if validite:
- self.editor.afficheCommentaire(commentaire)
- else:
- self.editor.afficheInfos(commentaire, Qt.red)
- self.inSaisieValeur = False
- self.setValide()
-
- def TraiteLEValeur(self, valeurTraitee=None):
- # lit la chaine entree dans le line edit
- # et la tranforme en chaine de valeurs
- # a traiter. renvoie eventuellement des complexes
- listeValeurs = []
- if valeurTraitee == None:
- valeurBrute = str(self.LEValeur.text())
- else:
- valeurBrute = valeurTraitee
- if valeurBrute == str(""):
- return listeValeurs, 1
-
- try:
- valeur = eval(valeurBrute, {})
- except:
- valeur = valeurBrute
-
- # pour traiter 11.0 - 30.0 pour le CIST
- # if (valeurTraitee and (type(valeurTraitee) in types.StringTypes) and (self.node.item.waitTxm())) :
- if (
- valeurTraitee
- and isinstance(valeurTraitee, str)
- and (self.node.item.waitTxm())
- ):
- valeur = str(valeurTraitee)
-
- if type(valeur) in (list, tuple):
- if self.node.item.waitComplex():
- indice = 0
- while indice < len(valeur):
- v = valeur[indice]
-
- if v == "RI" or v == "MP":
- try:
- t = tuple([v, valeur[indice + 1], valeur[indice + 2]])
- listeValeurs.append(t)
- indice = indice + 3
- except:
- commentaire = tr(
- "Veuillez entrer le complexe sous forme aster ou sous forme python"
- )
- self.editor.afficheInfos(commentaire)
- return listeValeurs, 0
-
- else: # ce n'est pas un tuple a la mode aster
- listeValeurs.append(v)
- indice = indice + 1
-
- else: # on n'attend pas un complexe
- listeValeurs = valeurBrute.split(",")
-
- elif type(valeur) == bytes:
- listeValeurs = valeur.split(",")
- else:
- # listeValeurs.append(valeurBrute)
- listeValeurs.append(valeur)
-
- return listeValeurs, 1
-
-
-class SaisieSDCO(object):
- def LESDCOReturnPressed(self):
- """
- Lit le nom donne par l'utilisateur au concept de type CO qui doit être
- la valeur du MCS courant et stocke cette valeur
- """
- self.editor.initModif()
- anc_val = self.node.item.getValeur()
- if anc_val != None:
- # il faut egalement propager la destruction de l'ancien concept
- self.node.item.deleteValeurCo(valeur=anc_val)
- # et on force le recalcul des concepts de sortie de l'etape
- self.node.item.object.etape.getType_produit(force=1)
- # et le recalcul du contexte
- self.node.item.object.etape.parent.resetContext()
- nomConcept = str(self.LESDCO.text())
- if nomConcept == "":
- return
-
- test, commentaire = self.node.item.setValeurCo(nomConcept)
- if test:
- commentaire = tr("Valeur du mot-clef enregistree")
- self.node.updateNodeValid()
- else:
- cr = self.node.item.getCr()
- commentaire = tr("Valeur du mot-clef non autorisee :") + cr.getMessFatal()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 lire un catalogue et a construire
- un objet CataItem pour Eficas.
- Il s'appuie sur la classe READERCATA
-"""
-# Modules Python
-import os, sys
-
-# Modules Eficas
-from Noyau.N_CR import CR
-from Editeur.catadesc import CatalogDescription
-
-import analyse_catalogue
-import analyse_catalogue_initial
-import autre_analyse_cata
-import uiinfo
-from Extensions.i18n import tr
-from Extensions.eficas_exception import EficasException
-
-
-# -------------------------------
-class ReaderCataCommun(object):
- # -------------------------------
-
- def askChoixCatalogue(self, cataListeChoix):
- # ____________________________________________
- """
- Ouvre une fenetre de selection du catalogue dans le cas où plusieurs
- ont ete definis dans Accas/editeur.ini
- """
- try:
- from PyQt5.QtWidgets import QDialog
- except:
- print("Pas de choix interactif sans qt")
- return
-
- code = getattr(self.appliEficas.maConfiguration, "code", None)
- if code != None:
- title = tr("Choix d une version du code ") + str(code)
- else:
- title = tr("Choix d une version ")
-
- from InterfaceQT4.monChoixCata import MonChoixCata
-
- widgetChoix = MonChoixCata(
- self.appliEficas, [cata.labelCode for cata in cataListeChoix], title
- )
- ret = widgetChoix.exec_()
-
- lab = str(self.VERSION_EFICAS) + " "
- lab += tr(" pour ")
- lab += str(self.code)
- lab += tr(" avec le catalogue ")
- if ret == QDialog.Accepted:
- cata = cataListeChoix[widgetChoix.CBChoixCata.currentIndex()]
- self.fichierCata = cata.fichierCata
- self.labelCode = cata.labelCode
- self.appliEficas.formatFichierOut = cata.formatFichierOut
- self.appliEficas.formatFichierIn = cata.formatFichierIn
- lab += self.labelCode
- self.appliEficas.setWindowTitle(lab)
- widgetChoix.close()
- else:
- widgetChoix.close()
- raise EficasException()
-
- def choisitCata(self):
- # ____________________
-
- listeCataPossibles = []
- #self.commandesOrdreCatalogue = []
-
- listeTousLesCatas = []
- for catalogue in self.appliEficas.maConfiguration.catalogues:
- if isinstance(catalogue, CatalogDescription):
- listeTousLesCatas.append(catalogue)
- elif isinstance(catalogue, tuple):
- listeTousLesCatas.append(CatalogDescription.createFromTuple(catalogue))
- else:
- print(("Catalog description cannot be interpreted: ", catalogue))
-
- if self.labelCode is None:
- listeCataPossibles = listeTousLesCatas
- else:
- for catalogue in listeTousLesCatas:
- if catalogue.code == self.code and catalogue.ssCode == self.ssCode:
- listeCataPossibles.append(catalogue)
-
- if len(listeCataPossibles) == 0:
- try:
- QMessageBox.critical(
- self.QWParent,
- tr("Import du catalogue"),
- tr("Pas de catalogue defini pour le code ") + self.code,
- )
- except:
- print("Pas de catalogue defini pour le code " + self.code)
- if self.appliEficas.salome == 0:
- sys.exit(1)
- self.appliEficas.close()
- return
-
- if self.labelCode is not None:
- # La version a ete fixee
- for cata in listeCataPossibles:
- if self.labelCode == cata.labelCode:
- self.fichierCata = cata.fichierCata
- self.labelCode = cata.labelCode
- self.appliEficas.formatFichierOut = cata.formatFichierOut
- self.appliEficas.formatFichierIn = cata.formatFichierIn
- else:
- cataChoiceList = []
- for cata in listeCataPossibles:
- if cata.selectable:
- if cata.default:
- cataChoiceList.insert(0, cata)
- else:
- cataChoiceList.append(cata)
-
- # le catalogue est fixe dans la ligne de commande
- if self.appliEficas.fichierCata != None:
- trouve = False
- for catalogue in listeTousLesCatas:
- if os.path.abspath(catalogue.fichierCata) == (
- os.path.abspath(self.appliEficas.fichierCata)
- ):
- listeCataPossibles = (catalogue,)
- trouve = True
- break
- if not trouve:
- catalogue = CatalogDescription.createFromTuple(
- (
- self.code,
- self.code,
- self.appliEficas.fichierCata,
- "python",
- "python",
- )
- )
- listeCataPossibles = (catalogue,)
-
- if len(listeCataPossibles) == 0:
- try:
- from PyQt5.QtWidgets import QMessageBox, QDialog
-
- QMessageBox.critical(
- self.QWParent,
- tr("Import du catalogue"),
- tr("Pas de catalogue defini pour le code ") + self.code,
- )
- except:
- print("Pas de catalogue defini pour le code " + self.code)
- self.appliEficas.close()
- if self.appliEficas.salome == 0:
- sys.exit(1)
- return
-
- # le label est fixe dans la ligne de commande
- if self.labelCode is not None:
- # La version a ete fixee
- for cata in listeCataPossibles:
- if self.labelCode == cata.labelCode:
- self.fichierCata = cata.fichierCata
- self.appliEficas.formatFichierIn = cata.formatFichierIn
- self.appliEficas.formatFichierOut = cata.formatFichierOut
- else:
- cataListeChoix = []
- for cata in listeCataPossibles:
- if cata.default:
- cataListeChoix.insert(0, cata)
- else:
- cataListeChoix.append(cata)
-
- if len(cataListeChoix) == 0:
- try:
- from PyQt5.QtWidgets import QMessageBox
-
- QMessageBox.critical(
- self.QWParent,
- tr("Import du catalogue"),
- tr("Aucun catalogue trouve"),
- )
- except:
- print("Pas de catalogue defini pour le code " + self.code)
- self.appliEficas.close()
- if self.appliEficas.salome == 0:
- sys.exit(1)
-
- elif len(cataListeChoix) == 1:
- self.fichierCata = cataListeChoix[0].fichierCata
- self.labelCode = cataListeChoix[0].labelCode
- self.appliEficas.formatFichierOut = cataListeChoix[0].formatFichierOut
- self.appliEficas.formatFichierIn = cataListeChoix[0].formatFichierIn
-
- else:
- # plusieurs catalogues sont disponibles : il faut demander a l'utilisateur
- # lequel il veut utiliser ...
- if self.appliEficas.ssIhm:
- print("Unable to know which catafile is choosen")
- exit()
- self.askChoixCatalogue(cataListeChoix)
- self.demandeCatalogue = True
-
- if self.fichierCata == None:
- if self.appliEficas.salome == 0:
- print(
- (
- "Pas de catalogue pour code %s, version %s"
- % (self.code, self.labelCode)
- )
- )
- sys.exit(1)
- else:
- self.appliEficas.close()
- return
-
-
-# ------------------------------------
-class ReaderCata(ReaderCataCommun):
- # ------------------------------------
-
- def __init__(self, QWParent, appliEficas):
- # _______________________________________
-
- self.QWParent = QWParent
- self.appliEficas = self.QWParent.appliEficas
- self.VERSION_EFICAS = self.appliEficas.VERSION_EFICAS
- self.demandeCatalogue = False
- self.code = self.appliEficas.code
- self.titre = self.appliEficas.code
- self.ssCode = self.appliEficas.ssCode
- # on positionne par defaut mais est-ce vraiment necessaire
- self.appliEficas.formatFichierIn = "python"
- self.appliEficas.formatFichierOut = "python"
- self.labelCode = self.appliEficas.labelCode
- self.fichierCata = self.appliEficas.fichierCata
- self.openCata()
- self.traiteIcones()
- self.cataitem = None
- self.creeDicoInverse()
- if self.code == "TELEMAC":
- self.creeDicoCasToCata()
-
- def openCata(self):
- """
- Ouvre le catalogue standard du code courant, cad le catalogue present
- dans le repertoire Cata
- """
- # import du catalogue
- if self.fichierCata == None:
- self.choisitCata()
-
- self.cata = self.importCata(self.fichierCata)
- if self.code == "NonConnu":
- self.code = self.cata.JdC.code
- modeleMetier = None
- dicoEltDif = {}
- if not (self.appliEficas.genereXSD):
- if self.appliEficas.maConfiguration.withXSD or self.appliEficas.withXSD:
- try:
- import pyxb
- except:
- self.QWParent.informe(
- "environnement", "please source pyxb environment"
- )
- exit()
- try:
- nomCataXsd = os.path.splitext(os.path.basename(self.fichierCata))[0]
- fichierCataTrunc = os.path.splitext(
- os.path.basename(self.fichierCata)
- )[0]
- nomCataXsd = fichierCataTrunc + "_driver"
-
- if os.path.dirname(self.fichierCata) == "":
- pathCata = "./raw/" + nomCataXsd + ".py"
- else:
- pathCata = (
- os.path.dirname(self.fichierCata)
- + "/raw/"
- + nomCataXsd
- + ".py"
- )
-
- self.cata.fileModeleMetier = (
- os.path.dirname(self.fichierCata)
- + "/raw/"
- + nomCataXsd
- + ".xsd"
- )
- import imp
-
- modeleMetier = imp.load_source(nomCataXsd, pathCata)
- # print ('nomCataXsd , pathCata ',nomCataXsd,pathCata)
- try:
- # if 1 :
- # monObjetAnnotation = getattr(modeleMetier,'PNEFdico_'+self.code)
- monObjetAnnotation = getattr(modeleMetier, "PNEFdico")
- texte = monObjetAnnotation.__doc__
- except:
- texte = None
- if texte != None and texte != "":
- l = {}
- texte = "dicoEltDif = " + texte
- exec(texte, globals(), l)
- dicoEltDif = l["dicoEltDif"]
- # print ('dans readerCata _________', dicoEltDif)
-
- except:
- if self.appliEficas.ssIhm == False:
- print("______________ poum import cata_genere ")
- self.QWParent.informe(
- "XSD driver", "unable to load xsd driver", critique=False
- )
- modeleMetier = None
-
- self.cata.DicoNomTypeDifferentNomElt = dicoEltDif
-
- if hasattr(self.cata, "implement"):
- self.cata.JdC.implement = self.cata.implement
- else:
- self.cata.JdC.implement = ""
- if hasattr(self.cata, "importedBy"):
- self.cata.JdC.importedBy = self.cata.importedBy
- else:
- self.cata.JdC.importedBy = []
- self.cata.JdC.labelCode = self.labelCode
- if not (hasattr(self.cata, "dict_condition")):
- self.cata.dict_condition = {}
-
- # pointeur pour le dumpXSD
- self.cata.JdC.cata = self.cata
-
- self.cata.modeleMetier = modeleMetier
- if not self.cata:
- # try:
- # from PyQt5.QtWidgets import QMessageBox, QDialog
- # QMessageBox.critical( self.QWParent, tr("Import du catalogue"),tr("Impossible d'importer le catalogue ")+ self.fichierCata)
- # except :
- # print ("Impossible d'importer le catalogue "+ self.fichierCata)
- self.QWParent.informe(
- "Catalogue", "Impossible d'importer le catalogue " + self.fichierCata
- )
- self.appliEficas.close()
- if self.appliEficas.salome == 0:
- sys.exit(1)
- #
- # analyse du catalogue (ordre des mots-cles)
- #
- # retrouveOrdreCataStandard fait une analyse textuelle du catalogue
- # remplace par retrouveOrdreCataStandardAutre qui utilise une numerotation
- # des mots cles a la creation
- # print (dir(self.cata))
- self.retrouveOrdreCataStandardAutre()
- if self.appliEficas.maConfiguration.modeNouvCommande == "initial":
- self.retrouveOrdreCataStandard()
- if hasattr(self.cata, "ordreDesCommandes"):
- self.ordreDesCommandes = self.cata.ordreDesCommandes
- else:
- self.ordreDesCommandes = None
-
- if hasattr(self.cata, "Classement_Commandes_Ds_Arbre"):
- self.Classement_Commandes_Ds_Arbre = self.cata.Classement_Commandes_Ds_Arbre
- else:
- self.Classement_Commandes_Ds_Arbre = ()
- if hasattr(self.cata, "enum"):
- try:
- _temp = __import__(
- self.cata.enum,
- globals(),
- locals(),
- ["DicoEnumCasFrToEnumCasEn", "TelemacdicoEn"],
- 0,
- )
- self.DicoEnumCasFrToEnumCasEn = _temp.DicoEnumCasFrToEnumCasEn
- self.TelemacdicoEn = _temp.TelemacdicoEn
- except:
- pass
-
- # print self.cata.ordreDesCommandes
-
- #
- # analyse des donnees liees l'IHM : UIinfo
- #
- uiinfo.traite_UIinfo(self.cata)
-
- #
- # traitement des clefs documentaires
- #
-
- self.titre = (
- self.VERSION_EFICAS
- + " "
- + tr(" avec le catalogue ")
- + os.path.basename(self.fichierCata)
- )
- if self.appliEficas.ssIhm == False:
- self.appliEficas.setWindowTitle(self.titre)
- self.appliEficas.titre = self.titre
- self.QWParent.titre = self.titre
-
- # incertitude --> change le convert
- if hasattr(self.cata, "avecIncertitude"):
- self.appliEficas.ajoutUQ()
- if hasattr(self.cata, "modifieCatalogueDeterministe"):
- self.cata.modifieCatalogueDeterministe(self.cata)
-
- def importCata(self, cata):
- """
- Realise l'import du catalogue dont le chemin d'acces est donne par cata
- """
- nom_cata = os.path.splitext(os.path.basename(cata))[0]
- rep_cata = os.path.dirname(cata)
- sys.path[:0] = [rep_cata]
- self.appliEficas.listeAEnlever.append(rep_cata)
-
- # PNPNPN pas propre __ A reflechir
- if "cata_Vimmp" in list(sys.modules.keys()):
- del sys.modules["cata_Vimmp"]
-
- if nom_cata in list(sys.modules.keys()):
- del sys.modules[nom_cata]
-
- for k in sys.modules:
- if k[0 : len(nom_cata) + 1] == nom_cata + ".":
- del sys.modules[k]
-
- mesScriptsNomFichier = "mesScripts_" + self.code.upper()
- try:
- self.appliEficas.mesScripts[self.code] = __import__(mesScriptsNomFichier)
- except:
- pass
-
- # if 1 :
- try:
- o = __import__(nom_cata)
- return o
- except Exception as e:
- self.QWParent.informe("catalog python", "unable to load catalog file")
- import traceback
-
- traceback.print_exc()
- return 0
-
- def retrouveOrdreCataStandardAutre(self):
- """
- Construit une structure de donnees dans le catalogue qui permet
- a EFICAS de retrouver l'ordre des mots-cles dans le texte du catalogue.
- Pour chaque entite du catlogue on cree une liste de nom ordreMC qui
- contient le nom des mots cles dans le bon ordre
- """
- (
- self.cata_ordonne_dico,
- self.appliEficas.liste_simp_reel,
- ) = autre_analyse_cata.analyseCatalogue(self.cata)
- # print ('_________________________________________', self)
- # print (self.cata_ordonne_dico)
- # self.appliEficas.liste_simp_reel = ()
- # self.cata_ordonne_dico = {}
-
- def retrouveOrdreCataStandard(self):
- """
- Retrouve l'ordre des mots-cles dans le catalogue, cad :
- Attention s appuie sur les commentaires
- """
- nom_cata = os.path.splitext(os.path.basename(self.fichierCata))[0]
- rep_cata = os.path.dirname(self.fichierCata)
- self.commandesOrdreCatalogue = analyse_catalogue_initial.analyseCatalogue( self.fichierCata)
- # print self.commandesOrdreCatalogue
-
- def traiteIcones(self):
- if self.appliEficas.maConfiguration.ficIcones == None:
- return
- try:
- ficIcones = self.appliEficas.maConfiguration.ficIcones
- fichierIcones = __import__(ficIcones, globals(), locals(), [], 0)
- self.appliEficas.maConfiguration.dicoIcones = (
- fichierIcones.dicoDesIcones.dicoIcones
- )
- self.appliEficas.maConfiguration.dicoImages = (
- fichierIcones.dicoDesIcones.dicoImages
- )
- except:
- print("Pas de fichier associe contenant des liens sur les icones ")
- self.appliEficas.maConfiguration.dicoIcones = {}
-
- def creeDicoInverse(self):
- self.dicoInverse = {}
- self.dicoMC = {}
- if not self.cata:
- return
- listeEtapes = self.cata.JdC.commandes
- for e in self.cata.JdC.commandes:
- self.traiteEntite(e)
-
- def creeDicoCasToCata(self):
- if hasattr(self.cata, "dicoCasEn"):
- _temp = __import__(
- self.cata.dicoCasEn, globals(), locals(), ["DicoCasEnToCata"], 0
- )
- if self.appliEficas.langue == "ang":
- self.dicoCasToCata = _temp.dicoCasEnToCata
- else:
- self.dicoCasToCata = _temp.dicoCasFrToCata
-
- def traiteEntite(self, e):
- boolIn = 0
- for nomFils, fils in list(e.entites.items()):
- self.dicoMC[nomFils] = fils
- self.traiteEntite(fils)
- boolIn = 1
- if boolIn == 0:
- liste = []
- moi = e
- while hasattr(moi, "pere"):
- liste.append((moi.nom, moi))
- moi = moi.pere
- liste.append((moi.nom, moi))
- self.dicoInverse[e.nom] = liste
- self.dicoInverse[tr(e.nom)] = liste
-
- def creeRubrique(self, e, dico, niveau):
- from Accas import A_BLOC
-
- decale = niveau * " "
- # if niveau != 0 :
- # if isinstance(e,A_BLOC.BLOC): print decale, e.condition
- # else : print decale, e. nom
- for nom, fils in list(e.entites.items()):
- if list(fils.entites.items()) != []:
- self.creeRubrique(fils, dico, niveau + 1)
- # else : print (niveau+1)*" ", nom
-
- # def dumpToXsdEficas(self):
- # Pas sur qu on ait jamais besoin de cela
- # pass
- # from Efi2Xsd import readerEfficas
- # newSchema= xml = open('Cata_MED_FAM.xml').read()
- # SchemaMed = efficas.CreateFromDocument(xml)
- # SchemaMed.alimenteCata(self.cata)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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 lire un catalogue et a construire
- un objet CataItem pour Eficas.
- Il s'appuie sur la classe READERCATA
-"""
-import autre_analyse_cata
-import uiinfo
-
-
-# Modules Eficas
-
-from monChoixCata import MonChoixCata
-from Extensions.i18n import tr
-from Extensions.eficas_exception import EficasException
-from Efi2Xsd import readerEfiXsd
-from autre_analyse_cata import analyseCatalogue
-
-# ATtention pas teste depuis le chgt de nom
-
-from readercata import ReaderCataCommun
-
-
-class ReaderCata(ReaderCataCommun):
- def __init__(self, QWParent, appliEficas):
- self.QWParent = QWParent
- self.appliEficas = appliEficas
- self.VERSION_EFICAS = self.appliEficas.VERSION_EFICAS
- self.code = self.appliEficas.code
- self.ssCode = self.appliEficas.ssCode
- # PN ?? bizarre le 22/04/20
- self.appliEficas.formatfichierOut = "python"
- self.appliEficas.formatfichierIn = "xml"
- self.modeNouvCommande = self.appliEficas.maConfiguration.modeNouvCommande
- self.labelCode = self.appliEficas.labelCode
- self.version_cata = None
- self.ficCata = None
- self.OpenCata()
- self.cataitem = None
- self.titre = "Eficas XML"
- self.ordreDesCommandes = None
- self.Classement_Commandes_Ds_Arbre = ()
- self.demandeCatalogue = False
-
- # self.traiteIcones()
- # self.creeDicoInverse()
-
- def OpenCata(self):
- # self.ficCata = 'Cata_MED_FAM.xml'
- # xml = open('/home/A96028/QT5GitEficasTravail/eficas/Med/Cata_MED_FAM.xml').read()
- # xml = open('/home/A96028/QT5GitEficasTravail/eficas/CataTestXSD/cata_test1.xml').read()
- self.choisitCata()
- xml = open(self.ficCata).read()
- SchemaMed = readerEfiXsd.efficas.CreateFromDocument(xml)
- SchemaMed.exploreCata()
- self.cata = SchemaMed
- uiinfo.traite_UIinfo(self.cata)
- #self.commandesOrdreCatalogue = []
- self.cata_ordonne_dico, self.appliEficas.liste_simp_reel = autre_analyse_cata.analyseCatalogue(self.cata)
- self.liste_groupes = None
-
- def dumpToXml(self):
- # pour compatibilite
- pass
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-# permet de lancer EFICAS en n affichant rien
-try:
- from builtins import object
-except:
- pass
-
-
-class appliEficasSSIhm(object):
- def __init__(self, code):
- self.VERSION_EFICAS = "Sans Ihm"
- self.code = code
- self.ssCode = None
- self.salome = None
- self.top = None
- self.indice = 0
- self.dict_reels = {}
- self.listeAEnlever = []
-
- name = "prefs_" + self.code
- try:
- prefsCode = __import__(name)
- except:
- name = "prefs_" + self.code.upper()
- self.code = self.code.upper()
- prefsCode = __import__(name)
-
- self.repIni = prefsCode.repIni
- self.format_fichier = "python" # par defaut
-
- nameConf = "configuration_" + self.code
- configuration = __import__(nameConf)
- self.CONFIGURATION = configuration.make_config(self, prefsCode.repIni)
-
-
-class QWParentSSIhm(object):
- def __init__(self, code, version_code):
- self.ihm = "QT"
- self.code = code
- self.version_code = version_code
- self.format_fichier = "python" # par defaut
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-
-try:
- from builtins import object
-except:
- pass
-
-from PyQt5.QtWidgets import QAction, QMenu, QMessageBox
-
-from Extensions.i18n import tr
-import types
-
-
-# ---------------------------#
-class PopUpMenuRacine(object):
- # ---------------------------#
-
- def createPopUpMenu(self):
- # print "createPopUpMenu"
- self.ParamApres = QAction(tr("Parametre"), self.tree)
- self.ParamApres.triggered.connect(self.addParametersApres)
- self.ParamApres.setStatusTip(tr("Insere un parametre"))
- self.menu = QMenu(self.tree)
- self.menu.addAction(self.ParamApres)
- self.menu.setStyleSheet("background:rgb(220,220,220); ")
-
- def addParametersApres(self):
- item = self.tree.currentItem()
- item.addParameters(True)
-
-
-# ---------------------------#
-class PopUpMenuNodeMinimal(object):
- # ---------------------------#
-
- def createPopUpMenu(self):
- # print ("createPopUpMenu")
- # self.appliEficas.salome=True
- self.createActions()
- self.menu = QMenu(self.tree)
- # self.menu.setStyleSheet("background:rgb(235,235,235); QMenu::item:selected { background-color: red; }")
- # ne fonctionne pas --> la ligne de commentaire devient rouge
- self.menu.setStyleSheet("background:rgb(220,220,220); ")
- # items du menu
- self.menu.addAction(self.Supprime)
- if hasattr(self.appliEficas, "mesScripts"):
- if self.editor.code in self.editor.appliEficas.mesScripts:
- self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
- self.editor.code
- ].dict_commandes
- if (
- self.tree.currentItem().item.getNom()
- in self.dict_commandes_mesScripts
- ):
- self.ajoutScript()
-
- def ajoutScript(self):
- # cochon mais je n arrive pas a faire mieux avec le mecanisme de plugin
- # a revoir avec un menu et un connect sur le triggered sur le menu ?
- if hasattr(self.appliEficas, "mesScripts"):
- if self.editor.code in self.editor.appliEficas.mesScripts:
- self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
- self.editor.code
- ].dict_commandes
- else:
- return
-
- from Extensions import jdc_include
-
- if isinstance(self.item.jdc, jdc_include.JDC_INCLUDE):
- return
-
- listeCommandes = self.dict_commandes_mesScripts[
- self.tree.currentItem().item.getNom()
- ]
- if type(listeCommandes) != tuple:
- listeCommandes = (listeCommandes,)
- numero = 0
- for commande in listeCommandes:
- conditionSalome = commande[3]
- if self.appliEficas.salome == 0 and conditionSalome == True:
- return
- label = commande[1]
- tip = commande[5]
- self.action = QAction(label, self.tree)
- self.action.setStatusTip(tip)
- if numero == 4:
- self.action.triggered.connect(self.appelleFonction4)
- if numero == 3:
- self.action.triggered.connect(self.appelleFonction3)
- numero = 4
- if numero == 2:
- self.action.triggered.connect(self.appelleFonction2)
- numero = 3
- if numero == 1:
- self.action.triggered.connect(self.appelleFonction1)
- numero = 2
- if numero == 0:
- self.action.triggered.connect(self.appelleFonction0)
- numero = 1
- self.menu.addAction(self.action)
-
- def appelleFonction0(self):
- self.appelleFonction(0)
-
- def appelleFonction1(self):
- self.appelleFonction(1)
-
- def appelleFonction2(self):
- self.appelleFonction(2)
-
- def appelleFonction3(self):
- self.appelleFonction(3)
-
- def appelleFonction4(self):
- self.appelleFonction(4)
-
- def appelleFonction(self, numero, nodeTraite=None):
- if nodeTraite == None:
- nodeTraite = self.tree.currentItem()
- nomCmd = nodeTraite.item.getNom()
- if hasattr(self.appliEficas, "mesScripts"):
- if self.editor.code in self.editor.appliEficas.mesScripts:
- self.dict_commandes_mesScripts = self.appliEficas.mesScripts[
- self.editor.code
- ].dict_commandes
- else:
- return
- listeCommandes = self.dict_commandes_mesScripts[nomCmd]
- commande = listeCommandes[numero]
- conditionValid = commande[4]
-
- if nodeTraite.item.isValid() == 0 and conditionValid == True:
- QMessageBox.warning(
- None,
- tr("item invalide"),
- tr("l item doit etre valide"),
- )
- return
- fonction = commande[0]
- listenomparam = commande[2]
- listeparam = []
- for p in listenomparam:
- if hasattr(nodeTraite, p):
- listeparam.append(getattr(nodeTraite, p))
- if p == "self":
- listeparam.append(self)
-
- try:
- res, commentaire = fonction(listeparam)
- if not res:
- QMessageBox.warning(
- None,
- tr("echec de la fonction"),
- tr(commentaire),
- )
- return
- except:
- pass
-
- def createActions(self):
- self.CommApres = QAction(tr("apres"), self.tree)
- self.CommApres.triggered.connect(self.addCommApres)
- self.CommApres.setStatusTip(tr("Insere un commentaire apres la commande "))
- self.CommAvant = QAction(tr("avant"), self.tree)
- self.CommAvant.triggered.connect(self.addCommAvant)
- self.CommAvant.setStatusTip(tr("Insere un commentaire avant la commande "))
-
- self.ParamApres = QAction(tr("apres"), self.tree)
- self.ParamApres.triggered.connect(self.addParametersApres)
- self.ParamApres.setStatusTip(tr("Insere un parametre apres la commande "))
- self.ParamAvant = QAction(tr("avant"), self.tree)
- self.ParamAvant.triggered.connect(self.addParametersAvant)
- self.ParamAvant.setStatusTip(tr("Insere un parametre avant la commande "))
-
- self.Supprime = QAction(tr("Supprimer"), self.tree)
- self.Supprime.triggered.connect(self.supprimeNoeud)
- self.Supprime.setStatusTip(tr("supprime le mot clef "))
- self.Documentation = QAction(tr("Documentation"), self.tree)
- self.Documentation.triggered.connect(self.viewDoc)
- self.Documentation.setStatusTip(tr("documentation sur la commande "))
-
- def supprimeNoeud(self):
- item = self.tree.currentItem()
- item.delete()
-
- def viewDoc(self):
- self.node = self.tree.currentItem()
- cle_doc = self.node.item.getDocu()
- if cle_doc == None:
- QMessageBox.information(
- self.editor,
- tr("Documentation Vide"),
- tr("Aucune documentation n'est associee a ce noeud"),
- )
- return
- commande = self.editor.appliEficas.maConfiguration.exec_acrobat
- try:
- f = open(commande, "rb")
- except:
- texte = tr("impossible de trouver la commande ") + commande
- QMessageBox.information(self.editor, tr("Lecteur PDF"), texte)
- return
- import os
-
- if cle_doc.startswith("http:"):
- fichier = cle_doc
- else:
- fichier = os.path.abspath(
- os.path.join(self.editor.maConfiguration.path_doc, cle_doc)
- )
- try:
- f = open(fichier, "rb")
- except:
- texte = tr("impossible d'ouvrir ") + fichier
- QMessageBox.information(self.editor, tr("Documentation Vide"), texte)
- return
-
- if os.name == "nt":
- os.spawnv(
- os.P_NOWAIT,
- commande,
- (
- commande,
- fichier,
- ),
- )
- elif os.name == "posix":
- script = "#!/usr/bin/sh \n%s %s&" % (commande, fichier)
- pid = os.system(script)
-
- def addParametersApres(self):
- item = self.tree.currentItem()
- item.addParameters(True)
-
- def addParametersAvant(self):
- item = self.tree.currentItem()
- item.addParameters(False)
-
- def addCommApres(self):
- item = self.tree.currentItem()
- item.addComment(True)
-
- def addCommAvant(self):
- item = self.tree.currentItem()
- item.addComment(False)
-
- def deplieCeNiveau(self):
- item = self.tree.currentItem()
- item.deplieCeNiveau()
-
-
-# --------------------------------------------#
-class PopUpMenuNodePartiel(PopUpMenuNodeMinimal):
- # ---------------------------------------------#
- def createPopUpMenu(self):
- PopUpMenuNodeMinimal.createPopUpMenu(self)
- # ss-menu Comment:
- self.commentMenu = self.menu.addMenu(tr("Commentaire"))
- self.commentMenu.addAction(self.CommApres)
- self.commentMenu.addAction(self.CommAvant)
- # ss-menu Parameters:
- self.paramMenu = self.menu.addMenu(tr("Parametre"))
- self.paramMenu.addAction(self.ParamApres)
- self.paramMenu.addAction(self.ParamAvant)
- self.menu.addAction(self.Documentation)
- self.menu.removeAction(self.Supprime)
- self.menu.addAction(self.Supprime)
-
-
-# -----------------------------------------#
-class PopUpMenuNode(PopUpMenuNodePartiel):
- # -----------------------------------------#
- def createPopUpMenu(self):
- PopUpMenuNodePartiel.createPopUpMenu(self)
- self.Commente = QAction(tr("ce noeud"), self.tree)
- self.Commente.triggered.connect(self.commenter)
- self.Commente.setStatusTip(tr("commente le noeud "))
- self.commentMenu.addAction(self.Commente)
- self.menu.removeAction(self.Supprime)
- self.menu.addAction(self.Supprime)
-
- def commenter(self):
- item = self.tree.currentItem()
- item.commentIt()
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-
-
-try:
- from builtins import str
- from builtins import object
-except:
- pass
-
-import os
-from Extensions.i18n import tr
-from PyQt5.QtWidgets import QFileDialog, QMessageBox
-from PyQt5.QtCore import QFileInfo
-
-DictExtensions = {"MAP": ".map"}
-
-
-class MyViewManager(object):
- def __init__(self, appliEficas):
- self.appliEficas = appliEficas
- self.tabWidgets = []
- self.mesIndexes = {}
- self.appliEficas = appliEficas
- self.editors = []
- self.dictEditors = {}
- self.untitledCount = 0
- self.doubles = {}
-
- self.myQtab = self.appliEficas.myQtab
-
- self.myQtab.currentChanged.connect(self.indexChanged)
- self.myQtab.tabCloseRequested.connect(self.closeTab)
-
- def indexChanged(self):
- index = self.myQtab.currentIndex()
- if index in self.dictEditors:
- editor = self.dictEditors[index]
- if editor.jdc != None:
- CONTEXT.unsetCurrentJdC()
- CONTEXT.setCurrentJdC(editor.jdc)
- self.appliEficas.maConfiguration = editor.maConfiguration
- self.appliEficas.code = editor.maConfiguration.code
- self.appliEficas.setWindowTitle(editor.titre)
- self.appliEficas.construitMenu()
-
- def handleOpen(self, fichier=None, patron=0, units=None):
- result = None
- if fichier is None:
- if self.appliEficas.demande == True:
- self.appliEficas.definitCode(None, None)
- if self.appliEficas.code == None:
- return
-
- if self.appliEficas.code in DictExtensions:
- chaine = "JDC (*" + DictExtensions[self.appliEficas.code] + ");;"
- extensions = tr(chaine + "All Files (*)")
- elif self.appliEficas.code == "TELEMAC":
- extensions = tr("CAS (*.cas);;All Files (*)")
- else:
- extensions = tr("Fichiers JDC (*.comm);;" "Tous les Fichiers (*)")
-
- fichier = QFileDialog.getOpenFileName(
- self.appliEficas,
- tr("Ouvrir Fichier"),
- self.appliEficas.maConfiguration.savedir,
- extensions,
- )
- fichier = fichier[0]
- if len(fichier) == 0:
- return None
- fichier = os.path.abspath(fichier)
- ulfile = os.path.abspath(fichier)
- self.appliEficas.maConfiguration.savedir = os.path.split(ulfile)[0]
- self.appliEficas.addToRecentList(fichier)
- maPage = self.getEditor(fichier, units=units)
- if maPage:
- result = maPage
- if maPage:
- self.myQtab.setTabText(
- self.myQtab.indexOf(maPage), os.path.basename(fichier)
- )
- return result
-
- def closeTab(self, indexAFermer):
- self.handleClose(indexAFermer=indexAFermer)
-
- def handleClose(self, doitSauverRecent=1, texte=tr("&Quitter"), indexAFermer=None):
- if doitSauverRecent:
- self.appliEficas.sauveRecents()
- if indexAFermer == None:
- index = self.myQtab.currentIndex()
- else:
- index = indexAFermer
- if index < 0:
- return
- res = self.checkDirty(self.dictEditors[index], texte)
- if res == 2:
- return 2 # l utilisateur a annule
- idx = index
- while idx < len(self.dictEditors) - 1:
- self.dictEditors[idx] = self.dictEditors[idx + 1]
- idx = idx + 1
- del self.dictEditors[len(self.dictEditors) - 1]
- try:
- del self.doubles[self.dictEditors[index]]
- except:
- pass
- self.myQtab.removeTab(index)
- return res
-
- def run(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.run()
-
- def saveRun(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.saveRun()
-
- def handleCloseAll(self, texte=tr("Quitter")):
- res = 0
- self.appliEficas.sauveRecents()
- while len(self.dictEditors) > 0:
- self.myQtab.setCurrentIndex(0)
- res = self.handleClose(0, texte)
- if res == 2:
- return res # l utilsateur a annule
- return res
-
- def handleRechercher(self):
- # print "passage dans handleRechercher"
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleRechercher()
-
- def handleRechercherDsCatalogue(self):
- # print "passage dans handleRechercher"
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleRechercherDsCatalogue()
-
- def handleDeplier(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleDeplier()
-
- def handleEditCopy(self):
- # print "passage dans handleEditCopy"
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleEditCopy()
-
- def handleEditCut(self):
- # print "passage dans handleEditCut"
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleEditCut()
-
- def handleEditPaste(self):
- # print "passage dans handleEditPaste"
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleEditPaste()
-
- def handleSupprimer(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleSupprimer()
-
- def handleAjoutEtape(self, nomEtape):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleAjoutEtape(nomEtape)
-
- def newEditor(self, include=0):
- if self.appliEficas.demande == True:
- self.appliEficas.definitCode(None, None)
- if self.appliEficas.code == None:
- return
- maPage = self.getEditor(include=include)
-
- def newIncludeEditor(self):
- self.newEditor(include=1)
-
- def handleViewJdcFichierSource(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- self.dictEditors[index].viewJdcSource()
-
- def ouvreArbre(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- self.dictEditors[index].ouvreArbre()
-
- def fermeArbre(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- self.dictEditors[index].fermeArbre()
-
- def ajoutCommentaire(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.ajoutCommentaire()
-
- def handleViewJdcRegles(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- self.dictEditors[index].viewJdcRegles()
-
- def handleGestionParam(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- QMessageBox.warning(
- self.appliEficas,
- tr("Creation Parametre indisponible"),
- tr("les parametres sont lies a un jeu de donnees"),
- )
- return
- self.dictEditors[index].gestionParam()
-
- def handleViewJdcRapport(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- self.dictEditors[index].viewJdcRapport()
-
- def handleViewJdcPy(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- self.dictEditors[index].viewJdcPy()
-
- def saveCurrentEditor(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- if editor in self.doubles:
- QMessageBox.warning(
- None,
- tr("Fichier Duplique"),
- tr("Le fichier ne sera pas sauvegarde."),
- )
- return
- ok, newName = editor.saveFile()
- if ok:
- fileName = os.path.basename(newName)
- self.myQtab.setTabText(index, fileName)
- return ok
-
- def handleSortieUQ(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- ok, newName = editor.saveUQFile()
- return ok
-
- def handleSauvePourPersalys(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- ok = editor.sauvePourPersalys()
- return ok
-
- def handleExeUQ(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- ok = editor.exeUQ()
- return ok
-
- def saveCompleteCurrentEditor(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- ok, newName = editor.saveCompleteFile()
- return ok
-
- def sauveLigneCurrentEditor(self):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- if editor in self.doubles:
- QMessageBox.warning(
- None,
- tr("Fichier Duplique"),
- tr("Le fichier ne sera pas sauvegarde."),
- )
- return
- ok, newName = editor.sauveLigneFile()
- if ok:
- fileName = os.path.basename(newName)
- self.myQtab.setTabText(index, fileName)
- return ok
-
- def saveAsCurrentEditor(self):
- index = self.myQtab.currentIndex()
- editor = self.dictEditors[index]
- oldName = editor.fichier
- ok, newName = editor.saveFileAs()
- if ok:
- fileName = os.path.basename(newName)
- self.myQtab.setTabText(index, fileName)
- if editor in self.doubles:
- if oldName != newName:
- del self.doubles[editor]
- return ok
-
- def displayJDC(self, jdc, fn=None):
- """
- Public slot to display a file in an editor.
- @param fn name of file to be opened
- # insert filename into list of recently opened files
- """
- titre = None
- if fn != None:
- titre = fn.split("/")[-1]
- editor = self.getEditor(fichier=fn, jdc=jdc, include=1)
- self.appliEficas.addToRecentList(editor.getFileName())
-
- def getEditor(self, fichier=None, jdc=None, units=None, include=0):
- newWin = 0
- double = None
- indexEditor = 0
- for indexEditor in self.dictEditors:
- editor = self.dictEditors[indexEditor]
- if self.samePath(fichier, editor.getFileName()):
- msgBox = QMessageBox()
- msgBox.setWindowTitle(tr("Fichier"))
- msgBox.setText(tr("Le fichier <b>%s</b> est deja ouvert", str(fichier)))
- msgBox.addButton(tr("&Duplication"), 0)
- msgBox.addButton(tr("&Abandonner"), 1)
- abort = msgBox.exec_()
- if abort:
- break
- double = editor
- else:
- # PNPN A reflechir avec le GUIPath
- if self.appliEficas.code == "5C":
- from InterfaceQT5C.editor5C import JDCEditor5C
-
- editor = JDCEditor5C(
- self.appliEficas,
- fichier,
- jdc,
- self.myQtab,
- units=units,
- include=include,
- )
- else:
- from InterfaceQT4.editor import JDCEditor
- editor = JDCEditor(
- self.appliEficas,
- fichier,
- jdc,
- self.myQtab,
- units=units,
- include=include,
- )
- if double != None:
- self.doubles[editor] = double
- if editor.jdc: # le fichier est bien un jdc
- self.editors.append(editor)
- newWin = 1
- else:
- editor.closeIt()
-
- if newWin:
- self.addView(editor, fichier)
- elif editor.jdc:
- self.myQtab.setCurrentIndex(indexEditor)
-
- index = self.myQtab.currentIndex()
- if index != -1:
- self.dictEditors[index] = editor
- return editor
-
- def addView(self, win, fichier=None):
- # PNPNPNPN --> a affiner
- if fichier is None:
- self.untitledCount += 1
- self.myQtab.addTab(
- win, tr("Fichier non encore nomme") + str(self.untitledCount)
- )
- # self.myQtab.addTab(win, str(self.appliEficas.code))
- else:
- liste = fichier.split("/")
- txt = liste[-1]
- if not QFileInfo(fichier).isWritable():
- txt = "%s (ro)" % txt
- self.myQtab.addTab(win, txt)
- self.myQtab.setCurrentWidget(win)
- self.currentEditor = win
- win.setFocus()
-
- def getOpenStartDir(self):
- # PN --> Les Preferences
- try:
- userDir = os.path.expanduser("~/Eficas_install/")
- return userDir
- except:
- return ""
-
- def samePath(self, f1, f2):
- """
- compare two paths.
- """
- if f1 is None or f2 is None:
- return 0
- if os.path.normcase(os.path.normpath(f1)) == os.path.normcase(
- os.path.normpath(f2)
- ):
- return 1
- return 0
-
- def checkDirty(self, editor, texte):
- """
- Private method to check dirty status and open a message window.
-
- @param editor editor window to check
- @return flag indicating successful reset of the dirty flag (boolean)
- """
- res = 1
- if (editor.modified) and (editor in self.doubles):
- msgBox = QMessageBox(None)
- msgBox.setWindowTitle(tr("Fichier Duplique"))
- msgBox.setText(tr("Le fichier ne sera pas sauvegarde."))
- msgBox.addButton(texte, 0)
- msgBox.addButton(tr("&Annuler"), 1)
- res = msgBox.exec_()
- if res == 0:
- return 1
- return 2
- if editor.modified:
- fn = editor.getFileName()
- if fn is None:
- fn = tr("Noname")
- msgBox = QMessageBox(None)
- msgBox.setWindowTitle(tr("Fichier Modifie"))
- msgBox.setText(tr("Le fichier ne sera pas sauvegarde."))
- msgBox.addButton(tr("&Sauvegarder"), 1)
- msgBox.addButton(tr("&Quitter sans sauvegarder"), 0)
- msgBox.addButton(tr("&Annuler"), 2)
- res = msgBox.exec_()
- if res == 2:
- return res
- if res == 0 and self.appliEficas.maConfiguration.afficheUQ:
- if fn is None:
- ret, fichier = editor.saveUQFile(self)
- else:
- ret, fichier = editor.saveUQFile(self, fn)
- return 2
- if res == 0:
- (ok, newName) = editor.saveFile()
- if ok:
- fileName = os.path.basename(newName)
- index = self.myQtab.currentIndex()
- self.myQtab.setTabText(index, fileName)
- return ok
- return res
-
- def handleAjoutGroup(self, listeGroup):
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- editor.handleAjoutGroup(listeGroup)
-
- def handleFonctionUtilisateur(self, laFonctionUtilisateur, lesArguments):
- # Peut-etre a blinder un peu plus sur le nb d argument
- index = self.myQtab.currentIndex()
- if index < 0:
- return
- editor = self.dictEditors[index]
- if editor.getEtapeCourante() == None:
- QMessageBox.information(
- self.appliEficas,
- tr("Selectionner une etape"),
- tr(
- "Le texte ne peut pas etre insere dans un fichier vide,\nCreer un materiau vide ou une zone vide et inserer le catalogue apres"
- ),
- )
- return
-
- listeParam = []
- for p in lesArguments:
- if hasattr(editor, p):
- listeParam.append(getattr(editor, p))
- if p == "editor":
- listeParam.append(editor)
- if p == "etapeCourante":
- listeParam.append(editor.getEtapeCourante())
- laFonctionUtilisateur(*listeParam)
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2024 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
-#
-
-
-
-try:
- from builtins import str
- from builtins import object
-except:
- pass
-
-import os
-from Extensions.i18n import tr
-
-
-# --------------------------------
-class JdcSsIhmHandler(object):
- # --------------------------------
- # retourne a l utilisateur
-
- def __init__(self, viewManager):
- # --------------------------------------
- self.viewManagerSsIhm = viewManager
-
- def viewJdcPy(self):
- # ---------------------
- self.viewManagerSsIhm.handleViewJdcPy(self)
-
- def viewJdcSource(self):
- # ---------------------
- self.viewManagerSsIhm.handleViewJdcSource(self)
-
- def getFileName(self):
- # ---------------------
- self.viewManagerSsIhm.getFileName(self)
-
- def viewJdcRapport(self):
- # ---------------------
- self.viewManagerSsIhm.handleViewJdcRapport(self)
-
- def getJdcRapport(self):
- # ---------------------
- return self.viewManagerSsIhm.handleGetJdcRapport(self)
-
- def getDicoPython(self):
- # -------------------------
- return self.viewManagerSsIhm.generDico(self)
-
- def isJdcValid(self):
- # -------------------------
- return self.viewManagerSsIhm.isJdcValid(self)
-
- def fileSaveAs(self, fileName):
- # -------------------------
- return self.viewManagerSsIhm.fileSaveAs(self, fileName)
-
- def fileLegerSaveAs(self, fileName):
- # -----------------------------------
- return self.viewManagerSsIhm.fileLegerSaveAs(self, fileName)
-
- def handleSortieUQ(self, fileName):
- # -----------------------------------
- return self.viewManagerSsIhm.handleSortieUQ(self, fileName)
-
- def handleExeUQ(self, fileName):
- # -----------------------------------
- # est-ce que cela a un sens de faire l exe hors IHM ?
- return self.viewManagerSsIhm.handleExeUQ(self, fileName)
-
-
-# --------------------------------
-class MyViewManagerSsIhm(object):
- # --------------------------------
- # Symetrique de ViewManager mais pas d heritage entre les 2
- # dans le viewManager pas de souci pour savoir qui est le jdc sur lequel on travaille
- # ici en revanche.... c est moins sur . voir avec le fichier
-
- # --------------------------------
- def __init__(self, appliEficas):
- # --------------------------------
- self.appliEficas = appliEficas
- self.tabWidgets = []
- self.mesIndexes = {}
- self.dictEditors = {}
- self.untitledCount = 0
- self.doubles = {}
-
- # ------------------------------------------------------
- def handleOpen(self, fichier=None, units=None):
- # ------------------------------------------------------
- result = None
- if fichier is None:
- print("nom de fichier obligatoire")
- return None
-
- for handler in self.dictEditors:
- editor = self.dictEditors[handler]
- if self.samePath(fichier, editor.getFileName()):
- print("fichier deja ouvert . pas de nouvel editor")
- return handler
-
- monNewHandler = self.getNewEditor(fichier, units)
- return monNewHandler
-
- # ----------------------------------------------------------------------
- def getNewEditor(self, fichier=None, jdc=None, units=None, include=0):
- # ----------------------------------------------------------------------
- # il faudrait decider entre e handler ou non
- # le cas d usage n est pas tout a fait identique :
- # avec handler pour les utilisateurs avance
- # sans pour les utilisateurs encore plus ancvances et les tests
-
- from InterfaceQT4.editorSsIhm import JDCEditorSsIhm
-
- editor = JDCEditorSsIhm(
- self.appliEficas, fichier, jdc, units=units, include=include
- )
-
- if editor.jdc: # le fichier est bien un jdc
- monHandler = JdcSsIhmHandler(self)
- self.dictEditors[monHandler] = editor
- return monHandler
- else:
- print("impossible de construire le jdc")
- return None
-
- # --------------------------------------------------------------------------------
- def getNewEditorNormal(self, fichier=None, jdc=None, units=None, include=0):
- # --------------------------------------------------------------------------------
-
- from InterfaceQT4.editorSsIhm import JDCEditorSsIhm
-
- editor = JDCEditorSsIhm(
- self.appliEficas, fichier, jdc, units=units, include=include
- )
- self.editor = editor
- return editor
-
- # -----------------------------
- def samePath(self, f1, f2):
- # ------------------------------
- """
- compare two paths.
- """
- if f1 is None or f2 is None:
- return 0
- if os.path.normcase(os.path.normpath(f1)) == os.path.normcase(
- os.path.normpath(f2)
- ):
- return 1
- return 0
-
- # ---------------------------------
- def handleViewJdcPy(self, handler):
- # ---------------------------------
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- self.dictEditors[handler].viewJdcPy()
-
- # ---------------------------------
- def getFileName(self, handler):
- # ---------------------------------
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- return self.dictEditors[handler].getFileName()
-
- # ---------------------------------------------
- def handleViewJdcSource(self, handler):
- # ---------------------------------------------
- print(handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- self.dictEditors[handler].viewJdcSource()
-
- # ---------------------------------------------
- def handleViewJdcRapport(self, handler):
- # ---------------------------------------------
- print(handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- self.dictEditors[handler].viewJdcRapport()
-
- # ---------------------------------------------
- def handleGetJdcRapport(self, handler):
- # ---------------------------------------------
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- return self.dictEditors[handler].getJdcRapport()
-
- # ---------------------------------------------
- def handleViewJdcRapport(self, handler):
- # ---------------------------------------------
- print(handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- self.dictEditors[handler].viewJdcRapport()
-
- # ---------------------------------------------
- def generDico(self, handler):
- # ---------------------------------------------
- print(handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- return self.dictEditors[handler].generDico()
-
- # ---------------------------------------------
- def isJdcValid(self, handler):
- # ---------------------------------------------
- print(handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- return self.dictEditors[handler].jdc.isValid()
-
- # ---------------------------------------------
- def fileSaveAs(self, handler, fileName):
- # ---------------------------------------------
- print(handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- return self.dictEditors[handler].saveFile(fileName)
-
- # ---------------------------------------------
- def fileLegerSaveAs(self, handler, fileName):
- # ---------------------------------------------
- # print (handler)
- if not (handler in self.dictEditors):
- print("editor non trouve")
- return
- self.dictEditors[handler].saveFileLegerAs(fileName)