def Render(self, canvas, obj): if len(self.attributes) < 4: return start = Canvas.Point(canvas.xmm2px(float(self.Attribute(0))), canvas.ymm2px(-float(self.Attribute(1)))) end = Canvas.Point(canvas.xmm2px(float(self.Attribute(2))), canvas.ymm2px(-float(self.Attribute(3)))) width = 2 if self.Attribute(len(self.attributes) - 1) == 'F': rect = Canvas.Rect(start, end, width, True) else: rect = Canvas.Rect(start, end, width, False) canvas.Draw(rect, ["Drawing"])
def Render(self, canvas, obj): if len(self.attributes) < 6: return width = 2 length = canvas.mm2px(float(self.Attribute(4))) if self.Attribute(5) == 'U': angle = 3 * math.pi / 2 text_angle = angle text_dx = -10 text_dy = -length / 2 elif self.Attribute(5) == 'D': angle = math.pi / 2 text_angle = 3 * math.pi / 2 text_dx = -10 text_dy = length / 2 elif self.Attribute(5) == 'R': angle = 0 text_angle = 0 text_dx = length / 2 text_dy = -10 else: angle = math.pi text_angle = 0 text_dx = -length / 2 text_dy = -10 start = Canvas.Point(canvas.xmm2px(float(self.Attribute(2))), canvas.ymm2px(-float(self.Attribute(3)))) end = Canvas.Point(canvas.xmm2px(start.x + length * math.cos(angle)), canvas.ymm2px(start.y + length * math.sin(angle))) line = Canvas.Line(start, end, width) canvas.Draw(line, ["Drawing"]) font = Canvas.Font( Canvas.Point(canvas.xmm2px(float(self.Attribute(6))), canvas.ymm2px(float(self.Attribute(7)))), 2) text = Canvas.Text(self.Attribute(1)) text.anchor_x = 'center' text.anchor_y = '' text.at = Canvas.Position(canvas.xmm2px(start.x + text_dx), canvas.ymm2px(start.y + text_dy), text_angle) canvas.SetFont(font) canvas.Draw(text, ["Label"]) circle = Canvas.Circle( start, Canvas.Point(canvas.xmm2px(start.x + 10), canvas.ymm2px(start.y)), 1, False) canvas.Draw(circle, ["Label"])
def Render(self, canvas, obj): if len(self.attributes) < 3: return start = Canvas.Point(canvas.xmm2px(float(self.Attribute(0))), canvas.ymm2px(-float(self.Attribute(1)))) end = Canvas.Point( canvas.xmm2px(float(self.Attribute(0)) + float(self.Attribute(2))), canvas.ymm2px(-float(self.Attribute(1)))) if self.Attribute(len(self.attributes) - 1) == 'F': circle = Canvas.Circle(start, end, 2, True) else: circle = Canvas.Circle(start, end, 2, False) canvas.Draw(circle, ["Drawing"])
def GetDrill(self): drill = Canvas.Point() if self.IsOval(): if self.HasAttribute(1): drill.x = float(self.Attribute(1)) if self.HasAttribute(2): drill.y = float(self.Attribute(2)) else: if self.HasAttribute(0): drill.x = float(self.Attribute(0)) return drill
def Render(self, canvas, obj): if len(self.attributes) < 4: return font = Canvas.Font( Canvas.Point(canvas.xmm2px(float(self.Attribute(3))), canvas.ymm2px(float(self.Attribute(3)))), 2) text = Canvas.Text(self.Attribute(7)) if int(self.Attribute(0)) > 0: angle = 3 * math.pi / 2 else: angle = 0 text.anchor_x = 'center' text.anchor_y = 'center' text.at = Canvas.Position(canvas.xmm2px(float(self.Attribute(1))), canvas.ymm2px(-float(self.Attribute(2))), angle) canvas.SetFont(font) canvas.Draw(text, ["Label"])
def Render(self, canvas, obj): if len(self.attributes) < 4: return num = int(self.Attribute(0)) points = [] for p in range(0, num * 2, 2): points.append( Canvas.Point(canvas.xmm2px(float(self.Attribute(4 + p))), canvas.ymm2px(-float(self.Attribute(5 + p))))) if float(self.Attribute(3)) > 0: width = float(self.Attribute(3)) else: width = 2 if self.Attribute(len(self.attributes) - 1) == 'F': polyline = Canvas.PolyLine(points, width, True) else: polyline = Canvas.PolyLine(points, width, False) canvas.Draw(polyline, ["Drawing"])
def GetRectDelta(self): return Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1)))
def Render(self, canvas, obj): if obj: obj.size = Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1))) super(KicadCenter, self).Render(canvas, obj)
def GetCenter(self): return Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1)))
def GetOffset(self): return Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1)))