mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-29 19:10:42 +01:00
Mage: warn with a non-blocking checker about solid lateral contributions, and rerun lateral contribution checkers when they are modified
This commit is contained in:
1 parent
c3afc4dd58
commit
70a26d0036
4 files changed
+62
No files matched your search
@@ -254,3 +254,46 @@ for each reach"
|
||||
return False
|
||||
|
||||
return ok
|
||||
|
||||
|
||||
class MageLateralSolidChecker(AbstractModelChecker):
|
||||
"""Mage has no solid lateral contribution (notice: only upstream
|
||||
solid discharges, QSO): the solid ones are not exported (LAT holds
|
||||
liquid discharges only). Non blocking warning"""
|
||||
|
||||
def __init__(self, version="mage8"):
|
||||
super(MageLateralSolidChecker, self).__init__()
|
||||
|
||||
self._name = _translate(
|
||||
"Checker", "Mage solid lateral contributions checker")
|
||||
self._description = _translate(
|
||||
"Checker",
|
||||
"Check if the study has solid lateral contributions, which "
|
||||
"Mage does not take into account"
|
||||
)
|
||||
self._solver = version
|
||||
self._modules = Modules.LATERAL_CONTRIBUTION
|
||||
|
||||
def run(self, study):
|
||||
if not self.basic_check(study):
|
||||
return False
|
||||
|
||||
edges = study.river.enable_edges()
|
||||
names = [
|
||||
lc.name
|
||||
for lc in study.river.lateral_contribution.get_tab("solid")
|
||||
if not lc.is_deleted() and lc.reach in edges and len(lc) > 0
|
||||
]
|
||||
|
||||
if len(names) == 0:
|
||||
self._status = STATUS.OK
|
||||
self._summary = "ok"
|
||||
return True
|
||||
|
||||
self._status = STATUS.WARNING
|
||||
self._summary = _translate(
|
||||
"Checker",
|
||||
"Solid lateral contributions not taken into account by Mage: "
|
||||
"{names}"
|
||||
).format(names=", ".join(names))
|
||||
return False
|
||||
@@ -28,6 +28,7 @@ from tools import timer, trace, logger_exception
|
||||
from Solver.CommandLine import CommandLineSolver
|
||||
from Checker.Mage import (
|
||||
MageNetworkGraphChecker, MageGeometryGuideLineChecker,
|
||||
MageLateralSolidChecker,
|
||||
)
|
||||
|
||||
from Model.Results.Results import Results
|
||||
@@ -106,6 +107,7 @@ class Mage(CommandLineSolver):
|
||||
MageNetworkGraphChecker(connectivity=True, version=cls._type),
|
||||
MageNetworkGraphChecker(connectivity=False, version=cls._type),
|
||||
MageGeometryGuideLineChecker(version=cls._type),
|
||||
MageLateralSolidChecker(version=cls._type),
|
||||
]
|
||||
|
||||
return lst
|
||||
|
||||
@@ -157,6 +157,8 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
self.widget_update()
|
||||
|
||||
def setup_connections(self):
|
||||
self._undo_stack.indexChanged.connect(self._propagate_lateral_update)
|
||||
|
||||
if self._study.is_editable():
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
@@ -172,6 +174,12 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
else:
|
||||
self._d50sigma.setEnabled(False)
|
||||
|
||||
def _propagate_lateral_update(self, index=None):
|
||||
# Every change of the lateral contributions goes through the undo
|
||||
# stack (push, undo, redo): the main window then reruns their
|
||||
# checkers
|
||||
self._propagate_update(key=Modules.LATERAL_CONTRIBUTION)
|
||||
|
||||
def d50_changed(self, value):
|
||||
self._undo_stack.push(SetMetaDataCommand(self._data, "d50", value))
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from Modules import Modules
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
@@ -159,6 +160,8 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
def setup_connections(self):
|
||||
self._undo_stack.indexChanged.connect(self._propagate_lateral_update)
|
||||
|
||||
if self._study.is_editable():
|
||||
self.find(QAction, "action_import").triggered.connect(
|
||||
self.import_from_file)
|
||||
@@ -178,6 +181,12 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
self._table[t].dataChanged\
|
||||
.connect(self._set_current_reach)
|
||||
|
||||
def _propagate_lateral_update(self, index=None):
|
||||
# Every change of the lateral contributions goes through the undo
|
||||
# stack (push, undo, redo): the main window then reruns their
|
||||
# checkers
|
||||
self._propagate_update(key=Modules.LATERAL_CONTRIBUTION)
|
||||
|
||||
def current_tab(self):
|
||||
return self.find(QTabWidget, "tabWidget")\
|
||||
.currentWidget()\
|
||||
|
||||
Reference in new issue
Block a user