mirror of https://gitlab.com/pamhyr/pamhyr2
Resutls: Synchronized table and slider.
parent
5e5cc8d050
commit
ebbe4c4be7
|
|
@ -31,6 +31,7 @@ from PyQt5.QtGui import (
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
Qt, QVariant, QAbstractTableModel,
|
Qt, QVariant, QAbstractTableModel,
|
||||||
QCoreApplication, QModelIndex, pyqtSlot,
|
QCoreApplication, QModelIndex, pyqtSlot,
|
||||||
|
QItemSelectionModel,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
|
|
@ -242,6 +243,7 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.plot_sed_profile.draw()
|
self.plot_sed_profile.draw()
|
||||||
|
|
||||||
def _compute_status_label(self):
|
def _compute_status_label(self):
|
||||||
|
# Timestamp
|
||||||
ts = self._timestamps[self._slider_time.value()]
|
ts = self._timestamps[self._slider_time.value()]
|
||||||
|
|
||||||
t0 = datetime.fromtimestamp(0)
|
t0 = datetime.fromtimestamp(0)
|
||||||
|
|
@ -251,7 +253,27 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
fts.replace("days", _translate("Results", "days"))\
|
fts.replace("days", _translate("Results", "days"))\
|
||||||
.replace("day", _translate("Results", "day"))
|
.replace("day", _translate("Results", "day"))
|
||||||
|
|
||||||
return (f"Timestamp : {fts} ({ts} sec)")
|
# Reach
|
||||||
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
reach = self._study.river.edges()[0]
|
||||||
|
else:
|
||||||
|
reach = self._study.river.edges()[indexes[0].row()]
|
||||||
|
|
||||||
|
# Profile
|
||||||
|
table = self.find(QTableView, f"tableView_profile")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
profile = reach.reach.profile(0)
|
||||||
|
else:
|
||||||
|
profile = reach.reach.profile(indexes[0].row())
|
||||||
|
|
||||||
|
pname = profile.name if profile.name != "" else profile.kp
|
||||||
|
|
||||||
|
return (f"Reach: {reach.name} | " +
|
||||||
|
f"Profile: {pname} | " +
|
||||||
|
f"Timestamp : {fts} ({ts} sec)")
|
||||||
|
|
||||||
def setup_statusbar(self):
|
def setup_statusbar(self):
|
||||||
txt = self._compute_status_label()
|
txt = self._compute_status_label()
|
||||||
|
|
@ -285,6 +307,31 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._slider_profile.valueChanged.connect(self._set_current_profile_slider)
|
self._slider_profile.valueChanged.connect(self._set_current_profile_slider)
|
||||||
self._slider_time.valueChanged.connect(self._set_current_timestamp)
|
self._slider_time.valueChanged.connect(self._set_current_timestamp)
|
||||||
|
|
||||||
|
def update_table_selection_reach(self, ind):
|
||||||
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
|
selectionModel = table.selectionModel()
|
||||||
|
index = table.model().index(ind, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
table.scrollTo(index)
|
||||||
|
|
||||||
|
def update_table_selection_profile(self, ind):
|
||||||
|
table = self.find(QTableView, f"tableView_profile")
|
||||||
|
selectionModel = table.selectionModel()
|
||||||
|
index = table.model().index(ind, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
table.scrollTo(index)
|
||||||
|
|
||||||
def update(self, reach_id = None, profile_id = None, timestamp = None):
|
def update(self, reach_id = None, profile_id = None, timestamp = None):
|
||||||
if reach_id is not None:
|
if reach_id is not None:
|
||||||
|
|
@ -296,6 +343,10 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
if self._study.river.has_sediment():
|
if self._study.river.has_sediment():
|
||||||
self.plot_sed_reach.set_reach(reach_id)
|
self.plot_sed_reach.set_reach(reach_id)
|
||||||
self.plot_sed_profile.set_reach(reach_id)
|
self.plot_sed_profile.set_reach(reach_id)
|
||||||
|
|
||||||
|
self.update_table_selection_reach(reach_id)
|
||||||
|
self.update_table_selection_profile(0)
|
||||||
|
|
||||||
if profile_id is not None:
|
if profile_id is not None:
|
||||||
self.plot_xy.set_profile(profile_id)
|
self.plot_xy.set_profile(profile_id)
|
||||||
self.plot_ac.set_profile(profile_id)
|
self.plot_ac.set_profile(profile_id)
|
||||||
|
|
@ -305,6 +356,8 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
if self._study.river.has_sediment():
|
if self._study.river.has_sediment():
|
||||||
self.plot_sed_reach.set_profile(profile_id)
|
self.plot_sed_reach.set_profile(profile_id)
|
||||||
self.plot_sed_profile.set_profile(profile_id)
|
self.plot_sed_profile.set_profile(profile_id)
|
||||||
|
|
||||||
|
self.update_table_selection_profile(profile_id)
|
||||||
if timestamp is not None:
|
if timestamp is not None:
|
||||||
self.plot_xy.set_timestamp(timestamp)
|
self.plot_xy.set_timestamp(timestamp)
|
||||||
self.plot_ac.set_timestamp(timestamp)
|
self.plot_ac.set_timestamp(timestamp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue