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
33 from InterfaceQT4.getVersion import getEficasVersion
34 from InterfaceQT4.viewManagerSsIhm import MyViewManagerSsIhm
36 from Editeur import session
41 Class implementing the main user interface.
43 def __init__(self,code=None,salome=1,parent=None,multi=False,langue='fr',ssIhm=True,labelCode=None,genereXSD=False):
47 version=getEficasVersion()
48 self.VERSION_EFICAS="Eficas QT5 Salome " + version
49 self.labelCode=labelCode
54 self.genereXSD=genereXSD
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 self.fichierCata=session.d_env.fichierCata
69 if session.d_env.labelCode : self.labelCode=session.d_env.labelCode
70 self.withXSD=session.d_env.withXSD
76 Accas.SalomeEntry = eficasSalome.SalomeEntry
78 print ('eficas hors salome')
82 print ('pas de multi sans ihm')
85 if langue=='fr': self.langue=langue
86 else : self.langue="ang"
88 if self.multi == False :
89 self.definitCode(code,None)
92 self.suiteTelemac=False
93 self.viewmanager=MyViewManagerSsIhm(self)
96 def definitCode(self,code,ssCode) :
99 if self.code == None:return # pour le cancel de la fenetre choix code
102 name='prefs_'+self.code
103 prefsCode=__import__(name)
104 self.repIni=prefsCode.repIni
106 self.repIni=os.path.dirname(os.path.abspath(__file__))
110 self.formatFichierOut = ssCode #par defaut
111 prefsCode.NAME_SCHEME = ssCode
113 self.formatFichierIn = "python" #par defaut
114 self.formatFichierOut = "python" #par defaut
116 nameConf='configuration_'+self.code
118 configuration=__import__(nameConf)
119 self.maConfiguration = configuration.make_config(self,self.repIni)
121 from InterfaceQT4.configuration import makeConfig
122 #self.maConfiguration = configuration.makeConfig(self,prefsCode.repIni)
123 self.maConfiguration = makeConfig(self,self.repIni)
125 if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
126 from Extensions import localisation
127 localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
128 if self.withXSD : self.maConfiguration.withXSD=True
131 def getSource(self,file):
132 # appele par Editeur/session.py
134 p=convert.plugins['python']()
136 texte=p.convert('execnoparseur')
140 def initEditor(self,fichier = None,jdc = None, units = None,include=0):
141 if (hasattr(self, 'editor')) and self.editor != None :
142 print ('un seul editeur par application')
144 self.editor = self.viewmanager.getNewEditorNormal()
146 def initEditorNormal(self,fichier = None,jdc = None, units = None,include=0):
147 if (hasattr(self, 'editor')) and self.editor != None :
148 print ('un seul editeur par application')
150 #self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
151 self.editor = self.viewmanager.getNewEditorNormal()
155 self.editor=self.initEditor()
158 if (hasattr(self, 'editor')) and self.editor != None : return self.editor
162 def fileOpen(self,fichier):
163 fichierIn = os.path.abspath(fichier)
165 monEditor=self.viewmanager.handleOpen(fichierIn)
166 except EficasException as exc:
172 if self.editor == None : return False
173 ok, newName = editor.saveFileAs()
174 print ('ok, newName ',ok, newName)
176 def fileSaveAs(self,fileName):
177 if self.editor == None : return False
178 ok = editor.saveFileAs()
181 def dumpXsd(self, avecEltAbstrait = False):
182 current_cata = CONTEXT.getCurrentCata()
183 texteXSD = current_cata.dumpXsd( avecEltAbstrait)
185 #if self.maConfiguration.afficheIhm==False : exit()
186 #else : return texteXSD
193 #,self.jdcFichierSource
198 if __name__=='__main__':
201 monEficas= AppliSsIhm(code='Adao',salome=0,labelCode='V83')