mirror of https://gitlab.com/pamhyr/pamhyr2
refactoring: Apply new Pamhyr tools on IC.
parent
7c4ba10871
commit
b2b5c971c3
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from View.ASubWindow import ASubWindow
|
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||||
from View.ListedSubWindow import ListedSubWindow
|
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QKeySequence,
|
QKeySequence,
|
||||||
|
|
@ -32,10 +31,15 @@ from PyQt5.QtWidgets import (
|
||||||
QDoubleSpinBox,
|
QDoubleSpinBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
class DischargeDialog(ASubWindow, ListedSubWindow):
|
class DischargeDialog(PamhyrDialog):
|
||||||
|
_pamhyr_ui = "InitialConditions_Dialog_Generator_Discharge"
|
||||||
|
_pamhyr_name = "Discharge"
|
||||||
|
|
||||||
def __init__(self, title="Discharge", parent=None):
|
def __init__(self, title="Discharge", parent=None):
|
||||||
super(DischargeDialog, self).__init__(
|
super(DischargeDialog, self).__init__(
|
||||||
name=title, ui="InitialConditions_Dialog_Generator_Discharge", parent=parent
|
title = _pamhyr_name,
|
||||||
|
options = [],
|
||||||
|
parent = parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self.value = None
|
self.value = None
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from View.ASubWindow import ASubWindow
|
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||||
from View.ListedSubWindow import ListedSubWindow
|
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QKeySequence,
|
QKeySequence,
|
||||||
|
|
@ -32,10 +31,15 @@ from PyQt5.QtWidgets import (
|
||||||
QDoubleSpinBox,
|
QDoubleSpinBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
class HeightDialog(ASubWindow, ListedSubWindow):
|
class HeightDialog(PamhyrDialog):
|
||||||
def __init__(self, title="Height", parent=None):
|
_pamhyr_ui = "InitialConditions_Dialog_Generator_Height"
|
||||||
|
_pamhyr_name = "Height"
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
super(HeightDialog, self).__init__(
|
super(HeightDialog, self).__init__(
|
||||||
name=title, ui="InitialConditions_Dialog_Generator_Height", parent=parent
|
title = name,
|
||||||
|
options = [],
|
||||||
|
parent = parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self.value = None
|
self.value = None
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@ import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||||
from View.ListedSubWindow import ListedSubWindow
|
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QKeySequence,
|
QKeySequence,
|
||||||
|
|
@ -61,41 +60,37 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
class InitialConditionsWindow(PamhyrWindow):
|
||||||
def __init__(self, title="Initial condition",
|
_pamhyr_ui = "InitialConditions"
|
||||||
study=None, parent=None):
|
_pamhyr_name = "Initial condition"
|
||||||
self._study = study
|
|
||||||
|
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()
|
self._reach = study.river.current_reach()
|
||||||
self._ics = self._study.river.initial_conditions.get(self._reach)
|
|
||||||
|
|
||||||
self.setup_title(title)
|
name = (
|
||||||
|
self._pamhyr_name +
|
||||||
super(InitialConditionsWindow, self).__init__(
|
" - " + study.name +
|
||||||
name=self._title, ui="InitialConditions", parent=parent
|
" - " + self._reach.name
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setup_sc()
|
super(InitialConditionsWindow, self).__init__(
|
||||||
|
title = name,
|
||||||
|
study = study,
|
||||||
|
config = config,
|
||||||
|
parent = parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._ics = study.river.initial_conditions.get(self._reach)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_graph()
|
self.setup_graph()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
self.ui.setWindowTitle(self._title)
|
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):
|
def setup_table(self):
|
||||||
retranslate()
|
retranslate()
|
||||||
|
|
||||||
|
|
@ -167,11 +162,6 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.generate_discharge
|
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)
|
self._table.dataChanged.connect(self._update_plot)
|
||||||
|
|
||||||
def index_selected_row(self):
|
def index_selected_row(self):
|
||||||
|
|
@ -227,19 +217,19 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._table.move_down(row)
|
self._table.move_down(row)
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def copy(self):
|
def _copy(self):
|
||||||
logger.info("TODO: copy")
|
logger.info("TODO: copy")
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def paste(self):
|
def _paste(self):
|
||||||
logger.info("TODO: paste")
|
logger.info("TODO: paste")
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def undo(self):
|
def _undo(self):
|
||||||
self._table.undo()
|
self._table.undo()
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def redo(self):
|
def _redo(self):
|
||||||
self._table.redo()
|
self._table.redo()
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ from View.Network.Window import NetworkWindow
|
||||||
from View.Geometry.Window import GeometryWindow
|
from View.Geometry.Window import GeometryWindow
|
||||||
from View.BoundaryCondition.Window import BoundaryConditionWindow
|
from View.BoundaryCondition.Window import BoundaryConditionWindow
|
||||||
from View.LateralContribution.Window import LateralContributionWindow
|
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.Stricklers.Window import StricklersWindow
|
||||||
# from View.Frictions.Window import FrictionsWindow
|
# from View.Frictions.Window import FrictionsWindow
|
||||||
# from View.SedimentLayers.Window import SedimentLayersWindow
|
# from View.SedimentLayers.Window import SedimentLayersWindow
|
||||||
|
|
@ -611,6 +611,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if initial is None:
|
if initial is None:
|
||||||
initial = InitialConditionsWindow(
|
initial = InitialConditionsWindow(
|
||||||
study = self._study,
|
study = self._study,
|
||||||
|
config = self.conf,
|
||||||
parent = self
|
parent = self
|
||||||
)
|
)
|
||||||
initial.show()
|
initial.show()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue