mirror of https://gitlab.com/pamhyr/pamhyr2
refactoring: Apply PamhyrWindow to SL.
parent
809a0dd9cb
commit
1a36d78ee2
|
|
@ -50,8 +50,8 @@ from View.LateralContribution.Window import LateralContributionWindow
|
|||
from View.InitialConditions.Window import InitialConditionsWindow
|
||||
from View.Stricklers.Window import StricklersWindow
|
||||
from View.Frictions.Window import FrictionsWindow
|
||||
# from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
# from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||
from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||
# from View.SolverParameters.Window import SolverParametersWindow
|
||||
# from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||
# from View.CheckList.Window import CheckListWindow
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -52,41 +51,32 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class EditSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Edit Sediment Layers",
|
||||
study=None, sl=None, parent=None):
|
||||
self._study = study
|
||||
class EditSedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "EditSedimentLayers"
|
||||
_pamhyr_name = "Edit Sediment Layers"
|
||||
|
||||
def __init__(self, study=None, config = None,
|
||||
sl=None, parent=None):
|
||||
self._sl = sl
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(EditSedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="EditSedimentLayers", parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
name = self._sl.name
|
||||
if name == "":
|
||||
name = _translate("SedimentLayers", "(no name)")
|
||||
|
||||
self._title = (
|
||||
title + " - " + self._study.name + " - " + name
|
||||
name = (
|
||||
self._pamhyr_name + " - " + study.name + " - " + name
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
super(EditSedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
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)
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
def setup_table(self):
|
||||
retranslate()
|
||||
|
|
@ -131,11 +121,6 @@ class EditSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_move_up").triggered.connect(self.move_up)
|
||||
self.find(QAction, "action_move_down").triggered.connect(self.move_down)
|
||||
|
||||
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._set_plot)
|
||||
self._table.layoutChanged.connect(self._set_plot)
|
||||
|
||||
|
|
@ -179,14 +164,14 @@ class EditSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
|
||||
self._table.move_down(rows[0])
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,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,
|
||||
|
|
@ -38,27 +37,31 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ProfileSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Profile sediment layers", study=None, profile=None, parent=None):
|
||||
self._study = study
|
||||
self._sediment_layers = self._study.river.sediment_layers
|
||||
self._profile = profile
|
||||
self._reach = self._study.river.current_reach().reach
|
||||
class ProfileSedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "ProfileSedimentLayers"
|
||||
_pamhyr_name = "Profile sediment layers"
|
||||
|
||||
self.setup_title(title)
|
||||
def __init__(self, study=None, config=None, profile=None, parent=None):
|
||||
self._sediment_layers = study.river.sediment_layers
|
||||
self._profile = profile
|
||||
self._reach = profile.reach
|
||||
|
||||
name = self.compute_name(study)
|
||||
|
||||
super(ProfileSedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="ProfileSedimentLayers", parent=parent
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
def compute_name(self, study):
|
||||
rname = self._reach.name
|
||||
if rname == "":
|
||||
rname = _translate("SedimentLayers", "(no name)")
|
||||
|
|
@ -70,20 +73,12 @@ class ProfileSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
"(no name - @kp)").replace("@kp", str(self._profile.kp)
|
||||
)
|
||||
|
||||
self._title = (
|
||||
title + " - "
|
||||
+ self._study.name + " - "
|
||||
return (
|
||||
self._pamhyr_name + " - "
|
||||
+ study.name + " - "
|
||||
+ rname + " - " + pname
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
|
|
@ -130,18 +125,9 @@ class ProfileSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
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.layoutChanged\
|
||||
.connect(self._update_plot)
|
||||
self._table.dataChanged\
|
||||
.connect(self._update_plot)
|
||||
|
||||
self._table.layoutChanged.connect(self._update_plot)
|
||||
self._table.dataChanged.connect(self._update_plot)
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
|
|
@ -155,14 +141,14 @@ class ProfileSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
)
|
||||
)
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from View.ASubWindow import ASubWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
|
|
@ -20,12 +19,16 @@ from View.SedimentLayers.Reach.translate import *
|
|||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class SLDialog(ASubWindow, ListedSubWindow):
|
||||
def __init__(self, title="SL", study=None, parent=None):
|
||||
self._study = study
|
||||
class SLDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "SLDialog"
|
||||
_pamhyr_name = "SL"
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
super(SLDialog, self).__init__(
|
||||
name=title, ui="SLDialog", parent=parent
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_combobox()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,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,
|
||||
|
|
@ -40,38 +39,31 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ReachSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Reach sediment layers", study=None, parent=None):
|
||||
self._study = study
|
||||
self._sediment_layers = self._study.river.sediment_layers
|
||||
self._reach = self._study.river.current_reach().reach
|
||||
class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "ReachSedimentLayers"
|
||||
_pamhyr_name = "Reach sediment layers"
|
||||
|
||||
self.setup_title(title)
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
self._sediment_layers = study.river.sediment_layers
|
||||
self._reach = study.river.current_reach().reach
|
||||
|
||||
super(ReachSedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="ReachSedimentLayers", parent=parent
|
||||
name = (
|
||||
self._pamhyr_name + " - " +
|
||||
study.name + " - " +
|
||||
self._reach.name
|
||||
)
|
||||
|
||||
super(ReachSedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent = parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
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()
|
||||
|
||||
|
|
@ -129,11 +121,6 @@ class ReachSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
.clicked\
|
||||
.connect(self.apply_sl_each_profile)
|
||||
|
||||
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.layoutChanged\
|
||||
.connect(self._update_plot)
|
||||
self._table.dataChanged\
|
||||
|
|
@ -152,17 +139,17 @@ class ReachSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
)
|
||||
)
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table.undo()
|
||||
self._update_plot()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
self._update_plot()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,26 @@
|
|||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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,
|
||||
|
|
@ -38,37 +53,33 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="SedimentLayersList", study=None, parent=None):
|
||||
self._study = study
|
||||
self._sediment_layers = self._study.river.sediment_layers
|
||||
class SedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SedimentLayersList"
|
||||
_pamhyr_name = "Sediment Layers List"
|
||||
|
||||
self.setup_title(title)
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
self._sediment_layers = study.river.sediment_layers
|
||||
|
||||
super(SedimentLayersWindow, self).__init__(
|
||||
name=self._title, ui="SedimentLayersList", parent=parent
|
||||
name = (
|
||||
self._pamhyr_name + " - " + study.name
|
||||
)
|
||||
|
||||
super(SedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
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
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
|
|
@ -94,11 +105,6 @@ class SedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_edit").triggered.connect(self.edit_sediment_layers)
|
||||
|
||||
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)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
|
|
@ -148,16 +154,16 @@ class SedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
|||
|
||||
self._table.delete(rows)
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
|
||||
def edit_sediment_layers(self):
|
||||
|
|
|
|||
|
|
@ -39,20 +39,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="action_add_sediment_layers"/>
|
||||
<addaction name="action_delete_sediment_layers"/>
|
||||
<addaction name="action_edit_sediment_layers"/>
|
||||
</widget>
|
||||
<action name="action_add_sediment_layers">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
|
|
|
|||
Loading…
Reference in New Issue