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 <lset.h>
35#include <padstack.h>
36#include <geometry/eda_angle.h>
38#include <core/arraydim.h>
39
40class PCB_SHAPE;
41class SHAPE;
42class SHAPE_SEGMENT;
43
44class LINE_READER;
45class EDA_3D_CANVAS;
46class FOOTPRINT;
47
48namespace KIGFX
49{
50 class VIEW;
51}
52
54{
55public:
56 PAD( FOOTPRINT* parent );
57
58 // Copy constructor & operator= are needed because the list of basic shapes
59 // must be duplicated in copy.
60 PAD( const PAD& aPad );
61 PAD& operator=( const PAD &aOther );
62
63 void Serialize( google::protobuf::Any &aContainer ) const override;
64 bool Deserialize( const google::protobuf::Any &aContainer ) override;
65
66 /*
67 * Default layers used for pads, according to the pad type.
68 *
69 * This is default values only, they can be changed for a given pad.
70 */
71 static LSET PTHMask();
72 static LSET SMDMask();
73 static LSET ConnSMDMask();
75 static LSET UnplatedHoleMask();
76 static LSET ApertureMask();
77
78 static inline bool ClassOf( const EDA_ITEM* aItem )
79 {
80 return aItem && PCB_PAD_T == aItem->Type();
81 }
82
83 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
84 {
85 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
86 return true;
87
88 for( KICAD_T scanType : aScanTypes )
89 {
90 if( HasHole() )
91 {
92 if( scanType == PCB_LOCATE_HOLE_T )
93 return true;
94 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
95 return true;
96 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
97 return true;
98 }
99 }
100
101 return false;
102 }
103
104 bool HasHole() const override
105 {
106 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
107 }
108
109 bool HasDrilledHole() const override
110 {
111 return HasHole() && GetDrillSizeX() == GetDrillSizeY();
112 }
113
114 bool IsLocked() const override;
115
123 void ImportSettingsFrom( const PAD& aMasterPad );
124
128 bool IsFlipped() const;
129
133 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
134 const wxString& GetNumber() const { return m_number; }
135
139 bool CanHaveNumber() const;
140
144 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
145 const wxString& GetPinFunction() const { return m_pinFunction; }
146
150 void SetPinType( const wxString& aType ) { m_pinType = aType; }
151 const wxString& GetPinType() const { return m_pinType; }
152
157 bool SameLogicalPadAs( const PAD* aOther ) const
158 {
159 // hide tricks behind sensible API
160 return GetParentFootprint() == aOther->GetParentFootprint()
161 && !m_number.IsEmpty() && m_number == aOther->m_number;
162 }
163
167 bool SharesNetTieGroup( const PAD* aOther ) const;
168
173 bool IsNoConnectPad() const;
174
179 bool IsFreePad() const;
180
184 void SetShape( PAD_SHAPE aShape )
185 {
186 m_padStack.SetShape( aShape );
187 SetDirty();
188 }
189
193 PAD_SHAPE GetShape() const { return m_padStack.Shape(); }
194
195 void SetPosition( const VECTOR2I& aPos ) override
196 {
197 m_pos = aPos;
198 SetDirty();
199 }
200
201 VECTOR2I GetPosition() const override { return m_pos; }
202
207 {
208 return m_padStack.AnchorShape();
209 }
210
215 {
217 }
218
225 {
227 }
228
236 {
237 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE
238 ? PAD_SHAPE::RECTANGLE
239 : PAD_SHAPE::CIRCLE );
240 SetDirty();
241 }
242
246 bool IsOnCopperLayer() const override;
247
248 void SetY( int y ) { m_pos.y = y; SetDirty(); }
249 void SetX( int x ) { m_pos.x = x; SetDirty(); }
250
251 void SetSize( const VECTOR2I& aSize )
252 {
253 m_padStack.Size() = aSize;
254 SetDirty();
255 }
256 const VECTOR2I& GetSize() const { return m_padStack.Size(); }
257
258 void SetSizeX( const int aX ) { if( aX > 0 ) { m_padStack.Size().x = aX; SetDirty(); } }
259 int GetSizeX() const { return m_padStack.Size().x; }
260 void SetSizeY( const int aY ) { if( aY > 0 ) { m_padStack.Size().y = aY; SetDirty(); } }
261 int GetSizeY() const { return m_padStack.Size().y; }
262
263 void SetDelta( const VECTOR2I& aSize ) { m_padStack.TrapezoidDeltaSize() = aSize; SetDirty(); }
264 const VECTOR2I& GetDelta() const { return m_padStack.TrapezoidDeltaSize(); }
265
266 void SetDrillSize( const VECTOR2I& aSize ) { m_padStack.Drill().size = aSize; SetDirty(); }
267 const VECTOR2I& GetDrillSize() const { return m_padStack.Drill().size; }
268 void SetDrillSizeX( const int aX ) { m_padStack.Drill().size.x = aX; SetDirty(); }
269 int GetDrillSizeX() const { return m_padStack.Drill().size.x; }
270 void SetDrillSizeY( const int aY ) { m_padStack.Drill().size.y = aY; SetDirty(); }
271 int GetDrillSizeY() const { return m_padStack.Drill().size.y; }
272
273 void SetOffset( const VECTOR2I& aOffset ) { m_padStack.Offset() = aOffset; SetDirty(); }
274 const VECTOR2I& GetOffset() const { return m_padStack.Offset(); }
275
276 VECTOR2I GetCenter() const override { return GetPosition(); }
277
278 const PADSTACK& Padstack() const { return m_padStack; }
280 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
281
293 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
294 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
295
307 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
308 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
309
314
318 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
319 {
320 return m_padStack.Primitives();
321 }
322
323 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
324
329 void FlipPrimitives( bool aFlipLeftRight );
330
335 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
336
341 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
342
346 void AddPrimitive( PCB_SHAPE* aPrimitive );
347
353 void SetOrientation( const EDA_ANGLE& aAngle );
354 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
355
361
362 // For property system
363 void SetOrientationDegrees( double aOrientation )
364 {
365 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
366 }
368 {
370 }
371
373 {
374 m_padStack.Drill().shape = aShape;
375 m_shapesDirty = true;
376 }
378
379 bool IsDirty() const
380 {
382 }
383
384 void SetDirty()
385 {
386 m_shapesDirty = true;
389 }
390
391 void SetLayerSet( LSET aLayers ) override { m_padStack.SetLayerSet( aLayers ); }
392 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
393
394 void SetAttribute( PAD_ATTRIB aAttribute );
396
397 void SetProperty( PAD_PROP aProperty );
398 PAD_PROP GetProperty() const { return m_property; }
399
400 // We don't currently have an attribute for APERTURE, and adding one will change the file
401 // format, so for now just infer a copper-less pad to be an APERTURE pad.
402 bool IsAperturePad() const
403 {
404 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
405 }
406
407 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
408 int GetPadToDieLength() const { return m_lengthPadToDie; }
409
410 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
411 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
412
413 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
414 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
415 {
416 m_padStack.SolderMaskMargin() = aMargin;
417 }
418
419 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
420 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
421 {
422 m_padStack.SolderPasteMargin() = aMargin;
423 }
424
425 std::optional<double> GetLocalSolderPasteMarginRatio() const
426 {
428 }
429 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
430 {
432 }
433
436 {
437 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
438 }
439
447 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
448
458 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
459 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
460 bool ignoreLineWidth = false ) const override;
461
471 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
472 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
473
489 virtual std::shared_ptr<SHAPE>
491 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
492
493 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
494
498 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
499
505 int GetBoundingRadius() const;
506
513 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
514
521 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
522
533 int GetSolderMaskExpansion() const;
534
547
548 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
549
554 void SetThermalSpokeWidth( int aWidth ) { m_padStack.ThermalSpokeWidth() = aWidth; }
555 int GetThermalSpokeWidth() const { return m_padStack.ThermalSpokeWidth().value_or( 0 ); }
556
557 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
558
564 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
565 {
567 }
569 {
571 }
572
573 // For property system
574 void SetThermalSpokeAngleDegrees( double aAngle )
575 {
577 }
579 {
581 }
582
583 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
584 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
585
586 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
587
593 void SetRoundRectCornerRadius( double aRadius );
594 int GetRoundRectCornerRadius() const;
595
596 VECTOR2I ShapePos() const;
597
604 void SetRoundRectRadiusRatio( double aRadiusScale );
606
613 void SetChamferRectRatio( double aChamferScale );
614 double GetChamferRectRatio() const { return m_padStack.ChamferRatio(); }
615
623 void SetChamferPositions( int aPositions ) { m_padStack.SetChamferPositions( aPositions ); }
625
629 int GetSubRatsnest() const { return m_subRatsnest; }
630 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
631
637 void SetRemoveUnconnected( bool aSet )
638 {
642 }
643
645 {
647 }
648
653 void SetKeepTopBottom( bool aSet )
654 {
658 }
659
660 bool GetKeepTopBottom() const
661 {
664 }
665
667 {
669 }
670
672 {
674 }
675
677 {
679 {
681 return false;
682
684 return true;
685
687 {
688 if( aLayer == m_padStack.Drill().start || aLayer == m_padStack.Drill().end )
689 return false;
690 }
691 }
692
693 return true;
694 }
695
696 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
697
698 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
699 {
700 return m_padStack.LayerSet().test( aLayer );
701 }
702
711 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
712
713 bool CanFlashLayer( int aLayer )
714 {
715 return FlashLayer( aLayer, true );
716 }
717
718 PCB_LAYER_ID GetLayer() const override;
719
724
732 bool FlashLayer( LSET aLayers ) const;
733
734 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
735 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
736
737
745 std::vector<PCB_SHAPE*> Recombine( bool aIsDryRun, int aMaxError );
746
747 wxString GetClass() const override
748 {
749 return wxT( "PAD" );
750 }
751
755 const BOX2I GetBoundingBox() const override;
756
763 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
764
765 void Move( const VECTOR2I& aMoveVector ) override
766 {
767 m_pos += aMoveVector;
768 SetDirty();
769 }
770
771 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
772
773 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
774
775 BITMAPS GetMenuImage() const override;
776
780 wxString ShowPadShape() const;
781
785 wxString ShowPadAttr() const;
786
787 EDA_ITEM* Clone() const override;
788
794 PAD* ClonePad() const
795 {
796 return (PAD*) Clone();
797 }
798
803 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
804 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
805
806 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
807
808 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
809
810 virtual const BOX2I ViewBBox() const override;
811
813 {
815 }
816
818 {
819 return m_zoneLayerOverrides.at( aLayer );
820 }
821
823 {
824 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
825 m_zoneLayerOverrides.at( aLayer ) = aOverride;
826 }
827
828 void CheckPad( UNITS_PROVIDER* aUnitsProvider,
829 const std::function<void( int aErrorCode,
830 const wxString& aMsg )>& aErrorHandler ) const;
831
832 double Similarity( const BOARD_ITEM& aOther ) const override;
833
834 bool operator==( const PAD& aOther ) const;
835 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
836
837#if defined(DEBUG)
838 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
839#endif
840
841protected:
842 virtual void swapData( BOARD_ITEM* aImage ) override;
843
844private:
845 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
846 ERROR_LOC aErrorLoc ) const;
847
848private:
849 wxString m_number; // Pad name (pin number in schematic)
850 wxString m_pinFunction; // Pin name in schematic
851 wxString m_pinType; // Pin electrical type in schematic
852
853 VECTOR2I m_pos; // Pad Position on board
854
856
857 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
858 mutable bool m_shapesDirty;
859 mutable std::mutex m_shapesBuildingLock;
861 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
862 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
863
864 mutable bool m_polyDirty[2];
865 mutable std::mutex m_polyBuildingLock;
866 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon[2];
868
869 int m_subRatsnest; // Variable used to handle subnet (block) number in
870 // ratsnest computations
871
872 PAD_ATTRIB m_attribute = PAD_ATTRIB::PTH;
873
874 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
875
876 int m_lengthPadToDie; // Length net from pad to die, inside the package
877
879 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
880};
881
882#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:66
@ ZLO_NONE
Definition: board_item.h:67
bool test(size_t pos) const
Definition: base_set.h:47
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:79
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:264
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:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:176
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: lset.h:35
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:732
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition: padstack.h:117
CUSTOM_SHAPE_ZONE_MODE CustomShapeInZoneMode() const
Definition: padstack.h:292
void SetCustomShapeInZoneMode(CUSTOM_SHAPE_ZONE_MODE aM)
Definition: padstack.h:293
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:273
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:246
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:272
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:468
DRILL_PROPS & Drill()
Definition: padstack.h:266
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:144
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:137
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:259
void SetLayerSet(const LSET &aSet)
Definition: padstack.h:248
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:54
bool IsAperturePad() const
Definition: pad.h:402
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:745
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition: pad.cpp:971
void SetLayerSet(LSET aLayers) override
Definition: pad.h:391
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1783
PAD_PROP GetProperty() const
Definition: pad.h:398
bool GetRemoveUnconnected() const
Definition: pad.h:644
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pad.cpp:136
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:959
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:150
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:392
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:817
int GetSizeX() const
Definition: pad.h:259
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:357
bool IsDirty() const
Definition: pad.h:379
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:1125
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:736
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:698
int GetSolderMaskExpansion() const
Definition: pad.cpp:997
int GetDrillSizeY() const
Definition: pad.h:271
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition: pad.h:425
const wxString & GetPinType() const
Definition: pad.h:151
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:822
const VECTOR2I & GetDrillSize() const
Definition: pad.h:267
PAD_ATTRIB GetAttribute() const
Definition: pad.h:395
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:286
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1307
void SetUnconnectedLayerMode(PADSTACK::UNCONNECTED_LAYER_MODE aMode)
Definition: pad.h:666
void SetRemoveUnconnected(bool aSet)
Definition: pad.h:637
const wxString & GetPinFunction() const
Definition: pad.h:145
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:517
std::mutex m_shapesBuildingLock
Definition: pad.h:859
void SetThermalGap(int aGap)
Definition: pad.h:583
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon[2]
Definition: pad.h:866
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:233
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:564
wxString m_pinType
Definition: pad.h:851
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pad.cpp:180
const wxString & GetNumber() const
Definition: pad.h:134
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:887
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:425
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:78
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition: pad.h:429
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:119
void DeletePrimitivesList()
Clear the basic shapes list.
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:862
bool IsLocked() const override
Definition: pad.cpp:247
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:276
VECTOR2I GetPosition() const override
Definition: pad.h:201
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:793
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:574
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:318
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:568
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:676
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:273
PAD_ATTRIB m_attribute
Definition: pad.h:872
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:765
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition: pad.cpp:1912
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:335
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:445
void SetDirty()
Definition: pad.h:384
const VECTOR2I & GetOffset() const
Definition: pad.h:274
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:307
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1519
double GetOrientationDegrees() const
Definition: pad.h:367
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:157
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1384
PADSTACK m_padStack
Definition: pad.h:855
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:431
bool IsNoConnectPad() const
Definition: pad.cpp:273
int GetDrillSizeX() const
Definition: pad.h:269
PAD_PROP m_property
Definition: pad.h:874
void SetKeepTopBottom(bool aSet)
Definition: pad.h:653
VECTOR2I ShapePos() const
Definition: pad.cpp:896
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:1808
PADSTACK & Padstack()
Definition: pad.h:279
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:133
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1116
wxString ShowPadAttr() const
Definition: pad.cpp:1409
wxString m_pinFunction
Definition: pad.h:850
wxString ShowPadShape() const
Definition: pad.cpp:1393
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition: pad.h:372
int m_effectiveBoundingRadius
Definition: pad.h:867
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pad.h:414
bool GetKeepTopBottom() const
Definition: pad.h:660
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:453
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:434
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.h:410
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1691
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:2404
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:263
bool IsOnCopperLayer() const override
Definition: pad.cpp:911
void SetDrillSizeX(const int aX)
Definition: pad.h:268
void SetPadstack(const PADSTACK &aPadstack)
Definition: pad.h:280
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:195
const PADSTACK & Padstack() const
Definition: pad.h:278
VECTOR2I m_pos
Definition: pad.h:853
const VECTOR2I & GetDelta() const
Definition: pad.h:264
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:693
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:300
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:266
bool IsFreePad() const
Definition: pad.cpp:279
wxString GetClass() const override
Return the class name.
Definition: pad.h:747
PAD_SHAPE GetShape() const
Definition: pad.h:193
bool CanFlashLayer(int aLayer)
Definition: pad.h:713
int m_subRatsnest
Definition: pad.h:869
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:359
PADSTACK::CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition: pad.h:214
PAD_DRILL_SHAPE GetDrillShape() const
Definition: pad.h:377
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:826
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:1034
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:314
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1667
bool m_shapesDirty
Definition: pad.h:858
std::mutex m_polyBuildingLock
Definition: pad.h:865
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:293
std::optional< int > GetLocalSolderPasteMargin() const
Definition: pad.h:419
void CheckPad(UNITS_PROVIDER *aUnitsProvider, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition: pad.cpp:2048
void SetX(int x)
Definition: pad.h:249
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pad.h:413
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition: pad.h:420
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:184
int GetSizeY() const
Definition: pad.h:261
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:329
int GetThermalSpokeWidth() const
Definition: pad.h:555
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1422
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:144
EDA_ANGLE GetFPRelativeOrientation() const
Definition: pad.cpp:817
bool m_polyDirty[2]
Definition: pad.h:864
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:1253
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition: pad.cpp:808
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:224
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:508
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:437
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:235
void ClearZoneLayerOverrides()
Definition: pad.h:812
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:879
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:801
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:878
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:671
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1513
int GetChamferPositions() const
Definition: pad.h:624
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:1525
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:849
bool HasDrilledHole() const override
Definition: pad.h:109
void SetLocalClearance(std::optional< int > aClearance)
Definition: pad.h:411
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:462
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:629
void SetSizeX(const int aX)
Definition: pad.h:258
ZONE_CONNECTION GetLocalZoneConnection() const
Definition: pad.h:435
int m_lengthPadToDie
Definition: pad.h:876
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:554
bool HasHole() const override
Definition: pad.h:104
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:251
void SetDrillSizeY(const int aY)
Definition: pad.h:270
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:578
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:794
double GetRoundRectRadiusRatio() const
Definition: pad.h:605
int GetThermalGap() const
Definition: pad.h:584
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:499
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:363
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition: pad.cpp:1087
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:256
const VECTOR2I & GetSize() const
Definition: pad.h:256
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1591
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:630
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:861
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:623
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1107
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:206
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:1791
double GetChamferRectRatio() const
Definition: pad.h:614
void SetPadToDieLength(int aLength)
Definition: pad.h:407
bool IsFlipped() const
Definition: pad.cpp:321
bool operator==(const PAD &aOther) const
Definition: pad.cpp:2320
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:83
void SetSizeY(const int aY)
Definition: pad.h:260
int GetPadToDieLength() const
Definition: pad.h:408
BOX2I m_effectiveBoundingBox
Definition: pad.h:860
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:63
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: padstack.h:74
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: padstack.h:46
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: padstack.h:91
PCB_LAYER_ID start
Definition: padstack.h:228
PCB_LAYER_ID end
Definition: padstack.h:229
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
Definition: padstack.h:226
PAD_DRILL_SHAPE shape
Definition: padstack.h:227
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