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


Python QLineF.fromPolar方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QLineF.fromPolar方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.fromPolar方法的具体用法?Python QLineF.fromPolar怎么用?Python QLineF.fromPolar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QLineF的用法示例。


在下文中一共展示了QLineF.fromPolar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _updateTextAnchors

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import fromPolar [as 别名]
    def _updateTextAnchors(self):
        n = len(self._items)

        items = self._items
        dist = 15

        shape = reduce(QPainterPath.united, [item.path() for item in items])
        brect = shape.boundingRect()
        bradius = max(brect.width() / 2, brect.height() / 2)

        center = self.boundingRect().center()

        anchors = _category_anchors(items)
        self._textanchors = []
        for angle, anchor_h, anchor_v in anchors:
            line = QLineF.fromPolar(bradius, angle)
            ext = QLineF.fromPolar(dist, angle)
            line = QLineF(line.p1(), line.p2() + ext.p2())
            line = line.translated(center)

            anchor_pos = line.p2()
            self._textanchors.append((anchor_pos, anchor_h, anchor_v))

        for i in range(n):
            self._updateTextItemPos(i)
开发者ID:PythonCharmers,项目名称:orange3,代码行数:27,代码来源:owvenndiagram.py

示例2: paint

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import fromPolar [as 别名]
 def paint(self, painter):
     pen = QPen(Qt.black)
     pen.setWidthF(2.5)
     painter.setPen(pen)
     line = QLineF(self.startPoint, self.pos)
     painter.drawLine(line)
     if self.pos != self.startPoint:
         #draw arrowhead
         a = line.angle()
         l1 = QLineF.fromPolar(25, a - 155)
         l1.translate(self.pos)
         l2 = QLineF.fromPolar(25, a + 155)
         l2.translate(self.pos)
         painter.drawLine(l1)
         painter.drawLine(l2)
开发者ID:dhrosa,项目名称:empyre_old,代码行数:17,代码来源:animations.py

示例3: arrow_path_concave

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import fromPolar [as 别名]
def arrow_path_concave(line, width):
    """
    Return a :class:`QPainterPath` of a pretty looking arrow.
    """
    path = QPainterPath()
    p1, p2 = line.p1(), line.p2()

    if p1 == p2:
        return path

    baseline = QLineF(line)
    # Require some minimum length.
    baseline.setLength(max(line.length() - width * 3, width * 3))

    start, end = baseline.p1(), baseline.p2()
    mid = (start + end) / 2.0
    normal = QLineF.fromPolar(1.0, baseline.angle() + 90).p2()

    path.moveTo(start)
    path.lineTo(start + (normal * width / 4.0))

    path.quadTo(mid + (normal * width / 4.0),
                end + (normal * width / 1.5))

    path.lineTo(end - (normal * width / 1.5))
    path.quadTo(mid - (normal * width / 4.0),
                start - (normal * width / 4.0))
    path.closeSubpath()

    arrow_head_len = width * 4
    arrow_head_angle = 50
    line_angle = line.angle() - 180

    angle_1 = line_angle - arrow_head_angle / 2.0
    angle_2 = line_angle + arrow_head_angle / 2.0

    points = [p2,
              p2 + QLineF.fromPolar(arrow_head_len, angle_1).p2(),
              baseline.p2(),
              p2 + QLineF.fromPolar(arrow_head_len, angle_2).p2(),
              p2]

    poly = QPolygonF(points)
    path_head = QPainterPath()
    path_head.addPolygon(poly)
    path = path.united(path_head)
    return path
开发者ID:CHANAYA,项目名称:orange3,代码行数:49,代码来源:annotationitem.py

示例4: arrow_path_plain

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import fromPolar [as 别名]
def arrow_path_plain(line, width):
    """
    Return an :class:`QPainterPath` of a plain looking arrow.
    """
    path = QPainterPath()
    p1, p2 = line.p1(), line.p2()

    if p1 == p2:
        return path

    baseline = QLineF(line)
    # Require some minimum length.
    baseline.setLength(max(line.length() - width * 3, width * 3))
    path.moveTo(baseline.p1())
    path.lineTo(baseline.p2())

    stroker = QPainterPathStroker()
    stroker.setWidth(width)
    path = stroker.createStroke(path)

    arrow_head_len = width * 4
    arrow_head_angle = 50
    line_angle = line.angle() - 180

    angle_1 = line_angle - arrow_head_angle / 2.0
    angle_2 = line_angle + arrow_head_angle / 2.0

    points = [
        p2,
        p2 + QLineF.fromPolar(arrow_head_len, angle_1).p2(),
        p2 + QLineF.fromPolar(arrow_head_len, angle_2).p2(),
        p2,
    ]

    poly = QPolygonF(points)
    path_head = QPainterPath()
    path_head.addPolygon(poly)
    path = path.united(path_head)
    return path
开发者ID:testmana2,项目名称:orange,代码行数:41,代码来源:annotationitem.py


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