当前位置: 首页>>代码示例>>Python>>正文


Python QLineF.setP1方法代码示例

本文整理汇总了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()
开发者ID:anthrotype,项目名称:trufont,代码行数:16,代码来源:uiMethods.py

示例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()
开发者ID:mandel59,项目名称:trufont,代码行数:26,代码来源:rulerTool.py


注:本文中的PyQt5.QtCore.QLineF.setP1方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。