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

HS: Refacto update function and fix NA value at table data set.

Showing with 36 additions and 24 deletions
+36 -24
......@@ -140,6 +140,7 @@ class TableModel(PamhyrTableModel):
row = index.row()
column = index.column()
na = _translate("Hydraulic structure", "Not associated")
try:
if self._headers[column] == "name":
......@@ -149,12 +150,18 @@ class TableModel(PamhyrTableModel):
)
)
elif self._headers[column] == "reach":
if value == na:
value = None
self._undo.push(
SetReachCommand(
self._lst, row, self._data.edge(value)
)
)
elif self._headers[column] == "kp":
if value == na:
value = None
self._undo.push(
SetKpCommand(
self._lst, row, value
......
......@@ -264,36 +264,41 @@ class HydraulicStructuresWindow(PamhyrWindow):
def update(self):
self._set_checkbox_state()
self._update_clear_plot()
def _update_clear_plot(self):
rows = self.index_selected_rows()
if len(rows) > 0 and len(self._hs_lst) > 0:
reach = self._hs_lst.get(rows[0]).input_reach
else:
reach = None
self.plot_kpc.clear()
self.plot_ac.clear()
if len(rows) == 0 or len(self._hs_lst) == 0:
self._update_clear_all()
return
profile_kp = self._hs_lst.get(rows[0]).input_kp
if profile_kp is None or profile_kp == "Not associated":
profile = None
self.plot_ac.clear()
self.plot_kpc.clear_profile()
else:
profile = reach.reach.get_profiles_from_kp(float(profile_kp))
if reach is not None and reach != "Not associated":
reach = self._hs_lst.get(rows[0]).input_reach
if reach is not None:
self.plot_kpc.set_reach(reach)
self.plot_ac.set_reach(reach)
else:
self.plot_kpc.clear()
self.plot_ac.clear()
return
if profile is not None:
self.plot_kpc.set_profile(profile[0])
self.plot_ac.set_profile(profile[0])
profile_kp = self._hs_lst.get(rows[0]).input_kp
if profile_kp is not None:
profiles = reach.reach\
.get_profiles_from_kp(
float(profile_kp)
)
if profiles is not None:
profile = profiles[0]
self.plot_kpc.set_profile(profile)
self.plot_ac.set_profile(profile)
else:
self._update_clear_profile()
else:
self.plot_ac.clear()
self.plot_kpc.clear_profile()
self._update_clear_all()
def _update_clear_all(self):
self.plot_kpc.clear()
self.plot_ac.clear()
def _update_clear_profile(self):
self.plot_ac.clear()
self.plot_kpc.clear_profile()
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