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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <mutex>
24#include <array>
25#include <optional>
26
28#include <core/arraydim.h>
29#include <core/mirror.h>
30#include <geometry/eda_angle.h>
33#include <lset.h>
34#include <padstack.h>
35#include <zones.h>
36
37class PCB_SHAPE;
38class SHAPE;
39class SHAPE_SEGMENT;
40
41class LINE_READER;
42class EDA_3D_CANVAS;
43class FOOTPRINT;
44
45namespace KIGFX
46{
47 class VIEW;
48}
49
50
53{
54 NONE = 0,
57};
58
59
61{
62public:
63 PAD( FOOTPRINT* parent );
64
65 // Copy constructor & operator= are needed because the list of basic shapes
66 // must be duplicated in copy.
67 PAD( const PAD& aPad );
68 PAD& operator=( const PAD &aOther );
69
70 void CopyFrom( const BOARD_ITEM* aOther ) override;
71
72 void Serialize( google::protobuf::Any &aContainer ) const override;
73 bool Deserialize( const google::protobuf::Any &aContainer ) override;
74
75 /*
76 * Default layers used for pads, according to the pad type.
77 *
78 * This is default values only, they can be changed for a given pad.
79 */
80 static LSET PTHMask();
81 static LSET SMDMask();
82 static LSET ConnSMDMask();
84 static LSET UnplatedHoleMask();
85 static LSET ApertureMask();
86
87 static inline bool ClassOf( const EDA_ITEM* aItem )
88 {
89 return aItem && PCB_PAD_T == aItem->Type();
90 }
91
92 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
93 {
94 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
95 return true;
96
97 for( KICAD_T scanType : aScanTypes )
98 {
99 if( HasHole() )
100 {
101 if( scanType == PCB_LOCATE_HOLE_T )
102 return true;
103 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
104 return true;
105 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
106 return true;
107 }
108 }
109
110 return false;
111 }
112
113 bool HasHole() const override
114 {
115 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
116 }
117
118 bool HasDrilledHole() const override
119 {
120 return HasHole() && GetDrillSizeX() == GetDrillSizeY();
121 }
122
123 bool IsLocked() const override;
124
132 void ImportSettingsFrom( const PAD& aMasterPad );
133
137 bool IsFlipped() const;
138
142 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
143 const wxString& GetNumber() const { return m_number; }
144
148 bool CanHaveNumber() const;
149
153 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
154 const wxString& GetPinFunction() const { return m_pinFunction; }
155
159 void SetPinType( const wxString& aType ) { m_pinType = aType; }
160 const wxString& GetPinType() const { return m_pinType; }
161
166 bool SameLogicalPadAs( const PAD* aOther ) const
167 {
168 // hide tricks behind sensible API
169 return GetParentFootprint() == aOther->GetParentFootprint()
170 && !m_number.IsEmpty() && m_number == aOther->m_number;
171 }
172
176 bool SharesNetTieGroup( const PAD* aOther ) const;
177
182 bool IsNoConnectPad() const;
183
188 bool IsFreePad() const;
189
193 void SetShape( PCB_LAYER_ID aLayer, PAD_SHAPE aShape )
194 {
195 m_padStack.SetShape( aShape, aLayer );
196 SetDirty();
197 }
198
202 PAD_SHAPE GetShape( PCB_LAYER_ID aLayer ) const { return m_padStack.Shape( aLayer ); }
203
204 // Used for the properties panel, which does not support padstacks at the moment
205 void SetFrontShape( PAD_SHAPE aShape );
206
207 PAD_SHAPE GetFrontShape() const { return m_padStack.Shape( F_Cu ); }
208
209 void SetPosition( const VECTOR2I& aPos ) override;
210 VECTOR2I GetPosition() const override;
212
217 {
218 return m_padStack.AnchorShape( aLayer );
219 }
220
225 {
226 return m_padStack.CustomShapeInZoneMode();
227 }
228
235 {
236 m_padStack.SetCustomShapeInZoneMode( aOption );
237 }
238
246 {
247 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE ? PAD_SHAPE::RECTANGLE
249 aLayer );
250 SetDirty();
251 }
252
256 bool IsOnCopperLayer() const override;
257
258 void SetY( int y )
259 {
260 VECTOR2I p = GetPosition();
261 p.y = y;
262 SetPosition( p );
263 }
264 void SetX( int x )
265 {
266 VECTOR2I p = GetPosition();
267 p.x = x;
268 SetPosition( p );
269 }
270
271 void SetSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize );
272 VECTOR2I GetSize( PCB_LAYER_ID aLayer ) const;
273
274 // Lib-frame setters used by the parser. These store the value as-is in the
275 // padstack without inverse-scaling against the parent FP transform.
276 void SetLibSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize );
277 void SetLibDrillSize( const VECTOR2I& aSize );
278 void SetLibOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset );
279
281 {
282 return m_padStack.HasExplicitDefinitionForLayer( aLayer );
283 }
284
285 // These accessors are for the properties panel, which does not have the ability to deal with
286 // custom padstacks where the properties can vary by layer. The properties should be disabled
287 // in the GUI when the padstack mode is set to anything other than NORMAL, but so that the code
288 // compiles, these are set up to work with the front layer (in other words, assume the mode is
289 // NORMAL, where F_Cu stores the whole padstack data)
290 void SetSizeX( int aX );
291 int GetSizeX() const;
292
293 void SetSizeY( int aY );
294 int GetSizeY() const;
295
296 void SetDelta( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
297 {
298 m_padStack.TrapezoidDeltaSize( aLayer ) = aSize;
299 SetDirty();
300 }
301
302 const VECTOR2I& GetDelta( PCB_LAYER_ID aLayer ) const
303 {
304 return m_padStack.TrapezoidDeltaSize( aLayer );
305 }
306
307 void SetPrimaryDrillSize( const VECTOR2I& aSize );
309 void SetPrimaryDrillSizeX( int aX );
311 void SetPrimaryDrillSizeY( int aY );
313
314 void SetDrillSize( const VECTOR2I& aSize ) { SetPrimaryDrillSize( aSize ); }
316 void SetDrillSizeX( int aX );
317 int GetDrillSizeX() const { return GetPrimaryDrillSizeX(); }
318 void SetDrillSizeY( int aY );
319 int GetDrillSizeY() const { return GetPrimaryDrillSizeY(); }
320
321 void SetOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset );
322 VECTOR2I GetOffset( PCB_LAYER_ID aLayer ) const;
323
324 VECTOR2I GetCenter() const override { return GetPosition(); }
325
326 const PADSTACK& Padstack() const { return m_padStack; }
328 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
329
341 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPoly, int aThickness,
342 bool aFilled );
343 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const std::vector<VECTOR2I>& aPoly, int aThickness,
344 bool aFilled );
345
358 void MergePrimitivesAsPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aMergedPolygon,
359 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
360
366
370 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives( PCB_LAYER_ID aLayer ) const
371 {
372 return m_padStack.Primitives( aLayer );
373 }
374
375 void Flip( const VECTOR2I& VECTOR2I, FLIP_DIRECTION aFlipDirection ) override;
376
381 void FlipPrimitives( FLIP_DIRECTION aFlipDirection );
382
387 void ReplacePrimitives( PCB_LAYER_ID aLayer,
388 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
389
394 void AppendPrimitives( PCB_LAYER_ID aLayer,
395 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
396
400 void AddPrimitive( PCB_LAYER_ID aLayer, PCB_SHAPE* aPrimitive );
401
407 void SetOrientation( const EDA_ANGLE& aAngle );
408 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
409
415
416 void GetPrimitiveLibScale( double& aScaleX, double& aScaleY ) const;
417
418 // For property system
419 void SetOrientationDegrees( double aOrientation )
420 {
421 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
422 }
423 double GetOrientationDegrees() const { return GetOrientation().AsDegrees(); }
424
426 PAD_DRILL_SHAPE GetPrimaryDrillShape() const { return m_padStack.Drill().shape; }
427
430
432 PCB_LAYER_ID GetPrimaryDrillStartLayer() const { return m_padStack.Drill().start; }
434 PCB_LAYER_ID GetPrimaryDrillEndLayer() const { return m_padStack.Drill().end; }
435
436 void SetFrontPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.FrontPostMachining().mode = aMode; }
437 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetFrontPostMachining() const { return m_padStack.FrontPostMachining().mode; }
438
440 {
441 m_padStack.FrontPostMachining().mode = aMode;
442 }
443
448
449 void SetFrontPostMachiningSize( int aSize ) { m_padStack.FrontPostMachining().size = aSize; }
450 int GetFrontPostMachiningSize() const { return m_padStack.FrontPostMachining().size; }
451 void SetFrontPostMachiningDepth( int aDepth ) { m_padStack.FrontPostMachining().depth = aDepth; }
452 int GetFrontPostMachiningDepth() const { return m_padStack.FrontPostMachining().depth; }
453 void SetFrontPostMachiningAngle( int aAngle ) { m_padStack.FrontPostMachining().angle = aAngle; }
454 int GetFrontPostMachiningAngle() const { return m_padStack.FrontPostMachining().angle; }
455
456 void SetBackPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.BackPostMachining().mode = aMode; }
457 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetBackPostMachining() const { return m_padStack.BackPostMachining().mode; }
458
460 {
461 m_padStack.BackPostMachining().mode = aMode;
462 }
463
468
469 void SetBackPostMachiningSize( int aSize ) { m_padStack.BackPostMachining().size = aSize; }
470 int GetBackPostMachiningSize() const { return m_padStack.BackPostMachining().size; }
471 void SetBackPostMachiningDepth( int aDepth ) { m_padStack.BackPostMachining().depth = aDepth; }
472 int GetBackPostMachiningDepth() const { return m_padStack.BackPostMachining().depth; }
473 void SetBackPostMachiningAngle( int aAngle ) { m_padStack.BackPostMachining().angle = aAngle; }
474 int GetBackPostMachiningAngle() const { return m_padStack.BackPostMachining().angle; }
475
485 bool IsBackdrilledOrPostMachined( PCB_LAYER_ID aLayer ) const;
486
493 int GetPostMachiningKnockout( PCB_LAYER_ID aLayer ) const;
494
495 void SetPrimaryDrillFilled( const std::optional<bool>& aFilled );
496 void SetPrimaryDrillFilledFlag( bool aFilled );
497 std::optional<bool> GetPrimaryDrillFilled() const { return m_padStack.Drill().is_filled; }
498 bool GetPrimaryDrillFilledFlag() const { return m_padStack.Drill().is_filled.value_or( false ); }
499
500 void SetPrimaryDrillCapped( const std::optional<bool>& aCapped );
501 void SetPrimaryDrillCappedFlag( bool aCapped );
502 std::optional<bool> GetPrimaryDrillCapped() const { return m_padStack.Drill().is_capped; }
503 bool GetPrimaryDrillCappedFlag() const { return m_padStack.Drill().is_capped.value_or( false ); }
504
505 void SetSecondaryDrillSize( const VECTOR2I& aSize );
506 const VECTOR2I& GetSecondaryDrillSize() const { return m_padStack.SecondaryDrill().size; }
508
509 void SetSecondaryDrillSizeX( int aX );
510 int GetSecondaryDrillSizeX() const { return m_padStack.SecondaryDrill().size.x; }
511 void SetSecondaryDrillSizeY( int aY );
512 int GetSecondaryDrillSizeY() const { return m_padStack.SecondaryDrill().size.y; }
513
515 PAD_DRILL_SHAPE GetSecondaryDrillShape() const { return m_padStack.SecondaryDrill().shape; }
516
518 PCB_LAYER_ID GetSecondaryDrillStartLayer() const { return m_padStack.SecondaryDrill().start; }
520 PCB_LAYER_ID GetSecondaryDrillEndLayer() const { return m_padStack.SecondaryDrill().end; }
521
522 void SetTertiaryDrillSize( const VECTOR2I& aSize );
523 const VECTOR2I& GetTertiaryDrillSize() const { return m_padStack.TertiaryDrill().size; }
525
526 void SetTertiaryDrillSizeX( int aX );
527 int GetTertiaryDrillSizeX() const { return m_padStack.TertiaryDrill().size.x; }
528 void SetTertiaryDrillSizeY( int aY );
529 int GetTertiaryDrillSizeY() const { return m_padStack.TertiaryDrill().size.y; }
530
532 PAD_DRILL_SHAPE GetTertiaryDrillShape() const { return m_padStack.TertiaryDrill().shape; }
533
535 PCB_LAYER_ID GetTertiaryDrillStartLayer() const { return m_padStack.TertiaryDrill().start; }
537 PCB_LAYER_ID GetTertiaryDrillEndLayer() const { return m_padStack.TertiaryDrill().end; }
538
539 bool IsDirty() const
540 {
542 }
543
544 void SetDirty()
545 {
546 m_shapesDirty = true;
549 }
550
551 void SetLayerSet( const LSET& aLayers ) override;
552 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
553
554 void SetAttribute( PAD_ATTRIB aAttribute );
556
557 void SetProperty( PAD_PROP aProperty );
558 PAD_PROP GetProperty() const { return m_property; }
559
560 // We don't currently have an attribute for APERTURE, and adding one will change the file
561 // format, so for now just infer a copper-less pad to be an APERTURE pad.
562 bool IsAperturePad() const
563 {
564 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
565 }
566
569
570 bool IsNPTHWithNoCopper() const;
571
572 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
573 int GetPadToDieLength() const { return m_lengthPadToDie; }
574
575 void SetPadToDieDelay( int aDelay ) { m_delayPadToDie = aDelay; }
576 int GetPadToDieDelay() const { return m_delayPadToDie; }
577
578 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
579 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
580
581 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
582 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
583 {
584 m_padStack.SolderMaskMargin( F_Mask ) = aMargin;
585 m_padStack.SolderMaskMargin( B_Mask ) = aMargin;
586 }
587
588 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
589 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
590 {
591 m_padStack.SolderPasteMargin( F_Paste ) = aMargin;
592 m_padStack.SolderPasteMargin( B_Paste ) = aMargin;
593 }
594
595 std::optional<double> GetLocalSolderPasteMarginRatio() const
596 {
597 return m_padStack.SolderPasteMarginRatio();
598 }
599 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
600 {
601 m_padStack.SolderPasteMarginRatio( F_Paste ) = aRatio;
602 m_padStack.SolderPasteMarginRatio( B_Paste ) = aRatio;
603 }
604
605 void SetLocalZoneConnection( ZONE_CONNECTION aType ) { m_padStack.ZoneConnection() = aType; }
607 {
608 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
609 }
610
618 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
619
629 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
630 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
631 bool ignoreLineWidth = false ) const override;
632
642 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
643 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
644
659 virtual std::shared_ptr<SHAPE>
661 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
662
663 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( PCB_LAYER_ID aLayer,
664 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
665
669 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
670
676 int GetBoundingRadius() const;
677
684 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
685
692 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
693
704 int GetSolderMaskExpansion( PCB_LAYER_ID aLayer ) const;
705
718
719 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
720
725 void SetLocalThermalSpokeWidthOverride( std::optional<int> aWidth )
726 {
727 m_padStack.ThermalSpokeWidth() = aWidth;
728 }
729 std::optional<int> GetLocalThermalSpokeWidthOverride() const
730 {
731 return m_padStack.ThermalSpokeWidth();
732 }
733
734 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
735
741 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
742 {
743 m_padStack.SetThermalSpokeAngle( aAngle );
744 }
746 {
747 return m_padStack.ThermalSpokeAngle();
748 }
749
750 // For property system
751 void SetThermalSpokeAngleDegrees( double aAngle )
752 {
753 m_padStack.SetThermalSpokeAngle( EDA_ANGLE( aAngle, DEGREES_T ) );
754 }
756 {
757 return m_padStack.ThermalSpokeAngle().AsDegrees();
758 }
759
760 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
761 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
762
763 int GetLocalThermalGapOverride( wxString* aSource ) const;
764
765 std::optional<int> GetLocalThermalGapOverride() const
766 {
767 return m_padStack.ThermalGap();
768 }
769 void SetLocalThermalGapOverride( const std::optional<int>& aOverride )
770 {
771 m_padStack.ThermalGap() = aOverride;
772 }
773
779 void SetRoundRectCornerRadius( PCB_LAYER_ID aLayer, double aRadius );
780 int GetRoundRectCornerRadius( PCB_LAYER_ID aLayer ) const;
781
782 VECTOR2I ShapePos( PCB_LAYER_ID aLayer ) const;
783
791 static void SwapShapePositions( PAD* aLhs, PAD* aRhs );
792
799 void SetRoundRectRadiusRatio( PCB_LAYER_ID aLayer, double aRadiusScale );
801 {
802 return m_padStack.RoundRectRadiusRatio( aLayer );
803 }
804
805 // For properties panel, which only supports normal padstacks
806 void SetFrontRoundRectRadiusRatio( double aRadiusScale );
808 {
809 return m_padStack.RoundRectRadiusRatio( F_Cu );
810 }
811
812 // For properties panel, which only supports normal padstacks
813 void SetFrontRoundRectRadiusSize( int aRadius );
814 int GetFrontRoundRectRadiusSize() const;
815
822 void SetChamferRectRatio( PCB_LAYER_ID aLayer, double aChamferScale );
823 double GetChamferRectRatio( PCB_LAYER_ID aLayer ) const
824 {
825 return m_padStack.ChamferRatio( aLayer );
826 }
827
835 void SetChamferPositions( PCB_LAYER_ID aLayer, int aPositions )
836 {
837 m_padStack.SetChamferPositions( aPositions, aLayer );
838 }
839
841 {
842 return m_padStack.ChamferPositions( aLayer );
843 }
844
848 int GetSubRatsnest() const { return m_subRatsnest; }
849 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
850
856 void SetRemoveUnconnected( bool aSet )
857 {
858 m_padStack.SetUnconnectedLayerMode( aSet ? UNCONNECTED_LAYER_MODE::REMOVE_ALL
860 }
861
863 {
864 return m_padStack.UnconnectedLayerMode() != UNCONNECTED_LAYER_MODE::KEEP_ALL;
865 }
866
871 void SetKeepTopBottom( bool aSet )
872 {
875 }
876
877 bool GetKeepTopBottom() const
878 {
880 }
881
883 {
884 m_padStack.SetUnconnectedLayerMode( aMode );
885 }
886
888 {
889 return m_padStack.UnconnectedLayerMode();
890 }
891
893 {
894 switch( m_padStack.UnconnectedLayerMode() )
895 {
897 return false;
898
900 return true;
901
904 return aLayer != m_padStack.Drill().start && aLayer != m_padStack.Drill().end;
905 }
906
907 return true;
908 }
909
910 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
911
912 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
913 {
914 return m_padStack.LayerSet().test( aLayer );
915 }
916
925 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
926
927 bool CanFlashLayer( int aLayer )
928 {
929 return FlashLayer( aLayer, true );
930 }
931
932 PCB_LAYER_ID GetLayer() const override;
933
938
946 bool FlashLayer( const LSET& aLayers ) const;
947
948 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
949 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
950 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
951
955 bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const;
956
964 std::vector<PCB_SHAPE*> Recombine( bool aIsDryRun, int aMaxError );
965
966 wxString GetClass() const override
967 {
968 return wxT( "PAD" );
969 }
970
974 const BOX2I GetBoundingBox() const override;
975 const BOX2I GetBoundingBox( PCB_LAYER_ID aLayer ) const;
976
983 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
984
985 void Move( const VECTOR2I& aMoveVector ) override {
986 SetPosition( GetPosition() + aMoveVector );
987 }
988
989 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
990
991 void OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
992 const EDA_ANGLE& aParentRotate ) override;
993
994 void OnFootprintTransformed() override;
995
996 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
997
998 BITMAPS GetMenuImage() const override;
999
1003 static wxString ShowPadShape( PAD_SHAPE aShape );
1004 wxString ShowPadShape( PCB_LAYER_ID aLayer ) const;
1005
1009 wxString ShowLegacyPadShape( PCB_LAYER_ID aLayer ) const;
1010
1014 wxString ShowPadAttr() const;
1015
1016 EDA_ITEM* Clone() const override;
1017
1023 PAD* ClonePad() const
1024 {
1025 return (PAD*) Clone();
1026 }
1027
1032 void BuildEffectiveShapes() const;
1033 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
1034
1035 virtual std::vector<int> ViewGetLayers() const override;
1036
1037 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1038
1039 virtual const BOX2I ViewBBox() const override;
1040
1042
1044
1045 void SetZoneLayerOverride( PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride );
1046
1047 void CheckPad( UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1048 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1049
1050 BACKDRILL_MODE GetBackdrillMode() const { return m_padStack.GetBackdrillMode(); }
1051 void SetBackdrillMode( BACKDRILL_MODE aMode ) { m_padStack.SetBackdrillMode( aMode ); }
1052
1053 std::optional<int> GetBottomBackdrillSize() const { return m_padStack.GetBackdrillSize( false ); }
1054 void SetBottomBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( false, aSize ); }
1055
1056 PCB_LAYER_ID GetBottomBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( false ); }
1057 void SetBottomBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( false, aLayer ); }
1058
1059 std::optional<int> GetTopBackdrillSize() const { return m_padStack.GetBackdrillSize( true ); }
1060 void SetTopBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( true, aSize ); }
1061
1062 PCB_LAYER_ID GetTopBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( true ); }
1063 void SetTopBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( true, aLayer ); }
1064
1065 double Similarity( const BOARD_ITEM& aOther ) const override;
1066
1067 bool operator==( const PAD& aOther ) const;
1068 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
1069
1070#if defined(DEBUG)
1071 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1072#endif
1073
1074protected:
1075 virtual void swapData( BOARD_ITEM* aImage ) override;
1076
1077private:
1078 const SHAPE_COMPOUND& buildEffectiveShape( PCB_LAYER_ID aLayer ) const;
1079
1080 // Scale a primitive's runtime geometry to the current footprint scale, in the pad frame.
1081 void rebakePrimitiveToFootprint( PCB_SHAPE* aPrimitive ) const;
1082
1084 {
1085 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
1086 typedef std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_COMPOUND>> LAYER_SHAPE_MAP;
1087 typedef std::map<PCB_LAYER_ID, std::array<std::shared_ptr<SHAPE_POLY_SET>, 2>> LAYER_POLYGON_MAP;
1088
1091 std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
1094 };
1095
1097
1098 void doCheckPad( PCB_LAYER_ID aLayer, UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1099 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1100
1101private:
1102 wxString m_number; // Pad name (pin number in schematic)
1103 wxString m_pinFunction; // Pin name in schematic
1104 wxString m_pinType; // Pin electrical type in schematic
1105
1106 VECTOR2I m_libPos; // Pad position in parent footprint's library frame
1107 EDA_ANGLE m_libOrientation; // Pad orientation in parent footprint's library frame
1108
1110
1111 // Mutex for shape building, poly building and zone layer overrides
1112 mutable std::mutex m_dataMutex;
1113
1114 mutable std::unique_ptr<PAD_DRAW_CACHE_DATA> m_drawCache;
1115
1117
1118 int m_subRatsnest; // Variable used to handle subnet (block) number in
1119 // ratsnest computations
1120
1122
1123 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
1124
1125 int m_lengthPadToDie; // Length net from pad to die, inside the package
1126 int m_delayPadToDie; // Propagation delay from pad to die
1127
1129
1130 // Bools at the end for better memory layout
1131 mutable bool m_polyDirty[2];
1132 mutable bool m_shapesDirty;
1133
1134 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> m_zoneLayerOverrides;
1135};
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
BITMAPS
A list of all bitmap identifiers.
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
Definition board_item.h:69
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:83
FOOTPRINT * GetParentFootprint() const
Implement a canvas based on a wxGLCanvas.
double AsDegrees() const
Definition eda_angle.h:116
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:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:202
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:62
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition padstack.h:157
Definition pad.h:61
VECTOR2I GetPrimaryDrillSize() const
Definition pad.cpp:744
void SetFrontPostMachiningSize(int aSize)
Definition pad.h:449
int GetBackPostMachiningSize() const
Definition pad.h:470
void SetAnchorPadShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition pad.h:245
bool IsAperturePad() const
Definition pad.h:562
void SetAttribute(PAD_ATTRIB aAttribute)
Definition pad.cpp:1615
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1944
void CheckPad(UNITS_PROVIDER *aUnitsProvider, bool aForPadProperties, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition pad.cpp:3197
std::optional< bool > GetPrimaryDrillFilled() const
Definition pad.h:497
void SetBackPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:456
PAD(FOOTPRINT *parent)
Definition pad.cpp:75
virtual void swapData(BOARD_ITEM *aImage) override
Definition pad.cpp:2920
PAD_PROP GetProperty() const
Definition pad.h:558
void SetFrontPostMachiningAngle(int aAngle)
Definition pad.h:453
bool GetRemoveUnconnected() const
Definition pad.h:862
void SetSizeY(int aY)
Definition pad.cpp:317
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pad.cpp:2488
void SetPrimaryDrillFilledFlag(bool aFilled)
Definition pad.cpp:1009
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pad.cpp:391
double GetFrontRoundRectRadiusRatio() const
Definition pad.h:807
void doCheckPad(PCB_LAYER_ID aLayer, UNITS_PROVIDER *aUnitsProvider, bool aForPadProperties, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition pad.cpp:3312
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2500
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition pad.cpp:1919
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition pad.h:159
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition pad.h:552
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
Definition pad.h:370
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition pad.cpp:480
int GetSizeX() const
Definition pad.cpp:311
void MergePrimitivesAsPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
Definition pad.cpp:3625
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1136
void rebakePrimitiveToFootprint(PCB_SHAPE *aPrimitive) const
Definition pad.cpp:2459
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:650
void SetLocalThermalGapOverride(const std::optional< int > &aOverride)
Definition pad.h:769
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:733
bool IsDirty() const
Definition pad.h:539
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pad.cpp:1208
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:2158
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1599
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1122
void SetSizeX(int aX)
Definition pad.cpp:297
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition pad.h:912
int GetDrillSizeY() const
Definition pad.h:319
void AddPrimitivePoly(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
Definition pad.cpp:3519
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition pad.h:595
void SetFrontPostMachiningDepth(int aDepth)
Definition pad.h:451
void SetFrontShape(PAD_SHAPE aShape)
Definition pad.cpp:1669
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1063
const wxString & GetPinType() const
Definition pad.h:160
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition pad.cpp:490
void SetSecondaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1030
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
Definition pad.cpp:1002
PAD_ATTRIB GetAttribute() const
Definition pad.h:555
static LSET PTHMask()
layer set for a through hole pad
Definition pad.cpp:579
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition pad.cpp:2424
void SetRemoveUnconnected(bool aSet)
Definition pad.h:856
const wxString & GetPinFunction() const
Definition pad.h:154
void SetThermalGap(int aGap)
Definition pad.h:760
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:497
void SetFrontPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:436
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition pad.h:741
wxString m_pinType
Definition pad.h:1104
std::optional< int > GetBottomBackdrillSize() const
Definition pad.h:1053
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pad.cpp:428
const wxString & GetNumber() const
Definition pad.h:143
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition pad.cpp:2741
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:302
int GetSecondaryDrillSizeX() const
Definition pad.h:510
void SetSecondaryDrillSizeX(int aX)
Definition pad.cpp:1037
void SetFrontRoundRectRadiusRatio(double aRadiusScale)
Definition pad.cpp:1156
void SetPrimaryDrillSizeX(int aX)
Definition pad.cpp:753
PAD_DRAW_CACHE_DATA & getDrawCache() const
Definition pad.cpp:1330
std::mutex m_dataMutex
Definition pad.h:1112
void BuildEffectiveShapes() const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition pad.cpp:1339
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:824
void SetSimElectricalType(PAD_SIM_ELECTRICAL_TYPE aType)
Definition pad.h:567
PAD_SHAPE GetFrontShape() const
Definition pad.h:207
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:439
static bool ClassOf(const EDA_ITEM *aItem)
Definition pad.h:87
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pad.cpp:356
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition pad.h:599
PAD & operator=(const PAD &aOther)
Definition pad.cpp:337
void SetLocalThermalSpokeWidthOverride(std::optional< int > aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition pad.h:725
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
Definition pad.h:193
void SetSecondaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1069
bool IsLocked() const override
Definition pad.cpp:541
wxString ShowLegacyPadShape(PCB_LAYER_ID aLayer) const
An older version still used by place file writer.
Definition pad.cpp:2522
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
Definition pad.cpp:2470
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pad.h:324
VECTOR2I GetPosition() const override
Definition pad.cpp:245
void SetProperty(PAD_PROP aProperty)
Definition pad.cpp:1688
void SetThermalSpokeAngleDegrees(double aAngle)
Definition pad.h:751
void SetPrimaryDrillSizeY(int aY)
Definition pad.cpp:771
EDA_ANGLE GetThermalSpokeAngle() const
Definition pad.h:745
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition pad.h:1134
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition pad.h:892
PAD_ATTRIB m_attribute
Definition pad.h:1121
void Flip(const VECTOR2I &VECTOR2I, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pad.cpp:1738
void SetBackPostMachiningSize(int aSize)
Definition pad.h:469
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pad.h:985
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition pad.cpp:3051
PCB_LAYER_ID GetPrincipalLayer() const
Definition pad.cpp:628
void ClearTertiaryDrillSize()
Definition pad.cpp:1108
void SetDirty()
Definition pad.h:544
PAD_DRILL_SHAPE GetTertiaryDrillShape() const
Definition pad.h:532
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:537
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:600
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.h:296
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1057
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pad.cpp:2641
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1115
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.cpp:796
double GetOrientationDegrees() const
Definition pad.h:423
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:166
void SetBackdrillMode(BACKDRILL_MODE aMode)
Definition pad.h:1051
VECTOR2I GetDrillSize() const
Definition pad.h:315
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pad.cpp:2435
int GetBackPostMachiningAngle() const
Definition pad.h:474
PADSTACK m_padStack
Definition pad.h:1109
void SetPadToDieDelay(int aDelay)
Definition pad.h:575
void FlipPrimitives(FLIP_DIRECTION aFlipDirection)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
Definition pad.cpp:1813
VECTOR2I m_libPos
Definition pad.h:1106
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pad.h:535
EDA_ANGLE m_libOrientation
Definition pad.h:1107
bool IsNoConnectPad() const
Definition pad.cpp:567
int GetDrillSizeX() const
Definition pad.h:317
PCB_LAYER_ID GetPrimaryDrillStartLayer() const
Definition pad.h:432
PAD_PROP m_property
Definition pad.h:1123
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:800
int GetFrontPostMachiningSize() const
Definition pad.h:450
void SetKeepTopBottom(bool aSet)
Definition pad.h:871
void SetTertiaryDrillSizeX(int aX)
Definition pad.cpp:1090
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
Definition pad.cpp:3606
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition pad.h:882
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:202
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:2945
PADSTACK & Padstack()
Definition pad.h:327
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition pad.h:142
BACKDRILL_MODE GetBackdrillMode() const
Definition pad.h:1050
void SetTertiaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1083
int GetTertiaryDrillSizeY() const
Definition pad.h:529
void SetFrontRoundRectRadiusSize(int aRadius)
Definition pad.cpp:1166
wxString ShowPadAttr() const
Definition pad.cpp:2538
wxString m_pinFunction
Definition pad.h:1103
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1076
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
Definition pad.cpp:3581
int GetFrontPostMachiningDepth() const
Definition pad.h:452
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.h:428
int m_effectiveBoundingRadius
Definition pad.h:1116
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pad.h:582
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:459
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:785
void SetCustomShapeInZoneOpt(CUSTOM_SHAPE_ZONE_MODE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition pad.h:234
bool GetKeepTopBottom() const
Definition pad.h:877
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition pad.h:605
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition pad.cpp:1186
void SetPrimaryDrillCappedFlag(bool aCapped)
Definition pad.cpp:1023
bool GetPrimaryDrillFilledFlag() const
Definition pad.h:498
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1951
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:287
int GetPadToDieDelay() const
Definition pad.h:576
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:578
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition pad.cpp:2848
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:3495
std::unique_ptr< PAD_DRAW_CACHE_DATA > m_drawCache
Definition pad.h:1114
bool IsOnCopperLayer() const override
Definition pad.cpp:1863
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1129
void SetPadstack(const PADSTACK &aPadstack)
Definition pad.h:328
void SetPosition(const VECTOR2I &aPos) override
Definition pad.cpp:234
const SHAPE_COMPOUND & buildEffectiveShape(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1388
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:805
const PADSTACK & Padstack() const
Definition pad.h:326
PAD_DRILL_SHAPE GetSecondaryDrillShape() const
Definition pad.h:515
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1543
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition pad.cpp:593
void SetDrillSize(const VECTOR2I &aSize)
Definition pad.h:314
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
Definition pad.h:464
bool IsFreePad() const
Definition pad.cpp:573
int GetFrontPostMachiningAngle() const
Definition pad.h:454
void SetLibOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:280
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
Definition pad.h:444
wxString GetClass() const override
Return the class name.
Definition pad.h:966
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetFrontPostMachining() const
Definition pad.h:437
bool IsNPTHWithNoCopper() const
Definition pad.cpp:511
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:506
bool CanFlashLayer(int aLayer)
Definition pad.h:927
void SetLibSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:266
int m_subRatsnest
Definition pad.h:1118
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1723
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:254
int m_delayPadToDie
Definition pad.h:1126
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:429
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1062
void ReplacePrimitives(PCB_LAYER_ID aLayer, const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
Definition pad.cpp:3558
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:840
void SetY(int y)
Definition pad.h:258
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:607
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetBackPostMachining() const
Definition pad.h:457
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pad.cpp:2814
UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition pad.h:887
VECTOR2I GetLibraryPosition() const
Definition pad.h:211
bool m_shapesDirty
Definition pad.h:1132
void SetRoundRectCornerRadius(PCB_LAYER_ID aLayer, double aRadius)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1142
void SetDrillSizeY(int aY)
Definition pad.cpp:779
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:586
std::optional< int > GetLocalSolderPasteMargin() const
Definition pad.h:588
int GetFrontRoundRectRadiusSize() const
Definition pad.cpp:1176
int GetTertiaryDrillSizeX() const
Definition pad.h:527
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1194
void SetX(int x)
Definition pad.h:264
void SetChamferPositions(PCB_LAYER_ID aLayer, int aPositions)
Has meaning only for chamfered rectangular pads.
Definition pad.h:835
int GetBackPostMachiningDepth() const
Definition pad.h:472
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
Definition pad.h:568
std::optional< int > GetLocalSolderMaskMargin() const
Definition pad.h:581
void SetDrillSizeX(int aX)
Definition pad.cpp:765
PAD_SIM_ELECTRICAL_TYPE m_simElectricalType
Definition pad.h:1128
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition pad.h:589
int GetSizeY() const
Definition pad.cpp:331
std::optional< int > GetLocalThermalGapOverride() const
Definition pad.h:765
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pad.cpp:622
void GetPrimitiveLibScale(double &aScaleX, double &aScaleY) const
Definition pad.cpp:2445
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pad.cpp:2551
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:153
EDA_ANGLE GetFPRelativeOrientation() const
Definition pad.cpp:1732
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:823
bool m_polyDirty[2]
Definition pad.h:1131
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:2317
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition pad.cpp:1709
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:908
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition pad.cpp:1321
std::optional< int > GetTopBackdrillSize() const
Definition pad.h:1059
void ClearZoneLayerOverrides()
Definition pad.cpp:471
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition pad.cpp:1696
int GetPrimaryDrillSizeY() const
Definition pad.h:312
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:729
PAD_DRILL_SHAPE GetPrimaryDrillShape() const
Definition pad.h:426
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
Definition pad.cpp:831
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition pad.cpp:2014
void SetTopBackdrillSize(std::optional< int > aSize)
Definition pad.h:1060
std::optional< bool > GetPrimaryDrillCapped() const
Definition pad.h:502
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pad.cpp:2635
void AppendPrimitives(PCB_LAYER_ID aLayer, 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.
Definition pad.cpp:3571
int GetPrimaryDrillSizeX() const
Definition pad.h:310
static void SwapShapePositions(PAD *aLhs, PAD *aRhs)
Swap the visible shape positions of two pads, preserving each pad's own shape offset.
Definition pad.cpp:1845
wxString m_number
Definition pad.h:1102
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:817
void SetBackPostMachiningDepth(int aDepth)
Definition pad.h:471
bool HasDrilledHole() const override
Definition pad.h:118
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
Definition pad.cpp:1016
void SetLibDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:273
PCB_LAYER_ID GetPrimaryDrillEndLayer() const
Definition pad.h:434
PCB_LAYER_ID GetBottomBackdrillLayer() const
Definition pad.h:1056
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Definition pad.h:280
void SetLocalClearance(std::optional< int > aClearance)
Definition pad.h:579
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pad.h:518
int GetSubRatsnest() const
Definition pad.h:848
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:523
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:606
void SetTertiaryDrillSizeY(int aY)
Definition pad.cpp:1101
int m_lengthPadToDie
Definition pad.h:1125
bool HasHole() const override
Definition pad.h:113
double GetThermalSpokeAngleDegrees() const
Definition pad.h:755
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition pad.h:1023
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition pad.h:224
int GetThermalGap() const
Definition pad.h:761
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1831
int GetSecondaryDrillSizeY() const
Definition pad.h:512
void SetSecondaryDrillSizeY(int aY)
Definition pad.cpp:1048
PCB_LAYER_ID GetTopBackdrillLayer() const
Definition pad.h:1062
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition pad.cpp:1312
void SetOrientationDegrees(double aOrientation)
Definition pad.h:419
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition pad.cpp:2120
void SetLayerSet(const LSET &aLayers) override
Definition pad.cpp:1931
bool SharesNetTieGroup(const PAD *aOther) const
Definition pad.cpp:550
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
Definition pad.h:216
void SetBottomBackdrillSize(std::optional< int > aSize)
Definition pad.h:1054
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1148
void ClearSecondaryDrillSize()
Definition pad.cpp:1055
bool GetPrimaryDrillCappedFlag() const
Definition pad.h:503
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:520
void SetSubRatsnest(int aSubRatsnest)
Definition pad.h:849
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition pad.cpp:2140
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:2928
void SetPadToDieLength(int aLength)
Definition pad.h:572
bool IsFlipped() const
Definition pad.cpp:614
bool operator==(const PAD &aOther) const
Definition pad.cpp:3480
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition pad.h:92
int GetPadToDieLength() const
Definition pad.h:573
void SetBackPostMachiningAngle(int aAngle)
Definition pad.h:473
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pad.cpp:2657
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition shape.h:124
@ DEGREES_T
Definition eda_angle.h:31
@ NONE
Definition eda_shape.h:72
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:181
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_Paste
Definition layer_ids.h:100
@ B_Mask
Definition layer_ids.h:94
@ F_Mask
Definition layer_ids.h:93
@ B_Paste
Definition layer_ids.h:101
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
FLIP_DIRECTION
Definition mirror.h:23
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
PAD_SIM_ELECTRICAL_TYPE
The electrical type of a pad.
Definition pad.h:53
PAD_DRILL_POST_MACHINING_MODE
Definition padstack.h:76
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:69
CUSTOM_SHAPE_ZONE_MODE
Definition padstack.h:137
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition padstack.h:97
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:103
@ PTH
Plated through hole pad.
Definition padstack.h:98
BACKDRILL_MODE
Definition padstack.h:84
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:52
@ RECTANGLE
Definition padstack.h:54
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition padstack.h:114
UNCONNECTED_LAYER_MODE
Definition padstack.h:128
std::map< PCB_LAYER_ID, std::array< std::shared_ptr< SHAPE_POLY_SET >, 2 > > LAYER_POLYGON_MAP
Definition pad.h:1087
LAYER_POLYGON_MAP m_effectivePolygons
Definition pad.h:1092
LAYER_SHAPE_MAP m_effectiveShapes
Definition pad.h:1090
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition pad.h:1091
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_COMPOUND > > LAYER_SHAPE_MAP
Definition pad.h:1086
BOX2I m_effectiveBoundingBox
Definition pad.h:1089
double m_lastGalZoomLevel
Definition pad.h:1093
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71
@ PCB_LOCATE_NPTH_T
Definition typeinfo.h:126
@ PCB_LOCATE_PTH_T
Definition typeinfo.h:125
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80
@ PCB_LOCATE_HOLE_T
Definition typeinfo.h:124
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43