infiniteline tests pass
This commit is contained in:
parent
ad8e169160
commit
4a3525eafd
@ -5,19 +5,19 @@ pg.mkQApp()
|
|||||||
|
|
||||||
|
|
||||||
def test_InfiniteLine():
|
def test_InfiniteLine():
|
||||||
|
# Test basic InfiniteLine API
|
||||||
plt = pg.plot()
|
plt = pg.plot()
|
||||||
plt.setXRange(-10, 10)
|
plt.setXRange(-10, 10)
|
||||||
plt.setYRange(-10, 10)
|
plt.setYRange(-10, 10)
|
||||||
vline = plt.addLine(x=1)
|
|
||||||
plt.resize(600, 600)
|
plt.resize(600, 600)
|
||||||
QtGui.QApplication.processEvents()
|
|
||||||
|
# seemingly arbitrary requirements; might need longer wait time for some platforms..
|
||||||
QtTest.QTest.qWaitForWindowShown(plt)
|
QtTest.QTest.qWaitForWindowShown(plt)
|
||||||
QtTest.QTest.qWait(100)
|
QtTest.QTest.qWait(100)
|
||||||
|
|
||||||
|
vline = plt.addLine(x=1)
|
||||||
assert vline.angle == 90
|
assert vline.angle == 90
|
||||||
br = vline.mapToView(QtGui.QPolygonF(vline.boundingRect()))
|
br = vline.mapToView(QtGui.QPolygonF(vline.boundingRect()))
|
||||||
print(vline.boundingRect())
|
|
||||||
print(list(QtGui.QPolygonF(vline.boundingRect())))
|
|
||||||
print(list(br))
|
|
||||||
assert br.containsPoint(pg.Point(1, 5), QtCore.Qt.OddEvenFill)
|
assert br.containsPoint(pg.Point(1, 5), QtCore.Qt.OddEvenFill)
|
||||||
assert not br.containsPoint(pg.Point(5, 0), QtCore.Qt.OddEvenFill)
|
assert not br.containsPoint(pg.Point(5, 0), QtCore.Qt.OddEvenFill)
|
||||||
hline = plt.addLine(y=0)
|
hline = plt.addLine(y=0)
|
||||||
@ -37,11 +37,12 @@ def test_InfiniteLine():
|
|||||||
assert oline.pos() == pg.Point(1, -1)
|
assert oline.pos() == pg.Point(1, -1)
|
||||||
assert oline.value() == [1, -1]
|
assert oline.value() == [1, -1]
|
||||||
|
|
||||||
|
# test bounding rect for oblique line
|
||||||
br = oline.mapToScene(oline.boundingRect())
|
br = oline.mapToScene(oline.boundingRect())
|
||||||
pos = oline.mapToScene(pg.Point(2, 0))
|
pos = oline.mapToScene(pg.Point(2, 0))
|
||||||
assert br.containsPoint(pos, QtCore.Qt.OddEvenFill)
|
assert br.containsPoint(pos, QtCore.Qt.OddEvenFill)
|
||||||
px = oline.pixelVectors(pg.Point(1, 0))[0]
|
px = pg.Point(-0.5, -1.0 / 3**0.5)
|
||||||
assert br.containsPoint(pos + 4 * px, QtCore.Qt.OddEvenFill)
|
assert br.containsPoint(pos + 5 * px, QtCore.Qt.OddEvenFill)
|
||||||
assert not br.containsPoint(pos + 7 * px, QtCore.Qt.OddEvenFill)
|
assert not br.containsPoint(pos + 7 * px, QtCore.Qt.OddEvenFill)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user