def _wrap_drawsegment(instance): obj_shape = instance.GetShape() if obj_shape is pcbnew.S_SEGMENT: return kicad.new(Segment, instance) if obj_shape is pcbnew.S_CIRCLE: return kicad.new(Circle, instance) if obj_shape is pcbnew.S_ARC: return kicad.new(Arc, instance)
def wrap(instance): """Wraps a wxPoint object from pcbnew and returns a Point one. This function should not be generally used, but it's provided as a helper when migrating old API code. :param instance: input wxPoint to wrap. :type instance: wxPoint :return: Point """ wrapped_point = kicad.new(Point, instance) wrapped_point._class = Point return wrapped_point
def _wrap_drawsegment(instance): obj_shape = instance.GetShape() if obj_shape is pcbnew.S_SEGMENT: return kicad.new(Segment, instance) if obj_shape is pcbnew.S_CIRCLE: return kicad.new(Circle, instance) if obj_shape is pcbnew.S_ARC: return kicad.new(Arc, instance) if obj_shape is pcbnew.S_POLYGON: return kicad.new(Polygon, instance) # Time to fail layer = instance.GetLayer() layer_str = pcbnew.BOARD_GetStandardLayerName(layer) unsupported = ['S_CURVE', 'S_RECT', 'S_LAST'] for unsup in unsupported: if obj_shape is getattr(pcbnew, unsup): raise TypeError('Unsupported shape type: pcbnew.{} on layer {}.'.format(unsup, layer_str)) raise TypeError('Unrecognized shape type on layer {}'.format(layer_str))
def wrap(instance): """Wraps a C++ api TRACK object, and returns a `Track`.""" return kicad.new(Zone, instance)
def wrap(instance): """Wraps a C++ api PAD object, and returns a `Pad`.""" return kicad.new(Pad, instance)
def wrap(instance): """Takes a wxSize instance and returns a Size class.""" wrapped_size = kicad.new(Size, instance) wrapped_size._class = Size return wrapped_size
def wrap(instance): if type(instance) is pcbnew.MODULE: return kicad.new(Module, instance)
def wrap(instance): if type(instance) is pcbnew.TEXTE_MODULE: return kicad.new(ModuleLabel, instance)
def wrap(instance): """Wraps a C++ api TRACK object, and returns a `Track`.""" return kicad.new(Track, instance)
def wrap(instance): if type(instance) is pcbnew.DRAWSEGMENT: return Drawing._wrap_drawsegment(instance) elif type(instance) is pcbnew.TEXTE_PCB: return kicad.new(TextPCB, instance)
def wrap(instance): return kicad.new(Net, instance)
def wrap(instance): """Wraps a C++/old api BOARD object, and returns a Board.""" return kicad.new(Board, instance)
def wrap(instance): """Wraps a C++/old api LSET object, and returns a LayerSet.""" return kicad.new(LayerSet, instance)
def wrap(instance): wrapped_bbox = kicad.new(BoundingBox, instance) wrapped_bbox._class = BoundingBox return wrapped_bbox
def wrap(instance): """Wraps a C++ api VIA object, and returns a `Via`.""" return kicad.new(Via, instance)