KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pad.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PAD_H
26#define PAD_H
27
28#include <mutex>
29#include <array>
30#include <zones.h>
34#include <pad_shapes.h>
35#include <geometry/eda_angle.h>
37#include <core/arraydim.h>
38
39class PCB_SHAPE;
40class SHAPE;
41class SHAPE_SEGMENT;
42
44{
47};
48
49class LINE_READER;
50class EDA_3D_CANVAS;
51class FOOTPRINT;
52
53namespace KIGFX
54{
55 class VIEW;
56}
57
59{
60public:
61 PAD( FOOTPRINT* parent );
62
63 // Copy constructor & operator= are needed because the list of basic shapes
64 // must be duplicated in copy.
65 PAD( const PAD& aPad );
66 PAD& operator=( const PAD &aOther );
67
68 /*
69 * Default layers used for pads, according to the pad type.
70 *
71 * This is default values only, they can be changed for a given pad.
72 */
73 static LSET PTHMask();
74 static LSET SMDMask();
75 static LSET ConnSMDMask();
77 static LSET UnplatedHoleMask();
78 static LSET ApertureMask();
79
80 static inline bool ClassOf( const EDA_ITEM* aItem )
81 {
82 return aItem && PCB_PAD_T == aItem->Type();
83 }
84
85 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
86 {
87 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
88 return true;
89
90 for( KICAD_T scanType : aScanTypes )
91 {
92 if( HasHole() )
93 {
94 if( scanType == PCB_LOCATE_HOLE_T )
95 return true;
96 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
97 return true;
98 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
99 return true;
100 }
101 }
102
103 return false;
104 }
105
106 bool HasHole() const override
107 {
108 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
109 }
110
111 bool IsLocked() const override;
112
120 void ImportSettingsFrom( const PAD& aMasterPad );
121
125 bool IsFlipped() const;
126
130 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
131 const wxString& GetNumber() const { return m_number; }
132
136 bool CanHaveNumber() const;
137
141 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
142 const wxString& GetPinFunction() const { return m_pinFunction; }
143
147 void SetPinType( const wxString& aType ) { m_pinType = aType; }
148 const wxString& GetPinType() const { return m_pinType; }
149
154 bool SameLogicalPadAs( const PAD* aOther ) const
155 {
156 // hide tricks behind sensible API
157 return GetParentFootprint() == aOther->GetParentFootprint()
158 && !m_number.IsEmpty() && m_number == aOther->m_number;
159 }
160
164 bool SharesNetTieGroup( const PAD* aOther ) const;
165
170 bool IsNoConnectPad() const;
171
176 bool IsFreePad() const;
177
181 void SetShape( PAD_SHAPE aShape )
182 {
183 m_padShape = aShape;
184 SetDirty();
185 }
186
190 PAD_SHAPE GetShape() const { return m_padShape; }
191
192 void SetPosition( const VECTOR2I& aPos ) override
193 {
194 m_pos = aPos;
195 SetDirty();
196 }
197
198 VECTOR2I GetPosition() const override { return m_pos; }
199
204
209 {
211 }
212
219 {
221 }
222
230 {
231 m_anchorPadShape = ( aShape == PAD_SHAPE::RECTANGLE ) ? PAD_SHAPE::RECTANGLE : PAD_SHAPE::CIRCLE;
232 SetDirty();
233 }
234
238 bool IsOnCopperLayer() const override;
239
240 void SetY( int y ) { m_pos.y = y; SetDirty(); }
241 void SetX( int x ) { m_pos.x = x; SetDirty(); }
242
243 void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); }
244 const VECTOR2I& GetSize() const { return m_size; }
245 void SetSizeX( const int aX ) { if( aX > 0 ) { m_size.x = aX; SetDirty(); } }
246 int GetSizeX() const { return m_size.x; }
247 void SetSizeY( const int aY ) { if( aY > 0 ) { m_size.y = aY; SetDirty(); } }
248 int GetSizeY() const { return m_size.y; }
249
250 void SetDelta( const VECTOR2I& aSize ) { m_deltaSize = aSize; SetDirty(); }
251 const VECTOR2I& GetDelta() const { return m_deltaSize; }
252
253 void SetDrillSize( const VECTOR2I& aSize ) { m_drill = aSize; SetDirty(); }
254 const VECTOR2I& GetDrillSize() const { return m_drill; }
255 void SetDrillSizeX( const int aX ) { m_drill.x = aX; SetDirty(); }
256 int GetDrillSizeX() const { return m_drill.x; }
257 void SetDrillSizeY( const int aY ) { m_drill.y = aY; SetDirty(); }
258 int GetDrillSizeY() const { return m_drill.y; }
259
260 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; SetDirty(); }
261 const VECTOR2I& GetOffset() const { return m_offset; }
262
263 VECTOR2I GetCenter() const override { return GetPosition(); }
264
276 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
277 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
278
290 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
291 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
292
297
301 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
302 {
303 return m_editPrimitives;
304 }
305
306 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
307
312 void FlipPrimitives( bool aFlipLeftRight );
313
318 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
319
324 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
325
329 void AddPrimitive( PCB_SHAPE* aPrimitive );
330
336 void SetOrientation( const EDA_ANGLE& aAngle );
337 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
338
344
345 // For property system
346 void SetOrientationDegrees( double aOrientation )
347 {
348 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
349 }
351 {
352 return m_orient.AsDegrees();
353 }
354
355 void SetDrillShape( PAD_DRILL_SHAPE_T aShape ) { m_drillShape = aShape; m_shapesDirty = true; }
357
358 bool IsDirty() const
359 {
361 }
362
363 void SetDirty()
364 {
365 m_shapesDirty = true;
368 }
369
370 void SetLayerSet( LSET aLayers ) override { m_layerMask = aLayers; }
371 LSET GetLayerSet() const override { return m_layerMask; }
372
373 void SetAttribute( PAD_ATTRIB aAttribute );
375
376 void SetProperty( PAD_PROP aProperty );
377 PAD_PROP GetProperty() const { return m_property; }
378
379 // We don't currently have an attribute for APERTURE, and adding one will change the file
380 // format, so for now just infer a copper-less pad to be an APERTURE pad.
381 bool IsAperturePad() const
382 {
383 return ( m_layerMask & LSET::AllCuMask() ).none();
384 }
385
386 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
387 int GetPadToDieLength() const { return m_lengthPadToDie; }
388
390 void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
391
392 int GetLocalClearance( wxString* aSource ) const override;
393 int GetLocalClearance() const { return m_localClearance; }
394 void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
395
397 void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
398
401
402 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
403
413 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
414 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
415 bool ignoreLineWidth = false ) const override;
416
426 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
427 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
428
444 virtual std::shared_ptr<SHAPE>
446 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
447
448 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
449
453 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
454
460 int GetBoundingRadius() const;
461
468 int GetLocalClearanceOverrides( wxString* aSource ) const override;
469
480 int GetSolderMaskExpansion() const;
481
494
497
498 ZONE_CONNECTION GetLocalZoneConnectionOverride( wxString* aSource = nullptr ) const;
499
504 void SetThermalSpokeWidth( int aWidth ) { m_thermalSpokeWidth = aWidth; }
506
507 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
508
514 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle ) { m_thermalSpokeAngle = aAngle; }
516
517 // For property system
518 void SetThermalSpokeAngleDegrees( double aAngle )
519 {
521 }
523 {
525 }
526
527 void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
528 int GetThermalGap() const { return m_thermalGap; }
529
530 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
531
537 void SetRoundRectCornerRadius( double aRadius );
538 int GetRoundRectCornerRadius() const;
539
540 VECTOR2I ShapePos() const;
541
548 void SetRoundRectRadiusRatio( double aRadiusScale );
550
557 void SetChamferRectRatio( double aChamferScale );
558 double GetChamferRectRatio() const { return m_chamferScale; }
559
567 void SetChamferPositions( int aPositions ) { m_chamferPositions = aPositions; }
569
573 int GetSubRatsnest() const { return m_subRatsnest; }
574 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
575
582 void SetRemoveUnconnected( bool aSet ) { m_removeUnconnectedLayer = aSet; }
584
588 void SetKeepTopBottom( bool aSet ) { m_keepTopBottomLayer = aSet; }
589 bool GetKeepTopBottom() const { return m_keepTopBottomLayer; }
590
592 {
594 return false;
595
596 if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) )
597 return false;
598
599 return true;
600 }
601
602 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
603
604 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
605 {
606 return m_layerMask[aLayer];
607 }
608
617 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
618
619 bool CanFlashLayer( int aLayer )
620 {
621 return FlashLayer( aLayer, true );
622 }
623
624 PCB_LAYER_ID GetLayer() const override;
625
630
638 bool FlashLayer( LSET aLayers ) const;
639
640 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
641 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
642
643 wxString GetClass() const override
644 {
645 return wxT( "PAD" );
646 }
647
651 const BOX2I GetBoundingBox() const override;
652
659 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
660
661 void Move( const VECTOR2I& aMoveVector ) override
662 {
663 m_pos += aMoveVector;
664 SetDirty();
665 }
666
667 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
668
669 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
670
671 BITMAPS GetMenuImage() const override;
672
676 wxString ShowPadShape() const;
677
681 wxString ShowPadAttr() const;
682
683 EDA_ITEM* Clone() const override;
684
690 PAD* ClonePad() const
691 {
692 return (PAD*) Clone();
693 }
694
699 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
700 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
701
702 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
703
704 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
705
706 virtual const BOX2I ViewBBox() const override;
707
709 {
711 }
712
714 {
715 return m_zoneLayerOverrides.at( aLayer );
716 }
717
719 {
720 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
721 m_zoneLayerOverrides.at( aLayer ) = aOverride;
722 }
723
724 double Similarity( const BOARD_ITEM& aOther ) const override;
725
726 bool operator==( const BOARD_ITEM& aOther ) const override;
727 bool operator!=( const BOARD_ITEM& aOther ) const { return !operator==( aOther ); }
728
729#if defined(DEBUG)
730 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
731#endif
732
733protected:
734 virtual void swapData( BOARD_ITEM* aImage ) override;
735
736private:
737 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
738 ERROR_LOC aErrorLoc ) const;
739
740private:
741 wxString m_number; // Pad name (pin number in schematic)
742 wxString m_pinFunction; // Pin name in schematic
743 wxString m_pinType; // Pin electrical type in schematic
744
745 VECTOR2I m_pos; // Pad Position on board
746
747 PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECTANGLE,
748 // PAD_SHAPE::OVAL, PAD_SHAPE::TRAPEZOID,
749 // PAD_SHAPE::ROUNDRECT, PAD_SHAPE::CHAMFERED_RECT,
750 // PAD_SHAPE::CUSTOM
751 /*
752 * Editing definitions of primitives for custom pad shapes. In local coordinates relative
753 * to m_Pos (NOT shapePos) at orient 0.
754 */
755 std::vector<std::shared_ptr<PCB_SHAPE>> m_editPrimitives;
756
757 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
758 mutable bool m_shapesDirty;
759 mutable std::mutex m_shapesBuildingLock;
761 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
762 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
763
764 mutable bool m_polyDirty[2];
765 mutable std::mutex m_polyBuildingLock;
766 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon[2];
768
769 int m_subRatsnest; // Variable used to handle subnet (block) number in
770 // ratsnest computations
771
772 VECTOR2I m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
773 VECTOR2I m_size; // X and Y size (relative to orient 0)
774
775 PAD_DRILL_SHAPE_T m_drillShape; // PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG
776
777 double m_roundedCornerScale; // Scaling factor of min(width, height) to corner
778 // radius, default 0.25
779 double m_chamferScale; // Scaling factor of min(width, height) to chamfer
780 // size, default 0.25
781 int m_chamferPositions; // The positions of the chamfers (at orient 0)
782
783 PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
784 // PAD_SHAPE::RECTANGLE, PAD_SHAPE::CIRCLE
785
786 /*
787 * Most of the time the hole is the center of the shape (m_Offset = 0). But some designers
788 * use oblong/rect pads with a hole moved to one of the oblong/rect pad shape ends.
789 * In all cases the hole is at the pad position. This offset is from the hole to the center
790 * of the pad shape (ie: the copper area around the hole).
791 * ShapePos() returns the board shape position according to the offset and the pad rotation.
792 */
794
795 LSET m_layerMask; // Bitwise layer: 1 = copper layer, 15 = cmp,
796 // 2..14 = internal layers, 16..31 = technical layers
797
798 VECTOR2I m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
799 // one end and half expands the other. It is only valid
800 // to have a single axis be non-0.
801
802 PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
803 // PAD_ATTRIB::NPTH
804 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
805
807
808 int m_lengthPadToDie; // Length net from pad to die, inside the package
809
812
815
816 /*
817 * Pad clearances, margins, etc. exist in a hierarchy. If a given level is specified then
818 * the remaining levels are NOT consulted.
819 *
820 * LEVEL 1: (highest priority) local overrides (pad, footprint, etc.)
821 * LEVEL 2: Rules
822 * LEVEL 3: Accumulated local settings, netclass settings, & board design settings
823 *
824 * These are the LEVEL 1 settings for a pad.
825 */
827 int m_localSolderMaskMargin; // Local solder mask margin
828 int m_localSolderPasteMargin; // Local solder paste margin absolute value
829 double m_localSolderPasteMarginRatio; // Local solder mask margin ratio of pad size
830 // The final margin is the sum of these 2 values
831
832 /*
833 * How to build the custom shape in zone, to create the clearance area:
834 * CUST_PAD_SHAPE_IN_ZONE_OUTLINE = use pad shape
835 * CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL = use the convex hull of the pad shape
836 */
838
839 ZONE_CONNECTION m_zoneConnection; // No connection, thermal relief, etc.
840 int m_thermalSpokeWidth; // Thermal spoke width.
841 EDA_ANGLE m_thermalSpokeAngle; // Rotation of the spokes. 45° will produce an X,
842 // while 90° will produce a +.
844
846 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
847};
848
849#endif // PAD_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
Definition: board_item.h:64
@ ZLO_NONE
Definition: board_item.h:65
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
double AsDegrees() const
Definition: eda_angle.h:155
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:172
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:573
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
Definition: pad.h:59
PAD_DRILL_SHAPE_T m_drillShape
Definition: pad.h:775
bool IsAperturePad() const
Definition: pad.h:381
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:650
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return an item's "own" clearance in internal units.
Definition: pad.cpp:831
void SetLayerSet(LSET aLayers) override
Definition: pad.h:370
int m_localClearance
Definition: pad.h:826
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1564
PAD_PROP GetProperty() const
Definition: pad.h:377
bool GetRemoveUnconnected() const
Definition: pad.h:583
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:356
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:147
int m_localSolderMaskMargin
Definition: pad.h:827
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:371
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
Definition: pad.h:837
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:713
int GetSizeX() const
Definition: pad.h:246
void AppendPrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Import a custom shape primitive list (composed of basic shapes) and add items to the current list.
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition: pad.cpp:265
VECTOR2I m_size
Definition: pad.h:773
bool IsDirty() const
Definition: pad.h:358
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: pad.cpp:972
double m_localSolderPasteMarginRatio
Definition: pad.h:829
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:641
VECTOR2I m_drill
Definition: pad.h:772
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:604
int GetSolderMaskExpansion() const
Definition: pad.cpp:857
int m_chamferPositions
Definition: pad.h:781
VECTOR2I m_offset
Definition: pad.h:793
int GetDrillSizeY() const
Definition: pad.h:258
const wxString & GetPinType() const
Definition: pad.h:148
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:718
const VECTOR2I & GetDrillSize() const
Definition: pad.h:254
PAD_ATTRIB GetAttribute() const
Definition: pad.h:374
void SetLocalSolderPasteMargin(int aMargin)
Definition: pad.h:397
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:194
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1140
VECTOR2I m_deltaSize
Definition: pad.h:798
ZONE_CONNECTION GetZoneConnection() const
Definition: pad.h:496
void SetRemoveUnconnected(bool aSet)
Set the unconnected removal property.
Definition: pad.h:582
const wxString & GetPinFunction() const
Definition: pad.h:142
void BuildEffectiveShapes(PCB_LAYER_ID aLayer) const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition: pad.cpp:423
std::mutex m_shapesBuildingLock
Definition: pad.h:759
void SetThermalGap(int aGap)
Definition: pad.h:527
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon[2]
Definition: pad.h:766
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:141
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:514
wxString m_pinType
Definition: pad.h:743
double m_roundedCornerScale
Definition: pad.h:777
const wxString & GetNumber() const
Definition: pad.h:131
EDA_ANGLE m_orient
Definition: pad.h:806
void FlipPrimitives(bool aFlipLeftRight)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
Definition: pad.cpp:752
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
double GetLocalSolderPasteMarginRatio() const
Definition: pad.h:399
int GetRoundRectCornerRadius() const
Definition: pad.cpp:328
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:80
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
Definition: pad.h:755
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:122
void DeletePrimitivesList()
Clear the basic shapes list.
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:762
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1256
bool IsLocked() const override
Definition: pad.cpp:155
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:263
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
Definition: pad.h:355
VECTOR2I GetPosition() const override
Definition: pad.h:198
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:661
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:518
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:301
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:515
bool operator==(const BOARD_ITEM &aOther) const override
Definition: pad.cpp:1693
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:591
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:260
PAD_ATTRIB m_attribute
Definition: pad.h:802
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:661
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:243
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:351
bool operator!=(const BOARD_ITEM &aOther) const
Definition: pad.h:727
void SetDirty()
Definition: pad.h:363
const VECTOR2I & GetOffset() const
Definition: pad.h:261
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:215
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1309
double GetOrientationDegrees() const
Definition: pad.h:350
bool SameLogicalPadAs(const PAD *aOther) const
Before we had custom pad shapes it was common to have multiple overlapping pads to represent a more c...
Definition: pad.h:154
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1216
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:334
bool IsNoConnectPad() const
Definition: pad.cpp:181
int GetDrillSizeX() const
Definition: pad.h:256
void SetLocalClearance(int aClearance)
Definition: pad.h:394
PAD_PROP m_property
Definition: pad.h:804
void SetKeepTopBottom(bool aSet)
Set whether we keep the top and bottom connections even if they are not connected.
Definition: pad.h:588
VECTOR2I ShapePos() const
Definition: pad.cpp:761
int m_localSolderPasteMargin
Definition: pad.h:828
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition: pad.cpp:1589
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:130
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:963
wxString ShowPadAttr() const
Definition: pad.cpp:1243
wxString m_pinFunction
Definition: pad.h:742
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:495
wxString ShowPadShape() const
Definition: pad.cpp:1227
int m_effectiveBoundingRadius
Definition: pad.h:767
int GetLocalSolderMaskMargin() const
Definition: pad.h:389
LSET m_layerMask
Definition: pad.h:795
bool GetKeepTopBottom() const
Definition: pad.h:589
int m_thermalGap
Definition: pad.h:843
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:359
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:208
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1474
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pad.cpp:1785
ZONE_CONNECTION m_zoneConnection
Definition: pad.h:839
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:250
bool IsOnCopperLayer() const override
Definition: pad.cpp:776
void SetDrillSizeX(const int aX)
Definition: pad.h:255
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:192
int m_thermalSpokeWidth
Definition: pad.h:840
VECTOR2I m_pos
Definition: pad.h:745
const VECTOR2I & GetDelta() const
Definition: pad.h:251
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:598
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:208
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:253
bool IsFreePad() const
Definition: pad.cpp:187
int GetLocalClearance() const
Definition: pad.h:393
wxString GetClass() const override
Return the class name.
Definition: pad.h:643
PAD_SHAPE GetShape() const
Definition: pad.h:190
bool CanFlashLayer(int aLayer)
Definition: pad.h:619
int m_subRatsnest
Definition: pad.h:769
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:342
EDA_ANGLE GetFPRelativeOrientation()
Definition: pad.cpp:687
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:696
void SetY(int y)
Definition: pad.h:240
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:897
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:222
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1450
bool m_shapesDirty
Definition: pad.h:758
std::mutex m_polyBuildingLock
Definition: pad.h:765
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:201
void SetX(int x)
Definition: pad.h:241
double m_chamferScale
Definition: pad.h:779
int GetLocalClearanceOverrides(wxString *aSource) const override
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:808
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: pad.h:400
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:181
int GetSizeY() const
Definition: pad.h:248
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:237
int GetThermalSpokeWidth() const
Definition: pad.h:505
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:141
int GetLocalSolderPasteMargin() const
Definition: pad.h:396
bool m_polyDirty[2]
Definition: pad.h:764
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pad.cpp:1086
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition: pad.cpp:678
PAD_SHAPE m_padShape
Definition: pad.h:747
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:414
void SetCustomShapeInZoneOpt(CUST_PAD_SHAPE_IN_ZONE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition: pad.h:218
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:343
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:229
void ClearZoneLayerOverrides()
Definition: pad.h:708
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:846
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition: pad.cpp:669
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:845
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
ZONE_CONNECTION GetLocalZoneConnectionOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:945
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1303
int GetChamferPositions() const
Definition: pad.h:568
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: pad.cpp:1315
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
wxString m_number
Definition: pad.h:741
bool m_removeUnconnectedLayer
< If true, the pad copper is removed for layers that are not connected.
Definition: pad.h:811
void SetLocalSolderMaskMargin(int aMargin)
Definition: pad.h:390
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:368
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:573
void SetSizeX(const int aX)
Definition: pad.h:245
bool m_keepTopBottomLayer
Definition: pad.h:814
int m_lengthPadToDie
Definition: pad.h:808
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:504
bool HasHole() const override
Definition: pad.h:106
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:243
void SetDrillSizeY(const int aY)
Definition: pad.h:257
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:522
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:690
double GetRoundRectRadiusRatio() const
Definition: pad.h:549
int GetThermalGap() const
Definition: pad.h:528
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:405
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:346
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:164
const VECTOR2I & GetSize() const
Definition: pad.h:244
PAD_SHAPE m_anchorPadShape
Definition: pad.h:783
EDA_ANGLE m_thermalSpokeAngle
Definition: pad.h:841
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1381
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:574
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:761
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:567
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:954
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:203
bool TransformHoleToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Build the corner list of the polygonal drill shape in the board coordinate system.
Definition: pad.cpp:1572
double GetChamferRectRatio() const
Definition: pad.h:558
void SetPadToDieLength(int aLength)
Definition: pad.h:386
bool IsFlipped() const
Definition: pad.cpp:229
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:85
void SetSizeY(const int aY)
Definition: pad.h:247
int GetPadToDieLength() const
Definition: pad.h:387
BOX2I m_effectiveBoundingBox
Definition: pad.h:760
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition: shape.h:126
@ DEGREES_T
Definition: eda_angle.h:31
a few functions useful in geometry calculations.
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
@ ERROR_INSIDE
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:148
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:96
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:65
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
CUST_PAD_SHAPE_IN_ZONE
Definition: pad.h:44
@ CUST_PAD_SHAPE_IN_ZONE_OUTLINE
Definition: pad.h:45
@ CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL
Definition: pad.h:46
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: pad_shapes.h:81
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:69
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: pad_shapes.h:35
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: pad_shapes.h:97
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_LOCATE_NPTH_T
Definition: typeinfo.h:127
@ PCB_LOCATE_PTH_T
Definition: typeinfo.h:126
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_LOCATE_HOLE_T
Definition: typeinfo.h:125
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:46