Exemplo n.º 1
0
    def rotate(self, x, y, rot):
        """
        TOWRITE

        :param `x`: TOWRITE
        :type `x`: qreal
        :param `y`: TOWRITE
        :type `y`: qreal
        :param `rot`: TOWRITE
        :type `rot`: qreal
        """
        rad = radians(rot)  # qreal
        cosRot = qCos(rad)  # qreal
        sinRot = qSin(rad)  # qreal
        px = self.object.scenePos().x()  # qreal
        py = self.object.scenePos().y()  # qreal
        px -= x
        py -= y
        rotX = px * cosRot - py * sinRot  # qreal
        rotY = px * sinRot + py * cosRot  # qreal
        rotX += x
        rotY += y

        self.object.setPos(rotX, rotY)
        self.object.setRotation(self.object.rotation() + rot)
Exemplo n.º 2
0
    def objectQuadrant270(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        halfH = self.objectHeight() / 2.0       # qreal
        rot = radians(self.rotation() + 270.0)  # qreal
        x = halfH * qCos(rot)                   # qreal
        y = halfH * qSin(rot)                   # qreal
        return self.objectCenter() + QPointF(x, y)
Exemplo n.º 3
0
    def objectQuadrant270(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        halfH = self.objectHeight() / 2.0  # qreal
        rot = radians(self.rotation() + 270.0)  # qreal
        x = halfH * qCos(rot)  # qreal
        y = halfH * qSin(rot)  # qreal
        return self.objectCenter() + QPointF(x, y)
Exemplo n.º 4
0
    def objectQuadrant180(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        halfW = self.objectWidth() / 2.0        # qreal
        rot = radians(self.rotation() + 180.0)  # qreal
        x = halfW * qCos(rot)                   # qreal
        y = halfW * qSin(rot)                   # qreal
        return self.objectCenter() + QPointF(x, y)
Exemplo n.º 5
0
    def objectQuadrant180(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        halfW = self.objectWidth() / 2.0  # qreal
        rot = radians(self.rotation() + 180.0)  # qreal
        x = halfW * qCos(rot)  # qreal
        y = halfW * qSin(rot)  # qreal
        return self.objectCenter() + QPointF(x, y)
Exemplo n.º 6
0
    def objectEndPoint(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(self.rotation())      # qreal
        cosRot = qCos(rot)                  # qreal
        sinRot = qSin(rot)                  # qreal
        x = arcEndPoint.x() * self.scale()  # qreal
        y = arcEndPoint.y() * self.scale()  # qreal
        rotX = x * cosRot - y * sinRot      # qreal
        rotY = x * sinRot + y * cosRot      # qreal

        return (self.scenePos() + QPointF(rotX, rotY))
Exemplo n.º 7
0
    def objectEndPoint2(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        lyne = self.line()  # QLineF
        rot = radians(self.rotation())  # qreal
        cosRot = qCos(rot)  # qreal
        sinRot = qSin(rot)  # qreal
        x2 = lyne.x2() * self.scale()  # qreal
        y2 = lyne.y2() * self.scale()  # qreal
        rotEnd2X = x2 * cosRot - y2 * sinRot  # qreal
        rotEnd2Y = x2 * sinRot + y2 * cosRot  # qreal

        return (self.scenePos() + QPointF(rotEnd2X, rotEnd2Y))
Exemplo n.º 8
0
    def objectEndPoint2(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        lyne = self.line()  # QLineF
        rot = radians(self.rotation())        # qreal
        cosRot = qCos(rot)                    # qreal
        sinRot = qSin(rot)                    # qreal
        x2 = lyne.x2() * self.scale()         # qreal
        y2 = lyne.y2() * self.scale()         # qreal
        rotEnd2X = x2 * cosRot - y2 * sinRot  # qreal
        rotEnd2Y = x2 * sinRot + y2 * cosRot  # qreal

        return (self.scenePos() + QPointF(rotEnd2X, rotEnd2Y))
Exemplo n.º 9
0
    def objectMidPoint(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        lyne = self.line()  # QLineF
        mp = lyne.pointAt(0.5)  # QPointF
        rot = radians(self.rotation())       # qreal
        cosRot = qCos(rot)                   # qreal
        sinRot = qSin(rot)                   # qreal
        mx = mp.x() * self.scale()           # qreal
        my = mp.y() * self.scale()           # qreal
        rotMidX = mx * cosRot - my * sinRot  # qreal
        rotMidY = mx * sinRot + my * cosRot  # qreal

        return (self.scenePos() + QPointF(rotMidX, rotMidY))
Exemplo n.º 10
0
    def objectMidPoint(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        lyne = self.line()  # QLineF
        mp = lyne.pointAt(0.5)  # QPointF
        rot = radians(self.rotation())  # qreal
        cosRot = qCos(rot)  # qreal
        sinRot = qSin(rot)  # qreal
        mx = mp.x() * self.scale()  # qreal
        my = mp.y() * self.scale()  # qreal
        rotMidX = mx * cosRot - my * sinRot  # qreal
        rotMidY = mx * sinRot + my * cosRot  # qreal

        return (self.scenePos() + QPointF(rotMidX, rotMidY))
Exemplo n.º 11
0
    def objectBottomRight(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(self.rotation())  # qreal
        cosRot = qCos(rot)  # qreal
        sinRot = qSin(rot)  # qreal

        br = self.rect().bottomRight()  # QPointF
        pbrX = br.x() * self.scale()  # qreal
        pbrY = br.y() * self.scale()  # qreal
        pbrXrot = pbrX * cosRot - pbrY * sinRot  # qreal
        pbrYrot = pbrX * sinRot + pbrY * cosRot  # qreal

        return (self.scenePos() + QPointF(pbrXrot, pbrYrot))
Exemplo n.º 12
0
    def objectBottomLeft(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(rotation())  # qreal
        cosRot = qCos(rot)         # qreal
        sinRot = qSin(rot)         # qreal

        bl = self.rect().bottomLeft()  # QPointF
        pblX = bl.x() * scale()                  # qreal
        pblY = bl.y() * scale()                  # qreal
        pblXrot = pblX * cosRot - pblY * sinRot  # qreal
        pblYrot = pblX * sinRot + pblY * cosRot  # qreal

        return (self.scenePos() + QPointF(pblXrot, pblYrot))
Exemplo n.º 13
0
    def objectTopRight(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(self.rotation())  # qreal
        cosRot = qCos(rot)  # qreal
        sinRot = qSin(rot)  # qreal

        tr = self.rect().topRight()  # QPointF
        ptrX = tr.x() * self.scale()  # qreal
        ptrY = tr.y() * self.scale()  # qreal
        ptrXrot = ptrX * cosRot - ptrY * sinRot  # qreal
        ptrYrot = ptrX * sinRot + ptrY * cosRot  # qreal

        return (self.scenePos() + QPointF(ptrXrot, ptrYrot))
Exemplo n.º 14
0
    def objectTopRight(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(self.rotation())  # qreal
        cosRot = qCos(rot)              # qreal
        sinRot = qSin(rot)              # qreal

        tr = self.rect().topRight()  # QPointF
        ptrX = tr.x() * self.scale()             # qreal
        ptrY = tr.y() * self.scale()             # qreal
        ptrXrot = ptrX * cosRot - ptrY * sinRot  # qreal
        ptrYrot = ptrX * sinRot + ptrY * cosRot  # qreal

        return (self.scenePos() + QPointF(ptrXrot, ptrYrot))
Exemplo n.º 15
0
    def objectTopLeft(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(rotation())  # qreal
        cosRot = qCos(rot)         # qreal
        sinRot = qSin(rot)         # qreal

        tl = self.rect().topLeft()  # QPointF
        ptlX = tl.x() * self.scale()             # qreal
        ptlY = tl.y() * self.scale()             # qreal
        ptlXrot = ptlX * cosRot - ptlY * sinRot  # qreal
        ptlYrot = ptlX * sinRot + ptlY * cosRot  # qreal

        return (self.scenePos() + QPointF(ptlXrot, ptlYrot))
Exemplo n.º 16
0
    def objectBottomRight(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(self.rotation())  # qreal
        cosRot = qCos(rot)              # qreal
        sinRot = qSin(rot)              # qreal

        br = self.rect().bottomRight()  # QPointF
        pbrX = br.x() * self.scale()             # qreal
        pbrY = br.y() * self.scale()             # qreal
        pbrXrot = pbrX * cosRot - pbrY * sinRot  # qreal
        pbrYrot = pbrX * sinRot + pbrY * cosRot  # qreal

        return (self.scenePos() + QPointF(pbrXrot, pbrYrot))
Exemplo n.º 17
0
    def objectTopLeft(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(rotation())  # qreal
        cosRot = qCos(rot)  # qreal
        sinRot = qSin(rot)  # qreal

        tl = self.rect().topLeft()  # QPointF
        ptlX = tl.x() * self.scale()  # qreal
        ptlY = tl.y() * self.scale()  # qreal
        ptlXrot = ptlX * cosRot - ptlY * sinRot  # qreal
        ptlYrot = ptlX * sinRot + ptlY * cosRot  # qreal

        return (self.scenePos() + QPointF(ptlXrot, ptlYrot))
Exemplo n.º 18
0
    def objectBottomLeft(self):
        """
        TOWRITE

        :rtype: `QPointF`_
        """
        rot = radians(rotation())  # qreal
        cosRot = qCos(rot)  # qreal
        sinRot = qSin(rot)  # qreal

        bl = self.rect().bottomLeft()  # QPointF
        pblX = bl.x() * scale()  # qreal
        pblY = bl.y() * scale()  # qreal
        pblXrot = pblX * cosRot - pblY * sinRot  # qreal
        pblYrot = pblX * sinRot + pblY * cosRot  # qreal

        return (self.scenePos() + QPointF(pblXrot, pblYrot))