From: YOANN AUDOUIN Date: Wed, 28 Mar 2018 14:21:28 +0000 (+0200) Subject: Nettoyage des menus X-Git-Tag: HYDRO_V2_0_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=93dcf7a5f61cb7bb4505cacecf5eb9f35f4d1d7f;p=modules%2Fhydrosolver.git Nettoyage des menus Suppression de la partie mascaret. Renommage de pytel en run_study. telemac2d en param_study. Pour param_study utilisation du catalogue en local. Ajout des bouttons/menu pour Liquid boundaries, breaches et generate interpolks.py Changement des icones en passant aussi. --- diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 0ca50f5..3acdb95 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -16,24 +16,29 @@ # along with SALOME HYDRO module. If not, see . SET(HYDROSOLVER_RESOURCES_FILES - HYDROSOLVERCatalog.xml - icon_variables.png HYDRO.png + HYDROSOLVERCatalog.xml HYDRO_small.png + SalomeApp.xml.in case1d.png case2d.png case_couplage.png create_case1d.png - create_case2d.png create_case_couplage.png - log.png - create_case_pytel.png - case_pytel.png + create_study.png + create_param_study.png + create_telma_cas.png define_boundary_conditions.png edit_boundary_conditions_file.png + edit_breaches_file.png + edit_liquid_boundary_conditions_file.png + generate_interpolks_py.png generate_interpolz_py.png - english.png - francais.png + icon_variables.png + log.png + study_file.png + telma_file.png + param_study_file.png ) INSTALL(FILES ${HYDROSOLVER_RESOURCES_FILES} DESTINATION ${SALOME_HYDROSOLVER_INSTALL_RES_DATA}) diff --git a/resources/case_pytel.png b/resources/case_pytel.png deleted file mode 100644 index a97bddb..0000000 Binary files a/resources/case_pytel.png and /dev/null differ diff --git a/resources/create_case2d.png b/resources/create_case2d.png deleted file mode 100644 index 76df23a..0000000 Binary files a/resources/create_case2d.png and /dev/null differ diff --git a/resources/create_case_pytel.png b/resources/create_case_pytel.png deleted file mode 100644 index 715f54e..0000000 Binary files a/resources/create_case_pytel.png and /dev/null differ diff --git a/resources/create_param_study.png b/resources/create_param_study.png new file mode 100644 index 0000000..502dd92 Binary files /dev/null and b/resources/create_param_study.png differ diff --git a/resources/create_study.png b/resources/create_study.png new file mode 100644 index 0000000..715f54e Binary files /dev/null and b/resources/create_study.png differ diff --git a/resources/create_telma_cas.png b/resources/create_telma_cas.png new file mode 100644 index 0000000..835b4a2 Binary files /dev/null and b/resources/create_telma_cas.png differ diff --git a/resources/edit_breaches_file.png b/resources/edit_breaches_file.png new file mode 100644 index 0000000..332cee4 Binary files /dev/null and b/resources/edit_breaches_file.png differ diff --git a/resources/edit_liquid_boundary_conditions_file.png b/resources/edit_liquid_boundary_conditions_file.png new file mode 100644 index 0000000..332cee4 Binary files /dev/null and b/resources/edit_liquid_boundary_conditions_file.png differ diff --git a/resources/english.png b/resources/english.png deleted file mode 100644 index 3ffa659..0000000 Binary files a/resources/english.png and /dev/null differ diff --git a/resources/francais.png b/resources/francais.png deleted file mode 100644 index 1bc2fcb..0000000 Binary files a/resources/francais.png and /dev/null differ diff --git a/resources/generate_interpolks_py.png b/resources/generate_interpolks_py.png new file mode 100644 index 0000000..332cee4 Binary files /dev/null and b/resources/generate_interpolks_py.png differ diff --git a/resources/param_study_file.png b/resources/param_study_file.png new file mode 100644 index 0000000..502dd92 Binary files /dev/null and b/resources/param_study_file.png differ diff --git a/resources/study_file.png b/resources/study_file.png new file mode 100644 index 0000000..a97bddb Binary files /dev/null and b/resources/study_file.png differ diff --git a/resources/telma_file.png b/resources/telma_file.png new file mode 100644 index 0000000..835b4a2 Binary files /dev/null and b/resources/telma_file.png differ diff --git a/src/HYDROGUI/HYDROSOLVERGUI.py b/src/HYDROGUI/HYDROSOLVERGUI.py index d1823f7..e060a10 100755 --- a/src/HYDROGUI/HYDROSOLVERGUI.py +++ b/src/HYDROGUI/HYDROSOLVERGUI.py @@ -34,12 +34,16 @@ logger = Logger("HYDROGUI", color = termcolor.BLUE) import HYDROSOLVER_ORB from salome.hydro.interpolz_gui import InterpolzDlg -from salome.hydro.gui_utils import HSGUIException, wait_cursor, get_and_check_selected_file_path +from salome.hydro.gui_utils import HSGUIException, wait_cursor, \ + get_and_check_selected_file_path import salome.hydro.study as hydro_study -from salome.hydro.mascaret.eficas.appli import EficasForMascaretAppli -from salome.hydro.telemac2d.eficas.appli import EficasForTelemac2DAppli -from salome.hydro.pytel.gui import create_case_pytel, run_selected_case_pytel, edit_selected_case_pytel, generate_job_for_selected_case_pytel -#from salome.hydro.boundary_conditions.eficas.appli import EficasForBoundaryConditionsAppli +from salome.hydro.run_study.eficas.appli import EficasForRunStudyAppli +from salome.hydro.param_study.eficas.appli import EficasForParamStudyAppli +from salome.hydro.telma.eficas.appli import EficasForTelmaAppli +from salome.hydro.run_study.gui import create_case_study, \ + run_selected_case_study, \ + edit_selected_case_study, \ + generate_job_for_selected_case_study from eficasSalome import runEficas import BndConditionsDialog @@ -52,118 +56,153 @@ import BndConditionsDialog class GUIcontext: # menus/toolbars/actions IDs HYDRO_MENU_ID = 90 - CREATE_MASCARET_CASE_ID = 941 - RUN_MASCARET_ID = 942 - EDIT_MASCARET_CASE_ID = 943 - SHOW_LOG_ID = 944 - CREATE_TELEMAC2D_CASE_ID = 945 - OPEN_SCHEMA_IN_YACS_ID = 950 - CREATE_PYTEL_CASE_ID = 951 - RUN_PYTEL_ID = 952 - EDIT_PYTEL_CASE_ID = 953 - GENERATE_JOB = 954 - #DEFINE_BOUNDARY_CONDITIONS_ID = 955 - DEFINE_CAS_FILE_EN = 955 - EDIT_BOUNDARY_CONDITIONS_FILE_ID = 956 - GENERATE_INTERPOLZ_PY_ID = 957 - GEN_TELEMAC2D_PYTHON_ID = 958 - GEN_TELEMAC2D_YACS_ID = 959 - DEFINE_CAS_FILE_FR = 960 - - def __init__( self ): - # create top-level menu - mid = sgPyQt.createMenu( "Hydro", -1, GUIcontext.HYDRO_MENU_ID, sgPyQt.defaultMenuGroup() ) - # create toolbar - tid = sgPyQt.createTool( "Hydro" ) - # create actions and fill menu and toolbar with actions - a = sgPyQt.createAction( GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID, - "Edit boundary conditions file", "Edit boundary conditions file", - "Create/edit the boundary conditions file for Telemac", - "edit_boundary_conditions_file.png" ) - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) - - - a = sgPyQt.createAction( GUIcontext.CREATE_MASCARET_CASE_ID, - "Create Mascaret case", "Create Mascaret case", - "Create a new Mascaret case", "create_case1d.png" ) - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) + CREATE_STUDY_ID = 951 + EDIT_STUDY_ID = 952 + RUN_STUDY_ID = 953 + GEN_STUDY_BATCH_ID = 954 - a = sgPyQt.createAction( GUIcontext.CREATE_TELEMAC2D_CASE_ID, - "Create Telemac2D case", "Create Telemac2D case", - "Create a new Telemac2D case", "create_case2d.png" ) - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) + CREATE_TELMA_CAS_ID = 955 + EDIT_TELMA_CAS_ID = 956 - a = sgPyQt.createSeparator() - - a = sgPyQt.createAction( GUIcontext.CREATE_PYTEL_CASE_ID, - "Create case for Pytel execution", "Create case for Pytel execution", - "Create a new case for Pytel execution", "create_case_pytel.png" ) - - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) - - a = sgPyQt.createAction( GUIcontext.EDIT_PYTEL_CASE_ID, - "Edit case for Pytel execution", "Edit case for Pytel execution", - "Edit a new case for Pytel execution", "case_pytel.png" ) - - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) - - a = sgPyQt.createSeparator() + GENERATE_INTERPOLZ_PY_ID = 957 + GENERATE_INTERPOLKS_PY_ID = 958 - a = sgPyQt.createAction( GUIcontext.GENERATE_INTERPOLZ_PY_ID, - "Generate interpolz.py", "Generate interpolz.py", - "Generate interpolation script from the template", "generate_interpolz_py.png" ) + # TODO Add create and edit ? + EDIT_BOUNDARY_CONDITIONS_FILE_ID = 959 + EDIT_LIQUID_BOUNDARY_FILE_ID = 960 + EDIT_BREACHES_FILE_ID = 961 - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) + CREATE_PARAM_STUDY_ID = 962 + EDIT_PARAM_STUDY_ID = 963 + GEN_PARAM_STUDY_PYTHON_ID = 964 + GEN_PARAM_STUDY_YACS_ID = 965 - a = sgPyQt.createSeparator() - a = sgPyQt.createAction( GUIcontext.DEFINE_CAS_FILE_EN, - "Edit cas file (English)", "Edit cas file (English)", - "Create/edit a .cas file for Telemac (English)", - "english.png" ) - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) + def __init__(self): + # create top-level menu + mid = sgPyQt.createMenu("Hydro", -1, GUIcontext.HYDRO_MENU_ID, + sgPyQt.defaultMenuGroup()) + # create toolbar + tid = sgPyQt.createTool("Hydro") + # create actions and fill menu and toolbar with actions + act = sgPyQt.createAction(\ + GUIcontext.GENERATE_INTERPOLZ_PY_ID, + "Generate interpolz.py", + "Generate interpolz.py", + "Generate interpolation script from the template", + "generate_interpolz_py.png") - a = sgPyQt.createSeparator() - a = sgPyQt.createAction( GUIcontext.DEFINE_CAS_FILE_FR, - "Edit cas file (French)", "Edit cas file (French)", - "Create/edit a .cas file for Telemac (French)", - "francais.png" ) - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + # create actions and fill menu and toolbar with actions + act = sgPyQt.createAction(\ + GUIcontext.GENERATE_INTERPOLKS_PY_ID, + "Generate interpolks.py", + "Generate interpolks.py", + "Generate friction coef script from the template", + "generate_interpolks_py.png") + + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createSeparator() + + act = sgPyQt.createAction(\ + GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID, + "Edit boundary conditions file", + "Edit boundary conditions file", + "Create/edit the boundary conditions file for Telemac", + "edit_boundary_conditions_file.png") + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createAction(\ + GUIcontext.EDIT_LIQUID_BOUNDARY_FILE_ID, + "Edit liquid boundary conditions file", + "Edit liquid boundary conditions file", + "Create/edit the liquid boundary conditions file for Telemac", + "edit_liquid_boundary_conditions_file.png") + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createAction(\ + GUIcontext.EDIT_BREACHES_FILE_ID, + "Edit breaches file", + "Edit breaches file", + "Create/edit the breaches file for Telemac", + "edit_breaches_file.png") + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createAction(\ + GUIcontext.CREATE_TELMA_CAS_ID, + "Edit cas file (English)", + "Edit cas file (English)", + "Create/edit act .cas file for Telemac (English)", + "create_telma_cas.png") + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createAction(\ + GUIcontext.CREATE_STUDY_ID, + "Execute a steering file", + "Execute a steering file", + "Fill formular for a normal execution", + "create_study.png") + + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createAction(\ + GUIcontext.CREATE_PARAM_STUDY_ID, + "Create Parameter Study", + "Create Parameter Study", + "Create act new Parameter Study", + "create_param_study.png") + sgPyQt.createMenu(act, mid) + sgPyQt.createTool(act, tid) + + act = sgPyQt.createSeparator() # the following action are used in context popup - sgPyQt.createAction( GUIcontext.RUN_MASCARET_ID, "Compute case", "Compute case", - "Run Mascaret solver to compute the case" ) - sgPyQt.createAction( GUIcontext.EDIT_MASCARET_CASE_ID, "Edit case", "Edit case", - "Edit the selected Mascaret case" ) - sgPyQt.createAction( GUIcontext.SHOW_LOG_ID, "Show log", "Show log", - "Show the log for the selected variable" ) - - sgPyQt.createAction( GUIcontext.GEN_TELEMAC2D_PYTHON_ID, "Generate Python script", - "Generate Python script", - "Generate a Python script from the eficas date" ) - sgPyQt.createAction( GUIcontext.GEN_TELEMAC2D_YACS_ID, "Generate YACS script", - "Generate YACS script", - "Generate a YACS script from the eficas date" ) - - sgPyQt.createAction( GUIcontext.RUN_PYTEL_ID, "Compute case", "Compute case", - "Run Pytel launcher to compute the case" ) - sgPyQt.createAction( GUIcontext.EDIT_PYTEL_CASE_ID, "Edit case", "Edit case", - "Edit the selected Pytel case" ) - sgPyQt.createAction( GUIcontext.GENERATE_JOB, "Generate batch job", "Generate batch job", - "Generate a batch job to run the selected case") - - sgPyQt.createAction( GUIcontext.DEFINE_CAS_FILE_EN, "Edit .cas file", "Edit .cas file", - "Edit .cas file") - sgPyQt.createAction( GUIcontext.DEFINE_CAS_FILE_FR, "Edit .cas file (French)", "Edit .cas file (French)", - "Edit .cas file (French)") + + sgPyQt.createAction(\ + GUIcontext.EDIT_PARAM_STUDY_ID, + "Edit param study", + "Edit param study", + "Edit study using python launcher") + sgPyQt.createAction(\ + GUIcontext.GEN_PARAM_STUDY_PYTHON_ID, + "Generate Python script", + "Generate Python script", + "Generate act Python script from the eficas date") + sgPyQt.createAction(\ + GUIcontext.GEN_PARAM_STUDY_YACS_ID, + "Generate YACS script", + "Generate YACS script", + "Generate act YACS script from the eficas date") + + sgPyQt.createAction(\ + GUIcontext.RUN_STUDY_ID, + "Compute study", + "Compute study", + "Compute study using python launcher") + sgPyQt.createAction(\ + GUIcontext.EDIT_STUDY_ID, + "Edit study", + "Edit study", + "Edit the selected study") + sgPyQt.createAction(\ + GUIcontext.GEN_STUDY_BATCH_ID, + "Generate batch job", + "Generate batch job", + "Generate a batch job to run the selected study") + + sgPyQt.createAction(\ + GUIcontext.EDIT_TELMA_CAS_ID, + "Edit Steering file", + "Edit Steering file", + "Edit a Telemac-Mascaret steering file") ################################################ @@ -171,7 +210,7 @@ class GUIcontext: ################################################ # study-to-context map -__study2context__ = {} +__study2context__ = {} # current context __current_context__ = None # object counter @@ -192,16 +231,16 @@ def _getStudyId(): ### def _getStudy(): studyId = _getStudyId() - study = getStudyManager().GetStudyByID( studyId ) + study = getStudyManager().GetStudyByID(studyId) return study ### # returns True if object has children ### -def _hasChildren( sobj ): +def _hasChildren(sobj): if sobj: study = _getStudy() - iter = study.NewChildIterator( sobj ) + iter = study.NewChildIterator(sobj) while iter.More(): name = iter.Value().GetName() if name: @@ -222,7 +261,7 @@ def _getContext(): # set and return current GUI context # study ID is passed as parameter ### -def _setContext( studyID ): +def _setContext(studyID): global __study2context__, __current_context__ if not __study2context__.has_key(studyID): __study2context__[studyID] = GUIcontext() @@ -233,7 +272,7 @@ def _setContext( studyID ): ### # increment object counter in the map ### -def _incObjToMap( m, id ): +def _incObjToMap(m, id): if id not in m: m[id] = 0 m[id] += 1 pass @@ -245,7 +284,7 @@ def _incObjToMap( m, id ): # called when module is activated # returns True if activating is successfull and False otherwise def activate(): - ctx = _setContext( _getStudyId() ) + ctx = _setContext(_getStudyId()) return True # called when module is deactivated @@ -254,8 +293,8 @@ def deactivate(): # called when active study is changed # active study ID is passed as parameter -def activeStudyChanged( studyID ): - ctx = _setContext( _getStudyId() ) +def activeStudyChanged(studyID): + ctx = _setContext(_getStudyId()) pass # called when popup menu is invoked @@ -267,22 +306,20 @@ def createPopupMenu(popup, context): # one object is selected sobj = ed.study.FindObjectID(salome.sg.getSelected(0)) selectedType = ed.getTypeId(sobj) - if selectedType == hydro_study.MASCARET_CASE_TYPE_ID: - popup.addAction(sgPyQt.action(GUIcontext.EDIT_MASCARET_CASE_ID)) - popup.addAction(sgPyQt.action(GUIcontext.RUN_MASCARET_ID)) - elif selectedType == hydro_study.TELEMAC2D_CASE_TYPE_ID: - popup.addAction(sgPyQt.action(GUIcontext.GEN_TELEMAC2D_PYTHON_ID)) - popup.addAction(sgPyQt.action(GUIcontext.GEN_TELEMAC2D_YACS_ID)) - elif selectedType == hydro_study.LOG_TYPE_ID: - popup.addAction(sgPyQt.action(GUIcontext.SHOW_LOG_ID)) - elif selectedType == hydro_study.PYTEL_CASE_TYPE_ID: - popup.addAction(sgPyQt.action(GUIcontext.EDIT_PYTEL_CASE_ID)) - popup.addAction(sgPyQt.action(GUIcontext.RUN_PYTEL_ID)) - popup.addAction(sgPyQt.action(GUIcontext.GENERATE_JOB)) + if selectedType == hydro_study.TELMA_TYPE_ID: + popup.addAction(sgPyQt.action(GUIcontext.EDIT_TELMA_CAS_ID)) + elif selectedType == hydro_study.PARAM_STUDY_TYPE_ID: + popup.addAction(sgPyQt.action(GUIcontext.EDIT_PARAM_STUDY_ID)) + popup.addAction(sgPyQt.action(GUIcontext.GEN_PARAM_STUDY_PYTHON_ID)) + popup.addAction(sgPyQt.action(GUIcontext.GEN_PARAM_STUDY_YACS_ID)) + elif selectedType == hydro_study.STUDY_TYPE_ID: + popup.addAction(sgPyQt.action(GUIcontext.EDIT_STUDY_ID)) + popup.addAction(sgPyQt.action(GUIcontext.RUN_STUDY_ID)) + popup.addAction(sgPyQt.action(GUIcontext.GEN_STUDY_BATCH_ID)) # called when GUI action is activated # action ID is passed as parameter -def OnGUIEvent( commandID ): +def OnGUIEvent(commandID): try: dict_command[commandID]() except HSGUIException, exc: @@ -298,7 +335,7 @@ def OnGUIEvent( commandID ): msgBox = QMessageBox(QMessageBox.Critical, QApplication.translate("OnGUIEvent", "Error"), msg, - parent = sgPyQt.getDesktop()) + parent=sgPyQt.getDesktop()) msgBox.setDetailedText(traceback.format_exc()) msgBox.exec_() @@ -306,94 +343,28 @@ def OnGUIEvent( commandID ): # GUI actions implementation ################################################ -# --------------------------------------------------------------------------------------- # -# Dialog box for text display (deprecated, it was only used in the calcium coupling test) # -# --------------------------------------------------------------------------------------- # -""" -from TextDisplayDialog import Ui_TextDisplayDialog - -class MyTextDisplayDialog(Ui_TextDisplayDialog, QDialog): - - def __init__(self, parent = None, modal = 0): - QDialog.__init__(self, parent) - Ui_TextDisplayDialog.__init__(self) - self.setupUi(self) - (self.closeButton.clicked.connect(self.close) - - def set_log(self, log): - self.contentTextEdit.setPlainText(log) - self.setWindowTitle("Coupling log") -""" - -### -# Open Eficas for Mascaret to create a new case -### -def create_mascaret_case(): - EficasForMascaretAppli() - -### -# Open Eficas for Mascaret to edit the selected case -### -def edit_mascaret_case(): - EficasForMascaretAppli(get_and_check_selected_file_path()) - -# Run Mascaret on selected case -def run_mascaret(): - try: - with wait_cursor: - ed = hydro_study.HydroStudyEditor() - sobj = ed.editor.study.FindObjectID(salome.sg.getSelected(0)) - (file_list, lig_file, input_vars, output_vars) = ed.get_mascaret_params_from_case(sobj) - var_names = [var["NOM"].strip() for var in output_vars] - mascaret_vars = [var["VARIABLE_MASCARET"].strip() for var in output_vars] - engine = salome.lcc.FindOrLoadComponent("FactoryServer", "MASCARET") - logger.debug("Calling MASCARET.Compute(%s, %s, %s)" % - (file_list, lig_file, mascaret_vars)) - output_values = engine.Compute(file_list, lig_file, mascaret_vars) - ed.add_results_to_mascaret_case(sobj, var_names, output_values) - salome.sg.updateObjBrowser( 0 ) - except SALOME.SALOME_Exception, exc: - salome.sg.updateObjBrowser( 0 ) - msg = unicode(QApplication.translate("run_mascaret", - "An error happened while trying to run Mascaret:")) - msg += "\n" + exc.details.text - raise HSGUIException(msg) - -# Display selected log (deprecated, it was only used in the calcium coupling test) -def show_log(): - ed = hydro_study.HydroStudyEditor() - sobj = ed.editor.study.FindObjectID(salome.sg.getSelected(0)) - if sobj is not None: - (found, attr) = getStudyEditor().builder.FindAttribute( - sobj, "AttributeParameter") - log = attr.GetString("log") - dialog = MyTextDisplayDialog(sgPyQt.getDesktop()) - dialog.set_log(log) - dialog.show() - ### -# Open Eficas for Telemac2D to create a new case +# Open Eficas for a new parametric study ### -def create_telemac2d_case(): - EficasForTelemac2DAppli() - +def create_param_study(): + EficasForParamStudyAppli() ### -# Open Eficas for Telemac2D to edit the selected case +# Open Eficas to edit a new parametric study ### -def edit_telemac2d_case(): - EficasForTelemac2DAppli(get_and_check_selected_file_path()) +def edit_param_study(): + EficasForParamStudyAppli(get_and_check_selected_file_path()) ### # Generate a python script from the eficas file ### -def generate_telemac2d_python(): +def generate_param_study_python(): try: with wait_cursor: ed = hydro_study.HydroStudyEditor() sobj = get_and_check_selected_file_path() ed.generate_study_script(sobj) except SALOME.SALOME_Exception, exc: - salome.sg.updateObjBrowser( 0 ) + salome.sg.updateObjBrowser(0) msg = unicode(QApplication.translate("generate_telemac2d_python", "An error happened while trying to generate telemac2d Python script:")) msg += "\n" + exc.details.text @@ -402,14 +373,14 @@ def generate_telemac2d_python(): ### # Generate a python script from the eficas file ### -def generate_telemac2d_yacs(): +def generate_param_study_yacs(): try: with wait_cursor: ed = hydro_study.HydroStudyEditor() sobj = get_and_check_selected_file_path() ed.generate_study_yacs(sobj) except SALOME.SALOME_Exception, exc: - salome.sg.updateObjBrowser( 0 ) + salome.sg.updateObjBrowser(0) msg = unicode(QApplication.translate("generate_telemac2d_yacs", "An error happened while trying to generate telemac2d Python script:")) msg += "\n" + exc.details.text @@ -427,12 +398,6 @@ def open_schema_in_yacs(): yg = salome.ImportComponentGUI("YACS") yg.loadSchema(filename) -### -# Open Eficas for boundary conditions definition -### -#def define_boundary_conditions(): -# EficasForBoundaryConditionsAppli() - ### # Open dialog for boundary conditions edition ### @@ -441,6 +406,26 @@ def edit_boundary_conditions_file(): dlg = BndConditionsDialog.BoundaryConditionsDialog(desktop) dlg.exec_() +### +# Open dialog for liquid boundary conditions edition +### +def edit_liquid_boundary_file(): + # TODO: Implement gui + QMessageBox.warning(sgPyQt.getDesktop(), + "", + "Liquid boundary file handling not implemented yet") + return + +### +# Open dialog for breaches file edition +### +def edit_breaches_file(): + # TODO: Implement gui + QMessageBox.warning(sgPyQt.getDesktop(), + "", + "Breaches file handling not implemented yet") + return + ### # Open dialog for interpolz.py script generation ### @@ -450,33 +435,45 @@ def generate_interpolz_py(): dlg.show() ### -# Open dialog for boundary conditions edition +# Open dialog for interpolks.py script generation ### -def eficas_for_cas_Telemac2D_fr(): - EficasForTelemac2DAppli(code='TELEMAC', lang = 'fr') +def generate_interpolks_py(): + QMessageBox.warning(sgPyQt.getDesktop(), + "", + "Generation of interpolks.py not implemented yet") + return -def eficas_for_cas_Telemac2D_en(): - EficasForTelemac2DAppli(code='TELEMAC', lang = 'en') +### +# Open dialog for creation of steering file +### +def create_telma_cas(): + EficasForTelmaAppli(code='TELEMAC', lang='en') + +### +# Open dialog for edition of steering file +### +def edit_telma_cas(): + # TODO: See how to detect module + EficasForTelmaAppli(fichier=get_and_check_selected_file_path(), + code='TELEMAC', lang='en') ### # Commands dictionary ### dict_command = { - GUIcontext.CREATE_MASCARET_CASE_ID: create_mascaret_case, - GUIcontext.RUN_MASCARET_ID: run_mascaret, - GUIcontext.EDIT_MASCARET_CASE_ID: edit_mascaret_case, - GUIcontext.SHOW_LOG_ID: show_log, - GUIcontext.CREATE_TELEMAC2D_CASE_ID: create_telemac2d_case, - GUIcontext.GEN_TELEMAC2D_PYTHON_ID: generate_telemac2d_python, - GUIcontext.GEN_TELEMAC2D_YACS_ID: generate_telemac2d_yacs, - GUIcontext.OPEN_SCHEMA_IN_YACS_ID: open_schema_in_yacs, - GUIcontext.CREATE_PYTEL_CASE_ID: create_case_pytel, - GUIcontext.RUN_PYTEL_ID: run_selected_case_pytel, - GUIcontext.EDIT_PYTEL_CASE_ID: edit_selected_case_pytel, - GUIcontext.GENERATE_JOB: generate_job_for_selected_case_pytel, - #GUIcontext.DEFINE_BOUNDARY_CONDITIONS_ID: define_boundary_conditions, - GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID: edit_boundary_conditions_file, + GUIcontext.CREATE_STUDY_ID: create_case_study, + GUIcontext.EDIT_STUDY_ID: edit_selected_case_study, + GUIcontext.RUN_STUDY_ID: run_selected_case_study, + GUIcontext.GEN_STUDY_BATCH_ID: generate_job_for_selected_case_study, + GUIcontext.CREATE_TELMA_CAS_ID: create_telma_cas, + GUIcontext.EDIT_TELMA_CAS_ID: edit_telma_cas, GUIcontext.GENERATE_INTERPOLZ_PY_ID: generate_interpolz_py, - GUIcontext.DEFINE_CAS_FILE_EN: eficas_for_cas_Telemac2D_en, - GUIcontext.DEFINE_CAS_FILE_FR: eficas_for_cas_Telemac2D_fr, + GUIcontext.GENERATE_INTERPOLKS_PY_ID: generate_interpolks_py, + GUIcontext.EDIT_LIQUID_BOUNDARY_FILE_ID: edit_liquid_boundary_file, + GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID: edit_boundary_conditions_file, + GUIcontext.EDIT_BREACHES_FILE_ID: edit_breaches_file, + GUIcontext.CREATE_PARAM_STUDY_ID: create_param_study, + GUIcontext.EDIT_PARAM_STUDY_ID: edit_param_study, + GUIcontext.GEN_PARAM_STUDY_PYTHON_ID: generate_param_study_python, + GUIcontext.GEN_PARAM_STUDY_YACS_ID: generate_param_study_yacs, } diff --git a/src/salome_hydro/CMakeLists.txt b/src/salome_hydro/CMakeLists.txt index a6c8307..f3d05f4 100644 --- a/src/salome_hydro/CMakeLists.txt +++ b/src/salome_hydro/CMakeLists.txt @@ -15,9 +15,9 @@ # You should have received a copy of the GNU General Public License # along with SALOME HYDRO module. If not, see . -ADD_SUBDIRECTORY(mascaret) -ADD_SUBDIRECTORY(telemac2d) -ADD_SUBDIRECTORY(pytel) +ADD_SUBDIRECTORY(telma) +ADD_SUBDIRECTORY(param_study) +ADD_SUBDIRECTORY(run_study) ADD_SUBDIRECTORY(boundary_conditions) # --- Python files --- diff --git a/src/salome_hydro/mascaret/CMakeLists.txt b/src/salome_hydro/mascaret/CMakeLists.txt deleted file mode 100644 index 91f7cd3..0000000 --- a/src/salome_hydro/mascaret/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -ADD_SUBDIRECTORY(eficas) - -# --- Python files --- - -SET(PYFILES - __init__.py -) - -# --- rules --- - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/mascaret) diff --git a/src/salome_hydro/mascaret/__init__.py b/src/salome_hydro/mascaret/__init__.py deleted file mode 100644 index e4b3bfd..0000000 --- a/src/salome_hydro/mascaret/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . diff --git a/src/salome_hydro/mascaret/eficas/CMakeLists.txt b/src/salome_hydro/mascaret/eficas/CMakeLists.txt deleted file mode 100644 index deb3c65..0000000 --- a/src/salome_hydro/mascaret/eficas/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -# --- Python files --- - -SET(PYFILES - __init__.py - appli.py - configuration_mascaret.py - prefs_mascaret.py - prefs.py - mascaret_V7_cata.py -) - -# --- rules --- - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/mascaret/eficas) diff --git a/src/salome_hydro/mascaret/eficas/__init__.py b/src/salome_hydro/mascaret/eficas/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/salome_hydro/mascaret/eficas/appli.py b/src/salome_hydro/mascaret/eficas/appli.py deleted file mode 100644 index ed5e4e4..0000000 --- a/src/salome_hydro/mascaret/eficas/appli.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import sys -import re - -from PyQt5.QtWidgets import QMessageBox , QScrollArea, QGridLayout - - -import salome -import SalomePyQt -sgPyQt = SalomePyQt.SalomePyQt() - -from salome.kernel.logger import Logger -from salome.kernel import termcolor -logger = Logger("salome.hydro.mascaret.eficas.appli", - color = termcolor.GREEN_FG) - -import eficasSalome - -from salome.hydro.study import HydroStudyEditor - -class EficasForMascaretAppli(eficasSalome.MyEficas): - """ - This class launches Eficas and adds entries for the created files in - MASCARET component in the study tree. The messages in this class are in - french because they are displayed in Eficas interface. - - :type fichier: string - :param fichier: path of an Eficas file to open - - """ - def __init__(self, fichier = None, version = None): - self.ed = HydroStudyEditor() - self.codedir = os.path.dirname(__file__) - sys.path[:0] = [self.codedir] - area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); - eficasSalome.MyEficas.__init__(self, area, - "mascaret", - fichier, version = version) - gridLayout = QGridLayout(area) - gridLayout.addWidget(self) - area.setWidgetResizable(1) - sgPyQt.createView("Eficas Mascaret", self) - - def addJdcInSalome(self, jdcPath): - """ - Add the newly created file in Salome study - """ - try: - self.ed.find_or_create_mascaret_case(jdcPath) - except Exception, exc: - msgError = "Can't add file to Salome study tree" - logger.exception(msgError) - QMessageBox.warning(self, self.tr("Warning"), - self.tr("%s. Reason:\n%s\n\nSee logs for " - "more details." % (msgError, exc))) - salome.sg.updateObjBrowser(0) - - def closeEvent(self, event): - while self.codedir in sys.path: - sys.path.remove(self.codedir) - eficasSalome.MyEficas.closeEvent(self, event) diff --git a/src/salome_hydro/mascaret/eficas/configuration_mascaret.py b/src/salome_hydro/mascaret/eficas/configuration_mascaret.py deleted file mode 100644 index ac321f2..0000000 --- a/src/salome_hydro/mascaret/eficas/configuration_mascaret.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os - -from Editeur.catadesc import CatalogDescription -from InterfaceQT4.configuration import configBase - -class CONFIG(configBase): - - def __init__(self, appli, repIni): - """ - This class stores the configuration parameters for Eficas - """ - configBase.__init__(self, appli, repIni) - - # Configuration parameters - self.savedir = os.getenv("HOME") - self.catalogues = (CatalogDescription("mascaret_V7", - os.path.join(repIni, "mascaret_V7_cata.py")),) - self.lang = 'fr' - - def save_params(self): - pass - -def make_config(appli, rep): - return CONFIG(appli, rep) - -def make_config_style(appli, rep): - return None diff --git a/src/salome_hydro/mascaret/eficas/mascaret_V7_cata.py b/src/salome_hydro/mascaret/eficas/mascaret_V7_cata.py deleted file mode 100644 index c3a97a3..0000000 --- a/src/salome_hydro/mascaret/eficas/mascaret_V7_cata.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -from Accas import * - -JdC = JDC_CATA(regles = (UN_PARMI('MASCARET',)), - ) - -MASCARET = PROC( - nom = "MASCARET", op = None, - fr = u"Définition d'un cas d'étude Mascaret", - ang = u"Definition of a Mascaret study case", - FICHIER_DICO = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier Dictionnaire", - ang = u"Dictionary file"), - FICHIER_MOT_CLE = SIMP(statut = "o", - typ = ('Fichier', 'Fichiers CAS (*.cas);;Tous les fichiers (*)',), - fr = u"Fichier Mot Clé", - ang = u"Keyword file"), - FICHIER_GEOMETRIE = SIMP(statut = "f", - typ = ('Fichier', 'Fichiers GEO (*.geo);;Tous les fichiers (*)',), - fr = u"Fichier de géométrie", - ang = u"Geometry file"), - FICHIER_LOI = FACT(statut = 'f', max = '**', - NOM = SIMP(statut = "o", - typ = ('Fichier', 'Fichiers LOI (*.loi);;Tous les fichiers (*)',), - fr = u"Fichier de lois", - ang = u"Laws file"), - ), - FICHIER_ABAQUES = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)',), - fr = u"Fichier abaques", - ang = u"Abacus file"), - FICHIER_CASIER = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)',), - fr = u"Fichier casier", - ang = u"Compartment file"), - FICHIER_DAMOCLE = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)',), - fr = u"Fichier damocle", - ang = u"Damocle file"), - FICHIER_LIG = SIMP(statut = "o", - typ = ('Fichier', 'Fichiers LIG (*.lig);;Tous les fichiers (*)',), - fr = u"Fichier LIG", - ang = u"LIG file"), - LISTING = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)', "Sauvegarde"), - fr = u"Fichier de listing", - ang = u"Listing file"), - LISTING_CASIER = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)', "Sauvegarde"), - fr = u"Fichier de listing casier", - ang = u"Compartment listing file"), - LISTING_LIAISON = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)', "Sauvegarde"), - fr = u"Fichier de listing liaison", - ang = u"Link listing file"), - RESULTAT = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)', "Sauvegarde"), - fr = u"Fichier de résultat", - ang = u"Result file"), - RESULTAT_CASIER = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)', "Sauvegarde"), - fr = u"Fichier de résultat casier", - ang = u"Compartment result file"), - RESULTAT_LIAISON = SIMP(statut = "f", - typ = ('Fichier', 'Tous les fichiers (*)', "Sauvegarde"), - fr = u"Fichier de résultat liaison", - ang = u"Link result file"), - VARIABLE_SORTIE = FACT(statut = 'f', max = '**', - fr = u"Variable de sortie du calcul", - ang = u"Computation output variable", - NOM = SIMP(statut = "o", typ = 'TXM', - fr = u"Nom de la variable", - ang = u"Variable name"), - VARIABLE_MASCARET = SIMP(statut = "o", typ = 'TXM', - fr = u'Variable Mascaret (ex : "Etat.Z(1,0,0)")', - ang = u'Mascaret variable (ex : "Etat.Z(1,0,0)")'), - ), - VARIABLE_ENTREE = FACT(statut = 'f', max = '**', - fr = u"Variable d'entrée du calcul", - ang = u"Computation input variable", - NOM = SIMP(statut = "o", typ = 'TXM', - fr = u"Nom de la variable", - ang = u"Variable name"), - VARIABLE_MASCARET = SIMP(statut = "o", typ = 'TXM', - fr = u'Variable Mascaret (ex : "Modele.Lois.Debit(1,1-2,0)")', - ang = u'Mascaret variable (ex : "Modele.Lois.Debit(1,1-2,0)")'), - ), -) -TEXTE_NEW_JDC="MASCARET()" diff --git a/src/salome_hydro/mascaret/eficas/prefs.py b/src/salome_hydro/mascaret/eficas/prefs.py deleted file mode 100644 index d0e8113..0000000 --- a/src/salome_hydro/mascaret/eficas/prefs.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -code = "mascaret" diff --git a/src/salome_hydro/mascaret/eficas/prefs_mascaret.py b/src/salome_hydro/mascaret/eficas/prefs_mascaret.py deleted file mode 100644 index e53112c..0000000 --- a/src/salome_hydro/mascaret/eficas/prefs_mascaret.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import sys - -repIni = os.path.dirname(__file__) -INSTALLDIR = os.getenv("EFICAS_ROOT") -closeAutreCommande=True -closeFrameRechercheCommande=True -closeArbre=True -closeCopier=True -suiteTelemac=True diff --git a/src/salome_hydro/param_study/CMakeLists.txt b/src/salome_hydro/param_study/CMakeLists.txt new file mode 100644 index 0000000..51fa92a --- /dev/null +++ b/src/salome_hydro/param_study/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +# --- Python files --- + +SET(PYFILES + __init__.py +) + +SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/param_study) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR}) + +ADD_SUBDIRECTORY(eficas) diff --git a/src/salome_hydro/param_study/__init__.py b/src/salome_hydro/param_study/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/salome_hydro/param_study/eficas/CMakeLists.txt b/src/salome_hydro/param_study/eficas/CMakeLists.txt new file mode 100644 index 0000000..ac8e894 --- /dev/null +++ b/src/salome_hydro/param_study/eficas/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +# --- Python files --- + +SET(PYFILES + __init__.py + configuration_telemac2d.py + prefs_telemac2d.py + prefs.py + appli.py + param_study_cata.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/param_study/eficas) diff --git a/src/salome_hydro/param_study/eficas/__init__.py b/src/salome_hydro/param_study/eficas/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/salome_hydro/param_study/eficas/appli.py b/src/salome_hydro/param_study/eficas/appli.py new file mode 100644 index 0000000..a4411d4 --- /dev/null +++ b/src/salome_hydro/param_study/eficas/appli.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import sys +import re + +from PyQt5.QtWidgets import QMessageBox , QScrollArea, QGridLayout + + +import salome +import SalomePyQt +sgPyQt = SalomePyQt.SalomePyQt() + +from salome.kernel.logger import Logger +from salome.kernel import termcolor +logger = Logger("salome.hydro.param_study.eficas.appli", + color = termcolor.GREEN_FG) + +import eficasSalome + +from salome.hydro.study import HydroStudyEditor + +def importFirst(): + """ + Horrible hack to allow a correct load of a Telemac case file when done after + some other edition, such as create case for Pytel execution. + """ + eficasTelemacPath = os.path.join(eficasSalome.eficasConfig.eficasPath,'Telemac') + sys.path.insert(0, eficasTelemacPath) + from telemac2d_enum_auto import TelemacdicoEn + sys.path.pop(0) + +importFirst() + +class EficasForParamStudyAppli(eficasSalome.MyEficas): + """ + This class launches Eficas and adds entries for the created files in + HYDRO component in the study tree. The messages in this class are in + french because they are displayed in Eficas interface. + + :type fichier: string + :param fichier: path of an Eficas file to open + + """ + def __init__(self, code="telemac2d", fichier=None, version=None, lang=None): + self.ed = HydroStudyEditor() + self.codedir = os.path.dirname(__file__) + sys.path[:0] = [self.codedir] + area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); + eficasSalome.MyEficas.__init__(self, area, + code=code, fichier=fichier, + version=version, lang=lang) + gridLayout = QGridLayout(area) + gridLayout.addWidget(self) + area.setWidgetResizable(1) + sgPyQt.createView("Eficas Telemac2D", self) + if fichier == None: + self.fileNew() + else: + self.addJdcInSalome(fichier) + + def addJdcInSalome(self, jdcPath): + """ + Add the newly created file in Salome study + """ + try: + self.ed.find_or_create_param_study(jdcPath) + except Exception, exc: + msgError = "Can't add file to Salome study tree" + logger.exception(msgError) + QMessageBox.warning(self, self.tr("Warning"), + self.tr("%s. Reason:\n%s\n\nSee logs for " + "more details." % (msgError, exc))) + salome.sg.updateObjBrowser(0) + + def closeEvent(self, event): + while self.codedir in sys.path: + sys.path.remove(self.codedir) + eficasSalome.MyEficas.closeEvent(self, event) diff --git a/src/salome_hydro/param_study/eficas/configuration_telemac2d.py b/src/salome_hydro/param_study/eficas/configuration_telemac2d.py new file mode 100644 index 0000000..1e9468f --- /dev/null +++ b/src/salome_hydro/param_study/eficas/configuration_telemac2d.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os + +from Editeur.catadesc import CatalogDescription +from InterfaceQT4.configuration import configBase + +class CONFIG(configBase): + + def __init__(self, appli, repIni): + """ + This class stores the configuration parameters for Eficas + """ + configBase.__init__(self, appli, repIni) + + # Configuration parameters + self.savedir = os.getenv("HOME") + self.catalogues = (CatalogDescription("param_study", + os.path.join(repIni, "param_study_cata.py")),) + self.lang = 'fr' + + def save_params(self): + pass + +def make_config(appli, rep): + return CONFIG(appli, rep) + +def make_config_style(appli, rep): + return None diff --git a/src/salome_hydro/param_study/eficas/param_study_cata.py b/src/salome_hydro/param_study/eficas/param_study_cata.py new file mode 100644 index 0000000..c95ea1c --- /dev/null +++ b/src/salome_hydro/param_study/eficas/param_study_cata.py @@ -0,0 +1,202 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import types +from Accas import * + +def get_list_var_api(module): + """ + Returns the list of variables avaialable throught the API for module + + @param One of the modules of TELEMAC-MASCARET + """ + if module == 'TELEMAC2D': + from TelApy.api.t2d import Telemac2d + model = Telemac2d('dummy.cas') + elif module == 'TELEMAC3D': + from TelApy.api.t3d import Telemac3d + model = Telemac3d('dummy.cas') + elif module == 'SISYPHE': + from TelApy.api.sis import Sisyphe + model = Sisyphe('dummy.cas') + else: + return ['No variable available'] + + varnames, _ = model.list_variables() + del(model) + return sorted(varnames) + +class Tuple: + def __init__(self,ntuple): + self.ntuple=ntuple + + def __convert__(self,valeur): + if type(valeur) == types.StringType: + return None + if len(valeur) != self.ntuple: + return None + return valeur + + def info(self): + return "Tuple de %s elements" % self.ntuple + + __repr__=info + __str__=info + +JdC = JDC_CATA(regles = (UN_PARMI('TELEMAC2D',)), + ) + + + +TELEMAC2D = PROC( + nom = "TELEMAC2D", op = None, + fr = u"Définition d'un cas d'étude Telemac2D", + ang = u"Definition of a Telemac2D study case", + STEERING_FILE = SIMP(statut = "o", typ = 'Fichier', + fr = u"Fichier de description du cas", + ang = u"Case description file", + ), + USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire', + fr = "Fichier Fortran utilisateur", + ang = u"Fortran user file", + ), + WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire', + defaut = '/tmp', + fr = "Repertoire de travail", + ang = u"Working directory user file", + ), + RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire', + fr = "Repertoire de travail", + ang = u"Working directory user file", + ), + RESULTS_FILE_NAME = SIMP(statut = "f", typ = 'TXM', + fr = u"Fichier des resultats (Ecrasera celui dans le fichier cas)", + ang = u"Results file (Will replace the one in the steering file)" + ), + Consigne = SIMP(statut ="o", homo="information", typ="TXM", + defaut = "All index are in Python numbering (Starting from 0)", + ), + INPUT_VARIABLE = FACT(statut = 'f', max = '**', + fr = u"Variable d'entrée du calcul", + ang = u"Computation input variable", + + NAME = SIMP(statut = "o", typ = 'TXM', + fr = u"Nom de la variable (format Python)", + ang = u"Variable name (Python format)" + ), + VAR_INFO = FACT(statut = "o", + fr = u'Variable du modèle Telemac2D', + ang = u'Telemac2D model variable', + + VAR_NAME = SIMP(statut = "o", typ = 'TXM', + intoSug = get_list_var_api('TELEMAC2D'), + fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")', + ang = u'Model variable name (ex: "MODEL.DEBIT")' + ), + DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM', + fr = u'Valeur par défaut', + ang = u'Default value', + ), + ZONE_DEF = FACT(statut = "o", + ang = u'Variable definition area', + fr = u'Zone de définition de la variable', + + TYPE = SIMP(statut = "o", typ = 'TXM', + into = ['INDEX', 'RANGE', 'POLYGON', 'POLYGON_FILE'], + fenetreIhm="menuDeroulant", + fr = u'Type de definition de la variable', + ang = u'Type of definition for the variable', + ), + + b_INDEX = BLOC(condition = "TYPE == 'INDEX'", + INDEX = SIMP(statut = "o", typ = Tuple(3), + defaut = (0, 0, 0), + ang = "Index of the variable", + fr = u"Indice de la variable", + validators = VerifTypeTuple(('I', 'I', 'I')), + ), + ), + b_RANGE = BLOC(condition = "TYPE == 'RANGE'", + RANGE = SIMP(statut = "o", typ = 'TXM', + fr = u"Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]", + ang = "Range of index for one dimension arrays ex: [1,3:8,666]", + ), + Consigne = SIMP(statut ="o", homo="information", typ="TXM", + defaut = "Format [0,2:8,50:88,666]", + ), + ), + b_POLYGON = BLOC(condition = "TYPE == 'POLYGON'", + POLYGON = SIMP(statut = "o", + typ = Tuple(2), + max = '**', + fr = u"Liste des sommets (coordonnées X,Y) du " + u"polygone définissant le contour de la zone", + ang = "List of points (X,Y coordinates) of the " + "polygon defining the border of the area", + validators = VerifTypeTuple(('R', 'R')), + ), + ), + b_POLYGON_FILE = BLOC(condition = "TYPE == 'POLYGON_FILE'", + POLYGON_FILE = FACT(statut = "o", + fr = u"Polygon dans un fichier", + ang = "Polygone in a file", + FILE_NAME = SIMP(statut = "o", typ = 'Fichier', + fr = u"Fichier contenant les info du polygone", + ang = "File containing the polygon info", + ), + SEPARATOR = SIMP(statut = "o", typ = 'TXM', + defaut = ',', + fr = u"Separateur pour le fichier de polygone", + ang = "Separator for the polygon file", + ), + ), + ), + ), + ), + ), + OUTPUT_VARIABLE = FACT(statut = 'f', max = '**', + fr = u"Variable de sortie du calcul", + ang = u"Computation output variable", + NAME = SIMP(statut = "o", typ = 'TXM', + fr = u"Nom de la variable", + ang = u"Variable name", + ), + VAR_INFO = FACT(statut = "o", + fr = u'Variable du modèle Telemac2D', + ang = u'Telemac2D model variable', + VAR_NAME = SIMP(statut = "o", typ = 'TXM', + intoSug = get_list_var_api('TELEMAC2D'), + fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")', + ang = u'Model variable name (ex: "MODEL.DEBIT")', + ), + ZONE_DEF = FACT(statut = "o", + ang = u'Variable definition area', + fr = u'Zone de définition de la variable', + INDEX = SIMP(statut = "o", typ = Tuple(3), + defaut = (0, 0, 0, ), + ang = "Index of the point / border", + fr = u"Indice du point ou de la frontière", + validators = VerifTypeTuple(('I', 'I', 'I')), + ), + ), + ), + ), +) + +TEXTE_NEW_JDC="TELEMAC2D()" diff --git a/src/salome_hydro/param_study/eficas/prefs.py b/src/salome_hydro/param_study/eficas/prefs.py new file mode 100644 index 0000000..a156e61 --- /dev/null +++ b/src/salome_hydro/param_study/eficas/prefs.py @@ -0,0 +1,18 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +code = "telemac2d" diff --git a/src/salome_hydro/param_study/eficas/prefs_telemac2d.py b/src/salome_hydro/param_study/eficas/prefs_telemac2d.py new file mode 100644 index 0000000..e53112c --- /dev/null +++ b/src/salome_hydro/param_study/eficas/prefs_telemac2d.py @@ -0,0 +1,27 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import sys + +repIni = os.path.dirname(__file__) +INSTALLDIR = os.getenv("EFICAS_ROOT") +closeAutreCommande=True +closeFrameRechercheCommande=True +closeArbre=True +closeCopier=True +suiteTelemac=True diff --git a/src/salome_hydro/pytel/CMakeLists.txt b/src/salome_hydro/pytel/CMakeLists.txt deleted file mode 100755 index 1c5645d..0000000 --- a/src/salome_hydro/pytel/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -ADD_SUBDIRECTORY(eficas) - -INCLUDE(UsePyQt) - -# --- Python files --- - -SET(PYFILES - __init__.py - genjob.py - genjobwindow.py - launcher.py - gui.py -) - -# uic files / to be processed by pyuic -SET(UIFILES - genjobwindow.ui -) - -# scripts / pyuic wrappings -PYQT_WRAP_UIC(_pyuic_SCRIPTS ${UIFILES}) - -# --- rules --- - -# scripts / pyuic wrappings - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/pytel) -INSTALL( FILES ${_pyuic_SCRIPTS} DESTINATION ${SALOME_INSTALL_PYTHON}/salome/hydro/pytel) - - diff --git a/src/salome_hydro/pytel/__init__.py b/src/salome_hydro/pytel/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/salome_hydro/pytel/eficas/CMakeLists.txt b/src/salome_hydro/pytel/eficas/CMakeLists.txt deleted file mode 100644 index 083540a..0000000 --- a/src/salome_hydro/pytel/eficas/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -# --- Python files --- - -SET(PYFILES - __init__.py - configuration_pytel.py - prefs_pytel.py - prefs.py - pytel_cata.py - appli.py -) - -# --- rules --- - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/pytel/eficas) diff --git a/src/salome_hydro/pytel/eficas/__init__.py b/src/salome_hydro/pytel/eficas/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/salome_hydro/pytel/eficas/appli.py b/src/salome_hydro/pytel/eficas/appli.py deleted file mode 100755 index f1eb3ec..0000000 --- a/src/salome_hydro/pytel/eficas/appli.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import sys - -from PyQt5.QtWidgets import QMessageBox , QScrollArea, QGridLayout - - -import salome -import SalomePyQt -sgPyQt = SalomePyQt.SalomePyQt() - -from salome.kernel.logger import Logger -from salome.kernel import termcolor -logger = Logger("salome.hydro.pytel.eficas.appli", - color = termcolor.GREEN_FG) - -import eficasSalome - -from salome.hydro.study import HydroStudyEditor - -class EficasForPytelAppli(eficasSalome.MyEficas): - """ - This class launches Eficas and adds entries for the created files in - HYDRO component in the study tree. - - :type fichier: string - :param fichier: path of an Eficas file to open - - """ - def __init__(self, fichier = None, version = None): - self.ed = HydroStudyEditor() - self.codedir = os.path.dirname(__file__) - sys.path[:0] = [self.codedir] - area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); - eficasSalome.MyEficas.__init__(self, area, "pytel", - fichier, version = version) - gridLayout = QGridLayout(area) - gridLayout.addWidget(self) - area.setWidgetResizable(1) - sgPyQt.createView("Eficas Pytel", self) - if fichier == None : self.fileNew() - else : self.addJdcInSalome(fichier) - - def addJdcInSalome(self, jdcPath): - """ - Add the newly created file in Salome study - """ - try: - self.ed.find_or_create_pytel_case(jdcPath) - except Exception, exc: - msgError = "Can't add file to Salome study tree" - logger.exception(msgError) - QMessageBox.warning(self, self.tr("Warning"), - self.tr("%s. Reason:\n%s\n\nSee logs for more details." % (msgError, exc))) - salome.sg.updateObjBrowser(0) - - def closeEvent(self, event): - while self.codedir in sys.path: - sys.path.remove(self.codedir) - eficasSalome.MyEficas.closeEvent(self, event) diff --git a/src/salome_hydro/pytel/eficas/configuration_pytel.py b/src/salome_hydro/pytel/eficas/configuration_pytel.py deleted file mode 100644 index b25ad32..0000000 --- a/src/salome_hydro/pytel/eficas/configuration_pytel.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os - -from Editeur.catadesc import CatalogDescription -from InterfaceQT4.configuration import configBase - -class CONFIG(configBase): - - def __init__(self, appli, repIni): - """ - This class stores the configuration parameters for Eficas - """ - configBase.__init__(self, appli, repIni) - - # Configuration parameters - self.savedir = os.getenv("HOME") - self.catalogues = (CatalogDescription("pytel", os.path.join(repIni, "pytel_cata.py")),) - self.labels_eficas=['lang','rep_cata','catalogues','closeAutreCommande','closeFrameRechercheCommande','closeEntete','closeArbre'] - self.lang = 'fr' - - def save_params(self): - pass - -def make_config(appli, rep): - return CONFIG(appli, rep) - -def make_config_style(appli, rep): - return None diff --git a/src/salome_hydro/pytel/eficas/prefs.py b/src/salome_hydro/pytel/eficas/prefs.py deleted file mode 100644 index 44cf4d7..0000000 --- a/src/salome_hydro/pytel/eficas/prefs.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -code = "pytel" diff --git a/src/salome_hydro/pytel/eficas/prefs_pytel.py b/src/salome_hydro/pytel/eficas/prefs_pytel.py deleted file mode 100644 index e53112c..0000000 --- a/src/salome_hydro/pytel/eficas/prefs_pytel.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import sys - -repIni = os.path.dirname(__file__) -INSTALLDIR = os.getenv("EFICAS_ROOT") -closeAutreCommande=True -closeFrameRechercheCommande=True -closeArbre=True -closeCopier=True -suiteTelemac=True diff --git a/src/salome_hydro/pytel/eficas/pytel_cata.py b/src/salome_hydro/pytel/eficas/pytel_cata.py deleted file mode 100644 index 50f0c43..0000000 --- a/src/salome_hydro/pytel/eficas/pytel_cata.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -from Accas import * - -codelist = ("artemis", "estel3d", "postel3d", "sisyphe", "stbtel", "telemac2d", "telemac3d", "tomawac", "mascaret") - -JdC = JDC_CATA(regles = (UN_PARMI('PYTEL',)), - ) -PYTEL = PROC( - nom = "PYTEL", op = None, - fr = u"Définition d'un cas pour le lanceur Pytel", - ang = u"Definition of a case for the Pytel launcher", - CODE = SIMP(statut = "o", typ = "TXM", into = codelist, defaut = "telemac2d", - fr = u"Code à exécuter", - ang = u"Code to run"), - FICHIER_CAS = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier de description du cas", - ang = u"Case description file"), - REPERTOIRE_TRAVAIL = SIMP(statut = "f", typ = 'Repertoire', - fr = u"Répertoire de travail", - ang = u"Working directory"), -) - -TEXTE_NEW_JDC="PYTEL()" diff --git a/src/salome_hydro/pytel/genjob.py b/src/salome_hydro/pytel/genjob.py deleted file mode 100644 index a265a90..0000000 --- a/src/salome_hydro/pytel/genjob.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import tempfile -from datetime import datetime -import glob - -import salome - -job_script_template = """#!/bin/sh - -. %(env_file)s -runcode.py %(code)s %(cas)s --ncsize %(nbcore)d -""" - -def generate_job(pytel_params, resource, telemac_root_dir, telemac_env_file, - nbcore, input_data_dir, result_dir): - """ - Create a Launcher job using the parameters specified by the user. - """ - # Generate job script - basename = os.path.basename(pytel_params["FICHIER_CAS"]) - job_script = job_script_template % {"env_file": telemac_env_file, - "code": pytel_params["CODE"], - "cas": basename, - "nbcore": nbcore} - - - (fd, job_script_file) = tempfile.mkstemp(prefix = "job_" + basename + "_", suffix = ".sh") - os.close(fd) - f = open(job_script_file, "w") - f.write(job_script) - f.close() - - # Define job parameters - job_params = salome.JobParameters() - job_params.job_name = basename - job_params.job_type = "command" - job_params.job_file = job_script_file - input_files = glob.glob(os.path.join(input_data_dir, "*")) + [pytel_params["FICHIER_CAS"]] - input_files = list(set(input_files)) # Remove duplicates - job_params.in_files = input_files - job_params.out_files = [] - job_params.result_directory = result_dir - - # Define resource parameters - job_params.resource_required = salome.ResourceParameters() - job_params.resource_required.name = resource - job_params.resource_required.nb_proc = nbcore - - # Generate name for the working directory - res_manager = salome.naming_service.Resolve("/ResourcesManager") - res_definition = res_manager.GetResourceDefinition(resource) - res_work_dir = res_definition.working_directory - if res_work_dir != "": - timestr = datetime.now().ctime() - timestr = timestr.replace('/', '_') - timestr = timestr.replace('-', '_') - timestr = timestr.replace(':', '_') - timestr = timestr.replace(' ', '_') - work_dir = res_work_dir + "/" + job_params.job_name + "_" + timestr - job_params.work_directory = work_dir - - # Create Launcher job - launcher = salome.naming_service.Resolve('/SalomeLauncher') - launcher.createJob(job_params) diff --git a/src/salome_hydro/pytel/genjobwindow.py b/src/salome_hydro/pytel/genjobwindow.py deleted file mode 100644 index ee665f1..0000000 --- a/src/salome_hydro/pytel/genjobwindow.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -from PyQt5.QtWidgets import QDialog , QFileDialog - -import salome -from salome.hydro.pytel.genjob import generate_job -from genjobwindow_ui import Ui_GenJobDialog - - -class GenJobDialog(QDialog, Ui_GenJobDialog): - - def __init__(self, parent, pytel_params): - QDialog.__init__(self, parent) - self.setupUi(self) - self.dialogButtonBox.accepted.connect(self.validate) - self.dialogButtonBox.rejected.connect( self.close) - self.chooseInputDataDirectoryButton.clicked.connect( self.choose_input_dir) - self.chooseResultDirectoryButton.clicked.connect(self.choose_result_dir) - - self.telemacRootDirLE.setText("/projets/systel/V7P2") - self.telemacEnvFileLE.setText("/projets/systel/V7P2/config/pysource.eole.intel.sh") - casedir = os.path.dirname(pytel_params["FICHIER_CAS"]) - self.inputDataDirectoryLE.setText(casedir) - self.resultDirectoryLE.setText(casedir) - - # Populate resource combo box - res_manager = salome.naming_service.Resolve("/ResourcesManager") - res_params = salome.ResourceParameters() - res_list = res_manager.GetFittingResources(res_params) - self.resourceCB.addItems(res_list) - - self.pytel_params = pytel_params - - def choose_input_dir(self): - directory = QFileDialog.getExistingDirectory(self, - directory = self.inputDataDirectoryLE.text(), - options = QFileDialog.ShowDirsOnly) - if not directory.isNull(): - self.inputDataDirectoryLE.setText(directory) - - def choose_result_dir(self): - directory = QFileDialog.getExistingDirectory(self, - directory = self.resultDirectoryLE.text(), - options = QFileDialog.ShowDirsOnly) - if not directory.isNull(): - self.resultDirectoryLE.setText(directory) - - def validate(self): - generate_job(self.pytel_params, - str(self.resourceCB.currentText()), - str(self.telemacRootDirLE.text()), - str(self.telemacEnvFileLE.text()), - self.nbCoreSB.value(), - str(self.inputDataDirectoryLE.text()), - str(self.resultDirectoryLE.text())) - self.close() diff --git a/src/salome_hydro/pytel/genjobwindow.ui b/src/salome_hydro/pytel/genjobwindow.ui deleted file mode 100644 index 31e8633..0000000 --- a/src/salome_hydro/pytel/genjobwindow.ui +++ /dev/null @@ -1,165 +0,0 @@ - - - GenJobDialog - - - - 0 - 0 - 636 - 280 - - - - Generate Job - - - - - - - - Resource - - - - - - - - - - Telemac remote root directory - - - - - - - - - - Telemac environment file - - - - - - - - - - Number of cores - - - - - - - 1 - - - 100000 - - - - - - - Input data directory - - - - - - - - - - 0 - 0 - - - - - - - - ... - - - - - - - - - Result directory - - - - - - - - - - 0 - 0 - - - - - - - - ... - - - - - - - - - - - Qt::Vertical - - - - 20 - 43 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - diff --git a/src/salome_hydro/pytel/gui.py b/src/salome_hydro/pytel/gui.py deleted file mode 100755 index 0e371c2..0000000 --- a/src/salome_hydro/pytel/gui.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import SalomePyQt -sgPyQt = SalomePyQt.SalomePyQt() - -from salome.hydro.gui_utils import get_and_check_selected_file_path -from salome.hydro.study import jdc_to_dict - -from salome.hydro.pytel.eficas.appli import EficasForPytelAppli -from launcher import run_pytel -from genjobwindow import GenJobDialog - -from PyQt5.QtWidgets import QFileDialog - -def create_case_pytel(): - EficasForPytelAppli() - -def edit_selected_case_pytel(): - file=get_and_check_selected_file_path() - if file == None : - file, filt = QFileDialog.getOpenFileName(sgPyQt.getDesktop(), "Open Pytel file", "", ) - EficasForPytelAppli(fichier=file) - -def get_params_from_selected_case(): - """ - Get the parameters dict from the selected case in Salome study - """ - jdcpath = get_and_check_selected_file_path() - with open(jdcpath) as jdcfile: - jdc = jdcfile.read() - param_dict = jdc_to_dict(jdc, ["PYTEL", "_F"]) - return param_dict - -def run_selected_case_pytel(): - param_dict = get_params_from_selected_case() - run_pytel(param_dict) - -def generate_job_for_selected_case_pytel(): - param_dict = get_params_from_selected_case() - dialog = GenJobDialog(sgPyQt.getDesktop(), param_dict) - dialog.exec_() diff --git a/src/salome_hydro/pytel/launcher.py b/src/salome_hydro/pytel/launcher.py deleted file mode 100644 index 0c27934..0000000 --- a/src/salome_hydro/pytel/launcher.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import subprocess -import tempfile - -from salome.kernel.logger import Logger -from salome.kernel import termcolor -logger = Logger("salome.hydro.pytel.launcher", color = termcolor.BLUE) -#logger.setLevel(logging.ERROR) - -def run_pytel(param_dict): - """ - Run the Python Telemac launching script (pytel), eventually preceded and - followed by data conversion scripts. - """ - interm_files = [] # Intermediate files that can eventually be deleted in the end - - # Get and eventually create working directory - if "REPERTOIRE_TRAVAIL" in param_dict: - wrkdir = param_dict["REPERTOIRE_TRAVAIL"] - if not os.path.exists(wrkdir): - os.makedirs(wrkdir) - else: - wrkdir = tempfile.mkdtemp(prefix = "tel-") - interm_files += [wrkdir] - - # Read original steering file - steering_filepath = param_dict["FICHIER_CAS"] - steering_file_dir = os.path.dirname(steering_filepath) - with open(steering_filepath) as f: - orig_steering = f.read() - orig_steering_lines = orig_steering.split("\n") - - cmd = "set -x ; " - - # Run the code itself - code = param_dict["CODE"] - cmd += "runcode.py -w %s %s %s" % \ - (wrkdir, code, steering_filepath) - cmd += " ; rc=$?" - - # Cleanup intermediate files if the computation was successful - cmd += " ; if test $rc -eq 0; then rm -rf %s ; fi" % " ".join(interm_files) - - cmd += ' ; echo "return code is $rc"' - - # Launch the command - logger.debug("Running the following command in xterm: %s" % cmd) - args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "-hold", "-l", "-e", cmd] - if param_dict.has_key('batchExec'): - if param_dict['batchExec'] == True: - args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "+hold", "-l", "-e", cmd] - subprocess.Popen(args, cwd = wrkdir) - -def check_file_or_create_link(filepath, dirpath, interm_file_list = None): - """ - This utility function checks if the file *filepath* is in directory *dirpath*. - If not, it creates a link with a unique name in *dirpath* to the file *filepath* - and it prepends the link path to the list *interm_file_list* if it is not None. - It returns the name of the link if a link was created, or the name of the file - *filepath* otherwise. - """ - filename = os.path.basename(filepath) - if not os.path.samefile(dirpath, os.path.dirname(filepath)): - name_wo_ext, ext = os.path.splitext(filename) - linkpath = tempfile.mktemp(dir = dirpath, prefix = name_wo_ext + "_", suffix = ext) - os.symlink(filepath, linkpath) - filename = os.path.basename(linkpath) - if interm_file_list is not None: - interm_file_list[:0] = [linkpath] - return filename diff --git a/src/salome_hydro/run_study/CMakeLists.txt b/src/salome_hydro/run_study/CMakeLists.txt new file mode 100755 index 0000000..1157be5 --- /dev/null +++ b/src/salome_hydro/run_study/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +ADD_SUBDIRECTORY(eficas) + +INCLUDE(UsePyQt) + +# --- Python files --- + +SET(PYFILES + __init__.py + genjob.py + genjobwindow.py + launcher.py + gui.py +) + +# uic files / to be processed by pyuic +SET(UIFILES + genjobwindow.ui +) + +# scripts / pyuic wrappings +PYQT_WRAP_UIC(_pyuic_SCRIPTS ${UIFILES}) + +# --- rules --- + +# scripts / pyuic wrappings + +SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/run_study) +INSTALL( FILES ${_pyuic_SCRIPTS} DESTINATION ${SALOME_INSTALL_PYTHON}/salome/hydro/run_study) + + diff --git a/src/salome_hydro/run_study/__init__.py b/src/salome_hydro/run_study/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/salome_hydro/run_study/eficas/CMakeLists.txt b/src/salome_hydro/run_study/eficas/CMakeLists.txt new file mode 100644 index 0000000..65f0998 --- /dev/null +++ b/src/salome_hydro/run_study/eficas/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +# --- Python files --- + +SET(PYFILES + __init__.py + configuration_run_study.py + prefs_run_study.py + prefs.py + run_study_cata.py + appli.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/run_study/eficas) diff --git a/src/salome_hydro/run_study/eficas/__init__.py b/src/salome_hydro/run_study/eficas/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/salome_hydro/run_study/eficas/appli.py b/src/salome_hydro/run_study/eficas/appli.py new file mode 100755 index 0000000..874cc99 --- /dev/null +++ b/src/salome_hydro/run_study/eficas/appli.py @@ -0,0 +1,78 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import sys + +from PyQt5.QtWidgets import QMessageBox, QScrollArea, QGridLayout + + +import salome +import SalomePyQt +sgPyQt = SalomePyQt.SalomePyQt() + +from salome.kernel.logger import Logger +from salome.kernel import termcolor +logger = Logger("salome.hydro.run_study.eficas.appli", + color=termcolor.GREEN_FG) + +import eficasSalome + +from salome.hydro.study import HydroStudyEditor + +class EficasForRunStudyAppli(eficasSalome.MyEficas): + """ + This class launches Eficas and adds entries for the created files in + HYDRO component in the study tree. + + :type fichier: string + :param fichier: path of an Eficas file to open + + """ + def __init__(self, fichier=None, version=None): + self.ed = HydroStudyEditor() + self.codedir = os.path.dirname(__file__) + sys.path[:0] = [self.codedir] + area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); + eficasSalome.MyEficas.__init__(self, area, code="run_study", + fichier=fichier, version=version) + gridLayout = QGridLayout(area) + gridLayout.addWidget(self) + area.setWidgetResizable(1) + sgPyQt.createView("Eficas Run_Study", self) + if fichier == None: + self.fileNew() + else: + self.addJdcInSalome(fichier) + + def addJdcInSalome(self, jdcPath): + """ + Add the newly created file in Salome study + """ + try: + self.ed.find_or_create_run_study(jdcPath) + except Exception, exc: + msgError = "Can't add file to Salome study tree" + logger.exception(msgError) + QMessageBox.warning(self, self.tr("Warning"), + self.tr("%s. Reason:\n%s\n\nSee logs for more details." % (msgError, exc))) + salome.sg.updateObjBrowser(0) + + def closeEvent(self, event): + while self.codedir in sys.path: + sys.path.remove(self.codedir) + eficasSalome.MyEficas.closeEvent(self, event) diff --git a/src/salome_hydro/run_study/eficas/configuration_run_study.py b/src/salome_hydro/run_study/eficas/configuration_run_study.py new file mode 100644 index 0000000..017eb90 --- /dev/null +++ b/src/salome_hydro/run_study/eficas/configuration_run_study.py @@ -0,0 +1,44 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os + +from Editeur.catadesc import CatalogDescription +from InterfaceQT4.configuration import configBase + +class CONFIG(configBase): + + def __init__(self, appli, repIni): + """ + This class stores the configuration parameters for Eficas + """ + configBase.__init__(self, appli, repIni) + + # Configuration parameters + self.savedir = os.getenv("HOME") + self.catalogues = (CatalogDescription("run_study", os.path.join(repIni, "run_study_cata.py")),) + self.labels_eficas=['lang','rep_cata','catalogues','closeAutreCommande','closeFrameRechercheCommande','closeEntete','closeArbre'] + self.lang = 'fr' + + def save_params(self): + pass + +def make_config(appli, rep): + return CONFIG(appli, rep) + +def make_config_style(appli, rep): + return None diff --git a/src/salome_hydro/run_study/eficas/prefs.py b/src/salome_hydro/run_study/eficas/prefs.py new file mode 100644 index 0000000..0ab9a94 --- /dev/null +++ b/src/salome_hydro/run_study/eficas/prefs.py @@ -0,0 +1,18 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +code = "run_study" diff --git a/src/salome_hydro/run_study/eficas/prefs_run_study.py b/src/salome_hydro/run_study/eficas/prefs_run_study.py new file mode 100644 index 0000000..e53112c --- /dev/null +++ b/src/salome_hydro/run_study/eficas/prefs_run_study.py @@ -0,0 +1,27 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import sys + +repIni = os.path.dirname(__file__) +INSTALLDIR = os.getenv("EFICAS_ROOT") +closeAutreCommande=True +closeFrameRechercheCommande=True +closeArbre=True +closeCopier=True +suiteTelemac=True diff --git a/src/salome_hydro/run_study/eficas/run_study_cata.py b/src/salome_hydro/run_study/eficas/run_study_cata.py new file mode 100644 index 0000000..8c1e9f8 --- /dev/null +++ b/src/salome_hydro/run_study/eficas/run_study_cata.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +from Accas import * + +codelist = ("artemis", "postel3d", "sisyphe", "stbtel", "telemac2d", "telemac3d", "tomawac", "mascaret") + +JdC = JDC_CATA(regles = (UN_PARMI('RUN_STUDY',)), + ) +RUN_STUDY = PROC( + nom = "RUN_STUDY", op = None, + fr = u"Définition d'un cas pour le lanceur Python", + ang = u"Definition of a case for the Python launcher", + CODE = SIMP(statut = "o", typ = "TXM", into = codelist, defaut = "telemac2d", + fr = u"Code à exécuter", + ang = u"Code to run"), + FICHIER_CAS = SIMP(statut = "o", typ = 'Fichier', + fr = u"Fichier de description du cas", + ang = u"Case description file"), + REPERTOIRE_TRAVAIL = SIMP(statut = "f", typ = 'Repertoire', + fr = u"Répertoire de travail", + ang = u"Working directory"), +) + +TEXTE_NEW_JDC="RUN_STUDY()" diff --git a/src/salome_hydro/run_study/genjob.py b/src/salome_hydro/run_study/genjob.py new file mode 100644 index 0000000..1781aa5 --- /dev/null +++ b/src/salome_hydro/run_study/genjob.py @@ -0,0 +1,81 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import tempfile +from datetime import datetime +import glob + +import salome + +job_script_template = """#!/bin/sh + +. %(env_file)s +runcode.py %(code)s %(cas)s --ncsize %(nbcore)d +""" + +def generate_job(study_params, resource, telemac_root_dir, telemac_env_file, + nbcore, input_data_dir, result_dir): + """ + Create a Launcher job using the parameters specified by the user. + """ + # Generate job script + basename = os.path.basename(study_params["FICHIER_CAS"]) + job_script = job_script_template % {"env_file": telemac_env_file, + "code": study_params["CODE"], + "cas": basename, + "nbcore": nbcore} + + + (fd, job_script_file) = tempfile.mkstemp(prefix = "job_" + basename + "_", suffix = ".sh") + os.close(fd) + f = open(job_script_file, "w") + f.write(job_script) + f.close() + + # Define job parameters + job_params = salome.JobParameters() + job_params.job_name = basename + job_params.job_type = "command" + job_params.job_file = job_script_file + input_files = glob.glob(os.path.join(input_data_dir, "*")) + [study_params["FICHIER_CAS"]] + input_files = list(set(input_files)) # Remove duplicates + job_params.in_files = input_files + job_params.out_files = [] + job_params.result_directory = result_dir + + # Define resource parameters + job_params.resource_required = salome.ResourceParameters() + job_params.resource_required.name = resource + job_params.resource_required.nb_proc = nbcore + + # Generate name for the working directory + res_manager = salome.naming_service.Resolve("/ResourcesManager") + res_definition = res_manager.GetResourceDefinition(resource) + res_work_dir = res_definition.working_directory + if res_work_dir != "": + timestr = datetime.now().ctime() + timestr = timestr.replace('/', '_') + timestr = timestr.replace('-', '_') + timestr = timestr.replace(':', '_') + timestr = timestr.replace(' ', '_') + work_dir = res_work_dir + "/" + job_params.job_name + "_" + timestr + job_params.work_directory = work_dir + + # Create Launcher job + launcher = salome.naming_service.Resolve('/SalomeLauncher') + launcher.createJob(job_params) diff --git a/src/salome_hydro/run_study/genjobwindow.py b/src/salome_hydro/run_study/genjobwindow.py new file mode 100644 index 0000000..685a9a1 --- /dev/null +++ b/src/salome_hydro/run_study/genjobwindow.py @@ -0,0 +1,72 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +from PyQt5.QtWidgets import QDialog , QFileDialog + +import salome +from salome.hydro.run_study.genjob import generate_job +from genjobwindow_ui import Ui_GenJobDialog + + +class GenJobDialog(QDialog, Ui_GenJobDialog): + + def __init__(self, parent, study_params): + QDialog.__init__(self, parent) + self.setupUi(self) + self.dialogButtonBox.accepted.connect(self.validate) + self.dialogButtonBox.rejected.connect( self.close) + self.chooseInputDataDirectoryButton.clicked.connect( self.choose_input_dir) + self.chooseResultDirectoryButton.clicked.connect(self.choose_result_dir) + + self.telemacRootDirLE.setText("/projets/systel/V8P0") + self.telemacEnvFileLE.setText("/projets/systel/V8P0/config/pysource.eole.intel.sh") + casedir = os.path.dirname(study_params["FICHIER_CAS"]) + self.inputDataDirectoryLE.setText(casedir) + self.resultDirectoryLE.setText(casedir) + + # Populate resource combo box + res_manager = salome.naming_service.Resolve("/ResourcesManager") + res_params = salome.ResourceParameters() + res_list = res_manager.GetFittingResources(res_params) + self.resourceCB.addItems(res_list) + + self.study_params = study_params + + def choose_input_dir(self): + directory = QFileDialog.getExistingDirectory(self, + directory = self.inputDataDirectoryLE.text(), + options = QFileDialog.ShowDirsOnly) + if not directory.isNull(): + self.inputDataDirectoryLE.setText(directory) + + def choose_result_dir(self): + directory = QFileDialog.getExistingDirectory(self, + directory = self.resultDirectoryLE.text(), + options = QFileDialog.ShowDirsOnly) + if not directory.isNull(): + self.resultDirectoryLE.setText(directory) + + def validate(self): + generate_job(self.study_params, + str(self.resourceCB.currentText()), + str(self.telemacRootDirLE.text()), + str(self.telemacEnvFileLE.text()), + self.nbCoreSB.value(), + str(self.inputDataDirectoryLE.text()), + str(self.resultDirectoryLE.text())) + self.close() diff --git a/src/salome_hydro/run_study/genjobwindow.ui b/src/salome_hydro/run_study/genjobwindow.ui new file mode 100644 index 0000000..31e8633 --- /dev/null +++ b/src/salome_hydro/run_study/genjobwindow.ui @@ -0,0 +1,165 @@ + + + GenJobDialog + + + + 0 + 0 + 636 + 280 + + + + Generate Job + + + + + + + + Resource + + + + + + + + + + Telemac remote root directory + + + + + + + + + + Telemac environment file + + + + + + + + + + Number of cores + + + + + + + 1 + + + 100000 + + + + + + + Input data directory + + + + + + + + + + 0 + 0 + + + + + + + + ... + + + + + + + + + Result directory + + + + + + + + + + 0 + 0 + + + + + + + + ... + + + + + + + + + + + Qt::Vertical + + + + 20 + 43 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + diff --git a/src/salome_hydro/run_study/gui.py b/src/salome_hydro/run_study/gui.py new file mode 100755 index 0000000..0a3e9f2 --- /dev/null +++ b/src/salome_hydro/run_study/gui.py @@ -0,0 +1,56 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import SalomePyQt +sgPyQt = SalomePyQt.SalomePyQt() + +from salome.hydro.gui_utils import get_and_check_selected_file_path +from salome.hydro.study import jdc_to_dict + +from salome.hydro.run_study.eficas.appli import EficasForRunStudyAppli +from launcher import run_study +from genjobwindow import GenJobDialog + +from PyQt5.QtWidgets import QFileDialog + +def create_case_study(): + EficasForRunStudyAppli() + +def edit_selected_case_study(): + file=get_and_check_selected_file_path() + if file == None: + file, filt = QFileDialog.getOpenFileName(sgPyQt.getDesktop(), "Open study file", "", ) + EficasForRunStudyAppli(fichier=file) + +def get_params_from_selected_case(): + """ + Get the parameters dict from the selected case in Salome study + """ + jdcpath = get_and_check_selected_file_path() + with open(jdcpath) as jdcfile: + jdc = jdcfile.read() + param_dict = jdc_to_dict(jdc, ["RUN_STUDY", "_F"]) + return param_dict + +def run_selected_case_study(): + param_dict = get_params_from_selected_case() + run_study(param_dict) + +def generate_job_for_selected_case_study(): + param_dict = get_params_from_selected_case() + dialog = GenJobDialog(sgPyQt.getDesktop(), param_dict) + dialog.exec_() diff --git a/src/salome_hydro/run_study/launcher.py b/src/salome_hydro/run_study/launcher.py new file mode 100644 index 0000000..3702551 --- /dev/null +++ b/src/salome_hydro/run_study/launcher.py @@ -0,0 +1,87 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import subprocess +import tempfile + +from salome.kernel.logger import Logger +from salome.kernel import termcolor +logger = Logger("salome.hydro.run_study.launcher", color = termcolor.BLUE) +#logger.setLevel(logging.ERROR) + +def run_study(param_dict): + """ + Run the Python Telemac launching script, eventually preceded and + followed by data conversion scripts. + """ + interm_files = [] # Intermediate files that can eventually be deleted in the end + + # Get and eventually create working directory + if "REPERTOIRE_TRAVAIL" in param_dict: + wrkdir = param_dict["REPERTOIRE_TRAVAIL"] + if not os.path.exists(wrkdir): + os.makedirs(wrkdir) + else: + wrkdir = tempfile.mkdtemp(prefix = "tel-") + interm_files += [wrkdir] + + # Read original steering file + steering_filepath = param_dict["FICHIER_CAS"] + steering_file_dir = os.path.dirname(steering_filepath) + with open(steering_filepath) as f: + orig_steering = f.read() + orig_steering_lines = orig_steering.split("\n") + + cmd = "set -x ; " + + # Run the code itself + code = param_dict["CODE"] + cmd += "runcode.py -w %s %s %s" % \ + (wrkdir, code, steering_filepath) + cmd += " ; rc=$?" + + # Cleanup intermediate files if the computation was successful + cmd += " ; if test $rc -eq 0; then rm -rf %s ; fi" % " ".join(interm_files) + + cmd += ' ; echo "return code is $rc"' + + # Launch the command + logger.debug("Running the following command in xterm: %s" % cmd) + args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "-hold", "-l", "-e", cmd] + if param_dict.has_key('batchExec'): + if param_dict['batchExec'] == True: + args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "+hold", "-l", "-e", cmd] + subprocess.Popen(args, cwd = wrkdir) + +def check_file_or_create_link(filepath, dirpath, interm_file_list = None): + """ + This utility function checks if the file *filepath* is in directory *dirpath*. + If not, it creates a link with a unique name in *dirpath* to the file *filepath* + and it prepends the link path to the list *interm_file_list* if it is not None. + It returns the name of the link if a link was created, or the name of the file + *filepath* otherwise. + """ + filename = os.path.basename(filepath) + if not os.path.samefile(dirpath, os.path.dirname(filepath)): + name_wo_ext, ext = os.path.splitext(filename) + linkpath = tempfile.mktemp(dir = dirpath, prefix = name_wo_ext + "_", suffix = ext) + os.symlink(filepath, linkpath) + filename = os.path.basename(linkpath) + if interm_file_list is not None: + interm_file_list[:0] = [linkpath] + return filename diff --git a/src/salome_hydro/study.py b/src/salome_hydro/study.py index 550a189..f4983b7 100644 --- a/src/salome_hydro/study.py +++ b/src/salome_hydro/study.py @@ -29,38 +29,19 @@ MODULE_NAME = "HYDROSOLVER" COMPONENT_NAME = "HydroSolver" COMPONENT_ICON = "HYDRO_small.png" -MASCARET_FILE_TYPE = "MASCARET_EFICAS_FILE" -MASCARET_ICON = "case1d.png" -MASCARET_CASE_TYPE_ID = 1 - VARS_ICON = "icon_variables.png" -LOG_ICON = "log.png" -LOG_TYPE_ID = 2 - -TELEMAC2D_FILE_TYPE = "TELEMAC2D_EFICAS_FILE" -TELEMAC2D_ICON = "case2d.png" -TELEMAC2D_CASE_TYPE_ID = 3 - -PYTEL_FILE_TYPE = "PYTEL_EFICAS_FILE" -PYTEL_ICON = "case_pytel.png" -PYTEL_CASE_TYPE_ID = 5 - -# Dictionary used to map Eficas parameters to Mascaret file types -mascaretFileTypeDict = {"FICHIER_ABAQUES" : "abaques", - "FICHIER_DICO" : "dico", - "FICHIER_CASIER" : "casier", - "FICHIER_GEOMETRIE" : "geo", - "FICHIER_LOI" : "loi", - "FICHIER_MOT_CLE" : "cas", - "LISTING" : "listing", - "FICHIER_DAMOCLE" : "damocle", - "RESULTAT" : "res", - "LISTING_CASIER" : "listing_casier", - "LISTING_LIAISON" : "listing_liaison", - "RESULTAT_CASIER" : "res_casier", - "RESULTAT_LIAISON" : "res_liaison" - } +TELMA_FILE_TYPE = "TELMA_EFICAS_FILE" +TELMA_ICON = "telma_file.png" +TELMA_TYPE_ID = 1 + +STUDY_FILE_TYPE = "STUDY_EFICAS_FILE" +STUDY_ICON = "study_file.png" +STUDY_TYPE_ID = 2 + +PARAM_STUDY_FILE_TYPE = "PARAM_STUDY_EFICAS_FILE" +PARAM_STUDY_ICON = "param_study_file.png" +PARAM_STUDY_TYPE_ID = 3 def jdc_to_dict(jdc, command_list): """ @@ -106,27 +87,38 @@ class HydroStudyEditor: COMPONENT_ICON) return self.hydroComp - def find_or_create_mascaret_case(self, filePath): + def find_or_create_telma(self, filePath): + self.find_or_create_hydro_component() + itemName = os.path.splitext(os.path.basename(filePath))[0] + sobj = self.editor.findOrCreateItem(self.hydroComp, + name=itemName, + fileType=TELMA_FILE_TYPE, + fileName=filePath, + icon=TELMA_ICON, + comment=str(filePath), + typeId=TELMA_TYPE_ID) + + def find_or_create_param_study(self, filePath): self.find_or_create_hydro_component() itemName = os.path.splitext(os.path.basename(filePath))[0] sobj = self.editor.findOrCreateItem(self.hydroComp, - name = itemName, - fileType = MASCARET_FILE_TYPE, - fileName = filePath, - icon = MASCARET_ICON, - comment = str(filePath), - typeId = MASCARET_CASE_TYPE_ID) - - def find_or_create_telemac2d_case(self, filePath): + name=itemName, + fileType=PARAM_STUDY_FILE_TYPE, + fileName=filePath, + icon=PARAM_STUDY_ICON, + comment=str(filePath), + typeId=PARAM_STUDY_TYPE_ID) + + def find_or_create_run_study(self, filePath): self.find_or_create_hydro_component() itemName = os.path.splitext(os.path.basename(filePath))[0] sobj = self.editor.findOrCreateItem(self.hydroComp, - name = itemName, - fileType = TELEMAC2D_FILE_TYPE, - fileName = filePath, - icon = TELEMAC2D_ICON, - comment = str(filePath), - typeId = TELEMAC2D_CASE_TYPE_ID) + name=itemName, + fileType=STUDY_FILE_TYPE, + fileName=filePath, + icon=STUDY_ICON, + comment=str(filePath), + typeId=STUDY_TYPE_ID) def generate_study_script(self, filePath): """ @@ -143,11 +135,11 @@ class HydroStudyEditor: # Computing name of the file (same as filePath) file_dir, filename = os.path.split(filePath) - root, sfx = os.path.splitext(filename) - python_file = os.path.join(file_dir,root+".py") + root, _ = os.path.splitext(filename) + python_file = os.path.join(file_dir, root+".py") # Writting to file - with open(python_file,'w') as pfile: + with open(python_file, 'w') as pfile: pfile.write(python_script) def generate_study_yacs(self, filePath): @@ -165,19 +157,8 @@ class HydroStudyEditor: # Computing name of the file (same as filePath) file_dir, filename = os.path.split(filePath) - root, sfx = os.path.splitext(filename) - yacs_file = os.path.join(file_dir,root+".xml") + root, _ = os.path.splitext(filename) + yacs_file = os.path.join(file_dir, root+".xml") # Writting to file yacs_scheme.saveSchema(yacs_file) - - def find_or_create_pytel_case(self, filePath): - self.find_or_create_hydro_component() - itemName = os.path.splitext(os.path.basename(filePath))[0] - sobj = self.editor.findOrCreateItem(self.hydroComp, - name = itemName, - fileType = PYTEL_FILE_TYPE, - fileName = filePath, - icon = PYTEL_ICON, - comment = str(filePath), - typeId = PYTEL_CASE_TYPE_ID) diff --git a/src/salome_hydro/telemac2d/CMakeLists.txt b/src/salome_hydro/telemac2d/CMakeLists.txt deleted file mode 100644 index 4d6aedc..0000000 --- a/src/salome_hydro/telemac2d/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -# --- Python files --- - -SET(PYFILES - __init__.py -) - -SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/telemac2d) - -# --- rules --- - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR}) - -ADD_SUBDIRECTORY(eficas) diff --git a/src/salome_hydro/telemac2d/__init__.py b/src/salome_hydro/telemac2d/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/salome_hydro/telemac2d/eficas/CMakeLists.txt b/src/salome_hydro/telemac2d/eficas/CMakeLists.txt deleted file mode 100644 index ade8037..0000000 --- a/src/salome_hydro/telemac2d/eficas/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -# --- Python files --- - -SET(PYFILES - __init__.py - configuration_telemac2d.py - prefs_telemac2d.py - prefs.py - appli.py -) - -# --- rules --- - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/telemac2d/eficas) diff --git a/src/salome_hydro/telemac2d/eficas/__init__.py b/src/salome_hydro/telemac2d/eficas/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/salome_hydro/telemac2d/eficas/appli.py b/src/salome_hydro/telemac2d/eficas/appli.py deleted file mode 100644 index 7356867..0000000 --- a/src/salome_hydro/telemac2d/eficas/appli.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import sys -import re - -from PyQt5.QtWidgets import QMessageBox , QScrollArea, QGridLayout - - -import salome -import SalomePyQt -sgPyQt = SalomePyQt.SalomePyQt() - -from salome.kernel.logger import Logger -from salome.kernel import termcolor -logger = Logger("salome.hydro.telemac2d.eficas.appli", - color = termcolor.GREEN_FG) - -import eficasSalome - -from salome.hydro.study import HydroStudyEditor - -def importFirst(): - """ - Horrible hack to allow a correct load of a Telemac case file when done after - some other edition, such as create case for Pytel execution. - """ - eficasTelemacPath = os.path.join(eficasSalome.eficasConfig.eficasPath,'Telemac') - sys.path.insert(0, eficasTelemacPath) - from telemac2d_enum_auto import TelemacdicoEn - sys.path.pop(0) - -importFirst() - -class EficasForTelemac2DAppli(eficasSalome.MyEficas): - """ - This class launches Eficas and adds entries for the created files in - HYDRO component in the study tree. The messages in this class are in - french because they are displayed in Eficas interface. - - :type fichier: string - :param fichier: path of an Eficas file to open - - """ - def __init__(self, code = "telemac2d", fichier = None, version = None, lang = None): - self.ed = HydroStudyEditor() - self.codedir = os.path.dirname(__file__) - sys.path[:0] = [self.codedir] - #eficasSalome.MyEficas.__init__(self, sgPyQt.getDesktop(), - # code = code, fichier = fichier, - # version = version, lang = lang) - #area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); - area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); - eficasSalome.MyEficas.__init__(self, area, - code = code, fichier = fichier, - version = version, lang = lang) - gridLayout = QGridLayout(area) - gridLayout.addWidget(self) - area.setWidgetResizable(1) - sgPyQt.createView("Eficas Telemac2D", self) - - - - - def addJdcInSalome(self, jdcPath): - """ - Add the newly created file in Salome study - """ - try: - self.ed.find_or_create_telemac2d_case(jdcPath) - except Exception, exc: - msgError = "Can't add file to Salome study tree" - logger.exception(msgError) - QMessageBox.warning(self, self.tr("Warning"), - self.tr("%s. Reason:\n%s\n\nSee logs for " - "more details." % (msgError, exc))) - salome.sg.updateObjBrowser(0) - - def closeEvent(self, event): - while self.codedir in sys.path: - sys.path.remove(self.codedir) - eficasSalome.MyEficas.closeEvent(self, event) diff --git a/src/salome_hydro/telemac2d/eficas/configuration_telemac2d.py b/src/salome_hydro/telemac2d/eficas/configuration_telemac2d.py deleted file mode 100644 index 29051ae..0000000 --- a/src/salome_hydro/telemac2d/eficas/configuration_telemac2d.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os - -from Editeur.catadesc import CatalogDescription -from InterfaceQT4.configuration import configBase - -class CONFIG(configBase): - - def __init__(self, appli, repIni): - """ - This class stores the configuration parameters for Eficas - """ - configBase.__init__(self, appli, repIni) - - # Configuration parameters - self.savedir = os.getenv("HOME") - self.catalogues = (CatalogDescription("telemac2d_V6", - os.path.join(repIni, "telemac2d_V6_cata.py")),) - self.lang = 'fr' - - def save_params(self): - pass - -def make_config(appli, rep): - return CONFIG(appli, rep) - -def make_config_style(appli, rep): - return None diff --git a/src/salome_hydro/telemac2d/eficas/prefs.py b/src/salome_hydro/telemac2d/eficas/prefs.py deleted file mode 100644 index a156e61..0000000 --- a/src/salome_hydro/telemac2d/eficas/prefs.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -code = "telemac2d" diff --git a/src/salome_hydro/telemac2d/eficas/prefs_telemac2d.py b/src/salome_hydro/telemac2d/eficas/prefs_telemac2d.py deleted file mode 100644 index e53112c..0000000 --- a/src/salome_hydro/telemac2d/eficas/prefs_telemac2d.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import os -import sys - -repIni = os.path.dirname(__file__) -INSTALLDIR = os.getenv("EFICAS_ROOT") -closeAutreCommande=True -closeFrameRechercheCommande=True -closeArbre=True -closeCopier=True -suiteTelemac=True diff --git a/src/salome_hydro/telemac2d/eficas/telemac2d_V6_cata.py b/src/salome_hydro/telemac2d/eficas/telemac2d_V6_cata.py deleted file mode 100644 index 9822a5b..0000000 --- a/src/salome_hydro/telemac2d/eficas/telemac2d_V6_cata.py +++ /dev/null @@ -1,201 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see . - -import types -from Accas import * - -def get_list_var_api(module): - """ - Returns the list of variables avaialable throught the API for module - - @param One of the modules of TELEMAC-MASCARET - """ - if module == 'TELEMAC2D': - from TelApy.api.t2d import Telemac2d - model = Telemac2d('dummy.cas') - elif module == 'TELEMAC3D': - from TelApy.api.t3d import Telemac3d - model = Telemac3d('dummy.cas') - elif module == 'SISYPHE': - from TelApy.api.sis import Sisyphe - model = Sisyphe('dummy.cas') - else: - return ['No variable available'] - - varnames, _ = model.list_variables() - del(model) - return sorted(varnames) - -class Tuple: - def __init__(self,ntuple): - self.ntuple=ntuple - - def __convert__(self,valeur): - if type(valeur) == types.StringType: - return None - if len(valeur) != self.ntuple: - return None - return valeur - - def info(self): - return "Tuple de %s elements" % self.ntuple - - __repr__=info - __str__=info - -JdC = JDC_CATA(regles = (UN_PARMI('TELEMAC2D',)), - ) - - - -TELEMAC2D = PROC( - nom = "TELEMAC2D", op = None, - fr = u"Définition d'un cas d'étude Telemac2D", - ang = u"Definition of a Telemac2D study case", - STEERING_FILE = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier de description du cas", - ang = u"Case description file", - ), - USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire', - fr = "Fichier Fortran utilisateur", - ang = u"Fortran user file", - ), - WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire', - defaut = '/tmp', - fr = "Repertoire de travail", - ang = u"Working directory user file", - ), - RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire', - fr = "Repertoire de travail", - ang = u"Working directory user file", - ), - RESULTS_FILE_NAME = SIMP(statut = "f", typ = 'TXM', - fr = u"Fichier des resultats (Ecrasera celui dans le fichier cas)", - ang = u"Results file (Will replace the one in the steering file)" - ), - Consigne = SIMP(statut ="o", homo="information", typ="TXM", - defaut = "All index are in Python numbering (Starting from 0)", - ), - INPUT_VARIABLE = FACT(statut = 'f', max = '**', - fr = u"Variable d'entrée du calcul", - ang = u"Computation input variable", - - NAME = SIMP(statut = "o", typ = 'TXM', - fr = u"Nom de la variable (format Python)", - ang = u"Variable name (Python format)" - ), - VAR_INFO = FACT(statut = "o", - fr = u'Variable du modèle Telemac2D', - ang = u'Telemac2D model variable', - - VAR_NAME = SIMP(statut = "o", typ = 'TXM', - intoSug = get_list_var_api('TELEMAC2D'), - fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")', - ang = u'Model variable name (ex: "MODEL.DEBIT")' - ), - DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM', - fr = u'Valeur par défaut', - ang = u'Default value', - ), - ZONE_DEF = FACT(statut = "o", - ang = u'Variable definition area', - fr = u'Zone de définition de la variable', - - TYPE = SIMP(statut = "o", typ = 'TXM', - into = ['INDEX', 'RANGE', 'POLYGON', 'POLYGON_FILE'], - fr = u'Type de definition de la variable', - ang = u'Type of definition for the variable', - ), - - b_INDEX = BLOC(condition = "TYPE == 'INDEX'", - INDEX = SIMP(statut = "o", typ = Tuple(3), - defaut = (0, 0, 0), - ang = "Index of the variable", - fr = u"Indice de la variable", - validators = VerifTypeTuple(('I', 'I', 'I')), - ), - ), - b_RANGE = BLOC(condition = "TYPE == 'RANGE'", - RANGE = SIMP(statut = "o", typ = 'TXM', - fr = u"Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]", - ang = "Range of index for one dimension arrays ex: [1,3:8,666]", - ), - Consigne = SIMP(statut ="o", homo="information", typ="TXM", - defaut = "Format [0,2:8,50:88,666]", - ), - ), - b_POLYGON = BLOC(condition = "TYPE == 'POLYGON'", - POLYGON = SIMP(statut = "o", - typ = Tuple(2), - max = '**', - fr = u"Liste des sommets (coordonnées X,Y) du " - u"polygone définissant le contour de la zone", - ang = "List of points (X,Y coordinates) of the " - "polygon defining the border of the area", - validators = VerifTypeTuple(('R', 'R')), - ), - ), - b_POLYGON_FILE = BLOC(condition = "TYPE == 'POLYGON_FILE'", - POLYGON_FILE = FACT(statut = "o", - fr = u"Polygon dans un fichier", - ang = "Polygone in a file", - FILE_NAME = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier contenant les info du polygone", - ang = "File containing the polygon info", - ), - SEPARATOR = SIMP(statut = "o", typ = 'TXM', - defaut = ',', - fr = u"Separateur pour le fichier de polygone", - ang = "Separator for the polygon file", - ), - ), - ), - ), - ), - ), - OUTPUT_VARIABLE = FACT(statut = 'f', max = '**', - fr = u"Variable de sortie du calcul", - ang = u"Computation output variable", - NAME = SIMP(statut = "o", typ = 'TXM', - fr = u"Nom de la variable", - ang = u"Variable name", - ), - VAR_INFO = FACT(statut = "o", - fr = u'Variable du modèle Telemac2D', - ang = u'Telemac2D model variable', - VAR_NAME = SIMP(statut = "o", typ = 'TXM', - intoSug = get_list_var_api('TELEMAC2D'), - fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")', - ang = u'Model variable name (ex: "MODEL.DEBIT")', - ), - ZONE_DEF = FACT(statut = "o", - ang = u'Variable definition area', - fr = u'Zone de définition de la variable', - INDEX = SIMP(statut = "o", typ = Tuple(3), - defaut = (0, 0, 0, ), - ang = "Index of the point / border", - fr = u"Indice du point ou de la frontière", - validators = VerifTypeTuple(('I', 'I', 'I')), - ), - ), - ), - ), -) - -TEXTE_NEW_JDC="TELEMAC2D()" diff --git a/src/salome_hydro/telma/CMakeLists.txt b/src/salome_hydro/telma/CMakeLists.txt new file mode 100755 index 0000000..b783842 --- /dev/null +++ b/src/salome_hydro/telma/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +# --- Python files --- + +SET(PYFILES + __init__.py +) + +SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/telma) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR}) + +ADD_SUBDIRECTORY(eficas) diff --git a/src/salome_hydro/telma/__init__.py b/src/salome_hydro/telma/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/src/salome_hydro/telma/eficas/CMakeLists.txt b/src/salome_hydro/telma/eficas/CMakeLists.txt new file mode 100644 index 0000000..d7bab39 --- /dev/null +++ b/src/salome_hydro/telma/eficas/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +# --- Python files --- + +SET(PYFILES + __init__.py + configuration_telma.py + prefs_telma.py + prefs.py + appli.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro/telma/eficas) diff --git a/src/salome_hydro/telma/eficas/__init__.py b/src/salome_hydro/telma/eficas/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/src/salome_hydro/telma/eficas/appli.py b/src/salome_hydro/telma/eficas/appli.py new file mode 100755 index 0000000..b4a9461 --- /dev/null +++ b/src/salome_hydro/telma/eficas/appli.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import sys +import re + +from PyQt5.QtWidgets import QMessageBox, QScrollArea, QGridLayout + + +import salome +import SalomePyQt +sgPyQt = SalomePyQt.SalomePyQt() + +from salome.kernel.logger import Logger +from salome.kernel import termcolor +logger = Logger("salome.hydro.telma.eficas.appli", + color = termcolor.GREEN_FG) + +import eficasSalome + +from salome.hydro.study import HydroStudyEditor + +def importFirst(): + """ + Horrible hack to allow a correct load of a Telemac case file when done after + some other edition, such as create case for Pytel execution. + """ + eficasTelemacPath = os.path.join(eficasSalome.eficasConfig.eficasPath,'Telemac') + sys.path.insert(0, eficasTelemacPath) + from telemac2d_enum_auto import TelemacdicoEn + sys.path.pop(0) + +importFirst() + +class EficasForTelmaAppli(eficasSalome.MyEficas): + """ + This class launches Eficas and adds entries for the created files in + HYDRO component in the study tree. The messages in this class are in + french because they are displayed in Eficas interface. + + :type fichier: string + :param fichier: path of an Eficas file to open + + """ + def __init__(self, code="telemac", fichier=None, version=None, lang=None): + self.ed = HydroStudyEditor() + self.codedir = os.path.dirname(__file__) + sys.path[:0] = [self.codedir] + area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop()); + eficasSalome.MyEficas.__init__(self, area, + code=code, fichier=fichier, + version=version, lang=lang) + gridLayout = QGridLayout(area) + gridLayout.addWidget(self) + area.setWidgetResizable(1) + sgPyQt.createView("Eficas Telemac", self) + + + + + def addJdcInSalome(self, jdcPath): + """ + Add the newly created file in Salome study + """ + try: + self.ed.find_or_create_telma(jdcPath) + except Exception, exc: + msgError = "Can't add file to Salome study tree" + logger.exception(msgError) + QMessageBox.warning(self, self.tr("Warning"), + self.tr("%s. Reason:\n%s\n\nSee logs for " + "more details." % (msgError, exc))) + salome.sg.updateObjBrowser(0) + + def closeEvent(self, event): + while self.codedir in sys.path: + sys.path.remove(self.codedir) + eficasSalome.MyEficas.closeEvent(self, event) diff --git a/src/salome_hydro/telma/eficas/configuration_telma.py b/src/salome_hydro/telma/eficas/configuration_telma.py new file mode 100755 index 0000000..54eb78f --- /dev/null +++ b/src/salome_hydro/telma/eficas/configuration_telma.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os + +from Editeur.catadesc import CatalogDescription +from InterfaceQT4.configuration import configBase + +class CONFIG(configBase): + + def __init__(self, appli, repIni): + """ + This class stores the configuration parameters for Eficas + """ + configBase.__init__(self, appli, repIni) + + # Configuration parameters + self.savedir = os.getenv("HOME") + self.lang = 'fr' + + def save_params(self): + pass + +def make_config(appli, rep): + return CONFIG(appli, rep) + +def make_config_style(appli, rep): + return None diff --git a/src/salome_hydro/telma/eficas/prefs.py b/src/salome_hydro/telma/eficas/prefs.py new file mode 100755 index 0000000..031a12f --- /dev/null +++ b/src/salome_hydro/telma/eficas/prefs.py @@ -0,0 +1,18 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +code = "TELEMAC" diff --git a/src/salome_hydro/telma/eficas/prefs_telma.py b/src/salome_hydro/telma/eficas/prefs_telma.py new file mode 100755 index 0000000..e53112c --- /dev/null +++ b/src/salome_hydro/telma/eficas/prefs_telma.py @@ -0,0 +1,27 @@ +# Copyright (C) 2012-2013 EDF +# +# This file is part of SALOME HYDRO module. +# +# SALOME HYDRO module is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME HYDRO module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SALOME HYDRO module. If not, see . + +import os +import sys + +repIni = os.path.dirname(__file__) +INSTALLDIR = os.getenv("EFICAS_ROOT") +closeAutreCommande=True +closeFrameRechercheCommande=True +closeArbre=True +closeCopier=True +suiteTelemac=True