diff --git a/src/View/InitialConditions/DialogDischarge.py b/src/View/InitialConditions/DialogDischarge.py index f8e7e32a41aa630dcaf4a3cbaee35dd8220b4ca7..7bbe8abd81324948bf19ef5479367b57c40b0f3b 100644 --- a/src/View/InitialConditions/DialogDischarge.py +++ b/src/View/InitialConditions/DialogDischarge.py @@ -16,8 +16,7 @@ # -*- coding: utf-8 -*- -from View.ASubWindow import ASubWindow -from View.ListedSubWindow import ListedSubWindow +from View.Tools.PamhyrWindow import PamhyrDialog from PyQt5.QtGui import ( QKeySequence, @@ -32,10 +31,15 @@ from PyQt5.QtWidgets import ( QDoubleSpinBox, ) -class DischargeDialog(ASubWindow, ListedSubWindow): +class DischargeDialog(PamhyrDialog): + _pamhyr_ui = "InitialConditions_Dialog_Generator_Discharge" + _pamhyr_name = "Discharge" + def __init__(self, title="Discharge", parent=None): super(DischargeDialog, self).__init__( - name=title, ui="InitialConditions_Dialog_Generator_Discharge", parent=parent + title = _pamhyr_name, + options = [], + parent = parent ) self.value = None diff --git a/src/View/InitialConditions/DialogHeight.py b/src/View/InitialConditions/DialogHeight.py index 18ad67c85f13c880f34e3b7424d86ef440652d5c..9ccadbd6126bacb0809624b678606205c43dd5eb 100644 --- a/src/View/InitialConditions/DialogHeight.py +++ b/src/View/InitialConditions/DialogHeight.py @@ -16,8 +16,7 @@ # -*- coding: utf-8 -*- -from View.ASubWindow import ASubWindow -from View.ListedSubWindow import ListedSubWindow +from View.Tools.PamhyrWindow import PamhyrDialog from PyQt5.QtGui import ( QKeySequence, @@ -32,10 +31,15 @@ from PyQt5.QtWidgets import ( QDoubleSpinBox, ) -class HeightDialog(ASubWindow, ListedSubWindow): - def __init__(self, title="Height", parent=None): +class HeightDialog(PamhyrDialog): + _pamhyr_ui = "InitialConditions_Dialog_Generator_Height" + _pamhyr_name = "Height" + + def __init__(self, parent=None): super(HeightDialog, self).__init__( - name=title, ui="InitialConditions_Dialog_Generator_Height", parent=parent + title = name, + options = [], + parent = parent ) self.value = None diff --git a/src/View/InitialConditions/Window.py b/src/View/InitialConditions/Window.py index 00e7b1216ee75280bb2ea4a6b429a621eb57527d..3f5ee1d8508f45cadef04eab0376badde6a6bcef 100644 --- a/src/View/InitialConditions/Window.py +++ b/src/View/InitialConditions/Window.py @@ -20,8 +20,7 @@ import logging from tools import trace, timer -from View.ASubWindow import ASubMainWindow -from View.ListedSubWindow import ListedSubWindow +from View.Tools.PamhyrWindow import PamhyrWindow from PyQt5.QtGui import ( QKeySequence, @@ -61,41 +60,37 @@ _translate = QCoreApplication.translate logger = logging.getLogger() -class InitialConditionsWindow(ASubMainWindow, ListedSubWindow): - def __init__(self, title="Initial condition", - study=None, parent=None): - self._study = study - self._reach = study.river.current_reach() - self._ics = self._study.river.initial_conditions.get(self._reach) +class InitialConditionsWindow(PamhyrWindow): + _pamhyr_ui = "InitialConditions" + _pamhyr_name = "Initial condition" - self.setup_title(title) + def __init__(self, study=None, config=None, reach=None, parent=None): + if reach is not None: + self._reach = reach + else: + self._reach = study.river.current_reach() + + name = ( + self._pamhyr_name + + " - " + study.name + + " - " + self._reach.name + ) super(InitialConditionsWindow, self).__init__( - name=self._title, ui="InitialConditions", parent=parent + title = name, + study = study, + config = config, + parent = parent ) - self.setup_sc() + self._ics = study.river.initial_conditions.get(self._reach) + self.setup_table() self.setup_graph() self.setup_connections() self.ui.setWindowTitle(self._title) - def setup_title(self, title): - self._title = ( - title + " - " - + self._study.name + " - " - + self._reach.name - ) - - def setup_sc(self): - self._undo_stack = QUndoStack() - - self.undo_sc = QShortcut(QKeySequence.Undo, self) - self.redo_sc = QShortcut(QKeySequence.Redo, self) - self.copy_sc = QShortcut(QKeySequence.Copy, self) - self.paste_sc = QShortcut(QKeySequence.Paste, self) - def setup_table(self): retranslate() @@ -167,11 +162,6 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow): self.generate_discharge ) - self.undo_sc.activated.connect(self.undo) - self.redo_sc.activated.connect(self.redo) - self.copy_sc.activated.connect(self.copy) - self.paste_sc.activated.connect(self.paste) - self._table.dataChanged.connect(self._update_plot) def index_selected_row(self): @@ -227,19 +217,19 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow): self._table.move_down(row) self._update_plot() - def copy(self): + def _copy(self): logger.info("TODO: copy") self._update_plot() - def paste(self): + def _paste(self): logger.info("TODO: paste") self._update_plot() - def undo(self): + def _undo(self): self._table.undo() self._update_plot() - def redo(self): + def _redo(self): self._table.redo() self._update_plot() diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 02a4e1fefe8475d344aa026078f96fd65bc3e85e..f5b3ffef51b4e9d4434b7f2bc4a7a9b167d1648b 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -47,7 +47,7 @@ from View.Network.Window import NetworkWindow from View.Geometry.Window import GeometryWindow from View.BoundaryCondition.Window import BoundaryConditionWindow from View.LateralContribution.Window import LateralContributionWindow -# from View.InitialConditions.Window import InitialConditionsWindow +from View.InitialConditions.Window import InitialConditionsWindow # from View.Stricklers.Window import StricklersWindow # from View.Frictions.Window import FrictionsWindow # from View.SedimentLayers.Window import SedimentLayersWindow @@ -611,6 +611,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): if initial is None: initial = InitialConditionsWindow( study = self._study, + config = self.conf, parent = self ) initial.show()