Commit b2b5c971 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

refactoring: Apply new Pamhyr tools on IC.

Showing with 44 additions and 45 deletions
+44 -45
......@@ -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
......
......@@ -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
......
......@@ -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()
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment