dirty work on BHS

This commit is contained in:
Theophile Terraz committed 2023-12-11 15:44:31 +01:00
commit f302e18d71
35 files changed
+682 -120

No files matched your search

+36 -29
View File
@@ -84,13 +84,13 @@ class HydraulicStructuresWindow(PamhyrWindow):
trad=self._trad,
data=self._study.river,
parent=self,
mode = "reaches"
mode="reaches"
)
self._delegate_kp = ComboBoxDelegate(
trad=self._trad,
data=self._study.river,
parent=self,
mode = "kp"
mode="kp"
)
table = self.find(QTableView, f"tableView")
@@ -177,7 +177,7 @@ class HydraulicStructuresWindow(PamhyrWindow):
table = self.find(QTableView, "tableView")
r = table.selectionModel().selectedRows()
if len(r)>0:
if len(r) > 0:
return r[0]
else:
return None
@@ -186,7 +186,7 @@ class HydraulicStructuresWindow(PamhyrWindow):
table = self.find(QTableView, "tableView")
r = table.selectionModel().selectedRows()
if len(r)>0:
if len(r) > 0:
return r[0].row()
else:
return None
@@ -233,7 +233,8 @@ class HydraulicStructuresWindow(PamhyrWindow):
rows = self.index_selected_rows()
for row in rows:
data = self._hs_lst.get(row)
print(row)
print(data)
if self.sub_window_exists(
BasicHydraulicStructuresWindow,
data=[self._study, None, data]
@@ -266,37 +267,43 @@ 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
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 profile is not None:
self.plot_kpc.set_profile(profile[0])
self.plot_ac.set_profile(profile[0])
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_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()