- added&enabled wheelEvent for PlotItem (symmetric scaling)

This commit is contained in:
Ingo B. 2011-02-03 11:49:56 +01:00
parent bf1e59ca22
commit 56f54cbf9b
2 changed files with 11 additions and 3 deletions

View File

@ -219,15 +219,14 @@ class GraphicsView(QtGui.QGraphicsView):
def wheelEvent(self, ev):
QtGui.QGraphicsView.wheelEvent(self, ev)
if not self.mouseEnabled:
return
QtGui.QGraphicsView.wheelEvent(self, ev)
sc = 1.001 ** ev.delta()
#self.scale *= sc
#self.updateMatrix()
self.scale(sc, sc)
def setAspectLocked(self, s):
self.aspectLocked = s

View File

@ -1491,7 +1491,16 @@ class ViewBox(QtGui.QGraphicsWidget):
#self.replot(autoRange=False)
#self.updateMatrix()
def wheelEvent(self, ev):
mask = np.array(self.mouseEnabled, dtype=np.float)
degree = ev.delta() / 8.0;
dif = np.array([degree, degree])
s = ((mask * 0.02) + 1) ** dif
center = Point(self.childGroup.transform().inverted()[0].map(ev.pos()))
self.scaleBy(s, center)
self.emit(QtCore.SIGNAL('rangeChangedManually'), self.mouseEnabled)
ev.accept()
def mouseMoveEvent(self, ev):
pos = np.array([ev.pos().x(), ev.pos().y()])
dif = pos - self.mousePos