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-2024 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 <padstack.h>
35#include <geometry/eda_angle.h>
37#include <core/arraydim.h>
38
39class PCB_SHAPE;
40class SHAPE;
41class SHAPE_SEGMENT;
42
43class LINE_READER;
44class EDA_3D_CANVAS;
45class FOOTPRINT;
46
47namespace KIGFX
48{
49 class VIEW;
50}
51
53{
54public:
55 PAD( FOOTPRINT* parent );
56
57 // Copy constructor & operator= are needed because the list of basic shapes
58 // must be duplicated in copy.
59 PAD( const PAD& aPad );
60 PAD& operator=( const PAD &aOther );
61
62 void Serialize( google::protobuf::Any &aContainer ) const override;
63 bool Deserialize( const google::protobuf::Any &aContainer ) override;
64
65 /*
66 * Default layers used for pads, according to the pad type.
67 *
68 * This is default values only, they can be changed for a given pad.
69 */
70 static LSET PTHMask();
71 static LSET SMDMask();
72 static LSET ConnSMDMask();
74 static LSET UnplatedHoleMask();
75 static LSET ApertureMask();
76
77 static inline bool ClassOf( const EDA_ITEM* aItem )
78 {
79 return aItem && PCB_PAD_T == aItem->Type();
80 }
81
82 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
83 {
84 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
85 return true;
86
87 for( KICAD_T scanType : aScanTypes )
88 {
89 if( HasHole() )
90 {
91 if( scanType == PCB_LOCATE_HOLE_T )
92 return true;
93 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
94 return true;
95 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
96 return true;
97 }
98 }
99
100 return false;
101 }
102
103 bool HasHole() const override
104 {
105 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
106 }
107
108 bool HasDrilledHole() const override
109 {
110 return HasHole() && GetDrillSizeX() == GetDrillSizeY();
111 }
112
113 bool IsLocked() const override;
114
122 void ImportSettingsFrom( const PAD& aMasterPad );
123
127 bool IsFlipped() const;
128
132 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
133 const wxString& GetNumber() const { return m_number; }
134
138 bool CanHaveNumber() const;
139
143 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
144 const wxString& GetPinFunction() const { return m_pinFunction; }
145
149 void SetPinType( const wxString& aType ) { m_pinType = aType; }
150 const wxString& GetPinType() const { return m_pinType; }
151
156 bool SameLogicalPadAs( const PAD* aOther ) const
157 {
158 // hide tricks behind sensible API
159 return GetParentFootprint() == aOther->GetParentFootprint()
160 && !m_number.IsEmpty() && m_number == aOther->m_number;
161 }
162
166 bool SharesNetTieGroup( const PAD* aOther ) const;
167
172 bool IsNoConnectPad() const;
173
178 bool IsFreePad() const;
179
183 void SetShape( PAD_SHAPE aShape )
184 {
185 m_padStack.SetShape( aShape );
186 SetDirty();
187 }
188
192 PAD_SHAPE GetShape() const { return m_padStack.Shape(); }
193
194 void SetPosition( const VECTOR2I& aPos ) override
195 {
196 m_pos = aPos;
197 SetDirty();
198 }
199
200 VECTOR2I GetPosition() const override { return m_pos; }
201
206 {
207 return m_padStack.AnchorShape();
208 }
209
214 {
216 }
217
224 {
226 }
227
235 {
236 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE
237 ? PAD_SHAPE::RECTANGLE
238 : PAD_SHAPE::CIRCLE );
239 SetDirty();
240 }
241
245 bool IsOnCopperLayer() const override;
246
247 void SetY( int y ) { m_pos.y = y; SetDirty(); }
248 void SetX( int x ) { m_pos.x = x; SetDirty(); }
249
250 void SetSize( const VECTOR2I& aSize )
251 {
252 m_padStack.Size() = aSize;
253 SetDirty();
254 }
255 const VECTOR2I& GetSize() const { return m_padStack.Size(); }
256
257 void SetSizeX( const int aX ) { if( aX > 0 ) { m_padStack.Size().x = aX; SetDirty(); } }
258 int GetSizeX() const { return m_padStack.Size().x; }
259 void SetSizeY( const int aY ) { if( aY > 0 ) { m_padStack.Size().y = aY; SetDirty(); } }
260 int GetSizeY() const { return m_padStack.Size().y; }
261
262 void SetDelta( const VECTOR2I& aSize ) { m_padStack.TrapezoidDeltaSize() = aSize; SetDirty(); }
263 const VECTOR2I& GetDelta() const { return m_padStack.TrapezoidDeltaSize(); }
264
265 void SetDrillSize( const VECTOR2I& aSize ) { m_padStack.Drill().size = aSize; SetDirty(); }
266 const VECTOR2I& GetDrillSize() const { return m_padStack.Drill().size; }
267 void SetDrillSizeX( const int aX ) { m_padStack.Drill().size.x = aX; SetDirty(); }
268 int GetDrillSizeX() const { return m_padStack.Drill().size.x; }
269 void SetDrillSizeY( const int aY ) { m_padStack.Drill().size.y = aY; SetDirty(); }
270 int GetDrillSizeY() const { return m_padStack.Drill().size.y; }
271
272 void SetOffset( const VECTOR2I& aOffset ) { m_padStack.Offset() = aOffset; SetDirty(); }
273 const VECTOR2I& GetOffset() const { return m_padStack.Offset(); }
274
275 VECTOR2I GetCenter() const override { return GetPosition(); }
276
277 const PADSTACK& Padstack() const { return m_padStack; }
279 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
280
292 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
293 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
294
306 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
307 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
308
313
317 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
318 {
319 return m_padStack.Primitives();
320 }
321
322 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
323
328 void FlipPrimitives( bool aFlipLeftRight );
329
334 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
335
340 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
341
345 void AddPrimitive( PCB_SHAPE* aPrimitive );
346
352 void SetOrientation( const EDA_ANGLE& aAngle );
353 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
354
360
361 // For property system
362 void SetOrientationDegrees( double aOrientation )
363 {
364 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
365 }
367 {
369 }
370
372 {
373 m_padStack.Drill().shape = aShape;
374 m_shapesDirty = true;
375 }
377
378 bool IsDirty() const
379 {
381 }
382
383 void SetDirty()
384 {
385 m_shapesDirty = true;
388 }
389
390 void SetLayerSet( LSET aLayers ) override { m_padStack.SetLayerSet( aLayers ); }
391 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
392
393 void SetAttribute( PAD_ATTRIB aAttribute );
395
396 void SetProperty( PAD_PROP aProperty );
397 PAD_PROP GetProperty() const { return m_property; }
398
399 // We don't currently have an attribute for APERTURE, and adding one will change the file
400 // format, so for now just infer a copper-less pad to be an APERTURE pad.
401 bool IsAperturePad() const
402 {
403 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
404 }
405
406 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
407 int GetPadToDieLength() const { return m_lengthPadToDie; }
408
409 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
410 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
411
412 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
413 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
414 {
415 m_padStack.SolderMaskMargin() = aMargin;
416 }
417
418 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
419 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
420 {
421 m_padStack.SolderPasteMargin() = aMargin;
422 }
423
424 std::optional<double> GetLocalSolderPasteMarginRatio() const
425 {
427 }
428 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
429 {
431 }
432
435 {
436 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
437 }
438
446 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
447
457 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
458 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
459 bool ignoreLineWidth = false ) const override;
460
470 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
471 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
472
488 virtual std::shared_ptr<SHAPE>
490 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
491
492 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
493
497 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
498
504 int GetBoundingRadius() const;
505
512 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
513
520 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
521
532 int GetSolderMaskExpansion() const;
533
546
547 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
548
553 void SetThermalSpokeWidth( int aWidth ) { m_padStack.ThermalSpokeWidth() = aWidth; }
554 int GetThermalSpokeWidth() const { return m_padStack.ThermalSpokeWidth().value_or( 0 ); }
555
556 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
557
563 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
564 {
566 }
568 {
570 }
571
572 // For property system
573 void SetThermalSpokeAngleDegrees( double aAngle )
574 {
576 }
578 {
580 }
581
582 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
583 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
584
585 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
586
592 void SetRoundRectCornerRadius( double aRadius );
593 int GetRoundRectCornerRadius() const;
594
595 VECTOR2I ShapePos() const;
596
603 void SetRoundRectRadiusRatio( double aRadiusScale );
605
612 void SetChamferRectRatio( double aChamferScale );
613 double GetChamferRectRatio() const { return m_padStack.ChamferRatio(); }
614
622 void SetChamferPositions( int aPositions ) { m_padStack.SetChamferPositions( aPositions ); }
624
628 int GetSubRatsnest() const { return m_subRatsnest; }
629 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
630
636 void SetRemoveUnconnected( bool aSet )
637 {
641 }
642
644 {
646 }
647
652 void SetKeepTopBottom( bool aSet )
653 {
657 }
658
659 bool GetKeepTopBottom() const
660 {
663 }
664
666 {
668 }
669
671 {
673 }
674
676 {
678 {
680 return false;
681
683 return true;
684
686 {
687 if( aLayer == m_padStack.Drill().start || aLayer == m_padStack.Drill().end )
688 return false;
689 }
690 }
691
692 return true;
693 }
694
695 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
696
697 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
698 {
699 return m_padStack.LayerSet().test( aLayer );
700 }
701
710 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
711
712 bool CanFlashLayer( int aLayer )
713 {
714 return FlashLayer( aLayer, true );
715 }
716
717 PCB_LAYER_ID GetLayer() const override;
718
723
731 bool FlashLayer( LSET aLayers ) const;
732
733 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
734 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
735
736 wxString GetClass() const override
737 {
738 return wxT( "PAD" );
739 }
740
744 const BOX2I GetBoundingBox() const override;
745
752 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
753
754 void Move( const VECTOR2I& aMoveVector ) override
755 {
756 m_pos += aMoveVector;
757 SetDirty();
758 }
759
760 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
761
762 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
763
764 BITMAPS GetMenuImage() const override;
765
769 wxString ShowPadShape() const;
770
774 wxString ShowPadAttr() const;
775
776 EDA_ITEM* Clone() const override;
777
783 PAD* ClonePad() const
784 {
785 return (PAD*) Clone();
786 }
787
792 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
793 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
794
795 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
796
797 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
798
799 virtual const BOX2I ViewBBox() const override;
800
802 {
804 }
805
807 {
808 return m_zoneLayerOverrides.at( aLayer );
809 }
810
812 {
813 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
814 m_zoneLayerOverrides.at( aLayer ) = aOverride;
815 }
816
817 void CheckPad( UNITS_PROVIDER* aUnitsProvider,
818 const std::function<void( int aErrorCode,
819 const wxString& aMsg )>& aErrorHandler ) const;
820
821 double Similarity( const BOARD_ITEM& aOther ) const override;
822
823 bool operator==( const BOARD_ITEM& aOther ) const override;
824 bool operator!=( const BOARD_ITEM& aOther ) const { return !operator==( aOther ); }
825
826#if defined(DEBUG)
827 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
828#endif
829
830protected:
831 virtual void swapData( BOARD_ITEM* aImage ) override;
832
833private:
834 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
835 ERROR_LOC aErrorLoc ) const;
836
837private:
838 wxString m_number; // Pad name (pin number in schematic)
839 wxString m_pinFunction; // Pin name in schematic
840 wxString m_pinType; // Pin electrical type in schematic
841
842 VECTOR2I m_pos; // Pad Position on board
843
845
846 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
847 mutable bool m_shapesDirty;
848 mutable std::mutex m_shapesBuildingLock;
850 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
851 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
852
853 mutable bool m_polyDirty[2];
854 mutable std::mutex m_polyBuildingLock;
855 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon[2];
857
858 int m_subRatsnest; // Variable used to handle subnet (block) number in
859 // ratsnest computations
860
861 PAD_ATTRIB m_attribute = PAD_ATTRIB::PTH;
862
863 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
864
865 int m_lengthPadToDie; // Length net from pad to die, inside the package
866
868 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
869};
870
871#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:113
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:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:175
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:576
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition: padstack.h:116
CUSTOM_SHAPE_ZONE_MODE CustomShapeInZoneMode() const
Definition: padstack.h:291
void SetCustomShapeInZoneMode(CUSTOM_SHAPE_ZONE_MODE aM)
Definition: padstack.h:292
std::optional< int > & Clearance(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:392
std::vector< std::shared_ptr< PCB_SHAPE > > & Primitives(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:498
void SetChamferPositions(int aPositions, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:386
std::optional< double > & SolderPasteMarginRatio(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:431
void SetAnchorShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:315
void SetThermalSpokeAngle(EDA_ANGLE aAngle, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:492
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:272
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:456
std::optional< int > & SolderPasteMargin(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:418
std::optional< int > & SolderMaskMargin(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:404
const LSET & LayerSet() const
Definition: padstack.h:245
PAD_SHAPE AnchorShape(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:309
EDA_ANGLE ThermalSpokeAngle(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:480
int & ChamferPositions(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:374
UNCONNECTED_LAYER_MODE UnconnectedLayerMode() const
Definition: padstack.h:271
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:468
DRILL_PROPS & Drill()
Definition: padstack.h:265
double RoundRectRadiusRatio(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:333
VECTOR2I & TrapezoidDeltaSize(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:321
CUSTOM_SHAPE_ZONE_MODE
Definition: padstack.h:143
VECTOR2I & Offset(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:297
VECTOR2I & Size(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:273
UNCONNECTED_LAYER_MODE
! Whether or not to remove the copper shape for unconnected layers
Definition: padstack.h:136
double ChamferRatio(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:362
PAD_SHAPE Shape(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:261
EDA_ANGLE GetOrientation() const
Definition: padstack.h:258
void SetLayerSet(const LSET &aSet)
Definition: padstack.h:247
std::optional< ZONE_CONNECTION > & ZoneConnection(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:444
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:267
Definition: pad.h:53
bool IsAperturePad() const
Definition: pad.h:401
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:744
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition: pad.cpp:969
void SetLayerSet(LSET aLayers) override
Definition: pad.h:390
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1795
PAD_PROP GetProperty() const
Definition: pad.h:397
bool GetRemoveUnconnected() const
Definition: pad.h:643
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pad.cpp:135
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:957
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:149
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:391
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:806
int GetSizeX() const
Definition: pad.h:258
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:356
bool IsDirty() const
Definition: pad.h:378
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:1123
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:735
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:697
int GetSolderMaskExpansion() const
Definition: pad.cpp:995
int GetDrillSizeY() const
Definition: pad.h:270
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition: pad.h:424
const wxString & GetPinType() const
Definition: pad.h:150
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:811
const VECTOR2I & GetDrillSize() const
Definition: pad.h:266
PAD_ATTRIB GetAttribute() const
Definition: pad.h:394
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:285
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1305
void SetUnconnectedLayerMode(PADSTACK::UNCONNECTED_LAYER_MODE aMode)
Definition: pad.h:665
void SetRemoveUnconnected(bool aSet)
Definition: pad.h:636
const wxString & GetPinFunction() const
Definition: pad.h:144
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:516
std::mutex m_shapesBuildingLock
Definition: pad.h:848
void SetThermalGap(int aGap)
Definition: pad.h:582
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon[2]
Definition: pad.h:855
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:232
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:563
wxString m_pinType
Definition: pad.h:840
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pad.cpp:179
const wxString & GetNumber() const
Definition: pad.h:133
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:885
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
int GetRoundRectCornerRadius() const
Definition: pad.cpp:424
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:77
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition: pad.h:428
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:118
void DeletePrimitivesList()
Clear the basic shapes list.
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:851
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1434
bool IsLocked() const override
Definition: pad.cpp:246
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:275
VECTOR2I GetPosition() const override
Definition: pad.h:200
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:792
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:573
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:317
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:567
bool operator==(const BOARD_ITEM &aOther) const override
Definition: pad.cpp:2168
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:675
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:272
PAD_ATTRIB m_attribute
Definition: pad.h:861
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:754
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:334
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:444
bool operator!=(const BOARD_ITEM &aOther) const
Definition: pad.h:824
void SetDirty()
Definition: pad.h:383
const VECTOR2I & GetOffset() const
Definition: pad.h:273
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:306
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1531
double GetOrientationDegrees() const
Definition: pad.h:366
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:156
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1396
PADSTACK m_padStack
Definition: pad.h:844
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:430
bool IsNoConnectPad() const
Definition: pad.cpp:272
int GetDrillSizeX() const
Definition: pad.h:268
PAD_PROP m_property
Definition: pad.h:863
void SetKeepTopBottom(bool aSet)
Definition: pad.h:652
VECTOR2I ShapePos() const
Definition: pad.cpp:894
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:1820
PADSTACK & Padstack()
Definition: pad.h:278
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:132
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1114
wxString ShowPadAttr() const
Definition: pad.cpp:1421
wxString m_pinFunction
Definition: pad.h:839
wxString ShowPadShape() const
Definition: pad.cpp:1405
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition: pad.h:371
int m_effectiveBoundingRadius
Definition: pad.h:856
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pad.h:413
bool GetKeepTopBottom() const
Definition: pad.h:659
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:452
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:433
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.h:409
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1703
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:2260
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:262
bool IsOnCopperLayer() const override
Definition: pad.cpp:909
void SetDrillSizeX(const int aX)
Definition: pad.h:267
void SetPadstack(const PADSTACK &aPadstack)
Definition: pad.h:279
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:194
const PADSTACK & Padstack() const
Definition: pad.h:277
VECTOR2I m_pos
Definition: pad.h:842
const VECTOR2I & GetDelta() const
Definition: pad.h:263
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:692
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:299
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:265
bool IsFreePad() const
Definition: pad.cpp:278
wxString GetClass() const override
Return the class name.
Definition: pad.h:736
PAD_SHAPE GetShape() const
Definition: pad.h:192
bool CanFlashLayer(int aLayer)
Definition: pad.h:712
int m_subRatsnest
Definition: pad.h:858
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:358
PADSTACK::CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition: pad.h:213
PAD_DRILL_SHAPE GetDrillShape() const
Definition: pad.h:376
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:825
void SetY(int y)
Definition: pad.h:247
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:1032
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:313
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1679
bool m_shapesDirty
Definition: pad.h:847
std::mutex m_polyBuildingLock
Definition: pad.h:854
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:292
std::optional< int > GetLocalSolderPasteMargin() const
Definition: pad.h:418
void CheckPad(UNITS_PROVIDER *aUnitsProvider, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition: pad.cpp:1924
void SetX(int x)
Definition: pad.h:248
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pad.h:412
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition: pad.h:419
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:183
int GetSizeY() const
Definition: pad.h:260
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:328
int GetThermalSpokeWidth() const
Definition: pad.h:554
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:143
EDA_ANGLE GetFPRelativeOrientation() const
Definition: pad.cpp:816
bool m_polyDirty[2]
Definition: pad.h:853
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:1251
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition: pad.cpp:807
void SetCustomShapeInZoneOpt(PADSTACK::CUSTOM_SHAPE_ZONE_MODE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition: pad.h:223
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:507
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:436
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:801
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:868
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:800
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:867
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
PADSTACK::UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition: pad.h:670
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1525
int GetChamferPositions() const
Definition: pad.h:623
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:1537
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:838
bool HasDrilledHole() const override
Definition: pad.h:108
void SetLocalClearance(std::optional< int > aClearance)
Definition: pad.h:410
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:461
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:628
void SetSizeX(const int aX)
Definition: pad.h:257
ZONE_CONNECTION GetLocalZoneConnection() const
Definition: pad.h:434
int m_lengthPadToDie
Definition: pad.h:865
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:553
bool HasHole() const override
Definition: pad.h:103
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:250
void SetDrillSizeY(const int aY)
Definition: pad.h:269
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:577
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:783
double GetRoundRectRadiusRatio() const
Definition: pad.h:604
int GetThermalGap() const
Definition: pad.h:583
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:498
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:362
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition: pad.cpp:1085
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:255
const VECTOR2I & GetSize() const
Definition: pad.h:255
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1603
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:629
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:850
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:622
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1105
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:205
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:1803
double GetChamferRectRatio() const
Definition: pad.h:613
void SetPadToDieLength(int aLength)
Definition: pad.h:406
bool IsFlipped() const
Definition: pad.cpp:320
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:82
void SetSizeY(const int aY)
Definition: pad.h:259
int GetPadToDieLength() const
Definition: pad.h:407
BOX2I m_effectiveBoundingBox
Definition: pad.h:849
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:149
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:62
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: padstack.h:73
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: padstack.h:45
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: padstack.h:90
PCB_LAYER_ID start
Definition: padstack.h:227
PCB_LAYER_ID end
Definition: padstack.h:228
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
Definition: padstack.h:225
PAD_DRILL_SHAPE shape
Definition: padstack.h:226
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:129
@ PCB_LOCATE_PTH_T
Definition: typeinfo.h:128
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_LOCATE_HOLE_T
Definition: typeinfo.h:127
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:47