本文整理汇总了Python中pyqtgraph.Point方法的典型用法代码示例。如果您正苦于以下问题:Python pyqtgraph.Point方法的具体用法?Python pyqtgraph.Point怎么用?Python pyqtgraph.Point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph
的用法示例。
在下文中一共展示了pyqtgraph.Point方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def __init__(self, gitem, **params):
ParamObj.__init__(self)
pg.GraphicsObject.__init__(self) #, [0,0], [1,1])
self.gitem = gitem
self.surfaces = gitem.surfaces
gitem.setParentItem(self)
self.roi = pg.ROI([0,0], [1,1])
self.roi.addRotateHandle([1, 1], [0.5, 0.5])
self.roi.setParentItem(self)
defaults = {
'pos': Point(0,0),
'angle': 0,
}
defaults.update(params)
self._ior_cache = {}
self.roi.sigRegionChanged.connect(self.roiChanged)
self.setParams(**defaults)
示例2: paramStateChanged
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def paramStateChanged(self):
"""Some parameters of the optic have changed."""
# Move graphics item
self.gitem.setPos(Point(self['pos']))
self.gitem.resetTransform()
self.gitem.rotate(self['angle'])
# Move ROI to match
try:
self.roi.sigRegionChanged.disconnect(self.roiChanged)
br = self.gitem.boundingRect()
o = self.gitem.mapToParent(br.topLeft())
self.roi.setAngle(self['angle'])
self.roi.setPos(o)
self.roi.setSize([br.width(), br.height()])
finally:
self.roi.sigRegionChanged.connect(self.roiChanged)
self.sigStateChanged.emit()
示例3: propagateRay
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def propagateRay(self, ray):
"""Refract, reflect, absorb, and/or scatter ray. This function may create and return new rays"""
surface = self.surfaces[0]
p1, ai = surface.intersectRay(ray)
if p1 is not None:
p1 = surface.mapToItem(ray, p1)
rd = ray['dir']
a1 = np.arctan2(rd[1], rd[0])
ar = a1 + np.pi - 2*ai
ray.setEnd(p1)
dp = Point(np.cos(ar), np.sin(ar))
ray = Ray(parent=ray, dir=dp)
else:
ray.setEnd(None)
return [ray]
示例4: test_mouse_drag_event
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def test_mouse_drag_event(self):
self.mock_graph.state = ZOOMING
mock_event = Mock()
mock_event.button.return_value = Qt.LeftButton
mock_event.pos.return_value = pg.Point(0.6, 0.6)
mock_event.isFinish.return_value = True
mock_event.buttonDownPos.return_value = pg.Point(0.4, 0.4)
self.mvb.mapToView = lambda x: x
self.mvb.state['mouseMode'] = pg.ViewBox.RectMode
self.mvb.match_zoom(pg.Point(0.5, 0.5))
qrect1 = self.sr.call_args[0][0]
zoom1 = self.mvb.get_zoom()
self.mvb.mouseDragEvent(mock_event)
mock_event.accept.assert_called()
zoom2 = self.mvb.get_zoom()
qrect2 = self.sr.call_args[0][0]
# when selecting a smaller region zoom level should increase and
# shown area should decrees
self.assertTrue(zoom2 > zoom1)
self.assertTrue(qrect2.width() < qrect1.width())
mock_event.button.return_value = Qt.RightButton
self.mvb.mouseDragEvent(mock_event)
mock_event.ignore.assert_called()
示例5: wheelEvent
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def wheelEvent(self, ev, axis=None):
if ev.modifiers() == QtCore.Qt.ControlModifier:
scale_fact = 1
self.v_zoom_scale /= 1.02 ** (ev.delta() * self.state['wheelScaleFactor'])
else:
scale_fact = 1.02 ** (ev.delta() * self.state['wheelScaleFactor'])
vr = self.targetRect()
center = self.mapToView(ev.pos())
if (center.x()-vr.left())/vr.width() < 0.05: # zoom to far left => all the way left
center = pg.Point(vr.left(), center.y())
elif (center.x()-vr.left())/vr.width() > 0.95: # zoom to far right => all the way right
center = pg.Point(vr.right(), center.y())
self.zoom_rect(vr, scale_fact, center)
# update crosshair
_mouse_moved(self.win, None)
ev.accept()
示例6: updateTransform
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def updateTransform(self):
self.resetTransform()
self.setPos(0, 0)
self.translate(Point(self['pos']))
self.rotate(self['angle'])
示例7: currentState
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def currentState(self, relativeTo=None):
pos = self['start']
dir = self['dir']
if relativeTo is None:
return pos, dir
else:
trans = self.itemTransform(relativeTo)[0]
p1 = trans.map(pos)
p2 = trans.map(pos + dir)
return Point(p1), Point(p2-p1)
示例8: stepTo
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def stepTo(self, t):
data = self.clock.refData
while self.i < len(data)-1 and data['t'][self.i] < t:
self.i += 1
while self.i > 1 and data['t'][self.i-1] >= t:
self.i -= 1
self.setPos(data['x'][self.i], self.clock.y0)
t = data['pt'][self.i]
self.hand.setRotation(-0.25 * t * 360.)
self.resetTransform()
v = data['v'][self.i]
gam = (1.0 - v**2)**0.5
self.scale(gam, 1.0)
f = data['f'][self.i]
self.flare.resetTransform()
if f < 0:
self.flare.translate(self.size*0.4, 0)
else:
self.flare.translate(-self.size*0.4, 0)
self.flare.scale(-f * (0.5+np.random.random()*0.1), 1.0)
if self._spaceline is not None:
self._spaceline.setPos(pg.Point(data['x'][self.i], data['t'][self.i]))
self._spaceline.setAngle(data['v'][self.i] * 45.)
示例9: test_InfiniteLine
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def test_InfiniteLine():
# Test basic InfiniteLine API
plt = pg.plot()
plt.setXRange(-10, 10)
plt.setYRange(-10, 10)
plt.resize(600, 600)
# seemingly arbitrary requirements; might need longer wait time for some platforms..
QtTest.QTest.qWaitForWindowShown(plt)
QtTest.QTest.qWait(100)
vline = plt.addLine(x=1)
assert vline.angle == 90
br = vline.mapToView(QtGui.QPolygonF(vline.boundingRect()))
assert br.containsPoint(pg.Point(1, 5), QtCore.Qt.OddEvenFill)
assert not br.containsPoint(pg.Point(5, 0), QtCore.Qt.OddEvenFill)
hline = plt.addLine(y=0)
assert hline.angle == 0
assert hline.boundingRect().contains(pg.Point(5, 0))
assert not hline.boundingRect().contains(pg.Point(0, 5))
vline.setValue(2)
assert vline.value() == 2
vline.setPos(pg.Point(4, -5))
assert vline.value() == 4
oline = pg.InfiniteLine(angle=30)
plt.addItem(oline)
oline.setPos(pg.Point(1, -1))
assert oline.angle == 30
assert oline.pos() == pg.Point(1, -1)
assert oline.value() == [1, -1]
# test bounding rect for oblique line
br = oline.mapToScene(oline.boundingRect())
pos = oline.mapToScene(pg.Point(2, 0))
assert br.containsPoint(pos, QtCore.Qt.OddEvenFill)
px = pg.Point(-0.5, -1.0 / 3**0.5)
assert br.containsPoint(pos + 5 * px, QtCore.Qt.OddEvenFill)
assert not br.containsPoint(pos + 7 * px, QtCore.Qt.OddEvenFill)
示例10: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def __init__(self, delegate):
self.delegate = delegate
self.source = self.delegate.source
source = self.source
pg.ROI.__init__(
self,
pos=pg.Point(source.outline()[1]),
size=pg.Point(source.width, source.length),
angle=-source.strike,
invertible=False,
pen=self.pen_outline)
self.handlePen = self.pen_handle
self.addScaleRotateHandle([0, 0], [0, 1])
self.addScaleRotateHandle([0, 1], [0, 0])
self.addScaleHandle([1, .5], [0, .5],
lockAspect=False)
for h in self.handles:
h['item'].sigClicked.connect(self.sigRegionChangeStarted.emit)
self.delegate.sourceParametersChanged.connect(
self.updateROIPosition)
self.sigRegionChangeFinished.connect(
self.setSourceParametersFromROI)
self.setAcceptedMouseButtons(QtCore.Qt.RightButton)
self.sigClicked.connect(self.showEditingDialog)
示例11: updateROIPosition
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def updateROIPosition(self):
source = self.source
width = source.width
self.setPos(
pg.Point(source.outline()[1]),
finish=False)
self.setSize(
pg.Point(width, source.length),
finish=False)
self.setAngle(
-source.strike,
finish=False)
示例12: test_match_zoom
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def test_match_zoom(self):
point1 = pg.Point(0.5, 0.5)
self.mvb.match_zoom(point1)
qrect1 = self.sr.call_args[0][0]
point2 = pg.Point(0.75, 0.75)
self.mvb.match_zoom(point2, offset=True)
qrect2 = self.sr.call_args[0][0]
# when center is offset the new rect should also be offset
self.assertTrue(qrect1.x() < qrect2.x())
self.assertAlmostEqual(qrect1.width(), qrect2.width())
示例13: test_wheel_event
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def test_wheel_event(self):
mock_event = Mock()
mock_event.delta.return_value = 1
mock_event.pos.return_value = pg.Point(0.5, 0.5)
self.assertEqual(self.mvb.get_zoom(), 2)
self.mvb.wheelEvent(mock_event)
self.assertEqual(self.mvb.get_zoom(), 3)
qrect1 = self.sr.call_args[0][0]
mock_event.accept.assert_called()
self.mvb.wheelEvent(mock_event)
self.assertEqual(self.mvb.get_zoom(), 4)
qrect2 = self.sr.call_args[0][0]
# after zooming in the shown rectangle should be smaller
self.assertTrue(qrect1.width() > qrect2.width())
mock_event.delta.return_value = -1
self.mvb.wheelEvent(mock_event)
self.assertEqual(self.mvb.get_zoom(), 3)
qrect3 = self.sr.call_args[0][0]
# after zooming out the shown rectangle should be larger
self.assertTrue(qrect3.width() > qrect2.width())
self.mvb.wheelEvent(mock_event)
self.mvb.wheelEvent(mock_event)
self.assertEqual(self.mvb.get_zoom(), 2)
示例14: test_no_data
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def test_no_data(self):
self.xy = None, None
self.graph.reset_graph()
self.view_box.recalculate_zoom.assert_called_once_with(1, 1)
self.view_box.match_zoom.assert_called_once_with(Point(0.5, 0.5))
示例15: test_update_view_range
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import Point [as 别名]
def test_update_view_range(self):
self.graph.reset_graph()
self.view_box.recalculate_zoom.reset_mock()
self.view_box.match_zoom.reset_mock()
self.graph.update_view_range()
self.view_box.recalculate_zoom.assert_called_once_with(0.7 - 0.5,
0.8 - 0.6)
self.view_box.match_zoom.assert_called_once_with(Point(0.6, 0.7))
self.view_box.recalculate_zoom.reset_mock()
self.view_box.match_zoom.reset_mock()
self.graph.update_view_range(match_data=False)
self.assertFalse(self.view_box.recalculate_zoom.called)
self.view_box.match_zoom.assert_called_once_with(Point(0.15, 0.35))