mirror of https://gitlab.com/pamhyr/pamhyr2
keep previons settings in generate IC dialogs
parent
fe4ae46784
commit
3814f9a1c9
|
|
@ -36,7 +36,7 @@ class DepthDialog(PamhyrDialog):
|
|||
_pamhyr_ui = "InitialConditions_Dialog_Generator_Depth"
|
||||
_pamhyr_name = "Depth"
|
||||
|
||||
def __init__(self, trad=None, parent=None):
|
||||
def __init__(self, value, option, trad=None, parent=None):
|
||||
super(DepthDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
options=[],
|
||||
|
|
@ -44,12 +44,16 @@ class DepthDialog(PamhyrDialog):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self.value = None
|
||||
self.option = None
|
||||
self.value = value
|
||||
self.option = option
|
||||
self.sb = self.find(QDoubleSpinBox, "doubleSpinBox")
|
||||
self.sb.setValue(self.value)
|
||||
self.cb = self.find(QCheckBox, "checkBox")
|
||||
self.cb.setChecked(self.option)
|
||||
|
||||
def accept(self):
|
||||
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
||||
self.option = self.find(QCheckBox, "checkBox").isChecked()
|
||||
self.value = self.sb.value()
|
||||
self.option = self.cb.isChecked()
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class DischargeDialog(PamhyrDialog):
|
|||
_pamhyr_ui = "InitialConditions_Dialog_Generator_Discharge"
|
||||
_pamhyr_name = "Discharge"
|
||||
|
||||
def __init__(self, title="Discharge", trad=None, parent=None):
|
||||
def __init__(self, value, option, title="Discharge", trad=None, parent=None):
|
||||
super(DischargeDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
options=[],
|
||||
|
|
@ -44,12 +44,16 @@ class DischargeDialog(PamhyrDialog):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self.value = None
|
||||
self.option = None
|
||||
self.value = value
|
||||
self.option = option
|
||||
self.sb = self.find(QDoubleSpinBox, "doubleSpinBox")
|
||||
self.sb.setValue(self.value)
|
||||
self.cb = self.find(QCheckBox, "checkBox")
|
||||
self.cb.setChecked(self.option)
|
||||
|
||||
def accept(self):
|
||||
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
||||
self.option = self.find(QCheckBox, "checkBox").isChecked()
|
||||
self.value = self.sb.value()
|
||||
self.option = self.cb.isChecked()
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class HeightDialog(PamhyrDialog):
|
|||
_pamhyr_ui = "InitialConditions_Dialog_Generator_Height"
|
||||
_pamhyr_name = "Height"
|
||||
|
||||
def __init__(self, trad=None, parent=None):
|
||||
def __init__(self, values, option, trad=None, parent=None):
|
||||
super(HeightDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
options=[],
|
||||
|
|
@ -44,27 +44,29 @@ class HeightDialog(PamhyrDialog):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self.value = [None, None, None]
|
||||
self.option = None
|
||||
self.find(QCheckBox, "checkBox").clicked.connect(
|
||||
self.enable_discharge
|
||||
)
|
||||
self.values = values
|
||||
self.option = option
|
||||
self.sb1 = self.find(QDoubleSpinBox, "doubleSpinBox_1")
|
||||
self.sb1.setValue(self.values[0])
|
||||
self.sb2 = self.find(QDoubleSpinBox, "doubleSpinBox_2")
|
||||
self.sb2.setValue(self.values[1])
|
||||
self.sb3 = self.find(QDoubleSpinBox, "doubleSpinBox_3")
|
||||
self.sb3.setValue(self.values[2])
|
||||
self.cb = self.find(QCheckBox, "checkBox")
|
||||
self.cb.setChecked(self.option)
|
||||
self.enable_discharge()
|
||||
self.cb.clicked.connect(self.enable_discharge)
|
||||
|
||||
def enable_discharge(self):
|
||||
cb = self.find(QCheckBox, "checkBox")
|
||||
dsb = self.find(QDoubleSpinBox, "doubleSpinBox_3")
|
||||
l = self.find(QLabel, "label_3")
|
||||
dsb.setEnabled(cb.isChecked())
|
||||
l.setEnabled(cb.isChecked())
|
||||
self.sb3.setEnabled(self.cb.isChecked())
|
||||
l.setEnabled(self.cb.isChecked())
|
||||
|
||||
def accept(self):
|
||||
self.value[0] = self.find(QDoubleSpinBox, "doubleSpinBox_1").value()
|
||||
self.value[1] = self.find(QDoubleSpinBox, "doubleSpinBox_2").value()
|
||||
self.option = self.find(QCheckBox, "checkBox").isChecked()
|
||||
if self.option:
|
||||
self.value[2] = self.find(QDoubleSpinBox, "doubleSpinBox_3").value()
|
||||
else:
|
||||
self.value[2] = None
|
||||
self.values[0] = self.sb1.value()
|
||||
self.values[1] = self.sb2.value()
|
||||
self.values[2] = self.sb3.value()
|
||||
self.option = self.cb.isChecked()
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||
self.setup_table()
|
||||
self.setup_plot()
|
||||
self.setup_connections()
|
||||
self.setub_dialogs()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
|
|
@ -188,6 +189,14 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||
|
||||
self._table.dataChanged.connect(self._update_plot)
|
||||
|
||||
def setub_dialogs(self):
|
||||
self.height_values = [0.0, 0.0, 0.0]
|
||||
self.height_option = True
|
||||
self.discharge_value = 0.0
|
||||
self.discharge_option = True
|
||||
self.depth_value = 0.0
|
||||
self.depth_option = True
|
||||
|
||||
def index_selected_row(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
rows = table.selectionModel()\
|
||||
|
|
@ -351,25 +360,40 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||
self._update()
|
||||
|
||||
def generate_growing_constant_depth(self):
|
||||
dlg = DepthDialog(trad=self._trad, parent=self)
|
||||
dlg = DepthDialog(self.depth_value,
|
||||
self.depth_option,
|
||||
trad=self._trad,
|
||||
parent=self)
|
||||
if dlg.exec():
|
||||
value = dlg.value
|
||||
compute_discharge = dlg.option
|
||||
self._table.generate("growing", value, compute_discharge)
|
||||
self.depth_value = dlg.value
|
||||
self.depth_option = dlg.option
|
||||
self._table.generate("growing",
|
||||
self.depth_value,
|
||||
self.depth_option)
|
||||
self._update()
|
||||
|
||||
def generate_discharge(self):
|
||||
dlg = DischargeDialog(trad=self._trad, parent=self)
|
||||
dlg = DischargeDialog(self.discharge_value,
|
||||
self.discharge_option,
|
||||
trad=self._trad,
|
||||
parent=self)
|
||||
if dlg.exec():
|
||||
value = dlg.value
|
||||
compute_depth = dlg.option
|
||||
self._table.generate("discharge", value, compute_depth)
|
||||
self.discharge_value = dlg.value
|
||||
self.discharge_option = dlg.option
|
||||
self._table.generate("discharge",
|
||||
self.discharge_value,
|
||||
self.discharge_option)
|
||||
self._update()
|
||||
|
||||
def generate_height(self):
|
||||
dlg = HeightDialog(trad=self._trad, parent=self)
|
||||
dlg = HeightDialog(self.height_values,
|
||||
self.height_option,
|
||||
trad=self._trad,
|
||||
parent=self)
|
||||
if dlg.exec():
|
||||
value = dlg.value
|
||||
compute_discharge = dlg.option
|
||||
self._table.generate("height", value, compute_discharge)
|
||||
self.height_values = dlg.values
|
||||
self.height_option = dlg.option
|
||||
self._table.generate("height",
|
||||
self.height_values,
|
||||
self.height_option)
|
||||
self._update()
|
||||
|
|
|
|||
Loading…
Reference in New Issue