mirror of https://gitlab.com/pamhyr/pamhyr2
work on multiple selection in profil plot
parent
89d5b2d576
commit
dfe12c8bcb
|
|
@ -78,7 +78,7 @@ class Plot(PamhyrPlot):
|
|||
return
|
||||
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
if modifiers not in [Qt.ControlModifier, Qt.NoModifier]:
|
||||
if modifiers not in [Qt.ControlModifier, Qt.NoModifier, Qt.ShiftModifier]:
|
||||
return
|
||||
|
||||
points, hyd = self.highlight
|
||||
|
|
@ -89,6 +89,18 @@ class Plot(PamhyrPlot):
|
|||
rows = self._parent.index_selected_rows()
|
||||
self.highlight = (points+[point], hyd)
|
||||
self._select_in_table(rows+[ind])
|
||||
elif modifiers == Qt.ShiftModifier:
|
||||
rows = self._parent.index_selected_rows()
|
||||
if len(rows)>0:
|
||||
i1 = min(rows[0], rows[-1], ind)
|
||||
i2 = max(rows[0], rows[-1], ind)
|
||||
p = [[self.data.points[i].x,self.data.points[i].y] for i in range(i1, i2)]
|
||||
else:
|
||||
i1 = ind
|
||||
i2 = ind
|
||||
p = [point]
|
||||
self.highlight = (p, hyd)
|
||||
self._select_range_in_table(i1, i2)
|
||||
else:
|
||||
self.highlight = ([point], hyd)
|
||||
self._select_in_table([ind])
|
||||
|
|
@ -123,7 +135,7 @@ class Plot(PamhyrPlot):
|
|||
self.update()
|
||||
return
|
||||
|
||||
def select_points_from_indices(self, indexes):
|
||||
def select_points_from_indices(self, indices):
|
||||
data = self.data
|
||||
_, hyd = self.highlight
|
||||
|
||||
|
|
@ -131,7 +143,7 @@ class Plot(PamhyrPlot):
|
|||
map(
|
||||
lambda e: e[1],
|
||||
filter(
|
||||
lambda e: e[0] in indexes,
|
||||
lambda e: e[0] in indices,
|
||||
enumerate(
|
||||
zip(data.get_station(), data.z())
|
||||
)
|
||||
|
|
@ -163,6 +175,22 @@ class Plot(PamhyrPlot):
|
|||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||
self._table.blockSignals(False)
|
||||
|
||||
def _select_range_in_table(self, ind1, ind2):
|
||||
if self._table is not None:
|
||||
self._table.blockSignals(True)
|
||||
self._table.setFocus()
|
||||
selection = self._table.selectionModel()
|
||||
index = QItemSelection(self._table.model().index(ind1, 0),
|
||||
self._table.model().index(ind2, 0))
|
||||
selection.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
self._table.blockSignals(False)
|
||||
|
||||
def _closer_point(self, event):
|
||||
points_ind = event.ind
|
||||
axes = self.canvas.axes
|
||||
|
|
|
|||
Loading…
Reference in New Issue