本文整理汇总了Python中PyQt5.QtCore.QLineF.setP1方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.setP1方法的具体用法?Python QLineF.setP1怎么用?Python QLineF.setP1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.setP1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rotateUIPointAroundRefLine
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import setP1 [as 别名]
def rotateUIPointAroundRefLine(x1, y1, x2, y2, pt):
"""
Given three points p1, p2, pt this rotates pt around p2 such that p1,p2 and
p1,pt are collinear.
"""
line = QLineF(pt.x, pt.y, x2, y2)
p2p_l = line.length()
line.setP1(QPointF(x1, y1))
p1p2_l = line.length()
if not p1p2_l:
return
line.setLength(p1p2_l + p2p_l)
pt.x = line.x2()
pt.y = line.y2()
示例2: mouseMoveEvent
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import setP1 [as 别名]
def mouseMoveEvent(self, event):
path, text = self._rulerObject
baseElem = path.elementAt(0)
canvasPos = event.localPos()
if event.modifiers() & Qt.ShiftModifier:
basePos = QPointF(baseElem.x, baseElem.y)
canvasPos = self.clampToOrigin(canvasPos, basePos)
canvasPos = self.magnetPos(canvasPos)
x, y = canvasPos.x(), canvasPos.y()
path.setElementPositionAt(1, x, baseElem.y)
path.setElementPositionAt(2, x, y)
path.setElementPositionAt(3, baseElem.x, baseElem.y)
line = QLineF(baseElem.x, baseElem.y, x, y)
l = line.length()
# angle() doesnt go by trigonometric direction. Weird.
# TODO: maybe split in positive/negative 180s (ff)
a = 360 - line.angle()
line.setP2(QPointF(x, baseElem.y))
h = line.length()
line.setP1(QPointF(x, y))
v = line.length()
text = "%d\n↔ %d\n↕ %d\nα %dº" % (l, h, v, a)
self._rulerObject = (path, text)
self.parent().update()