From: mzn Date: Mon, 21 Nov 2016 13:27:54 +0000 (+0300) Subject: refs #1028,1029: adjust values from file to [0, 6] range, show help message on help... X-Git-Tag: v1.6~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5eca125259b956b1fd1312fac8f473961f8a6313;p=modules%2Fhydrosolver.git refs #1028,1029: adjust values from file to [0, 6] range, show help message on help button click. --- diff --git a/src/HYDROGUI/BndConditionsDialog.py b/src/HYDROGUI/BndConditionsDialog.py index 29cb4ba..5156d84 100644 --- a/src/HYDROGUI/BndConditionsDialog.py +++ b/src/HYDROGUI/BndConditionsDialog.py @@ -104,7 +104,7 @@ class BoundaryConditionsDialog(QtGui.QDialog): 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) @@ -134,7 +134,7 @@ class BoundaryConditionsDialog(QtGui.QDialog): """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() @@ -205,12 +205,7 @@ class BoundaryConditionsDialog(QtGui.QDialog): 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 @@ -242,7 +237,13 @@ class BoundaryConditionsDialog(QtGui.QDialog): 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: @@ -383,4 +384,40 @@ class BoundaryConditionsDialog(QtGui.QDialog): else: is_ok = True - return is_ok \ No newline at end of file + return is_ok + + """Shows help page""" + def on_help(self): + msg = """ +

Boundary conditions dialog

+ + This dialog is used to read and write boundary conditions files. + Below is the description of the dialog controls. + +

MED file

+ 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. + +

Boundary conditions file

+ 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. + +

Result boundary conditions file

+ 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. + +

Boundary conditions table

+ 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. +
+
+ 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 diff --git a/src/HYDROTools/boundaryConditions.py b/src/HYDROTools/boundaryConditions.py index 307f6b4..041314d 100644 --- a/src/HYDROTools/boundaryConditions.py +++ b/src/HYDROTools/boundaryConditions.py @@ -63,6 +63,22 @@ class BoundaryCondition(): 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): @@ -117,6 +133,10 @@ class BoundaryConditionReader(): 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