Salome HOME
dialog check boundaries, new names for some icons, png to draw...
authorPaul RASCLE <paul.rascle@openfields.fr>
Tue, 22 Sep 2020 13:09:51 +0000 (15:09 +0200)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:04:18 +0000 (17:04 +0100)
src/HYDROGUI/HYDROSOLVERGUI.py
src/salome_hydro/CMakeLists.txt
src/salome_hydro/checkBoundaries.ui [new file with mode: 0644]
src/salome_hydro/checkBoundariesDialog.py [new file with mode: 0644]

index b3c2b8078c6feb9de18995e13d56d3b2597b20e9..74d60dc5f5f3432c19e1b304838a91faf12c281e 100755 (executable)
@@ -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,
index f40a286821ba4ba4333576952d86689f7cb49008..c9dd3598eae3b2c0faa6728d58c7b5faab7c1695 100644 (file)
@@ -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 (file)
index 0000000..5b22699
--- /dev/null
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>448</width>
+    <height>260</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Check Boundary Conditions</string>
+  </property>
+  <property name="layoutDirection">
+   <enum>Qt::LeftToRight</enum>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="lb_medFile">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>MED file</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QLineEdit" name="le_medFile">
+       <property name="statusTip">
+        <string>The file containing the mesh to check</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="2">
+      <widget class="QToolButton" name="pb_medFile">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="statusTip">
+        <string>Browse file</string>
+       </property>
+       <property name="text">
+        <string>...</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="lb_bcdFile">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Boundary Condition file</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="le_bcdFile">
+       <property name="statusTip">
+        <string>The file containing the MED group names and their associated Boundary condition type</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="2">
+      <widget class="QToolButton" name="pb_bcdFile">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="statusTip">
+        <string>Browse file</string>
+       </property>
+       <property name="text">
+        <string>...</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="rb_liqbcd">
+     <property name="toolTip">
+      <string>shows all the groups of Liquid/solid boundaries</string>
+     </property>
+     <property name="text">
+      <string>Liquid / solid boundaries by MED groups</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="rb_allbcd">
+     <property name="toolTip">
+      <string>shows all the boundaries classed by Telemac Type</string>
+     </property>
+     <property name="text">
+      <string>All boundaries by Telemac type</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>66</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <widget class="QTextEdit" name="textEdit">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="html">
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic; color:#0000ff;&quot;&gt;The drawing is launch in a separate process, without waiting.&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic; color:#0000ff;&quot;&gt;The process may be long on a big mesh...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QDialogButtonBox" name="pb_ok">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pb_help">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Help</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/salome_hydro/checkBoundariesDialog.py b/src/salome_hydro/checkBoundariesDialog.py
new file mode 100644 (file)
index 0000000..5b0a846
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+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 = """
+        <h2>Display boundarycondition dialog</h2>
+
+        This dialog is used to draw the mesh with colored boundary conditions on nodes.
+        <br><br>        
+        The boundary condition file (bcd) associates a type of boundary condition to each concerned group in the mesh.
+        <br> 
+        The option "Liquid /solid boundaries" allows to distinguish all the differents boundary condition groups 
+        <br>     
+        The option "All boundaries by Telemac type" allows to distinguish all the types of boundary conditions.
+        <br><br>         
+        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_()