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


Python QLineF.intersect方法代码示例

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


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

示例1: paint

# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import intersect [as 别名]
    def paint(self, painter, option, widget=None):
        if self.my_start_item.collidesWithItem(self.my_end_item):
            return

        my_start_item = self.my_start_item
        my_end_item = self.my_end_item
        my_color = self.my_color
        my_pen = self.pen()
        my_pen.setColor(self.my_color)
        arrow_size = 20.0
        painter.setPen(my_pen)
        painter.setBrush(my_color)

        center_line = QLineF(my_start_item.pos(), my_end_item.pos())
        end_polygon = my_end_item.polygon

        p1 = end_polygon.first() + my_end_item.pos()

        intersect_point = QPointF()
        for i in end_polygon:
            p2 = i + my_end_item.pos()
            poly_line = QLineF(p1, p2)
            intersect_type = poly_line.intersect(center_line, intersect_point)
            if intersect_type == QLineF.BoundedIntersection:
                break
            p1 = p2

        self.setLine(QLineF(intersect_point, my_start_item.pos()))
        line = self.line()

        angle = math.acos(line.dx() / line.length())

        if line.dy() >= 0:
            angle = (math.pi * 2) - angle

        arrow_p1 = line.p1() + QPointF(math.sin(angle + math.pi / 3.0) * arrow_size,
                                       math.cos(angle + math.pi / 3) * arrow_size)
        arrow_p2 = line.p1() + QPointF(math.sin(angle + math.pi - math.pi / 3.0) * arrow_size,
                                       math.cos(angle + math.pi - math.pi / 3.0) * arrow_size)

        self.arrowHead.clear()
        for point in [line.p1(), arrow_p1, arrow_p2]:
            self.arrowHead.append(point)

        painter.drawLine(line)
        painter.drawPolygon(self.arrowHead)
        if self.isSelected():
            painter.setPen(QPen(my_color, 1, Qt.DashLine))
            my_line = QLineF(line)
            my_line.translate(0, 4.0)
            painter.drawLine(my_line)
            my_line.translate(0, -8.0)
            painter.drawLine(my_line)
开发者ID:ADobrodey,项目名称:Apache-Flume-Editor,代码行数:55,代码来源:_arrow.py

示例2: intersectLineGeometry

# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import intersect [as 别名]
 def intersectLineGeometry(self, lineGeo, breakShape):
     """
     Try to break lineGeo with the given breakShape. Will return the intersection points of lineGeo with breakShape.
     """
     # TODO geos should be abs
     intersections = []
     line = QLineF(lineGeo.Ps.x, lineGeo.Ps.y, lineGeo.Pe.x, lineGeo.Pe.y)
     for breakGeo in breakShape.geos.abs_iter():
         if isinstance(breakGeo, LineGeo):
             breakLine = QLineF(breakGeo.Ps.x, breakGeo.Ps.y, breakGeo.Pe.x, breakGeo.Pe.y)
             intersection = QPointF(0, 0)  # values do not matter
             res = line.intersect(breakLine, intersection)
             if res == QLineF.BoundedIntersection:
                 intersections.append(Point(intersection.x(), intersection.y()))
     return intersections
开发者ID:atmelino,项目名称:CNCMaker,代码行数:17,代码来源:breaks.py

示例3: intersection

# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import intersect [as 别名]
    def intersection(self, line):
        """
        Returns the intersection of the shape with the given line (in scene coordinates).
        :type line: QLineF
        :rtype: QPointF
        """
        intersection = QPointF()
        path = self.painterPath()
        polygon = self.mapToScene(path.toFillPolygon(self.transform()))

        for i in range(0, polygon.size() - 1):
            polyline = QLineF(polygon[i], polygon[i + 1])
            if polyline.intersect(line, intersection) == QLineF.BoundedIntersection:
                return intersection

        return None
开发者ID:gitter-badger,项目名称:eddy,代码行数:18,代码来源:base.py

示例4: __findRectIntersectionPoint

# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import intersect [as 别名]
 def __findRectIntersectionPoint(self, item, p1, p2):
     """
     Private method to find the intersetion point of a line with a
     rectangle.
     
     @param item item to check against
     @param p1 first point of the line (QPointF)
     @param p2 second point of the line (QPointF)
     @return the intersection point (QPointF)
     """
     rect = self.__mapRectFromItem(item)
     lines = [
         QLineF(rect.topLeft(), rect.topRight()),
         QLineF(rect.topLeft(), rect.bottomLeft()),
         QLineF(rect.bottomRight(), rect.bottomLeft()),
         QLineF(rect.bottomRight(), rect.topRight()),
     ]
     intersectLine = QLineF(p1, p2)
     intersectPoint = QPointF(0, 0)
     for line in lines:
         if intersectLine.intersect(line, intersectPoint) == QLineF.BoundedIntersection:
             return intersectPoint
     return QPointF(-1.0, -1.0)
开发者ID:testmana2,项目名称:eric,代码行数:25,代码来源:AssociationItem.py


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