LC: Change graph to reach plot.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-05-17 15:31:32 +02:00
1 parent bcaca20f28
commit 55cd309188
2 files changed
+88 -38

No files matched your search

+42 -8
View File
@@ -36,7 +36,8 @@ from View.LateralContribution.Table import (
TableModel, ComboBoxDelegate
)
from View.Network.GraphWidget import GraphWidget
from View.Plot.MplCanvas import MplCanvas
from View.Geometry.PlotXY import PlotXY
from View.LateralContribution.translate import *
from View.LateralContribution.Edit.Window import EditLateralContributionWindow
@@ -106,14 +107,16 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
table.setAlternatingRowColors(True)
def setup_graph(self):
self.graph_widget = GraphWidget(
self._study.river,
min_size=None, size=(200,200),
only_display=True,
parent=self
self.canvas = MplCanvas(width=5, height=4, dpi=100)
self.canvas.setObjectName("canvas")
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
self.plot_layout.addWidget(self.canvas)
self.plot = PlotXY(
canvas = self.canvas,
data = None,
toolbar = None,
)
self.graph_layout = self.find(QVBoxLayout, "verticalLayout")
self.graph_layout.addWidget(self.graph_widget)
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
@@ -126,6 +129,12 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
self.copy_sc.activated.connect(self.copy)
self.paste_sc.activated.connect(self.paste)
for t in ["liquid", "solid", "suspenssion"]:
table = self.find(QTableView, f"tableView_{t}")
table.selectionModel()\
.selectionChanged\
.connect(self._set_current_reach)
def current_tab(self):
return self.find(QTabWidget, "tabWidget")\
.currentWidget()\
@@ -152,6 +161,31 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
)
)
def _set_current_reach(self):
tab = self.current_tab()
rows = self.index_selected_rows()
data = None
highlight = None
if len(rows) > 0:
edge = self._study\
.river\
.lateral_contribution\
.get(tab, rows[0])\
.edge
if edge:
data = edge.reach
lc = self._lcs.get(tab, rows[0])
highlight = (lc.begin_kp, lc.end_kp)
self.plot = PlotXY(
canvas = self.canvas,
data = data,
toolbar = None,
)
self.plot.draw(highlight=highlight)
def add(self):
tab = self.current_tab()
rows = self.index_selected_rows()