Beispiel #1
0
    def bounding_rect(self) -> QRectF:
        """
        Bounding rect

        Returns
        -------
        value : QRectF
        """
        c1, c2 = self.points_c1_c2()
        basic_rect = QRectF(self._out, self._in).normalized()
        c1c2_rect = QRectF(c1, c2).normalized()

        common_rect = basic_rect.united(c1c2_rect)
        corner_offset = QPointF(self._point_diameter, self._point_diameter)
        common_rect.setTopLeft(common_rect.topLeft() - corner_offset)
        common_rect.setBottomRight(common_rect.bottomRight() + 2 * corner_offset)
        return common_rect
Beispiel #2
0
 def get_shapes_bounding_rect(shapes, margin=0.0):
     rects = [shape.boundingRect() for shape in shapes]
     reduced = QRectF()
     for rect in rects:
         reduced = reduced.united(rect)
     return reduced.adjusted(-margin, -margin, margin, margin)
Beispiel #3
0
def get_bbox(items):
    r = QRectF()
    for it in items:
        r = r.united(it.boundingRect())
    return r