work on ctrl+click

0.0.9
Theophile Terraz 2024-06-11 10:02:43 +02:00
parent 8cd9ec939b
commit fe57890da4
3 changed files with 29 additions and 20 deletions

View File

@ -81,6 +81,10 @@ class PlotKPZ(PamhyrPlot):
(i.row() for i in self.parent.tableView.selectedIndexes())
)
)
if ind in rows:
rows.remove(ind)
self._select_in_table(rows)
else:
self._select_in_table(rows+[ind])
elif modifiers == Qt.ShiftModifier:
rows = list(
@ -99,7 +103,7 @@ class PlotKPZ(PamhyrPlot):
self.parent.select_row_profile_slider(ind)
self.parent._table.blockSignals(False)
self.update()
#self.update()
return
def _closest_kp(self, event):
@ -122,7 +126,6 @@ class PlotKPZ(PamhyrPlot):
def _select_in_table(self, ind):
if self._table is not None:
self._table.blockSignals(True)
self._table.setFocus()
selection = self._table.selectionModel()
index = QItemSelection()
@ -138,11 +141,9 @@ class PlotKPZ(PamhyrPlot):
if len(ind) > 0:
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),
@ -154,7 +155,6 @@ class PlotKPZ(PamhyrPlot):
QItemSelectionModel.Select
)
self._table.scrollTo(self._table.model().index(ind2, 0))
self._table.blockSignals(False)
@timer
def draw(self):

View File

@ -69,7 +69,6 @@ class PlotXY(PamhyrPlot):
return
ind, point = self._closest_section(event)
print(ind)
if self._table is not None:
self._table.blockSignals(True)
if modifiers == Qt.ControlModifier:
@ -78,6 +77,10 @@ class PlotXY(PamhyrPlot):
(i.row() for i in self.parent.tableView.selectedIndexes())
)
)
if ind in rows:
rows.remove(ind)
self._select_in_table(rows)
else:
self._select_in_table(rows+[ind])
elif modifiers == Qt.ShiftModifier:
rows = list(
@ -126,7 +129,6 @@ class PlotXY(PamhyrPlot):
def _select_in_table(self, ind):
if self._table is not None:
self._table.blockSignals(True)
self._table.setFocus()
selection = self._table.selectionModel()
index = QItemSelection()
@ -142,11 +144,9 @@ class PlotXY(PamhyrPlot):
if len(ind) > 0:
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),
@ -158,7 +158,6 @@ class PlotXY(PamhyrPlot):
QItemSelectionModel.Select
)
self._table.scrollTo(self._table.model().index(ind2, 0))
self._table.blockSignals(False)
@timer
def draw(self):

View File

@ -70,6 +70,7 @@ class Plot(PamhyrPlot):
None # Hydrolic values (z, wet_area,
# wet_preimeter, water_width)
)
self.events = []
def onpick(self, event):
if event.mouseevent.inaxes != self.canvas.axes:
@ -87,6 +88,12 @@ class Plot(PamhyrPlot):
if modifiers == Qt.ControlModifier:
rows = self._parent.index_selected_rows()
if ind in rows:
rows.remove(ind)
del(points[ind])
self.highlight = (points, hyd)
self._select_in_table(rows)
else:
self.highlight = (points+[point], hyd)
self._select_in_table(rows+[ind])
elif modifiers == Qt.ShiftModifier:
@ -114,10 +121,6 @@ class Plot(PamhyrPlot):
if event.button.value == 1:
return
#modifiers = QApplication.keyboardModifiers()
#if modifiers not in [Qt.ShiftModifier]:
#return
points, _ = self.highlight
z = self._get_z_from_click(event)
@ -240,6 +243,13 @@ class Plot(PamhyrPlot):
if modifiers == Qt.ControlModifier:
rows = self._parent.index_selected_rows()
if all(i in rows for i in inds):
for ind in sorted(inds, reverse=True):
rows.remove(ind)
del(points[ind])
self.highlight = (points, hyd)
self._select_in_table(rows)
else:
self.highlight = (points+points2, hyd)
self._select_in_table(rows+inds)
else: