+#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# CONFIGURATION MANAGEMENT OF EDF VERSION
-# ======================================================================
-# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
-# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
-# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
-# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
-# (AT YOUR OPTION) ANY LATER VERSION.
+# Copyright (C) 2007-2017 EDF R&D
#
-# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
-# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
-# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
-# GENERAL PUBLIC LICENSE FOR MORE DETAILS.
+# 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.
#
-# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
-# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
-# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
+# 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
#
-# ======================================================================
-"""
- Ce module permet de lancer l'application EFICAS en affichant
- un ecran Splash pour faire patienter l'utilisateur
-"""
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
# Modules Python
-import sys
-from qt import *
+from __future__ import absolute_import
+from __future__ import print_function
+try :
+ from builtins import str
+except : pass
+
+from PyQt5.QtWidgets import QApplication
+
+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)
-# Modules Eficas
-import prefs
-if hasattr(prefs,'encoding'):
- # Hack pour changer le codage par defaut des strings
- import sys
- reload(sys)
- sys.setdefaultencoding(prefs.encoding)
- del sys.setdefaultencoding
- # Fin hack
+def getEficasSsIhm(code=None,fichier=None,ssCode=None,multi=False,langue='en',versionCode=None):
+ #print (versionCode)
+ from InterfaceQT4.qtEficasSsIhm import AppliSsIhm
+ Eficas=AppliSsIhm(code=code,salome=0,ssCode=ssCode,multi=multi,langue=langue,versionCode=versionCode)
+ from Editeur import session
+ options=session.parse(['ssIhm','-k',code,'-v',versionCode])
+ return Eficas
-from Editeur import import_code
-from Editeur import session
-def lance_eficas(code=None,fichier=None):
+def lanceEficas(code=None,fichier=None,ssCode=None,multi=False,langue='en'):
"""
Lance l'appli EFICAS
"""
# Analyse des arguments de la ligne de commande
- if code !=None : prefs.code=code
- import qtEficas
+ from Editeur import session
options=session.parse(sys.argv)
- code=options.code
+ if options.code!= None : code=options.code
+ if options.ssCode!= None : ssCode=options.ssCode
+ from InterfaceQT4.qtEficas import Appli
app = QApplication(sys.argv)
- mw = qtEficas.Appli(code=code)
- app.setMainWidget(mw)
- app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
- mw.show()
- mw.ouvreFichiers()
- res = app.exec_loop()
+
+ #import cProfile, pstats, StringIO
+ #pr = cProfile.Profile()
+ #pr.enable()
+
+ Eficas=Appli(code=code,salome=0,ssCode=ssCode,multi=multi,langue=langue)
+ #pr.disable()
+ #s = StringIO.StringIO()
+ #sortby = 'cumulative'
+ #ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
+ #ps.print_stats()
+ #print (s.getValue())
+
+ Eficas.show()
+
+ res=app.exec_()
sys.exit(res)
+def lanceEficas_ssIhm(code=None,fichier=None,ssCode=None,version=None,debug=False,langue='en'):
+ """
+ Lance l'appli EFICAS pour trouver les noms des groupes
+ """
+ # Analyse des arguments de la ligne de commande
+ from Editeur import session
+ options=session.parse(sys.argv)
+ if version!=None and options.cata==None : options.cata=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):
+ monEditeur=lanceEficas_ssIhm(code,fichier,ssCode,version)
+ print((monEditeur.chercheGroupes()))
+
+def lanceEficas_ssIhm_cherche_cr(code=None,fichier=None,ssCode=None,version=None):
+ 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 '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
+ """
+ # Analyse des arguments de la ligne de commande
+ from Editeur import session
+ options=session.parse(sys.argv)
+
+ from .qtEficas import Appli
+ #app = QApplication(sys.argv)
+ #Eficas=Appli(code=code,ssCode=None,salome=0)
+
+ 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 getEficasSsIhm(code='Adao',versionCode='V0'):
+# from .qtEficasSsIhm import AppliSsIhm
+# Eficas=AppliSsIhm(code=code,ssCode=None,salome=0)
+# return Eficas
+
+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.
+ """
+ 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).
+ """
+ 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,fichier=None,ssCode=None,multi=True)
+
+