diff --git a/src/View/BoundaryCondition/Window.py b/src/View/BoundaryCondition/Window.py index 6377a73982b337aa816e0d46cfdcbf0d7c3fb318..f9ba4c134f8a70953883baeb3a3f5266d5863a16 100644 --- a/src/View/BoundaryCondition/Window.py +++ b/src/View/BoundaryCondition/Window.py @@ -18,7 +18,7 @@ import logging -from tools import trace, timer +from tools import trace, timer, logger_exception from View.Tools.PamhyrWindow import PamhyrWindow @@ -37,6 +37,7 @@ from PyQt5.QtWidgets import ( QFileDialog, QTableView, QAbstractItemView, QUndoStack, QShortcut, QAction, QItemDelegate, QComboBox, QVBoxLayout, QHeaderView, QTabWidget, + QWidget, ) from Model.BoundaryCondition.BoundaryConditionTypes import ( @@ -170,6 +171,13 @@ class BoundaryConditionWindow(PamhyrWindow): ) ) + def set_active_tab(self, tab_id=0): + try: + tab_widget = self.find(QTabWidget, "tabWidget") + tab_widget.setCurrentIndex(tab_id) + except Exception as e: + logger_exception(e) + def add(self): tab = self.current_tab() rows = self.index_selected_rows() diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 45dfca3c6566c0bc273088980646b0f4485b81ca..ff57e77a549888db177cdc51065e0a6682445549 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -109,6 +109,7 @@ define_model_action = [ "action_menu_edit_reach_sediment_layers", "action_menu_edit_reservoirs", "action_menu_edit_hydraulic_structures", "action_menu_results_last", "action_open_results_from_file", + "action_menu_boundary_conditions_sediment", ] action = ( @@ -200,6 +201,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): "action_menu_edit_network": self.open_network, "action_menu_edit_geometry": self.open_geometry, "action_menu_boundary_conditions": self.open_boundary_cond, + "action_menu_boundary_conditions_sediment": self.open_boundary_cond_sed, "action_menu_edit_reservoirs": self.open_reservoir, "action_menu_edit_hydraulic_structures": self.open_hydraulic_structures, @@ -764,15 +766,24 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): else: self.msg_select_reach() - def open_boundary_cond(self): + def open_boundary_cond_sed(self): + self.open_boundary_cond(tab=1) + + def open_boundary_cond(self, tab=0): if self.sub_window_exists( BoundaryConditionWindow, data=[self._study, None] ): + bound = self.get_sub_window( + BoundaryConditionWindow, + data=[self._study, None] + ) + bound.set_active_tab(tab) return bound = BoundaryConditionWindow(study=self._study, parent=self) bound.show() + bound.set_active_tab(tab) def open_reservoir(self): if self.sub_window_exists( diff --git a/src/View/Tools/ListedSubWindow.py b/src/View/Tools/ListedSubWindow.py index d40e58ddf3e0526be967a751ac3ab660889433f3..d369c78240d9e1c280da1603674d395bb6f26c4a 100644 --- a/src/View/Tools/ListedSubWindow.py +++ b/src/View/Tools/ListedSubWindow.py @@ -83,6 +83,10 @@ class ListedSubWindow(object): except Exception: return None + def get_sub_window(self, cls, data=None): + hash = cls._hash(data) + return self.get_sub_win(hash) + def sub_window_exists(self, cls, data=None): """Check if window already exists diff --git a/src/View/ui/MainWindow.ui b/src/View/ui/MainWindow.ui index 0e47519f41718073e4286e17321c404be692d46c..2458faa28e7c6aeb0926c2a0e345ebf4001faee5 100644 --- a/src/View/ui/MainWindow.ui +++ b/src/View/ui/MainWindow.ui @@ -176,6 +176,7 @@ <property name="title"> <string>&Sediment</string> </property> + <addaction name="action_menu_boundary_conditions_sediment"/> <addaction name="action_menu_sediment_layers"/> <addaction name="action_menu_edit_reach_sediment_layers"/> </widget> @@ -957,6 +958,11 @@ <string>Open results from file</string> </property> </action> + <action name="action_menu_boundary_conditions_sediment"> + <property name="text"> + <string>Boundary conditions and punctual contributions</string> + </property> + </action> </widget> <resources/> <connections>