Пример #1
0
    def calculatePosition( self, e ):
        # only needs x_move here as y is calculated dependently on x
        x_move = e.pos().x() - self.xOnWidget

        p = CST.toCcsCoord( self.ccs, self.x, self.y, self,
                            self.parent )
        x = p.x() + x_move

        p = CST.fromCcsCoord( self.ccs, x, 0, self, self.parent )
        self.x = p.x()
        self.setPosition()
Пример #2
0
    def calculatePosition(self, e):
        """Calculates its position after a move. Can easily
        overwritten by subclasses to get different behaviour"""

        # these calculations are in widget coordinates.
        x_move = e.pos().x() - self.xOnWidget
        y_move = e.pos().y() - self.yOnWidget
            
        p = CST.toCcsCoord( self.ccs, self.x, self.y, self, self.parent )
           
        x = p.x() + x_move
        y = p.y() + y_move
           
        self.setPos(QPointF(x, y))
           
        # self.x and self.y need to be adjusted, too.
        p = CST.fromCcsCoord( self.ccs, x,y, self, self.parent )
        self.x = p.x()
        self.y = p.y()