mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
add hydraulic structures plots
This commit is contained in:
1 parent
d73e901a96
commit
7b7ba2eb37
4 files changed
+389
-7
No files matched your search
@@ -35,6 +35,12 @@ from PyQt5.QtWidgets import (
|
||||
QHeaderView, QDoubleSpinBox, QVBoxLayout, QCheckBox
|
||||
)
|
||||
|
||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||
|
||||
from View.HydraulicStructures.PlotAC import PlotAC
|
||||
from View.HydraulicStructures.PlotKPC import PlotKPC
|
||||
|
||||
from View.HydraulicStructures.Table import (
|
||||
TableModel, ComboBoxDelegate
|
||||
)
|
||||
@@ -112,21 +118,71 @@ class HydraulicStructuresWindow(PamhyrWindow):
|
||||
|
||||
def setup_checkbox(self):
|
||||
self._checkbox = self.find(QCheckBox, f"checkBox")
|
||||
self._set_checkbox_state
|
||||
self._set_checkbox_state()
|
||||
|
||||
def setup_plots(self):
|
||||
return
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
self.toolbar = PamhyrPlotToolbar(
|
||||
self.canvas, self
|
||||
)
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self.plot_layout.addWidget(self.toolbar)
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot_kpc = PlotKPC(
|
||||
canvas=self.canvas,
|
||||
river=self._study.river,
|
||||
reach=None,
|
||||
profile=None,
|
||||
toolbar=self.toolbar
|
||||
)
|
||||
self.plot_kpc.draw()
|
||||
|
||||
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas_2.setObjectName("canvas_2")
|
||||
self.toolbar_2 = PamhyrPlotToolbar(
|
||||
self.canvas_2, self
|
||||
)
|
||||
self.plot_layout_2 = self.find(QVBoxLayout, "verticalLayout_2")
|
||||
self.plot_layout_2.addWidget(self.toolbar_2)
|
||||
self.plot_layout_2.addWidget(self.canvas_2)
|
||||
|
||||
self.plot_ac = PlotAC(
|
||||
canvas=self.canvas_2,
|
||||
river=self._study.river,
|
||||
reach=None,
|
||||
profile=None,
|
||||
toolbar=self.toolbar_2
|
||||
)
|
||||
self.plot_ac.draw()
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||
#self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||
self._checkbox.stateChanged.connect(self._set_structure_state)
|
||||
|
||||
table = self.find(QTableView, "tableView")
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(self._set_checkbox_state)
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(self.update)
|
||||
#self._delegate_kp.currentItemChanged.connect(lambda:x, print("toto"))
|
||||
#self._delegate_reach.currentItemChanged.connect(lambda:x, print("titi"))
|
||||
self._table.dataChanged.connect(self.update)
|
||||
self._table.layoutChanged.connect(self.update)
|
||||
|
||||
def index_selected(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
r = table.selectionModel()\
|
||||
.selectedRows()
|
||||
if len(r)>0:
|
||||
return r[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def index_selected_row(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
@@ -204,5 +260,42 @@ class HydraulicStructuresWindow(PamhyrWindow):
|
||||
|
||||
def _set_structure_state(self):
|
||||
row = self.index_selected_row()
|
||||
#self._checkbox.setChecked(self._hs_lst.get(row).enabled)
|
||||
self._hs_lst.get(row).enabled = self._checkbox.isChecked()
|
||||
if row is None:
|
||||
self._checkbox.setEnabled(False)
|
||||
else:
|
||||
self._hs_lst.get(row).enabled = self._checkbox.isChecked()
|
||||
|
||||
def update(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()
|
||||
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":
|
||||
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])
|
||||
else:
|
||||
self.plot_ac.clear()
|
||||
self.plot_kpc.clear_profile()
|
||||
Reference in new issue
Block a user