mirror of https://gitlab.com/pamhyr/pamhyr2
Limit case: we cannot split reaches that contains less than 3 profiles, and not split on a limit profile (first or last one)
parent
f95c646ef3
commit
3d467c9620
|
|
@ -963,6 +963,12 @@ Last export at: @date."""
|
|||
self._results[solv_type] = results
|
||||
|
||||
def _split_reach(self, reach, profile):
|
||||
profiles = reach.reach.profiles
|
||||
if not profiles or profile not in profiles[1:-1]:
|
||||
raise ValueError(
|
||||
"A reach cannot be split at its first or last profile"
|
||||
)
|
||||
|
||||
node1 = reach.node1
|
||||
node2 = reach.node2
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ from PyQt5.QtGui import (
|
|||
from PyQt5.QtWidgets import (
|
||||
QApplication, QGraphicsScene, QGraphicsView,
|
||||
QGraphicsItem, QGraphicsTextItem, QMenu,
|
||||
QMessageBox,
|
||||
)
|
||||
|
||||
from Model.Network.Node import Node
|
||||
|
|
@ -724,6 +725,16 @@ class GraphWidget(QGraphicsView):
|
|||
|
||||
def split_edge(self, item):
|
||||
edge = item.edge
|
||||
if len(edge.reach.profiles) < 3:
|
||||
QMessageBox.information(
|
||||
self,
|
||||
self._trad["menu_split_edge"],
|
||||
_translate(
|
||||
"Network",
|
||||
"No profile is available to split this reach."
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
dlg = SelectProfileDialog(
|
||||
study=self.parent._study,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,10 @@ class SelectProfileDialog(PamhyrDialog):
|
|||
list(
|
||||
map(
|
||||
lambda p: p.display_name(),
|
||||
self._reach.reach.profiles)))
|
||||
self._reach.reach.profiles[1:-1]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def accept(self):
|
||||
profile = self.get_combobox_text("comboBox")
|
||||
|
|
@ -81,7 +84,7 @@ class SelectProfileDialog(PamhyrDialog):
|
|||
self._profile = next(
|
||||
filter(
|
||||
lambda p: p.display_name() == profile,
|
||||
self._reach.reach.profiles
|
||||
self._reach.reach.profiles[1:-1]
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue