diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 562b05d75ffa6c00fb07bade1c87b1eff2f83305..002ee11bd6cca88bae89848fd83b17dd4f41810f 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -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 diff --git a/src/View/SedimentLayers/Edit/Window.py b/src/View/SedimentLayers/Edit/Window.py index 29b9ddffa16ba2cadac6f2ac6d55c8c43bf4317e..ebe3aece00f1792351dc497742b06f67c2312aa4 100644 --- a/src/View/SedimentLayers/Edit/Window.py +++ b/src/View/SedimentLayers/Edit/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, @@ -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 - 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() +class EditSedimentLayersWindow(PamhyrWindow): + _pamhyr_ui = "EditSedimentLayers" + _pamhyr_name = "Edit Sediment Layers" - self.ui.setWindowTitle(self._title) + def __init__(self, study=None, config = None, + sl=None, parent=None): + self._sl = sl - 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() diff --git a/src/View/SedimentLayers/Reach/Profile/Window.py b/src/View/SedimentLayers/Reach/Profile/Window.py index eaae59d385dcf7379cbb334ec249ad7b53554fb8..f424e06a8a3b64fab29a186d3af6463be448d362 100644 --- a/src/View/SedimentLayers/Reach/Profile/Window.py +++ b/src/View/SedimentLayers/Reach/Profile/Window.py @@ -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 +class ProfileSedimentLayersWindow(PamhyrWindow): + _pamhyr_ui = "ProfileSedimentLayers" + _pamhyr_name = "Profile sediment layers" + + def __init__(self, study=None, config=None, profile=None, parent=None): + self._sediment_layers = study.river.sediment_layers self._profile = profile - self._reach = self._study.river.current_reach().reach + self._reach = profile.reach - self.setup_title(title) + 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() diff --git a/src/View/SedimentLayers/Reach/SLDialog.py b/src/View/SedimentLayers/Reach/SLDialog.py index ce1e97942547b805c0bfb2d5c328ca87c66137b0..c8a1efa0cf2952ea6f5caa2c1df89b4dce24a521 100644 --- a/src/View/SedimentLayers/Reach/SLDialog.py +++ b/src/View/SedimentLayers/Reach/SLDialog.py @@ -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() diff --git a/src/View/SedimentLayers/Reach/Window.py b/src/View/SedimentLayers/Reach/Window.py index d79312b221a5d9851b089a464cc5cc17fbb35d6e..2a655b7c3c7d7bbfcc2b57d28c25aad741838c32 100644 --- a/src/View/SedimentLayers/Reach/Window.py +++ b/src/View/SedimentLayers/Reach/Window.py @@ -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 + + name = ( + self._pamhyr_name + " - " + + study.name + " - " + + self._reach.name + ) super(ReachSedimentLayersWindow, self).__init__( - name=self._title, ui="ReachSedimentLayers", 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): - 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() diff --git a/src/View/SedimentLayers/Window.py b/src/View/SedimentLayers/Window.py index 6c14ae6c117132cf592572d78b20cbd1f08be673..c4010745508b971b8197b2acfd9ca56e39ffce8f 100644 --- a/src/View/SedimentLayers/Window.py +++ b/src/View/SedimentLayers/Window.py @@ -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" + + def __init__(self, study=None, config=None, parent=None): + self._sediment_layers = study.river.sediment_layers - self.setup_title(title) + name = ( + self._pamhyr_name + " - " + study.name + ) super(SedimentLayersWindow, self).__init__( - name=self._title, ui="SedimentLayersList", 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): 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): diff --git a/src/View/ui/ProfileSedimentLayers.ui b/src/View/ui/ProfileSedimentLayers.ui index b9f5106dab3d25190b3d41bd8209e2e89cdd36ed..05f6618e7a98d509a9ed7f56f72bb4d60a73f915 100644 --- a/src/View/ui/ProfileSedimentLayers.ui +++ b/src/View/ui/ProfileSedimentLayers.ui @@ -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>