def __init__(self, parent = None, modal = 0):
QtGui.QDialog.__init__(self, parent)
- uic.loadUi(os.path.join(hydro_solver_root,'BndConditionsDialog.ui'), self)
+ uic.loadUi(os.path.join(hydro_solver_root, 'BndConditionsDialog.ui'), self )
# Connections
self.medFileButton.clicked.connect(self.on_med_file_browse)
"""Initialize presets"""
def init_presets(self):
# TODO: determine another presets path
- presets_data_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'tests', 'data')
+ presets_data_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'tests', 'data')
file_path = os.path.join(presets_data_root, 'bnd_conditions_presets.txt')
reader = boundaryConditions.PresetReader(file_path)
self.presets = reader.read()
def on_apply_and_close(self):
if self.on_apply():
self.accept()
-
- """Shows help page"""
- def on_help(self):
- # TODO: to be implemented
- pass
-
+
"""Select MED file"""
def on_med_file_browse(self):
# Get file path
self.input_conditions.clear()
for cnd in conditions:
self.input_conditions[cnd.group] = (cnd.lihbor, cnd.liubor, cnd.livbor, cnd.litbor)
-
+
+ # Check read errors
+ read_errors = reader.errors
+ if len( read_errors ) > 0:
+ msg = "\n".join(read_errors)
+ QtGui.QMessageBox.warning(self, self.tr("Warning"), msg)
+
if len(self.input_conditions) > 0:
self.update_table()
else:
else:
is_ok = True
- return is_ok
\ No newline at end of file
+ return is_ok
+
+ """Shows help page"""
+ def on_help(self):
+ msg = """
+ <h2>Boundary conditions dialog</h2>
+
+ This dialog is used to read and write boundary conditions files.
+ Below is the description of the dialog controls.
+
+ <h3>MED file</h3>
+ This field allows selection of a med file (via the standard file open dialog).
+ The file must contain groups of edges, if this is not the case a warning message appears.
+ The filling of this field is mandatory.
+
+ <h3>Boundary conditions file</h3>
+ This field allows selecting the file of boundary conditions (via the standard file open dialog).
+ The data from this file is displayed in the table "Boundary conditions".
+ This field is optional; if it is not selected the table will not be prefilled.
+
+ <h3>Result boundary conditions file</h3>
+ This field allows selecting the file in which to save the data (via the standard file save dialog).
+ This field is mandatory if the "Same as the input" check box is unchecked.
+
+ <h3>Boundary conditions table</h3>
+ Contains data representing the list of boundary conditions.
+ The first column contains a list of presets.
+ The last columns is read-only, it contains names of group of edges from the selected MED file.
+ Other columns is for LIHBOR, LIUBOR, LIVBOR and LITBOR parameters, which can take a value ranging between 0 and 6.
+ <br>
+ <br>
+ When the table is filled and the output file is defined, the user clicks on "Apply" or "Apply and Close" button
+ to perform the data export to the file.
+ Click on "Close" button does not lead to saving the data and just closes the dialog.
+ """
+ QtGui.QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
+ pass
\ No newline at end of file
self.litbor = litbor
self.group = group
+ def get_min(self):
+ return min( self.lihbor, self.liubor, self.livbor, self.litbor )
+
+ def get_max(self):
+ return max( self.lihbor, self.liubor, self.livbor, self.litbor )
+
+ def set_range(self, min_val, max_val):
+ self.lihbor = min(self.lihbor, max_val)
+ self.lihbor = max(self.lihbor, min_val)
+ self.liubor = min(self.liubor, max_val)
+ self.liubor = max(self.liubor, min_val)
+ self.livbor = min(self.livbor, max_val)
+ self.livbor = max(self.livbor, min_val)
+ self.litbor = min(self.litbor, max_val)
+ self.litbor = max(self.litbor, min_val)
+
"""Boundary conditions file reader"""
class BoundaryConditionReader():
def __init__(self, file_name):
if cnd:
if groups.count(cnd.group) == 0:
+ if cnd.get_min() < 0 or cnd.get_max() > 6:
+ cnd.set_range(0, 6)
+ self._errors.append("Line #%s: values out of range [0, 6] have been adjusted." % line_number)
+
conditions.append(cnd)
groups.append(cnd.group)
cnd_count += 1