KiCad PCB EDA Suite
D_PAD Class Reference

#include <class_pad.h>

Inheritance diagram for D_PAD:
BOARD_CONNECTED_ITEM BOARD_ITEM EDA_ITEM KIGFX::VIEW_ITEM

Public Member Functions

 D_PAD (MODULE *parent)
 
D_PADNext () const
 
MODULEGetParent () const
 
void ImportSettingsFromMaster (const D_PAD &aMasterPad)
 Imports the pad settings from aMasterPad. More...
 
bool IsFlipped () const
 
void SetName (const wxString &aName)
 Set the pad name (sometimes called pad number, although it can be an array reference like AA12). More...
 
const wxString & GetName () const
 
bool IncrementPadName (bool aSkipUnconnectable, bool aFillSequenceGaps)
 Function IncrementPadName. More...
 
bool PadNameEqual (const D_PAD *other) const
 
PAD_SHAPE_T GetShape () const
 Function GetShape. More...
 
void SetShape (PAD_SHAPE_T aShape)
 
void SetPosition (const wxPoint &aPos) override
 
const wxPointGetPosition () const override
 
PAD_SHAPE_T GetAnchorPadShape () const
 Function GetAnchorPadShape. More...
 
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt () const
 
void SetCustomShapeInZoneOpt (CUST_PAD_SHAPE_IN_ZONE aOption)
 Set the option for the custom pad shape to use as clearance area in copper zones. More...
 
void SetAnchorPadShape (PAD_SHAPE_T aShape)
 Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads. More...
 
void SetY (int y)
 
void SetX (int x)
 
void SetPos0 (const wxPoint &aPos)
 
const wxPointGetPos0 () const
 
void SetY0 (int y)
 
void SetX0 (int x)
 
void SetSize (const wxSize &aSize)
 
const wxSize & GetSize () const
 
void SetDelta (const wxSize &aSize)
 
const wxSize & GetDelta () const
 
void SetDrillSize (const wxSize &aSize)
 
const wxSize & GetDrillSize () const
 
void SetOffset (const wxPoint &aOffset)
 
const wxPointGetOffset () const
 
void AddPrimitive (const SHAPE_POLY_SET &aPoly, int aThickness)
 Has meaning only for free shape pads. More...
 
void AddPrimitive (const std::vector< wxPoint > &aPoly, int aThickness)
 add a polygonal basic shape More...
 
void AddPrimitive (wxPoint aStart, wxPoint aEnd, int aThickness)
 segment basic shape More...
 
void AddPrimitive (wxPoint aCenter, int aRadius, int aThickness)
 ring or circle basic shape More...
 
void AddPrimitive (wxPoint aCenter, wxPoint aStart, int aArcAngle, int aThickness)
 arc basic shape More...
 
bool GetBestAnchorPosition (VECTOR2I &aPos)
 
bool MergePrimitivesAsPolygon (SHAPE_POLY_SET *aMergedPolygon=NULL, int aCircleToSegmentsCount=32)
 Merge all basic shapes, converted to a polygon in one polygon, in m_customShapeAsPolygon. More...
 
void DeletePrimitivesList ()
 clear the basic shapes list More...
 
void CustomShapeAsPolygonToBoardPosition (SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
 When created, the corners coordinates are relative to the pad position, orientation 0, in m_customShapeAsPolygon CustomShapeAsPolygonToBoardPosition transform these coordinates to actual (board) coordinates. More...
 
const std::vector< PAD_CS_PRIMITIVE > & GetPrimitives () const
 Accessor to the basic shape list. More...
 
const SHAPE_POLY_SETGetCustomShapeAsPolygon () const
 Accessor to the custom shape as one polygon. More...
 
void Flip (const wxPoint &aCentre) override
 Function Flip Flip this object, i.e. More...
 
void FlipPrimitives ()
 Flip the basic shapes, in custom pads. More...
 
bool SetPrimitives (const std::vector< PAD_CS_PRIMITIVE > &aPrimitivesList)
 Import to the basic shape list. More...
 
void SetOrientation (double aAngle)
 Function SetOrientation sets the rotation angle of the pad. More...
 
void SetOrientationDegrees (double aOrientation)
 Set orientation in degrees. More...
 
double GetOrientation () const
 Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees. More...
 
double GetOrientationDegrees () const
 
double GetOrientationRadians () const
 
void SetDrillShape (PAD_DRILL_SHAPE_T aDrillShape)
 
PAD_DRILL_SHAPE_T GetDrillShape () const
 
void GetOblongDrillGeometry (wxPoint &aStartPoint, wxPoint &aEndPoint, int &aWidth) const
 Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segment which have the same position and width as the hole Usefull to plot/draw oblong holes like segments with rounded ends used in draw and plot functions. More...
 
void SetLayerSet (LSET aLayerMask)
 
LSET GetLayerSet () const override
 Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segment or VIA physically resides. More...
 
void SetAttribute (PAD_ATTR_T aAttribute)
 
PAD_ATTR_T GetAttribute () const
 
void SetPadToDieLength (int aLength)
 
int GetPadToDieLength () const
 
int GetLocalSolderMaskMargin () const
 
void SetLocalSolderMaskMargin (int aMargin)
 
int GetLocalClearance () const
 
void SetLocalClearance (int aClearance)
 
int GetLocalSolderPasteMargin () const
 
void SetLocalSolderPasteMargin (int aMargin)
 
double GetLocalSolderPasteMarginRatio () const
 
void SetLocalSolderPasteMarginRatio (double aRatio)
 
void TransformShapeWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
 Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filling zones calculations Circles and arcs are approximated by segments. More...
 
int GetClearance (BOARD_CONNECTED_ITEM *aItem=NULL) const override
 Function GetClearance returns the clearance in internal units. More...
 
int GetSolderMaskMargin () const
 Function GetSolderMaskMargin. More...
 
wxSize GetSolderPasteMargin () const
 Function GetSolderPasteMargin. More...
 
void SetZoneConnection (ZoneConnection aType)
 
ZoneConnection GetZoneConnection () const
 
void SetThermalWidth (int aWidth)
 
int GetThermalWidth () const
 
void SetThermalGap (int aGap)
 
int GetThermalGap () const
 
void Draw (EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
 Function Draw BOARD_ITEMs have their own color information. More...
 
void DrawShape (EDA_RECT *aClipBox, wxDC *aDC, PAD_DRAWINFO &aDrawInfo)
 Function DrawShape basic function to draw a pad. More...
 
void BuildPadPolygon (wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
 Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Corner list of the polygonal shape, depending on shape, extra size (clearance ...) and orientation. More...
 
int GetRoundRectCornerRadius () const
 Function GetRoundRectCornerRadius Has meaning only for rounded rect pads. More...
 
int GetRoundRectCornerRadius (const wxSize &aSize) const
 Helper function GetRoundRectCornerRadius Has meaning only for rounded rect pads Returns the radius of the rounded corners of a rectangle size aSize, using others setting of the pad. More...
 
void BuildPadShapePolygon (SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
 Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape, extra size (clearance ...) pad and orientation This function is similar to TransformShapeWithClearanceToPolygon, but the difference is BuildPadShapePolygon creates a polygon shape exactly similar to pad shape, which a size inflated by aInflateValue and TransformShapeWithClearanceToPolygon creates a more complex shape (for instance a rectangular pad is converted in a rectangulr shape with ronded corners) More...
 
bool BuildPadDrillShapePolygon (SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aSegmentsPerCircle) const
 Function BuildPadDrillShapePolygon Build the Corner list of the polygonal drill shape, depending on shape pad hole and orientation. More...
 
int BuildSegmentFromOvalShape (wxPoint &aSegStart, wxPoint &aSegEnd, double aRotation, const wxSize &aMargin) const
 Function BuildSegmentFromOvalShape Has meaning only for OVAL (and ROUND) pads Build an equivalent segment having the same shape as the OVAL shape, Useful in draw function and in DRC and HitTest functions, because segments are already well handled by track tests. More...
 
int GetBoundingRadius () const
 Function GetBoundingRadius returns the radius of a minimum sized circle which fully encloses this pad. More...
 
wxPoint ShapePos () const
 
double GetRoundRectRadiusRatio () const
 has meaning only for rounded rect pads More...
 
void SetRoundRectRadiusRatio (double aRadiusScale)
 has meaning only for rounded rect pads Set the scaling factor between the smaller Y or Y size and the radius of the rounded corners. More...
 
int GetSubRatsnest () const
 Function GetSubRatsnest. More...
 
void SetSubRatsnest (int aSubRatsnest)
 
void GetMsgPanelInfo (std::vector< MSG_PANEL_ITEM > &aList) override
 Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
bool IsOnLayer (PCB_LAYER_ID aLayer) const override
 Function IsOnLayer tests to see if this object is on the given layer. More...
 
bool HitTest (const wxPoint &aPosition) const override
 Function HitTest tests if aPosition is contained within or on the bounding area of an item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Function HitTest tests if the aRect intersects or contains this object (depending on aContained). More...
 
wxString GetClass () const override
 Function GetClass returns the class name. More...
 
const EDA_RECT GetBoundingBox () const override
 Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes. More...
 
void SetDrawCoord ()
 

Set absolute coordinates.

More...
 
void SetLocalCoord ()
 

Set relative coordinates.

More...
 
void Move (const wxPoint &aMoveVector) override
 Function Move move this object. More...
 
void Rotate (const wxPoint &aRotCentre, double aAngle) override
 Function Rotate Rotate this object. More...
 
wxString GetSelectMenuText () const override
 Function GetSelectMenuText returns the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. More...
 
BITMAP_DEF GetMenuImage () const override
 Function GetMenuImage returns a pointer to an image to be used in menus. More...
 
wxString ShowPadShape () const
 Function ShowPadShape. More...
 
wxString ShowPadAttr () const
 Function ShowPadAttr. More...
 
void AppendConfigs (PARAM_CFG_ARRAY *aResult)
 Function AppendConfigs appends to aResult the configuration setting accessors which will later allow reading or writing of configuration file information directly into this object. More...
 
EDA_ITEMClone () const override
 Function Clone creates a duplicate of this item with linked list members set to NULL. More...
 
D_PADDuplicate () const
 same as Clone, but returns a D_PAD item. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on. More...
 
virtual unsigned int ViewGetLOD (int aLayer, KIGFX::VIEW *aView) const override
 Function ViewGetLOD() Returns the level of detail (LOD) of the item. More...
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() returns the bounding box of the item covering all its layers. More...
 
void CopyNetlistSettings (D_PAD *aPad, bool aCopyLocalSettings)
 Function CopyNetlistSettings copies the netlist settings to aPad, and the net name. More...
 
virtual void SwapData (BOARD_ITEM *aImage) override
 Swap data between aItem and aImage. More...
 
bool IsConnected () const override
 > More...
 
NETINFO_ITEMGetNet () const
 Function GetNet Returns NET_INFO object for a given item. More...
 
void SetNet (NETINFO_ITEM *aNetInfo)
 Function SetNet Sets a NET_INFO object for the item. More...
 
int GetNetCode () const
 Function GetNetCode. More...
 
bool SetNetCode (int aNetCode, bool aNoAssert=false)
 Function SetNetCode sets net using a net code. More...
 
const wxString & GetNetname () const
 Function GetNetname. More...
 
const wxString & GetShortNetname () const
 Function GetShortNetname. More...
 
std::shared_ptr< NETCLASSGetNetClass () const
 Function GetNetClass returns the NETCLASS for this item. More...
 
wxString GetNetClassName () const
 Function GetNetClassName returns a pointer to the netclass of the zone. More...
 
void SetLocalRatsnestVisible (bool aVisible)
 
bool GetLocalRatsnestVisible () const
 
virtual const wxPoint GetCenter () const
 Function GetCenter() More...
 
BOARD_ITEMBack () const
 
virtual PCB_LAYER_ID GetLayer () const
 Function GetLayer returns the primary layer this item is on. More...
 
virtual void SetLayer (PCB_LAYER_ID aLayer)
 Function SetLayer sets the layer this item is on. More...
 
bool IsTrack () const
 Function IsTrack tests to see if this object is a track or via (or microvia). More...
 
virtual bool IsLocked () const
 Function IsLocked. More...
 
virtual void SetLocked (bool aLocked)
 Function SetLocked modifies 'lock' status for of the item. More...
 
virtual void UnLink ()
 Function UnLink detaches this object from its owner. More...
 
void DeleteStructure ()
 Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one. More...
 
void Move (const VECTOR2I &aMoveVector)
 
void Rotate (const VECTOR2I &aRotCentre, double aAngle)
 
void Flip (const VECTOR2I &aCentre)
 
virtual BOARDGetBoard () const
 Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none. More...
 
wxString GetLayerName () const
 Function GetLayerName returns the name of the PCB layer on which the item resides. More...
 
KICAD_T Type () const
 Function Type() More...
 
void SetTimeStamp (time_t aNewTimeStamp)
 
time_t GetTimeStamp () const
 
DHEADGetList () const
 
void SetNext (EDA_ITEM *aNext)
 
void SetBack (EDA_ITEM *aBack)
 
void SetParent (EDA_ITEM *aParent)
 
void SetList (DHEAD *aList)
 
bool IsNew () const
 
bool IsModified () const
 
bool IsMoving () const
 
bool IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsResized () const
 
bool IsHighlighted () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetHighlighted ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearHighlighted ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (int type) const
 
void SetState (int type, int state)
 
STATUS_FLAGS GetStatus () const
 
void SetStatus (STATUS_FLAGS aStatus)
 
void SetFlags (STATUS_FLAGS aMask)
 
void ClearFlags (STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
STATUS_FLAGS GetFlags () const
 
void SetForceVisible (bool aEnable)
 Function SetForceVisible is used to set and cleag force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
virtual SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Function Visit may be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
virtual bool Matches (wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
 Function Matches compares the item against the search criteria in aSearchData. More...
 
bool Replace (wxFindReplaceData &aSearchData, wxString &aText)
 Helper function used in search and replace dialog Function Replace performs a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool Replace (wxFindReplaceData &aSearchData, void *aAuxData=NULL)
 Function Replace performs a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Function IsReplaceable. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Function ViewDraw() Draws the parts of the object belonging to layer aLayer. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 

Static Public Member Functions

static LSET StandardMask ()
 layer set for a through hole pad More...
 
static LSET SMDMask ()
 layer set for a SMD pad on Front layer More...
 
static LSET ConnSMDMask ()
 layer set for a SMD pad on Front layer used for edge board connectors More...
 
static LSET UnplatedHoleMask ()
 layer set for a mechanical unplated through hole pad More...
 
static bool ClassOf (const EDA_ITEM *aItem)
 
static int Compare (const D_PAD *padref, const D_PAD *padcmp)
 Function Compare compares two pads and return 0 if they are equal. More...
 
static wxString ShowShape (STROKE_T aShape)
 Function ShowShape converts the enum STROKE_T integer value to a wxString. More...
 
static std::string FormatInternalUnits (int aValue)
 Function FormatInternalUnits converts aValue from board internal units to a string appropriate for writing to file. More...
 
static std::string FormatInternalUnits (const wxPoint &aPoint)
 
static std::string FormatInternalUnits (const wxSize &aSize)
 
static std::string FormatAngle (double aAngle)
 Function FormatAngle converts aAngle from board units to a string appropriate for writing to file. More...
 
static SEARCH_RESULT IterateForward (EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Function IterateForward walks through the object tree calling the inspector() on each object type requested in scanTypes. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 

Static Public Attributes

static int m_PadSketchModePenSize = 0
 Pen size used to draw pads in sketch mode (mode used to print pads on silkscreen layer) More...
 
static wxPoint ZeroOffset
 A value of wxPoint(0,0) which can be passed to the Draw() functions. More...
 

Protected Member Functions

bool Matches (const wxString &aText, wxFindReplaceData &aSearchData)
 Function Matches compares aText against search criteria in aSearchData. More...
 

Static Protected Member Functions

static int getTrailingInt (wxString aStr)
 
static int getNextNumberInSequence (const std::set< int > &aSeq, bool aFillSequenceGaps)
 

Protected Attributes

NETINFO_ITEMm_netinfo
 Stores all informations about the net that item belongs to. More...
 
PCB_LAYER_ID m_Layer
 
EDA_ITEMPnext
 next in linked list More...
 
EDA_ITEMPback
 previous in linked list More...
 
DHEADm_List
 which DLIST I am on. More...
 
EDA_ITEMm_Parent
 Linked list: Link (parent struct) More...
 
time_t m_TimeStamp
 Time stamp used for logical links. More...
 
bool m_forceVisible
 Set to true to override the visibility setting of the item. More...
 
STATUS_FLAGS m_Flags
 Flag bits for editing and other uses. More...
 

Private Member Functions

int boundingRadius () const
 Function boundingRadius returns a calculated radius of a bounding circle for this pad. More...
 
bool buildCustomPadPolygon (SHAPE_POLY_SET *aMergedPolygon, int aCircleToSegmentsCount)
 

Private Attributes

int m_boundingRadius
 radius of the circle containing the pad shape More...
 
wxString m_name
 
wxPoint m_Pos
 pad Position on board More...
 
PAD_SHAPE_T m_padShape
 Shape: PAD_SHAPE_CIRCLE, PAD_SHAPE_RECT, PAD_SHAPE_OVAL, PAD_SHAPE_TRAPEZOID, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_POLYGON. More...
 
std::vector< PAD_CS_PRIMITIVEm_basicShapes
 for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to m_Pos They are expected to define only one copper area. More...
 
SHAPE_POLY_SET m_customShapeAsPolygon
 for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos More...
 
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
 How to build the custom shape in zone, to create the clearance area: CUST_PAD_SHAPE_IN_ZONE_OUTLINE = use pad shape CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL = use the convex hull of the pad shape other values are currently reserved. More...
 
int m_SubRatsnest
 variable used in rats nest computations handle subnet (block) number in ratsnest connection More...
 
wxSize m_Drill
 Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE, drill diam = m_Drill.x. More...
 
wxSize m_Size
 X and Y size ( relative to orient 0) More...
 
PAD_DRILL_SHAPE_T m_drillShape
 PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG. More...
 
double m_padRoundRectRadiusScale
 scaling factor from smallest m_Size coord to corner radius, default 0.25 More...
 
PAD_SHAPE_T m_anchorPadShape
 for custom shaped pads: shape of pad anchor, PAD_SHAPE_RECT, PAD_SHAPE_CIRCLE More...
 
wxPoint m_Offset
 m_Offset is useful only for oblong and rect pads (it can be used for other shapes, but without any interest). More...
 
LSET m_layerMask
 Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 . More...
 
wxSize m_DeltaSize
 delta on rectangular shapes More...
 
wxPoint m_Pos0
 Initial Pad position (i.e. More...
 
PAD_ATTR_T m_Attribute
 PAD_ATTRIB_NORMAL, PAD_ATTRIB_SMD, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED. More...
 
double m_Orient
 in 1/10 degrees More...
 
int m_LengthPadToDie
 Length net from pad to die, inside the package. More...
 
int m_LocalClearance
 Local clearance. More...
 
int m_LocalSolderMaskMargin
 Local mask margins: when 0, the parent footprint design values are used. More...
 
int m_LocalSolderPasteMargin
 Local solder paste margin absolute value. More...
 
double m_LocalSolderPasteMarginRatio
 Local solder mask margin ratio value of pad size The final margin is the sum of these 2 values. More...
 
ZoneConnection m_ZoneConnection
 how the connection to zone is made: no connection, thermal relief ... More...
 
int m_ThermalWidth
 
int m_ThermalGap
 

Detailed Description

Definition at line 134 of file class_pad.h.

Constructor & Destructor Documentation

D_PAD::D_PAD ( MODULE parent)

Definition at line 59 of file class_pad.cpp.

References CUST_PAD_SHAPE_IN_ZONE_OUTLINE, GetParent(), MODULE::GetPosition(), m_Attribute, m_boundingRadius, m_customShapeClearanceArea, m_Drill, m_layerMask, m_LengthPadToDie, m_LocalClearance, m_LocalSolderMaskMargin, m_LocalSolderPasteMargin, m_LocalSolderPasteMarginRatio, m_Orient, m_padRoundRectRadiusScale, EDA_ITEM::m_Parent, m_Pos, m_Size, m_ThermalGap, m_ThermalWidth, m_ZoneConnection, PAD_ATTRIB_STANDARD, PAD_DRILL_SHAPE_CIRCLE, PAD_SHAPE_CIRCLE, PAD_ZONE_CONN_INHERITED, PCB_MODULE_T, SetAnchorPadShape(), SetDrillShape(), SetShape(), SetSubRatsnest(), StandardMask(), and EDA_ITEM::Type().

Referenced by Clone().

59  :
61 {
62  m_Size.x = m_Size.y = Mils2iu( 60 ); // Default pad size 60 mils.
63  m_Drill.x = m_Drill.y = Mils2iu( 30 ); // Default drill size 30 mils.
64  m_Orient = 0; // Pad rotation in 1/10 degrees.
65  m_LengthPadToDie = 0;
66 
67  if( m_Parent && m_Parent->Type() == PCB_MODULE_T )
68  {
70  }
71 
72  SetShape( PAD_SHAPE_CIRCLE ); // Default pad shape is PAD_CIRCLE.
73  SetAnchorPadShape( PAD_SHAPE_CIRCLE ); // Default shape for custom shaped pads
74  // is PAD_CIRCLE.
75  SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); // Default pad drill shape is a circle.
76  m_Attribute = PAD_ATTRIB_STANDARD; // Default pad type is NORMAL (thru hole)
77  m_LocalClearance = 0;
81  // Parameters for round rect only:
82  m_padRoundRectRadiusScale = 0.25; // from IPC-7351C standard
83 
84  m_ZoneConnection = PAD_ZONE_CONN_INHERITED; // Use parent setting by default
85  m_ThermalWidth = 0; // Use parent setting by default
86  m_ThermalGap = 0; // Use parent setting by default
87 
89 
90  // Set layers mask to default for a standard thru hole pad.
92 
93  SetSubRatsnest( 0 ); // used in ratsnest calculations
94 
95  m_boundingRadius = -1;
96 }
int m_LocalClearance
Local clearance.
Definition: class_pad.h:834
int m_ThermalGap
Definition: class_pad.h:847
int m_LocalSolderMaskMargin
Local mask margins: when 0, the parent footprint design values are used.
Definition: class_pad.h:838
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
double m_padRoundRectRadiusScale
scaling factor from smallest m_Size coord to corner radius, default 0.25
Definition: class_pad.h:794
int m_boundingRadius
radius of the circle containing the pad shape
Definition: class_pad.h:754
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:182
static LSET StandardMask()
layer set for a through hole pad
Definition: class_pad.cpp:99
int m_LocalSolderPasteMargin
Local solder paste margin absolute value.
Definition: class_pad.h:839
const wxPoint & GetPosition() const override
Definition: class_module.h:175
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
MODULE * GetParent() const
Definition: class_pad.h:162
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void SetSubRatsnest(int aSubRatsnest)
Definition: class_pad.h:633
class MODULE, a footprint
Definition: typeinfo.h:89
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: class_pad.h:253
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
How to build the custom shape in zone, to create the clearance area: CUST_PAD_SHAPE_IN_ZONE_OUTLINE =...
Definition: class_pad.h:781
int m_ThermalWidth
Definition: class_pad.h:846
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
void SetDrillShape(PAD_DRILL_SHAPE_T aDrillShape)
Definition: class_pad.h:379
int m_LengthPadToDie
Length net from pad to die, inside the package.
Definition: class_pad.h:829
Usual pad.
Definition: pad_shapes.h:60
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:217
PAD_ATTR_T m_Attribute
PAD_ATTRIB_NORMAL, PAD_ATTRIB_SMD, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED.
Definition: class_pad.h:825
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE...
Definition: class_pad.h:786
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
double m_LocalSolderPasteMarginRatio
Local solder mask margin ratio value of pad size The final margin is the sum of these 2 values...
Definition: class_pad.h:841
ZoneConnection m_ZoneConnection
how the connection to zone is made: no connection, thermal relief ...
Definition: class_pad.h:844
wxPoint m_Pos
pad Position on board
Definition: class_pad.h:758

Member Function Documentation

void D_PAD::AddPrimitive ( const SHAPE_POLY_SET aPoly,
int  aThickness 
)

Has meaning only for free shape pads.

add a free shape to the shape list. the shape can be a polygon (outline can have a thickness) a thick segment a filled circle or ring ( if thickness == 0, this is a filled circle, else a ring) a arcadd a polygonal basic shape

Definition at line 92 of file class_pad_custom_shape_functions.cpp.

References SHAPE_POLY_SET::CIterate().

Referenced by PCB_EDIT_FRAME::Create_MuWaveComponent().

93 {
94  std::vector<wxPoint> points;
95 
96  for( auto iter = aPoly.CIterate(); iter; iter++ )
97  points.push_back( wxPoint( iter->x, iter->y ) );
98 
99  AddPrimitive( points, aThickness );
100 }
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void AddPrimitive(const SHAPE_POLY_SET &aPoly, int aThickness)
Has meaning only for free shape pads.
void D_PAD::AddPrimitive ( const std::vector< wxPoint > &  aPoly,
int  aThickness 
)

add a polygonal basic shape

Definition at line 102 of file class_pad_custom_shape_functions.cpp.

References m_basicShapes, PAD_CS_PRIMITIVE::m_Poly, PAD_CS_PRIMITIVE::m_Thickness, MergePrimitivesAsPolygon(), and S_POLYGON.

103 {
104  PAD_CS_PRIMITIVE shape( S_POLYGON );
105  shape.m_Poly = aPoly;
106  shape.m_Thickness = aThickness;
107  m_basicShapes.push_back( shape );
108 
110 }
bool MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon=NULL, int aCircleToSegmentsCount=32)
Merge all basic shapes, converted to a polygon in one polygon, in m_customShapeAsPolygon.
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
polygon (not yet used for tracks, but could be in microwave apps)
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
void D_PAD::AddPrimitive ( wxPoint  aStart,
wxPoint  aEnd,
int  aThickness 
)

segment basic shape

Definition at line 113 of file class_pad_custom_shape_functions.cpp.

References m_basicShapes, PAD_CS_PRIMITIVE::m_End, PAD_CS_PRIMITIVE::m_Start, PAD_CS_PRIMITIVE::m_Thickness, MergePrimitivesAsPolygon(), and S_SEGMENT.

114 {
115  PAD_CS_PRIMITIVE shape( S_SEGMENT );
116  shape.m_Start = aStart;
117  shape.m_End = aEnd;
118  shape.m_Thickness = aThickness;
119  m_basicShapes.push_back( shape );
120 
122 }
bool MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon=NULL, int aCircleToSegmentsCount=32)
Merge all basic shapes, converted to a polygon in one polygon, in m_customShapeAsPolygon.
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
usual segment : line with rounded ends
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
void D_PAD::AddPrimitive ( wxPoint  aCenter,
int  aRadius,
int  aThickness 
)

ring or circle basic shape

Definition at line 138 of file class_pad_custom_shape_functions.cpp.

References m_basicShapes, PAD_CS_PRIMITIVE::m_Radius, PAD_CS_PRIMITIVE::m_Start, PAD_CS_PRIMITIVE::m_Thickness, MergePrimitivesAsPolygon(), and S_CIRCLE.

139 {
140  PAD_CS_PRIMITIVE shape( S_CIRCLE );
141  shape.m_Start = aCenter;
142  shape.m_Radius = aRadius;
143  shape.m_Thickness = aThickness;
144  m_basicShapes.push_back( shape );
145 
147 }
bool MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon=NULL, int aCircleToSegmentsCount=32)
Merge all basic shapes, converted to a polygon in one polygon, in m_customShapeAsPolygon.
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
void D_PAD::AddPrimitive ( wxPoint  aCenter,
wxPoint  aStart,
int  aArcAngle,
int  aThickness 
)

arc basic shape

Definition at line 125 of file class_pad_custom_shape_functions.cpp.

References PAD_CS_PRIMITIVE::m_ArcAngle, m_basicShapes, PAD_CS_PRIMITIVE::m_End, PAD_CS_PRIMITIVE::m_Start, PAD_CS_PRIMITIVE::m_Thickness, MergePrimitivesAsPolygon(), and S_ARC.

126 {
127  PAD_CS_PRIMITIVE shape( S_ARC );
128  shape.m_Start = aCenter;
129  shape.m_End = aStart;
130  shape.m_ArcAngle = aArcAngle;
131  shape.m_Thickness = aThickness;
132  m_basicShapes.push_back( shape );
133 
135 }
bool MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon=NULL, int aCircleToSegmentsCount=32)
Merge all basic shapes, converted to a polygon in one polygon, in m_customShapeAsPolygon.
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
Arcs (with rounded ends)
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
void D_PAD::AppendConfigs ( PARAM_CFG_ARRAY aResult)

Function AppendConfigs appends to aResult the configuration setting accessors which will later allow reading or writing of configuration file information directly into this object.

Definition at line 468 of file class_pad.cpp.

References m_Drill, and m_Size.

Referenced by BOARD_DESIGN_SETTINGS::AppendConfigs().

469 {
470  // Parameters stored in config are only significant parameters
471  // for a template.
472  // So not all parameters are stored, just few.
473  aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrill" ),
474  &m_Drill.x,
475  Millimeter2iu( 0.6 ),
476  Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ),
477  NULL, MM_PER_IU ) );
478 
479  aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrillOvalY" ),
480  &m_Drill.y,
481  Millimeter2iu( 0.6 ),
482  Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ),
483  NULL, MM_PER_IU ) );
484 
485  aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeH" ),
486  &m_Size.x,
487  Millimeter2iu( 1.4 ),
488  Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ),
489  NULL, MM_PER_IU ) );
490 
491  aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeV" ),
492  &m_Size.y,
493  Millimeter2iu( 1.4 ),
494  Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ),
495  NULL, MM_PER_IU ) );
496 }
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
Configuration parameter - Integer Class with unit conversion.
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE...
Definition: class_pad.h:786
BOARD_ITEM* BOARD_ITEM::Back ( ) const
inlineinherited

Definition at line 117 of file class_board_item.h.

References EDA_ITEM::Pback.

Referenced by PCB_EDIT_FRAME::Delete_Segment_Edge(), and SwapItemData().

117 { return static_cast<BOARD_ITEM*>( Pback ); }
EDA_ITEM * Pback
previous in linked list
Definition: base_struct.h:179
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
int D_PAD::boundingRadius ( ) const
private

Function boundingRadius returns a calculated radius of a bounding circle for this pad.

Definition at line 133 of file class_pad.cpp.

References abs, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), dist, EuclideanNorm(), VECTOR2< T >::EuclideanNorm(), GetRoundRectCornerRadius(), GetShape(), KiROUND(), m_customShapeAsPolygon, m_DeltaSize, m_Size, max, SHAPE_POLY_SET::OutlineCount(), PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, and SHAPE_LINE_CHAIN::PointCount().

Referenced by GetBoundingRadius().

134 {
135  int x, y;
136  int radius;
137 
138  switch( GetShape() )
139  {
140  case PAD_SHAPE_CIRCLE:
141  radius = m_Size.x / 2;
142  break;
143 
144  case PAD_SHAPE_OVAL:
145  radius = std::max( m_Size.x, m_Size.y ) / 2;
146  break;
147 
148  case PAD_SHAPE_RECT:
149  radius = 1 + KiROUND( EuclideanNorm( m_Size ) / 2 );
150  break;
151 
152  case PAD_SHAPE_TRAPEZOID:
153  x = m_Size.x + std::abs( m_DeltaSize.y ); // Remember: m_DeltaSize.y is the m_Size.x change
154  y = m_Size.y + std::abs( m_DeltaSize.x ); // Remember: m_DeltaSize.x is the m_Size.y change
155  radius = 1 + KiROUND( hypot( x, y ) / 2 );
156  break;
157 
158  case PAD_SHAPE_ROUNDRECT:
159  radius = GetRoundRectCornerRadius();
160  x = m_Size.x >> 1;
161  y = m_Size.y >> 1;
162  radius += 1 + KiROUND( EuclideanNorm( wxSize( x - radius, y - radius )));
163  break;
164 
165  case PAD_SHAPE_CUSTOM:
166  radius = 0;
167 
168  for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt )
169  {
170  const SHAPE_LINE_CHAIN& poly = m_customShapeAsPolygon.COutline( cnt );
171  for( int ii = 0; ii < poly.PointCount(); ++ii )
172  {
173  int dist = KiROUND( poly.CPoint( ii ).EuclideanNorm() );
174  radius = std::max( radius, dist );
175  }
176  }
177 
178  radius += 1;
179  break;
180 
181  default:
182  radius = 0;
183  }
184 
185  return radius;
186 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
int PointCount() const
Function PointCount()
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:511
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
static const int dist[10][10]
Definition: dist.cpp:57
int OutlineCount() const
Returns the number of outlines in the set
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
#define abs(a)
Definition: auxiliary.h:84
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:294
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos
Definition: class_pad.h:773
wxSize m_DeltaSize
delta on rectangular shapes
Definition: class_pad.h:820
#define max(a, b)
Definition: auxiliary.h:86
Class SHAPE_LINE_CHAIN.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
bool D_PAD::buildCustomPadPolygon ( SHAPE_POLY_SET aMergedPolygon,
int  aCircleToSegmentsCount 
)
private

Definition at line 171 of file class_pad_custom_shape_functions.cpp.

References SHAPE_POLY_SET::Append(), SHAPE_LINE_CHAIN::Area(), SHAPE_POLY_SET::BooleanAdd(), SHAPE_POLY_SET::COutline(), SHAPE_POLY_SET::DeletePolygon(), SHAPE_POLY_SET::Fracture(), SHAPE_POLY_SET::Inflate(), PAD_CS_PRIMITIVE::m_ArcAngle, m_basicShapes, PAD_CS_PRIMITIVE::m_End, PAD_CS_PRIMITIVE::m_Poly, PAD_CS_PRIMITIVE::m_Radius, PAD_CS_PRIMITIVE::m_Shape, PAD_CS_PRIMITIVE::m_Start, PAD_CS_PRIMITIVE::m_Thickness, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::Polygon(), S_ARC, S_CIRCLE, S_POLYGON, S_SEGMENT, SHAPE_POLY_SET::Simplify(), TransformArcToPolygon(), TransformCircleToPolygon(), TransformRingToPolygon(), and TransformRoundedEndsSegmentToPolygon().

Referenced by GetBestAnchorPosition(), and MergePrimitivesAsPolygon().

174 {
175  SHAPE_POLY_SET aux_polyset;
176 
177  for( unsigned cnt = 0; cnt < m_basicShapes.size(); ++cnt )
178  {
179  const PAD_CS_PRIMITIVE& bshape = m_basicShapes[cnt];
180 
181  switch( bshape.m_Shape )
182  {
183  case S_SEGMENT: // usual segment : line with rounded ends
185  bshape.m_Start, bshape.m_End, aCircleToSegmentsCount, bshape.m_Thickness );
186  break;
187 
188  case S_ARC: // Arc with rounded ends
189  TransformArcToPolygon( aux_polyset,
190  bshape.m_Start, bshape.m_End, bshape.m_ArcAngle,
191  aCircleToSegmentsCount, bshape.m_Thickness );
192  break;
193 
194  case S_CIRCLE: // ring or circle
195  if( bshape.m_Thickness ) // ring
196  TransformRingToPolygon( aux_polyset,
197  bshape.m_Start, bshape.m_Radius,
198  aCircleToSegmentsCount, bshape.m_Thickness ) ;
199  else // Filled circle
200  TransformCircleToPolygon( aux_polyset,
201  bshape.m_Start, bshape.m_Radius,
202  aCircleToSegmentsCount ) ;
203  break;
204 
205  case S_POLYGON: // polygon
206  if( bshape.m_Poly.size() < 2 )
207  break; // Malformed polygon.
208 
209  {
210  // Insert the polygon:
211  const std::vector< wxPoint>& poly = bshape.m_Poly;
212  aux_polyset.NewOutline();
213 
214  if( bshape.m_Thickness )
215  {
216  SHAPE_POLY_SET polyset;
217  polyset.NewOutline();
218 
219  for( unsigned ii = 0; ii < poly.size(); ii++ )
220  {
221  polyset.Append( poly[ii].x, poly[ii].y );
222  }
223 
224  polyset.Inflate( bshape.m_Thickness/2, 32 );
225 
226  aux_polyset.Append( polyset );
227  }
228 
229  else
230  for( unsigned ii = 0; ii < poly.size(); ii++ )
231  aux_polyset.Append( poly[ii].x, poly[ii].y );
232  }
233  break;
234 
235  default:
236  break;
237  }
238  }
239 
240  aux_polyset.Simplify( SHAPE_POLY_SET::PM_FAST );
241 
242  // Merge all polygons, if more than one, pick the largest (area-wise)
243  if( aux_polyset.OutlineCount() )
244  {
245 
246  if( aux_polyset.OutlineCount() >= 2)
247  {
248  int bestOutline = 0;
249  double maxArea = 0.0;
250 
251  for( int i = 0; i < aux_polyset.OutlineCount(); i++ )
252  {
253  double area = aux_polyset.COutline(i).Area();
254 
255  if ( area > maxArea )
256  {
257  maxArea = area;
258  bestOutline = i;
259  }
260  }
261 
262  if( bestOutline != 0 )
263  aux_polyset.Polygon( 0 ) = aux_polyset.Polygon( bestOutline );
264 
265  for (int i = 1; i < aux_polyset.OutlineCount(); i++ )
266  {
267  aux_polyset.DeletePolygon( i );
268  }
269  }
270 
271  aMergedPolygon->BooleanAdd( aux_polyset, SHAPE_POLY_SET::PM_FAST );
272  aMergedPolygon->Fracture( SHAPE_POLY_SET::PM_FAST );
273  }
274 
275  return aMergedPolygon->OutlineCount() <= 1;
276 }
void TransformRoundedEndsSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aCircleToSegmentsCount, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset union For aFastMode meaning, see function booleanOp
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
int OutlineCount() const
Returns the number of outlines in the set
void DeletePolygon(int aIdx)
Deletes aIdx-th polygon from the set
int m_Radius
thickness of segment or outline For filled S_CIRCLE shape, thickness = 0.
Definition: class_pad.h:98
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
std::vector< wxPoint > m_Poly
is also the start point of the arc
Definition: class_pad.h:102
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101
int NewOutline()
Creates a new empty polygon in the set and returns its index
STROKE_T m_Shape
Definition: class_pad.h:94
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
int m_Thickness
S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON only (same as DRAWSEGMENT)
Definition: class_pad.h:95
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aCircleToSegmentsCount, int aWidth)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
void TransformArcToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, wxPoint aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth)
Function TransformArcToPolygon Creates a polygon from an Arc Convert arcs to multiple straight segmen...
double Area() const
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
double m_ArcAngle
radius of a circle
Definition: class_pad.h:99
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
bool D_PAD::BuildPadDrillShapePolygon ( SHAPE_POLY_SET aCornerBuffer,
int  aInflateValue,
int  aSegmentsPerCircle 
) const

Function BuildPadDrillShapePolygon Build the Corner list of the polygonal drill shape, depending on shape pad hole and orientation.

Parameters
aCornerBuffer= a buffer to fill.
aInflateValue= the clearance or margin value. value > 0: inflate, < 0 deflate, = 0 : no change
aSegmentsPerCircle= number of segments to approximate a circle (used for round and oblong shapes only(16 to 32 is a good value)
Returns
false if the pad has no hole, true otherwise

Definition at line 771 of file board_items_to_polygon_shape_transform.cpp.

References GetDrillSize(), GetOblongDrillGeometry(), GetPosition(), TransformCircleToPolygon(), and TransformRoundedEndsSegmentToPolygon().

Referenced by CINFO3D_VISU::createLayers().

773 {
774  wxSize drillsize = GetDrillSize();
775 
776  if( !drillsize.x || !drillsize.y )
777  return false;
778 
779  if( drillsize.x == drillsize.y ) // usual round hole
780  {
781  TransformCircleToPolygon( aCornerBuffer, GetPosition(),
782  (drillsize.x / 2) + aInflateValue, aSegmentsPerCircle );
783  }
784  else // Oblong hole
785  {
786  wxPoint start, end;
787  int width;
788 
789  GetOblongDrillGeometry( start, end, width );
790 
791  width += aInflateValue * 2;
792 
794  GetPosition() + start, GetPosition() + end, aSegmentsPerCircle, width );
795  }
796 
797  return true;
798 }
void TransformRoundedEndsSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aCircleToSegmentsCount, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
void GetOblongDrillGeometry(wxPoint &aStartPoint, wxPoint &aEndPoint, int &aWidth) const
Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segm...
Definition: class_pad.cpp:749
void D_PAD::BuildPadPolygon ( wxPoint  aCoord[4],
wxSize  aInflateValue,
double  aRotation 
) const

Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Corner list of the polygonal shape, depending on shape, extra size (clearance ...) and orientation.

Parameters
aCoord= a buffer to fill (4 corners).
aInflateValue= wxSize: the clearance or margin value. value > 0: inflate, < 0 deflate
aRotation= full rotation of the polygon

Definition at line 786 of file class_pad_draw_functions.cpp.

References PNS::angle(), delta, GetShape(), KiROUND(), m_DeltaSize, m_Size, PAD_SHAPE_RECT, PAD_SHAPE_TRAPEZOID, RotatePoint(), wxPoint::x, and wxPoint::y.

Referenced by CINFO3D_VISU::buildPadShapePolygon(), BuildPadShapePolygon(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), CINFO3D_VISU::createNewPad(), CINFO3D_VISU::createNewPadWithClearance(), CreatePadsShapesSection(), KIGFX::PCB_PAINTER::draw(), DrawShape(), HitTest(), BRDITEMS_PLOTTER::PlotPad(), PNS_KICAD_IFACE::syncPad(), and TransformShapeWithClearanceToPolygon().

788 {
789  wxSize delta;
790  wxSize halfsize;
791 
792  halfsize.x = m_Size.x >> 1;
793  halfsize.y = m_Size.y >> 1;
794 
795  switch( GetShape() )
796  {
797  case PAD_SHAPE_RECT:
798  // For rectangular shapes, inflate is easy
799  halfsize += aInflateValue;
800 
801  // Verify if do not deflate more than than size
802  // Only possible for inflate negative values.
803  if( halfsize.x < 0 )
804  halfsize.x = 0;
805 
806  if( halfsize.y < 0 )
807  halfsize.y = 0;
808  break;
809 
810  case PAD_SHAPE_TRAPEZOID:
811  // Trapezoidal pad: verify delta values
812  delta.x = ( m_DeltaSize.x >> 1 );
813  delta.y = ( m_DeltaSize.y >> 1 );
814 
815  // be sure delta values are not to large
816  if( (delta.x < 0) && (delta.x <= -halfsize.y) )
817  delta.x = -halfsize.y + 1;
818 
819  if( (delta.x > 0) && (delta.x >= halfsize.y) )
820  delta.x = halfsize.y - 1;
821 
822  if( (delta.y < 0) && (delta.y <= -halfsize.x) )
823  delta.y = -halfsize.x + 1;
824 
825  if( (delta.y > 0) && (delta.y >= halfsize.x) )
826  delta.y = halfsize.x - 1;
827  break;
828 
829  default: // is used only for rect and trap. pads
830  return;
831  }
832 
833  // Build the basic rectangular or trapezoid shape
834  // delta is null for rectangular shapes
835  aCoord[0].x = -halfsize.x - delta.y; // lower left
836  aCoord[0].y = +halfsize.y + delta.x;
837 
838  aCoord[1].x = -halfsize.x + delta.y; // upper left
839  aCoord[1].y = -halfsize.y - delta.x;
840 
841  aCoord[2].x = +halfsize.x - delta.y; // upper right
842  aCoord[2].y = -halfsize.y + delta.x;
843 
844  aCoord[3].x = +halfsize.x + delta.y; // lower right
845  aCoord[3].y = +halfsize.y - delta.x;
846 
847  // Offsetting the trapezoid shape id needed
848  // It is assumed delta.x or/and delta.y == 0
849  if( GetShape() == PAD_SHAPE_TRAPEZOID && (aInflateValue.x != 0 || aInflateValue.y != 0) )
850  {
851  double angle;
852  wxSize corr;
853 
854  if( delta.y ) // lower and upper segment is horizontal
855  {
856  // Calculate angle of left (or right) segment with vertical axis
857  angle = atan2( (double) m_DeltaSize.y, (double) m_Size.y );
858 
859  // left and right sides are moved by aInflateValue.x in their perpendicular direction
860  // We must calculate the corresponding displacement on the horizontal axis
861  // that is delta.x +- corr.x depending on the corner
862  corr.x = KiROUND( tan( angle ) * aInflateValue.x );
863  delta.x = KiROUND( aInflateValue.x / cos( angle ) );
864 
865  // Horizontal sides are moved up and down by aInflateValue.y
866  delta.y = aInflateValue.y;
867 
868  // corr.y = 0 by the constructor
869  }
870  else if( delta.x ) // left and right segment is vertical
871  {
872  // Calculate angle of lower (or upper) segment with horizontal axis
873  angle = atan2( (double) m_DeltaSize.x, (double) m_Size.x );
874 
875  // lower and upper sides are moved by aInflateValue.x in their perpendicular direction
876  // We must calculate the corresponding displacement on the vertical axis
877  // that is delta.y +- corr.y depending on the corner
878  corr.y = KiROUND( tan( angle ) * aInflateValue.y );
879  delta.y = KiROUND( aInflateValue.y / cos( angle ) );
880 
881  // Vertical sides are moved left and right by aInflateValue.x
882  delta.x = aInflateValue.x;
883 
884  // corr.x = 0 by the constructor
885  }
886  else // the trapezoid is a rectangle
887  {
888  delta = aInflateValue; // this pad is rectangular (delta null).
889  }
890 
891  aCoord[0].x += -delta.x - corr.x; // lower left
892  aCoord[0].y += delta.y + corr.y;
893 
894  aCoord[1].x += -delta.x + corr.x; // upper left
895  aCoord[1].y += -delta.y - corr.y;
896 
897  aCoord[2].x += delta.x - corr.x; // upper right
898  aCoord[2].y += -delta.y + corr.y;
899 
900  aCoord[3].x += delta.x + corr.x; // lower right
901  aCoord[3].y += delta.y - corr.y;
902 
903  /* test coordinates and clamp them if the offset correction is too large:
904  * Note: if a coordinate is bad, the other "symmetric" coordinate is bad
905  * So when a bad coordinate is found, the 2 symmetric coordinates
906  * are set to the minimun value (0)
907  */
908 
909  if( aCoord[0].x > 0 ) // lower left x coordinate must be <= 0
910  aCoord[0].x = aCoord[3].x = 0;
911 
912  if( aCoord[1].x > 0 ) // upper left x coordinate must be <= 0
913  aCoord[1].x = aCoord[2].x = 0;
914 
915  if( aCoord[0].y < 0 ) // lower left y coordinate must be >= 0
916  aCoord[0].y = aCoord[1].y = 0;
917 
918  if( aCoord[3].y < 0 ) // lower right y coordinate must be >= 0
919  aCoord[3].y = aCoord[2].y = 0;
920  }
921 
922  if( aRotation )
923  {
924  for( int ii = 0; ii < 4; ii++ )
925  RotatePoint( &aCoord[ii], aRotation );
926  }
927 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
static const int delta[8][2]
Definition: solve.cpp:112
wxSize m_DeltaSize
delta on rectangular shapes
Definition: class_pad.h:820
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void D_PAD::BuildPadShapePolygon ( SHAPE_POLY_SET aCornerBuffer,
wxSize  aInflateValue,
int  aSegmentsPerCircle,
double  aCorrectionFactor 
) const

Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape, extra size (clearance ...) pad and orientation This function is similar to TransformShapeWithClearanceToPolygon, but the difference is BuildPadShapePolygon creates a polygon shape exactly similar to pad shape, which a size inflated by aInflateValue and TransformShapeWithClearanceToPolygon creates a more complex shape (for instance a rectangular pad is converted in a rectangulr shape with ronded corners)

Parameters
aCornerBuffer= a buffer to fill.
aInflateValue= the clearance or margin value. value > 0: inflate, < 0 deflate, = 0 : no change the clearance can have different values for x and y directions (relative to the pad)
aSegmentsPerCircle= number of segments to approximate a circle (used for round and oblong shapes only (16 to 32 is a good value)
aCorrectionFactor= the correction to apply to circles radius to keep the pad size/clearance when the arcs are approximated by segments

Definition at line 733 of file board_items_to_polygon_shape_transform.cpp.

References SHAPE_POLY_SET::Append(), BuildPadPolygon(), GetShape(), m_Orient, SHAPE_POLY_SET::NewOutline(), PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, ShapePos(), and TransformShapeWithClearanceToPolygon().

Referenced by CINFO3D_VISU::buildPadShapeThickOutlineAsSegments(), PNS_KICAD_IFACE::syncPad(), and MODULE::TransformPadsShapesWithClearanceToPolygon().

736 {
737  wxPoint corners[4];
738  wxPoint padShapePos = ShapePos(); /* Note: for pad having a shape offset,
739  * the pad position is NOT the shape position */
740  switch( GetShape() )
741  {
742  case PAD_SHAPE_CIRCLE:
743  case PAD_SHAPE_OVAL:
744  case PAD_SHAPE_ROUNDRECT:
745  case PAD_SHAPE_CUSTOM:
746  TransformShapeWithClearanceToPolygon( aCornerBuffer, aInflateValue.x,
747  aSegmentsPerCircle, aCorrectionFactor );
748  break;
749 
750  case PAD_SHAPE_TRAPEZOID:
751  case PAD_SHAPE_RECT:
752  aCornerBuffer.NewOutline();
753 
754  BuildPadPolygon( corners, aInflateValue, m_Orient );
755  for( int ii = 0; ii < 4; ii++ )
756  {
757  corners[ii] += padShapePos; // Shift origin to position
758  aCornerBuffer.Append( corners[ii].x, corners[ii].y );
759  }
760 
761  break;
762  }
763 }
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
int NewOutline()
Creates a new empty polygon in the set and returns its index
wxPoint ShapePos() const
Definition: class_pad.cpp:500
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
int D_PAD::BuildSegmentFromOvalShape ( wxPoint aSegStart,
wxPoint aSegEnd,
double  aRotation,
const wxSize &  aMargin 
) const

Function BuildSegmentFromOvalShape Has meaning only for OVAL (and ROUND) pads Build an equivalent segment having the same shape as the OVAL shape, Useful in draw function and in DRC and HitTest functions, because segments are already well handled by track tests.

Function BuildSegmentFromOvalShape Has meaning only for OVAL (and ROUND) pads.

Parameters
aSegStart= the starting point of the equivalent segment relative to the shape position.
aSegEnd= the ending point of the equivalent segment, relative to the shape position
aRotation= full rotation of the segment
aRotation= full rotation of the segment
aMargin= a margin around the shape (for instance mask margin)
Returns
the width of the segment

Build an equivalent segment having the same shape as the OVAL shape, aSegStart and aSegEnd are the ending points of the equivalent segment of the shape aRotation is the asked rotation of the segment (usually m_Orient)

Definition at line 752 of file class_pad_draw_functions.cpp.

References delta, m_Size, RotatePoint(), wxPoint::x, and wxPoint::y.

Referenced by DrawShape(), and PNS_KICAD_IFACE::syncPad().

754 {
755  int width;
756 
757  if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment
758  {
759  int delta = ( m_Size.x - m_Size.y ) / 2;
760  aSegStart.x = -delta - aMargin.x;
761  aSegStart.y = 0;
762  aSegEnd.x = delta + aMargin.x;
763  aSegEnd.y = 0;
764  width = m_Size.y + ( aMargin.y * 2 );
765  }
766  else // Vertical oval: build a vertical equiv segment
767  {
768  int delta = ( m_Size.y -m_Size.x ) / 2;
769  aSegStart.x = 0;
770  aSegStart.y = -delta - aMargin.y;
771  aSegEnd.x = 0;
772  aSegEnd.y = delta + aMargin.y;
773  width = m_Size.x + ( aMargin.x * 2 );
774  }
775 
776  if( aRotation )
777  {
778  RotatePoint( &aSegStart, aRotation);
779  RotatePoint( &aSegEnd, aRotation);
780  }
781 
782  return width;
783 }
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static const int delta[8][2]
Definition: solve.cpp:112
static bool D_PAD::ClassOf ( const EDA_ITEM aItem)
inlinestatic

Definition at line 155 of file class_pad.h.

References PCB_PAD_T, and EDA_ITEM::Type().

156  {
157  return aItem && PCB_PAD_T == aItem->Type();
158  }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void EDA_ITEM::ClearBrightened ( )
inlineinherited

Definition at line 247 of file base_struct.h.

References BRIGHTENED, and EDA_ITEM::ClearFlags().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), and SELECTION_TOOL::disambiguationMenu().

247 { ClearFlags( BRIGHTENED ); }
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:151
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
void EDA_ITEM::ClearFlags ( STATUS_FLAGS  aMask = EDA_ITEM_ALL_FLAGS)
inlineinherited

Definition at line 268 of file base_struct.h.

Referenced by Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_Move_ModuleOutline(), Abort_Move_Pad(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Create_Outline(), Abort_Zone_Move_Corner_Or_Outlines(), AbortMoveAndEditTarget(), abortMoveBitmap(), AbortMoveDimensionText(), abortMoveItem(), AbortMoveTextModule(), AbortPinMove(), SCH_SCREEN::addConnectedItemsToBlock(), SCH_EDIT_FRAME::addCurrentItemToList(), PNS_KICAD_IFACE::AddItem(), PCB_EDIT_FRAME::AppendBoardFile(), PCB_EDIT_FRAME::Begin_DrawSegment(), FOOTPRINT_EDIT_FRAME::Begin_Edge_Module(), PCB_EDIT_FRAME::Begin_Zone(), SCH_EDIT_FRAME::BeginSegment(), PCB_EDIT_FRAME::Block_Delete(), PCB_EDIT_FRAME::Block_Flip(), PCB_EDIT_FRAME::Block_Move(), PCB_EDIT_FRAME::Change_Side_Module(), SCH_SCREEN::ClearAnnotation(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearHighlighted(), ClearMarkItems(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), SCH_EDIT_FRAME::ConvertPart(), SCH_EDIT_FRAME::copyBlockItems(), CopyMarkedItems(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), MWAVE::CreateMicrowaveInductor(), FOOTPRINT_EDIT_FRAME::CreateTextModule(), PCB_EDIT_FRAME::Delete_LastCreatedCorner(), PCB_EDIT_FRAME::Delete_Segment_Edge(), LIB_PART::DeleteSelectedItems(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), PCB_EDIT_FRAME::EditDimension(), PCB_EDIT_FRAME::End_Edge(), FOOTPRINT_EDIT_FRAME::End_Edge_Module(), PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines(), PCB_EDIT_FRAME::End_Zone(), SCH_EDIT_FRAME::EndSegment(), PCB_EDIT_FRAME::Exchange_Module(), ExitSheet(), SCH_SCREEN::GetConnection(), PCB_BASE_FRAME::GlobalChange_PadSettings(), PCB_BASE_FRAME::Import_Pad_Settings(), SCH_JUNCTION::IsSelectStateChanged(), SCH_NO_CONNECT::IsSelectStateChanged(), SCH_MARKER::IsSelectStateChanged(), SCH_BUS_ENTRY_BASE::IsSelectStateChanged(), SCH_BITMAP::IsSelectStateChanged(), SCH_LINE::IsSelectStateChanged(), SCH_TEXT::IsSelectStateChanged(), SCH_SHEET::IsSelectStateChanged(), SCH_COMPONENT::IsSelectStateChanged(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), SCH_EAGLE_PLUGIN::loadSheet(), MarkItemsInBloc(), MirrorX(), MirrorY(), moveBitmap(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), LIB_EDIT_FRAME::OnEditPin(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), LIB_EDIT_FRAME::OnRotateItem(), SCH_EDIT_FRAME::OnSelectUnit(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), SCH_FIELD::Place(), PCB_EDIT_FRAME::Place_DrawItem(), FOOTPRINT_EDIT_FRAME::Place_EdgeMod(), PCB_EDIT_FRAME::Place_Texte_Pcb(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDIT_FRAME::PlaceDimensionText(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), PCB_BASE_FRAME::PlaceModule(), PCB_BASE_FRAME::PlacePad(), PCB_EDIT_FRAME::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_BASE_FRAME::PlaceTexteModule(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), LIB_EDIT_FRAME::Process_Special_Functions(), EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::RepeatDrawItem(), LIB_EDIT_FRAME::RepeatPinItem(), BOARD_COMMIT::Revert(), PCB_BASE_FRAME::Rotate_Module(), RotateListOfItems(), LIB_PIN::Save(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), SCH_EDIT_FRAME::SetRepeatItem(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

268 { m_Flags &= ~aMask; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
void EDA_ITEM::ClearHighlighted ( )
inlineinherited

Definition at line 246 of file base_struct.h.

References EDA_ITEM::ClearFlags(), and HIGHLIGHTED.

246 { ClearFlags( HIGHLIGHTED ); }
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:150
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
void EDA_ITEM::ClearSelected ( )
inlineinherited
EDA_ITEM * D_PAD::Clone ( ) const
overridevirtual

Function Clone creates a duplicate of this item with linked list members set to NULL.

The default version will return NULL in release builds and likely crash the program. In debug builds, a warning message indicating the derived class has not implemented cloning. This really should be a pure virtual function. Due to the fact that there are so many objects derived from EDA_ITEM, the decision was made to return NULL until all the objects derived from EDA_ITEM implement cloning. Once that happens, this function should be made pure.

Returns
A clone of the item.

Reimplemented from EDA_ITEM.

Definition at line 1208 of file class_pad.cpp.

References D_PAD().

Referenced by MODULE_EDITOR_TOOLS::CreatePadFromShapes(), and Duplicate().

1209 {
1210  return new D_PAD( *this );
1211 }
D_PAD(MODULE *parent)
Definition: class_pad.cpp:59
int D_PAD::Compare ( const D_PAD padref,
const D_PAD padcmp 
)
static

Function Compare compares two pads and return 0 if they are equal.

Returns
int - <0 if left less than right, 0 if equal, >0 if left greater than right.

Definition at line 1063 of file class_pad.cpp.

References GetDrillShape(), GetShape(), m_DeltaSize, m_Drill, m_layerMask, m_Offset, m_Size, wxPoint::x, and wxPoint::y.

Referenced by CreatePadsShapesSection(), and PadListSortByShape().

1064 {
1065  int diff;
1066 
1067  if( ( diff = padref->GetShape() - padcmp->GetShape() ) != 0 )
1068  return diff;
1069 
1070  if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0)
1071  return diff;
1072 
1073  if( ( diff = padref->m_Drill.x - padcmp->m_Drill.x ) != 0 )
1074  return diff;
1075 
1076  if( ( diff = padref->m_Drill.y - padcmp->m_Drill.y ) != 0 )
1077  return diff;
1078 
1079  if( ( diff = padref->m_Size.x - padcmp->m_Size.x ) != 0 )
1080  return diff;
1081 
1082  if( ( diff = padref->m_Size.y - padcmp->m_Size.y ) != 0 )
1083  return diff;
1084 
1085  if( ( diff = padref->m_Offset.x - padcmp->m_Offset.x ) != 0 )
1086  return diff;
1087 
1088  if( ( diff = padref->m_Offset.y - padcmp->m_Offset.y ) != 0 )
1089  return diff;
1090 
1091  if( ( diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x ) != 0 )
1092  return diff;
1093 
1094  if( ( diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y ) != 0 )
1095  return diff;
1096 
1097 // TODO: test custom shapes
1098 
1099  // Dick: specctra_export needs this
1100  // Lorenzo: gencad also needs it to implement padstacks!
1101 
1102 #if __cplusplus >= 201103L
1103  long long d = padref->m_layerMask.to_ullong() - padcmp->m_layerMask.to_ullong();
1104  if( d < 0 )
1105  return -1;
1106  else if( d > 0 )
1107  return 1;
1108 
1109  return 0;
1110 #else
1111  // these strings are not typically constructed, since we don't get here often.
1112  std::string s1 = padref->m_layerMask.to_string();
1113  std::string s2 = padcmp->m_layerMask.to_string();
1114  return s1.compare( s2 );
1115 #endif
1116 }
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:381
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
wxSize m_DeltaSize
delta on rectangular shapes
Definition: class_pad.h:820
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE...
Definition: class_pad.h:786
wxPoint m_Offset
m_Offset is useful only for oblong and rect pads (it can be used for other shapes, but without any interest).
Definition: class_pad.h:814
LSET D_PAD::ConnSMDMask ( )
static

layer set for a SMD pad on Front layer used for edge board connectors

Definition at line 113 of file class_pad.cpp.

References F_Cu, and F_Mask.

114 {
115  static LSET saved( 2, F_Cu, F_Mask );
116  return saved;
117 }
Class LSET is a set of PCB_LAYER_IDs.
void D_PAD::CopyNetlistSettings ( D_PAD aPad,
bool  aCopyLocalSettings 
)

Function CopyNetlistSettings copies the netlist settings to aPad, and the net name.

Used to copy some pad parameters when replacing a footprint by an other footprint when reading a netlist, or in exchange footprint dialog

The netlist settings are all of the D_PAD settings not define by a D_PAD in a netlist. The copied settings are the net name and optionally include local clearance, etc. The pad physical geometry settings are not copied.

Parameters
aPadis the D_PAD to copy the settings to.
aCopyLocalSettings= false to copy only the net name true to also copy local prms

Definition at line 526 of file class_pad.cpp.

References BOARD_CONNECTED_ITEM::GetNetCode(), m_LocalClearance, m_LocalSolderMaskMargin, m_LocalSolderPasteMargin, m_LocalSolderPasteMarginRatio, m_ThermalGap, m_ThermalWidth, m_ZoneConnection, SetLocalClearance(), SetLocalSolderMaskMargin(), SetLocalSolderPasteMargin(), SetLocalSolderPasteMarginRatio(), BOARD_CONNECTED_ITEM::SetNetCode(), SetThermalGap(), SetThermalWidth(), and SetZoneConnection().

Referenced by MODULE::CopyNetlistSettings().

527 {
528  // Don't do anything foolish like trying to copy to yourself.
529  wxCHECK_RET( aPad != NULL && aPad != this, wxT( "Cannot copy to NULL or yourself." ) );
530 
531  aPad->SetNetCode( GetNetCode() );
532 
533  if( aCopyLocalSettings )
534  {
541  aPad->SetThermalGap( m_ThermalGap );
542  }
543 }
int m_LocalClearance
Local clearance.
Definition: class_pad.h:834
int m_ThermalGap
Definition: class_pad.h:847
int m_LocalSolderMaskMargin
Local mask margins: when 0, the parent footprint design values are used.
Definition: class_pad.h:838
int m_LocalSolderPasteMargin
Local solder paste margin absolute value.
Definition: class_pad.h:839
void SetZoneConnection(ZoneConnection aType)
Definition: class_pad.h:469
void SetThermalWidth(int aWidth)
Definition: class_pad.h:472
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
int m_ThermalWidth
Definition: class_pad.h:846
void SetLocalClearance(int aClearance)
Definition: class_pad.h:407
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: class_pad.h:413
int GetNetCode() const
Function GetNetCode.
void SetLocalSolderMaskMargin(int aMargin)
Definition: class_pad.h:404
void SetLocalSolderPasteMargin(int aMargin)
Definition: class_pad.h:410
double m_LocalSolderPasteMarginRatio
Local solder mask margin ratio value of pad size The final margin is the sum of these 2 values...
Definition: class_pad.h:841
void SetThermalGap(int aGap)
Definition: class_pad.h:475
ZoneConnection m_ZoneConnection
how the connection to zone is made: no connection, thermal relief ...
Definition: class_pad.h:844
void D_PAD::CustomShapeAsPolygonToBoardPosition ( SHAPE_POLY_SET aMergedPolygon,
wxPoint  aPosition,
double  aRotation 
) const

When created, the corners coordinates are relative to the pad position, orientation 0, in m_customShapeAsPolygon CustomShapeAsPolygonToBoardPosition transform these coordinates to actual (board) coordinates.

Parameters
aMergedPolygon= the corners coordinates, relative to aPosition and rotated by aRotation
aPosition= the position of the shape (usually the pad shape, but not always, when moving the pad)
aRotation= the rotation of the shape (usually the pad rotation, but not always, in DRC)

Definition at line 318 of file class_pad_custom_shape_functions.cpp.

References SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CINFO3D_VISU::buildPadShapePolygon(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), CINFO3D_VISU::createNewPadWithClearance(), DrawShape(), GetBoundingBox(), BRDITEMS_PLOTTER::PlotPad(), PNS_KICAD_IFACE::syncPad(), and TransformShapeWithClearanceToPolygon().

320 {
321  if( aMergedPolygon->OutlineCount() == 0 )
322  return;
323 
324  // Move, rotate, ... coordinates in aMergedPolygon according to the
325  // pad position and orientation
326  for( int cnt = 0; cnt < aMergedPolygon->OutlineCount(); ++cnt )
327  {
328  SHAPE_LINE_CHAIN& poly = aMergedPolygon->Outline( cnt );
329 
330  for( int ii = 0; ii < poly.PointCount(); ++ii )
331  {
332  wxPoint corner( poly.Point( ii ).x, poly.Point( ii ).y );
333  RotatePoint( &corner, aRotation );
334  corner += aPosition;
335 
336  poly.Point( ii ).x = corner.x;
337  poly.Point( ii ).y = corner.y;
338  }
339  }
340 }
int PointCount() const
Function PointCount()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int OutlineCount() const
Returns the number of outlines in the set
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Class SHAPE_LINE_CHAIN.
VECTOR2I & Point(int aIndex)
Function Point()
void D_PAD::DeletePrimitivesList ( )

clear the basic shapes list

Definition at line 164 of file class_pad_custom_shape_functions.cpp.

References m_basicShapes, m_customShapeAsPolygon, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

165 {
166  m_basicShapes.clear();
168 }
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos
Definition: class_pad.h:773
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
void BOARD_ITEM::DeleteStructure ( )
inherited
void D_PAD::Draw ( EDA_DRAW_PANEL panel,
wxDC *  DC,
GR_DRAWMODE  aDrawMode,
const wxPoint offset = ZeroOffset 
)
overridevirtual

Function Draw BOARD_ITEMs have their own color information.

Implements BOARD_ITEM.

Definition at line 77 of file class_pad_draw_functions.cpp.

References KIGFX::COLOR4D::a, LSET::AllCuMask(), B_Cu, B_Mask, B_Paste, LSET::BackMask(), BLACK, color, PCB_GENERAL_SETTINGS::Colors(), DARKDARKGRAY, DARKGRAY, DO_NOT_DRAW, DrawShape(), LSET::ExtractLayer(), F_Cu, F_Mask, F_Paste, LSET::FrontMask(), GetAttribute(), BOARD_ITEM::GetBoard(), GetClearance(), EDA_DRAW_PANEL::GetClipBox(), EDA_DRAW_PANEL::GetParent(), GetSolderMaskMargin(), GetSolderPasteMargin(), BOARD::GetVisibleLayers(), GR_ALLOW_HIGHCONTRAST, GR_AND, GR_HIGHLIGHT, ID_TRACK_BUTT, IsCopperLayer(), BOARD::IsElementVisible(), IsOnLayer(), LAYER_NO_CONNECTS, LAYER_NON_PLATED, LAYER_PAD_BK, LAYER_PAD_FR, PCB_SCREEN::m_Active_Layer, PAD_DRAWINFO::m_Color, PAD_DRAWINFO::m_Display_netname, PAD_DRAWINFO::m_Display_padnum, PAD_DRAWINFO::m_DrawMode, PAD_DRAWINFO::m_DrawPanel, EDA_ITEM::m_Flags, PAD_DRAWINFO::m_IsPrinting, BASE_SCREEN::m_IsPrinting, m_layerMask, PAD_DRAWINFO::m_Mask_margin, PAD_DRAWINFO::m_NoNetMarkColor, PAD_DRAWINFO::m_NPHoleColor, PAD_DRAWINFO::m_Offset, PAD_DRAWINFO::m_PadClearance, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PAD_DRAWINFO::m_ShowNCMark, PAD_DRAWINFO::m_ShowNotPlatedHole, PAD_DRAWINFO::m_ShowPadFilled, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PCB_BASE_FRAME::Settings(), SKETCH, UNDEFINED_LAYER, and UNSELECTED_LAYER.

Referenced by Abort_Move_Pad(), DrawMovingBlockOutlines(), MODULE::DrawOutlinesWhenMoving(), PCB_BASE_FRAME::PlacePad(), Show_Pad_Move(), and PCB_BASE_FRAME::StartMovePad().

79 {
80  wxSize mask_margin; // margin (clearance) used for some non copper layers
81 
82 #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
83  int showActualMaskSize = 0; /* Layer number if the actual pad size on mask layer can
84  * be displayed i.e. if only one layer is shown for this pad
85  * and this layer is a mask (solder mask or solder paste
86  */
87 #endif
88 
89  if( m_Flags & DO_NOT_DRAW )
90  return;
91 
92  PAD_DRAWINFO drawInfo;
93 
94  drawInfo.m_Offset = aOffset;
95 
96  /* We can show/hide pads from the layer manager.
97  * options are show/hide pads on front and/or back side of the board
98  * For through pads, we hide them only if both sides are hidden.
99  * smd pads on back are hidden for all layers (copper and technical layers)
100  * on back side of the board
101  * smd pads on front are hidden for all layers (copper and technical layers)
102  * on front side of the board
103  * ECO, edge and Draw layers and not considered
104  */
105 
106  BOARD* brd = GetBoard();
107 
108  auto frame = static_cast<PCB_EDIT_FRAME*> ( aPanel->GetParent() );
109  const auto& cds = frame->Settings().Colors();
110 
111  bool frontVisible = brd->IsElementVisible( LAYER_PAD_FR );
112  bool backVisible = brd->IsElementVisible( LAYER_PAD_BK );
113 
114  if( !frontVisible && !backVisible )
115  return;
116 
117  // If pad is only on front side (no layer on back side)
118  // and if hide front side pads is enabled, do not draw
119  if( !frontVisible && !( m_layerMask & LSET::BackMask() ).any() )
120  return;
121 
122  // If pad is only on back side (no layer on front side)
123  // and if hide back side pads is enabled, do not draw
124  if( !backVisible && !( m_layerMask & LSET::FrontMask() ).any() )
125  return;
126 
127 
128  wxCHECK_RET( frame != NULL, wxT( "Panel has no parent frame window." ) );
129 
130  auto displ_opts = (PCB_DISPLAY_OPTIONS*)( frame->GetDisplayOptions() );
131  PCB_SCREEN* screen = frame->GetScreen();
132 
133  if( displ_opts && displ_opts->m_DisplayPadFill == SKETCH )
134  drawInfo.m_ShowPadFilled = false;
135  else
136  drawInfo.m_ShowPadFilled = true;
137 
139 
140  if( m_layerMask[F_Cu] )
141  {
142  color = cds.GetItemColor( LAYER_PAD_FR );
143  }
144 
145  if( m_layerMask[B_Cu] )
146  {
147  color = color.LegacyMix( cds.GetItemColor( LAYER_PAD_BK ) );
148  }
149 
150  if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show)
151  {
152  // If the pad is on only one tech layer, use the layer color else use DARKGRAY
153  LSET mask_non_copper_layers = m_layerMask & ~LSET::AllCuMask();
154 
155 #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
156  mask_non_copper_layers &= brd->GetVisibleLayers();
157 #endif
158  PCB_LAYER_ID pad_layer = mask_non_copper_layers.ExtractLayer();
159 
160  switch( (int) pad_layer )
161  {
162  case UNDEFINED_LAYER: // More than one layer
163  color = DARKGRAY;
164  break;
165 
166  case UNSELECTED_LAYER: // Shouldn't really happen...
167  break;
168 
169  default:
170  color = cds.GetLayerColor( pad_layer );
171 #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
172  showActualMaskSize = pad_layer;
173 #endif
174  }
175  }
176 
177  // if SMD or connector pad and high contrast mode
178  if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
180  displ_opts && displ_opts->m_ContrastModeDisplay )
181  {
182  // when routing tracks
183  if( frame->GetToolId() == ID_TRACK_BUTT )
184  {
185  PCB_LAYER_ID routeTop = screen->m_Route_Layer_TOP;
186  PCB_LAYER_ID routeBot = screen->m_Route_Layer_BOTTOM;
187 
188  // if routing between copper and component layers,
189  // or the current layer is one of said 2 external copper layers,
190  // then highlight only the current layer.
191  if( ( screen->m_Active_Layer == F_Cu || screen->m_Active_Layer == B_Cu ) ||
192  ( routeTop==F_Cu && routeBot==B_Cu ) ||
193  ( routeTop==B_Cu && routeBot==F_Cu )
194  )
195  {
196  if( !IsOnLayer( screen->m_Active_Layer ) )
197  color = COLOR4D( DARKDARKGRAY );
198  }
199  // else routing between an internal signal layer and some other
200  // layer. Grey out all PAD_ATTRIB_SMD pads not on current or the single
201  // selected external layer.
202  else if( !IsOnLayer( screen->m_Active_Layer )
203  && !IsOnLayer( routeTop )
204  && !IsOnLayer( routeBot ) )
205  {
206  color = COLOR4D( DARKDARKGRAY );
207  }
208  }
209  // when not edting tracks, show PAD_ATTRIB_SMD components not on active layer
210  // as greyed out
211  else
212  {
213  if( !IsOnLayer( screen->m_Active_Layer ) )
214  color = COLOR4D( DARKDARKGRAY );
215  }
216  }
217 
218 #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
219  if( showActualMaskSize )
220  {
221  switch( showActualMaskSize )
222  {
223  case B_Mask:
224  case F_Mask:
225  mask_margin.x = mask_margin.y = GetSolderMaskMargin();
226  break;
227 
228  case B_Paste:
229  case F_Paste:
230  mask_margin = GetSolderPasteMargin();
231  break;
232 
233  default:
234  // Another layer which has no margin to handle
235  break;
236  }
237  }
238 #endif
239 
240  // if Contrast mode is ON and a technical layer active, show pads on this
241  // layer so we can see pads on paste or solder layer and the size of the
242  // mask
243  if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
244  displ_opts && displ_opts->m_ContrastModeDisplay && !IsCopperLayer( screen->m_Active_Layer ) )
245  {
246  if( IsOnLayer( screen->m_Active_Layer ) )
247  {
248  color = cds.GetLayerColor( screen->m_Active_Layer );
249 
250  // In high contrast mode, and if the active layer is the mask
251  // layer shows the pad size with the mask clearance
252  switch( screen->m_Active_Layer )
253  {
254  case B_Mask:
255  case F_Mask:
256  mask_margin.x = mask_margin.y = GetSolderMaskMargin();
257  break;
258 
259  case B_Paste:
260  case F_Paste:
261  mask_margin = GetSolderPasteMargin();
262  break;
263 
264  default:
265  break;
266  }
267  }
268  else
269  color = DARKDARKGRAY;
270  }
271 
272  if( ( aDraw_mode & GR_HIGHLIGHT ) && !( aDraw_mode & GR_AND ) )
273  color.SetToLegacyHighlightColor();
274 
275  bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol;
276 
277  if( !( m_layerMask & LSET::AllCuMask() ).any() )
278  DisplayIsol = false;
279 
282  {
283  drawInfo.m_ShowNotPlatedHole = true;
284  drawInfo.m_NPHoleColor = cds.GetItemColor( LAYER_NON_PLATED );
285  }
286 
287  drawInfo.m_DrawMode = aDraw_mode;
288  drawInfo.m_Color = color;
289  drawInfo.m_NoNetMarkColor = cds.GetItemColor( LAYER_NO_CONNECTS );
290  drawInfo.m_DrawPanel = aPanel;
291  drawInfo.m_Mask_margin = mask_margin;
293  drawInfo.m_IsPrinting = screen->m_IsPrinting;
294  color.a = 0.666;
295 
296  /* Get the pad clearance. This has a meaning only for Pcbnew.
297  * for CvPcb GetClearance() creates debug errors because
298  * there is no net classes so a call to GetClearance() is made only when
299  * needed (never needed in CvPcb)
300  */
301  drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0;
302 
303  // Draw the pad number
304  if( displ_opts && !displ_opts->m_DisplayPadNum )
305  drawInfo.m_Display_padnum = false;
306 
307  if( displ_opts &&
308  (( displ_opts ->m_DisplayNetNamesMode == 0 ) || ( displ_opts->m_DisplayNetNamesMode == 2 )) )
309  drawInfo.m_Display_netname = false;
310 
311  // Display net names is restricted to pads that are on the active layer
312  // in high contrast mode display
313  if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
314  !IsOnLayer( screen->m_Active_Layer ) && displ_opts && displ_opts->m_ContrastModeDisplay )
315  drawInfo.m_Display_netname = false;
316 
317  DrawShape( aPanel->GetClipBox(), aDC, drawInfo );
318 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:646
show a marker on pads with no nets
bool m_Display_padnum
Definition: class_pad.h:75
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:398
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
COLOR4D m_NoNetMarkColor
Definition: class_pad.h:72
bool m_ShowNCMark
Definition: class_pad.h:79
PCB_LAYER_ID m_Active_Layer
smd pads, back layer
static LSET FrontMask()
Function FrontMask returns a mask holding all technical layers and the external CU layer on front sid...
Definition: lset.cpp:745
bool m_IsPrinting
Definition: class_pad.h:82
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
Definition: lset.cpp:585
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:289
Class LSET is a set of PCB_LAYER_IDs.
PCB_GENERAL_SETTINGS & Settings()
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:577
GR_DRAWMODE m_DrawMode
Definition: class_pad.h:67
EDA_DRAW_PANEL * m_DrawPanel
Definition: class_pad.h:66
PCB_LAYER_ID m_Route_Layer_BOTTOM
bool m_ShowNotPlatedHole
Definition: class_pad.h:80
void DrawShape(EDA_RECT *aClipBox, wxDC *aDC, PAD_DRAWINFO &aDrawInfo)
Function DrawShape basic function to draw a pad.
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:62
int m_PadClearance
Definition: class_pad.h:73
COLORS_DESIGN_SETTINGS & Colors()
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
wxPoint m_Offset
Definition: class_pad.h:83
smd pads, front layer
handle color for not plated holes
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:610
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:546
static LSET BackMask()
Function BackMask returns a mask holding all technical layers and the external CU layer on back side...
Definition: lset.cpp:752
bool m_ShowPadFilled
Definition: class_pad.h:77
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
COLOR4D m_NPHoleColor
Definition: class_pad.h:71
COLOR4D m_Color
Definition: class_pad.h:68
Definition: colors.h:45
bool m_Display_netname
Definition: class_pad.h:76
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:637
wxSize m_Mask_margin
Definition: class_pad.h:74
PCB_LAYER_ID m_Route_Layer_TOP
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:139
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void D_PAD::DrawShape ( EDA_RECT aClipBox,
wxDC *  aDC,
PAD_DRAWINFO aDrawInfo 
)

Function DrawShape basic function to draw a pad.

This function is used by Draw after calculation of parameters (color, ) final orientation transforms are set. It can also be called to draw a pad on any panel even if this panel is not a EDA_DRAW_PANEL for instance on a wxPanel inside the pad editor.

Definition at line 321 of file class_pad_draw_functions.cpp.

References PNS::angle(), SHAPE_POLY_SET::Append(), B_Cu, BLACK, BuildPadPolygon(), BuildSegmentFromOvalShape(), CustomShapeAsPolygonToBoardPosition(), DrawGraphicHaloText(), F_Cu, GetAnchorPadShape(), EDA_DRAW_PANEL::GetClipBox(), GetDrillShape(), GetGRForceBlackPenState(), BOARD_CONNECTED_ITEM::GetNetCode(), GetOblongDrillGeometry(), GetOrientation(), GetPosition(), GetRoundRectCornerCenters(), GetRoundRectCornerRadius(), GetShape(), BOARD_CONNECTED_ITEM::GetShortNetname(), GetSize(), GR_COPY, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_XOR, GRCircle(), GRClosedPoly(), GRCSegm(), GRFillCSegm(), GRFilledCircle(), GRFilledSegment(), GRForceBlackPen(), GRLine(), GRSetDrawMode(), SHAPE_POLY_SET::Inflate(), PAD_DRAWINFO::m_Color, m_customShapeAsPolygon, PAD_DRAWINFO::m_Display_netname, PAD_DRAWINFO::m_Display_padnum, PAD_DRAWINFO::m_DrawMode, PAD_DRAWINFO::m_DrawPanel, m_Drill, PAD_DRAWINFO::m_HoleColor, PAD_DRAWINFO::m_IsPrinting, m_layerMask, PAD_DRAWINFO::m_Mask_margin, m_name, PAD_DRAWINFO::m_NoNetMarkColor, PAD_DRAWINFO::m_NPHoleColor, PAD_DRAWINFO::m_Offset, m_Orient, PAD_DRAWINFO::m_PadClearance, m_PadSketchModePenSize, m_Pos, PAD_DRAWINFO::m_ShowNCMark, PAD_DRAWINFO::m_ShowNotPlatedHole, PAD_DRAWINFO::m_ShowPadFilled, m_Size, max, min, MIN_TEXT_SIZE, NORMALIZE_ANGLE_90(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::RemoveAllContours(), RotatePoint(), SEGCOUNT, ShapePos(), TransformRoundRectToPolygon(), TransformShapeWithClearanceToPolygon(), WHITE, wxPoint::x, and wxPoint::y.

Referenced by Draw(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

322 {
323  wxPoint coord[12];
324  double angle = m_Orient;
325  int seg_width;
326 
327  GRSetDrawMode( aDC, aDrawInfo.m_DrawMode );
328 
329  // calculate pad shape position :
330  wxPoint shape_pos = ShapePos() - aDrawInfo.m_Offset;
331 
332  wxSize halfsize = m_Size;
333  halfsize.x >>= 1;
334  halfsize.y >>= 1;
335 
336  switch( GetShape() )
337  {
338  case PAD_SHAPE_CIRCLE:
339  if( aDrawInfo.m_ShowPadFilled )
340  GRFilledCircle( aClipBox, aDC, shape_pos.x, shape_pos.y,
341  halfsize.x + aDrawInfo.m_Mask_margin.x, 0,
342  aDrawInfo.m_Color, aDrawInfo.m_Color );
343  else
344  GRCircle( aClipBox, aDC, shape_pos.x, shape_pos.y,
345  halfsize.x + aDrawInfo.m_Mask_margin.x,
346  m_PadSketchModePenSize, aDrawInfo.m_Color );
347 
348  if( aDrawInfo.m_PadClearance )
349  {
350  GRCircle( aClipBox,
351  aDC, shape_pos.x, shape_pos.y,
352  halfsize.x + aDrawInfo.m_PadClearance,
353  0, aDrawInfo.m_Color );
354  }
355 
356  break;
357 
358  case PAD_SHAPE_OVAL:
359  {
360  wxPoint segStart, segEnd;
361  seg_width = BuildSegmentFromOvalShape(segStart, segEnd, angle,
362  aDrawInfo.m_Mask_margin);
363  segStart += shape_pos;
364  segEnd += shape_pos;
365 
366  if( aDrawInfo.m_ShowPadFilled )
367  {
368  GRFillCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y,
369  seg_width, aDrawInfo.m_Color );
370  }
371  else
372  {
373  GRCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y,
374  seg_width, m_PadSketchModePenSize, aDrawInfo.m_Color );
375  }
376 
377  // Draw the clearance line
378  if( aDrawInfo.m_PadClearance )
379  {
380  seg_width += 2 * aDrawInfo.m_PadClearance;
381  GRCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y,
382  seg_width, aDrawInfo.m_Color );
383  }
384  }
385  break;
386 
387  case PAD_SHAPE_RECT:
388  case PAD_SHAPE_TRAPEZOID:
389  BuildPadPolygon( coord, aDrawInfo.m_Mask_margin, angle );
390 
391  for( int ii = 0; ii < 4; ii++ )
392  coord[ii] += shape_pos;
393 
394  GRClosedPoly( aClipBox, aDC, 4, coord, aDrawInfo.m_ShowPadFilled,
395  aDrawInfo.m_ShowPadFilled ? 0 : m_PadSketchModePenSize,
396  aDrawInfo.m_Color, aDrawInfo.m_Color );
397 
398  if( aDrawInfo.m_PadClearance )
399  {
400  #define SEGCOUNT 32 // number of segments to approximate a circle
401  SHAPE_POLY_SET outline;
403 
404  // Draw the polygon: Inflate creates only one convex polygon
405  if( outline.OutlineCount() > 0 )
406  {
407  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
408 
409  if( poly.PointCount() > 0 )
410  {
411  GRClosedPoly( aClipBox, aDC, poly.PointCount(),
412  (wxPoint*)&poly.Point( 0 ), false, 0,
413  aDrawInfo.m_Color, aDrawInfo.m_Color );
414  }
415  }
416  }
417  break;
418 
419  case PAD_SHAPE_ROUNDRECT:
420  {
421  // Use solder[Paste/Mask]size or pad size to build pad shape to draw
422  wxSize size( GetSize() );
423  size += aDrawInfo.m_Mask_margin * 2;
424  int corner_radius = GetRoundRectCornerRadius( size );
425 
426  // Draw the polygon: Inflate creates only one convex polygon
427  SHAPE_POLY_SET outline;
428  bool filled = aDrawInfo.m_ShowPadFilled;
429 
430  if( filled )
431  {
432  wxPoint centers[4];
433  GetRoundRectCornerCenters( centers, corner_radius, shape_pos,
434  size, GetOrientation() );
435  GRClosedPoly( aClipBox, aDC, 4, centers, true, corner_radius*2,
436  aDrawInfo.m_Color, aDrawInfo.m_Color );
437  }
438  else
439  {
440  TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
441  corner_radius, 64 );
442 
443  if( outline.OutlineCount() > 0 )
444  {
445  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
446 
447  if( poly.PointCount() > 0 )
448  {
449  GRClosedPoly( aClipBox, aDC, poly.PointCount(),
450  (wxPoint*)&poly.Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
451  aDrawInfo.m_Color, aDrawInfo.m_Color );
452  }
453  }
454  }
455 
456  if( aDrawInfo.m_PadClearance )
457  {
458  outline.RemoveAllContours();
459  size = GetSize();
460  size.x += aDrawInfo.m_PadClearance * 2;
461  size.y += aDrawInfo.m_PadClearance * 2;
462  corner_radius = GetRoundRectCornerRadius() + aDrawInfo.m_PadClearance;
463 
464  TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
465  corner_radius, 32 );
466 
467  if( outline.OutlineCount() > 0 )
468  {
469  // Draw the polygon: Inflate creates only one convex polygon
470  SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
471 
472  if( clearance_poly.PointCount() > 0 )
473  {
474  GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(),
475  (wxPoint*)&clearance_poly.Point( 0 ), false, 0,
476  aDrawInfo.m_Color, aDrawInfo.m_Color );
477  }
478  }
479  }
480  }
481  break;
482 
483  case PAD_SHAPE_CUSTOM:
484  {
485  // The full shape has 2 items
486  // 1- The anchor pad: a round or rect pad located at pad position
487  // 2- The custom complex shape
488  // Note: The anchor pad shape is containing by the custom complex shape polygon
489  // The anchor pad is shown to help user to see where is the anchor, only in sketch mode
490  // (In filled mode, it is merged with the basic shapes)
491  wxPoint pad_pos = GetPosition() - aDrawInfo.m_Offset;
492 
493  // In sketch mode only: Draw the anchor pad: a round or rect pad
494  if( !aDrawInfo.m_ShowPadFilled )
495  {
497  {
498  wxPoint poly[4];
499  poly[0] = wxPoint( - halfsize.x, - halfsize.y );
500  poly[1] = wxPoint( - halfsize.x, + halfsize.y );
501  poly[2] = wxPoint( + halfsize.x, + halfsize.y );
502  poly[3] = wxPoint( + halfsize.x, - halfsize.y );
503 
504  for( int ii = 0; ii < 4; ++ii )
505  {
506  RotatePoint( &poly[ii], m_Orient );
507  poly[ii] += pad_pos;
508  }
509 
510  GRClosedPoly( aClipBox, aDC, 4, poly, false, 0,
511  aDrawInfo.m_Color, aDrawInfo.m_Color );
512  }
513  else
514  {
515  GRCircle( aClipBox, aDC, pad_pos.x, pad_pos.y,
516  halfsize.x,
517  m_PadSketchModePenSize, aDrawInfo.m_Color );
518  }
519  }
520 
521  SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
522  outline.Append( m_customShapeAsPolygon );
523  CustomShapeAsPolygonToBoardPosition( &outline, pad_pos, GetOrientation() );
524  SHAPE_LINE_CHAIN* poly;
525 
526  const int segmentToCircleCount = 32;
527 
528  if( aDrawInfo.m_Mask_margin.x )
529  {
530  SHAPE_POLY_SET clearance_outline;
531  clearance_outline.Append( outline );
532  clearance_outline.Inflate( aDrawInfo.m_Mask_margin.x, segmentToCircleCount );
533 
534  poly = &clearance_outline.Outline( 0 );
535  }
536  else
537  {
538  // Draw the polygon: only one polygon is expected
539  // However we provide a multi polygon shape drawing
540  // ( for the future or to show a non expected shape )
541  for( int jj = 0; jj < outline.OutlineCount(); ++jj )
542  {
543  poly = &outline.Outline( jj );
544 
545  GRClosedPoly( aClipBox, aDC, poly->PointCount(),
546  (wxPoint*)&poly->Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
547  aDrawInfo.m_Color, aDrawInfo.m_Color );
548  }
549  }
550 
551  if( aDrawInfo.m_PadClearance )
552  {
553  SHAPE_POLY_SET clearance_outline;
554  clearance_outline.Append( outline );
555 
556  clearance_outline.Inflate( aDrawInfo.m_PadClearance, segmentToCircleCount );
557 
558  for( int jj = 0; jj < clearance_outline.OutlineCount(); ++jj )
559  {
560  poly = &clearance_outline.Outline( jj );
561 
562  if( poly->PointCount() > 0 )
563  {
564  GRClosedPoly( aClipBox, aDC, poly->PointCount(),
565  (wxPoint*)&poly->Point( 0 ), false, 0,
566  aDrawInfo.m_Color, aDrawInfo.m_Color );
567  }
568  }
569  }
570  break;
571  }
572 
573  default:
574  break;
575  }
576 
577  // Draw the pad hole
578  wxPoint holepos = m_Pos - aDrawInfo.m_Offset;
579  int hole = m_Drill.x >> 1;
580 
581  bool drawhole = hole > 0;
582 
583  if( !aDrawInfo.m_ShowPadFilled && !aDrawInfo.m_ShowNotPlatedHole )
584  drawhole = false;
585 
586  if( drawhole )
587  {
588  bool blackpenstate = false;
589 
590  if( aDrawInfo.m_IsPrinting )
591  {
592  blackpenstate = GetGRForceBlackPenState();
593  GRForceBlackPen( false );
594  aDrawInfo.m_HoleColor = WHITE;
595  aDrawInfo.m_NPHoleColor = WHITE;
596  }
597  else
598  {
599  GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR );
600  }
601 
602  COLOR4D hole_color = aDrawInfo.m_HoleColor;
603 
604  if( aDrawInfo. m_ShowNotPlatedHole ) // Draw a specific hole color
605  hole_color = aDrawInfo.m_NPHoleColor;
606 
607  switch( GetDrillShape() )
608  {
610  if( aDC->LogicalToDeviceXRel( hole ) > 1 ) // hole is drawn if hole > 1pixel
611  GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0,
612  hole_color, hole_color );
613  break;
614 
616  {
617  wxPoint drl_start, drl_end;
618  GetOblongDrillGeometry( drl_start, drl_end, seg_width );
619  GRFilledSegment( aClipBox, aDC, holepos + drl_start,
620  holepos + drl_end, seg_width, hole_color );
621  }
622  break;
623 
624  default:
625  break;
626  }
627 
628  if( aDrawInfo.m_IsPrinting )
629  GRForceBlackPen( blackpenstate );
630  }
631 
632  GRSetDrawMode( aDC, aDrawInfo.m_DrawMode );
633 
634  // Draw "No connect" ( / or \ or cross X ) if necessary
635  if( GetNetCode() == 0 && aDrawInfo.m_ShowNCMark )
636  {
637  int dx0 = std::min( halfsize.x, halfsize.y );
638 
639  if( m_layerMask[F_Cu] ) /* Draw \ */
640  GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0,
641  holepos.x + dx0, holepos.y + dx0, 0, aDrawInfo.m_NoNetMarkColor );
642 
643  if( m_layerMask[B_Cu] ) // Draw /
644  GRLine( aClipBox, aDC, holepos.x + dx0, holepos.y - dx0,
645  holepos.x - dx0, holepos.y + dx0, 0, aDrawInfo.m_NoNetMarkColor );
646  }
647 
648  if( !aDrawInfo.m_IsPrinting )
649  GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR );
650 
651  // Draw the pad number
652  if( !aDrawInfo.m_Display_padnum && !aDrawInfo.m_Display_netname )
653  return;
654 
655  wxPoint tpos0 = shape_pos; // Position of the centre of text
656  wxPoint tpos = tpos0;
657  wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
658  int shortname_len = 0;
659 
660  if( aDrawInfo.m_Display_netname )
661  shortname_len = GetShortNetname().Len();
662 
663  if( GetShape() == PAD_SHAPE_CIRCLE )
664  angle = 0;
665 
666  AreaSize = m_Size;
667 
668  if( m_Size.y > m_Size.x )
669  {
670  angle += 900;
671  AreaSize.x = m_Size.y;
672  AreaSize.y = m_Size.x;
673  }
674 
675  if( shortname_len > 0 ) // if there is a netname, provides room to display this netname
676  {
677  AreaSize.y /= 2; // Text used only the upper area of the
678  // pad. The lower area displays the net name
679  tpos.y -= AreaSize.y / 2;
680  }
681 
682  // Calculate the position of text, that is the middle point of the upper
683  // area of the pad
684  RotatePoint( &tpos, shape_pos, angle );
685 
686  // Draw text with an angle between -90 deg and + 90 deg
687  double t_angle = angle;
688  NORMALIZE_ANGLE_90( t_angle );
689 
690  /* Note: in next calculations, texte size is calculated for 3 or more
691  * chars. Of course, pads numbers and nets names can have less than 3
692  * chars. but after some tries, i found this is gives the best look
693  */
694  constexpr int MIN_CHAR_COUNT = 3;
695 
696  unsigned int tsize;
697  EDA_RECT* clipBox = aDrawInfo.m_DrawPanel?
698  aDrawInfo.m_DrawPanel->GetClipBox() : NULL;
699 
700  if( aDrawInfo.m_Display_padnum )
701  {
702  int numpad_len = std::max( (int) m_name.Length(), MIN_CHAR_COUNT );
703  tsize = std::min( (int) AreaSize.y, AreaSize.x / numpad_len );
704 
705  if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small.
706  {
707  // tsize reserve room for marges and segments thickness
708  tsize = ( tsize * 7 ) / 10;
709  DrawGraphicHaloText( clipBox, aDC, tpos,
710  aDrawInfo.m_Color, BLACK, WHITE,
711  m_name, t_angle,
712  wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER,
713  GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
714 
715  }
716  }
717 
718  // display the short netname, if exists
719  if( shortname_len == 0 )
720  return;
721 
722  shortname_len = std::max( shortname_len, MIN_CHAR_COUNT );
723  tsize = std::min( AreaSize.y, AreaSize.x / shortname_len );
724 
725  if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable in size too small.
726  {
727  tpos = tpos0;
728 
729  if( aDrawInfo.m_Display_padnum )
730  tpos.y += AreaSize.y / 2;
731 
732  RotatePoint( &tpos, shape_pos, angle );
733 
734  // tsize reserve room for marges and segments thickness
735  tsize = ( tsize * 7 ) / 10;
736  DrawGraphicHaloText( clipBox, aDC, tpos,
737  aDrawInfo.m_Color, BLACK, WHITE,
738  GetShortNetname(), t_angle,
739  wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
740  GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
741  }
742 }
void DrawGraphicHaloText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, const COLOR4D aBgColor, COLOR4D aColor1, COLOR4D aColor2, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf), PLOTTER *aPlotter)
Draw graphic text with a border, so that it can be read on different backgrounds. ...
Definition: drawtxt.cpp:176
static int m_PadSketchModePenSize
Pen size used to draw pads in sketch mode (mode used to print pads on silkscreen layer) ...
Definition: class_pad.h:137
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:226
bool m_Display_padnum
Definition: class_pad.h:75
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:296
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
int PointCount() const
Function PointCount()
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:511
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
#define SEGCOUNT
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:488
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:381
COLOR4D m_NoNetMarkColor
Definition: class_pad.h:72
bool m_ShowNCMark
Definition: class_pad.h:79
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int OutlineCount() const
Returns the number of outlines in the set
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:851
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
void NORMALIZE_ANGLE_90(T &Angle)
Definition: trigo.h:299
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, COLOR4D Color, COLOR4D BgColor)
Function GRClosedPoly draws a closed polygon onto the drawing context aDC and optionally fills and/or...
Definition: gr_basic.cpp:784
bool m_IsPrinting
Definition: class_pad.h:82
wxString m_name
Definition: class_pad.h:756
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
#define MIN_TEXT_SIZE
Definition: drawtxt.h:43
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:277
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:591
GR_DRAWMODE m_DrawMode
Definition: class_pad.h:67
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
EDA_DRAW_PANEL * m_DrawPanel
Definition: class_pad.h:66
COLOR4D m_HoleColor
Definition: class_pad.h:70
const wxSize & GetSize() const
Definition: class_pad.h:269
EDA_RECT * GetClipBox()
bool m_ShowNotPlatedHole
Definition: class_pad.h:80
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos
Definition: class_pad.h:773
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:358
int m_PadClearance
Definition: class_pad.h:73
int GetNetCode() const
Function GetNetCode.
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
int BuildSegmentFromOvalShape(wxPoint &aSegStart, wxPoint &aSegEnd, double aRotation, const wxSize &aMargin) const
Function BuildSegmentFromOvalShape Has meaning only for OVAL (and ROUND) pads Build an equivalent seg...
wxPoint m_Offset
Definition: class_pad.h:83
void GetOblongDrillGeometry(wxPoint &aStartPoint, wxPoint &aEndPoint, int &aWidth) const
Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segm...
Definition: class_pad.cpp:749
#define max(a, b)
Definition: auxiliary.h:86
Class SHAPE_LINE_CHAIN.
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:599
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:828
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
Class EDA_RECT handles the component boundary box.
void GetRoundRectCornerCenters(wxPoint aCenters[4], int aRadius, const wxPoint &aPosition, const wxSize &aSize, double aRotation)
Helper function GetRoundRectCornerCenters Has meaning only for rounded rect Returns the centers of th...
Definition: colors.h:49
wxPoint ShapePos() const
Definition: class_pad.cpp:500
bool m_ShowPadFilled
Definition: class_pad.h:77
COLOR4D m_NPHoleColor
Definition: class_pad.h:71
COLOR4D m_Color
Definition: class_pad.h:68
VECTOR2I & Point(int aIndex)
Function Point()
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE...
Definition: class_pad.h:786
Definition: colors.h:45
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
bool m_Display_netname
Definition: class_pad.h:76
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:287
wxSize m_Mask_margin
Definition: class_pad.h:74
#define min(a, b)
Definition: auxiliary.h:85
wxPoint m_Pos
pad Position on board
Definition: class_pad.h:758
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
const wxString & GetShortNetname() const
Function GetShortNetname.
D_PAD* D_PAD::Duplicate ( ) const
inline

same as Clone, but returns a D_PAD item.

Useful mainly for pythons scripts, because Clone (virtual function) returns an EDA_ITEM.

Definition at line 706 of file class_pad.h.

References Clone().

707  {
708  return (D_PAD*) Clone();
709  }
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_pad.cpp:1208
void BOARD_ITEM::Flip ( const VECTOR2I aCentre)
inlineinherited

Definition at line 270 of file class_board_item.h.

References BOARD_ITEM::Flip(), VECTOR2< T >::x, and VECTOR2< T >::y.

271  {
272  Flip( wxPoint( aCentre.x, aCentre.y ) );
273  }
virtual void Flip(const wxPoint &aCentre)
Function Flip Flip this object, i.e.
void D_PAD::Flip ( const wxPoint aCentre)
overridevirtual

Function Flip Flip this object, i.e.

change the board side for this object

Parameters
aCentre- the rotation point.

Reimplemented from BOARD_ITEM.

Definition at line 408 of file class_pad.cpp.

References FlipLayerMask(), FlipPrimitives(), GetOrientation(), GetPosition(), m_DeltaSize, m_layerMask, m_Offset, m_Pos0, MIRROR(), SetLayerSet(), SetOrientation(), SetY(), and wxPoint::y.

409 {
410  int y = GetPosition().y;
411  MIRROR( y, aCentre.y ); // invert about x axis.
412  SetY( y );
413 
414  MIRROR( m_Pos0.y, 0 );
415  MIRROR( m_Offset.y, 0 );
416  MIRROR( m_DeltaSize.y, 0 );
417 
419 
420  // flip pads layers
421  // PADS items are currently on all copper layers, or
422  // currently, only on Front or Back layers.
423  // So the copper layers count is not taken in account
425 
426  // Flip the basic shapes, in custom pads
427  FlipPrimitives();
428 
429  // m_boundingRadius = -1; the shape has not been changed
430 }
LSET FlipLayerMask(LSET aMask, int aCopperLayersCount)
Calculate the mask layer when flipping a footprint BACK and FRONT copper layers, mask, paste, solder layers are swapped internal layers are flipped only if the copper layers count is known.
Definition: lset.cpp:491
void FlipPrimitives()
Flip the basic shapes, in custom pads.
Definition: class_pad.cpp:434
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
wxSize m_DeltaSize
delta on rectangular shapes
Definition: class_pad.h:820
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:394
void SetY(int y)
Definition: class_pad.h:259
wxPoint m_Pos0
Initial Pad position (i.e.
Definition: class_pad.h:822
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:401
wxPoint m_Offset
m_Offset is useful only for oblong and rect pads (it can be used for other shapes, but without any interest).
Definition: class_pad.h:814
void D_PAD::FlipPrimitives ( )

Flip the basic shapes, in custom pads.

Definition at line 434 of file class_pad.cpp.

References PAD_CS_PRIMITIVE::m_ArcAngle, m_basicShapes, m_customShapeAsPolygon, PAD_CS_PRIMITIVE::m_End, PAD_CS_PRIMITIVE::m_Poly, PAD_CS_PRIMITIVE::m_Shape, PAD_CS_PRIMITIVE::m_Start, MIRROR(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), S_POLYGON, wxPoint::y, and VECTOR2< T >::y.

Referenced by Flip(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

435 {
436  // Flip custom shapes
437  for( unsigned ii = 0; ii < m_basicShapes.size(); ++ii )
438  {
439  PAD_CS_PRIMITIVE& primitive = m_basicShapes[ii];
440 
441  MIRROR( primitive.m_Start.y, 0 );
442  MIRROR( primitive.m_End.y, 0 );
443  primitive.m_ArcAngle = -primitive.m_ArcAngle;
444 
445  switch( primitive.m_Shape )
446  {
447  case S_POLYGON: // polygon
448  for( unsigned jj = 0; jj < primitive.m_Poly.size(); jj++ )
449  MIRROR( primitive.m_Poly[jj].y, 0 );
450  break;
451 
452  default:
453  break;
454  }
455  }
456 
457  // Flip local coordinates in merged Polygon
458  for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt )
459  {
461 
462  for( int ii = 0; ii < poly.PointCount(); ++ii )
463  MIRROR( poly.Point( ii ).y, 0 );
464  }
465 }
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
int PointCount() const
Function PointCount()
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100
polygon (not yet used for tracks, but could be in microwave apps)
int OutlineCount() const
Returns the number of outlines in the set
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
std::vector< wxPoint > m_Poly
is also the start point of the arc
Definition: class_pad.h:102
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos
Definition: class_pad.h:773
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101
STROKE_T m_Shape
Definition: class_pad.h:94
Class SHAPE_LINE_CHAIN.
VECTOR2I & Point(int aIndex)
Function Point()
double m_ArcAngle
radius of a circle
Definition: class_pad.h:99
std::string BOARD_ITEM::FormatAngle ( double  aAngle)
staticinherited

Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.

Note
Internal angles for board items can be either degrees or tenths of degree on how KiCad is built.
Parameters
aAngleA angle value to convert.
Returns
A std::string object containing the converted angle.

Definition at line 170 of file class_board_item.cpp.

171 {
172  char temp[50];
173 
174  int len = snprintf( temp, sizeof(temp), "%.10g", aAngle / 10.0 );
175 
176  return std::string( temp, len );
177 }
std::string BOARD_ITEM::FormatInternalUnits ( int  aValue)
staticinherited

Function FormatInternalUnits converts aValue from board internal units to a string appropriate for writing to file.

Note
Internal units for board items can be either deci-mils or nanometers depending on how KiCad is build.
Parameters
aValueA coordinate value to convert.
Returns
A std::string object containing the converted value.

Definition at line 89 of file class_board_item.cpp.

Referenced by checkConnectedTo(), ConvertOutlineToPolygon(), BOARD_ITEM::FormatInternalUnits(), and BOARD::TracksInNetBetweenPoints().

90 {
91 #if 1
92 
93  char buf[50];
94  int len;
95  double mm = aValue / IU_PER_MM;
96 
97  if( mm != 0.0 && fabs( mm ) <= 0.0001 )
98  {
99  len = sprintf( buf, "%.10f", mm );
100 
101  while( --len > 0 && buf[len] == '0' )
102  buf[len] = '\0';
103 
104  if( buf[len] == '.' )
105  buf[len] = '\0';
106  else
107  ++len;
108  }
109  else
110  {
111  len = sprintf( buf, "%.10g", mm );
112  }
113 
114  return std::string( buf, len );
115 
116 #else
117 
118  // Assume aValue is in nanometers, and that we want the result in millimeters,
119  // and that int is 32 bits wide. Then perform an alternative algorithm.
120  // Can be used to verify that the above algorithm is correctly generating text.
121  // Convert aValue into an integer string, then insert a decimal point manually.
122  // Results are the same as above general purpose algorithm.
123 
124  wxASSERT( sizeof(int) == 4 );
125 
126  if( aValue == 0 )
127  return std::string( 1, '0' );
128  else
129  {
130  char buf[50];
131  int len = sprintf( buf, aValue > 0 ? "%06d" : "%07d", aValue ); // optionally pad w/leading zeros
132 
133  std::string ret( buf, len );
134 
135  std::string::iterator it = ret.end() - 1; // last byte
136 
137  // insert '.' at 6 positions from end, dividing by 10e6 (a million), nm => mm
138  std::string::iterator decpoint = ret.end() - 6;
139 
140  // truncate trailing zeros, up to decimal point position
141  for( ; *it=='0' && it >= decpoint; --it )
142  ret.erase( it ); // does not invalidate iterators it or decpoint
143 
144  if( it >= decpoint )
145  {
146  ret.insert( decpoint, '.' );
147 
148  // decpoint is invalidated here, after insert()
149 
150 #if 1 // want a leading zero when decimal point is in first position?
151  if( ret[0] == '.' )
152  {
153  // insert leading zero ahead of decimal point.
154  ret.insert( ret.begin(), '0' );
155  }
156  else if( ret[0]=='-' && ret[1]=='.' )
157  {
158  ret.insert( ret.begin() + 1, '0' );
159  }
160 #endif
161  }
162 
163  return ret;
164  }
165 
166 #endif
167 }
std::string BOARD_ITEM::FormatInternalUnits ( const wxPoint aPoint)
staticinherited

Definition at line 180 of file class_board_item.cpp.

References BOARD_ITEM::FormatInternalUnits(), wxPoint::x, and wxPoint::y.

181 {
182  return FormatInternalUnits( aPoint.x ) + " " + FormatInternalUnits( aPoint.y );
183 }
static std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from board internal units to a string appropriate for wr...
std::string BOARD_ITEM::FormatInternalUnits ( const wxSize &  aSize)
staticinherited

Definition at line 186 of file class_board_item.cpp.

References BOARD_ITEM::FormatInternalUnits().

187 {
188  return FormatInternalUnits( aSize.GetWidth() ) + " " + FormatInternalUnits( aSize.GetHeight() );
189 }
static std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from board internal units to a string appropriate for wr...
PAD_SHAPE_T D_PAD::GetAnchorPadShape ( ) const
inline

Function GetAnchorPadShape.

Returns
the shape of the anchor pad shape, for custom shaped pads.

Definition at line 226 of file class_pad.h.

References m_anchorPadShape.

Referenced by DrawShape(), PCB_IO::format(), GetBestAnchorPosition(), PCB_BASE_FRAME::Import_Pad_Settings(), ImportSettingsFromMaster(), DIALOG_PAD_PROPERTIES::initValues(), MergePrimitivesAsPolygon(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and DIALOG_PAD_PROPERTIES::transferDataToPad().

226 { return m_anchorPadShape; }
PAD_SHAPE_T m_anchorPadShape
for custom shaped pads: shape of pad anchor, PAD_SHAPE_RECT, PAD_SHAPE_CIRCLE
Definition: class_pad.h:797
bool D_PAD::GetBestAnchorPosition ( VECTOR2I aPos)

Definition at line 342 of file class_pad_custom_shape_functions.cpp.

References SHAPE_POLY_SET::BBox(), buildCustomPadPolygon(), SHAPE_POLY_SET::Contains(), SHAPE_POLY_SET::COutline(), dist, SHAPE_LINE_CHAIN::Distance(), EuclideanNorm(), GetAnchorPadShape(), BOX2< Vec >::GetHeight(), GetSize(), max, min, PAD_SHAPE_CIRCLE, rescale(), VECTOR2< T >::x, and VECTOR2< T >::y.

343 {
344  SHAPE_POLY_SET poly;
345 
346  if ( !buildCustomPadPolygon( &poly, 16 ) )
347  return false;
348 
349  const int minSteps = 10;
350  const int maxSteps = 50;
351 
352  int stepsX, stepsY;
353 
354  auto bbox = poly.BBox();
355 
356  if( bbox.GetWidth() < bbox.GetHeight() )
357  {
358  stepsX = minSteps;
359  stepsY = minSteps * (double) bbox.GetHeight() / (double )(bbox.GetWidth() + 1);
360  }
361  else
362  {
363  stepsY = minSteps;
364  stepsX = minSteps * (double) bbox.GetWidth() / (double )(bbox.GetHeight() + 1);
365  }
366 
367  stepsX = std::max(minSteps, std::min( maxSteps, stepsX ) );
368  stepsY = std::max(minSteps, std::min( maxSteps, stepsY ) );
369 
370  auto center = bbox.Centre();
371 
372  auto minDist = std::numeric_limits<int64_t>::max();
373  int64_t minDistEdge;
374 
376  {
377  minDistEdge = GetSize().x;
378  }
379  else
380  {
381  minDistEdge = std::max( GetSize().x, GetSize().y );
382  }
383 
384  OPT<VECTOR2I> bestAnchor;
385 
386  for ( int y = 0; y < stepsY ; y++ )
387  {
388  for ( int x = 0; x < stepsX; x++ )
389  {
390  VECTOR2I p = bbox.GetPosition();
391  p.x += rescale( x, bbox.GetWidth(), (stepsX - 1) );
392  p.y += rescale( y, bbox.GetHeight(), (stepsY - 1) );
393 
394  if ( poly.Contains(p) )
395  {
396 
397  auto dist = (center - p).EuclideanNorm();
398  auto distEdge = poly.COutline(0).Distance( p, true );
399  if ( distEdge >= minDistEdge )
400  {
401  if ( dist < minDist )
402  {
403  bestAnchor = p;
404  minDist = dist;
405  }
406  }
407  }
408  }
409  }
410 
411  if ( bestAnchor )
412  {
413  aPos = *bestAnchor;
414  return true;
415  }
416 
417  return false;
418 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:226
static const int dist[10][10]
Definition: dist.cpp:57
Class SHAPE_POLY_SET.
const wxSize & GetSize() const
Definition: class_pad.h:269
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
int rescale(int aNumerator, int aValue, int aDenominator)
Definition: math_util.cpp:32
coord_type GetHeight() const
Definition: box2.h:186
#define max(a, b)
Definition: auxiliary.h:86
boost::optional< T > OPT
Definition: optional.h:7
bool buildCustomPadPolygon(SHAPE_POLY_SET *aMergedPolygon, int aCircleToSegmentsCount)
int Distance(const VECTOR2I &aP, bool aOutlineOnly=false) const
Function Distance()
const BOX2I BBox(int aClearance=0) const override
Function BBox()
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1) const
Returns true if a given subpolygon contains the point aP.
#define min(a, b)
Definition: auxiliary.h:85
BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.

Definition at line 63 of file class_board_item.cpp.

References BOARD_ITEM::GetBoard(), BOARD_ITEM::GetParent(), PCB_T, and EDA_ITEM::Type().

Referenced by ZONE_CONTAINER::buildFeatureHoleList(), DeleteMarkedItems(), TEXTE_PCB::Draw(), PCB_TARGET::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), DIMENSION::Draw(), MODULE::Draw(), SEGZONE::Draw(), VIA::Draw(), Draw(), MODULE::DrawAncre(), ZONE_CONTAINER::DrawFilledArea(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), EVT_COMMAND_RANGE(), TEXTE_PCB::Flip(), TRACK::Flip(), VIA::Flip(), ZONE_CONTAINER::Flip(), BOARD_ITEM::GetBoard(), MODULE::GetBoundingBox(), BOARD_ITEM::GetLayerName(), TRACK::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), GetMsgPanelInfo(), TRACK::GetMsgPanelInfoBase(), SEGZONE::GetMsgPanelInfoBase(), VIA::GetMsgPanelInfoBase(), TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), TRACK::GetSelectMenuText(), SEGZONE::GetSelectMenuText(), VIA::GetSelectMenuText(), ZONE_CONTAINER::GetSelectMenuText(), GetSelectMenuText(), GetSolderMaskMargin(), GetSolderPasteMargin(), PushTrack(), BOARD_CONNECTED_ITEM::SetNet(), BOARD_CONNECTED_ITEM::SetNetCode(), and VIA::ViewGetLOD().

64 {
65  if( Type() == PCB_T )
66  return (BOARD*) this;
67 
68  BOARD_ITEM* parent = GetParent();
69 
70  if( parent )
71  return parent->GetBoard();
72 
73  return NULL;
74 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
BOARD_ITEM_CONTAINER * GetParent() const
Definition: typeinfo.h:85
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
const EDA_RECT D_PAD::GetBoundingBox ( ) const
overridevirtual

Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.

This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.

Reimplemented from EDA_ITEM.

Definition at line 199 of file class_pad.cpp.

References abs, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), CustomShapeAsPolygonToBoardPosition(), EDA_RECT::GetBoundingBoxRotated(), GetOrientation(), GetPosition(), GetShape(), EDA_RECT::Inflate(), m_customShapeAsPolygon, m_DeltaSize, m_Orient, m_Pos, m_Size, max, EDA_RECT::Merge(), min, SHAPE_POLY_SET::OutlineCount(), PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), ShapePos(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by CreateThermalReliefPadPolygon(), HitTest(), PCB_BASE_FRAME::Import_Pad_Settings(), PCB_EDIT_FRAME::moveExact(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and ViewBBox().

200 {
201  EDA_RECT area;
202  wxPoint quadrant1, quadrant2, quadrant3, quadrant4;
203  int x, y, r, dx, dy;
204 
205  wxPoint center = ShapePos();
206  wxPoint endPoint;
207 
208  EDA_RECT endRect;
209 
210  switch( GetShape() )
211  {
212  case PAD_SHAPE_CIRCLE:
213  area.SetOrigin( center );
214  area.Inflate( m_Size.x / 2 );
215  break;
216 
217  case PAD_SHAPE_OVAL:
218  /* To get the BoundingBox of an oval pad:
219  * a) If the pad is ROUND, see method for PAD_SHAPE_CIRCLE above
220  * OTHERWISE:
221  * b) Construct EDA_RECT for portion between circular ends
222  * c) Rotate that EDA_RECT
223  * d) Add the circular ends to the EDA_RECT
224  */
225 
226  // Test if the shape is circular
227  if( m_Size.x == m_Size.y )
228  {
229  area.SetOrigin( center );
230  area.Inflate( m_Size.x / 2 );
231  break;
232  }
233 
234  if( m_Size.x > m_Size.y )
235  {
236  // Pad is horizontal
237  dx = ( m_Size.x - m_Size.y ) / 2;
238  dy = m_Size.y / 2;
239 
240  // Location of end-points
241  x = dx;
242  y = 0;
243  r = dy;
244  }
245  else
246  {
247  // Pad is vertical
248  dx = m_Size.x / 2;
249  dy = ( m_Size.y - m_Size.x ) / 2;
250 
251  x = 0;
252  y = dy;
253  r = dx;
254  }
255 
256  // Construct the center rectangle and rotate
257  area.SetOrigin( center );
258  area.Inflate( dx, dy );
259  area = area.GetBoundingBoxRotated( center, m_Orient );
260 
261  endPoint = wxPoint( x, y );
262  RotatePoint( &endPoint, m_Orient );
263 
264  // Add points at each quadrant of circular regions
265  endRect.SetOrigin( center + endPoint );
266  endRect.Inflate( r );
267 
268  area.Merge( endRect );
269 
270  endRect.SetSize( 0, 0 );
271  endRect.SetOrigin( center - endPoint );
272  endRect.Inflate( r );
273 
274  area.Merge( endRect );
275 
276  break;
277 
278  case PAD_SHAPE_RECT:
279  case PAD_SHAPE_ROUNDRECT:
280  // Use two opposite corners and track their rotation
281  // (use symmetry for other points)
282  quadrant1.x = m_Size.x/2;
283  quadrant1.y = m_Size.y/2;
284  quadrant2.x = -m_Size.x/2;
285  quadrant2.y = m_Size.y/2;
286 
287  RotatePoint( &quadrant1, m_Orient );
288  RotatePoint( &quadrant2, m_Orient );
289  dx = std::max( std::abs( quadrant1.x ) , std::abs( quadrant2.x ) );
290  dy = std::max( std::abs( quadrant1.y ) , std::abs( quadrant2.y ) );
291 
292  // Set the bbox
293  area.SetOrigin( ShapePos() );
294  area.Inflate( dx, dy );
295  break;
296 
297  case PAD_SHAPE_TRAPEZOID:
298  // Use the four corners and track their rotation
299  // (Trapezoids will not be symmetric)
300 
301  quadrant1.x = (m_Size.x + m_DeltaSize.y)/2;
302  quadrant1.y = (m_Size.y - m_DeltaSize.x)/2;
303 
304  quadrant2.x = -(m_Size.x + m_DeltaSize.y)/2;
305  quadrant2.y = (m_Size.y + m_DeltaSize.x)/2;
306 
307  quadrant3.x = -(m_Size.x - m_DeltaSize.y)/2;
308  quadrant3.y = -(m_Size.y + m_DeltaSize.x)/2;
309 
310  quadrant4.x = (m_Size.x - m_DeltaSize.y)/2;
311  quadrant4.y = -(m_Size.y - m_DeltaSize.x)/2;
312 
313  RotatePoint( &quadrant1, m_Orient );
314  RotatePoint( &quadrant2, m_Orient );
315  RotatePoint( &quadrant3, m_Orient );
316  RotatePoint( &quadrant4, m_Orient );
317 
318  x = std::min( quadrant1.x, std::min( quadrant2.x, std::min( quadrant3.x, quadrant4.x) ) );
319  y = std::min( quadrant1.y, std::min( quadrant2.y, std::min( quadrant3.y, quadrant4.y) ) );
320  dx = std::max( quadrant1.x, std::max( quadrant2.x, std::max( quadrant3.x, quadrant4.x) ) );
321  dy = std::max( quadrant1.y, std::max( quadrant2.y, std::max( quadrant3.y, quadrant4.y) ) );
322 
323  area.SetOrigin( ShapePos().x + x, ShapePos().y + y );
324  area.SetSize( dx-x, dy-y );
325  break;
326 
327  case PAD_SHAPE_CUSTOM:
328  {
330  // Move shape to actual position
332  quadrant1 = m_Pos;
333  quadrant2 = m_Pos;
334 
335  for( int cnt = 0; cnt < polySet.OutlineCount(); ++cnt )
336  {
337  const SHAPE_LINE_CHAIN& poly = polySet.COutline( cnt );
338 
339  for( int ii = 0; ii < poly.PointCount(); ++ii )
340  {
341  quadrant1.x = std::min( quadrant1.x, poly.CPoint( ii ).x );
342  quadrant1.y = std::min( quadrant1.y, poly.CPoint( ii ).y );
343  quadrant2.x = std::max( quadrant2.x, poly.CPoint( ii ).x );
344  quadrant2.y = std::max( quadrant2.y, poly.CPoint( ii ).y );
345  }
346  }
347 
348  area.SetOrigin( quadrant1 );
349  area.SetEnd( quadrant2 );
350  }
351  break;
352 
353  default:
354  break;
355  }
356 
357  return area;
358 }
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect...
int PointCount() const
Function PointCount()
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
void SetOrigin(const wxPoint &pos)
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
#define abs(a)
Definition: auxiliary.h:84
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
Class SHAPE_POLY_SET.
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
void SetEnd(int x, int y)
const EDA_RECT GetBoundingBoxRotated(wxPoint aRotCenter, double aAngle)
Function GetBoundingBoxRotated.
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos
Definition: class_pad.h:773
wxSize m_DeltaSize
delta on rectangular shapes
Definition: class_pad.h:820
void SetSize(const wxSize &size)
#define max(a, b)
Definition: auxiliary.h:86
Class SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
Class EDA_RECT handles the component boundary box.
wxPoint ShapePos() const
Definition: class_pad.cpp:500
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
#define min(a, b)
Definition: auxiliary.h:85
wxPoint m_Pos
pad Position on board
Definition: class_pad.h:758
int D_PAD::GetBoundingRadius ( ) const
inline

Function GetBoundingRadius returns the radius of a minimum sized circle which fully encloses this pad.

The center is the pad position

Definition at line 586 of file class_pad.h.

References boundingRadius(), and m_boundingRadius.

Referenced by DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), HitTest(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), and DRC::testPad2Pad().

587  {
588  // Any member function which would affect this calculation should set
589  // m_boundingRadius to -1 to re-trigger the calculation from here.
590  // Currently that is only m_Size, m_DeltaSize, and m_padShape accessors.
591  if( m_boundingRadius == -1 )
592  {
594  }
595 
596  return m_boundingRadius;
597  }
int m_boundingRadius
radius of the circle containing the pad shape
Definition: class_pad.h:754
int boundingRadius() const
Function boundingRadius returns a calculated radius of a bounding circle for this pad...
Definition: class_pad.cpp:133
virtual const wxPoint BOARD_ITEM::GetCenter ( ) const
inlinevirtualinherited

Function GetCenter()

This defaults to the same point as returned by GetPosition(), unless overridden

Returns
centre point of the item

Reimplemented in DRAWSEGMENT.

Definition at line 97 of file class_board_item.h.

References BOARD_ITEM::GetPosition().

Referenced by LEGACY_ARRAY_CREATOR::getRotationCentre(), and DIALOG_CREATE_ARRAY::ARRAY_CIRCULAR_OPTIONS::TransformItem().

97 { return GetPosition(); }
virtual const wxPoint & GetPosition() const =0
wxString D_PAD::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Implements EDA_ITEM.

Definition at line 646 of file class_pad.h.

647  {
648  return wxT( "PAD" );
649  }
int D_PAD::GetClearance ( BOARD_CONNECTED_ITEM aItem = NULL) const
overridevirtual

Function GetClearance returns the clearance in internal units.

If aItem is not NULL then the returned clearance is the greater of this object's clearance and aItem's clearance. If aItem is NULL, then this objects clearance is returned.

Parameters
aItemis another BOARD_CONNECTED_ITEM or NULL
Returns
int - the clearance in internal units.

Reimplemented from BOARD_CONNECTED_ITEM.

Definition at line 546 of file class_pad.cpp.

References BOARD_CONNECTED_ITEM::GetClearance(), MODULE::GetLocalClearance(), GetLocalClearance(), GetParent(), m_LocalClearance, and max.

Referenced by ZONE_CONTAINER::buildFeatureHoleList(), DRC::checkClearancePadToPad(), KIGFX::PCB_PAINTER::draw(), Draw(), genModuleOnRoutingMatrix(), DRC::testPad2Pad(), and DRC::testTexts().

547 {
548  // A pad can have specific clearance parameters that
549  // overrides its NETCLASS clearance value
550  int clearance = m_LocalClearance;
551 
552  if( clearance == 0 )
553  {
554  // If local clearance is 0, use the parent footprint clearance value
555  if( GetParent() && GetParent()->GetLocalClearance() )
556  clearance = GetParent()->GetLocalClearance();
557  }
558 
559  if( clearance == 0 ) // If the parent footprint clearance value = 0, use NETCLASS value
560  return BOARD_CONNECTED_ITEM::GetClearance( aItem );
561 
562  // We have a specific clearance.
563  // if aItem, return the biggest clearance
564  if( aItem )
565  {
566  int hisClearance = aItem->GetClearance();
567  return std::max( hisClearance, clearance );
568  }
569 
570  // Return the specific clearance.
571  return clearance;
572 }
int m_LocalClearance
Local clearance.
Definition: class_pad.h:834
int GetLocalClearance() const
Definition: class_module.h:199
MODULE * GetParent() const
Definition: class_pad.h:162
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const
Function GetClearance returns the clearance in internal units.
int GetLocalClearance() const
Definition: class_pad.h:406
#define max(a, b)
Definition: auxiliary.h:86
const SHAPE_POLY_SET& D_PAD::GetCustomShapeAsPolygon ( ) const
inline

Accessor to the custom shape as one polygon.

Definition at line 341 of file class_pad.h.

References m_customShapeAsPolygon.

Referenced by CINFO3D_VISU::buildPadShapePolygon(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), CINFO3D_VISU::createNewPadWithClearance(), CreatePadsShapesSection(), KIGFX::PCB_PAINTER::draw(), and PNS_KICAD_IFACE::syncPad().

341 { return m_customShapeAsPolygon; }
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates, orient 0, coordinates relative to m_Pos
Definition: class_pad.h:773
CUST_PAD_SHAPE_IN_ZONE D_PAD::GetCustomShapeInZoneOpt ( ) const
inline
Returns
the option for the custom pad shape to use as clearance area in copper zones

Definition at line 232 of file class_pad.h.

References m_customShapeClearanceArea.

Referenced by PCB_IO::format(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

233  {
235  }
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
How to build the custom shape in zone, to create the clearance area: CUST_PAD_SHAPE_IN_ZONE_OUTLINE =...
Definition: class_pad.h:781
STATUS_FLAGS EDA_ITEM::GetFlags ( ) const
inlineinherited

Definition at line 269 of file base_struct.h.

References EDA_ITEM::m_Flags.

Referenced by AbortMoveAndEditTarget(), SCH_SCREEN::addConnectedItemsToBlock(), AddMenusForBitmap(), AddMenusForBusEntry(), AddMenusForComponent(), AddMenusForComponentField(), AddMenusForEditComponent(), AddMenusForGLabel(), AddMenusForHierchicalSheet(), AddMenusForHLabel(), AddMenusForLabel(), AddMenusForSheetPin(), AddMenusForText(), SCH_EDIT_FRAME::BeginSegment(), SCH_EDIT_FRAME::ChangeTextOrient(), Collect_TrackSegmentsToDrag(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), LIB_EDIT_FRAME::CreatePin(), PCB_EDIT_FRAME::createPopUpMenuForFootprints(), PCB_EDIT_FRAME::createPopUpMenuForFpPads(), PCB_EDIT_FRAME::createPopUpMenuForFpTexts(), PCB_EDIT_FRAME::createPopUpMenuForTexts(), PCB_EDIT_FRAME::createPopupMenuForTracks(), PCB_EDIT_FRAME::createPopUpMenuForZones(), PCB_EDIT_FRAME::Delete_Segment_Edge(), BOARD::Draw(), PCB_EDIT_FRAME::Edit_TrackSegm_Width(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditImage(), PCB_EDIT_FRAME::FlipTextePcb(), LIB_VIEW_FRAME::GeneralControl(), SCH_EDIT_FRAME::GeneralControl(), SCH_SCREEN::GetConnection(), InitialiseDragParameters(), EDA_DRAW_FRAME::isBusy(), LIB_EDIT_FRAME::LoadOneSymbol(), Magnetize(), SCH_EDIT_FRAME::MirrorImage(), SCH_EDIT_FRAME::MirrorSheet(), moveBitmap(), SCH_EDIT_FRAME::OnAutoplaceFields(), SCH_EDIT_FRAME::OnConvertTextType(), SCH_EDIT_FRAME::OnCopySchematicItemRequest(), SCH_EDIT_FRAME::OnDragItem(), SCH_EDIT_FRAME::OnEditItem(), LIB_EDIT_FRAME::OnEditPin(), FOOTPRINT_EDIT_FRAME::OnHotKey(), SCH_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotkeyBeginRoute(), PCB_EDIT_FRAME::OnHotkeyCopyItem(), PCB_EDIT_FRAME::OnHotkeyDeleteItem(), PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem(), PCB_EDIT_FRAME::OnHotkeyEditItem(), PCB_EDIT_FRAME::OnHotkeyFlipItem(), PCB_EDIT_FRAME::OnHotkeyMoveItem(), PCB_EDIT_FRAME::OnHotkeyPlaceItem(), PCB_EDIT_FRAME::OnHotkeyRotateItem(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), FOOTPRINT_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnLeftDClick(), PCB_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnMoveItem(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick(), SCH_EDIT_FRAME::OnOpenLibraryEditor(), SCH_EDIT_FRAME::OnOrient(), FOOTPRINT_EDIT_FRAME::OnRightClick(), GERBVIEW_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRightClick(), PCB_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRotate(), SCH_EDIT_FRAME::OnSelectUnit(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDIT_FRAME::PlaceTarget(), FOOTPRINT_EDIT_FRAME::PrepareItemForHotkey(), LIB_EDIT_FRAME::Process_Special_Functions(), EDIT_TOOL::Properties(), TRACKS_CLEANER::removeDuplicatesOfTrack(), PCB_BASE_FRAME::Rotate_Module(), PCB_EDIT_FRAME::Rotate_Texte_Pcb(), SCH_EDIT_FRAME::RotateField(), SCH_EDIT_FRAME::RotateHierarchicalSheet(), SCH_EDIT_FRAME::RotateImage(), PCB_BASE_FRAME::RotateTextModule(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SCREEN::SelectBlockItems(), SCH_EDIT_FRAME::SetBusEntryShape(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), Show_Drag_Track_Segment_With_Cte_Slope(), Show_MoveNode(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), DIALOG_LABEL_EDITOR::TextPropertiesAccept(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow().

269 { return m_Flags; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Function GetLayer returns the primary layer this item is on.

Reimplemented in ZONE_CONTAINER.

Definition at line 124 of file class_board_item.h.

References BOARD_ITEM::m_Layer.

Referenced by Abort_MoveOrCopyModule(), DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer(), DIMENSION::AdjustDimensionDetails(), PCB_EDIT_FRAME::Begin_DrawSegment(), GRID_HELPER::BestSnapAnchor(), PCB_EDIT_FRAME::Change_Side_Module(), checkConnectedTo(), MODULE::CopyNetlistSettings(), CreateBoardSection(), MWAVE::CreateMicrowaveInductor(), CreateRoutesSection(), DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), DRC::doTrackKeepoutDrc(), TEXTE_MODULE::Draw(), DRAWSEGMENT::Draw(), KIGFX::PCB_PAINTER::draw(), FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer(), export_vrml_drawsegment(), export_vrml_edge_module(), export_vrml_module(), export_vrml_pcbtext(), export_vrml_text_module(), PCB_EDIT_FRAME::ExportToGenCAD(), TEXTE_PCB::Flip(), PCB_TARGET::Flip(), EDGE_MODULE::Flip(), TEXTE_MODULE::Flip(), TRACK::Flip(), DIMENSION::Flip(), DRAWSEGMENT::Flip(), MODULE::Flip(), PCB_IO::FootprintSave(), FootprintWriteShape(), PCB_IO::formatLayer(), DSN::SPECCTRA_DB::FromBOARD(), genModuleOnRoutingMatrix(), genPlacementRoutingMatrix(), BOARD::GetFootprint(), ZONE_CONTAINER::GetLayer(), getOptimalModulePlacement(), BOARD::GetPad(), BOARD::GetVisibleTrack(), SELECTION_TOOL::guessSelectionCandidates(), idf_export_module(), DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), IsFlipped(), MODULE::IsFlipped(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), BOARD::MarkTrace(), BOARD::OnAreaPolygonModified(), PCB_EDIT_FRAME::OnRightClick(), PlaceCells(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), BRDITEMS_PLOTTER::Plot_1_EdgeModule(), BRDITEMS_PLOTTER::Plot_Edges_Modules(), BRDITEMS_PLOTTER::PlotAllTextsModule(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotDrawSegment(), BRDITEMS_PLOTTER::PlotPcbTarget(), BRDITEMS_PLOTTER::PlotTextePcb(), Print_Module(), TRACKS_CLEANER::removeDuplicatesOfTrack(), SELECTION_TOOL::selectable(), ShowClearance(), PCB_EDIT_FRAME::Swap_Layers(), PNS_KICAD_IFACE::syncTrack(), TEXTE_MODULE::TEXTE_MODULE(), TraceSegmentPcb(), TrackListSortByNetcode(), DialogEditModuleText::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow(), DialogEditModuleText::TransferDataToWindow(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), CINFO3D_VISU::transformGraphicModuleEdgeToPolygonSet(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TstModuleOnBoard(), TEXTE_MODULE::ViewGetLayers(), and TRACK::ViewGetLayers().

124 { return m_Layer; }
PCB_LAYER_ID m_Layer
wxString BOARD_ITEM::GetLayerName ( ) const
inherited

Function GetLayerName returns the name of the PCB layer on which the item resides.

Returns
wxString containing the layer name associated with this item.

Definition at line 77 of file class_board_item.cpp.

References BOARD_ITEM::GetBoard(), BOARD::GetLayerName(), BOARD::GetStandardLayerName(), and BOARD_ITEM::m_Layer.

Referenced by PCB_IO::format(), PCB_IO::formatLayer(), TEXTE_PCB::GetMsgPanelInfo(), EDGE_MODULE::GetMsgPanelInfo(), ZONE_CONTAINER::GetMsgPanelInfo(), DRAWSEGMENT::GetMsgPanelInfo(), TEXTE_MODULE::GetMsgPanelInfo(), EDGE_MODULE::GetSelectMenuText(), TEXTE_PCB::GetSelectMenuText(), TEXTE_MODULE::GetSelectMenuText(), DIMENSION::GetSelectMenuText(), DRAWSEGMENT::GetSelectMenuText(), TRACK::GetSelectMenuText(), SEGZONE::GetSelectMenuText(), MODULE::GetSelectMenuText(), and ZONE_CONTAINER::GetSelectMenuText().

78 {
79  BOARD* board = GetBoard();
80 
81  if( board )
82  return board->GetLayerName( m_Layer );
83 
84  // If no parent, return standard name
86 }
PCB_LAYER_ID m_Layer
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:647
LSET D_PAD::GetLayerSet ( ) const
inlineoverridevirtual

Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segment or VIA physically resides.

Returns
int - a layer mask, see layers_id_colors_visibility.h.

Reimplemented from BOARD_ITEM.

Definition at line 395 of file class_pad.h.

References m_layerMask.

Referenced by CreatePadsShapesSection(), DRC::doPadToPadsDrc(), DRC::doTrackDrc(), PCB_EDIT_FRAME::EraseRedundantTrack(), export_vrml_pad(), PCB_IO::format(), BOARD::GetPad(), PCB_BASE_FRAME::GlobalChange_PadSettings(), globalChangePadSettings(), ImportSettingsFromMaster(), DIALOG_PAD_PROPERTIES::initValues(), DSN::isRoundKeepout(), DSN::SPECCTRA_DB::makeIMAGE(), DSN::SPECCTRA_DB::makePADSTACK(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::padValuesOK(), PlacePad(), BRDITEMS_PLOTTER::PlotPad(), PNS_KICAD_IFACE::syncPad(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

395 { return m_layerMask; }
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
DHEAD* EDA_ITEM::GetList ( ) const
inlineinherited
int D_PAD::GetLocalClearance ( ) const
inline
bool BOARD_CONNECTED_ITEM::GetLocalRatsnestVisible ( ) const
inlineinherited
int D_PAD::GetLocalSolderMaskMargin ( ) const
inline

Definition at line 403 of file class_pad.h.

References m_LocalSolderMaskMargin.

Referenced by PCB_IO::format(), PCB_BASE_FRAME::GlobalChange_PadSettings(), DIALOG_PAD_PROPERTIES::initValues(), DIALOG_PAD_PROPERTIES::padValuesOK(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

403 { return m_LocalSolderMaskMargin; }
int m_LocalSolderMaskMargin
Local mask margins: when 0, the parent footprint design values are used.
Definition: class_pad.h:838
int D_PAD::GetLocalSolderPasteMargin ( ) const
inline
double D_PAD::GetLocalSolderPasteMarginRatio ( ) const
inline

Definition at line 412 of file class_pad.h.

References m_LocalSolderPasteMarginRatio.

Referenced by PCB_IO::format(), PCB_BASE_FRAME::GlobalChange_PadSettings(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

double m_LocalSolderPasteMarginRatio
Local solder mask margin ratio value of pad size The final margin is the sum of these 2 values...
Definition: class_pad.h:841
BITMAP_DEF D_PAD::GetMenuImage ( ) const
overridevirtual

Function GetMenuImage returns a pointer to an image to be used in menus.

The default version returns the right arrow image. Override this function to provide object specific menu images.

Returns
The menu image associated with the item.

Reimplemented from EDA_ITEM.

Definition at line 1202 of file class_pad.cpp.

1203 {
1204  return pad_xpm;
1205 }
void D_PAD::GetMsgPanelInfo ( std::vector< MSG_PANEL_ITEM > &  aList)
overridevirtual

Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.

Note
This method replaces DisplayInfo() so that KiCad objects no longer have any knowledge of wxWidgets UI objects.
Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Definition at line 683 of file class_pad.cpp.

References BROWN, CoordinateToString(), CYAN, DARKCYAN, DARKGREEN, BOARD_ITEM::GetBoard(), GetDrillShape(), BOARD_CONNECTED_ITEM::GetNetname(), MODULE::GetOrientationDegrees(), GetOrientationDegrees(), GetPadToDieLength(), MODULE::GetReference(), LayerMaskDescribe(), LIGHTBLUE, m_Drill, m_layerMask, m_name, EDA_ITEM::m_Parent, m_Pos, m_Size, PAD_DRILL_SHAPE_CIRCLE, RED, ShowPadAttr(), ShowPadShape(), wxPoint::x, and wxPoint::y.

684 {
685  MODULE* module;
686  wxString Line;
687  BOARD* board;
688 
689  module = (MODULE*) m_Parent;
690 
691  if( module )
692  {
693  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), module->GetReference(), DARKCYAN ) );
694  aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), m_name, BROWN ) );
695  }
696 
697  aList.push_back( MSG_PANEL_ITEM( _( "Net" ), GetNetname(), DARKCYAN ) );
698 
699  board = GetBoard();
700 
701  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ),
702  LayerMaskDescribe( board, m_layerMask ), DARKGREEN ) );
703 
704  aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) );
705 
706  Line = ::CoordinateToString( m_Size.x );
707  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), Line, RED ) );
708 
709  Line = ::CoordinateToString( m_Size.y );
710  aList.push_back( MSG_PANEL_ITEM( _( "Height" ), Line, RED ) );
711 
712  Line = ::CoordinateToString( (unsigned) m_Drill.x );
713 
715  {
716  aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), Line, RED ) );
717  }
718  else
719  {
720  Line = ::CoordinateToString( (unsigned) m_Drill.x );
721  wxString msg;
722  msg = ::CoordinateToString( (unsigned) m_Drill.y );
723  Line += wxT( "/" ) + msg;
724  aList.push_back( MSG_PANEL_ITEM( _( "Drill X / Y" ), Line, RED ) );
725  }
726 
727  double module_orient_degrees = module ? module->GetOrientationDegrees() : 0;
728 
729  if( module_orient_degrees != 0.0 )
730  Line.Printf( wxT( "%3.1f(+%3.1f)" ),
731  GetOrientationDegrees() - module_orient_degrees,
732  module_orient_degrees );
733  else
734  Line.Printf( wxT( "%3.1f" ), GetOrientationDegrees() );
735 
736  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), Line, LIGHTBLUE ) );
737 
738  Line = ::CoordinateToString( m_Pos.x ) + wxT( ", " ) + ::CoordinateToString( m_Pos.y );
739  aList.push_back( MSG_PANEL_ITEM( _( "Position" ), Line, LIGHTBLUE ) );
740 
741  if( GetPadToDieLength() )
742  {
744  aList.push_back( MSG_PANEL_ITEM( _( "Length in package" ), Line, CYAN ) );
745  }
746 }
wxString CoordinateToString(int aValue, bool aConvertToMils)
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: base_units.cpp:118
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:182
int GetPadToDieLength() const
Definition: class_pad.h:401
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
wxString ShowPadAttr() const
Function ShowPadAttr.
Definition: class_pad.cpp:1157
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:381
wxString m_name
Definition: class_pad.h:756
double GetOrientationDegrees() const
Definition: class_module.h:181
Definition: colors.h:59
Definition: colors.h:60
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
const wxString & GetNetname() const
Function GetNetname.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:439
wxString ShowPadShape() const
Function ShowPadShape.
Definition: class_pad.cpp:1129
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE...
Definition: class_pad.h:786
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
double GetOrientationDegrees() const
Definition: class_pad.h:376
static wxString LayerMaskDescribe(const BOARD *aBoard, LSET aMask)
Helper function Return a string (to be shown to the user) describing a layer mask.
Definition: class_pad.cpp:1299
wxPoint m_Pos
pad Position on board
Definition: class_pad.h:758
Definition: colors.h:62
NETCLASSPTR BOARD_CONNECTED_ITEM::GetNetClass ( ) const
inherited

Function GetNetClass returns the NETCLASS for this item.

Definition at line 104 of file class_board_connected_item.cpp.

References DBG, BOARD::FindNet(), BOARD_ITEM::GetBoard(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), NETINFO_ITEM::GetNetClass(), BOARD_CONNECTED_ITEM::GetNetCode(), and EDA_ITEM::Type().

Referenced by DIALOG_TRACK_VIA_PROPERTIES::Apply(), DRC::doTrackDrc(), BOARD_CONNECTED_ITEM::GetClearance(), ZONE_CONTAINER::GetClearance(), VIA::GetDrillValue(), TRACK::GetMsgPanelInfo(), BOARD_CONNECTED_ITEM::GetNetClassName(), and ROUTER_TOOL::prepareInteractive().

105 {
106  // It is important that this be implemented without any sequential searching.
107  // Simple array lookups should be fine, performance-wise.
108  BOARD* board = GetBoard();
109 
110  // DO NOT use wxASSERT, because GetNetClass is called inside an OnPaint event
111  // and a call to wxASSERT can crash the application.
112 
113  if( board == NULL ) // Should not occur
114  {
115  DBG(printf( "%s: NULL board,type %d", __func__, Type() );)
116 
117  return NETCLASSPTR();
118  }
119 
120  NETCLASSPTR netclass;
121  NETINFO_ITEM* net = board->FindNet( GetNetCode() );
122 
123  if( net )
124  {
125  netclass = net->GetNetClass();
126 
127  //DBG( if(!netclass) printf( "%s: NULL netclass,type %d", __func__, Type() );)
128  }
129 
130  if( netclass )
131  return netclass;
132  else
133  return board->GetDesignSettings().GetDefault();
134 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
NETCLASSPTR GetDefault() const
Function GetDefault.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
int GetNetCode() const
Function GetNetCode.
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
NETCLASSPTR GetNetClass()
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
#define DBG(x)
Definition: fctsys.h:33
wxString BOARD_CONNECTED_ITEM::GetNetClassName ( ) const
inherited

Function GetNetClassName returns a pointer to the netclass of the zone.

If the net is not found (can happen when a netlist is reread, and the net name does not exist, return the default net class (should not return a null pointer).

Returns
the Net Class name of this item

Definition at line 137 of file class_board_connected_item.cpp.

References NETCLASS::Default, BOARD_CONNECTED_ITEM::GetNetClass(), and name.

Referenced by PCB_EDIT_FRAME::createPopUpMenuForFpPads(), and PCB_EDIT_FRAME::createPopupMenuForTracks().

138 {
139  wxString name;
140  NETCLASSPTR myclass = GetNetClass();
141 
142  if( myclass )
143  name = myclass->GetName();
144  else
145  name = NETCLASS::Default;
146 
147  return name;
148 }
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
static const char Default[]
the name of the default NETCLASS
const char * name
int BOARD_CONNECTED_ITEM::GetNetCode ( ) const
inlineinherited

Function GetNetCode.

Returns
int - the net code.

Definition at line 103 of file class_board_connected_item.h.

References NETINFO_ITEM::GetNet(), and BOARD_CONNECTED_ITEM::m_netinfo.

Referenced by ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList_NG(), PCB_EDIT_FRAME::Attribut_net(), PCB_EDIT_FRAME::Autoroute(), PCB_EDIT_FRAME::Begin_Route(), PCB_EDIT_FRAME::Begin_Zone(), Build_Work(), ZONE_CONTAINER::buildFeatureHoleList(), BuildUnconnectedThermalStubsPolygonList(), PCB_EDIT_FRAME::Change_Net_Tracks_And_Vias_Sizes(), Collect_TrackSegmentsToDrag(), BOARD::CombineAllAreasInNet(), CopyNetlistSettings(), CreateRoutesSection(), CreateSignalsSection(), PCB_EDIT_FRAME::Delete_net(), PCB_EDIT_FRAME::Delete_Segment(), PCB_EDIT_FRAME::Delete_Track(), DRC::doEdgeZoneDrc(), DRC::doPadToPadsDrc(), DRC::doTrackDrc(), KIGFX::PCB_PAINTER::draw(), VIA::Draw(), BOARD::DrawHighLight(), DrawShape(), TRACK::DrawShortNetname(), PCB_EDIT_FRAME::duplicateZone(), PCB_EDIT_FRAME::End_Zone(), PCB_EDIT_FRAME::EraseRedundantTrack(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::Fill_Zone(), PNS::NODE::FindItemByParent(), PCB_IO::format(), DSN::SPECCTRA_DB::FromBOARD(), TRACK::GetBestInsertPoint(), CONNECTIVITY_DATA::GetConnectedItems(), TRACK::GetEndNetCode(), ZONE_CONTAINER::GetMsgPanelInfo(), TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), TRACK::GetSelectMenuText(), VIA::GetSelectMenuText(), ZONE_CONTAINER::GetSelectMenuText(), TRACK::GetStartNetCode(), TRACK::GetTrack(), hash_eda(), BOARD::HitTestForAnyFilledArea(), ZONE_CONTAINER::IsSame(), LocateIntrusion(), Magnetize(), DSN::SPECCTRA_DB::makeIMAGE(), CONNECTIVITY_DATA::NearestUnconnectedTargets(), BOARD::NormalizeAreaPolygon(), BOARD::OnAreaPolygonModified(), ZONE_SETTINGS::operator<<(), PlaceCells(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), PCB_EDIT_FRAME::Process_Special_Functions(), PushTrack(), PCB_EDIT_FRAME::Remove_One_Track(), PCB_EDIT_FRAME::Remove_Zone_Corner(), TRACKS_CLEANER::removeDuplicatesOfTrack(), BOARD::ReplaceNetlist(), PCB_SELECTION_CONDITIONS::sameNetFunc(), SaveCopyOfZones(), BOARD::SetAreasNetCodesFromNetNames(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::Start_Move_Zone_Corner(), PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge(), PCB_EDIT_FRAME::Start_Move_Zone_Outlines(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), PNS_KICAD_IFACE::syncPad(), PNS_KICAD_IFACE::syncTrack(), PNS_KICAD_IFACE::syncVia(), BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines(), BOARD::TestAreaIntersections(), BOARD_NETLIST_UPDATER::testConnectivity(), DRC::testZones(), TrackListSortByNetcode(), BOARD::TracksInNet(), NETINFO_MAPPING::Update(), ZONE_CONTAINER::ZONE_CONTAINER(), and PCB_EDITOR_CONTROL::ZoneMerge().

104  {
105  return m_netinfo->GetNet();
106  }
int GetNet() const
Function GetNet.
NETINFO_ITEM * m_netinfo
Stores all informations about the net that item belongs to.
int BOARD_ITEM::getNextNumberInSequence ( const std::set< int > &  aSeq,
bool  aFillSequenceGaps 
)
staticprotectedinherited

Definition at line 223 of file class_board_item.cpp.

Referenced by MODULE::GetNextPadName().

224 {
225  if( aSeq.empty() )
226  return 1;
227 
228  // By default go to the end of the sequence
229  int candidate = *aSeq.rbegin();
230 
231  // Filling in gaps in pad numbering
232  if( aFillSequenceGaps )
233  {
234  // start at the beginning
235  candidate = *aSeq.begin();
236 
237  for( auto it : aSeq )
238  {
239  if( it - candidate > 1 )
240  break;
241 
242  candidate = it;
243  }
244  }
245 
246  ++candidate;
247 
248  return candidate;
249 }
void D_PAD::GetOblongDrillGeometry ( wxPoint aStartPoint,
wxPoint aEndPoint,
int &  aWidth 
) const

Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segment which have the same position and width as the hole Usefull to plot/draw oblong holes like segments with rounded ends used in draw and plot functions.

Parameters
aStartPoint= first point of the equivalent segment, relative to the pad position.
aEndPoint= second point of the equivalent segment, relative to the pad position.
aWidth= width equivalent segment.

Definition at line 749 of file class_pad.cpp.

References GetDrillSize(), m_Drill, m_Orient, RotatePoint(), wxPoint::x, and wxPoint::y.

Referenced by BuildPadDrillShapePolygon(), CINFO3D_VISU::createNewPadDrill(), and DrawShape().

751 {
752  // calculates the start point, end point and width
753  // of an equivalent segment which have the same position and width as the hole
754  int delta_cx, delta_cy;
755 
756  wxSize halfsize = GetDrillSize();
757  halfsize.x /= 2;
758  halfsize.y /= 2;
759 
760  if( m_Drill.x > m_Drill.y ) // horizontal
761  {
762  delta_cx = halfsize.x - halfsize.y;
763  delta_cy = 0;
764  aWidth = m_Drill.y;
765  }
766  else // vertical
767  {
768  delta_cx = 0;
769  delta_cy = halfsize.y - halfsize.x;
770  aWidth = m_Drill.x;
771  }
772 
773  RotatePoint( &delta_cx, &delta_cy, m_Orient );
774 
775  aStartPoint.x = delta_cx;
776  aStartPoint.y = delta_cy;
777 
778  aEndPoint.x = - delta_cx;
779  aEndPoint.y = - delta_cy;
780 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE...
Definition: class_pad.h:786
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
double D_PAD::GetOrientationDegrees ( ) const
inline

Definition at line 376 of file class_pad.h.

References m_Orient.

Referenced by GetMsgPanelInfo(), and DSN::SPECCTRA_DB::makeIMAGE().

376 { return m_Orient/10.0; }
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
double D_PAD::GetOrientationRadians ( ) const
inline

Definition at line 377 of file class_pad.h.

References m_Orient.

Referenced by KIGFX::PCB_PAINTER::draw().

377 { return m_Orient*M_PI/1800; }
double m_Orient
in 1/10 degrees
Definition: class_pad.h:827
int D_PAD::GetPadToDieLength ( ) const
inline

Definition at line 401 of file class_pad.h.

References m_LengthPadToDie.

Referenced by PCB_IO::format(), GetMsgPanelInfo(), DIALOG_PAD_PROPERTIES::initValues(), BOARD::MarkTrace(), ShowNewTrackWhenMovingCursor(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

401 { return m_LengthPadToDie; }
int m_LengthPadToDie
Length net from pad to die, inside the package.
Definition: class_pad.h:829
const std::vector<PAD_CS_PRIMITIVE>& D_PAD::GetPrimitives ( ) const
inline

Accessor to the basic shape list.

Definition at line 336 of file class_pad.h.

References m_basicShapes.

Referenced by PCB_IO::format(), PCB_BASE_FRAME::Import_Pad_Settings(), ImportSettingsFromMaster(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

336 { return m_basicShapes; }
std::vector< PAD_CS_PRIMITIVE > m_basicShapes
for free shape pads: a list of basic shapes, in local coordinates, orient 0, coordinates relative to ...
Definition: class_pad.h:768
int D_PAD::GetRoundRectCornerRadius ( ) const
inline

Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.

Returns
The radius of the rounded corners for this pad.

Definition at line 511 of file class_pad.h.

References m_Size.

Referenced by boundingRadius(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), CINFO3D_VISU::createNewPadWithClearance(), CreatePadsShapesSection(), KIGFX::PCB_PAINTER::draw(), DrawShape(), HitTest(), DIALOG_PAD_PROPERTIES::onCornerSizePercentChange(), BRDITEMS_PLOTTER::PlotPad(), TransformShapeWithClearanceToPolygon(), and DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues().

512  {
514  }
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:511
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
int D_PAD::GetRoundRectCornerRadius ( const wxSize &  aSize) const

Helper function GetRoundRectCornerRadius Has meaning only for rounded rect pads Returns the radius of the rounded corners of a rectangle size aSize, using others setting of the pad.

Parameters
aSize= size of the of the round rect. Usually the pad size but can be the size of the pad on solder mask or solder paste
Returns
The radius of the rounded corners for this pad size.

Definition at line 189 of file class_pad.cpp.

References m_padRoundRectRadiusScale.

190 {
191  // radius of rounded corners, usually 25% of shorter pad edge for now
192  int r = aSize.x > aSize.y ? aSize.y : aSize.x;
193  r = int( r * m_padRoundRectRadiusScale );
194 
195  return r;
196 }
double m_padRoundRectRadiusScale
scaling factor from smallest m_Size coord to corner radius, default 0.25
Definition: class_pad.h:794
double D_PAD::GetRoundRectRadiusRatio ( ) const
inline

has meaning only for rounded rect pads

Returns
the scaling factor between the smaller Y or Y size and the radius of the rounded corners. Cannot be > 0.5 the normalized IPC-7351C value is 0.25

Definition at line 608 of file class_pad.h.

References m_padRoundRectRadiusScale.

Referenced by PCB_IO::format(), ImportSettingsFromMaster(), DIALOG_PAD_PROPERTIES::OnPadShapeSelection(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues().

609  {
611  }
double m_padRoundRectRadiusScale
scaling factor from smallest m_Size coord to corner radius, default 0.25
Definition: class_pad.h:794
wxString D_PAD::GetSelectMenuText ( ) const
overridevirtual

Function GetSelectMenuText returns the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position.

The default version of this function raises an assertion in the debug mode and returns a string to indicate that it was not overridden to provide the object specific text.

Returns
The menu text string.

Reimplemented from EDA_ITEM.

Definition at line 1179 of file class_pad.cpp.

References BOARD_ITEM::GetBoard(), GetChars(), GetName(), GetParent(), LayerMaskDescribe(), and m_layerMask.

Referenced by PCB_EDIT_FRAME::createPopUpMenuForFpPads(), and DRC::fillMarker().

1180 {
1181  wxString text;
1182  wxString padlayers( LayerMaskDescribe( GetBoard(), m_layerMask ) );
1183  wxString padname( GetName() );
1184 
1185  if( padname.IsEmpty() )
1186  {
1187  text.Printf( _( "Pad on %s of %s" ),
1188  GetChars( padlayers ),
1189  GetChars(GetParent()->GetReference() ) );
1190  }
1191  else
1192  {
1193  text.Printf( _( "Pad %s on %s of %s" ),
1194  GetChars(GetName() ), GetChars( padlayers ),
1195  GetChars(GetParent()->GetReference() ) );
1196  }
1197 
1198  return text;
1199 }
MODULE * GetParent() const
Definition: class_pad.h:162
const wxString & GetName() const
Definition: class_pad.h:190
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:816
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
static wxString LayerMaskDescribe(const BOARD *aBoard, LSET aMask)
Helper function Return a string (to be shown to the user) describing a layer mask.
Definition: class_pad.cpp:1299
PAD_SHAPE_T D_PAD::GetShape ( ) const
inline

Function GetShape.

Returns
the shape of this pad.

Definition at line 216 of file class_pad.h.

References m_padShape.

Referenced by CINFO3D_VISU::AddPadsShapesWithClearanceToContainer(), boundingRadius(), BuildPadPolygon(), CINFO3D_VISU::buildPadShapePolygon(), BuildPadShapePolygon(), CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon(), CINFO3D_VISU::buildPadShapeThickOutlineAsSegments(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), Compare(), CINFO3D_VISU::createNewPad(), CINFO3D_VISU::createNewPadWithClearance(), CreatePadsShapesSection(), CreateThermalReliefPadPolygon(), KIGFX::PCB_PAINTER::draw(), DrawShape(), export_vrml_padshape(), PCB_IO::format(), GetBoundingBox(), PCB_BASE_FRAME::GlobalChange_PadSettings(), globalChangePadSettings(), hash_eda(), HitTest(), ImportSettingsFromMaster(), DIALOG_PAD_PROPERTIES::initValues(), DSN::isRoundKeepout(), DSN::SPECCTRA_DB::makePADSTACK(), DIALOG_PAD_PROPERTIES::onCornerSizePercentChange(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), EAGLE_PLUGIN::packagePad(), DIALOG_PAD_PROPERTIES::padValuesOK(), GPCB_FPL_CACHE::parseMODULE(), PlacePad(), BRDITEMS_PLOTTER::PlotPad(), ShowPadShape(), PNS_KICAD_IFACE::syncPad(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::transferDataToPad(), MODULE::TransformPadsShapesWithClearanceToPolygon(), CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon(), TransformShapeWithClearanceToPolygon(), and DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues().

216 { return m_padShape; }
PAD_SHAPE_T m_padShape
Shape: PAD_SHAPE_CIRCLE, PAD_SHAPE_RECT, PAD_SHAPE_OVAL, PAD_SHAPE_TRAPEZOID, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_POLYGON.
Definition: class_pad.h:760
const wxString& BOARD_CONNECTED_ITEM::GetShortNetname ( ) const
inlineinherited

Function GetShortNetname.

Returns
wxString - the short netname

Definition at line 131 of file class_board_connected_item.h.

References NETINFO_ITEM::GetShortNetname(), and BOARD_CONNECTED_ITEM::m_netinfo.

Referenced by KIGFX::PCB_PAINTER::draw(), and DrawShape().

132  {
133  return m_netinfo->GetShortNetname();
134  }
const wxString & GetShortNetname() const
Function GetShortNetname.
NETINFO_ITEM * m_netinfo
Stores all informations about the net that item belongs to.
int D_PAD::GetSolderMaskMargin ( ) const

Function GetSolderMaskMargin.

Returns
the margin for the solder mask layer usually > 0 (mask shape bigger than pad value is 1 - the local value 2 - if null, the parent footprint value 1 - if null, the global value

Definition at line 577 of file class_pad.cpp.

References BOARD_ITEM::GetBoard(), BOARD::GetDesignSettings(), MODULE::GetLocalSolderMaskMargin(), GetParent(), m_LocalSolderMaskMargin, m_Size, BOARD_DESIGN_SETTINGS::m_SolderMaskMargin, and min.

Referenced by CINFO3D_VISU::AddPadsShapesWithClearanceToContainer(), KIGFX::PCB_PAINTER::draw(), Draw(), MODULE::TransformPadsShapesWithClearanceToPolygon(), CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon(), and ViewBBox().

578 {
579  int margin = m_LocalSolderMaskMargin;
580  MODULE* module = GetParent();
581 
582  if( module )
583  {
584  if( margin == 0 )
585  {
586  if( module->GetLocalSolderMaskMargin() )
587  margin = module->GetLocalSolderMaskMargin();
588  }
589 
590  if( margin == 0 )
591  {
592  BOARD* brd = GetBoard();
593  margin = brd->GetDesignSettings().m_SolderMaskMargin;
594  }
595  }
596 
597  // ensure mask have a size always >= 0
598  if( margin < 0 )
599  {
600  int minsize = -std::min( m_Size.x, m_Size.y ) / 2;
601 
602  if( margin < minsize )
603  margin = minsize;
604  }
605 
606  return margin;
607 }
int m_LocalSolderMaskMargin
Local mask margins: when 0, the parent footprint design values are used.
Definition: class_pad.h:838
int m_SolderMaskMargin
Solder mask margin.
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
MODULE * GetParent() const
Definition: class_pad.h:162
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
int GetLocalSolderMaskMargin() const
Definition: class_module.h:196
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
#define min(a, b)
Definition: auxiliary.h:85
wxSize D_PAD::GetSolderPasteMargin ( ) const

Function GetSolderPasteMargin.

Returns
the margin for the solder mask layer usually < 0 (mask shape smaller than pad because the margin can be dependent on the pad size, the margin has a x and a y value value is 1 - the local value 2 - if null, the parent footprint value 1 - if null, the global value

Definition at line 610 of file class_pad.cpp.

References BOARD_ITEM::GetBoard(), BOARD::GetDesignSettings(), MODULE::GetLocalSolderPasteMargin(), MODULE::GetLocalSolderPasteMarginRatio(), GetParent(), KiROUND(), m_LocalSolderPasteMargin, m_LocalSolderPasteMarginRatio, m_Size, BOARD_DESIGN_SETTINGS::m_SolderPasteMargin, and BOARD_DESIGN_SETTINGS::m_SolderPasteMarginRatio.

Referenced by CINFO3D_VISU::AddPadsShapesWithClearanceToContainer(), KIGFX::PCB_PAINTER::draw(), Draw(), MODULE::TransformPadsShapesWithClearanceToPolygon(), CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon(), and ViewBBox().

611 {
612  int margin = m_LocalSolderPasteMargin;
613  double mratio = m_LocalSolderPasteMarginRatio;
614  MODULE* module = GetParent();
615 
616  if( module )
617  {
618  if( margin == 0 )
619  margin = module->GetLocalSolderPasteMargin();
620 
621  BOARD * brd = GetBoard();
622 
623  if( margin == 0 )
624  margin = brd->GetDesignSettings().m_SolderPasteMargin;
625 
626  if( mratio == 0.0 )
627  mratio = module->GetLocalSolderPasteMarginRatio();
628 
629  if( mratio == 0.0 )
630  {
632  }
633  }
634 
635  wxSize pad_margin;
636  pad_margin.x = margin + KiROUND( m_Size.x * mratio );
637  pad_margin.y = margin + KiROUND( m_Size.y * mratio );
638 
639  // ensure mask have a size always >= 0
640  if( pad_margin.x < -m_Size.x / 2 )
641  pad_margin.x = -m_Size.x / 2;
642 
643  if( pad_margin.y < -m_Size.y / 2 )
644  pad_margin.y = -m_Size.y / 2;
645 
646  return pad_margin;
647 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
int m_SolderPasteMargin
Solder paste margin absolute value.
int m_LocalSolderPasteMargin
Local solder paste margin absolute value.
Definition: class_pad.h:839
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
MODULE * GetParent() const
Definition: class_pad.h:162
double GetLocalSolderPasteMarginRatio() const
Definition: class_module.h:205
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
int GetLocalSolderPasteMargin() const
Definition: class_module.h:202
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
double m_LocalSolderPasteMarginRatio
Local solder mask margin ratio value of pad size The final margin is the sum of these 2 values...
Definition: class_pad.h:841
double m_SolderPasteMarginRatio
Solder pask margin ratio value of pad size The final margin is the sum of these 2 values...
STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 264 of file base_struct.h.

References EDA_ITEM::m_Status.

Referenced by PCB_IO::format().

264 { return m_Status; }
STATUS_FLAGS m_Status
Definition: base_struct.h:175
int D_PAD::GetSubRatsnest ( ) const
inline

Function GetSubRatsnest.

Returns
int - the netcode

Definition at line 632 of file class_pad.h.

References m_SubRatsnest.

Referenced by CreatePadsShapesSection(), and CreateShapesSection().

632 { return m_SubRatsnest; }
int m_SubRatsnest
variable used in rats nest computations handle subnet (block) number in ratsnest connection ...
Definition: class_pad.h:783
int D_PAD::GetThermalGap ( ) const

Definition at line 672 of file class_pad.cpp.

References GetParent(), MODULE::GetThermalGap(), and m_ThermalGap.

Referenced by PCB_IO::format(), ZONE_CONTAINER::GetThermalReliefGap(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

673 {
674  MODULE* module = GetParent();
675 
676  if( m_ThermalGap == 0 && module )
677  return module->GetThermalGap();
678  else
679  return m_ThermalGap;
680 }
int m_ThermalGap
Definition: class_pad.h:847
int GetThermalGap() const
Definition: class_module.h:215
MODULE * GetParent() const
Definition: class_pad.h:162
int D_PAD::GetThermalWidth ( ) const

Definition at line 661 of file class_pad.cpp.

References GetParent(), MODULE::GetThermalWidth(), and m_ThermalWidth.

Referenced by PCB_IO::format(), ZONE_CONTAINER::GetThermalReliefCopperBridge(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

662 {
663  MODULE* module = GetParent();
664 
665  if( m_ThermalWidth == 0 && module )
666  return module->GetThermalWidth();
667  else
668  return m_ThermalWidth;
669 }
MODULE * GetParent() const
Definition: class_pad.h:162
int m_ThermalWidth
Definition: class_pad.h:846
int GetThermalWidth() const
Definition: class_module.h:212
int BOARD_ITEM::getTrailingInt ( wxString  aStr)
staticprotectedinherited

Definition at line 200 of file class_board_item.cpp.

Referenced by MODULE::GetNextPadName().

201 {
202  int number = 0;
203  int base = 1;
204 
205  // Trim and extract the trailing numeric part
206  int index = aStr.Len() - 1;
207  while( index >= 0 )
208  {
209  const char chr = aStr.GetChar( index );
210 
211  if( chr < '0' || chr > '9' )
212  break;
213 
214  number += ( chr - '0' ) * base;
215  base *= 10;
216  index--;
217  }
218 
219  return number;
220 }
ZoneConnection D_PAD::GetZoneConnection ( ) const

Definition at line 650 of file class_pad.cpp.

References GetParent(), MODULE::GetZoneConnection(), m_ZoneConnection, and PAD_ZONE_CONN_INHERITED.

Referenced by PCB_IO::format(), ZONE_CONTAINER::GetPadConnection(), DIALOG_PAD_PROPERTIES::initValues(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

651 {
652  MODULE* module = GetParent();
653 
654  if( m_ZoneConnection == PAD_ZONE_CONN_INHERITED && module )
655  return module->GetZoneConnection();
656  else
657  return m_ZoneConnection;
658 }
MODULE * GetParent() const
Definition: class_pad.h:162
ZoneConnection GetZoneConnection() const
Definition: class_module.h:209
ZoneConnection m_ZoneConnection
how the connection to zone is made: no connection, thermal relief ...
Definition: class_pad.h:844
bool D_PAD::HitTest ( const wxPoint aPosition) const
overridevirtual

Function HitTest tests if aPosition is contained within or on the bounding area of an item.

Parameters
aPositionA reference to a wxPoint object containing the coordinates to test.
Returns
True if aPosition is within or on the item bounding area.

Reimplemented from BOARD_ITEM.

Definition at line 783 of file class_pad.cpp.

References abs, BuildPadPolygon(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), delta, dist, EuclideanNorm(), GetBoundingRadius(), GetRoundRectCornerRadius(), GetShape(), GetSize(), KiROUND(), m_customShapeAsPolygon, m_Orient, m_Size, SHAPE_POLY_SET::OutlineCount(), PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), ShapePos(), TestPointInsidePolygon(), TestSegmentHit(), TransformRoundRectToPolygon(), wxPoint::x, and wxPoint::y.

784 {
785  int dx, dy;
786 
787  wxPoint shape_pos = ShapePos();
788 
789  wxPoint delta = aPosition - shape_pos;
790 
791  // first test: a test point must be inside a minimum sized bounding circle.
792  int radius = GetBoundingRadius();
793 
794  if( ( abs( delta.x ) > radius ) || ( abs( delta.y ) > radius ) )
795  return false;
796 
797  dx = m_Size.x >> 1; // dx also is the radius for rounded pads
798  dy = m_Size.y >> 1;
799 
800  switch( GetShape() )
801  {
802  case PAD_SHAPE_CIRCLE:
803  if( KiROUND( EuclideanNorm( delta ) ) <= dx )
804  return true;
805 
806  break;
807 
808  case PAD_SHAPE_TRAPEZOID:
809  {
810  wxPoint poly[4];
811  BuildPadPolygon( poly, wxSize(0,0), 0 );
812  RotatePoint( &delta, -m_Orient );
813 
814  return TestPointInsidePolygon( poly, 4, delta );
815  }
816 
817  case PAD_SHAPE_OVAL:
818  {
819  RotatePoint( &delta, -m_Orient );
820  // An oval pad has the same shape as a segment with rounded ends
821  // After rotation, the test point is relative to an horizontal pad
822  int dist;
823  wxPoint offset;
824  if( dy > dx ) // shape is a vertical oval
825  {
826  offset.y = dy - dx;
827  dist = dx;
828  }
829  else //if( dy <= dx ) shape is an horizontal oval
830  {
831  offset.x = dy - dx;
832  dist = dy;
833  }
834  return TestSegmentHit( delta, - offset, offset, dist );
835  }
836  break;
837 
838  case PAD_SHAPE_RECT:
839  RotatePoint( &delta, -m_Orient );
840 
841  if( (abs( delta.x ) <= dx ) && (abs( delta.y ) <= dy) )
842  return true;
843 
844  break;
845 
846  case PAD_SHAPE_ROUNDRECT:
847  {
848  // Check for hit in polygon
849  SHAPE_POLY_SET outline;
850  const int segmentToCircleCount = 32;
852  GetRoundRectCornerRadius(), segmentToCircleCount );
853 
854  const SHAPE_LINE_CHAIN &poly = outline.COutline( 0 );
855  return TestPointInsidePolygon( (const wxPoint*)&poly.CPoint(0), poly.PointCount(), delta );
856  }
857  break;
858 
859  case PAD_SHAPE_CUSTOM:
860  // Check for hit in polygon
861  RotatePoint( &delta, -m_Orient );
862 
864  {
866  return TestPointInsidePolygon( (const wxPoint*)&poly.CPoint(0), poly.PointCount(), delta );
867  }
868  break;
869  }
870 
871  return false;
872 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
int PointCount() const
Function PointCount()
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:511
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:790
static const int dist[10][10]
Definition: dist.cpp:57
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int OutlineCount() const
Returns the number of outlines in the set
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: