示例#1
0
文件: _anchors.py 项目: pikers/piker
def gpath_pin(
    gpath: QGraphicsPathItem,
    label: Label,  # noqa
    location_description: str = 'right-of-path-centered',
    use_right_of_pp_label: bool = False,
) -> QPointF:

    # get actual arrow graphics path
    path_br = gpath.mapToScene(gpath.path()).boundingRect()

    # label.vb.locate(label.txt)  #, children=True)

    if location_description == 'right-of-path-centered':
        return path_br.topRight() - QPointF(label.h / 16, label.h / 3)

    if location_description == 'left-of-path-centered':
        return path_br.topLeft() - QPointF(label.w, label.h / 6)

    elif location_description == 'below-path-left-aligned':
        return path_br.bottomLeft() - QPointF(0, label.h / 6)

    elif location_description == 'below-path-right-aligned':
        return path_br.bottomRight() - QPointF(label.w, label.h / 6)