def __init__(self, *args):
apply
(QwtPlot.__init__,
(self,
)+args
)
#put the picker in my __init__ function
#connect the signal from the picker to my slot "pickerSlot"
self.connect(self.picker,SIGNAL("selected(const QwtDoublePoint&)"),self.pickerSlot)
#pickerSlot() to process picking signals in the plot
def pickerSlot(self,qDoublePoint):
#transform the (x,y) coordinates of the point of clicking to plot coordinates
pickX
= self.
transform(QwtPlot.
xBottom,qDoublePoint.
x()) pickY
= self.
transform(QwtPlot.
yleft,qDoublePoint.
y())
#get the closest marker to point of clicking on the plot
#closestmarker() returns the tuple containing the marker_Key and distance
#the distance can be used to filter out the selection if desired
markerSelected = self.closestMarker(pickX,pickY)
#get the key to the closest marker
markerKey = markerSelected[0]
#i set the font of the selected text to bold to show that it has been selected
fn = self.fontInfo().family()
self.
setMarkerLabel(markerKey,
"s",
QFont(fn,
12,
QFont.
Bold,
False),Qt.
blue)
self.replot()
def __init__(self, *args):
apply(QwtPlot.__init__,(self,)+args)
#put the picker in my __init__ function
self.picker = QwtPlotPicker(QwtPlot.xBottom,QwtPlot.yLeft,
QwtPicker.PointSelection,QwtPicker.NoRubberBand,
QwtPicker.AlwaysOn,self.canvas())
#connect the signal from the picker to my slot "pickerSlot"
self.connect(self.picker,SIGNAL("selected(const QwtDoublePoint&)"),self.pickerSlot)
#pickerSlot() to process picking signals in the plot
def pickerSlot(self,qDoublePoint):
#transform the (x,y) coordinates of the point of clicking to plot coordinates
pickX = self.transform(QwtPlot.xBottom,qDoublePoint.x())
pickY = self.transform(QwtPlot.yleft,qDoublePoint.y())
#get the closest marker to point of clicking on the plot
#closestmarker() returns the tuple containing the marker_Key and distance
#the distance can be used to filter out the selection if desired
markerSelected = self.closestMarker(pickX,pickY)
#get the key to the closest marker
markerKey = markerSelected[0]
#i set the font of the selected text to bold to show that it has been selected
fn = self.fontInfo().family()
self.setMarkerLabel(markerKey,"s",QFont(fn,12,QFont.Bold,False),Qt.blue)
self.replot()
To copy to clipboard, switch view to plain text mode
Bookmarks