mirror of https://gitlab.com/pamhyr/pamhyr2
HS: Refacto update function and fix NA value at table data set.
parent
eea355a784
commit
163a842384
|
|
@ -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)
|
||||
|
||||
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._update_clear_all()
|
||||
|
||||
def _update_clear_all(self):
|
||||
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])
|
||||
else:
|
||||
def _update_clear_profile(self):
|
||||
self.plot_ac.clear()
|
||||
self.plot_kpc.clear_profile()
|
||||
|
|
|
|||
Loading…
Reference in New Issue