def __str__(self): # A X Y radius start end part dmg pen fill Xstart Ystart Xend Yend start = Point(distance = self.radius, angle = self.angle_start/10).translate(self.at) end = Point(distance = self.radius, angle = self.angle_end/10).translate(self.at) return 'A {cp:s} {r:d} {angle_start:d} {angle_end:d} {unit_idx:d} {deMorgan_idx:d} {line_width:d} {fill:s} {p_start:s} {p_end:s}\n'.format( cp = self.at, r = self.radius, angle_start = self.angle_start, angle_end = self.angle_end, unit_idx = self.unit_idx, deMorgan_idx = self.deMorgan_idx, fill = self.fill, line_width = self.line_width, p_start = start, p_end = end )
def __init__(self, start, end, **kwargs): self.start = Point(start) self.end = Point(end) self.unit_idx = int(kwargs.get('unit_idx', 1)) self.deMorgan_idx = int(kwargs.get('deMorgan_idx', 1)) self.line_width = int(kwargs.get('line_width', 10)) fill = kwargs.get('fill', ElementFill.NO_FILL) if isinstance(fill, ElementFill): self.fill = fill else: raise TypeError('fill needs to be of type ElementFill')
def toPolyline(self): p1 = Point(self.start) p3 = Point(self.end) p2 = Point(p1.x, p3.y) p4 = Point(p3.x, p1.y) points = [p1, p2, p3, p4, p1] polyline = DrawingPolyline( points=points, unit_idx=self.unit_idx, deMorgan_idx=self.deMorgan_idx, line_width=self.line_width, fill=self.fill ) return polyline
def __init__(self, at, number, **kwargs): self.at = Point(at) self.num = number self.name = str(kwargs.get('name', self.num)) self.unit_idx = int(kwargs.get('unit_idx', 1)) self.deMorgan_idx = int(kwargs.get('deMorgan_idx', 1)) self.pin_length = int(kwargs.get('pin_length', 100)) self.fontsize_pinnumber = int(kwargs.get('sizenumber', 50)) self.fontsize_pinname = int(kwargs.get('sizename', self.fontsize_pinnumber)) el_type = kwargs.get('el_type', DrawingPin.PinElectricalType.EL_TYPE_PASSIVE) if isinstance(el_type, DrawingPin.PinElectricalType): self.el_type = el_type else: raise TypeError('el_type needs to be of type PinElectricalType') visibility = kwargs.get('visibility', DrawingPin.PinVisibility.VISIBLE) if isinstance(visibility, DrawingPin.PinVisibility): self.visibility = visibility else: raise TypeError('visibility needs to be of type PinVisibility') style = kwargs.get('style', DrawingPin.PinStyle.SHAPE_LINE) if isinstance(style, DrawingPin.PinStyle): self.style = style else: raise TypeError('style needs to be of type PinStyle') orientation = kwargs.get('orientation', DrawingPin.PinOrientation.LEFT) if isinstance(orientation, DrawingPin.PinOrientation): self.orientation = orientation else: raise TypeError('orientation needs to be of type PinOrientation')
def __init__(self, **kwargs): self.idx = int(kwargs['idx']) self.value = str(kwargs['value']) self.at = Point(kwargs.get('at'), {}) self.fontsize = int(kwargs.get('fontsize', 50)) if self.idx == 0: self.name = 'reference' elif self.idx == 1: self.name = 'value' elif self.idx == 2: self.name = 'footprint' elif self.idx == 3: self.name = 'datasheet' else: self.name = kwargs.get('name', 'F{:d}'.format(self.idx)) orientation = kwargs.get('orientation', SymbolField.FieldOrientation.HORIZONTAL) if isinstance(orientation, SymbolField.FieldOrientation): self.orientation = orientation else: raise TypeError('orientation needs to be of type FieldOrientation') visibility = kwargs.get( 'visibility', SymbolField.FieldVisibility.VISIBLE if self.idx < 2 else SymbolField.FieldVisibility.INVISIBLE) if isinstance(visibility, SymbolField.FieldVisibility): self.visibility = visibility else: raise TypeError('visibility needs to be of type FieldVisibility') alignment_horizontal = kwargs.get('alignment_horizontal', SymbolField.FieldAlignment.CENTER) if isinstance(alignment_horizontal, SymbolField.FieldAlignment): self.alignment_horizontal = alignment_horizontal else: raise TypeError( 'alignment_horizontal needs to be of type FieldAlignment') alignment_vertical = kwargs.get('alignment_vertical', SymbolField.FieldAlignment.CENTER) if isinstance(alignment_vertical, SymbolField.FieldAlignment): self.alignment_vertical = alignment_vertical else: raise TypeError( 'alignment_horizontal needs to be of type FieldAlignment') fontweight = kwargs.get('fontweight', SymbolField.FieldFontWeight.NORMAL) if isinstance(fontweight, SymbolField.FieldFontWeight): self.fontweight = fontweight else: raise TypeError('fontweight needs to be of type FieldFontWeight') fontstyle = kwargs.get('fontstyle', SymbolField.FieldFontStyle.NORMAL) if isinstance(fontstyle, SymbolField.FieldFontStyle): self.fontstyle = fontstyle else: raise TypeError('fontstyle needs to be of type FieldFontStyle')
def rotate(self, angle, origin = None, apply_on_copy = False): # obj = self if not apply_on_copy else deepcopy(self) if not apply_on_copy: raise NotImplementedError('Rotating the rectangles only implemented for copies -> converts to polyline') if origin is None: origin = Point((self.start.x + self.end.x)/2, (self.start.y + self.end.y)/2) obj = self.toPolyline() obj.rotate(angle, origin, False) return obj
def __init__(self, at, radius, **kwargs): self.at = Point(at) self.radius = int(radius) self.unit_idx = int(kwargs.get('unit_idx', 1)) self.deMorgan_idx = int(kwargs.get('deMorgan_idx', 1)) self.line_width = int(kwargs.get('line_width', 10)) fill = kwargs.get('fill', ElementFill.NO_FILL) if isinstance(fill, ElementFill): self.fill = fill else: raise TypeError('fill needs to be of type ElementFill')
def __init__(self, at, radius, angle_start, angle_end, **kwargs): self.at = Point(at) self.radius = int(radius) self.angle_start = DrawingArc.__normalizeAngle(int(angle_start)) self.angle_end = DrawingArc.__normalizeAngle(int(angle_end)) self.__ensureUniqueDrawing() self.unit_idx = int(kwargs.get('unit_idx', 1)) self.deMorgan_idx = int(kwargs.get('deMorgan_idx', 1)) self.line_width = int(kwargs.get('line_width', 10)) fill = kwargs.get('fill', ElementFill.NO_FILL) if isinstance(fill, ElementFill): self.fill = fill else: raise TypeError('fill needs to be of type ElementFill')
def __init__(self, points, **kwargs): self.unit_idx = int(kwargs.get('unit_idx', 1)) self.deMorgan_idx = int(kwargs.get('deMorgan_idx', 1)) self.line_width = int(kwargs.get('line_width', 10)) fill = kwargs.get('fill', ElementFill.NO_FILL) if isinstance(fill, ElementFill): self.fill = fill else: raise TypeError('fill needs to be of type ElementFill') if len(points) < 2: raise TypeError('A polyline needs at least two points') self.points=[] for point in points: self.points.append(Point(point))
def rotate(self, angle, origin = None, apply_on_copy = False): if origin is None: x = 0 y = 0 if self.points[0] == self.points[-1]: points = self.points[:-1] else: points = self.points for point in points: x += point.x y += point.y origin = Point(x/len(point), y/len(point)) obj = self if not apply_on_copy else deepcopy(self) for point in obj.points: point.rotate(angle, origin) return obj