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
1 changed files with 6 additions and 3 deletions

View File

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