mirror of https://github.com/m-labs/artiq.git
scanwidget: fix div by zero rubberband width (closes #335) (4b8fe1e)
This commit is contained in:
parent
223657fa63
commit
d60eaa7b44
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue