def Arc(self, cx, cy, sx, sy, a):
        """!
        Draw an arc based on centre, start and angle

        The transform matrix is applied

        Note that this won't work properly if the result is not a
        circular arc (e.g. a horizontal scale)

        @param cx: the x coordinate of the arc centre
        @param cy: the y coordinate of the arc centre
        @param sx: the x coordinate of the arc start point
        @param sy: the y coordinate of the arc start point
        @param a: the arc's central angle (in deci-degrees)
        """
        circle = pcbnew.FP_SHAPE(self.module)
        circle.SetWidth(self.dc['lineThickness'])

        center = self.TransformPoint(cx, cy)
        start = self.TransformPoint(sx, sy)

        circle.SetLayer(self.dc['layer'])
        circle.SetShape(pcbnew.S_ARC)

        # check if the angle needs to be reverse (a flip scaling)
        if self.MyCmp(self.dc['transform'][0], 0) != self.MyCmp(
                self.dc['transform'][4], 0):
            a = -a

        circle.SetAngle(a)
        circle.SetStartEnd(center, start)
        self.module.Add(circle)
    def Circle(self, x, y, r, filled=False):
        """!
        Draw a circle at (x,y) of radius r
        If filled is true, the thickness and radius of the line will be set
        such that the circle appears filled

        @param x: the x coordinate of the arc centre
        @param y: the y coordinate of the arc centre
        @param r: the circle's radius
        @param filled: True to draw a filled circle, False to use the current
                       DC line thickness
        """

        circle = pcbnew.FP_SHAPE(self.module)
        start = self.TransformPoint(x, y)

        if filled:
            circle.SetWidth(r)
            end = self.TransformPoint(x, y + r / 2)
        else:
            circle.SetWidth(self.dc['lineThickness'])
            end = self.TransformPoint(x, y + r)

        circle.SetLayer(self.dc['layer'])
        circle.SetShape(pcbnew.S_CIRCLE)
        circle.SetStartEnd(start, end)
        self.module.Add(circle)
 def Line(self, x1, y1, x2, y2):
     """!
     Draw a line from (x1, y1) to (x2, y2)
     """
     outline = pcbnew.FP_SHAPE(self.module)
     outline.SetWidth(self.GetLineThickness())
     outline.SetLayer(self.GetLayer())
     outline.SetShape(pcbnew.S_SEGMENT)
     start = self.TransformPoint(x1, y1)
     end = self.TransformPoint(x2, y2)
     outline.SetStartEnd(start, end)
     self.module.Add(outline)
Example #4
0
 def drawPixelSquareArea( self, layer, size, xposition, yposition):
     # creates a FP_SHAPE of polygon type. The polygon is a square
     polygon = pcbnew.FP_SHAPE(self.module)
     polygon.SetShape(pcbnew.S_POLYGON)
     polygon.SetWidth( 0 )
     polygon.SetLayer(layer)
     halfsize = int(size/2)
     polygon.GetPolyShape().NewOutline();
     polygon.GetPolyShape().Append( halfsize+xposition, halfsize+yposition )
     polygon.GetPolyShape().Append( halfsize+xposition, -halfsize+yposition )
     polygon.GetPolyShape().Append( -halfsize+xposition, -halfsize+yposition )
     polygon.GetPolyShape().Append( -halfsize+xposition, halfsize+yposition )
     return polygon