diff --git a/src/View/SolverParameters/RubarFields.py b/src/View/SolverParameters/RubarFields.py index 6f3ffc5b..4950ac36 100644 --- a/src/View/SolverParameters/RubarFields.py +++ b/src/View/SolverParameters/RubarFields.py @@ -42,6 +42,16 @@ OPTION_CHOICES = ( ) +# Choices read by RubarBE 2021 but never used by its computation: the +# upstream level of HAMONT (rubar_init.f90). The export refuses them. +UNSUPPORTED_CHOICES = { + ('rubarbe_condam', '2'): 'La version actuelle de RubarBE ne prend pas ' + 'en compte la cote amont imposée.', + ('rubarbe_regime', '1'): 'La version actuelle de RubarBE ne prend pas ' + 'en compte le tirant d’eau amont imposé.', +} + + @dataclass(frozen=True) class Field: key: str @@ -89,7 +99,9 @@ def fields(): 'Nécessite les fichiers de reprise du calcul précédent.', YES_NO) choice('condam', 1, 'Condition à la limite amont', - 'Le choix doit correspondre aux données de la limite amont.', + 'Le choix doit correspondre aux données de la limite amont. ' + 'La cote imposée n’est pas prise en compte par la version ' + 'actuelle de RubarBE.', {'0': 'Réflexion', '1': 'Débit imposé Q(t)', '2': 'Cote imposée Z(t)', '4': 'Confluence'}) choice('condav', 1, 'Condition à la limite aval', @@ -99,8 +111,8 @@ def fields(): '3': 'Cote imposée Z(t)', '4': 'Confluence / défluence', '5': 'Régime uniforme', '7': 'Régime critique'}) choice('regime', 1, 'Imposer aussi le tirant d’eau amont', - 'Complète le débit imposé ; incompatible avec une limite ' - 'amont de type "Réflexion".', + 'Complète le débit imposé ; non pris en compte par la version ' + 'actuelle de RubarBE.', ON_OFF) choice('iodev', 1, 'Déversement latéral', 'Nécessite les données de déversements latéraux.', diff --git a/src/View/SolverParameters/RubarForm.py b/src/View/SolverParameters/RubarForm.py index 5c594652..47f45e09 100644 --- a/src/View/SolverParameters/RubarForm.py +++ b/src/View/SolverParameters/RubarForm.py @@ -10,7 +10,8 @@ from PyQt5.QtWidgets import ( ) from View.SolverParameters.RubarFields import ( - FIELDS, GROUPS, OPTION_CHOICES, Field, active, canonical, validate, + FIELDS, GROUPS, OPTION_CHOICES, UNSUPPORTED_CHOICES, Field, active, + canonical, validate, ) from View.SolverParameters.UndoCommand import SetCommand @@ -293,6 +294,15 @@ class RubarForm(QWidget): index = editor.findData(forbidden) if index >= 0: editor.model().item(index).setEnabled(not blocked) + # Unsupported choices stay visible, so a stored value is still + # displayed, but cannot be selected anymore + for (key, value), reason in UNSUPPORTED_CHOICES.items(): + editor = self.editors.get(key) + index = editor.findData(value) if editor is not None else -1 + if index >= 0: + item = editor.model().item(index) + item.setEnabled(False) + item.setToolTip(tr(reason)) self._refreshing = False def _update_context(self, values): @@ -312,6 +322,11 @@ class RubarForm(QWidget): values.get('rubarbe_regime') == '1'): warnings.append(tr('Une limite amont réfléchissante ne permet pas ' 'd’imposer aussi le tirant d’eau.')) + for (key, value), reason in UNSUPPORTED_CHOICES.items(): + if values.get(key) == value: + warnings.append(tr(reason) + tr( + ' Le calcul sera refusé : choisissez un autre réglage ' + 'de la limite amont.')) try: from tools import old_pamhyr_date_to_timestamp