<desktop>
- <!-- ### MENUBAR ### -->
-
- <menubar>
- <menu-item label-id="EFICAS" item-id="90" pos-id="3">
- <popup-item item-id="941" label-id="Eficas pour Code_Aster" icon-id="eficaster.png" tooltip-id="Editer un jeu de commande ASTER avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="942" label-id="Eficas pour Outils Metier" icon-id="eficasOM.png" tooltip-id="Editer un jeu de commande ASTER avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="945" label-id="Eficas pour Map" icon-id="plus.png" tooltip-id="Editer un jeu de commande Openturns Study avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="947" label-id="Eficas pour Openturns Study" icon-id="eficasotstd.png" tooltip-id="Editer un jeu de commande Openturns Study avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="948" label-id="Eficas pour Openturns Wrapper" icon-id="eficasotwrp.png" tooltip-id="Editer un jeu de commande Openturns Study avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- </menu-item>
- </menubar>
-
- <!-- ### TOOLBAR ### -->
-
- <toolbar label-id="Eficas">
- <toolbutton-item item-id="4041" label-id="Eficas pour Code_Aster" icon-id="eficaster.png" tooltip-id="Editer un jeu de commande ASTER avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <toolbutton-item item-id="4042" label-id="Eficas pour Openturns Outils Metier" icon-id="eficaster.png" tooltip-id="Editer un jeu de commande Outils Metier avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <toolbutton-item item-id="4047" label-id="Eficas pour Openturns Study" icon-id="eficasotstd.png" tooltip-id="Editer un jeu de commande Openturns Study avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <toolbutton-item item-id="4048" label-id="Eficas pour Openturns Wrapper" icon-id="eficasotwrp.png" tooltip-id="Editer un jeu de commande Openturns Wrapper avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- <toolbutton-item item-id="4049" label-id="Eficas pour Map" icon-id="plus.png" tooltip-id="Editer un jeu de commande Map avec Eficas" accel-id="" toggle-id="" execute-action=""/>
- </toolbar>
+ <!-- Menubar and toolbar are now created dynamically depending on the catalogs installed with Eficas.
+ Check file EFICASGUI.py for more details. -->
<!-- ### POPUP MENU ### -->
<popupmenu label-id="Popup for Viewer" context-id="" parent-id="ObjectBrowser" object-id="" pos_id="1">
# -*- coding: utf-8 -*-
+import os
+
"""
Interface PyQt
"""
from PyQt4.QtGui import *
from PyQt4.QtCore import *
-import libSALOME_Swig
+import salome
import SalomePyQt
-# Variable globale pour stocker le Workspace de Salome
-
-WORKSPACE=None
-currentStudyId=None
-desktop=None
-
-# -----------------------------------------------------------------------------
-
-
-
-# -----------------------------------------------------------------------------
-
-import salome
+from pal.studyedit import getStudyEditor
-sg=salome.sg
sgPyQt=SalomePyQt.SalomePyQt()
-from pal.studyedit import getStudyEditor
+# -----------------------------------------------------------------------------
print "EFicasGUI :: :::::::::::::::::::::::::::::::::::::::::::::::::::::"
+# Test Eficas directory
+eficasRoot = os.getenv("EFICAS_ROOT")
+if eficasRoot is None:
+ QMessageBox.critical(sgPyQt.getDesktop(), "Error",
+ "Cannot initialize EFICAS module. Environment "
+ "variable EFICAS_ROOT is not set.")
+elif not os.path.isdir(eficasRoot):
+ QMessageBox.critical(sgPyQt.getDesktop(), "Error",
+ "Cannot initialize EFICAS module. Directory %s does "
+ "not exist (check EFICAS_ROOT environment "
+ "variable)." % eficasRoot)
+
+
+################################################
+# GUI context class
+# Used to store actions, menus, toolbars, etc...
+################################################
+
+class GUIcontext:
+ # menus/toolbars/actions IDs
+ EFICAS_MENU_ID = 90
+ ASTER_ID = 941
+ OM_ID = 942
+ MAP_ID = 943
+ OT_STUDY_ID = 944
+ OT_WRAPPER_ID = 945
+
+ # constructor
+ def __init__(self):
+ # create top-level menu
+ self.mid = sgPyQt.createMenu("Eficas", -1, GUIcontext.EFICAS_MENU_ID,
+ sgPyQt.defaultMenuGroup())
+ # create toolbar
+ self.tid = sgPyQt.createTool("Eficas")
+
+ # create actions conditionally and fill menu and toolbar with actions
+ self.addActionConditionally("Aster/prefs.py", GUIcontext.ASTER_ID,
+ "Eficas pour Code_Aster",
+ "Editer un jeu de commande ASTER avec Eficas",
+ "eficaster.png")
+ self.addActionConditionally("Sep/prefs.py", GUIcontext.OM_ID,
+ "Eficas pour Outils Metier",
+ "Editer un jeu de commande Outils Metier avec Eficas",
+ "eficasOM.png")
+ self.addActionConditionally("Map/prefs.py", GUIcontext.MAP_ID,
+ "Eficas pour Map",
+ "Editer un jeu de commande Map avec Eficas",
+ "plus.png")
+ self.addActionConditionally("Openturns_Study/prefs.py", GUIcontext.OT_STUDY_ID,
+ "Eficas pour Openturns Study",
+ "Editer un jeu de commande Openturns Study avec Eficas",
+ "eficasotstd.png")
+ self.addActionConditionally("Openturns_Wrapper/prefs.py", GUIcontext.OT_WRAPPER_ID,
+ "Eficas pour Openturns Wrapper",
+ "Editer un jeu de commande Openturns Wrapper avec Eficas",
+ "eficasotwrp.png")
+
+ def addActionConditionally(self, fileToTest, commandId, menuLabel, tipLabel, icon):
+ global eficasRoot
+ if os.path.isfile(os.path.join(eficasRoot, fileToTest)):
+ a = sgPyQt.createAction(commandId, menuLabel, tipLabel, tipLabel, icon)
+ sgPyQt.createMenu(a, self.mid)
+ sgPyQt.createTool(a, self.tid)
+
+################################################
+# Global variables
+################################################
+
+# study-to-context map
+__study2context__ = {}
+# current context
+__current_context__ = None
+
+###
+# set and return current GUI context
+# study ID is passed as parameter
+###
+def _setContext( studyID ):
+ global eficasRoot
+ if eficasRoot is None:
+ return
+ global __study2context__, __current_context__
+ if not __study2context__.has_key(studyID):
+ __study2context__[studyID] = GUIcontext()
+ pass
+ __current_context__ = __study2context__[studyID]
+ return __current_context__
# -----------------------------------------------------------------------------
def setSettings():
"""
- Cette méthode permet les initialisations. On définit en particulier
- l'identifiant de l'étude courante.
+ Cette méthode permet les initialisations.
"""
- # le desktop
- desktop=sgPyQt.getDesktop()
- global currentStudyId
- currentStudyId = sgPyQt.getStudyId()
+ _setContext(sgPyQt.getStudyId())
def activate():
"""
# -----------------------------------------------------------------------------
def activeStudyChanged(ID):
- # le desktop
- desktop=sgPyQt.getDesktop()
- global currentStudyId
- currentStudyId=ID
-
-
+ _setContext(ID)
+
#def definePopup(theContext, theObject, theParent):
# print "EFICASGUI --- definePopup"
# -----------------------------------------------------------------------------
-import eficasSalome
-
def runEficas():
print "-------------------------EFICASGUI::runEficas-------------------------"
- print currentStudyId
+ import eficasSalome
eficasSalome.runEficas( "ASTER" )
def runEficaspourOpenturnsStudy():
print "runEficas Pour Openturns Study"
- desktop=sgPyQt.getDesktop()
+ import eficasSalome
eficasSalome.runEficas( "OPENTURNS_STUDY" )
def runEficaspourOpenturnsWrapper():
print "runEficas Pour Openturns Wrapper"
- desktop=sgPyQt.getDesktop()
+ import eficasSalome
eficasSalome.runEficas( "OPENTURNS_WRAPPER" )
def runEficaspourOM():
print "runEficas Pour Outils Metier"
- desktop=sgPyQt.getDesktop()
+ import eficasSalome
eficasSalome.runEficas( "SEP" )
def runEficaspourMap():
print "runEficas Pour Map "
- desktop=sgPyQt.getDesktop()
+ import eficasSalome
eficasSalome.runEficas( "MAP" )
"Selectionner un seul fichier SVP")
return;
-
+ import eficasSalome
if code:
if version :
eficasSalome.runEficas( code, fileName, version=version)
# Partie applicative
dict_command={
- 941:runEficas,# runEficas,
- 942:runEficaspourOM,# runEficas,
- 947:runEficaspourOpenturnsStudy,
- 948:runEficaspourOpenturnsWrapper,
- 949:runEficaspourMap,
-
- 4041:runEficas, #runEficas,
- 4042:runEficaspourOM,# runEficas,
- 4047:runEficaspourOpenturnsStudy,
- 4048:runEficaspourOpenturnsWrapper,
- 4049:runEficaspourMap,
+ GUIcontext.ASTER_ID : runEficas,
+ GUIcontext.OM_ID : runEficaspourOM,
+ GUIcontext.MAP_ID : runEficaspourMap,
+ GUIcontext.OT_STUDY_ID : runEficaspourOpenturnsStudy,
+ GUIcontext.OT_WRAPPER_ID : runEficaspourOpenturnsWrapper,
9041:runEficasFichier,
}
-