KiCad PCB EDA Suite
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>
36#include <core/arraydim.h>
37
38class PCB_SHAPE;
39class PARAM_CFG;
40class SHAPE;
41class SHAPE_SEGMENT;
42
44{
47};
48
49class LINE_READER;
50class EDA_3D_CANVAS;
51class FOOTPRINT;
52class FP_SHAPE;
53
54namespace KIGFX
55{
56 class VIEW;
57}
58
60{
61public:
62 PAD( FOOTPRINT* parent );
63
64 // Copy constructor & operator= are needed because the list of basic shapes
65 // must be duplicated in copy.
66 PAD( const PAD& aPad );
67 PAD& operator=( const PAD &aOther );
68
69 /*
70 * Default layers used for pads, according to the pad type.
71 *
72 * This is default values only, they can be changed for a given pad.
73 */
74 static LSET PTHMask();
75 static LSET SMDMask();
76 static LSET ConnSMDMask();
78 static LSET UnplatedHoleMask();
79 static LSET ApertureMask();
80
81 static inline bool ClassOf( const EDA_ITEM* aItem )
82 {
83 return aItem && PCB_PAD_T == aItem->Type();
84 }
85
86 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
87 {
88 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
89 return true;
90
91 for( KICAD_T scanType : aScanTypes )
92 {
93 if( HasHole() )
94 {
95 if( scanType == PCB_LOCATE_HOLE_T )
96 return true;
97 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
98 return true;
99 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
100 return true;
101 }
102 }
103
104 return false;
105 }
106
107 bool HasHole() const override
108 {
109 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
110 }
111
112 FOOTPRINT* GetParent() const;
113
114 wxString GetParentAsString() const;
115
116 bool IsLocked() const override;
117
125 void ImportSettingsFrom( const PAD& aMasterPad );
126
130 bool IsFlipped() const;
131
135 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
136 const wxString& GetNumber() const { return m_number; }
137
141 bool CanHaveNumber() const;
142
146 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
147 const wxString& GetPinFunction() const { return m_pinFunction; }
148
152 void SetPinType( const wxString& aType ) { m_pinType = aType; }
153 const wxString& GetPinType() const { return m_pinType; }
154
159 bool SameLogicalPadAs( const PAD* aOther ) const
160 {
161 // hide tricks behind sensible API
162 return GetParentFootprint() == aOther->GetParentFootprint()
163 && !m_number.IsEmpty() && m_number == aOther->m_number;
164 }
165
169 bool SharesNetTieGroup( const PAD* aOther ) const;
170
175 bool IsNoConnectPad() const;
176
181 bool IsFreePad() const;
182
186 void SetShape( PAD_SHAPE aShape )
187 {
188 m_padShape = aShape;
189 SetDirty();
190 }
191
195 PAD_SHAPE GetShape() const { return m_padShape; }
196
197 void SetPosition( const VECTOR2I& aPos ) override
198 {
199 m_pos = aPos;
200 SetDirty();
201 }
202
203 VECTOR2I GetPosition() const override { return m_pos; }
204
209
214 {
216 }
217
224 {
226 }
227
235 {
237 SetDirty();
238 }
239
243 bool IsOnCopperLayer() const override
244 {
245 return ( GetLayerSet() & LSET::AllCuMask() ) != 0;
246 }
247
248 void SetY( int y ) { m_pos.y = y; SetDirty(); }
249 void SetX( int x ) { m_pos.x = x; SetDirty(); }
250
251 void SetPos0( const VECTOR2I& aPos ) { m_pos0 = aPos; }
252 const VECTOR2I& GetPos0() const { return m_pos0; }
253
254 void SetY0( int y ) { m_pos0.y = y; }
255 void SetX0( int x ) { m_pos0.x = x; }
256
257 void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); }
258 const VECTOR2I& GetSize() const { return m_size; }
259 void SetSizeX( const int aX ) { m_size.x = aX; SetDirty(); }
260 int GetSizeX() const { return m_size.x; }
261 void SetSizeY( const int aY ) { m_size.y = aY; SetDirty(); }
262 int GetSizeY() const { return m_size.y; }
263
264 void SetDelta( const VECTOR2I& aSize ) { m_deltaSize = aSize; SetDirty(); }
265 const VECTOR2I& GetDelta() const { return m_deltaSize; }
266
267 void SetDrillSize( const VECTOR2I& aSize ) { m_drill = aSize; SetDirty(); }
268 const VECTOR2I& GetDrillSize() const { return m_drill; }
269 void SetDrillSizeX( const int aX ) { m_drill.x = aX; SetDirty(); }
270 int GetDrillSizeX() const { return m_drill.x; }
271 void SetDrillSizeY( const int aY ) { m_drill.y = aY; SetDirty(); }
272 int GetDrillSizeY() const { return m_drill.y; }
273
274 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; SetDirty(); }
275 const VECTOR2I& GetOffset() const { return m_offset; }
276
277 VECTOR2I GetCenter() const override { return GetPosition(); }
278
290 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
291 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
292 void AddPrimitiveSegment( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aThickness );
293 void AddPrimitiveCircle( const VECTOR2I& aCenter, int aRadius, int aThickness, bool aFilled );
294 void AddPrimitiveRect( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aThickness,
295 bool aFilled );
296 void AddPrimitiveArc( const VECTOR2I& aCenter, const VECTOR2I& aStart,
297 const EDA_ANGLE& aArcAngle, int aThickness );
298 void AddPrimitiveCurve( const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCtrl1,
299 const VECTOR2I& aCtrl2, int aThickness );
300
305 void AddPrimitiveAnnotationBox( const VECTOR2I& aStart, const VECTOR2I& aEnd );
306
307 bool GetBestAnchorPosition( VECTOR2I& aPos );
308
320 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
321 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
322
327
331 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
332 {
333 return m_editPrimitives;
334 }
335
336 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
337
342 void FlipPrimitives( bool aFlipLeftRight );
343
348 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
349
354 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
355
359 void AddPrimitive( PCB_SHAPE* aPrimitive );
360
366 void SetOrientation( const EDA_ANGLE& aAngle );
367
372
373 // For property system
374 void SetOrientationDegrees( double aOrientation )
375 {
376 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
377 }
379 {
380 return m_orient.AsDegrees();
381 }
382
383 void SetDrillShape( PAD_DRILL_SHAPE_T aShape ) { m_drillShape = aShape; m_shapesDirty = true; }
385
386 bool IsDirty() const
387 {
388 return m_shapesDirty || m_polyDirty;
389 }
390
391 void SetDirty()
392 {
393 m_shapesDirty = true;
394 m_polyDirty = true;
395 }
396
397 void SetLayerSet( LSET aLayers ) override { m_layerMask = aLayers; }
398 LSET GetLayerSet() const override { return m_layerMask; }
399
400 void SetAttribute( PAD_ATTRIB aAttribute );
402
403 void SetProperty( PAD_PROP aProperty );
404 PAD_PROP GetProperty() const { return m_property; }
405
406 // We don't currently have an attribute for APERTURE, and adding one will change the file
407 // format, so for now just infer a copper-less pad to be an APERTURE pad.
408 bool IsAperturePad() const
409 {
410 return ( m_layerMask & LSET::AllCuMask() ).none();
411 }
412
413 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
414 int GetPadToDieLength() const { return m_lengthPadToDie; }
415
417 void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
418
419 int GetLocalClearance( wxString* aSource ) const override;
420 int GetLocalClearance() const { return m_localClearance; }
421 void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
422
424 void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
425
428
429 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
430
440 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
441 int aMaxError, ERROR_LOC aErrorLoc,
442 bool ignoreLineWidth = false ) const override;
443
453 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
454 ERROR_LOC aErrorLoc ) const;
455
471 virtual std::shared_ptr<SHAPE>
473 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
474
475 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon() const;
476
480 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
481
487 int GetBoundingRadius() const;
488
495 int GetLocalClearanceOverrides( wxString* aSource ) const override;
496
507 int GetSolderMaskExpansion() const;
508
521
524
525 ZONE_CONNECTION GetLocalZoneConnectionOverride( wxString* aSource = nullptr ) const;
526
531 void SetThermalSpokeWidth( int aWidth ) { m_thermalSpokeWidth = aWidth; }
533
534 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
535
541 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle ) { m_thermalSpokeAngle = aAngle; }
543
544 // For property system
545 void SetThermalSpokeAngleDegrees( double aAngle )
546 {
548 }
550 {
552 }
553
554 void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
555 int GetThermalGap() const { return m_thermalGap; }
556
557 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
558
564 void SetRoundRectCornerRadius( double aRadius );
565 int GetRoundRectCornerRadius() const;
566
567 VECTOR2I ShapePos() const;
568
575 void SetRoundRectRadiusRatio( double aRadiusScale );
577
584 void SetChamferRectRatio( double aChamferScale );
585 double GetChamferRectRatio() const { return m_chamferScale; }
586
594 void SetChamferPositions( int aPositions ) { m_chamferPositions = aPositions; }
596
600 int GetSubRatsnest() const { return m_subRatsnest; }
601 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
602
609 void SetRemoveUnconnected( bool aSet ) { m_removeUnconnectedLayer = aSet; }
611
615 void SetKeepTopBottom( bool aSet ) { m_keepTopBottomLayer = aSet; }
616 bool GetKeepTopBottom() const { return m_keepTopBottomLayer; }
617
619 {
621 return false;
622
623 if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) )
624 return false;
625
626 return true;
627 }
628
629 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
630
631 bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const override
632 {
633 return m_layerMask[aLayer];
634 }
635
644 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
645
646 bool CanFlashLayer( int aLayer )
647 {
648 return FlashLayer( aLayer, true );
649 }
650
651 PCB_LAYER_ID GetLayer() const override;
652
657
665 bool FlashLayer( LSET aLayers ) const;
666
667 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
668 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
669
670 wxString GetClass() const override
671 {
672 return wxT( "PAD" );
673 }
674
678 const BOX2I GetBoundingBox() const override;
679
681 void SetDrawCoord();
682
683 //todo: Remove SetLocalCoord along with m_pos
685 void SetLocalCoord();
686
693 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
694
695 void Move( const VECTOR2I& aMoveVector ) override
696 {
697 m_pos += aMoveVector;
699 SetDirty();
700 }
701
702 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
703
704 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
705
706 BITMAPS GetMenuImage() const override;
707
711 wxString ShowPadShape() const;
712
716 wxString ShowPadAttr() const;
717
718 EDA_ITEM* Clone() const override;
719
725 PAD* ClonePad() const
726 {
727 return (PAD*) Clone();
728 }
729
734 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
735 void BuildEffectivePolygon() const;
736
737 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
738
739 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
740
741 virtual const BOX2I ViewBBox() const override;
742
744 {
746 }
747
749 {
750 return m_zoneLayerOverrides[ aLayer ];
751 }
752
754 {
755 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
756 m_zoneLayerOverrides[ aLayer ] = aOverride;
757 }
758
759#if defined(DEBUG)
760 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
761#endif
762
763protected:
764 virtual void swapData( BOARD_ITEM* aImage ) override;
765
766private:
767 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
768 ERROR_LOC aErrorLoc ) const;
769
770private:
771 wxString m_number; // Pad name (pin number in schematic)
772 wxString m_pinFunction; // Pin name in schematic
773 wxString m_pinType; // Pin electrical type in schematic
774
775 VECTOR2I m_pos; // Pad Position on board
776
777 PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECT,
778 // PAD_SHAPE::OVAL, PAD_SHAPE::TRAPEZOID,
779 // PAD_SHAPE::ROUNDRECT, PAD_SHAPE_POLYGON
780 /*
781 * Editing definitions of primitives for custom pad shapes. In local coordinates relative
782 * to m_Pos (NOT shapePos) at orient 0.
783 */
784 std::vector<std::shared_ptr<PCB_SHAPE>> m_editPrimitives;
785
786 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
787 mutable bool m_shapesDirty;
788 mutable std::mutex m_shapesBuildingLock;
790 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
791 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
792
793 mutable bool m_polyDirty;
794 mutable std::mutex m_polyBuildingLock;
795 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon;
797
798 /*
799 * How to build the custom shape in zone, to create the clearance area:
800 * CUST_PAD_SHAPE_IN_ZONE_OUTLINE = use pad shape
801 * CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL = use the convex hull of the pad shape
802 */
804
805 int m_subRatsnest; // Variable used to handle subnet (block) number in
806 // ratsnest computations
807
808 VECTOR2I m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
809 VECTOR2I m_size; // X and Y size (relative to orient 0)
810
811 PAD_DRILL_SHAPE_T m_drillShape; // PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG
812
813 double m_roundedCornerScale; // Scaling factor of min(width, height) to corner
814 // radius, default 0.25
815 double m_chamferScale; // Scaling factor of min(width, height) to chamfer
816 // size, default 0.25
817 int m_chamferPositions; // The positions of the chamfers (at orient 0)
818
819 PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
820 // PAD_SHAPE::RECT, PAD_SHAPE::CIRCLE
821
822 /*
823 * Most of the time the hole is the center of the shape (m_Offset = 0). But some designers
824 * use oblong/rect pads with a hole moved to one of the oblong/rect pad shape ends.
825 * In all cases the hole is at the pad position. This offset is from the hole to the center
826 * of the pad shape (ie: the copper area around the hole).
827 * ShapePos() returns the board shape position according to the offset and the pad rotation.
828 */
830
831 LSET m_layerMask; // Bitwise layer: 1 = copper layer, 15 = cmp,
832 // 2..14 = internal layers, 16..31 = technical layers
833
834 VECTOR2I m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
835 // one end and half expands the other. It is only valid
836 // to have a single axis be non-0.
837
838 VECTOR2I m_pos0; // Initial Pad position (i.e. pad position relative to the
839 // footprint anchor, orientation 0)
840
841 PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
842 // PAD_ATTRIB::NPTH
843 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
844
846
847 int m_lengthPadToDie; // Length net from pad to die, inside the package
848
851
854
855 /*
856 * Pad clearances, margins, etc. exist in a hierarchy. If a given level is specified then
857 * the remaining levels are NOT consulted.
858 *
859 * LEVEL 1: (highest priority) local overrides (pad, footprint, etc.)
860 * LEVEL 2: Rules
861 * LEVEL 3: Accumulated local settings, netclass settings, & board design settings
862 *
863 * These are the LEVEL 1 settings for a pad.
864 */
866 int m_localSolderMaskMargin; // Local solder mask margin
867 int m_localSolderPasteMargin; // Local solder paste margin absolute value
868 double m_localSolderPasteMarginRatio; // Local solder mask margin ratio of pad size
869 // The final margin is the sum of these 2 values
870
871 ZONE_CONNECTION m_zoneConnection; // No connection, thermal relief, etc.
872 int m_thermalSpokeWidth; // Thermal spoke width.
873 EDA_ANGLE m_thermalSpokeAngle; // Rotation of the spokes. 45° will produce an X,
874 // while 90° will produce a +.
876
878 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
879};
880
881#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:57
@ ZLO_NONE
Definition: board_item.h:58
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:70
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Definition: board_item.cpp:239
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
double AsDegrees() const
Definition: eda_angle.h:149
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:181
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:81
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
Definition: pad.h:60
PAD_DRILL_SHAPE_T m_drillShape
Definition: pad.h:811
bool IsAperturePad() const
Definition: pad.h:408
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:675
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return an item's "own" clearance in internal units.
Definition: pad.cpp:808
void SetLayerSet(LSET aLayers) override
Definition: pad.h:397
int m_localClearance
Definition: pad.h:865
PAD(FOOTPRINT *parent)
Definition: pad.cpp:63
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1561
PAD_PROP GetProperty() const
Definition: pad.h:404
bool GetRemoveUnconnected() const
Definition: pad.h:610
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:384
void AddPrimitiveArc(const VECTOR2I &aCenter, const VECTOR2I &aStart, const EDA_ANGLE &aArcAngle, int aThickness)
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:152
int m_localSolderMaskMargin
Definition: pad.h:866
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:398
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
Definition: pad.h:803
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:748
int GetSizeX() const
Definition: pad.h:260
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:267
VECTOR2I m_size
Definition: pad.h:809
bool IsDirty() const
Definition: pad.h:386
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:956
double m_localSolderPasteMarginRatio
Definition: pad.h:868
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:635
VECTOR2I m_drill
Definition: pad.h:808
int GetSolderMaskExpansion() const
Definition: pad.cpp:834
int m_chamferPositions
Definition: pad.h:817
VECTOR2I m_offset
Definition: pad.h:829
int GetDrillSizeY() const
Definition: pad.h:272
const wxString & GetPinType() const
Definition: pad.h:153
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:753
const VECTOR2I & GetDrillSize() const
Definition: pad.h:268
PAD_ATTRIB GetAttribute() const
Definition: pad.h:401
void SetLocalSolderPasteMargin(int aMargin)
Definition: pad.h:424
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:196
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1124
VECTOR2I m_deltaSize
Definition: pad.h:834
ZONE_CONNECTION GetZoneConnection() const
Definition: pad.h:523
void SetRemoveUnconnected(bool aSet)
Set the unconnected removal property.
Definition: pad.h:609
const wxString & GetPinFunction() const
Definition: pad.h:147
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:425
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition: pad.cpp:1586
std::mutex m_shapesBuildingLock
Definition: pad.h:788
void SetThermalGap(int aGap)
Definition: pad.h:554
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:142
void AddPrimitiveAnnotationBox(const VECTOR2I &aStart, const VECTOR2I &aEnd)
Has meaning only for custom shape pads.
void SetX0(int x)
Definition: pad.h:255
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:541
wxString m_pinType
Definition: pad.h:773
double m_roundedCornerScale
Definition: pad.h:813
const wxString & GetNumber() const
Definition: pad.h:136
EDA_ANGLE m_orient
Definition: pad.h:845
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:761
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:426
int GetRoundRectCornerRadius() const
Definition: pad.cpp:330
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:81
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
Definition: pad.h:784
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:791
bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const override
Test to see if this object is on the given layer.
Definition: pad.h:631
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1242
bool IsLocked() const override
Definition: pad.cpp:156
bool TransformHoleToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Build the corner list of the polygonal drill shape in the board coordinate system.
Definition: pad.cpp:1569
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:277
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
Definition: pad.h:383
VECTOR2I GetPosition() const override
Definition: pad.h:203
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:686
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:545
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:331
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:542
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:618
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:274
PAD_ATTRIB m_attribute
Definition: pad.h:841
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:695
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:245
void SetY0(int y)
Definition: pad.h:254
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:353
void SetDirty()
Definition: pad.h:391
const VECTOR2I & GetOffset() const
Definition: pad.h:275
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:217
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1295
double GetOrientationDegrees() const
Definition: pad.h:378
void AddPrimitiveSegment(const VECTOR2I &aStart, const VECTOR2I &aEnd, int aThickness)
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:159
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1200
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:336
bool IsNoConnectPad() const
Definition: pad.cpp:182
int GetDrillSizeX() const
Definition: pad.h:270
void SetLocalClearance(int aClearance)
Definition: pad.h:421
PAD_PROP m_property
Definition: pad.h:843
void SetKeepTopBottom(bool aSet)
Set whether we keep the top and bottom connections even if they are not connected.
Definition: pad.h:615
VECTOR2I ShapePos() const
Definition: pad.cpp:770
int m_localSolderPasteMargin
Definition: pad.h:867
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:135
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:947
wxString ShowPadAttr() const
Definition: pad.cpp:1229
wxString m_pinFunction
Definition: pad.h:772
void AddPrimitiveCurve(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCtrl1, const VECTOR2I &aCtrl2, int aThickness)
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:522
wxString ShowPadShape() const
Definition: pad.cpp:1213
int m_effectiveBoundingRadius
Definition: pad.h:796
int GetLocalSolderMaskMargin() const
Definition: pad.h:416
LSET m_layerMask
Definition: pad.h:831
bool GetKeepTopBottom() const
Definition: pad.h:616
int m_thermalGap
Definition: pad.h:875
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:213
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1477
FOOTPRINT * GetParent() const
Definition: pad.cpp:1471
ZONE_CONNECTION m_zoneConnection
Definition: pad.h:871
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:264
void SetLocalCoord()
< Set relative coordinates.
Definition: pad.cpp:660
bool IsOnCopperLayer() const override
Definition: pad.h:243
void SetDrillSizeX(const int aX)
Definition: pad.h:269
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:197
int m_thermalSpokeWidth
Definition: pad.h:872
VECTOR2I m_pos
Definition: pad.h:775
const VECTOR2I & GetDelta() const
Definition: pad.h:265
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:210
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:267
bool IsFreePad() const
Definition: pad.cpp:189
int GetLocalClearance() const
Definition: pad.h:420
wxString GetClass() const override
Return the class name.
Definition: pad.h:670
PAD_SHAPE GetShape() const
Definition: pad.h:195
bool CanFlashLayer(int aLayer)
Definition: pad.h:646
int m_subRatsnest
Definition: pad.h:805
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:371
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:703
void SetY(int y)
Definition: pad.h:248
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:879
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:224
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1447
bool m_shapesDirty
Definition: pad.h:787
std::mutex m_polyBuildingLock
Definition: pad.h:794
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:203
bool GetBestAnchorPosition(VECTOR2I &aPos)
void SetX(int x)
Definition: pad.h:249
double m_chamferScale
Definition: pad.h:815
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:361
int GetLocalClearanceOverrides(wxString *aSource) const override
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:785
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: pad.h:427
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:186
int GetSizeY() const
Definition: pad.h:262
void AddPrimitiveCircle(const VECTOR2I &aCenter, int aRadius, int aThickness, bool aFilled)
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:239
wxString GetParentAsString() const
Definition: pad.cpp:1688
int GetThermalSpokeWidth() const
Definition: pad.h:532
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:146
int GetLocalSolderPasteMargin() const
Definition: pad.h:423
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:1070
void BuildEffectivePolygon() const
Definition: pad.cpp:597
PAD_SHAPE m_padShape
Definition: pad.h:777
void SetPos0(const VECTOR2I &aPos)
Definition: pad.h:251
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:416
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:223
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:345
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:234
void ClearZoneLayerOverrides()
Definition: pad.h:743
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:878
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:694
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:877
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
void SetDrawCoord()
Definition: pad.cpp:644
ZONE_CONNECTION GetLocalZoneConnectionOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:929
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1289
int GetChamferPositions() const
Definition: pad.h:595
void AddPrimitiveRect(const VECTOR2I &aStart, const VECTOR2I &aEnd, int aThickness, bool aFilled)
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:1301
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:771
bool m_removeUnconnectedLayer
< If true, the pad copper is removed for layers that are not connected.
Definition: pad.h:850
void SetLocalSolderMaskMargin(int aMargin)
Definition: pad.h:417
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:370
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:600
void SetSizeX(const int aX)
Definition: pad.h:259
bool m_keepTopBottomLayer
Definition: pad.h:853
int m_lengthPadToDie
Definition: pad.h:847
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:531
bool HasHole() const override
Definition: pad.h:107
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:257
void SetDrillSizeY(const int aY)
Definition: pad.h:271
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:549
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:725
double GetRoundRectRadiusRatio() const
Definition: pad.h:576
int GetThermalGap() const
Definition: pad.h:555
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:407
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:374
const VECTOR2I & GetPos0() const
Definition: pad.h:252
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:165
const VECTOR2I & GetSize() const
Definition: pad.h:258
VECTOR2I m_pos0
Definition: pad.h:838
PAD_SHAPE m_anchorPadShape
Definition: pad.h:819
EDA_ANGLE m_thermalSpokeAngle
Definition: pad.h:873
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1378
bool m_polyDirty
Definition: pad.h:793
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:601
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:790
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:594
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:938
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:208
double GetChamferRectRatio() const
Definition: pad.h:585
void SetPadToDieLength(int aLength)
Definition: pad.h:413
bool IsFlipped() const
Definition: pad.cpp:231
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:86
void SetSizeY(const int aY)
Definition: pad.h:261
int GetPadToDieLength() const
Definition: pad.h:414
BOX2I m_effectiveBoundingBox
Definition: pad.h:789
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon
Definition: pad.h:795
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:82
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition: shape.h:124
@ DEGREES_T
Definition: eda_angle.h:31
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_INSIDE
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:246
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
@ NPTH
like PAD_PTH, but not plated
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:49