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