From: Paul RASCLE Date: Fri, 19 Oct 2018 09:46:44 +0000 (+0200) Subject: nouveaux menus et boutons X-Git-Tag: HYDRO_V2_0_0^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=540a00814a2c85249fb5549782a48cb18e1e9b97;p=modules%2Fhydrosolver.git nouveaux menus et boutons --- diff --git a/src/HYDROGUI/BreachesDialog.py b/src/HYDROGUI/BreachesDialog.py new file mode 100644 index 0000000..a2cf61c --- /dev/null +++ b/src/HYDROGUI/BreachesDialog.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +import sys, os +import string + +#hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro') + +#import salome +#salome.salome_init() + +#import HYDROPy + +from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox +from PyQt5 import uic + +#import SalomePyQt +#import libSALOME_Swig +#salome_gui = libSALOME_Swig.SALOMEGUI_Swig() + +class BreachesDialog(): + + def __init__(self, parent = None): + pass + + def exec_(self): + msgBox = QMessageBox() + msgBox.setText( "The Breaches dialog is not yet implemented!" ) + msgBox.exec_() + + diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index af6eb29..f385352 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -20,6 +20,9 @@ SET(PYFILES HYDROSOLVERGUI.py BndConditionsDialog.py + BreachesDialog.py + InitialConditionsDialog.py + LiquidBoundariesDialog.py ) SET(UIFILES diff --git a/src/HYDROGUI/HYDROSOLVERGUI.py b/src/HYDROGUI/HYDROSOLVERGUI.py index d1823f7..c45182d 100755 --- a/src/HYDROGUI/HYDROSOLVERGUI.py +++ b/src/HYDROGUI/HYDROSOLVERGUI.py @@ -33,16 +33,22 @@ logger = Logger("HYDROGUI", color = termcolor.BLUE) #logger.setLevel(logging.ERROR) import HYDROSOLVER_ORB + from salome.hydro.interpolz_gui import InterpolzDlg +from salome.hydro.interpolks_gui import InterpolksDlg + 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.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 eficasSalome import runEficas -import BndConditionsDialog +from BndConditionsDialog import BoundaryConditionsDialog +from LiquidBoundariesDialog import LiquidBoundariesDialog +from BreachesDialog import BreachesDialog +from InitialConditionsDialog import InitialConditionsDialog ################################################ # GUI context class @@ -50,11 +56,13 @@ import BndConditionsDialog ################################################ class GUIcontext: - # menus/toolbars/actions IDs + + # --- menus/toolbars/actions IDs + HYDRO_MENU_ID = 90 - CREATE_MASCARET_CASE_ID = 941 + #CREATE_MASCARET_CASE_ID = 941 RUN_MASCARET_ID = 942 - EDIT_MASCARET_CASE_ID = 943 + #EDIT_MASCARET_CASE_ID = 943 SHOW_LOG_ID = 944 CREATE_TELEMAC2D_CASE_ID = 945 OPEN_SCHEMA_IN_YACS_ID = 950 @@ -68,14 +76,39 @@ class GUIcontext: GENERATE_INTERPOLZ_PY_ID = 957 GEN_TELEMAC2D_PYTHON_ID = 958 GEN_TELEMAC2D_YACS_ID = 959 - DEFINE_CAS_FILE_FR = 960 + #DEFINE_CAS_FILE_FR = 960 + GENERATE_INTERPOLKS_PY_ID = 961 + EDIT_LIQUID_BOUNDARIES_FILE_ID = 962 + EDIT_BREACHES_FILE_ID = 962 + EDIT_INITIAL_CONDITIONS_FILE_ID = 963 def __init__( self ): - # create top-level menu + # --- create top-level menu + mid = sgPyQt.createMenu( "Hydro", -1, GUIcontext.HYDRO_MENU_ID, sgPyQt.defaultMenuGroup() ) - # create toolbar + + # --- create toolbar + tid = sgPyQt.createTool( "Hydro" ) - # create actions and fill menu and toolbar with actions + + # --- create actions and fill menu and toolbar with actions + + a = sgPyQt.createAction( GUIcontext.GENERATE_INTERPOLZ_PY_ID, + "Generate interpolZ.py", "Generate interpolZ.py", + "Generate interpolation script for altitudes", + "generate_interpolz_py.png" ) + 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", + "generate_interpolz_py.png" ) + sgPyQt.createMenu( a, mid ) + sgPyQt.createTool( a, tid ) + + a = sgPyQt.createSeparator() + 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", @@ -83,16 +116,31 @@ class GUIcontext: sgPyQt.createMenu( a, mid ) sgPyQt.createTool( a, tid ) + a = sgPyQt.createAction( GUIcontext.EDIT_LIQUID_BOUNDARIES_FILE_ID, + "Edit liquid boundaries file", "Edit liquid boundaries file", + "Create/edit the liquid boundaries 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" ) + a = sgPyQt.createAction( GUIcontext.EDIT_BREACHES_FILE_ID, + "Edit breaches file", "Edit breaches file", + "Create/edit the breaches file for Telemac", + "edit_boundary_conditions_file.png" ) + sgPyQt.createMenu( a, mid ) + sgPyQt.createTool( a, tid ) + + a = sgPyQt.createAction( GUIcontext.EDIT_INITIAL_CONDITIONS_FILE_ID, + "Edit initial conditions file", "Edit initial conditions file", + "Create/edit the initial conditions file for Telemac", + "edit_boundary_conditions_file.png" ) sgPyQt.createMenu( a, mid ) sgPyQt.createTool( a, tid ) - a = sgPyQt.createAction( GUIcontext.CREATE_TELEMAC2D_CASE_ID, - "Create Telemac2D case", "Create Telemac2D case", - "Create a new Telemac2D case", "create_case2d.png" ) + 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 ) @@ -100,49 +148,48 @@ class GUIcontext: 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" ) - + "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" ) + #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 ) - sgPyQt.createMenu( a, mid ) - sgPyQt.createTool( a, tid ) - - a = sgPyQt.createSeparator() - - a = 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.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 ) + 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 ) 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 ) - 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 ) + #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 ) - # the following action are used in context popup + # --- 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.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" ) @@ -162,8 +209,8 @@ class GUIcontext: 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.DEFINE_CAS_FILE_FR, "Edit .cas file (French)", "Edit .cas file (French)", + #"Edit .cas file (French)") ################################################ @@ -268,7 +315,7 @@ def createPopupMenu(popup, context): 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.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)) @@ -438,7 +485,31 @@ def open_schema_in_yacs(): ### def edit_boundary_conditions_file(): desktop = sgPyQt.getDesktop() - dlg = BndConditionsDialog.BoundaryConditionsDialog(desktop) + dlg = BoundaryConditionsDialog(desktop) + dlg.exec_() + +### +# Open dialog for liquid boundaries edition +### +def edit_liquid_boundaries_file(): + desktop = sgPyQt.getDesktop() + dlg = LiquidBoundariesDialog(desktop) + dlg.exec_() + +### +# Open dialog for breaches edition +### +def edit_breaches_file(): + desktop = sgPyQt.getDesktop() + dlg = BreachesDialog(desktop) + dlg.exec_() + +### +# Open dialog for initial conditions edition +### +def edit_initial_conditions_file(): + desktop = sgPyQt.getDesktop() + dlg = InitialConditionsDialog(desktop) dlg.exec_() ### @@ -449,6 +520,14 @@ def generate_interpolz_py(): dlg = InterpolzDlg(desktop) dlg.show() +### +# Open dialog for interpolks.py script generation +### +def generate_interpolks_py(): + desktop = sgPyQt.getDesktop() + dlg = InterpolksDlg(desktop) + dlg.show() + ### # Open dialog for boundary conditions edition ### @@ -462,9 +541,9 @@ def eficas_for_cas_Telemac2D_en(): # Commands dictionary ### dict_command = { - GUIcontext.CREATE_MASCARET_CASE_ID: create_mascaret_case, + #GUIcontext.CREATE_MASCARET_CASE_ID: create_mascaret_case, GUIcontext.RUN_MASCARET_ID: run_mascaret, - GUIcontext.EDIT_MASCARET_CASE_ID: edit_mascaret_case, + #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, @@ -476,7 +555,11 @@ dict_command = { 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.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_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.DEFINE_CAS_FILE_FR: eficas_for_cas_Telemac2D_fr, } diff --git a/src/HYDROGUI/InitialConditionsDialog.py b/src/HYDROGUI/InitialConditionsDialog.py new file mode 100644 index 0000000..bb0be2d --- /dev/null +++ b/src/HYDROGUI/InitialConditionsDialog.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +import sys, os +import string + +#hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro') + +#import salome +#salome.salome_init() + +#import HYDROPy + +from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox +from PyQt5 import uic + +#import SalomePyQt +#import libSALOME_Swig +#salome_gui = libSALOME_Swig.SALOMEGUI_Swig() + +class InitialConditionsDialog(): + + def __init__(self, parent = None): + pass + + def exec_(self): + msgBox = QMessageBox() + msgBox.setText( "The Initial Conditions dialog is not yet implemented!" ) + msgBox.exec_() + + diff --git a/src/HYDROGUI/LiquidBoundariesDialog.py b/src/HYDROGUI/LiquidBoundariesDialog.py new file mode 100644 index 0000000..f860d89 --- /dev/null +++ b/src/HYDROGUI/LiquidBoundariesDialog.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +import sys, os +import string + +#hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro') + +#import salome +#salome.salome_init() + +#import HYDROPy + +from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox +from PyQt5 import uic + +#import SalomePyQt +#import libSALOME_Swig +#salome_gui = libSALOME_Swig.SALOMEGUI_Swig() + +class LiquidBoundariesDialog(): + + def __init__(self, parent = None): + pass + + def exec_(self): + msgBox = QMessageBox() + msgBox.setText( "The Liquid boundaries dialog is not yet implemented!" ) + msgBox.exec_() + + \ No newline at end of file diff --git a/src/salome_hydro/CMakeLists.txt b/src/salome_hydro/CMakeLists.txt index a6c8307..a459b9d 100644 --- a/src/salome_hydro/CMakeLists.txt +++ b/src/salome_hydro/CMakeLists.txt @@ -27,10 +27,12 @@ SET(PYFILES study.py gui_utils.py generate_interpolz.py + interpolks_gui.py interpolz_gui.py ) SET(UIFILES + interpolks.ui interpolz.ui ) diff --git a/src/salome_hydro/interpolks.ui b/src/salome_hydro/interpolks.ui new file mode 100644 index 0000000..796ce5f --- /dev/null +++ b/src/salome_hydro/interpolks.ui @@ -0,0 +1,150 @@ + + + Dialog + + + + 0 + 0 + 695 + 174 + + + + Dialog + + + + + + Paths + + + + + + + + Output path: + + + + + + + + + + MED file: + + + + + + + + + + ... + + + + + + + ... + + + + + + + + + + + + + + Calculation case: + + + + + + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Apply and Close + + + + + + + Apply + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Help + + + + + + + + + + + diff --git a/src/salome_hydro/interpolks_gui.py b/src/salome_hydro/interpolks_gui.py new file mode 100644 index 0000000..8bcd626 --- /dev/null +++ b/src/salome_hydro/interpolks_gui.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- + +import sys, os +import string + +hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro') + +import salome +salome.salome_init() + +import HYDROPy +from salome.hydrotools.interpolS import assignStrickler + +from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox +from PyQt5 import uic + +import SalomePyQt +import libSALOME_Swig +salome_gui = libSALOME_Swig.SALOMEGUI_Swig() + + +def get_selected_calc_case(): + ind = SalomePyQt.SalomePyQt.getObjectBrowser().selectionModel().selectedIndexes() + aStudyId = salome.myStudyId + doc = HYDROPy.HYDROData_Document.Document( aStudyId ) + for i in ind: + if i.column()==0: + name = str(i.data()) + case = doc.FindObjectByName( name ) + if isinstance(case, HYDROPy.HYDROData_CalculationCase): + return name + return None + +class InterpolksDlg( 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' ) + SalomePyQt.SalomePyQt.getObjectBrowser().selectionChanged.connect(self.onSelectionChanged) + self.btnOutputPath.clicked.connect(self.onOutputFile) + self.btnMEDFile.clicked.connect(self.onMEDFile) + self.CalcCase.textChanged.connect(self.onCalcCaseChanged) + self.MEDFile.textChanged.connect(self.onMEDChanged) + self.ApplyClose.clicked.connect(self.onApplyClose) + self.Apply.clicked.connect(self.onApply) + self.Close.clicked.connect(self.onClose) + self.Help.clicked.connect(self.onHelp) + self.onSelectionChanged() + + def onSelectionChanged( self ): + calc_case_name = get_selected_calc_case() + if calc_case_name is not None: + self.CalcCase.setText( calc_case_name ) + + def onOutputFile( self ): + caption = "Python file" + mask = "*.py" + fname, filt = QFileDialog.getSaveFileName( self, caption, ".", mask ) + if fname!=None and fname!="": + if string.split(fname, '.')[-1] != 'py': + fname += '.py' + self.OutputPath.setText( fname ) + + def onMEDFile( self ): + caption = "MED file" + mask = "*.med" + fname, filt = QFileDialog.getOpenFileName( self, caption, ".", mask ) + if fname!=None and fname!="": + self.MEDFile.setText( fname ) + + def onCalcCaseChanged( self ): + self.onMEDChanged() + + def onMEDChanged( self ): + pass + + def onApplyClose( self ): + if self.onApply(): + self.onClose() + + def onApply( self ): + path = str(self.OutputPath.text()) + calc_case = str(self.CalcCase.text()) + med_file = str(self.MEDFile.text()) + + msg = "" + if len(path)==0: + msg = "Please input the output path" + elif len(calc_case)==0: + msg = "Please choose the calculation case" + elif len(med_file)==0: + 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" + result = True + + QMessageBox.information( self, "", msg ) + return result + + def onClose( self ): + self.close() + + """Shows help page""" + def onHelp( self ): + msg = """ +

Interpolks dialog

+ + This dialog is a tool for automation the writing of the script interpolks.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. + +

MED file

+ The path to MED file where MED groups are extracted. + +

Method

+ The interpolation method (interpolation at the nearest point and linear interpolation from a triangulation of the cloud of points). + +

Undefined Z

+ The Z value for nodes outside the regions. + +

Table

+ The table with MED groups and regions names. + + When the data is input, the user clicks on "Apply" or "Apply and Close" button to perform the script generation. + """ + QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg); + + +if __name__=='__main__': + dlg = InterpolksDlg() + dlg.show()