Repository: silx-kit/silx
Issue: [Plot][BUG] Crosshair cursor mode gives wrong values

When crosshair cursor mode is activated on 1D curves, the position of the active curve points is not correctly reported.

Changed files:
silx/gui/plot/PlotTools.py, silx/gui/plot/PlotActions.py

diff --git a/silx/gui/plot/PlotActions.py b/silx/gui/plot/PlotActions.py
index 9c398b62b..678f32793 100644
--- a/silx/gui/plot/PlotActions.py
+++ b/silx/gui/plot/PlotActions.py
@@ -1303,6 +1303,7 @@ class PixelIntensitiesHistoAction(PlotAction):
         """
         return self._histo
 
+
 class MedianFilterAction(PlotAction):
     """QAction to plot the pixels intensities diagram
 
@@ -1319,7 +1320,8 @@ class MedianFilterAction(PlotAction):
                             triggered=self._triggered,
                             parent=parent)
         self._originalImage = None
-        self._filtredImage = None
+        self._legend = None
+        self._filteredImage = None
         self._popup = MedianFilterDialog(parent=None)
         self._popup.sigFilterOptChanged.connect(self._updateFilter)
         self.plot.sigActiveImageChanged.connect( self._updateActiveImage)
@@ -1337,27 +1339,29 @@ class MedianFilterAction(PlotAction):
         self._activeImageLegend = self.plot.getActiveImage(just_legend=True)
         if self._activeImageLegend is None:
             self._originalImage = None
+            self._legend = None
         else:
-            self._originalImage = self.plot.getImage(self._activeImageLegend)[0]
+            self._originalImage = self.plot.getImage(self._activeImageLegend).getData(copy=False)
+            self._legend = self.plot.getImage(self._activeImageLegend).getLegend()
 
     def _updateFilter(self, kernelWidth, conditionnal=False):
         if self._originalImage is None:
             return
 
-        self.plot.sigActiveImageChanged.disconnect( self._updateActiveImage)
-        filtredImage = self._computeFiltredImage(kernelWidth, conditionnal)
-        self.plot.addImage(data=filtredImage,
-                           legend=self._originalImage,
+        self.plot.sigActiveImageChanged.disconnect(self._updateActiveImage)
+        filteredImage = self._computeFilteredImage(kernelWidth, conditionnal)
+        self.plot.addImage(data=filteredImage,
+                           legend=self._legend,
                            replace=True)
-        self.plot.sigActiveImageChanged.connect( self._updateActiveImage)
+        self.plot.sigActiveImageChanged.connect(self._updateActiveImage)
 
-    def _computeFiltredImage(self, kernelWidth, conditionnal):
+    def _computeFilteredImage(self, kernelWidth, conditional):
         raise NotImplemented('MedianFilterAction is a an abstract class')
 
     def getFilteredImage(self):
         """
         :return: the image with the median filter apply on"""
-        return self._filtredImage
+        return self._filteredImage
 
 
 class MedianFilter1DAction(MedianFilterAction):
@@ -1371,11 +1375,11 @@ class MedianFilter1DAction(MedianFilterAction):
                         plot,
                         parent=parent)
 
-    def _computeFiltredImage(self, kernelWidth, conditionnal):
+    def _computeFilteredImage(self, kernelWidth, conditional):
         assert(self.plot is not None)
         return medianfilter(self._originalImage,
-                                    kernelWidth,
-                                    conditionnal )
+                            kernelWidth,
+                            conditional)
 
 
 class MedianFilter2DAction(MedianFilterAction):
@@ -1389,8 +1393,8 @@ class MedianFilter2DAction(MedianFilterAction):
                         plot,
                         parent=parent)
 
-    def _computeFiltredImage(self, kernelWidth, conditionnal):
+    def _computeFilteredImage(self, kernelWidth, conditional):
         assert(self.plot is not None)
         return medianfilter(self._originalImage,
-                                          (kernelWidth, kernelWidth),
-                                          conditionnal )
+                            (kernelWidth, kernelWidth),
+                            conditional)
diff --git a/silx/gui/plot/PlotTools.py b/silx/gui/plot/PlotTools.py
index d5ee2b343..7158d0eac 100644
--- a/silx/gui/plot/PlotTools.py
+++ b/silx/gui/plot/PlotTools.py
@@ -29,7 +29,7 @@ from __future__ import division
 
 __authors__ = ["V.A. Sole", "T. Vincent"]
 __license__ = "MIT"
-__date__ = "16/12/2016"
+__date__ = "03/03/2017"
 
 
 import logging
@@ -172,11 +172,10 @@ class PositionInfo(qt.QWidget):
                         closestInPixels = self.plot.dataToPixel(
                             xClosest, yClosest, axis=activeCurve.getYAxis())
                         if closestInPixels is not None:
-                            xClosest, yClosest = closestInPixels
                             xPixel, yPixel = event['xpixel'], event['ypixel']
 
-                            if (abs(xClosest - xPixel) < 5 and
-                                    abs(yClosest - yPixel) < 5):
+                            if (abs(closestInPixels[0] - xPixel) < 5 and
+                                    abs(closestInPixels[1] - yPixel) < 5):
                                 # Update label style sheet
                                 styleSheet = "color: rgb(0, 0, 0);"