diff --git a/src/Model/Friction/FrictionList.py b/src/Model/Friction/FrictionList.py index cc14da10..e24d0e60 100644 --- a/src/Model/Friction/FrictionList.py +++ b/src/Model/Friction/FrictionList.py @@ -112,7 +112,7 @@ class FrictionList(PamhyrModelList): frictions = list( filter( lambda f: ((rk_min <= f.begin_rk <= rk_max) or - (rk_min <= f.end_rk <= rk_max)), + (rk_min <= f.end_rk <= rk_max)), self._lst)) for ind, friction in enumerate(frictions): diff --git a/src/Model/River.py b/src/Model/River.py index a22f25b0..2671b12b 100644 --- a/src/Model/River.py +++ b/src/Model/River.py @@ -446,6 +446,7 @@ class RiverReach(Edge): return new_reach1, new_reach2 + class River(Graph): _sub_classes = [ StricklersList, diff --git a/src/View/Network/ProfileDialog.py b/src/View/Network/ProfileDialog.py new file mode 100644 index 00000000..eff601a9 --- /dev/null +++ b/src/View/Network/ProfileDialog.py @@ -0,0 +1,91 @@ +# ProfileDialog.py -- Pamhyr +# Copyright (C) 2025 INRAE +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# -*- coding: utf-8 -*- + +import logging +import random + +from tools import logger_exception + +from View.Tools.PamhyrWindow import PamhyrDialog +from View.Network.translate import NetworkTranslate + +from PyQt5.QtGui import ( + QKeySequence, +) + +from PyQt5.QtCore import ( + Qt, QVariant, QAbstractTableModel, + QCoreApplication, QModelIndex, pyqtSlot, +) + +from PyQt5.QtWidgets import ( + QDialogButtonBox, QPushButton, QLineEdit, + QFileDialog, QTableView, QAbstractItemView, + QUndoStack, QShortcut, QAction, QItemDelegate, + QComboBox, QVBoxLayout, QHeaderView, QTabWidget, + QTextEdit, +) + +logger = logging.getLogger() + + +class SelectProfileDialog(PamhyrDialog): + _pamhyr_ui = "SelectProfile" + _pamhyr_name = "Select profile" + + def __init__(self, study=None, config=None, + reach=None, trad=None, parent=None): + self._trad = trad + if self._trad is not None: + name = trad["dialog_select_profile_title"] + + super(SelectProfileDialog, self).__init__( + title=name, + study=study, + config=config, + options=[], + parent=parent + ) + + self._reach = reach + self._profile = None + + self.setup_combobox() + + def setup_combobox(self): + self.combobox_add_items( + "comboBox", + list( + map( + lambda p: p.display_name(), + self._reach.reach.profiles))) + + def accept(self): + profile = self.get_combobox_text("comboBox") + + self._profile = next( + filter( + lambda p: p.display_name() == profile, + self._reach.reach.profiles + ) + ) + + super(SelectProfileDialog, self).accept() + + def reject(self): + self.close() diff --git a/src/View/Network/UndoCommand.py b/src/View/Network/UndoCommand.py index 9229cc17..d3c1a44f 100644 --- a/src/View/Network/UndoCommand.py +++ b/src/View/Network/UndoCommand.py @@ -117,6 +117,7 @@ class DelEdgeCommand(QUndoCommand): def redo(self): self._graph.remove_edge(self._edge) + class SplitEdgeCommand(QUndoCommand): def __init__(self, graph, edge, profile): QUndoCommand.__init__(self) @@ -139,6 +140,7 @@ class SplitEdgeCommand(QUndoCommand): self._new_r1.set_as_not_deleted() self._new_r2.set_as_not_deleted() + class SetCommand(QUndoCommand): def __init__(self, element, column, new_value): QUndoCommand.__init__(self) diff --git a/src/View/Network/translate.py b/src/View/Network/translate.py index a70ab82d..fe82e19e 100644 --- a/src/View/Network/translate.py +++ b/src/View/Network/translate.py @@ -46,9 +46,12 @@ class NetworkTranslate(MainTranslate): "Network", "Delete node reservoir" ) - self._dict["menu_del_edge"] = _translate("Network", "Delete the reach") - self._dict["menu_split_edge"] = _translate("Network", "Split the reach") - self._dict["menu_ena_edge"] = _translate("Network", "Enable the reach") + self._dict["menu_del_edge"] = _translate("Network", + "Delete the reach") + self._dict["menu_split_edge"] = _translate("Network", + "Split the reach") + self._dict["menu_ena_edge"] = _translate("Network", + "Enable the reach") self._dict["menu_dis_edge"] = _translate("Network", "Disable the reach") self._dict["menu_rev_edge"] = _translate( diff --git a/src/View/ui/SelectProfile.ui b/src/View/ui/SelectProfile.ui new file mode 100644 index 00000000..df3fd91f --- /dev/null +++ b/src/View/ui/SelectProfile.ui @@ -0,0 +1,67 @@ + + + Dialog + + + + 0 + 0 + 400 + 76 + + + + Dialog + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +