From b58c5e4e7587ab2a8ab7b6bbb6cd280b52164101 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Tue, 22 Sep 2020 15:09:51 +0200 Subject: [PATCH] dialog check boundaries, new names for some icons, png to draw... --- src/HYDROGUI/HYDROSOLVERGUI.py | 33 +++- src/salome_hydro/CMakeLists.txt | 2 + src/salome_hydro/checkBoundaries.ui | 201 ++++++++++++++++++++++ src/salome_hydro/checkBoundariesDialog.py | 146 ++++++++++++++++ 4 files changed, 376 insertions(+), 6 deletions(-) create mode 100644 src/salome_hydro/checkBoundaries.ui create mode 100644 src/salome_hydro/checkBoundariesDialog.py diff --git a/src/HYDROGUI/HYDROSOLVERGUI.py b/src/HYDROGUI/HYDROSOLVERGUI.py index b3c2b80..74d60dc 100755 --- a/src/HYDROGUI/HYDROSOLVERGUI.py +++ b/src/HYDROGUI/HYDROSOLVERGUI.py @@ -53,6 +53,8 @@ from BndConditionsDialog import BoundaryConditionsDialog from LiquidBoundariesDialog import LiquidBoundariesDialog from BreachesDialog import BreachesDialog from salome.hydro.initialFieldDialog import initialFieldDialog +from salome.hydro.checkBoundariesDialog import checkBoundariesDialog + ################################################ # GUI context class @@ -87,6 +89,7 @@ class GUIcontext: GEN_PARAM_STUDY_YACS_ID = 966 CHANGECOORDS_PY_ID = 967 + CHECK_BOUNDARY_CONDITIONS_ID = 968 def __init__(self): # create top-level menu @@ -100,7 +103,7 @@ class GUIcontext: "Change coordinates", "Change coordinates", "Change mesh coordinates", - "generate_interpolz_py.png") + "changes_coords.png") sgPyQt.createMenu(act, mid) sgPyQt.createTool(act, tid) @@ -118,7 +121,7 @@ class GUIcontext: "Generate assignStrickler.py", "Generate assignStrickler.py", "Generate assignation script for bottom friction coefficients", - "generate_interpolz_py.png" ) + "assign_Strickler_py.png" ) sgPyQt.createMenu( act, mid ) sgPyQt.createTool( act, tid ) @@ -133,11 +136,20 @@ class GUIcontext: sgPyQt.createMenu(act, mid) sgPyQt.createTool(act, tid) + act = sgPyQt.createAction(\ + GUIcontext.CHECK_BOUNDARY_CONDITIONS_ID, + "check boundary conditions", + "check boundary conditions", + "display a graph with boundary conditions on the mesh", + "check_boundary_conditions.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 evolution of liquid boundary conditions file", + "Edit evolution of liquid boundary conditions file", + "Create/edit the evolution in time of the liquid boundary conditions file for Telemac", "edit_liquid_boundary_conditions_file.png") sgPyQt.createMenu(act, mid) sgPyQt.createTool(act, tid) @@ -156,7 +168,7 @@ class GUIcontext: "Edit initial field file", "Edit initial field file", "Create/edit the initial field file for Telemac", - "edit_boundary_conditions_file.png" ) + "edit_initial_field_file.png" ) sgPyQt.createMenu( act, mid ) sgPyQt.createTool( act, tid ) @@ -459,6 +471,14 @@ def edit_initial_field_file(): dlg = initialFieldDialog(desktop) dlg.exec_() +### +# Open dialog for initial conditions edition +### +def check_boundaries(): + desktop = sgPyQt.getDesktop() + dlg = checkBoundariesDialog(desktop) + dlg.exec_() + ### # Open dialog for liquid boundary conditions edition ### @@ -538,6 +558,7 @@ dict_command = { GUIcontext.CHANGECOORDS_PY_ID: changeCoords_py, GUIcontext.EDIT_LIQUID_BOUNDARY_FILE_ID: edit_liquid_boundary_file, GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID: edit_boundary_conditions_file, + GUIcontext.CHECK_BOUNDARY_CONDITIONS_ID: check_boundaries, GUIcontext.EDIT_BREACHES_FILE_ID: edit_breaches_file, GUIcontext.EDIT_INITIAL_FIELD_FILE_ID: edit_initial_field_file, GUIcontext.CREATE_PARAM_STUDY_ID: create_param_study, diff --git a/src/salome_hydro/CMakeLists.txt b/src/salome_hydro/CMakeLists.txt index f40a286..c9dd359 100644 --- a/src/salome_hydro/CMakeLists.txt +++ b/src/salome_hydro/CMakeLists.txt @@ -31,6 +31,7 @@ SET(PYFILES interpolz_gui.py changeCoordsDialog.py initialFieldDialog.py + checkBoundariesDialog.py ) SET(UIFILES @@ -38,6 +39,7 @@ SET(UIFILES interpolz.ui changeCoords.ui initialField.ui + checkBoundaries.ui ) SET(TEMPLFILES diff --git a/src/salome_hydro/checkBoundaries.ui b/src/salome_hydro/checkBoundaries.ui new file mode 100644 index 0000000..5b22699 --- /dev/null +++ b/src/salome_hydro/checkBoundaries.ui @@ -0,0 +1,201 @@ + + + Dialog + + + + 0 + 0 + 448 + 260 + + + + Check Boundary Conditions + + + Qt::LeftToRight + + + + + + + + + 0 + 0 + + + + MED file + + + + + + + The file containing the mesh to check + + + + + + + + 0 + 0 + + + + Browse file + + + ... + + + + + + + + 0 + 0 + + + + Boundary Condition file + + + + + + + The file containing the MED group names and their associated Boundary condition type + + + + + + + + 0 + 0 + + + + Browse file + + + ... + + + + + + + + + shows all the groups of Liquid/solid boundaries + + + Liquid / solid boundaries by MED groups + + + + + + + shows all the boundaries classed by Telemac Type + + + All boundaries by Telemac type + + + + + + + Qt::Vertical + + + + 20 + 66 + + + + + + + + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic; color:#0000ff;">The drawing is launch in a separate process, without waiting.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic; color:#0000ff;">The process may be long on a big mesh...</span></p></body></html> + + + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Help + + + + + + + + + + diff --git a/src/salome_hydro/checkBoundariesDialog.py b/src/salome_hydro/checkBoundariesDialog.py new file mode 100644 index 0000000..5b0a846 --- /dev/null +++ b/src/salome_hydro/checkBoundariesDialog.py @@ -0,0 +1,146 @@ +# 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.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +from PyQt5 import uic + +import subprocess +import time + +import sysconfig +from test import outstanding_bugs +pythonVersion = 'python' + sysconfig.get_python_version() +hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', pythonVersion, 'site-packages', 'salome', 'salome', 'hydro') + +class checkBoundariesDialog(QDialog): + """ + """ + + def __init__(self, parent = None, modal = 0): + QDialog.__init__(self, parent) + uic.loadUi(os.path.join(hydro_solver_root, 'checkBoundaries.ui'), self ) + + # Connections + self.pb_medFile.clicked.connect(self.on_med_file_browse) + self.pb_bcdFile.clicked.connect(self.on_bcd_file_browse) + self.rb_liqbcd.toggled.connect(self.on_liqbcd) + self.pb_help.clicked.connect(self.on_help) + self.pb_ok.accepted.connect(self.on_accept) + self.pb_ok.rejected.connect(self.on_reject) + self.medFile = None + self.bcdFile = None + self.rb_liqbcd.setChecked(True) + self.rb_allbcd.setChecked(False) + self.liqbcd = True + + def on_med_file_browse(self): + """ + Select MED file + """ + print("on_med_file_browse") + self.medFile, _filt = QFileDialog.getOpenFileName(self, self.tr("MED file"), "", self.tr("MED files (*.med)")) + print(self.medFile) + if not self.medFile: + return + self.le_medFile.setText(self.medFile) + + def on_bcd_file_browse(self): + """ + Select bcd file + """ + print("on_bcd_file_browse") + self.bcdFile, _filt = QFileDialog.getOpenFileName(self, self.tr("Boundary Condition file"), "", self.tr("Boundary Condition files (*.bcd)")) + print(self.bcdFile) + if not self.bcdFile: + return + self.le_bcdFile.setText(self.bcdFile) + + def on_liqbcd(self): + """ + switch type of display + """ + print("on_liqbcd") + if self.rb_liqbcd.isChecked(): + self.liqbcd = True + else: + self.liqbcd = False + + def on_help(self): + """ + display a help message + """ + msg = """ +

Display boundarycondition dialog

+ + This dialog is used to draw the mesh with colored boundary conditions on nodes. +

+ The boundary condition file (bcd) associates a type of boundary condition to each concerned group in the mesh. +
+ The option "Liquid /solid boundaries" allows to distinguish all the differents boundary condition groups +
+ The option "All boundaries by Telemac type" allows to distinguish all the types of boundary conditions. +

+ The drawing computation Is launch in a separate process, without waiting. + It may be long, for a big mesh... + """ + QMessageBox.about(self, self.tr("About change coordinates dialog"), msg); + + + def on_accept(self): + print("accept") + #TODO check medfile in and out not empty + #TODO preset for bcdFile + medFile = self.le_medFile.text() + bcdFile = self.le_bcdFile.text() + if not os.path.isfile(medFile): + msgBox = QMessageBox() + msgBox.setText( "MED file does not exist" ) + msgBox.exec_() + return + if not os.path.isfile(bcdFile): + msgBox = QMessageBox() + msgBox.setText( "Boundary condition file does not exist" ) + msgBox.exec_() + return + option = "--bnd" + if self.liqbcd: + option = "--liq-bnd" + cmd = ["plot.py", "mesh2d", medFile, "-b", bcdFile, option] + try: + proc = subprocess.Popen(cmd) + except OSError: + print("invalid command") + QMessageBox.critical(self, "command error", "%s is not found" % cmd[0]) + self.accept() + + def on_reject(self): + print("reject") + self.reject() + + +def execDialog(context): + print("execDialog") + # get context study, salomeGui + study = context.study + sg = context.sg + dlg = checkBoundariesDialog() + dlg.exec_() -- 2.39.2