KiCad Pcbnew Python Scripting
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
plugins.FootprintWizardBase.FootprintWizardDrawingAids Class Reference

Collection of handy functions to simplify drawing shapes from within footprint wizards. More...

Public Member Functions

def DefaultGraphicLayer (self)
 
def DefaultTextValueLayer (self)
 
def __init__ (self, module)
 
def PushTransform (self, mat)
 Add a transform to the top of the stack and recompute the overall transform. More...
 
def PopTransform (self, num=1)
 Remove a transform from the top of the stack and recompute the overall transform. More...
 
def ResetTransform (self)
 Reset the transform stack to the identity matrix. More...
 
def RecomputeTransforms (self)
 Re-compute the transform stack into a single transform and store in the DC. More...
 
def TransformTranslate (self, x, y, push=True)
 Set up and return a transform matrix representing a translation optionally pushing onto the stack. More...
 
def TransformFlipOrigin (self, flip, push=True)
 Set up and return a transform matrix representing a horizontal, vertical or both flip about the origin. More...
 
def TransformFlip (self, x, y, flip=flipNone, push=True)
 Set up and return a transform matrix representing a horizontal, vertical or both flip about a point (x,y) More...
 
def TransformRotationOrigin (self, rot, push=True)
 Set up and return a transform matrix representing a rotation about the origin, and optionally push onto the stack. More...
 
def TransformRotation (self, x, y, rot, push=True)
 Set up and return a transform matrix representing a rotation about the point (x,y), and optionally push onto the stack. More...
 
def TransformScaleOrigin (self, sx, sy=None, push=True)
 Set up and return a transform matrix representing a scale about the origin, and optionally push onto the stack. More...
 
def TransformPoint (self, x, y, mat=None)
 Return a point (x, y) transformed by the given matrix, or if that is not given, the drawing context transform. More...
 
def SetLineThickness (self, lineThickness)
 Set the current pen lineThickness used for subsequent drawing operations. More...
 
def SetLineTickness (self, lineThickness)
 Old version of SetLineThickness. More...
 
def GetLineThickness (self)
 Get the current drawing context line thickness. More...
 
def SetLayer (self, layer)
 Set the current drawing layer, used for subsequent drawing operations. More...
 
def GetLayer (self)
 Return the current drawing layer, used for drawing operations. More...
 
def Line (self, x1, y1, x2, y2)
 Draw a line from (x1, y1) to (x2, y2) More...
 
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. More...
 
def Arc (self, cx, cy, sx, sy, a)
 Draw an arc based on centre, start and angle. More...
 
def HLine (self, x, y, l)
 Draw a horizontal line from (x,y), rightwards. More...
 
def VLine (self, x, y, l)
 Draw a vertical line from (x1,y1), downwards. More...
 
def Polyline (self, pts, mirrorX=None, mirrorY=None)
 Draw a polyline, optionally mirroring around the given points. More...
 
def Reference (self, x, y, size, orientation_degree=0)
 Draw the module's reference as the given point. More...
 
def Value (self, x, y, size, orientation_degree=0)
 As for references, draw the module's value. More...
 
def Box (self, x, y, w, h)
 Draw a rectangular box, centred at (x,y), with given width and height. More...
 
def NotchedCircle (self, x, y, r, notch_w, notch_h, rotate=0)
 Circle radius r centred at (x, y) with a raised or depressed notch at the top Notch height is measured from the top of the circle radius. More...
 
def NotchedBox (self, x, y, w, h, notchW, notchH, rotate=0)
 Draw a box with a notch in the centre of the top edge. More...
 
def BoxWithDiagonalAtCorner (self, x, y, w, h, setback=pcbnew.FromMM(1.27), flip=flipNone)
 Draw a box with a diagonal at the top left corner. More...
 
def BoxWithOpenCorner (self, x, y, w, h, setback=pcbnew.FromMM(1.27), flip=flipNone)
 Draw a box with an opening at the top left corner. More...
 
def RoundedBox (self, x, y, w, h, rad)
 Draw a box with rounded corners (i.e. More...
 
def ChamferedBox (self, x, y, w, h, chamfer_x, chamfer_y)
 Draw a box with chamfered corners. More...
 
def MarkerArrow (self, x, y, direction=dirN, width=pcbnew.FromMM(1))
 Draw a marker arrow facing in the given direction, with the point at (x,y) More...
 

Public Attributes

 module
 
 dc
 

Static Public Attributes

int dirN = 0
 
int dirNE = 45
 
int dirE = 90
 
int dirSE = 135
 
int dirS = 180
 
int dirSW = 225
 
int dirW = 270
 
int dirNW = 315
 
int flipNone = 0
 
int flipX = 1
 
int flipY = 2
 
int flipBoth = 3
 
list xfrmIDENTITY = [1, 0, 0, 0, 1, 0]
 
 defaultLineThickness = pcbnew.FromMM(0.15)
 

Detailed Description

Collection of handy functions to simplify drawing shapes from within footprint wizards.

A "drawing context" is provided which can be used to set and retain settings such as line thickness and layer. The DC also contains a "transform stack", which allows easy positioning and transforming of drawn elements without lots of geometric book-keeping.

Definition at line 175 of file FootprintWizardBase.py.

Constructor & Destructor Documentation

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.__init__ (   self,
  module 
)

Definition at line 213 of file FootprintWizardBase.py.

Member Function Documentation

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.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)

Parameters
cxthe x co-ordinate of the arc centre
cythe y co-ordinate of the arc centre
sxthe x co-ordinate of the arc start point
sythe y co-ordinate of the arc start point
athe arc's central angle (in deci-degrees)

Definition at line 521 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Box (   self,
  x,
  y,
  w,
  h 
)

Draw a rectangular box, centred at (x,y), with given width and height.

Parameters
xthe x co-ordinate of the box's centre
ythe y co-ordinate of the box's centre
wthe width of the box
hthe height of the box

Definition at line 646 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.BoxWithDiagonalAtCorner (   self,
  x,
  y,
  w,
  h,
  setback = pcbnew.FromMM(1.27),
  flip = flipNone 
)

Draw a box with a diagonal at the top left corner.

Parameters
xthe x co-ordinate of the circle's centre
ythe y co-ordinate of the circle's centre
wthe width of the box
hthe height of the box
setbackthe set-back of the diagonal, in both x and y
flipone of flipNone, flipX, flipY or flipBoth to change the diagonal corner

Definition at line 736 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.BoxWithOpenCorner (   self,
  x,
  y,
  w,
  h,
  setback = pcbnew.FromMM(1.27),
  flip = flipNone 
)

Draw a box with an opening at the top left corner.

Parameters
xthe x co-ordinate of the circle's centre
ythe y co-ordinate of the circle's centre
wthe width of the box
hthe height of the box
setbackthe set-back of the opening, in both x and y
flipone of flipNone, flipX, flipY or flipBoth to change the open corner position

Definition at line 763 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.ChamferedBox (   self,
  x,
  y,
  w,
  h,
  chamfer_x,
  chamfer_y 
)

Draw a box with chamfered corners.

:param x: the x co-ordinate of the box's centre :param y: the y co-ordinate of the box's centre :param w: the width of the box :param h: the height of the box :param chamfer_x: the size of the chamfer set-back in the x direction :param chamfer_y: the size of the chamfer set-back in the y direction

Definition at line 824 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.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.

Parameters
xthe x co-ordinate of the arc centre
ythe y co-ordinate of the arc centre
rthe circle's radius
filledTrue to draw a filled circle, False to use the current DC line thickness

Definition at line 493 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.DefaultGraphicLayer (   self)

Definition at line 207 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.DefaultTextValueLayer (   self)

Definition at line 210 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.GetLayer (   self)

Return the current drawing layer, used for drawing operations.

Definition at line 474 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.GetLineThickness (   self)

Get the current drawing context line thickness.

Definition at line 461 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.HLine (   self,
  x,
  y,
  l 
)

Draw a horizontal line from (x,y), rightwards.

Parameters
xline start x co-ordinate
yline start y co-ordinate
lline length

Definition at line 553 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Line (   self,
  x1,
  y1,
  x2,
  y2 
)

Draw a line from (x1, y1) to (x2, y2)

Definition at line 480 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.MarkerArrow (   self,
  x,
  y,
  direction = dirN,
  width = pcbnew.FromMM(1) 
)

Draw a marker arrow facing in the given direction, with the point at (x,y)

Parameters
xx position of the arrow tip
yy position of the arrow tip
directionarrow direction in degrees (0 is "north", can use dir* shorthands)
widtharrow width

Definition at line 857 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.NotchedBox (   self,
  x,
  y,
  w,
  h,
  notchW,
  notchH,
  rotate = 0 
)

Draw a box with a notch in the centre of the top edge.

Parameters
xthe x co-ordinate of the circle's centre
ythe y co-ordinate of the circle's centre
wthe width of the box
hthe height of the box
notchWthe width of the notch
notchHthe height of the notch
rotatethe rotation of the whole figure, in degrees

Definition at line 701 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.NotchedCircle (   self,
  x,
  y,
  r,
  notch_w,
  notch_h,
  rotate = 0 
)

Circle radius r centred at (x, y) with a raised or depressed notch at the top Notch height is measured from the top of the circle radius.

Parameters
xthe x co-ordinate of the circle's centre
ythe y co-ordinate of the circle's centre
rthe radius of the circle
notch_wthe width of the notch
notch_hthe height of the notch
rotatethe rotation of the whole figure, in degrees

Definition at line 665 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Polyline (   self,
  pts,
  mirrorX = None,
  mirrorY = None 
)

Draw a polyline, optionally mirroring around the given points.

Parameters
ptslist of polyline vertices (list of (x, y))
mirrorXx co-ordinate of mirror point (None for no x-flip)
mirrorYy co-ordinate of mirror point (None for no y-flip)

Definition at line 573 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.PopTransform (   self,
  num = 1 
)

Remove a transform from the top of the stack and recompute the overall transform.

Parameters
numthe number of transforms to pop from the stack.
Returns
the last popped transform

Definition at line 233 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.PushTransform (   self,
  mat 
)

Add a transform to the top of the stack and recompute the overall transform.

Parameters
matthe transform matrix to add to the stack

Definition at line 223 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.RecomputeTransforms (   self)

Re-compute the transform stack into a single transform and store in the DC.

Definition at line 277 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Reference (   self,
  x,
  y,
  size,
  orientation_degree = 0 
)

Draw the module's reference as the given point.

The actual setting of the reference is not done in this drawing aid - that is up to the wizard

Parameters
xthe x position of the reference
ythe y position of the reference
sizethe text size (in both directions)
orientation_degreetext orientation in degrees

Definition at line 606 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.ResetTransform (   self)

Reset the transform stack to the identity matrix.

Definition at line 247 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.RoundedBox (   self,
  x,
  y,
  w,
  h,
  rad 
)

Draw a box with rounded corners (i.e.

a 90-degree circular arc)

:param x: the x co-ordinate of the box's centre :param y: the y co-ordinate of the box's centre :param w: the width of the box :param h: the height of the box :param rad: the radius of the corner rounds

Definition at line 789 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.SetLayer (   self,
  layer 
)

Set the current drawing layer, used for subsequent drawing operations.

Definition at line 467 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.SetLineThickness (   self,
  lineThickness 
)

Set the current pen lineThickness used for subsequent drawing operations.

Parameters
lineThicknessthe new line thickness to set

Definition at line 440 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.SetLineTickness (   self,
  lineThickness 
)

Old version of SetLineThickness.

Does the same thing, but is is only here for compatibility with old scripts. Set the current pen lineThickness used for subsequent drawing operations

Parameters
lineThicknessthe new line thickness to set

Definition at line 449 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformFlip (   self,
  x,
  y,
  flip = flipNone,
  push = True 
)

Set up and return a transform matrix representing a horizontal, vertical or both flip about a point (x,y)

This is performed by a translate-to-origin, flip, translate- back sequence.

Parameters
xthe x co-ordinate of the flip point
ythe y co-ordinate of the flip point
flipone of flipNone, flipX, flipY, flipBoth
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 329 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformFlipOrigin (   self,
  flip,
  push = True 
)

Set up and return a transform matrix representing a horizontal, vertical or both flip about the origin.

Parameters
flipone of flipNone, flipX, flipY, flipBoth
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 304 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformPoint (   self,
  x,
  y,
  mat = None 
)

Return a point (x, y) transformed by the given matrix, or if that is not given, the drawing context transform.

Parameters
xthe x co-ordinate of the point to transform
ythe y co-ordinate of the point to transform
matthe transform matrix to use or None to use the current DC's
Returns
: the transformed point as a wxPoint

Definition at line 423 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformRotation (   self,
  x,
  y,
  rot,
  push = True 
)

Set up and return a transform matrix representing a rotation about the point (x,y), and optionally push onto the stack.

This is performed by a translate-to-origin, rotate, translate- back sequence

Parameters
xthe x co-ordinate of the rotation centre
ythe y co-ordinate of the rotation centre
rotthe rotation angle in degrees
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 374 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformRotationOrigin (   self,
  rot,
  push = True 
)

Set up and return a transform matrix representing a rotation about the origin, and optionally push onto the stack.

( cos(t) -sin(t) 0 ) ( sin(t) cos(t) 0 )

Parameters
rotthe rotation angle in degrees
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 354 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformScaleOrigin (   self,
  sx,
  sy = None,
  push = True 
)

Set up and return a transform matrix representing a scale about the origin, and optionally push onto the stack.

( sx 0 0 ) ( 0 sy 0 )

Parameters
sxthe scale factor in the x direction
sythe scale factor in the y direction
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 400 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformTranslate (   self,
  x,
  y,
  push = True 
)

Set up and return a transform matrix representing a translation optionally pushing onto the stack.

( 1 0 x ) ( 0 1 y )

Parameters
xtranslation in x-direction
ytranslation in y-direction
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 285 of file FootprintWizardBase.py.

Here is the caller graph for this function:

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Value (   self,
  x,
  y,
  size,
  orientation_degree = 0 
)

As for references, draw the module's value.

Parameters
xthe x position of the value
ythe y position of the value
sizethe text size (in both directions)
orientation_degreetext orientation in degrees

Definition at line 628 of file FootprintWizardBase.py.

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.VLine (   self,
  x,
  y,
  l 
)

Draw a vertical line from (x1,y1), downwards.

Parameters
xline start x co-ordinate
yline start y co-ordinate
lline length

Definition at line 563 of file FootprintWizardBase.py.

Here is the caller graph for this function:

Member Data Documentation

plugins.FootprintWizardBase.FootprintWizardDrawingAids.dc

Definition at line 216 of file FootprintWizardBase.py.

plugins.FootprintWizardBase.FootprintWizardDrawingAids.defaultLineThickness = pcbnew.FromMM(0.15)
static

Definition at line 205 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirE = 90
static

Definition at line 189 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirN = 0
static

Definition at line 187 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirNE = 45
static

Definition at line 188 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirNW = 315
static

Definition at line 194 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirS = 180
static

Definition at line 191 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirSE = 135
static

Definition at line 190 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirSW = 225
static

Definition at line 192 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirW = 270
static

Definition at line 193 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipBoth = 3
static

Definition at line 200 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipNone = 0
static

Definition at line 197 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipX = 1
static

Definition at line 198 of file FootprintWizardBase.py.

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipY = 2
static

Definition at line 199 of file FootprintWizardBase.py.

plugins.FootprintWizardBase.FootprintWizardDrawingAids.module

Definition at line 214 of file FootprintWizardBase.py.

list plugins.FootprintWizardBase.FootprintWizardDrawingAids.xfrmIDENTITY = [1, 0, 0, 0, 1, 0]
static

Definition at line 202 of file FootprintWizardBase.py.


The documentation for this class was generated from the following file: