From af922ac232e8529b838c7ad2ff8f8e89df7f7cdf Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 26 Oct 2018 16:22:10 +0200 Subject: [PATCH] renaming --- src/HYDROGUI/HYDROSOLVERGUI.py | 18 ++--- src/salome_hydro/CMakeLists.txt | 5 +- src/salome_hydro/assignStrickler.template | 26 +++++++ .../{interpolks.ui => assignStrickler.ui} | 67 ++++++++++++++----- ...terpolks_gui.py => assignStrickler_gui.py} | 36 +++++++--- 5 files changed, 113 insertions(+), 39 deletions(-) create mode 100644 src/salome_hydro/assignStrickler.template rename src/salome_hydro/{interpolks.ui => assignStrickler.ui} (71%) rename src/salome_hydro/{interpolks_gui.py => assignStrickler_gui.py} (79%) diff --git a/src/HYDROGUI/HYDROSOLVERGUI.py b/src/HYDROGUI/HYDROSOLVERGUI.py index c45182d..1e82b6c 100755 --- a/src/HYDROGUI/HYDROSOLVERGUI.py +++ b/src/HYDROGUI/HYDROSOLVERGUI.py @@ -35,7 +35,7 @@ logger = Logger("HYDROGUI", color = termcolor.BLUE) import HYDROSOLVER_ORB from salome.hydro.interpolz_gui import InterpolzDlg -from salome.hydro.interpolks_gui import InterpolksDlg +from salome.hydro.assignStrickler_gui import assignStricklerDlg from salome.hydro.gui_utils import HSGUIException, wait_cursor, get_and_check_selected_file_path import salome.hydro.study as hydro_study @@ -77,7 +77,7 @@ class GUIcontext: GEN_TELEMAC2D_PYTHON_ID = 958 GEN_TELEMAC2D_YACS_ID = 959 #DEFINE_CAS_FILE_FR = 960 - GENERATE_INTERPOLKS_PY_ID = 961 + GENERATE_ASSIGNSTRICKLER_PY_ID = 961 EDIT_LIQUID_BOUNDARIES_FILE_ID = 962 EDIT_BREACHES_FILE_ID = 962 EDIT_INITIAL_CONDITIONS_FILE_ID = 963 @@ -100,9 +100,9 @@ class GUIcontext: sgPyQt.createMenu( a, mid ) sgPyQt.createTool( a, tid ) - a = sgPyQt.createAction( GUIcontext.GENERATE_INTERPOLKS_PY_ID, - "Generate interpolKS.py", "Generate interpolKS.py", - "Generate interpolation script for bottom friction coefficients", + a = sgPyQt.createAction( GUIcontext.GENERATE_ASSIGNSTRICKLER_PY_ID, + "Generate assignStrickler.py", "Generate assignStrickler.py", + "Generate assignation script for bottom friction coefficients", "generate_interpolz_py.png" ) sgPyQt.createMenu( a, mid ) sgPyQt.createTool( a, tid ) @@ -521,11 +521,11 @@ def generate_interpolz_py(): dlg.show() ### -# Open dialog for interpolks.py script generation +# Open dialog for assignStrickler.py script generation ### -def generate_interpolks_py(): +def generate_assignStrickler_py(): desktop = sgPyQt.getDesktop() - dlg = InterpolksDlg(desktop) + dlg = assignStricklerDlg(desktop) dlg.show() ### @@ -558,7 +558,7 @@ dict_command = { GUIcontext.EDIT_LIQUID_BOUNDARIES_FILE_ID: edit_liquid_boundaries_file, GUIcontext.EDIT_BREACHES_FILE_ID: edit_breaches_file, GUIcontext.EDIT_INITIAL_CONDITIONS_FILE_ID: edit_initial_conditions_file, - GUIcontext.GENERATE_INTERPOLKS_PY_ID: generate_interpolks_py, + GUIcontext.GENERATE_ASSIGNSTRICKLER_PY_ID: generate_assignStrickler_py, 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, diff --git a/src/salome_hydro/CMakeLists.txt b/src/salome_hydro/CMakeLists.txt index a459b9d..0137546 100644 --- a/src/salome_hydro/CMakeLists.txt +++ b/src/salome_hydro/CMakeLists.txt @@ -27,17 +27,18 @@ SET(PYFILES study.py gui_utils.py generate_interpolz.py - interpolks_gui.py + assignStrickler_gui.py interpolz_gui.py ) SET(UIFILES - interpolks.ui + assignStrickler.ui interpolz.ui ) SET(TEMPLFILES interpolz.template + assignStrickler.template ) # --- rules --- diff --git a/src/salome_hydro/assignStrickler.template b/src/salome_hydro/assignStrickler.template new file mode 100644 index 0000000..a172e16 --- /dev/null +++ b/src/salome_hydro/assignStrickler.template @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +# ===== Assign Strickler coefficients script, to be edited ===== +#=============================================================== + +# --- name of the case in HYDRO module +caseName = + +# --- input file: MED file with mesh and optional Z interpolation field, +# to be completed with Strickler coefficients field (default name 'BOTTOM FRICTION') + +meshFile_in = + +from salome.hydrotools.interpolS import assignStrickler + +assignStrickler(caseName, meshFile_in) + +""" +# --- it is possible to write everything in a new file instead of adding a field to the existing file, +# it is also possible to use a different field name than the default ('BOTTOM FRICTION') +# --- output_file_name : optional: + output_file_name = meshFile_in +# --- med_field_name : optional, Strickler coefficients field name, default = 'BOTTOM FRICTION': + med_field_name = 'BOTTOM FRICTION' +assignStrickler(caseName, meshFile_in, output_file_name=meshfile_out, med_field_name=fieldName) +""" \ No newline at end of file diff --git a/src/salome_hydro/interpolks.ui b/src/salome_hydro/assignStrickler.ui similarity index 71% rename from src/salome_hydro/interpolks.ui rename to src/salome_hydro/assignStrickler.ui index 796ce5f..34f6d48 100644 --- a/src/salome_hydro/interpolks.ui +++ b/src/salome_hydro/assignStrickler.ui @@ -6,14 +6,35 @@ 0 0 - 695 - 174 + 496 + 201 Dialog + + + + + + calculation case selected in HYDRO module + + + Calculation case: + + + + + + + calculation case selected in HYDRO module + + + + + @@ -24,23 +45,37 @@ + + path of the script to create, for generation of Strickler coefficients + Output path: - + + + path of the script to create, for generation of Strickler coefficients + + + + MED file containing the mesh, that will receive a new field on nodes, for Strickler coefficients + MED file: - + + + MED file containing the mesh, that will receive a new field on nodes, for Strickler coefficients + + @@ -61,21 +96,17 @@ - - - - - - Calculation case: - - - - - - - - + + + if checked the script is generated and executed on apply, otherwise it is only generated for later use + + + Execute the script + + + + QFrame::NoFrame diff --git a/src/salome_hydro/interpolks_gui.py b/src/salome_hydro/assignStrickler_gui.py similarity index 79% rename from src/salome_hydro/interpolks_gui.py rename to src/salome_hydro/assignStrickler_gui.py index 8bcd626..9eb791d 100644 --- a/src/salome_hydro/interpolks_gui.py +++ b/src/salome_hydro/assignStrickler_gui.py @@ -11,6 +11,8 @@ salome.salome_init() import HYDROPy from salome.hydrotools.interpolS import assignStrickler +from generate_interpolz import replace + from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox from PyQt5 import uic @@ -31,12 +33,12 @@ def get_selected_calc_case(): return name return None -class InterpolksDlg( QDialog ): +class assignStricklerDlg( QDialog ): def __init__(self, parent = None): QDialog.__init__( self, parent ) p = hydro_solver_root - uic.loadUi( p+'/interpolks.ui', self ) - self.setWindowTitle( 'Generate interpolks script' ) + uic.loadUi( p+'/assignStrickler.ui', self ) + self.setWindowTitle( 'Generate assignStrickler script' ) SalomePyQt.SalomePyQt.getObjectBrowser().selectionChanged.connect(self.onSelectionChanged) self.btnOutputPath.clicked.connect(self.onOutputFile) self.btnMEDFile.clicked.connect(self.onMEDFile) @@ -79,11 +81,21 @@ class InterpolksDlg( QDialog ): if self.onApply(): self.onClose() + def generateScript( self, path, calc_case, med_file ): + f = open( path, "w" ) + tf = open( hydro_solver_root+"/assignStrickler.template", "r" ) + templ = tf.readlines() + replace( templ, "", calc_case ) + replace( templ, "", med_file ) + for line in templ: + f.write( line ) + f.close() + def onApply( self ): path = str(self.OutputPath.text()) calc_case = str(self.CalcCase.text()) med_file = str(self.MEDFile.text()) - + isScriptExec = self.cb_scriptExec.isChecked() msg = "" if len(path)==0: msg = "Please input the output path" @@ -93,9 +105,13 @@ class InterpolksDlg( QDialog ): msg = "Please choose the MED file" result = False + if len(msg)==0: - assignStrickler(calc_case, med_file) #, output_file_name=fichierMaillage_out, verbose=True) - msg = "InterpolKs script is successfully generated" + self.generateScript( path, calc_case, med_file ) + msg = "Strickler script is successfully generated" + if isScriptExec: + assignStrickler(calc_case, med_file) #, output_file_name=fichierMaillage_out, verbose=True) + msg = "Strickler script is successfully generated and executed" result = True QMessageBox.information( self, "", msg ) @@ -107,15 +123,15 @@ class InterpolksDlg( QDialog ): """Shows help page""" def onHelp( self ): msg = """ -

Interpolks dialog

+

assignStrickler dialog

- This dialog is a tool for automation the writing of the script interpolks.py. + This dialog is a tool for automation the writing of the script assignStrickler.py.

Calculation case

The name of the calculation case. It can be filled automatically on the base of selection or can be input by user.

Output path

- The path for the output, i.e. the path of the target script interpolks. + The path for the output, i.e. the path of the target script assignStrickler.

MED file

The path to MED file where MED groups are extracted. @@ -135,5 +151,5 @@ class InterpolksDlg( QDialog ): if __name__=='__main__': - dlg = InterpolksDlg() + dlg = assignStricklerDlg() dlg.show() -- 2.39.2