diff --git a/src/Model/Ensembles/Ensemble.py b/src/Model/Ensembles/Ensemble.py index c978fc2b..d24d4644 100644 --- a/src/Model/Ensembles/Ensemble.py +++ b/src/Model/Ensembles/Ensemble.py @@ -31,7 +31,7 @@ class Ensemble(SQLSubModel): _sub_classes = [] def __init__(self, id: int = -1, name: str = "", - function=None, range=[], + function=None, range=[0., 100.], data_type=None, target_data=None, status=None, owner_scenario=-1): super(Ensemble, self).__init__( diff --git a/src/View/Ensembles/Table.py b/src/View/Ensembles/Table.py index 93a744e0..9cf3d7a7 100644 --- a/src/View/Ensembles/Table.py +++ b/src/View/Ensembles/Table.py @@ -171,6 +171,9 @@ class EnsembleTableModel(PamhyrTableModel): if value is None: return self._trad["not_defined"] return value.name + elif self._headers[column] == "parameters": + value = self._lst.get(row).range + return str(value) return QVariant() diff --git a/src/View/Ensembles/Window.py b/src/View/Ensembles/Window.py index 1212a18e..c361bb7c 100644 --- a/src/View/Ensembles/Window.py +++ b/src/View/Ensembles/Window.py @@ -18,9 +18,9 @@ import logging -from tools import trace, timer +from tools import trace, timer, logger_exception -from View.Tools.PamhyrWindow import PamhyrWindow +from View.Tools.PamhyrWindow import PamhyrWindow, PamhyrDialog from PyQt5.QtGui import ( QKeySequence, @@ -141,7 +141,7 @@ class EnsemblesWindow(PamhyrWindow): if self._study.is_editable(): self.find(QAction, "action_add").triggered.connect(self.add) self.find(QAction, "action_del").triggered.connect(self.delete) - # self.find(QAction, "action_edit").triggered.connect(self.edit) + self.find(QAction, "action_edit").triggered.connect(self.edit) table = self.find(QTableView, f"tableView") table.selectionModel()\ @@ -183,16 +183,55 @@ class EnsemblesWindow(PamhyrWindow): def _redo(self): self._table.redo() - # def edit(self): - # if self.sub_window_exists( - # EnsemblesWindow, - # data=[self._study, self.parent.conf] - # ): - # return + def edit(self): + rows = self.index_selected_rows() - # strick = EnsemblesWindow( - # study=self._study, - # config=self.parent.conf, - # parent=self - # ) - # strick.show() + for row in rows: + try: + dlg = MinMaxDialog( + ensemble=self._ensembles.get(row), + trad=self._trad, + parent=self + ) + if dlg.exec(): + self._ensembles.get(row).range = dlg._minmax + except Exception as e: + logger_exception(e) + return + +class MinMaxDialog(PamhyrDialog): + _pamhyr_ui = "MinMaxDialog" + _pamhyr_name = "Minmax" + + def __init__(self, ensemble=None, + trad=None, parent=None): + super(MinMaxDialog, self).__init__( + title=trad[self._pamhyr_name], + trad=trad, + options=[], + parent=parent + ) + + self._ensemble = ensemble + + self._init_default_values() + + def _init_default_values(self): + self._minmax = self._ensemble.range + if len(self._minmax) > 0: + self.set_double_spin_box("doubleSpinBox_min", self._minmax[0]) + self.set_double_spin_box("doubleSpinBox_max", self._minmax[1]) + + @property + def minmax(self): + return self._minmax + + def accept(self): + self._minmax = [ + self.get_double_spin_box("doubleSpinBox_min"), + self.get_double_spin_box("doubleSpinBox_max") + ] + super().accept() + + def reject(self): + self.close()