def RouteToManhattanRelativeToPosition(**kwargs): """ route a port to a horizontal pointing east at a coordinate value larger/smaller than or equal to the given position (coordinate is x for EAST/WEST direction, and y for NORTH/SOUTH) relation is either '>' or '<' """ direction = extract_kwarg(kwargs, "direction") relation = extract_kwarg(kwargs, "relation") position = extract_kwarg(kwargs, "position") if not direction in [EAST, WEST, NORTH, SOUTH]: raise AttributeError( "direction of RouteToManhattanBeyondPosition must be EAST, WEST, NORTH or SOUTH" ) if not relation in ['<', '>']: raise AttributeError( "relation in RouteToManhattanBeyondPosition must be '<' (smaller than) or '>' (larger than)" ) R = RouteToAngle(angle_out=angle_deg(direction), allow_unmatched_kwargs=True, **kwargs) if direction in [NORTH, SOUTH]: pos_coord = Coord2(position, 0.0) out_coord = R.out_ports[0].x else: pos_coord = Coord2(0, position) out_coord = R.out_ports[0].y if relation == '<': if out_coord <= position: return R else: if out_coord >= position: return R return RouteToLine(line_point=pos_coord, angle_out=angle_deg(direction), **kwargs)
def RouteToEastAtMinY(**kwargs): """ route a port to a horizontal pointing east at a y-value larger than or equal to y_position """ y_position = extract_kwarg(kwargs, "y_position") R = RouteToEast(allow_unmatched_kwargs=True, **kwargs) if R.out_ports[0].y >= y_position: return R else: return RouteToLine(line_point=(0.0, y_position), **kwargs)
def RouteToSouthAtMinX(**kwargs): """ route a port to a vertical pointing down at a x-value larger than or equal to y_position """ x_position = extract_kwarg(kwargs, "x_position") R = RouteToSouth(allow_unmatched_kwargs=True, **kwargs) if R.out_ports[0].x >= x_position: return R else: return RouteToLine( line_point=(x_position, 0.0), angle_out=-90.0, **kwargs)
def RouteToWestAtMaxY(**kwargs): """ route a port to a horizontal pointing west at a y-value smaller than or equal to y_position """ y_position = extract_kwarg(kwargs, "y_position") R = RouteToWest(allow_unmatched_kwargs=True, **kwargs) if R.out_ports[0].y <= y_position: return R else: return RouteToLine( line_point=(0.0, y_position), angle_out=180.0, **kwargs)