Merge changes from lp:~ibressler/pyqtgraph/devel

This commit is contained in:
Luke Campagnola 2011-02-07 19:52:48 -05:00
commit 4aeaf61976
4 changed files with 22 additions and 7 deletions

View File

@ -226,15 +226,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

@ -953,7 +953,7 @@ class PlotItem(QtGui.QGraphicsWidget):
if arr.ndim != 1:
raise Exception("Array must be 1D to plot (shape is %s)" % arr.shape)
if x is None:
x = arange(arr.shape[0])
x = np.arange(arr.shape[0])
if x.ndim != 1:
raise Exception("X array must be 1D to plot (shape is %s)" % x.shape)
c = PlotCurveItem(arr, x=x)

View File

@ -5,6 +5,7 @@ import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from scipy import random
from numpy import array, arange
from PyQt4 import QtGui, QtCore
from pyqtgraph.PlotWidget import *
from pyqtgraph.graphicsItems import *
@ -90,4 +91,4 @@ for i in range(0, 5):
yd, xd = rand(10000)
pw2.plot(y=yd*(j+1), x=xd, params={'iter': i, 'val': j})
#app.exec_()
app.exec_()

View File

@ -1458,8 +1458,10 @@ class ScaleItem(QtGui.QGraphicsWidget):
else:
xs = bounds.width() / dif
tickPositions = set() # remembers positions of previously drawn ticks
## draw ticks and text
for i in [i1, i1+1, i1+2]: ## draw three different intervals
## draw three different intervals, long ticks first
for i in reversed([i1, i1+1, i1+2]):
if i > len(intervals):
continue
## spacing for this interval
@ -1503,7 +1505,11 @@ class ScaleItem(QtGui.QGraphicsWidget):
if p1[1-axis] < 0:
continue
p.setPen(QtGui.QPen(QtGui.QColor(100, 100, 100, a)))
p.drawLine(Point(p1), Point(p2))
# draw tick only if there is none
tickPos = p1[1-axis]
if tickPos not in tickPositions:
p.drawLine(Point(p1), Point(p2))
tickPositions.add(tickPos)
if i == textLevel:
if abs(v) < .001 or abs(v) >= 10000:
vstr = "%g" % (v * self.scale)
@ -1728,7 +1734,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):
QtGui.QGraphicsWidget.mouseMoveEvent(self, ev)
pos = np.array([ev.pos().x(), ev.pos().y()])