1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2021 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from __future__ import absolute_import
23 from __future__ import print_function
25 from builtins import str
30 from Extensions.eficas_exception import EficasException
31 from Extensions import param2
32 from InterfaceQT4.getVersion import getEficasVersion
33 from InterfaceQT4.viewManagerSsIhm import MyViewManagerSsIhm
34 from Editeur import session
39 Class implementing the main user interface.
41 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):
45 version=getEficasVersion()
46 self.VERSION_EFICAS="Eficas QT5 Salome " + version
47 self.labelCode=labelCode
52 self.genereXSD=genereXSD
53 self.versionCode=versionCode
64 self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
65 self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
66 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
68 if fichierCata== None: self.fichierCata=session.d_env.fichierCata
69 else : self.fichierCata=fichierCata
70 if session.d_env.labelCode : self.labelCode=session.d_env.labelCode
71 self.withXSD=session.d_env.withXSD
77 Accas.SalomeEntry = eficasSalome.SalomeEntry
79 print ('eficas hors salome')
83 print ('pas de multi sans ihm')
86 if langue=='fr': self.langue=langue
87 else : self.langue="ang"
89 if self.multi == False :
90 self.definitCode(code,ssCode)
93 self.suiteTelemac=False
94 self.viewmanager=MyViewManagerSsIhm(self)
97 def definitCode(self,code,ssCode) :
100 if self.code == None:return # pour le cancel de la fenetre choix code
103 name='prefs_'+self.code
104 prefsCode=__import__(name)
105 self.repIni=prefsCode.repIni
107 self.repIni=os.path.dirname(os.path.abspath(__file__))
111 self.formatFichierOut = ssCode #par defaut
112 prefsCode.NAME_SCHEME = ssCode
114 self.formatFichierIn = "python" #par defaut
115 self.formatFichierOut = "python" #par defaut
117 nameConf='configuration_'+self.code
119 configuration=__import__(nameConf)
120 self.maConfiguration = configuration.make_config(self,self.repIni)
122 from InterfaceQT4.configuration import makeConfig
123 #self.maConfiguration = configuration.makeConfig(self,prefsCode.repIni)
124 self.maConfiguration = makeConfig(self,self.repIni)
126 if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
127 from Extensions import localisation
128 localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
129 if self.withXSD : self.maConfiguration.withXSD=True
132 def getSource(self,file):
133 # appele par Editeur/session.py
135 p=convert.plugins['python']()
137 texte=p.convert('execnoparseur')
141 def initEditor(self,fichier = None,jdc = None, units = None,include=0):
142 if (hasattr(self, 'editor')) and self.editor != None :
143 print ('un seul editeur par application')
145 self.editor = self.viewmanager.getNewEditorNormal()
147 def initEditorNormal(self,fichier = None,jdc = None, units = None,include=0):
148 if (hasattr(self, 'editor')) and self.editor != None :
149 print ('un seul editeur par application')
151 #self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
152 self.editor = self.viewmanager.getNewEditorNormal()
156 self.editor=self.initEditor()
159 if (hasattr(self, 'editor')) and self.editor != None : return self.editor
163 def fileOpen(self,fichier):
164 fichierIn = os.path.abspath(fichier)
166 monEditor=self.viewmanager.handleOpen(fichierIn)
167 except EficasException as exc:
173 if self.editor == None : return False
174 ok, newName = editor.saveFileAs()
175 print ('ok, newName ',ok, newName)
177 def fileSaveAs(self,fileName):
178 if self.editor == None : return False
179 ok = editor.saveFileAs()
182 def dumpXsd(self, avecEltAbstrait = False):
183 currentCata = CONTEXT.getCurrentCata()
184 texteXSD = currentCata.dumpXsd( avecEltAbstrait)
186 #if self.maConfiguration.afficheIhm==False : exit()
187 #else : return texteXSD
195 #,self.jdcFichierSource
200 if __name__=='__main__':
203 monEficas= AppliSsIhm(code='Adao',salome=0,labelCode='V83')