scanwidget: fix div by zero rubberband width (closes #335) (4b8fe1e)

This commit is contained in:
Robert Jördens 2016-03-18 09:04:35 +01:00
parent 223657fa63
commit d60eaa7b44

View File

@ -159,10 +159,13 @@ class ScanWidget(QtWidgets.QWidget):
if self._drag == "zoom":
self._rubber.hide()
left, scale = self._axisView
scale *= self.width()/self._rubber.geometry().width()
center = self._pixelToAxis(self._rubber.geometry().center().x())
if center:
scale = min(scale, self.dynamicRange/abs(center))
if self._rubber.geometry().width():
scale *= self.width()/self._rubber.geometry().width()
if center:
scale = min(scale, self.dynamicRange/abs(center))
elif center:
scale = self.dynamicRange/abs(center)
left = self.width()/2 - center*scale
self._setView(left, scale)
self._drag = None