diff --git a/src/View/BoundaryCondition/Edit/Table.py b/src/View/BoundaryCondition/Edit/Table.py index 35360400244d11b449e59138f60e60c0cdc1396a..e89e6d0d87fbb19e97232b1580486a9887c48213 100644 --- a/src/View/BoundaryCondition/Edit/Table.py +++ b/src/View/BoundaryCondition/Edit/Table.py @@ -23,8 +23,6 @@ from datetime import date, time, datetime, timedelta from tools import trace, timer -from View.ASubWindow import ASubMainWindow, AWidget -from View.ListedSubWindow import ListedSubWindow from View.Tools.PamhyrTable import PamhyrTableModel from PyQt5.QtCore import ( diff --git a/src/View/BoundaryCondition/Edit/Window.py b/src/View/BoundaryCondition/Edit/Window.py index 6e0d6131178c6437dbea0f3b9c750e9d75abb31f..249a34cb80da10b764191d99aa18b510c22d6238 100644 --- a/src/View/BoundaryCondition/Edit/Window.py +++ b/src/View/BoundaryCondition/Edit/Window.py @@ -20,8 +20,8 @@ import logging from tools import timer, trace -from View.ASubWindow import ASubMainWindow, AWidget -from View.ListedSubWindow import ListedSubWindow +from View.Tools.PamhyrWindow import PamhyrWindow +from View.Tools.PamhyrWidget import PamhyrWidget from View.Tools.PamhyrDelegate import PamhyrExTimeDelegate from PyQt5.QtGui import ( @@ -54,16 +54,16 @@ _translate = QCoreApplication.translate logger = logging.getLogger() -class WD50Sigma(AWidget): +class WD50Sigma(PamhyrWidget): + _pamhyr_ui = "d50sigma" + d50Changed = pyqtSignal(float) sigmaChanged = pyqtSignal(float) def __init__(self, parent=None): super(WD50Sigma, self).__init__( - ui="d50sigma", parent=parent ) - self.parent = parent self.spinBox_d50 = self.find(QDoubleSpinBox, "doubleSpinBox_d50") self.spinBox_sigma = self.find(QDoubleSpinBox, "doubleSpinBox_sigma") @@ -95,46 +95,38 @@ class WD50Sigma(AWidget): def valueChangedSigma(self, value): self.sigmaChanged.emit(value) -class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow): - def __init__(self, title="Edit boundary condition", - data=None, study=None, parent=None): +class EditBoundaryConditionWindow(PamhyrWindow): + _pamhyr_ui = "EditBoundaryConditions" + _pamhyr_name = "Edit Boundary Conditions" + + def __init__(self, data=None, study=None, config=None, parent=None): self._data = data - self._study = study - self._title = title - self.compute_title() + name = self._pamhyr_name + if self._data is not None: + node_name = (self._data.node.name if self._data.node is not None + else _translate("BoundaryCondition", "Not associate")) + name = ( + _translate("Edit boundary condition", self._pamhyr_name) + + f" - {study.name} " + + f" - {self._data.name} ({self._data.id}) " + + f"({long_types[self._data.bctype]} - {node_name})" + ) super(EditBoundaryConditionWindow, self).__init__( - name=self._title, ui="EditBoundaryConditions", parent=parent + title = name, + study = study, + config = config, + parent = parent ) self.ui.setWindowTitle(self._title) - self.setup_sc() self.setup_table() self.setup_plot() self.setup_data() self.setup_connections() - def compute_title(self): - if self._data is not None: - node_name = (self._data.node.name if self._data.node is not None - else _translate("BoundaryCondition", "Not associate")) - self._title = ( - _translate("Edit boundary condition", self._title) + - f" - {self._study.name} " + - f" - {self._data.name} ({self._data.id}) " + - f"({long_types[self._data.bctype]} - {node_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_data(self): self._is_solid = self._data.bctype == "SL" @@ -193,17 +185,11 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow): ) self.plot.draw() - def setup_connections(self): self.find(QAction, "action_add").triggered.connect(self.add) self.find(QAction, "action_del").triggered.connect(self.delete) self.find(QAction, "action_sort").triggered.connect(self.sort) - 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) if self._is_solid: @@ -252,7 +238,6 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow): ) ) - def add(self): rows = self.index_selected_rows() if len(self._data) == 0 or len(rows) == 0: @@ -285,7 +270,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow): self.plot.update() - def copy(self): + def _copy(self): rows = self.index_selected_rows() table = [] @@ -297,7 +282,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow): self.copyTableIntoClipboard(table) - def paste(self): + def _paste(self): header, data = self.parseClipboardTable() if len(data) == 0: @@ -311,12 +296,12 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow): self._table.paste(row, header, data) self.plot.update() - def undo(self): + def _undo(self): self._table.undo() self.plot.update() self.widget_update() - def redo(self): + def _redo(self): self._table.redo() self.plot.update() self.widget_update() diff --git a/src/View/BoundaryCondition/Window.py b/src/View/BoundaryCondition/Window.py index 7f8c13e27c6a6fd9cc909dbd7a8236c40d60742d..5f08ecf8ef6ab92d01eb90bfee30682a5ab46ce5 100644 --- a/src/View/BoundaryCondition/Window.py +++ b/src/View/BoundaryCondition/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, @@ -63,32 +62,28 @@ _translate = QCoreApplication.translate logger = logging.getLogger() -class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): - def __init__(self, title="Boundary conditions", study=None, parent=None): - self._title = title + " - " + study.name +class BoundaryConditionWindow(PamhyrWindow): + _pamhyr_ui = "BoundaryConditions" + _pamhyr_name = "Boundary conditions" + + def __init__(self, study=None, config=None, parent=None): + name = self._pamhyr_name + " - " + study.name super(BoundaryConditionWindow, self).__init__( - name=title, ui="BoundaryConditions", parent=parent + title = name, + study = study, + config = config, + parent=parent ) - self._study = study self._bcs = self._study.river.boundary_condition - self.setup_sc() self.setup_table() self.setup_graph() self.setup_connections() self.ui.setWindowTitle(self._title) - 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() self._table = {} @@ -141,11 +136,6 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): self.find(QAction, "action_edit").triggered.connect(self.edit) self.find(QAction, "action_sort").triggered.connect(self.sort) - 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) - def current_tab(self): return self.find(QTabWidget, "tabWidget")\ .currentWidget()\ @@ -202,17 +192,17 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): row = self.index_selected_row() self._table[tab].move_down(row) - 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): tab = self.current_tab() self._table[tab].undo() - def redo(self): + def _redo(self): tab = self.current_tab() self._table[tab].redo() diff --git a/src/View/Geometry/Profile/Window.py b/src/View/Geometry/Profile/Window.py index 54d1e0111bb39fa10a4f1045065c3976b9c248c2..eca6e7af14d99969d7df05e744b240ac922fbade 100644 --- a/src/View/Geometry/Profile/Window.py +++ b/src/View/Geometry/Profile/Window.py @@ -37,7 +37,8 @@ from PyQt5.QtWidgets import ( from Model.Geometry.Reach import Reach from Model.Geometry.ProfileXYZ import ProfileXYZ -from View.ASubWindow import ASubMainWindow +from View.Tools.ASubWindow import ASubMainWindow + from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow from View.Geometry.Profile.Plot import Plot from View.Geometry.Profile.Table import * diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 1c8cb5da4fb18af85068426a9c77199300ac2162..a66ed7812225cd52e8b7514814d0d80bb84602a8 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -41,8 +41,9 @@ from View.Geometry.PlotXY import PlotXY from View.Geometry.PlotKPZ import PlotKPZ from View.Geometry.PlotAC import PlotAC -from View.ASubWindow import ASubMainWindow, WindowToolKit -from View.ListedSubWindow import ListedSubWindow +from View.Tools.ASubWindow import ASubMainWindow, WindowToolKit +from View.Tools.ListedSubWindow import ListedSubWindow + from View.Geometry.mainwindow_ui_reach import Ui_MainWindow from View.Geometry.Table import * from View.Geometry.Profile.Window import ProfileWindow diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index cf253dd5d4408f954988c7604cffbce7f58b8328..f701a47447f46bffacd57e80e44bfc9ce216b96e 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -44,8 +44,8 @@ from View.Configure.Window import ConfigureWindow from View.Study.Window import NewStudyWindow from View.About.Window import AboutWindow from View.Network.Window import NetworkWindow -# from View.Geometry.Window import GeometryWindow -# from View.BoundaryCondition.Window import BoundaryConditionWindow +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.Stricklers.Window import StricklersWindow diff --git a/src/View/Plot/PamhyrToolbar.py b/src/View/Plot/PamhyrToolbar.py index 6a729f04fc4fdac96f194e5633ee0235befc29dc..c88dfacf6ffa5d8cc1180fed06fa9887137fb33f 100644 --- a/src/View/Plot/PamhyrToolbar.py +++ b/src/View/Plot/PamhyrToolbar.py @@ -81,8 +81,6 @@ class PamhyrPlotToolbar(NavigationToolbar2QT): os.path.abspath(f"{file_path}/../ui/ressources/zoom.png") )) - logger.info(os.path.abspath(f"{file_path}/../ui/ressources/zoom.png")) - icons.append(("zoom",icon_zoom)) if "iso" in items: diff --git a/src/View/Tools/PamhyrWidget.py b/src/View/Tools/PamhyrWidget.py index 60e061742036af1682446e5064341109c8fd6d3c..22bf9584c96955d86f7ec39cb15994439679e844 100644 --- a/src/View/Tools/PamhyrWidget.py +++ b/src/View/Tools/PamhyrWidget.py @@ -26,10 +26,21 @@ from PyQt5.QtWidgets import ( QSpinBox, QTimeEdit, QDateTimeEdit, QItemDelegate, ) -from View.ASubWindow import AWidget +from View.Tools.ASubWindow import AWidget logger = logging.getLogger() +class PamhyrWidget(AWidget): + _pamhyr_ui = "" + _pamhyr_name = "PamhyrWidget" + + def __init__(self, parent=None): + super(PamhyrWidget, self).__init__( + ui = self._pamhyr_ui, + parent = parent + ) + + class PamhyrExtendedTimeEdit(AWidget): def __init__(self, parent=None): super(PamhyrExtendedTimeEdit, self).__init__(