1 # Copyright (C) 2012-2013 EDF
3 # This file is part of SALOME HYDRO module.
5 # SALOME HYDRO module is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # SALOME HYDRO module is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with SALOME HYDRO module. If not, see <http://www.gnu.org/licenses/>.
21 from PyQt5.QtCore import *
22 from PyQt5.QtGui import *
23 from PyQt5.QtWidgets import *
30 pythonVersion = 'python' + sysconfig.get_python_version()
31 hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', pythonVersion, 'site-packages', 'salome', 'salome', 'hydro')
33 class checkBoundariesDialog(QDialog):
37 def __init__(self, parent = None, modal = 0):
38 QDialog.__init__(self, parent)
39 uic.loadUi(os.path.join(hydro_solver_root, 'checkBoundaries.ui'), self )
42 self.pb_medFile.clicked.connect(self.on_med_file_browse)
43 self.pb_bcdFile.clicked.connect(self.on_bcd_file_browse)
44 self.rb_liqbcd.toggled.connect(self.on_liqbcd)
45 self.pb_help.clicked.connect(self.on_help)
46 self.pb_ok.accepted.connect(self.on_accept)
47 self.pb_ok.rejected.connect(self.on_reject)
50 self.rb_liqbcd.setChecked(True)
51 self.rb_allbcd.setChecked(False)
54 def on_med_file_browse(self):
58 print("on_med_file_browse")
59 self.medFile, _filt = QFileDialog.getOpenFileName(self, self.tr("MED file"), "", self.tr("MED files (*.med)"))
63 self.le_medFile.setText(self.medFile)
65 def on_bcd_file_browse(self):
69 print("on_bcd_file_browse")
70 self.bcdFile, _filt = QFileDialog.getOpenFileName(self, self.tr("Boundary Condition file"), "", self.tr("Boundary Condition files (*.bcd)"))
74 self.le_bcdFile.setText(self.bcdFile)
78 switch type of display
81 if self.rb_liqbcd.isChecked():
88 display a help message
91 <h2>Display boundarycondition dialog</h2>
93 This dialog is used to draw the mesh with colored boundary conditions on nodes.
95 The boundary condition file (bcd) associates a type of boundary condition to each concerned group in the mesh.
97 The option "Liquid /solid boundaries" allows to distinguish all the differents boundary condition groups
99 The option "All boundaries by Telemac type" allows to distinguish all the types of boundary conditions.
101 The drawing computation Is launch in a separate process, without waiting.
102 It may be long, for a big mesh...
104 QMessageBox.about(self, self.tr("About change coordinates dialog"), msg);
109 #TODO check medfile in and out not empty
110 #TODO preset for bcdFile
111 medFile = self.le_medFile.text()
112 bcdFile = self.le_bcdFile.text()
113 if not os.path.isfile(medFile):
114 msgBox = QMessageBox()
115 msgBox.setText( "MED file does not exist" )
118 if not os.path.isfile(bcdFile):
119 msgBox = QMessageBox()
120 msgBox.setText( "Boundary condition file does not exist" )
126 cmd = ["plot.py", "mesh2d", medFile, "-b", bcdFile, option]
128 proc = subprocess.Popen(cmd)
130 print("invalid command")
131 QMessageBox.critical(self, "command error", "%s is not found" % cmd[0])
139 def execDialog(context):
141 # get context study, salomeGui
142 study = context.study
144 dlg = checkBoundariesDialog()