mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
refactoring: Apply new Pamhyr tools on IC.
This commit is contained in:
1 parent
7c4ba10871
commit
b2b5c971c3
4 files changed
+45
-46
No files matched your search
@@ -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()
|
||||
|
||||
super(InitialConditionsWindow, self).__init__(
|
||||
name=self._title, ui="InitialConditions", parent=parent
|
||||
name = (
|
||||
self._pamhyr_name +
|
||||
" - " + study.name +
|
||||
" - " + 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_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()
|
||||
|
||||
|
||||
Reference in new issue
Block a user