MainWindow: Add BC short cut for sediment.

setup.py
Pierre-Antoine Rouby 2024-02-26 14:21:49 +01:00
parent a4c5d34720
commit 8466531916
4 changed files with 31 additions and 2 deletions

View File

@ -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()

View File

@ -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(

View File

@ -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

View File

@ -176,6 +176,7 @@
<property name="title">
<string>&amp;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>