mirror of https://gitlab.com/pamhyr/pamhyr2
Ensemble: Add min max dialog for range.
parent
5b3f777100
commit
394c0779fc
|
|
@ -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__(
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue