X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2Feficas_go.py;h=40f404d943db2f98d9f5d82cca330961b1281c7f;hb=e570dff249a11579eb7d33de376ed71be16d7261;hp=daaf8bf783d14f2a7c9c0893e6ac57435e27dfd1;hpb=69ed0ccae7884aee37bbe54cb1af2983cb51492d;p=tools%2Feficas.git diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index daaf8bf7..40f404d9 100644 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -1,61 +1,157 @@ +#!/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-2013 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 +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# ====================================================================== -""" - Ce module permet de lancer l'application EFICAS en affichant - un ecran Splash pour faire patienter l'utilisateur -""" -# Modules Python -import sys -from qt import * -# 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 +# Modules Python +import sys,os +repIni=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"..")) +ihmQTDir=os.path.join(repIni,"UiQT4") +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) -from Editeur import import_code -from Editeur import session +from PyQt4.QtGui import * -def lance_eficas(code=None,fichier=None): +def lance_eficas(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 qtEficas import Appli + from Extensions import localisation 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() + localisation.localise(app,langue) + Eficas=Appli(code=code,ssCode=ssCode,multi=multi,langue=langue) + Eficas.show() + + res=app.exec_() sys.exit(res) +def lance_eficas_ssIhm(code=None,fichier=None,ssCode=None,version=None): + """ + 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 + app = QApplication(sys.argv) + Eficas=Appli(code=code,ssCode=ssCode,ssIhm=True) + + from ssIhm import QWParentSSIhm + parent=QWParentSSIhm(code,Eficas,version) + + 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 lance_eficas_ssIhm_cherche_Groupes(code=None,fichier=None,ssCode=None,version=None): + monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version) + print monEditeur.cherche_Groupes() + +def lance_eficas_ssIhm_cherche_cr(code=None,fichier=None,ssCode=None,version=None): + monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version) + print monEditeur.jdc.cr + +def lance_eficas_ssIhm_reecrit(code=None,fichier=None,ssCode=None,version=None): + monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version) + fileName=fichier.split(".")[0]+"_73.comm" + monEditeur.saveFileAs(fileName=fileName) + +def lance_eficas_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) + + from ssIhm import QWParentSSIhm + parent=QWParentSSIhm(code,Eficas,version) + + 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. + """ + 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(),'..'))) + lance_eficas(code=None,fichier=None,ssCode=None,multi=True) + +