Beispiel #1
0
    def __init__(self, start_point, rect_size, shape, position,
                 clockwise=True):
        ''' (QPointF, QSizeF, str in self.SHAPES, str in self.POSITIONS, bool)
        '''
        W, H = rect_size.width(), rect_size.height()

        vlarg('start_point', start_point, QPointF)
        vlarg('rect_size', rect_size, QSizeF)
        vlarg('position', position, str, self.POSITIONS)
        vlarg('shape', shape, str, self.SHAPES)
        vlarg('clockwise', clockwise, bool)

        GxPainterPath.__init__(self, start_point)

        if shape == 'trig':

            if clockwise:
                if position == 'top-right':
                    self.lineToInc(W, H)
                elif position == 'bottom-right':
                    self.lineToInc(-W, H)
                elif position == 'bottom-left':
                    self.lineToInc(-W, -H)
                elif position == 'top-left':
                    self.lineToInc(W, -H)
            else:
                if position == 'top-left':
                    self.lineToInc(-W, H)
                elif position == 'bottom-left':
                    self.lineToInc(W, H)
                elif position == 'bottom-right':
                    self.lineToInc(W, -H)
                elif position == 'top-right':
                    self.lineToInc(-W, -H)

        elif shape == 'arc':

            if clockwise:
                if position == 'top-right':
                    self.arcTo(self.x - W, self.y, 2*W, 2*H, -270, -90)
                elif position == 'bottom-right':
                    self.arcTo(self.x - 2*W, self.y - H, 2*W, 2*H, 0, -90)
                elif position == 'bottom-left':
                    self.arcTo(self.x - W, self.y - 2*H, 2*W, 2*H, -90, -90)
                elif position == 'top-left':
                    self.arcTo(self.x, self.y - H, 2*W, 2*H, -180, -90)
            else:
                if position == 'top-left':
                    self.arcTo(self.x - W, self.y, 2*W, 2*H, 90, 90)
                elif position == 'bottom-left':
                    self.arcTo(self.x, self.y - H, 2*W, 2*H, 180, 90)
                elif position == 'bottom-right':
                    self.arcTo(self.x - W, self.y - 2*H, 2*W, 2*H, 270, 90)
                elif position == 'top-right':
                    self.arcTo(self.x - 2*W, self.y - H, 2*W, 2*H, 0, 90)

        elif shape == 'rect':

            if clockwise:
                if position == 'top-right':
                    self.lineToInc(dx = W)
                    self.lineToInc(dy = H)
                elif position == 'bottom-right':
                    self.lineToInc(dy = H)
                    self.lineToInc(dx = -W)
                elif position == 'bottom-left':
                    self.lineToInc(dx = -W)
                    self.lineToInc(dy = -H)
                elif position == 'top-left':
                    self.lineToInc(dy = -H)
                    self.lineToInc(dx = W)
            else:
                if position == 'top-left':
                    self.lineToInc(dx = -W)
                    self.lineToInc(dy = H)
                elif position == 'bottom-left':
                    self.lineToInc(dy = H)
                    self.lineToInc(dx = W)
                elif position == 'bottom-right':
                    self.lineToInc(dx = W)
                    self.lineToInc(dy = -H)
                elif position == 'top-right':
                    self.lineToInc(dy = -H)
                    self.lineToInc(dx = -W)
Beispiel #2
0
    def updateMetrics(self):
        ''' () -> NoneType

        Update its border path based on its size, by properly connecting
        the notch and corner paths.
        '''
        self.prepareGeometryChange()

        path = GxPainterPath(QPointF(100, 0))

        path.lineToInc(dx = 100)
        path.connectPath(self.getNotch(path, 'top', '+i'))
        path.lineToInc(dx = 100)
        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['tr'],
                                    self.corner_shape['tr'], 'top-right'))
        path.lineToInc(dy = 50)
        path.connectPath(self.getNotch(path, 'right', '+j'))
        path.lineToInc(dy = 50)
        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['br'],
                                    self.corner_shape['br'], 'bottom-right'))
        path.lineToInc(dx = -100)
        path.connectPath(self.getNotch(path, 'bottom', '-i'))
        path.lineToInc(dx = -100)

        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['bl'],
                                    self.corner_shape['bl'], 'bottom-left'))
        path.lineToInc(dy = -50)
        path.connectPath(self.getNotch(path, 'left', '-j'))
        path.lineToInc(dy = -50)
        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['tl'],
                                    self.corner_shape['tl'], 'top-left'))

        self.border_path = path

        self._width = path.boundingRect().width()
        self._height = path.boundingRect().height()
        self.update()
Beispiel #3
0
    def __init__(self, start_point, rect_size, shape, place, clockwise=True):
        '''        
        :param start_point: ``QPointF``
            Point from where this path will begin to draw.
        :param rect_size: ``QSizeF``
            Size of the bounding rectangle of the corner area.
            This is used to calculate the final point of the corner path.
        :param shape: ``str`` in ``self.VALID_SHAPES``
            Indicates the appearence of the corner path.
        :param place: ``str`` in ``self.VALID_PLACES``
            Indicates what kind of corner this will be on the final picture.
        :param clockwise: ``bool``
            Direction of the drawing. 
        '''
        W, H = rect_size.width(), rect_size.height()

        GxPainterPath.__init__(self, start_point)

        if shape == 'trig':

            if clockwise:
                if place == 'top-right':
                    self.lineToInc(W, H)
                elif place == 'bottom-right':
                    self.lineToInc(-W, H)
                elif place == 'bottom-left':
                    self.lineToInc(-W, -H)
                elif place == 'top-left':
                    self.lineToInc(W, -H)
            else:
                if place == 'top-left':
                    self.lineToInc(-W, H)
                elif place == 'bottom-left':
                    self.lineToInc(W, H)
                elif place == 'bottom-right':
                    self.lineToInc(W, -H)
                elif place == 'top-right':
                    self.lineToInc(-W, -H)

        elif shape == 'arc':

            if clockwise:
                if place == 'top-right':
                    self.arcTo(self.x - W, self.y, 2*W, 2*H, -270, -90)
                elif place == 'bottom-right':
                    self.arcTo(self.x - 2*W, self.y - H, 2*W, 2*H, 0, -90)
                elif place == 'bottom-left':
                    self.arcTo(self.x - W, self.y - 2*H, 2*W, 2*H, -90, -90)
                elif place == 'top-left':
                    self.arcTo(self.x, self.y - H, 2*W, 2*H, -180, -90)
            else:
                if place == 'top-left':
                    self.arcTo(self.x - W, self.y, 2*W, 2*H, 90, 90)
                elif place == 'bottom-left':
                    self.arcTo(self.x, self.y - H, 2*W, 2*H, 180, 90)
                elif place == 'bottom-right':
                    self.arcTo(self.x - W, self.y - 2*H, 2*W, 2*H, 270, 90)
                elif place == 'top-right':
                    self.arcTo(self.x - 2*W, self.y - H, 2*W, 2*H, 0, 90)

        elif shape == 'rect':

            if clockwise:
                if place == 'top-right':
                    self.lineToInc(dx = W)
                    self.lineToInc(dy = H)
                elif place == 'bottom-right':
                    self.lineToInc(dy = H)
                    self.lineToInc(dx = -W)
                elif place == 'bottom-left':
                    self.lineToInc(dx = -W)
                    self.lineToInc(dy = -H)
                elif place == 'top-left':
                    self.lineToInc(dy = -H)
                    self.lineToInc(dx = W)
            else:
                if place == 'top-left':
                    self.lineToInc(dx = -W)
                    self.lineToInc(dy = H)
                elif place == 'bottom-left':
                    self.lineToInc(dy = H)
                    self.lineToInc(dx = W)
                elif place == 'bottom-right':
                    self.lineToInc(dx = W)
                    self.lineToInc(dy = -H)
                elif place == 'top-right':
                    self.lineToInc(dy = -H)
                    self.lineToInc(dx = -W)
Beispiel #4
0
    def updateMetrics(self):
        ''' () -> NoneType

        Update its border path based on its size, by properly connecting
        the notch and corner paths.
        '''
        self.prepareGeometryChange()

        path = GxPainterPath(QPointF(100, 0))

        path.lineToInc(dx = 100)
        path.connectPath(self.getNotch(path, 'top', '+i'))
        path.lineToInc(dx = 100)
        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['tr'],
                                    self.corner_shape['tr'], 'top-right'))
        path.lineToInc(dy = 50)
        path.connectPath(self.getNotch(path, 'right', '+j'))
        path.lineToInc(dy = 50)
        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['br'],
                                    self.corner_shape['br'], 'bottom-right'))
        path.lineToInc(dx = -100)
        path.connectPath(self.getNotch(path, 'bottom', '-i'))
        path.lineToInc(dx = -100)

        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['bl'],
                                    self.corner_shape['bl'], 'bottom-left'))
        path.lineToInc(dy = -50)
        path.connectPath(self.getNotch(path, 'left', '-j'))
        path.lineToInc(dy = -50)
        path.connectPath(CornerPath(path.currentPosition(), self.corner_size['tl'],
                                    self.corner_shape['tl'], 'top-left'))

        self.border_path = path

        self._width = path.boundingRect().width()
        self._height = path.boundingRect().height()
        self.update()
Beispiel #5
0
    def __init__(self, start_point, rect_size, shape, place, clockwise=True):
        """        
        :param start_point: ``QPointF``
            Point from where this path will begin to draw.
        :param rect_size: ``QSizeF``
            Size of the bounding rectangle of the corner area.
            This is used to calculate the final point of the corner path.
        :param shape: ``str`` in ``self.VALID_SHAPES``
            Indicates the appearence of the corner path.
        :param place: ``str`` in ``self.VALID_PLACES``
            Indicates what kind of corner this will be on the final picture.
        :param clockwise: ``bool``
            Direction of the drawing. 
        """
        W, H = rect_size.width(), rect_size.height()

        GxPainterPath.__init__(self, start_point)

        if shape == "trig":

            if clockwise:
                if place == "top-right":
                    self.lineToInc(W, H)
                elif place == "bottom-right":
                    self.lineToInc(-W, H)
                elif place == "bottom-left":
                    self.lineToInc(-W, -H)
                elif place == "top-left":
                    self.lineToInc(W, -H)
            else:
                if place == "top-left":
                    self.lineToInc(-W, H)
                elif place == "bottom-left":
                    self.lineToInc(W, H)
                elif place == "bottom-right":
                    self.lineToInc(W, -H)
                elif place == "top-right":
                    self.lineToInc(-W, -H)

        elif shape == "arc":

            if clockwise:
                if place == "top-right":
                    self.arcTo(self.x - W, self.y, 2 * W, 2 * H, -270, -90)
                elif place == "bottom-right":
                    self.arcTo(self.x - 2 * W, self.y - H, 2 * W, 2 * H, 0, -90)
                elif place == "bottom-left":
                    self.arcTo(self.x - W, self.y - 2 * H, 2 * W, 2 * H, -90, -90)
                elif place == "top-left":
                    self.arcTo(self.x, self.y - H, 2 * W, 2 * H, -180, -90)
            else:
                if place == "top-left":
                    self.arcTo(self.x - W, self.y, 2 * W, 2 * H, 90, 90)
                elif place == "bottom-left":
                    self.arcTo(self.x, self.y - H, 2 * W, 2 * H, 180, 90)
                elif place == "bottom-right":
                    self.arcTo(self.x - W, self.y - 2 * H, 2 * W, 2 * H, 270, 90)
                elif place == "top-right":
                    self.arcTo(self.x - 2 * W, self.y - H, 2 * W, 2 * H, 0, 90)

        elif shape == "rect":

            if clockwise:
                if place == "top-right":
                    self.lineToInc(dx=W)
                    self.lineToInc(dy=H)
                elif place == "bottom-right":
                    self.lineToInc(dy=H)
                    self.lineToInc(dx=-W)
                elif place == "bottom-left":
                    self.lineToInc(dx=-W)
                    self.lineToInc(dy=-H)
                elif place == "top-left":
                    self.lineToInc(dy=-H)
                    self.lineToInc(dx=W)
            else:
                if place == "top-left":
                    self.lineToInc(dx=-W)
                    self.lineToInc(dy=H)
                elif place == "bottom-left":
                    self.lineToInc(dy=H)
                    self.lineToInc(dx=W)
                elif place == "bottom-right":
                    self.lineToInc(dx=W)
                    self.lineToInc(dy=-H)
                elif place == "top-right":
                    self.lineToInc(dy=-H)
                    self.lineToInc(dx=-W)
Beispiel #6
0
    def updateMetrics(self):
        """ () -> NoneType

        Update its border path based on its size, by properly connecting
        the notch and corner paths.
        """
        self.prepareGeometryChange()

        path = GxPainterPath(QPointF(100, 0))

        path.lineToInc(dx=100)
        path.connectPath(self.getNotch(path, "top", "+i"))
        path.lineToInc(dx=100)
        path.connectPath(
            CornerPath(path.currentPosition(), self.corner_size["tr"], self.corner_shape["tr"], "top-right")
        )
        path.lineToInc(dy=50)
        path.connectPath(self.getNotch(path, "right", "+j"))
        path.lineToInc(dy=50)
        path.connectPath(
            CornerPath(path.currentPosition(), self.corner_size["br"], self.corner_shape["br"], "bottom-right")
        )
        path.lineToInc(dx=-100)
        path.connectPath(self.getNotch(path, "bottom", "-i"))
        path.lineToInc(dx=-100)

        path.connectPath(
            CornerPath(path.currentPosition(), self.corner_size["bl"], self.corner_shape["bl"], "bottom-left")
        )
        path.lineToInc(dy=-50)
        path.connectPath(self.getNotch(path, "left", "-j"))
        path.lineToInc(dy=-50)
        path.connectPath(
            CornerPath(path.currentPosition(), self.corner_size["tl"], self.corner_shape["tl"], "top-left")
        )

        self.border_path = path

        self._width = path.boundingRect().width()
        self._height = path.boundingRect().height()
        self.update()