diff --git a/Code/Mantid/MantidQt/SliceViewer/src/LineOverlay.cpp b/Code/Mantid/MantidQt/SliceViewer/src/LineOverlay.cpp index d6c316a4be02..dd3f765dd991 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/LineOverlay.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/LineOverlay.cpp @@ -387,10 +387,21 @@ namespace SliceViewer double distance = fabs( diff.x()*(current.y()-pixA.y()) - (current.x() - pixA.x())*diff.y() ) / sqrt(diff.x()*diff.x() + diff.y()*diff.y()); - // Margin of 6 pixels, and must be between the 2 limits - return ((distance < 7) && - isBetween( current.x(), pixA.x(), pixB.x()) && - isBetween( current.y(), pixA.y(), pixB.y()) ); + // Margin of 6 pixels, and must be between the 2 limits (if the limits are not the same) + bool retval = false; + if (distance < 7) + { + retval = true; + if ((pixA.x() != pixB.x()) && (!isBetween( current.x(), pixA.x(), pixB.x()))) + { + retval = false; + } + if ((pixA.y() != pixB.y()) && (!isBetween( current.y(), pixA.y(), pixB.y()))) + { + retval = false; + } + } + return retval; } //-----------------------------------------------------------------------------------------------