def GetScaledEventPosition(event, dc, scaling):
    """
    Function that calculates the nearest point of the grid defined by scaling for the given point
    """
    pos = event.GetLogicalPosition(dc)
    if scaling:
        pos.x = round(pos.x / scaling[0]) * scaling[0]
        pos.y = round(pos.y / scaling[1]) * scaling[1]
    return pos
