Emit event with mouse clicks for some items (#1414)
Harmonizes behavior with PlotCurveItem.
This commit is contained in:
parent
27ca1747f1
commit
0dacc57e02
@ -22,18 +22,18 @@ class PlotDataItem(GraphicsObject):
|
||||
usually created by plot() methods such as :func:`pyqtgraph.plot` and
|
||||
:func:`PlotItem.plot() <pyqtgraph.PlotItem.plot>`.
|
||||
|
||||
============================== ==============================================
|
||||
================================== ==============================================
|
||||
**Signals:**
|
||||
sigPlotChanged(self) Emitted when the data in this item is updated.
|
||||
sigClicked(self) Emitted when the item is clicked.
|
||||
sigPointsClicked(self, points) Emitted when a plot point is clicked
|
||||
Sends the list of points under the mouse.
|
||||
============================== ==============================================
|
||||
sigPlotChanged(self) Emitted when the data in this item is updated.
|
||||
sigClicked(self, ev) Emitted when the item is clicked.
|
||||
sigPointsClicked(self, points, ev) Emitted when a plot point is clicked
|
||||
Sends the list of points under the mouse.
|
||||
================================== ==============================================
|
||||
"""
|
||||
|
||||
sigPlotChanged = QtCore.Signal(object)
|
||||
sigClicked = QtCore.Signal(object)
|
||||
sigPointsClicked = QtCore.Signal(object, object)
|
||||
sigClicked = QtCore.Signal(object, object)
|
||||
sigPointsClicked = QtCore.Signal(object, object, object)
|
||||
|
||||
def __init__(self, *args, **kargs):
|
||||
"""
|
||||
@ -762,12 +762,12 @@ class PlotDataItem(GraphicsObject):
|
||||
def appendData(self, *args, **kargs):
|
||||
pass
|
||||
|
||||
def curveClicked(self):
|
||||
self.sigClicked.emit(self)
|
||||
def curveClicked(self, curve, ev):
|
||||
self.sigClicked.emit(self, ev)
|
||||
|
||||
def scatterClicked(self, plt, points):
|
||||
self.sigClicked.emit(self)
|
||||
self.sigPointsClicked.emit(self, points)
|
||||
def scatterClicked(self, plt, points, ev):
|
||||
self.sigClicked.emit(self, ev)
|
||||
self.sigPointsClicked.emit(self, points, ev)
|
||||
|
||||
def viewRangeChanged(self):
|
||||
# view range has changed; re-plot if needed
|
||||
|
@ -247,16 +247,16 @@ class ScatterPlotItem(GraphicsObject):
|
||||
or for all points.
|
||||
|
||||
|
||||
======================== ===============================================
|
||||
============================ ===============================================
|
||||
**Signals:**
|
||||
sigPlotChanged(self) Emitted when the data being plotted has changed
|
||||
sigClicked(self, points) Emitted when the curve is clicked. Sends a list
|
||||
of all the points under the mouse pointer.
|
||||
======================== ===============================================
|
||||
sigPlotChanged(self) Emitted when the data being plotted has changed
|
||||
sigClicked(self, points, ev) Emitted when the curve is clicked. Sends a list
|
||||
of all the points under the mouse pointer.
|
||||
============================ ===============================================
|
||||
|
||||
"""
|
||||
#sigPointClicked = QtCore.Signal(object, object)
|
||||
sigClicked = QtCore.Signal(object, object) ## self, points
|
||||
sigClicked = QtCore.Signal(object, object, object) ## self, points
|
||||
sigPlotChanged = QtCore.Signal(object)
|
||||
def __init__(self, *args, **kargs):
|
||||
"""
|
||||
@ -895,7 +895,7 @@ class ScatterPlotItem(GraphicsObject):
|
||||
if len(pts) > 0:
|
||||
self.ptsClicked = pts
|
||||
ev.accept()
|
||||
self.sigClicked.emit(self, self.ptsClicked)
|
||||
self.sigClicked.emit(self, self.ptsClicked, ev)
|
||||
else:
|
||||
#print "no spots"
|
||||
ev.ignore()
|
||||
|
@ -33,7 +33,7 @@ class ScatterPlotWidget(QtGui.QSplitter):
|
||||
specifying multiple criteria.
|
||||
4) A PlotWidget for displaying the data.
|
||||
"""
|
||||
sigScatterPlotClicked = QtCore.Signal(object, object)
|
||||
sigScatterPlotClicked = QtCore.Signal(object, object, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QSplitter.__init__(self, QtCore.Qt.Horizontal)
|
||||
@ -279,8 +279,8 @@ class ScatterPlotWidget(QtGui.QSplitter):
|
||||
self._indexMap = {j:i for i,j in enumerate(self._visibleIndices)}
|
||||
return self._indexMap
|
||||
|
||||
def plotClicked(self, plot, points):
|
||||
def plotClicked(self, plot, points, ev):
|
||||
# Tag each point with its index into the original dataset
|
||||
for pt in points:
|
||||
pt.originalIndex = self._visibleIndices[pt.index()]
|
||||
self.sigScatterPlotClicked.emit(self, points)
|
||||
self.sigScatterPlotClicked.emit(self, points, ev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user