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


Python QPainterPath.lineTo方法代码示例

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


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

示例1: move_label

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [as 别名]
 def move_label(label, frm, to):
     label.setX(to)
     to += t_box.width() / 2
     path = QPainterPath()
     path.lineTo(0, 4)
     path.lineTo(to - frm, 4)
     path.lineTo(to - frm, 8)
     p = QGraphicsPathItem(path)
     p.setPos(frm, 12)
     labels.addToGroup(p)
开发者ID:PrimozGodec,项目名称:orange3,代码行数:12,代码来源:owboxplot.py

示例2: qpainterpath_simple_split

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [as 别名]
def qpainterpath_simple_split(path, t):
    """
    Split a QPainterPath defined simple curve.

    The path must be either empty or composed of a single LineToElement or
    CurveToElement.

    Parameters
    ----------
    path : QPainterPath

    t : float
        Point where to split specified as a percentage along the path

    Returns
    -------
    splitpath: Tuple[QPainterPath, QPainterPath]
        A pair of QPainterPaths
    """
    assert path.elementCount() > 0
    el0 = path.elementAt(0)
    assert el0.type == QPainterPath.MoveToElement
    if path.elementCount() == 1:
        p1 = QPainterPath()
        p1.moveTo(el0.x, el0.y)
        return p1, QPainterPath(p1)

    el1 = path.elementAt(1)
    if el1.type == QPainterPath.LineToElement:
        pointat = path.pointAtPercent(t)
        l1 = QLineF(el0.x, el0.y, pointat.x(), pointat.y())
        l2 = QLineF(pointat.x(), pointat.y(), el1.x, el1.y)
        p1 = QPainterPath()
        p2 = QPainterPath()
        p1.moveTo(l1.p1())
        p1.lineTo(l1.p2())
        p2.moveTo(l2.p1())
        p2.lineTo(l2.p2())
        return p1, p2
    elif el1.type == QPainterPath.CurveToElement:
        c0, c1, c2, c3 = el0, el1, path.elementAt(2), path.elementAt(3)
        assert all(el.type == QPainterPath.CurveToDataElement
                   for el in [c2, c3])
        cp = [QPointF(el.x, el.y) for el in [c0, c1, c2, c3]]
        first, second = bezier_subdivide(cp, t)
        p1, p2 = QPainterPath(), QPainterPath()
        p1.moveTo(first[0])
        p1.cubicTo(*first[1:])
        p2.moveTo(second[0])
        p2.cubicTo(*second[1:])
        return p1, p2
    else:
        assert False
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:55,代码来源:linkitem.py

示例3: ParallelCoordinatesCurve

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [as 别名]
class ParallelCoordinatesCurve(OWCurve):
    def __init__(self, n_attributes, y_values, color, name=""):
        OWCurve.__init__(self, tooltip=name)
        self._item = QGraphicsPathItem(self)
        self.path = QPainterPath()
        self.fitted = False

        self.n_attributes = n_attributes
        self.n_rows = int(len(y_values) / n_attributes)

        self.set_style(OWCurve.Lines)
        if isinstance(color, tuple):
            self.set_pen(QPen(QColor(*color)))
        else:
            self.set_pen(QPen(QColor(color)))

        x_values = list(range(n_attributes)) * self.n_rows
        self.set_data(x_values, y_values)

    def update_properties(self):
        self.redraw_path()

    def redraw_path(self):
        self.path = QPainterPath()
        for segment in self.segment(self.data()):
            if self.fitted:
                self.draw_cubic_path(segment)
            else:
                self.draw_normal_path(segment)
        self._item.setPath(self.graph_transform().map(self.path))
        self._item.setPen(self.pen())

    def segment(self, data):
        for i in range(self.n_rows):
            yield data[i * self.n_attributes:(i + 1) * self.n_attributes]

    def draw_cubic_path(self, segment):
        for (x1, y1), (x2, y2) in zip(segment, segment[1:]):
            self.path.moveTo(x1, y1)
            self.path.cubicTo(QPointF(x1 + 0.5, y1),
                              QPointF(x2 - 0.5, y2), QPointF(x2, y2))

    def draw_normal_path(self, segment):
        if not segment:
            return

        x, y = segment[0]
        self.path.moveTo(x, y)
        for x, y in segment[1:]:
            self.path.lineTo(x, y)
开发者ID:RachitKansal,项目名称:orange3,代码行数:52,代码来源:owparallelgraph.py

示例4: update_properties

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [as 别名]
 def update_properties(self):
     p = self.plot()
     if p is None:
         return
     x_id, y_id = self.axes()
     rect = p.data_rect_for_axes(x_id, y_id)
     path = QPainterPath()
     if self._x_enabled and x_id in p.axes:
         for pos, label, size, _w in p.axes[x_id].ticks():
             path.moveTo(pos, rect.bottom())
             path.lineTo(pos, rect.top())
     if self._y_enabled and y_id in p.axes:
         for pos, label, size, _w in p.axes[y_id].ticks():
             path.moveTo(rect.left(), pos)
             path.lineTo(rect.right(), pos)
     self._path_item.setPath(self.graph_transform().map(path))
开发者ID:RachitKansal,项目名称:orange3,代码行数:18,代码来源:owtools.py

示例5: arrow_path_concave

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [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:PrimozGodec,项目名称:orange3,代码行数:49,代码来源:annotationitem.py

示例6: _define_symbols

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [as 别名]
def _define_symbols():
    """
    Add symbol ? to ScatterPlotItemSymbols,
    reflect the triangle to point upwards
    """
    symbols = pyqtgraph.graphicsItems.ScatterPlotItem.Symbols
    path = QPainterPath()
    path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))
    path.moveTo(-0.5, 0.5)
    path.lineTo(0.5, -0.5)
    path.moveTo(-0.5, -0.5)
    path.lineTo(0.5, 0.5)
    symbols["?"] = path

    tr = QTransform()
    tr.rotate(180)
    symbols['t'] = tr.map(symbols['t'])
开发者ID:mstrazar,项目名称:orange3,代码行数:19,代码来源:owscatterplotgraph.py

示例7: __init__

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [as 别名]
    def __init__(self, id, title='', title_above=False, title_location=AxisMiddle,
                 line=None, arrows=0, plot=None, bounds=None):
        QGraphicsItem.__init__(self)
        self.setFlag(QGraphicsItem.ItemHasNoContents)
        self.setZValue(AxisZValue)
        self.id = id
        self.title = title
        self.title_location = title_location
        self.data_line = line
        self.plot = plot
        self.graph_line = None
        self.size = None
        self.scale = None
        self.tick_length = (10, 5, 0)
        self.arrows = arrows
        self.title_above = title_above
        self.line_item = QGraphicsLineItem(self)
        self.title_item = QGraphicsTextItem(self)
        self.end_arrow_item = None
        self.start_arrow_item = None
        self.show_title = False
        self.scale = None
        path = QPainterPath()
        path.setFillRule(Qt.WindingFill)
        path.moveTo(0, 3.09)
        path.lineTo(0, -3.09)
        path.lineTo(9.51, 0)
        path.closeSubpath()
        self.arrow_path = path
        self.label_items = []
        self.label_bg_items = []
        self.tick_items = []
        self._ticks = []
        self.zoom_transform = QTransform()
        self.labels = None
        self.values = None
        self._bounds = bounds
        self.auto_range = None
        self.auto_scale = True

        self.zoomable = False
        self.update_callback = None
        self.max_text_width = 50
        self.text_margin = 5
        self.always_horizontal_text = False
开发者ID:RachitKansal,项目名称:orange3,代码行数:47,代码来源:owaxis.py

示例8: arrow_path_plain

# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import lineTo [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:ales-erjavec,项目名称:orange3,代码行数:41,代码来源:annotationitem.py


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