예제 #1
0
    def getBounds(self):
        xPos = self.xPos
        xDest = self.xDest
        yPos = self.yPos
        yDest = self.yDest
        width = self.tool.getWidth()
        height = self.tool.getHeight()
        r = CityRect()

        r.x = xPos
        if width >= 3:
            r.x -= 1
        if xDest >= xPos:
            r.width = ((xDest - xPos) / width + 1) * width
        else:
            r.width = ((xPos - xDest) / width + 1) * height
            r.x += width - r.width

        r.y = yPos
        if height >= 3:
            r.y -= 1
        if yDest > yPos:
            r.height = ((yDest - yPos) / height + 1) * height
        else:
            # tool dragged upwards
            r.height = (((yPos - yDest) / height) + 1) * height
            r.y -= r.height - height

        return r
예제 #2
0
    def getBounds(self):
        xPos = self.xPos
        xDest = self.xDest
        yPos = self.yPos
        yDest = self.yDest
        width = self.tool.getWidth()
        height = self.tool.getHeight()
        r = CityRect()

        r.x = xPos
        if width >= 3:
            r.x -= 1
        if xDest >= xPos:
            r.width = ((xDest - xPos) / width + 1) * width
        else:
            r.width = ((xPos - xDest) / width + 1) * height
            r.x += width - r.width

        r.y = yPos
        if height >= 3:
            r.y -= 1
        if yDest > yPos:
            r.height = ((yDest - yPos) / height + 1) * height
        else:
            # tool dragged upwards
            r.height = (((yPos - yDest) / height) + 1) * height
            r.y -= r.height - height

        return r
예제 #3
0
    def onToolHover(self, x, y):
        if (self.currentTool is None
                or self.currentTool.type == micropolistool.QUERY):
            self.cityView.setToolCursor(None)
            return

        loc = self.cityView.screenCoordsToCityLocation(x, y)
        x = loc.x
        y = loc.y
        w = self.currentTool.getWidth()
        h = self.currentTool.getHeight()

        if w >= 3:
            x -= 1
        if h >= 3:
            y -= 1

        rect = CityRect(x, y, w, h)
        self.cityView.newToolCursor(rect, self.currentTool)
예제 #4
0
    def getBounds(self):
        ''' constrain bounds to be rectangle with
            either width of height equal to one '''

        assert self.tool.getWidth() == 1
        assert self.tool.getHeight() == 1

        xDest = self.xDest
        xPos = self.xPos
        yDest = self.yDest
        yPos = self.yPos

        if abs(xDest - xPos) >= abs(yDest - yPos):
            # horizontal line
            r = CityRect()
            r.x = min(xPos, xDest)
            r.width = abs(xDest - xPos) + 1
            r.y = yPos
            r.height = 1
            return r
        else:
            # vertical line
            r = CityRect()
            r.x = xPos
            r.width = 1
            r.y = min(yPos, yDest)
            r.height = abs(yDest - yPos) + 1
            return r
예제 #5
0
 def getBounds(self):
     return CityRect(-self.offsetX, -self.offsetY, self.getWidth(),
                     self.getHeight())