mirror of https://gitlab.com/pamhyr/pamhyr2
Friction: switch coefficients types or edit the list of application coefficients now send a notify the Friction window to update the list and plot, even if the window is opened already
parent
48e9c14525
commit
4cad251e57
|
|
@ -223,9 +223,41 @@ class FrictionsWindow(PamhyrWindow):
|
|||
# self._propagate_update(key=Modules.FRICTION)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.GEOMETRY not in key:
|
||||
return
|
||||
if Modules.CONFIG in key:
|
||||
self.update_config()
|
||||
|
||||
if Modules.GEOMETRY in key:
|
||||
self.update_plot()
|
||||
|
||||
for _, window in self.sub_win_list:
|
||||
window._propagated_update(key=key)
|
||||
|
||||
def update_config(self):
|
||||
display_manning = getattr(
|
||||
self._config, "display_manning", False
|
||||
)
|
||||
|
||||
self._delegate_stricklers._application_stricklers = (
|
||||
self._config.stricklers.stricklers
|
||||
if self._config is not None else []
|
||||
)
|
||||
self._delegate_stricklers._display_manning = display_manning
|
||||
|
||||
self._table.display_manning = display_manning
|
||||
self._table._table_headers["begin_strickler"] = (
|
||||
self._trad["manning"] if display_manning
|
||||
else self._trad["strickler"]
|
||||
)
|
||||
self._table.headerDataChanged.emit(
|
||||
Qt.Horizontal, 0, self._table.columnCount() - 1
|
||||
)
|
||||
self._table.layoutChanged.emit()
|
||||
|
||||
self.plot_2._display_manning = display_manning
|
||||
self.plot_2.label_y = (
|
||||
self._trad["manning_plot"] if display_manning
|
||||
else self._trad["strickler_plot"]
|
||||
)
|
||||
self.update_plot()
|
||||
|
||||
def _set_current_reach(self):
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ from PyQt5.QtWidgets import (
|
|||
)
|
||||
|
||||
from Model.Stricklers.Stricklers import Stricklers
|
||||
from Modules import Modules
|
||||
|
||||
from View.Stricklers.UndoCommand import PasteCommand
|
||||
from View.Stricklers.Table import TableModel
|
||||
|
|
@ -57,11 +58,7 @@ class StricklersWindow(PamhyrWindow):
|
|||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
trad = StricklersTranslate()
|
||||
display_manning = getattr(config, "display_manning", False)
|
||||
coefficient_name = (
|
||||
"Mannings" if display_manning else self._pamhyr_name
|
||||
)
|
||||
name = trad[coefficient_name] + " - " + study.name
|
||||
name = self.window_name(study, config, trad)
|
||||
|
||||
super(StricklersWindow, self).__init__(
|
||||
title=name,
|
||||
|
|
@ -75,6 +72,14 @@ class StricklersWindow(PamhyrWindow):
|
|||
self.setup_table()
|
||||
self.setup_connections()
|
||||
|
||||
@classmethod
|
||||
def window_name(cls, study, config, trad):
|
||||
display_manning = getattr(config, "display_manning", False)
|
||||
coefficient_name = (
|
||||
"Mannings" if display_manning else cls._pamhyr_name
|
||||
)
|
||||
return trad[coefficient_name] + " - " + study.name
|
||||
|
||||
def setup_labels(self):
|
||||
display_manning = getattr(self._config, "display_manning", False)
|
||||
study_label = (
|
||||
|
|
@ -127,6 +132,31 @@ class StricklersWindow(PamhyrWindow):
|
|||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.CONFIG not in key:
|
||||
return
|
||||
|
||||
display_manning = getattr(
|
||||
self._config, "display_manning", False
|
||||
)
|
||||
application_stricklers = self._config.stricklers
|
||||
|
||||
self._table["app"]._data = application_stricklers
|
||||
self._table["app"].display_manning = display_manning
|
||||
self._table["app"].layoutChanged.emit()
|
||||
|
||||
self._table["study"].hidden_stricklers = (
|
||||
application_stricklers.stricklers
|
||||
)
|
||||
self._table["study"].display_manning = display_manning
|
||||
self._table["study"].layoutChanged.emit()
|
||||
|
||||
self._title = self.window_name(
|
||||
self._study, self._config, self._trad
|
||||
)
|
||||
self._set_title()
|
||||
self.setup_labels()
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView_study")
|
||||
return list(
|
||||
|
|
|
|||
Loading…
Reference in New Issue