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
|
self._results[solv_type] = results
|
||||||
|
|
||||||
def _split_reach(self, reach, profile):
|
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
|
node1 = reach.node1
|
||||||
node2 = reach.node2
|
node2 = reach.node2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ from PyQt5.QtGui import (
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication, QGraphicsScene, QGraphicsView,
|
QApplication, QGraphicsScene, QGraphicsView,
|
||||||
QGraphicsItem, QGraphicsTextItem, QMenu,
|
QGraphicsItem, QGraphicsTextItem, QMenu,
|
||||||
|
QMessageBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
from Model.Network.Node import Node
|
from Model.Network.Node import Node
|
||||||
|
|
@ -724,6 +725,16 @@ class GraphWidget(QGraphicsView):
|
||||||
|
|
||||||
def split_edge(self, item):
|
def split_edge(self, item):
|
||||||
edge = item.edge
|
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(
|
dlg = SelectProfileDialog(
|
||||||
study=self.parent._study,
|
study=self.parent._study,
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,10 @@ class SelectProfileDialog(PamhyrDialog):
|
||||||
list(
|
list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.display_name(),
|
lambda p: p.display_name(),
|
||||||
self._reach.reach.profiles)))
|
self._reach.reach.profiles[1:-1]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
profile = self.get_combobox_text("comboBox")
|
profile = self.get_combobox_text("comboBox")
|
||||||
|
|
@ -81,7 +84,7 @@ class SelectProfileDialog(PamhyrDialog):
|
||||||
self._profile = next(
|
self._profile = next(
|
||||||
filter(
|
filter(
|
||||||
lambda p: p.display_name() == profile,
|
lambda p: p.display_name() == profile,
|
||||||
self._reach.reach.profiles
|
self._reach.reach.profiles[1:-1]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue