KiCad Pcbnew Python Scripting
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | 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.
 
def PopTransform (self, num=1)
 Remove a transform from the top of the stack and recompute the overall transform.
 
def ResetTransform (self)
 Reset the transform stack to the identity matrix.
 
def RecomputeTransforms (self)
 Re-compute the transform stack into a single transform and store in the DC.
 
def TransformTranslate (self, x, y, push=True)
 Set up and return a transform matrix representing a translation optionally pushing onto the stack.
 
def TransformFlipOrigin (self, flip, push=True)
 Set up and return a transform matrix representing a horizontal, vertical or both flip about the origin.
 
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)
 
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.
 
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.
 
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.
 
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.
 
def SetLineThickness (self, lineThickness)
 Set the current pen lineThickness used for subsequent drawing operations.
 
def SetLineTickness (self, lineThickness)
 Old version of SetLineThickness.
 
def GetLineThickness (self)
 Get the current drawing context line thickness.
 
def SetLayer (self, layer)
 Set the current drawing layer, used for subsequent drawing operations.
 
def GetLayer (self)
 Return the current drawing layer, used for drawing operations.
 
def Line (self, x1, y1, x2, y2)
 Draw a line from (x1, y1) to (x2, y2)
 
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.
 
def MyCmp (self, n1, n2)
 
def Arc (self, cx, cy, sx, sy, angle)
 Draw an arc based on centre, start and angle.
 
def HLine (self, x, y, l)
 Draw a horizontal line from (x,y), rightwards.
 
def VLine (self, x, y, l)
 Draw a vertical line from (x1,y1), downwards.
 
def Polyline (self, pts, mirrorX=None, mirrorY=None)
 Draw a polyline, optionally mirroring around the given points.
 
def Reference (self, x, y, size, orientation_degree=0)
 Draw the module's reference as the given point.
 
def Value (self, x, y, size, orientation_degree=0)
 As for references, draw the module's value.
 
def Box (self, x, y, w, h)
 Draw a rectangular box, centred at (x,y), with given width and height.
 
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.
 
def NotchedBox (self, x, y, w, h, notchW, notchH, rotate=0)
 Draw a box with a notch in the centre of the top edge.
 
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.
 
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.
 
def RoundedBox (self, x, y, w, h, rad)
 Draw a box with rounded corners (i.e.
 
def ChamferedBox (self, x, y, w, h, chamfer_x, chamfer_y)
 Draw a box with chamfered corners.
 
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)
 

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]
 
pcbnew defaultLineThickness = pcbnew.FromMM(0.15)
 

Protected Member Functions

def _ComposeMatricesWithIdentity (self, mats)
 Compose a sequence of matrices together by sequential pre-multiplication with the identity matrix.
 

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 180 of file FootprintWizardBase.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 218 of file FootprintWizardBase.py.

Member Function Documentation

◆ _ComposeMatricesWithIdentity()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids._ComposeMatricesWithIdentity (   self,
  mats 
)
protected

Compose a sequence of matrices together by sequential pre-multiplication with the identity matrix.

Parameters
matslist of matrices to compose
Returns
: the composed transform matrix

Definition at line 259 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ Arc()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Arc (   self,
  cx,
  cy,
  sx,
  sy,
  angle 
)

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 coordinate of the arc centre
cythe y coordinate of the arc centre
sxthe x coordinate of the arc start point
sythe y coordinate of the arc start point
anglethe arc's central angle (in deci-degrees)

Definition at line 536 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ Box()

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 coordinate of the box's centre
ythe y coordinate of the box's centre
wthe width of the box
hthe height of the box

Definition at line 659 of file FootprintWizardBase.py.

◆ BoxWithDiagonalAtCorner()

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 coordinate of the circle's centre
ythe y coordinate 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 748 of file FootprintWizardBase.py.

◆ BoxWithOpenCorner()

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 coordinate of the circle's centre
ythe y coordinate 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 775 of file FootprintWizardBase.py.

◆ ChamferedBox()

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

Draw a box with chamfered corners.

:param x: the x coordinate of the box's centre :param y: the y coordinate 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 837 of file FootprintWizardBase.py.

◆ Circle()

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 coordinate of the arc centre
ythe y coordinate 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 498 of file FootprintWizardBase.py.

◆ DefaultGraphicLayer()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.DefaultGraphicLayer (   self)

Definition at line 212 of file FootprintWizardBase.py.

◆ DefaultTextValueLayer()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.DefaultTextValueLayer (   self)

Definition at line 215 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ GetLayer()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.GetLayer (   self)

Return the current drawing layer, used for drawing operations.

Definition at line 479 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ GetLineThickness()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.GetLineThickness (   self)

Get the current drawing context line thickness.

Definition at line 466 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ HLine()

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

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

Parameters
xline start x coordinate
yline start y coordinate
lline length

Definition at line 570 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ Line()

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

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

Definition at line 485 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ MarkerArrow()

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 870 of file FootprintWizardBase.py.

◆ MyCmp()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.MyCmp (   self,
  n1,
  n2 
)
replace the cmp() of python2

Definition at line 526 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ NotchedBox()

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 coordinate of the circle's centre
ythe y coordinate 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 714 of file FootprintWizardBase.py.

◆ NotchedCircle()

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 coordinate of the circle's centre
ythe y coordinate 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 678 of file FootprintWizardBase.py.

◆ Polyline()

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 coordinate of mirror point (None for no x-flip)
mirrorYy coordinate of mirror point (None for no y-flip)

Definition at line 590 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ PopTransform()

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 238 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ PushTransform()

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 228 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ RecomputeTransforms()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.RecomputeTransforms (   self)

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

Definition at line 282 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ Reference()

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 624 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ ResetTransform()

def plugins.FootprintWizardBase.FootprintWizardDrawingAids.ResetTransform (   self)

Reset the transform stack to the identity matrix.

Definition at line 252 of file FootprintWizardBase.py.

◆ RoundedBox()

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 coordinate of the box's centre :param y: the y coordinate 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 802 of file FootprintWizardBase.py.

◆ SetLayer()

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

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

Definition at line 472 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ SetLineThickness()

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 445 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ SetLineTickness()

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

Old version of SetLineThickness.

Does the same thing, but 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 454 of file FootprintWizardBase.py.

◆ TransformFlip()

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 coordinate of the flip point
ythe y coordinate 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 334 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ TransformFlipOrigin()

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 309 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ TransformPoint()

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 coordinate of the point to transform
ythe y coordinate of the point to transform
matthe transform matrix to use or None to use the current DC's
Returns
: the transformed point as a VECTOR2I

Definition at line 428 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ TransformRotation()

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 coordinate of the rotation centre
ythe y coordinate of the rotation centre
rotthe rotation angle in degrees
pushadd this transform to the current stack
Returns
the generated transform matrix

Definition at line 379 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ TransformRotationOrigin()

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 359 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ TransformScaleOrigin()

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 405 of file FootprintWizardBase.py.

◆ TransformTranslate()

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 290 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ Value()

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 643 of file FootprintWizardBase.py.

Here is the caller graph for this function:

◆ VLine()

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

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

Parameters
xline start x coordinate
yline start y coordinate
lline length

Definition at line 580 of file FootprintWizardBase.py.

Here is the caller graph for this function:

Member Data Documentation

◆ dc

plugins.FootprintWizardBase.FootprintWizardDrawingAids.dc

Definition at line 221 of file FootprintWizardBase.py.

◆ defaultLineThickness

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

Definition at line 210 of file FootprintWizardBase.py.

◆ dirE

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirE = 90
static

Definition at line 194 of file FootprintWizardBase.py.

◆ dirN

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirN = 0
static

Definition at line 192 of file FootprintWizardBase.py.

◆ dirNE

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirNE = 45
static

Definition at line 193 of file FootprintWizardBase.py.

◆ dirNW

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirNW = 315
static

Definition at line 199 of file FootprintWizardBase.py.

◆ dirS

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirS = 180
static

Definition at line 196 of file FootprintWizardBase.py.

◆ dirSE

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirSE = 135
static

Definition at line 195 of file FootprintWizardBase.py.

◆ dirSW

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirSW = 225
static

Definition at line 197 of file FootprintWizardBase.py.

◆ dirW

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.dirW = 270
static

Definition at line 198 of file FootprintWizardBase.py.

◆ flipBoth

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipBoth = 3
static

Definition at line 205 of file FootprintWizardBase.py.

◆ flipNone

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipNone = 0
static

Definition at line 202 of file FootprintWizardBase.py.

◆ flipX

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipX = 1
static

Definition at line 203 of file FootprintWizardBase.py.

◆ flipY

int plugins.FootprintWizardBase.FootprintWizardDrawingAids.flipY = 2
static

Definition at line 204 of file FootprintWizardBase.py.

◆ module

plugins.FootprintWizardBase.FootprintWizardDrawingAids.module

Definition at line 219 of file FootprintWizardBase.py.

◆ xfrmIDENTITY

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

Definition at line 207 of file FootprintWizardBase.py.


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