1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2001-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, or (at your option) any later version.
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 # -*- coding: utf-8 -*-
25 from PyQt5.QtWidgets import QMessageBox
26 from salome.kernel.studyedit import getStudyEditor
31 sgPyQt = SalomePyQt.SalomePyQt()
33 # -----------------------------------------------------------------------------
35 print("EFicasGUI :: :::::::::::::::::::::::::::::::::::::::::::::::::::::")
37 # Test Eficas directory
38 eficasRoot = os.getenv("EFICAS_ROOT")
39 if eficasRoot is None:
40 QMessageBox.critical(sgPyQt.getDesktop(), "Error",
41 "Cannot initialize EFICAS module. Environment "
42 "variable EFICAS_ROOT is not set.")
43 elif not os.path.isdir(eficasRoot):
44 QMessageBox.critical(sgPyQt.getDesktop(), "Error",
45 "Cannot initialize EFICAS module. Directory %s does "
46 "not exist (check EFICAS_ROOT environment "
47 "variable)." % eficasRoot)
50 ################################################
52 # Used to store actions, menus, toolbars, etc...
53 ################################################
56 # menus/toolbars/actions IDs
70 # create top-level menu
71 self.mid = sgPyQt.createMenu("Eficas", -1, GUIcontext.EFICAS_MENU_ID,
72 sgPyQt.defaultMenuGroup())
74 self.tid = sgPyQt.createTool("Eficas")
76 a = sgPyQt.createAction(GUIcontext.MULTICATALOG_ID, "Eficas MultiCatalogue", "Lancer Eficas", "Lancer Eficas", "eficas.png")
77 sgPyQt.createMenu(a, self.mid)
78 sgPyQt.createTool(a, self.tid)
80 # create actions conditionally and fill menu and toolbar with actions
81 self.addActionConditionally("Telemac3/prefs.py", GUIcontext.TELEMAC_ID,
82 "Eficas pour Telemac",
83 "Editer un .cas avec Eficas",
85 self.addActionConditionally("SEP/prefs.py", GUIcontext.SEP_ID,
87 "Editer un jeu de commande SEP avec Eficas",
89 self.addActionConditionally("SPECA/prefs.py", GUIcontext.SPECA_ID,
91 "Editer un jeu de commande SPECA avec Eficas",
93 self.addActionConditionally("CF/prefs.py", GUIcontext.CF_ID,
95 "Editer un jeu de commande CF avec Eficas",
97 self.addActionConditionally("MT/prefs.py", GUIcontext.MT_ID,
99 "Editer un jeu de commande MT avec Eficas",
101 self.addActionConditionally("Adao/prefs.py", GUIcontext.ADAO_ID,
103 "Editer un jeu de commande Adao avec Eficas",
105 self.addActionConditionally("MAP/prefs.py", GUIcontext.MAP_ID,
107 "Editer un jeu de commande Map avec Eficas",
109 self.addActionConditionally("Carmel3D/prefs.py", GUIcontext.CARMEL3D_ID,
110 "Eficas pour Carmel3D",
111 "Editer un jeu de commande Carmel3D avec Eficas",
112 "eficasCarmel3D.png")
114 def addActionConditionally(self, fileToTest, commandId, menuLabel, tipLabel, icon):
116 if os.path.isfile(os.path.join(eficasRoot, fileToTest)):
117 a = sgPyQt.createAction(commandId, menuLabel, tipLabel, tipLabel, icon)
118 sgPyQt.createMenu(a, self.mid)
119 sgPyQt.createTool(a, self.tid)
121 ################################################
123 ################################################
125 # study-to-context map
126 #__study2context__ = {}
128 #__current_context__ = None
133 # set and return current GUI context
134 # study ID is passed as parameter
136 #def _setContext(studyID):
138 # if eficasRoot is None:
140 # global __study2context__, __current_context__
141 # if studyID not in __study2context__:
142 # __study2context__[studyID] = GUIcontext()
144 # __current_context__ = __study2context__[studyID]
145 # return __current_context__
148 # -----------------------------------------------------------------------------
150 def OnGUIEvent(commandID):
151 if commandID in dict_command:
152 print("OnGUIEvent :::::::::: commande associée : ", commandID)
153 dict_command[commandID]()
155 print("Pas de commande associée a : ", commandID)
158 # -----------------------------------------------------------------------------
162 # Cette méthode permet les initialisations.
164 #_setContext(sgPyQt.getStudyId())
169 Cette méthode permet l'activation du module, s'il a été chargé mais pas encore
170 activé dans une étude précédente.
178 # -----------------------------------------------------------------------------
180 #def activeStudyChanged(ID):
184 # -----------------------------------------------------------------------------
187 print("-------------------------EFICASGUI::runEficas-------------------------")
189 eficasSalome.runEficas(multi=True)
192 def runEficaspourTelemac():
194 eficasSalome.runEficas("TELEMAC")
197 def runEficaspourAdao():
198 print("runEficas Pour Ada")
200 eficasSalome.runEficas("ADAO")
203 def runEficaspourMT():
204 print("runEficas Pour MT")
206 eficasSalome.runEficas("MT")
209 def runEficaspourSPECA():
210 print("runEficas Pour SPECA")
212 eficasSalome.runEficas("SPECA")
215 def runEficaspourSEP():
216 print("runEficas Pour SEP")
218 eficasSalome.runEficas("SEP")
221 def runEficaspourMap():
222 print("runEficas Pour Map ")
224 eficasSalome.runEficas("MAP")
227 def runEficaspourCarmel3D():
228 print("runEficas Pour Carmel3D ")
230 eficasSalome.runEficas("CARMEL3D")
233 def runEficaspourCF():
234 print("runEficas Pour CF ")
236 eficasSalome.runEficas("CF")
239 def runEficasFichier(version=None):
241 Lancement d'eficas pour ASTER
242 si un fichier est sélectionné, il est ouvert dans eficas
246 a = salome.sg.getAllSelected()
250 editor = getStudyEditor()
251 mySO = editor.study.FindObjectID(selectedEntry)
252 aType = editor.getFileType(mySO)
253 aValue = editor.getFileName(mySO)
254 if aType is not None:
258 QMessageBox.critical(None, "Selection Invalide",
259 "Selectionner un seul fichier SVP")
265 eficasSalome.runEficas(code, fileName, version=version)
267 eficasSalome.runEficas(code, fileName)
273 GUIcontext.TELEMAC_ID: runEficaspourTelemac,
274 GUIcontext.ADAO_ID: runEficaspourAdao,
275 GUIcontext.MT_ID: runEficaspourMT,
276 GUIcontext.SPECA_ID: runEficaspourSPECA,
277 GUIcontext.SEP_ID: runEficaspourSEP,
278 GUIcontext.CF_ID: runEficaspourCF,
279 GUIcontext.MAP_ID: runEficaspourMap,
280 GUIcontext.CARMEL3D_ID: runEficaspourCarmel3D,
281 GUIcontext.MULTICATALOG_ID: runEficas,
283 9041: runEficasFichier,