Commit e842fef4 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

BC, Geometry: Add safety condition to value computation.

No related merge requests found
Pipeline #59166 passed with stages
in 3 minutes and 27 seconds
Showing with 39 additions and 1 deletion
+39 -1
......@@ -368,6 +368,9 @@ class Reach(SQLSubModel):
def inter_profiles_rk(self):
profiles = sorted(self.profiles, key=lambda p: p.rk)
if len(profiles) == 0:
return []
first = profiles[0]
last = profiles[-1]
......@@ -750,6 +753,9 @@ class Reach(SQLSubModel):
cnt += 1
def get_incline(self):
if len(self.profiles) == 0:
return 0.0
first = self.profile(0)
last = self.profile(len(self) - 1)
......@@ -767,6 +773,9 @@ class Reach(SQLSubModel):
def get_incline_mean(self):
profiles = self.profiles
if len(profiles) == 0:
return 0.0
previous = profiles[0]
incline_acc = 0
......@@ -790,6 +799,9 @@ class Reach(SQLSubModel):
def get_incline_median(self):
profiles = self.profiles
if len(profiles) == 0:
return 0.0
previous = profiles[0]
incline_acc = []
......@@ -814,6 +826,9 @@ class Reach(SQLSubModel):
def get_incline_median_mean(self):
profiles = self.profiles
if len(profiles) == 0:
return 0.0
previous = profiles[0]
incline_acc = []
......
......@@ -347,6 +347,13 @@ class EditBoundaryConditionWindow(PamhyrWindow):
if node is None:
return
reach = self._data.reach(self._study.river)[0]
if len(reach.profiles) == 0:
self.message_box(
text=self._trad["title_need_geometry"],
informative_text=self._trad["msg_need_geometry"]
)
return
profile = reach.profiles[-1]
dlg = GenerateDialog(self.slope_value,
reach,
......@@ -379,6 +386,13 @@ class EditBoundaryConditionWindow(PamhyrWindow):
if node is None:
return
reach = self._data.reach(self._study.river)[0]
if len(reach.profiles) == 0:
self.message_box(
text=self._trad["title_need_geometry"],
informative_text=self._trad["msg_need_geometry"]
)
return
profile = reach.profiles[-1]
z_min = profile.z_min()
z_max = profile.z_max()
......
......@@ -44,3 +44,12 @@ class BCETranslate(BCTranslate):
"z": self._dict["unit_elevation"],
"solid": _translate("BoundaryCondition", "Solid (kg/s)"),
}
self._dict["title_need_geometry"] = _translate(
"Geometry", "No geometry"
)
self._dict["msg_need_geometry"] = _translate(
"Geometry",
"There is not geometry found for this reach, "
"a geometry is needed to this features"
)
......@@ -142,7 +142,7 @@ class WindowToolKit(object):
Returns:
Nothing
"""
msg = QMessageBox()
msg = QMessageBox(parent=self)
msg.setIcon(QMessageBox.Warning)
msg.setText(text)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment