Ejemplo n.º 1
0
 def GetAt(self):
     if self.Attribute(0) == '':
         at = Canvas.Position()
     else:
         at = Canvas.Position(float(self.Attribute(0)),
                              float(self.Attribute(1)))
         if self.Attribute(2) != '':
             at.angle = float(self.Attribute(2))
     return at
Ejemplo n.º 2
0
 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"])
Ejemplo n.º 3
0
    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"])
Ejemplo n.º 4
0
    def Render(self, canvas, obj):
        pad = Canvas.Pad()
        pad.type = self.GetType()
        pad.shape = self.GetShape()

        super(KicadPad, self).Render(canvas, pad)
        canvas.Draw(pad)
Ejemplo n.º 5
0
    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"])
Ejemplo n.º 6
0
 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"])
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
    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"])
Ejemplo n.º 9
0
 def Render(self, filename, width=256, height=256):
     canvas = Canvas.FootprintCanvas()
     canvas.Origin(width / 2, height / 2)
     canvas.Viewport(width, height)
     surface = canvas.RenderFit(self.parent)
     surface.write_to_png(filename)
Ejemplo n.º 10
0
 def GetOffset(self):
     return Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1)))
Ejemplo n.º 11
0
 def Render(self, canvas, obj):
     arc = Canvas.Arc()
     super(KicadFPArc, self).Render(canvas, arc)
     canvas.Draw(arc)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 def Render(self, canvas, obj):
     line = Canvas.Line()
     super(KicadFPLine, self).Render(canvas, line)
     canvas.Draw(line)
Ejemplo n.º 14
0
 def Render(self, filename, width=256, height=256):
     canvas = Canvas.LibraryCanvas()
     surface = canvas.Render(self.parent, width, height)
     surface.write_to_png(filename)
Ejemplo n.º 15
0
 def Render(self, canvas, obj):
     font = Canvas.Font()
     canvas.SetFont(font)
     super(KicadFont, self).Render(canvas, font)
Ejemplo n.º 16
0
 def GetCenter(self):
     return Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1)))
Ejemplo n.º 17
0
 def Render(self, canvas, obj):
     text = Canvas.Text(self.Attribute(1))
     super(KicadFPText, self).Render(canvas, text)
     if self.GetKind() == 'value':
         canvas.Draw(text)
Ejemplo n.º 18
0
 def GetRectDelta(self):
     return Canvas.Point(float(self.Attribute(0)), float(self.Attribute(1)))
Ejemplo n.º 19
0
 def Render(self, canvas, obj):
     circle = Canvas.Circle()
     super(KicadFPCircle, self).Render(canvas, circle)
     canvas.Draw(circle)