mirror of https://gitlab.com/pamhyr/pamhyr2
pep8
parent
59fc80a10b
commit
7d4091eb24
|
|
@ -21,7 +21,7 @@ import logging
|
||||||
from tools import timer
|
from tools import timer
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtCore import(
|
from PyQt5.QtCore import (
|
||||||
Qt, QItemSelectionModel,
|
Qt, QItemSelectionModel,
|
||||||
QItemSelection, QItemSelectionRange,
|
QItemSelection, QItemSelectionRange,
|
||||||
)
|
)
|
||||||
|
|
@ -57,8 +57,8 @@ class PlotKPZ(PamhyrPlot):
|
||||||
self.before_plot_selected = None
|
self.before_plot_selected = None
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
self.after_plot_selected = None
|
self.after_plot_selected = None
|
||||||
self.parent=parent
|
self.parent = parent
|
||||||
self._table=table
|
self._table = table
|
||||||
self._colors = []
|
self._colors = []
|
||||||
|
|
||||||
def onpick(self, event):
|
def onpick(self, event):
|
||||||
|
|
@ -68,47 +68,49 @@ class PlotKPZ(PamhyrPlot):
|
||||||
return
|
return
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
if modifiers not in [Qt.ControlModifier, Qt.NoModifier, Qt.ShiftModifier]:
|
if modifiers not in [Qt.ControlModifier,
|
||||||
|
Qt.NoModifier,
|
||||||
|
Qt.ShiftModifier]:
|
||||||
return
|
return
|
||||||
|
|
||||||
ind, point = self._closest_kp(event)
|
ind, point = self._closest_kp(event)
|
||||||
if self.parent._table is not None:
|
if self.parent._table is None:
|
||||||
self.parent._table.blockSignals(True)
|
return
|
||||||
if modifiers == Qt.ControlModifier:
|
self.parent._table.blockSignals(True)
|
||||||
rows = list(
|
if modifiers == Qt.ControlModifier:
|
||||||
set(
|
rows = list(
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
set(
|
||||||
)
|
(i.row() for i in self.parent.tableView.selectedIndexes())
|
||||||
)
|
)
|
||||||
if ind in rows:
|
)
|
||||||
rows.remove(ind)
|
if ind in rows:
|
||||||
self._select_in_table(rows)
|
rows.remove(ind)
|
||||||
else:
|
self._select_in_table(rows)
|
||||||
self._select_in_table(rows+[ind])
|
|
||||||
elif modifiers == Qt.ShiftModifier:
|
|
||||||
rows = list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if len(rows)>0:
|
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
|
||||||
i2 = max(rows[0], rows[-1], ind)
|
|
||||||
else:
|
|
||||||
i1 = ind
|
|
||||||
i2 = ind
|
|
||||||
self._select_range_in_table(i1, i2)
|
|
||||||
else:
|
else:
|
||||||
self.parent.select_row_profile_slider(ind)
|
self._select_in_table(rows+[ind])
|
||||||
self.parent._table.blockSignals(False)
|
elif modifiers == Qt.ShiftModifier:
|
||||||
|
rows = list(
|
||||||
|
set(
|
||||||
|
(i.row() for i in self.parent.tableView.selectedIndexes())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if len(rows) > 0:
|
||||||
|
i1 = min(rows[0], rows[-1], ind)
|
||||||
|
i2 = max(rows[0], rows[-1], ind)
|
||||||
|
else:
|
||||||
|
i1 = ind
|
||||||
|
i2 = ind
|
||||||
|
self._select_range_in_table(i1, i2)
|
||||||
|
else:
|
||||||
|
self.parent.select_row_profile_slider(ind)
|
||||||
|
self.parent._table.blockSignals(False)
|
||||||
|
|
||||||
#self.update()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _closest_kp(self, event):
|
def _closest_kp(self, event):
|
||||||
|
|
||||||
s = event.artist.get_segments()
|
s = event.artist.get_segments()
|
||||||
x = [i[0,0] for i in s]
|
x = [i[0, 0] for i in s]
|
||||||
mx = event.mouseevent.xdata
|
mx = event.mouseevent.xdata
|
||||||
points = enumerate(x)
|
points = enumerate(x)
|
||||||
|
|
||||||
|
|
@ -124,22 +126,28 @@ class PlotKPZ(PamhyrPlot):
|
||||||
return closest
|
return closest
|
||||||
|
|
||||||
def _select_in_table(self, ind):
|
def _select_in_table(self, ind):
|
||||||
if self._table is not None:
|
if self._table is None:
|
||||||
self._table.setFocus()
|
return
|
||||||
selection = self._table.selectionModel()
|
|
||||||
index = QItemSelection()
|
|
||||||
if len(ind) > 0:
|
|
||||||
for i in ind:
|
|
||||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
|
||||||
selection.select(
|
|
||||||
index,
|
|
||||||
QItemSelectionModel.Rows |
|
|
||||||
QItemSelectionModel.ClearAndSelect |
|
|
||||||
QItemSelectionModel.Select
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(ind) > 0:
|
self._table.setFocus()
|
||||||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
selection = self._table.selectionModel()
|
||||||
|
index = QItemSelection()
|
||||||
|
|
||||||
|
if len(ind) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
for i in ind:
|
||||||
|
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
||||||
|
|
||||||
|
selection.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(ind) > 0:
|
||||||
|
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||||
|
|
||||||
def _select_range_in_table(self, ind1, ind2):
|
def _select_range_in_table(self, ind1, ind2):
|
||||||
if self._table is not None:
|
if self._table is not None:
|
||||||
|
|
@ -195,7 +203,7 @@ class PlotKPZ(PamhyrPlot):
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
x=kp, ymin=z_min, ymax=z_max,
|
x=kp, ymin=z_min, ymax=z_max,
|
||||||
color=self._colors,
|
color=self._colors,
|
||||||
linestyle = self._style,
|
linestyle=self._style,
|
||||||
lw=1.,
|
lw=1.,
|
||||||
picker=10,
|
picker=10,
|
||||||
)
|
)
|
||||||
|
|
@ -208,7 +216,7 @@ class PlotKPZ(PamhyrPlot):
|
||||||
))
|
))
|
||||||
colors = [self.color_plot for row in range(len(self._data))]
|
colors = [self.color_plot for row in range(len(self._data))]
|
||||||
style = ["-" for row in range(len(self._data))]
|
style = ["-" for row in range(len(self._data))]
|
||||||
if len(rows) >0:
|
if len(rows) > 0:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
colors[row] = self.color_plot_current
|
colors[row] = self.color_plot_current
|
||||||
if rows[0] > 0:
|
if rows[0] > 0:
|
||||||
|
|
@ -334,19 +342,19 @@ class PlotKPZ(PamhyrPlot):
|
||||||
|
|
||||||
self.line_kp_zmin.set_data(kp, z_min)
|
self.line_kp_zmin.set_data(kp, z_min)
|
||||||
|
|
||||||
# TODO comprendre à quoi sert ce bout de code
|
# TODO comprendre à quoi sert ce bout de code
|
||||||
# ========>
|
# ========>
|
||||||
#self.line_kp_zmin_zmax.remove()
|
# self.line_kp_zmin_zmax.remove()
|
||||||
#self._colors, self._style = self.color_hightlight()
|
# self._colors, self._style = self.color_hightlight()
|
||||||
#self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
# self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
#x=kp,
|
# x=kp,
|
||||||
#ymin=z_min,
|
# ymin=z_min,
|
||||||
#ymax=z_max,
|
# ymax=z_max,
|
||||||
#color=self._colors,
|
# color=self._colors,
|
||||||
#linestyle = self._style,
|
# linestyle = self._style,
|
||||||
#lw=1.
|
# lw=1.
|
||||||
#)
|
# )
|
||||||
# <========
|
# <========
|
||||||
|
|
||||||
z_complete = self.data.get_guidelines_z()
|
z_complete = self.data.get_guidelines_z()
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,9 @@ class PlotXY(PamhyrPlot):
|
||||||
self.before_plot_selected = None
|
self.before_plot_selected = None
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
self.after_plot_selected = None
|
self.after_plot_selected = None
|
||||||
self.parent=parent
|
self.parent = parent
|
||||||
self.line_xy_collection = None
|
self.line_xy_collection = None
|
||||||
self._table=table
|
self._table = table
|
||||||
self._colors = []
|
self._colors = []
|
||||||
self._style = []
|
self._style = []
|
||||||
|
|
||||||
|
|
@ -64,41 +64,43 @@ class PlotXY(PamhyrPlot):
|
||||||
return
|
return
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
if modifiers not in [Qt.ControlModifier, Qt.NoModifier, Qt.ShiftModifier]:
|
if modifiers not in [Qt.ControlModifier,
|
||||||
|
Qt.NoModifier,
|
||||||
|
Qt.ShiftModifier]:
|
||||||
return
|
return
|
||||||
|
|
||||||
ind, point = self._closest_section(event)
|
ind, point = self._closest_section(event)
|
||||||
if self._table is not None:
|
if self._table is None:
|
||||||
self._table.blockSignals(True)
|
return
|
||||||
if modifiers == Qt.ControlModifier:
|
self._table.blockSignals(True)
|
||||||
rows = list(
|
if modifiers == Qt.ControlModifier:
|
||||||
set(
|
rows = list(
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
set(
|
||||||
)
|
(i.row() for i in self.parent.tableView.selectedIndexes())
|
||||||
)
|
)
|
||||||
if ind in rows:
|
)
|
||||||
rows.remove(ind)
|
if ind in rows:
|
||||||
self._select_in_table(rows)
|
rows.remove(ind)
|
||||||
else:
|
self._select_in_table(rows)
|
||||||
self._select_in_table(rows+[ind])
|
|
||||||
elif modifiers == Qt.ShiftModifier:
|
|
||||||
rows = list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if len(rows)>0:
|
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
|
||||||
i2 = max(rows[0], rows[-1], ind)
|
|
||||||
else:
|
|
||||||
i1 = ind
|
|
||||||
i2 = ind
|
|
||||||
self._select_range_in_table(i1, i2)
|
|
||||||
else:
|
else:
|
||||||
self.parent.select_row_profile_slider(ind)
|
self._select_in_table(rows + [ind])
|
||||||
self._table.blockSignals(False)
|
elif modifiers == Qt.ShiftModifier:
|
||||||
|
rows = list(
|
||||||
|
set(
|
||||||
|
(i.row() for i in self.parent.tableView.selectedIndexes())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if len(rows) > 0:
|
||||||
|
i1 = min(rows[0], rows[-1], ind)
|
||||||
|
i2 = max(rows[0], rows[-1], ind)
|
||||||
|
else:
|
||||||
|
i1 = ind
|
||||||
|
i2 = ind
|
||||||
|
self._select_range_in_table(i1, i2)
|
||||||
|
else:
|
||||||
|
self.parent.select_row_profile_slider(ind)
|
||||||
|
self._table.blockSignals(False)
|
||||||
|
|
||||||
#self.update()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _closest_section(self, event):
|
def _closest_section(self, event):
|
||||||
|
|
@ -113,7 +115,7 @@ class PlotXY(PamhyrPlot):
|
||||||
|
|
||||||
points = []
|
points = []
|
||||||
for i in ind:
|
for i in ind:
|
||||||
points = points + [[i, j] for j in segments[i]]
|
points = points + [[i, j] for j in segments[i]]
|
||||||
|
|
||||||
def dist_mouse(point):
|
def dist_mouse(point):
|
||||||
x, y = point[1]
|
x, y = point[1]
|
||||||
|
|
@ -127,22 +129,24 @@ class PlotXY(PamhyrPlot):
|
||||||
return closest
|
return closest
|
||||||
|
|
||||||
def _select_in_table(self, ind):
|
def _select_in_table(self, ind):
|
||||||
if self._table is not None:
|
if self._table is None:
|
||||||
self._table.setFocus()
|
return
|
||||||
selection = self._table.selectionModel()
|
self._table.setFocus()
|
||||||
index = QItemSelection()
|
selection = self._table.selectionModel()
|
||||||
if len(ind) > 0:
|
index = QItemSelection()
|
||||||
for i in ind:
|
if len(ind) == 0:
|
||||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
return
|
||||||
selection.select(
|
for i in ind:
|
||||||
index,
|
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
||||||
QItemSelectionModel.Rows |
|
selection.select(
|
||||||
QItemSelectionModel.ClearAndSelect |
|
index,
|
||||||
QItemSelectionModel.Select
|
QItemSelectionModel.Rows |
|
||||||
)
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
|
||||||
if len(ind) > 0:
|
if len(ind) > 0:
|
||||||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||||
|
|
||||||
def _select_range_in_table(self, ind1, ind2):
|
def _select_range_in_table(self, ind1, ind2):
|
||||||
if self._table is not None:
|
if self._table is not None:
|
||||||
|
|
@ -184,10 +188,12 @@ class PlotXY(PamhyrPlot):
|
||||||
self.line_xy.append(np.column_stack(xy))
|
self.line_xy.append(np.column_stack(xy))
|
||||||
|
|
||||||
self._colors, self._style = self.color_hightlight()
|
self._colors, self._style = self.color_hightlight()
|
||||||
self.line_xy_collection = collections.LineCollection(self.line_xy,
|
self.line_xy_collection = collections.LineCollection(
|
||||||
colors = self._colors,
|
self.line_xy,
|
||||||
linestyle = self._style,
|
colors=self._colors,
|
||||||
picker=10)
|
linestyle=self._style,
|
||||||
|
picker=10
|
||||||
|
)
|
||||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
self.canvas.axes.add_collection(self.line_xy_collection)
|
||||||
|
|
||||||
def color_hightlight(self):
|
def color_hightlight(self):
|
||||||
|
|
@ -198,7 +204,7 @@ class PlotXY(PamhyrPlot):
|
||||||
))
|
))
|
||||||
colors = [self.color_plot for row in range(len(self._data))]
|
colors = [self.color_plot for row in range(len(self._data))]
|
||||||
style = ["-" for row in range(len(self._data))]
|
style = ["-" for row in range(len(self._data))]
|
||||||
if len(rows) >0:
|
if len(rows) > 0:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
colors[row] = self.color_plot_current
|
colors[row] = self.color_plot_current
|
||||||
if rows[0] > 0:
|
if rows[0] > 0:
|
||||||
|
|
@ -274,24 +280,24 @@ class PlotXY(PamhyrPlot):
|
||||||
x_complete = list(self.data.get_guidelines_x())
|
x_complete = list(self.data.get_guidelines_x())
|
||||||
y_complete = list(self.data.get_guidelines_y())
|
y_complete = list(self.data.get_guidelines_y())
|
||||||
|
|
||||||
# TODO comprendre à quoi sert ce bout de code
|
# TODO comprendre à quoi sert ce bout de code
|
||||||
# ========>
|
# ========>
|
||||||
#for i in range(self.data.number_profiles):
|
# for i in range(self.data.number_profiles):
|
||||||
#if i < len(self.line_xy):
|
# if i < len(self.line_xy):
|
||||||
#self.line_xy[i][0].set_data(
|
# self.line_xy[i][0].set_data(
|
||||||
#self.data.profile(i).x(),
|
# self.data.profile(i).x(),
|
||||||
#self.data.profile(i).y()
|
# self.data.profile(i).y()
|
||||||
#)
|
# )
|
||||||
#else:
|
# else:
|
||||||
#self.line_xy.append(
|
# self.line_xy.append(
|
||||||
#self.canvas.axes.plot(
|
# self.canvas.axes.plot(
|
||||||
#self.data.profile(i).x(),
|
# self.data.profile(i).x(),
|
||||||
#self.data.profile(i).y(),
|
# self.data.profile(i).y(),
|
||||||
#color='r',
|
# color='r',
|
||||||
#**self.plot_default_kargs
|
# **self.plot_default_kargs
|
||||||
#)
|
# )
|
||||||
#)
|
# )
|
||||||
# <========
|
# <========
|
||||||
|
|
||||||
for i in range(len(x_complete)):
|
for i in range(len(x_complete)):
|
||||||
if i < len(self.line_gl):
|
if i < len(self.line_gl):
|
||||||
|
|
|
||||||
|
|
@ -72,17 +72,20 @@ class Plot(PamhyrPlot):
|
||||||
# wet_preimeter, water_width)
|
# wet_preimeter, water_width)
|
||||||
)
|
)
|
||||||
self._onpickevent = None
|
self._onpickevent = None
|
||||||
self._rect_select = RectangleSelector(ax=self.canvas.axes,
|
self._rect_select = RectangleSelector(
|
||||||
onselect=self.rect_select_callback,
|
ax=self.canvas.axes,
|
||||||
useblit=True,
|
onselect=self.rect_select_callback,
|
||||||
button=[1], # don't use middle nor right button
|
useblit=True,
|
||||||
minspanx=2.0,
|
button=[1], # don't use middle nor right button
|
||||||
minspany=2.0,
|
minspanx=2.0,
|
||||||
spancoords='pixels',
|
minspany=2.0,
|
||||||
interactive=False)
|
spancoords='pixels',
|
||||||
|
interactive=False
|
||||||
|
)
|
||||||
|
|
||||||
def onrelease(self, event):
|
def onrelease(self, event):
|
||||||
# we need to do that to prevent conflicst between onpick and rect_select_callback
|
# we need to do that to prevent conflicst
|
||||||
|
# between onpick and rect_select_callback
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
points, hyd = self.highlight
|
points, hyd = self.highlight
|
||||||
if self._onpickevent is not None:
|
if self._onpickevent is not None:
|
||||||
|
|
@ -91,7 +94,7 @@ class Plot(PamhyrPlot):
|
||||||
rows = self._parent.index_selected_rows()
|
rows = self._parent.index_selected_rows()
|
||||||
if ind in rows:
|
if ind in rows:
|
||||||
rows.remove(ind)
|
rows.remove(ind)
|
||||||
del(points[ind])
|
del (points[ind])
|
||||||
self.highlight = (points, hyd)
|
self.highlight = (points, hyd)
|
||||||
self._select_in_table(rows)
|
self._select_in_table(rows)
|
||||||
else:
|
else:
|
||||||
|
|
@ -99,10 +102,13 @@ class Plot(PamhyrPlot):
|
||||||
self._select_in_table(rows+[ind])
|
self._select_in_table(rows+[ind])
|
||||||
elif modifiers == Qt.ShiftModifier:
|
elif modifiers == Qt.ShiftModifier:
|
||||||
rows = self._parent.index_selected_rows()
|
rows = self._parent.index_selected_rows()
|
||||||
if len(rows)>0:
|
if len(rows) > 0:
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
i1 = min(rows[0], rows[-1], ind)
|
||||||
i2 = max(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)]
|
p = [
|
||||||
|
[self.data.points[i].x, self.data.points[i].y]
|
||||||
|
for i in range(i1, i2)
|
||||||
|
]
|
||||||
else:
|
else:
|
||||||
i1 = ind
|
i1 = ind
|
||||||
i2 = ind
|
i2 = ind
|
||||||
|
|
@ -122,7 +128,9 @@ class Plot(PamhyrPlot):
|
||||||
return
|
return
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
if modifiers not in [Qt.ControlModifier, Qt.NoModifier, Qt.ShiftModifier]:
|
if modifiers not in [Qt.ControlModifier,
|
||||||
|
Qt.NoModifier,
|
||||||
|
Qt.ShiftModifier]:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._onpickevent = event
|
self._onpickevent = event
|
||||||
|
|
@ -178,7 +186,9 @@ class Plot(PamhyrPlot):
|
||||||
index = QItemSelection()
|
index = QItemSelection()
|
||||||
if len(ind) > 0:
|
if len(ind) > 0:
|
||||||
for i in ind:
|
for i in ind:
|
||||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
index.append(QItemSelectionRange(
|
||||||
|
self._table.model().index(i, 0))
|
||||||
|
)
|
||||||
selection.select(
|
selection.select(
|
||||||
index,
|
index,
|
||||||
QItemSelectionModel.Rows |
|
QItemSelectionModel.Rows |
|
||||||
|
|
@ -244,11 +254,10 @@ class Plot(PamhyrPlot):
|
||||||
x1, y1 = eclick.xdata, eclick.ydata
|
x1, y1 = eclick.xdata, eclick.ydata
|
||||||
x2, y2 = erelease.xdata, erelease.ydata
|
x2, y2 = erelease.xdata, erelease.ydata
|
||||||
|
|
||||||
if(max(abs(x1-x2), abs(y1-y2))<0.001):
|
if (max(abs(x1-x2), abs(y1-y2)) < 0.001):
|
||||||
return
|
return
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
|
|
||||||
|
|
||||||
x1, y1 = eclick.xdata, eclick.ydata
|
x1, y1 = eclick.xdata, eclick.ydata
|
||||||
x2, y2 = erelease.xdata, erelease.ydata
|
x2, y2 = erelease.xdata, erelease.ydata
|
||||||
|
|
||||||
|
|
@ -259,7 +268,7 @@ class Plot(PamhyrPlot):
|
||||||
if all(i in rows for i in inds):
|
if all(i in rows for i in inds):
|
||||||
for ind in sorted(inds, reverse=True):
|
for ind in sorted(inds, reverse=True):
|
||||||
rows.remove(ind)
|
rows.remove(ind)
|
||||||
del(points[ind])
|
del (points[ind])
|
||||||
self.highlight = (points, hyd)
|
self.highlight = (points, hyd)
|
||||||
self._select_in_table(rows)
|
self._select_in_table(rows)
|
||||||
else:
|
else:
|
||||||
|
|
@ -276,12 +285,12 @@ class Plot(PamhyrPlot):
|
||||||
listp = []
|
listp = []
|
||||||
station = self.data._get_station(self.data.points)
|
station = self.data._get_station(self.data.points)
|
||||||
for i, p in enumerate(self.data.points):
|
for i, p in enumerate(self.data.points):
|
||||||
if (min(x1,x2)<station[i]<max(x1,x2) and min(y1,y2)<p.z<max(y1,y2)):
|
if (min(x1, x2) < station[i] < max(x1, x2)
|
||||||
|
and min(y1, y2) < p.z < max(y1, y2)):
|
||||||
listi.append(i)
|
listi.append(i)
|
||||||
listp.append((station[i], p.z))
|
listp.append((station[i], p.z))
|
||||||
return listi, listp
|
return listi, listp
|
||||||
|
|
||||||
|
|
||||||
def _compute_hydraulics(self, z):
|
def _compute_hydraulics(self, z):
|
||||||
profile = self.data
|
profile = self.data
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,9 @@ class PlotKPC(PamhyrPlot):
|
||||||
return
|
return
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
if modifiers not in [Qt.ControlModifier, Qt.NoModifier, Qt.ShiftModifier]:
|
if modifiers not in [Qt.ControlModifier,
|
||||||
|
Qt.NoModifier,
|
||||||
|
Qt.ShiftModifier]:
|
||||||
return
|
return
|
||||||
|
|
||||||
closest = self._closest_profile(event)
|
closest = self._closest_profile(event)
|
||||||
|
|
@ -194,7 +196,7 @@ class PlotKPC(PamhyrPlot):
|
||||||
def _closest_profile(self, event):
|
def _closest_profile(self, event):
|
||||||
|
|
||||||
s = event.artist.get_segments()
|
s = event.artist.get_segments()
|
||||||
x = [i[0,0] for i in s]
|
x = [i[0, 0] for i in s]
|
||||||
mx = event.mouseevent.xdata
|
mx = event.mouseevent.xdata
|
||||||
points = enumerate(x)
|
points = enumerate(x)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,16 +51,16 @@ class PlotXY(PamhyrPlot):
|
||||||
self.before_plot_selected = None
|
self.before_plot_selected = None
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
self.after_plot_selected = None
|
self.after_plot_selected = None
|
||||||
self.parent=parent
|
self.parent = parent
|
||||||
self.line_xy_collection = None
|
self.line_xy_collection = None
|
||||||
self._table=table
|
self._table = table
|
||||||
self._colors = []
|
self._colors = []
|
||||||
self._style = []
|
self._style = []
|
||||||
|
|
||||||
def onpick(self, event):
|
def onpick(self, event):
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
if event.mouseevent.inaxes != self.canvas.axes:
|
||||||
return
|
return
|
||||||
if event.mouseevent.button.value not in [1,3]:
|
if event.mouseevent.button.value not in [1, 3]:
|
||||||
return
|
return
|
||||||
|
|
||||||
closest = self._closest_section(event)
|
closest = self._closest_section(event)
|
||||||
|
|
@ -75,7 +75,6 @@ class PlotXY(PamhyrPlot):
|
||||||
if event.mouseevent.button.value == 3:
|
if event.mouseevent.button.value == 3:
|
||||||
table.setData(index[4], kp[closest[0]])
|
table.setData(index[4], kp[closest[0]])
|
||||||
|
|
||||||
#self.update()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _closest_section(self, event):
|
def _closest_section(self, event):
|
||||||
|
|
@ -90,7 +89,7 @@ class PlotXY(PamhyrPlot):
|
||||||
|
|
||||||
points = []
|
points = []
|
||||||
for i in ind:
|
for i in ind:
|
||||||
points = points + [[i, j] for j in segments[i]]
|
points = points + [[i, j] for j in segments[i]]
|
||||||
|
|
||||||
def dist_mouse(point):
|
def dist_mouse(point):
|
||||||
x, y = point[1]
|
x, y = point[1]
|
||||||
|
|
@ -129,10 +128,12 @@ class PlotXY(PamhyrPlot):
|
||||||
self.line_xy.append(np.column_stack(xy))
|
self.line_xy.append(np.column_stack(xy))
|
||||||
|
|
||||||
self._colors, self._style = self.color_hightlight()
|
self._colors, self._style = self.color_hightlight()
|
||||||
self.line_xy_collection = collections.LineCollection(self.line_xy,
|
self.line_xy_collection = collections.LineCollection(
|
||||||
colors = self._colors,
|
self.line_xy,
|
||||||
linestyle = self._style,
|
colors=self._colors,
|
||||||
picker=10)
|
linestyle=self._style,
|
||||||
|
picker=10
|
||||||
|
)
|
||||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
self.canvas.axes.add_collection(self.line_xy_collection)
|
||||||
|
|
||||||
def color_hightlight(self):
|
def color_hightlight(self):
|
||||||
|
|
@ -213,24 +214,24 @@ class PlotXY(PamhyrPlot):
|
||||||
x_complete = list(self.data.get_guidelines_x())
|
x_complete = list(self.data.get_guidelines_x())
|
||||||
y_complete = list(self.data.get_guidelines_y())
|
y_complete = list(self.data.get_guidelines_y())
|
||||||
|
|
||||||
# TODO comprendre à quoi sert ce bout de code
|
# TODO comprendre à quoi sert ce bout de code
|
||||||
# ========>
|
# ========>
|
||||||
#for i in range(self.data.number_profiles):
|
# for i in range(self.data.number_profiles):
|
||||||
#if i < len(self.line_xy):
|
# if i < len(self.line_xy):
|
||||||
#self.line_xy[i][0].set_data(
|
# self.line_xy[i][0].set_data(
|
||||||
#self.data.profile(i).x(),
|
# self.data.profile(i).x(),
|
||||||
#self.data.profile(i).y()
|
# self.data.profile(i).y()
|
||||||
#)
|
# )
|
||||||
#else:
|
# else:
|
||||||
#self.line_xy.append(
|
# self.line_xy.append(
|
||||||
#self.canvas.axes.plot(
|
# self.canvas.axes.plot(
|
||||||
#self.data.profile(i).x(),
|
# self.data.profile(i).x(),
|
||||||
#self.data.profile(i).y(),
|
# self.data.profile(i).y(),
|
||||||
#color='r',
|
# color='r',
|
||||||
#**self.plot_default_kargs
|
# **self.plot_default_kargs
|
||||||
#)
|
# )
|
||||||
#)
|
# )
|
||||||
# <========
|
# <========
|
||||||
|
|
||||||
for i in range(len(x_complete)):
|
for i in range(len(x_complete)):
|
||||||
if i < len(self.line_gl):
|
if i < len(self.line_gl):
|
||||||
|
|
|
||||||
|
|
@ -297,9 +297,3 @@ class LateralContributionWindow(PamhyrWindow):
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
win.show()
|
win.show()
|
||||||
|
|
||||||
#@pyqtSlot()
|
|
||||||
def onChange(self,i): #changed!
|
|
||||||
QtGui.QMessageBox.information(self,
|
|
||||||
"Tab Index Changed!",
|
|
||||||
"Current Tab Index: %d" % i ) #changed!
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue