Commit ab1b1c6a authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Added ViewBox test suite

parent 662af1a9
ViewBox test cases:
* call setRange then resize; requested range must be fully visible
* lockAspect works correctly for arbitrary aspect ratio
* autoRange works correctly with aspect locked
* call setRange with aspect locked, then resize
* AutoRange with all the bells and whistles
* item moves / changes transformation / changes bounds
* pan only
* fractional range
import pyqtgraph as pg
app = pg.mkQApp()
win = pg.GraphicsWindow()
vb = win.addViewBox(name="image view")
p1 = win.addPlot(name="plot 1")
p2 = win.addPlot(name="plot 2", row=1, col=0), 150), 150)
def viewsMatch():
r0 =
r1 =[1])
r2 =[1])
match = (abs(r0[1]-r1) <= (abs(r1) * 0.001)).all() and (abs(r0[0]-r2) <= (abs(r2) * 0.001)).all()
return match
print "link views match:", viewsMatch()
print "show views match:", viewsMatch()
imgData =, 10))
imgData[0] = 1
imgData[-1] = 1
imgData[:,0] = 1
imgData[:,-1] = 1
img = pg.ImageItem(imgData)
p1.plot(x=imgData.sum(axis=0), y=range(10))
p2.plot(x=range(10), y=imgData.sum(axis=1))
print "add items views match:", viewsMatch()
#grid = pg.GridItem()
#print "init views match:", viewsMatch()
#p2.setYRange(-300, 300)
#print "setRange views match:", viewsMatch()
#print "setRange views match (after update):", viewsMatch()
#print "--lock aspect--"
#print "lockAspect views match:", viewsMatch()
#p2.setYRange(-200, 200)
#print "setRange views match:", viewsMatch()
#print "setRange views match (after update):", viewsMatch()
#win.resize(100, 600)
#vb.setRange(xRange=[-10, 10], padding=0)
#win.resize(600, 100)
#print vb.viewRange()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment