1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2017 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
21 from __future__ import absolute_import
22 from __future__ import print_function
24 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
35 #from editorSsIhm import JDCEditorSsIhm
40 Class implementing the main user interface.
42 def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=True,versionCode=None):
46 version=getEficasVersion()
47 self.VERSION_EFICAS="Eficas QT5 Salome " + version
48 self.versionCode=versionCode
62 self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
63 self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
64 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
70 Accas.SalomeEntry = eficasSalome.SalomeEntry
72 print ('eficas hors salome')
76 print ('pas de multi sans ihm')
79 if langue=='fr': self.langue=langue
80 else : self.langue="ang"
82 if self.multi == False :
83 self.definitCode(code,ssCode)
86 self.suiteTelemac=False
87 self.viewmanager=MyViewManagerSsIhm(self)
90 def definitCode(self,code,ssCode) :
93 if self.code == None:return # pour le cancel de la fenetre choix code
95 name='prefs_'+self.code
96 prefsCode=__import__(name)
98 self.repIni=prefsCode.repIni
100 self.format_fichier= ssCode #par defaut
101 prefsCode.NAME_SCHEME=ssCode
103 self.format_fichier="python" #par defaut
105 nameConf='configuration_'+self.code
106 configuration=__import__(nameConf)
107 self.maConfiguration = configuration.make_config(self,prefsCode.repIni)
109 if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
110 from Extensions import localisation
111 localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
114 def getSource(self,file):
115 # appele par Editeur/session.py
117 p=convert.plugins['python']()
119 texte=p.convert('execnoparseur')
123 def initEditor(self,fichier = None,jdc = None, units = None,include=0):
124 if self.editor != None :
125 print ('un seul editeur par appli')
127 self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
131 self.editor=initEditor(self)
136 def fileOpen(self,fichier):
137 fichierIn = os.path.abspath(six.text_type(fichier))
139 monEditor=self.viewmanager.handleOpen(fichierIn)
140 except EficasException as exc:
146 if self.editor == None : return False
147 ok, newName = editor.saveFileAs()
148 print ('ok, newName ',ok, newName)
150 def fileSaveAs(self,fileName):
151 if self.editor == None : return False
152 ok = editor.saveFileAs()
156 current_cata = CONTEXT.getCurrentCata()
157 current_cata.dumpXsd()
158 if self.maConfiguration.afficheIhm==False : exit()
165 #,self.jdcFichierSource
170 if __name__=='__main__':
173 monEficas= AppliSsIhm(code='Adao',salome=0,versionCode='V83')