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 GetDrillSize().x > 0 && GetDrillSize().y > 0;
116 }
117
118 bool HasDrilledHole() const override
119 {
120 return HasHole() && GetDrillSize().x == GetDrillSize().y;
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
190 void SetPadstackMode( PADSTACK::MODE aMode ) { m_padStack.SetMode( aMode ); }
191 PADSTACK::MODE GetPadstackMode() const { return m_padStack.Mode(); }
192
196 void SetShape( PCB_LAYER_ID aLayer, PAD_SHAPE aShape )
197 {
198 m_padStack.SetShape( aShape, aLayer );
199 SetDirty();
200 }
201
205 PAD_SHAPE GetShape( PCB_LAYER_ID aLayer ) const { return m_padStack.Shape( aLayer ); }
206
207 // Used for the properties panel, which does not support padstacks at the moment
208 void SetFrontShape( PAD_SHAPE aShape );
209
210 PAD_SHAPE GetFrontShape() const { return m_padStack.Shape( F_Cu ); }
211
212 void SetPosition( const VECTOR2I& aPos ) override;
213 VECTOR2I GetPosition() const override;
215
220 {
221 return m_padStack.AnchorShape( aLayer );
222 }
223
228 {
229 return m_padStack.CustomShapeInZoneMode();
230 }
231
238 {
239 m_padStack.SetCustomShapeInZoneMode( aOption );
240 }
241
250 {
251 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE ? PAD_SHAPE::RECTANGLE
253 aLayer );
254 SetDirty();
255 }
256
260 bool IsOnCopperLayer() const override;
261
262 void SetY( int y )
263 {
264 VECTOR2I p = GetPosition();
265 p.y = y;
266 SetPosition( p );
267 }
268
269 void SetX( int x )
270 {
271 VECTOR2I p = GetPosition();
272 p.x = x;
273 SetPosition( p );
274 }
275
276 void SetSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize );
277 VECTOR2I GetSize( PCB_LAYER_ID aLayer ) const;
278
279 // Lib-frame setters used by the parser. These store the value as-is in the
280 // padstack without inverse-scaling against the parent FP transform.
281 void SetLibSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize );
282 void SetLibDrillSize( const VECTOR2I& aSize );
283 void SetLibOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset );
284
286 {
287 return m_padStack.HasExplicitDefinitionForLayer( aLayer );
288 }
289
290 // These accessors are for the properties panel, which does not have the ability to deal with
291 // custom padstacks where the properties can vary by layer. The properties should be disabled
292 // in the GUI when the padstack mode is set to anything other than NORMAL, but so that the code
293 // compiles, these are set up to work with the front layer (in other words, assume the mode is
294 // NORMAL, where F_Cu stores the whole padstack data)
295 void SetSizeXProp( int aX );
296 int GetSizeXProp() const;
297
298 void SetSizeYProp( int aY );
299 int GetSizeYProp() const;
300
301 void SetDelta( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
302 {
303 m_padStack.TrapezoidDeltaSize( aLayer ) = aSize;
304 SetDirty();
305 }
306
307 const VECTOR2I& GetDelta( PCB_LAYER_ID aLayer ) const
308 {
309 return m_padStack.TrapezoidDeltaSize( aLayer );
310 }
311
312 void SetPrimaryDrillSize( const VECTOR2I& aSize );
314 void SetPrimaryDrillSizeX( int aX );
316 void SetPrimaryDrillSizeY( int aY );
318
319 void SetDrillSize( const VECTOR2I& aSize ) { SetPrimaryDrillSize( aSize ); }
321 void SetDrillSizeXProp( int aX );
322 int GetDrillSizeXProp() const { return GetPrimaryDrillSizeX(); }
323 void SetDrillSizeYProp( int aY );
324 int GetDrillSizeYProp() const { return GetPrimaryDrillSizeY(); }
325
326 void SetOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset );
327 VECTOR2I GetOffset( PCB_LAYER_ID aLayer ) const;
328
329 VECTOR2I GetCenter() const override { return GetPosition(); }
330
331 const PADSTACK& Padstack() const { return m_padStack; }
333 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
334
346 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPoly, int aThickness,
347 bool aFilled );
348 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const std::vector<VECTOR2I>& aPoly, int aThickness,
349 bool aFilled );
350
363 void MergePrimitivesAsPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aMergedPolygon,
364 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
365
371
375 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives( PCB_LAYER_ID aLayer ) const
376 {
377 return m_padStack.Primitives( aLayer );
378 }
379
380 void Flip( const VECTOR2I& VECTOR2I, FLIP_DIRECTION aFlipDirection ) override;
381
382 void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
383
384 void Mirror( const SEG& aAxis ) override;
385
390 void FlipPrimitives( FLIP_DIRECTION aFlipDirection );
391
396 void ReplacePrimitives( PCB_LAYER_ID aLayer,
397 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
398
403 void AppendPrimitives( PCB_LAYER_ID aLayer,
404 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
405
409 void AddPrimitive( PCB_LAYER_ID aLayer, PCB_SHAPE* aPrimitive );
410
416 void SetOrientation( const EDA_ANGLE& aAngle );
417 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
418
424
425 void GetPrimitiveLibScale( double& aScaleX, double& aScaleY ) const;
426
427 // For property system
428 void SetOrientationDegrees( double aOrientation )
429 {
430 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
431 }
432 double GetOrientationDegrees() const { return GetOrientation().AsDegrees(); }
433
435 PAD_DRILL_SHAPE GetPrimaryDrillShape() const { return m_padStack.Drill().shape; }
436
439
441 PCB_LAYER_ID GetPrimaryDrillStartLayer() const { return m_padStack.Drill().start; }
443 PCB_LAYER_ID GetPrimaryDrillEndLayer() const { return m_padStack.Drill().end; }
444
445 void SetFrontPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.FrontPostMachining().mode = aMode; }
446 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetFrontPostMachining() const { return m_padStack.FrontPostMachining().mode; }
447
449 {
450 m_padStack.FrontPostMachining().mode = aMode;
451 }
452
457
458 void SetFrontPostMachiningSize( int aSize ) { m_padStack.FrontPostMachining().size = aSize; }
459 int GetFrontPostMachiningSize() const { return m_padStack.FrontPostMachining().size; }
460 void SetFrontPostMachiningDepth( int aDepth ) { m_padStack.FrontPostMachining().depth = aDepth; }
461 int GetFrontPostMachiningDepth() const { return m_padStack.FrontPostMachining().depth; }
462 void SetFrontPostMachiningAngle( int aAngle ) { m_padStack.FrontPostMachining().angle = aAngle; }
463 int GetFrontPostMachiningAngle() const { return m_padStack.FrontPostMachining().angle; }
464
465 void SetBackPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.BackPostMachining().mode = aMode; }
466 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetBackPostMachining() const { return m_padStack.BackPostMachining().mode; }
467
469 {
470 m_padStack.BackPostMachining().mode = aMode;
471 }
472
477
478 void SetBackPostMachiningSize( int aSize ) { m_padStack.BackPostMachining().size = aSize; }
479 int GetBackPostMachiningSize() const { return m_padStack.BackPostMachining().size; }
480 void SetBackPostMachiningDepth( int aDepth ) { m_padStack.BackPostMachining().depth = aDepth; }
481 int GetBackPostMachiningDepth() const { return m_padStack.BackPostMachining().depth; }
482 void SetBackPostMachiningAngle( int aAngle ) { m_padStack.BackPostMachining().angle = aAngle; }
483 int GetBackPostMachiningAngle() const { return m_padStack.BackPostMachining().angle; }
484
494 bool IsBackdrilledOrPostMachined( PCB_LAYER_ID aLayer ) const;
495
502 int GetPostMachiningKnockout( PCB_LAYER_ID aLayer ) const;
503
510
520 bool HasCopperRemoved( PCB_LAYER_ID aLayer ) const;
521
522 void SetPrimaryDrillFilled( const std::optional<bool>& aFilled );
523 void SetPrimaryDrillFilledFlag( bool aFilled );
524 std::optional<bool> GetPrimaryDrillFilled() const { return m_padStack.Drill().is_filled; }
525 bool GetPrimaryDrillFilledFlag() const { return m_padStack.Drill().is_filled.value_or( false ); }
526
527 void SetPrimaryDrillCapped( const std::optional<bool>& aCapped );
528 void SetPrimaryDrillCappedFlag( bool aCapped );
529 std::optional<bool> GetPrimaryDrillCapped() const { return m_padStack.Drill().is_capped; }
530 bool GetPrimaryDrillCappedFlag() const { return m_padStack.Drill().is_capped.value_or( false ); }
531
532 void SetSecondaryDrillSize( const VECTOR2I& aSize );
533 const VECTOR2I& GetSecondaryDrillSize() const { return m_padStack.SecondaryDrill().size; }
535
536 void SetSecondaryDrillSizeX( int aX );
537 int GetSecondaryDrillSizeX() const { return m_padStack.SecondaryDrill().size.x; }
538 void SetSecondaryDrillSizeY( int aY );
539 int GetSecondaryDrillSizeY() const { return m_padStack.SecondaryDrill().size.y; }
540
542 PAD_DRILL_SHAPE GetSecondaryDrillShape() const { return m_padStack.SecondaryDrill().shape; }
543
545 PCB_LAYER_ID GetSecondaryDrillStartLayer() const { return m_padStack.SecondaryDrill().start; }
547 PCB_LAYER_ID GetSecondaryDrillEndLayer() const { return m_padStack.SecondaryDrill().end; }
548
549 void SetTertiaryDrillSize( const VECTOR2I& aSize );
550 const VECTOR2I& GetTertiaryDrillSize() const { return m_padStack.TertiaryDrill().size; }
552
553 void SetTertiaryDrillSizeX( int aX );
554 int GetTertiaryDrillSizeX() const { return m_padStack.TertiaryDrill().size.x; }
555 void SetTertiaryDrillSizeY( int aY );
556 int GetTertiaryDrillSizeY() const { return m_padStack.TertiaryDrill().size.y; }
557
559 PAD_DRILL_SHAPE GetTertiaryDrillShape() const { return m_padStack.TertiaryDrill().shape; }
560
562 PCB_LAYER_ID GetTertiaryDrillStartLayer() const { return m_padStack.TertiaryDrill().start; }
564 PCB_LAYER_ID GetTertiaryDrillEndLayer() const { return m_padStack.TertiaryDrill().end; }
565
566 bool IsDirty() const
567 {
569 }
570
571 void SetDirty()
572 {
573 m_shapesDirty = true;
576 }
577
578 void SetLayerSet( const LSET& aLayers ) override;
579 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
580
581 void SetAttribute( PAD_ATTRIB aAttribute );
583
584 void SetProperty( PAD_PROP aProperty );
585 PAD_PROP GetProperty() const { return m_property; }
586
587 // We don't currently have an attribute for APERTURE, and adding one will change the file
588 // format, so for now just infer a copper-less pad to be an APERTURE pad.
589 bool IsAperturePad() const
590 {
591 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
592 }
593
596
597 bool IsNPTHWithNoCopper() const;
598
599 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
600 int GetPadToDieLength() const { return m_lengthPadToDie; }
601
602 void SetPadToDieDelay( int aDelay ) { m_delayPadToDie = aDelay; }
603 int GetPadToDieDelay() const { return m_delayPadToDie; }
604
605 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
606 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
607
608 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
609 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
610 {
611 m_padStack.SolderMaskMargin( F_Mask ) = aMargin;
612 m_padStack.SolderMaskMargin( B_Mask ) = aMargin;
613 }
614
615 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
616 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
617 {
618 m_padStack.SolderPasteMargin( F_Paste ) = aMargin;
619 m_padStack.SolderPasteMargin( B_Paste ) = aMargin;
620 }
621
622 std::optional<double> GetLocalSolderPasteMarginRatio() const
623 {
624 return m_padStack.SolderPasteMarginRatio();
625 }
626 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
627 {
628 m_padStack.SolderPasteMarginRatio( F_Paste ) = aRatio;
629 m_padStack.SolderPasteMarginRatio( B_Paste ) = aRatio;
630 }
631
632 void SetLocalZoneConnection( ZONE_CONNECTION aType ) { m_padStack.ZoneConnection() = aType; }
634 {
635 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
636 }
637
645 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
646
647 double GetCoverageArea( int aTextMargin ) const override;
648
659 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
660 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
661 bool aIgnoreLineWidth = false ) const override;
662
672 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
673 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
674
692 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
694 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
695
696 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( PCB_LAYER_ID aLayer,
697 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
698
702 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
703 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
704
710 int GetBoundingRadius() const;
711
718 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
719
726 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
727
738 int GetSolderMaskExpansion( PCB_LAYER_ID aLayer ) const;
739
752
753 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
754
759 void SetLocalThermalSpokeWidthOverride( std::optional<int> aWidth )
760 {
761 m_padStack.ThermalSpokeWidth() = aWidth;
762 }
763 std::optional<int> GetLocalThermalSpokeWidthOverride() const
764 {
765 return m_padStack.ThermalSpokeWidth();
766 }
767
768 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
769
775 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
776 {
777 m_padStack.SetThermalSpokeAngle( aAngle );
778 }
780 {
781 return m_padStack.ThermalSpokeAngle();
782 }
783
784 // For property system
785 void SetThermalSpokeAngleDegrees( double aAngle )
786 {
787 m_padStack.SetThermalSpokeAngle( EDA_ANGLE( aAngle, DEGREES_T ) );
788 }
790 {
791 return m_padStack.ThermalSpokeAngle().AsDegrees();
792 }
793
794 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
795 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
796
797 int GetLocalThermalGapOverride( wxString* aSource ) const;
798
799 std::optional<int> GetLocalThermalGapOverride() const
800 {
801 return m_padStack.ThermalGap();
802 }
803 void SetLocalThermalGapOverride( const std::optional<int>& aOverride )
804 {
805 m_padStack.ThermalGap() = aOverride;
806 }
807
808 void SetRoundRectCornerRadius( PCB_LAYER_ID aLayer, double aRadius );
809
813 int GetRoundRectCornerRadius( PCB_LAYER_ID aLayer ) const;
814
815 VECTOR2I ShapePos( PCB_LAYER_ID aLayer ) const;
816
828 static void SwapShapePositions( PAD* aLhs, PAD* aRhs, PCB_LAYER_ID aActiveLayer );
829
836 void SetRoundRectRadiusRatio( PCB_LAYER_ID aLayer, double aRadiusScale );
838 {
839 return m_padStack.RoundRectRadiusRatio( aLayer );
840 }
841
842 // For properties panel, which only supports normal padstacks
843 void SetFrontRoundRectRadiusRatio( double aRadiusScale );
845 {
846 return m_padStack.RoundRectRadiusRatio( F_Cu );
847 }
848
849 // For properties panel, which only supports normal padstacks
850 void SetFrontRoundRectRadiusSize( int aRadius );
851 int GetFrontRoundRectRadiusSize() const;
852
859 void SetChamferRectRatio( PCB_LAYER_ID aLayer, double aChamferScale );
860 double GetChamferRectRatio( PCB_LAYER_ID aLayer ) const
861 {
862 return m_padStack.ChamferRatio( aLayer );
863 }
864
873 void SetChamferPositions( PCB_LAYER_ID aLayer, int aPositions )
874 {
875 m_padStack.SetChamferPositions( aPositions, aLayer );
876 }
877
879 {
880 return m_padStack.ChamferPositions( aLayer );
881 }
882
886 int GetSubRatsnest() const { return m_subRatsnest; }
887 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
888
894 void SetRemoveUnconnected( bool aSet )
895 {
896 m_padStack.SetUnconnectedLayerMode( aSet ? UNCONNECTED_LAYER_MODE::REMOVE_ALL
898 }
899
901 {
902 return m_padStack.UnconnectedLayerMode() != UNCONNECTED_LAYER_MODE::KEEP_ALL;
903 }
904
909 void SetKeepTopBottom( bool aSet )
910 {
913 }
914
915 bool GetKeepTopBottom() const
916 {
918 }
919
921 {
922 m_padStack.SetUnconnectedLayerMode( aMode );
923 }
924
926 {
927 return m_padStack.UnconnectedLayerMode();
928 }
929
931 {
932 switch( m_padStack.UnconnectedLayerMode() )
933 {
935 return false;
936
938 return true;
939
942 return aLayer != m_padStack.Drill().start && aLayer != m_padStack.Drill().end;
943 }
944
945 return true;
946 }
947
948 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
949
950 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
951 {
952 return m_padStack.LayerSet().test( aLayer );
953 }
954
963 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
964
965 bool CanFlashLayer( int aLayer )
966 {
967 return FlashLayer( aLayer, true );
968 }
969
970 PCB_LAYER_ID GetLayer() const override;
971
976
984 bool FlashLayer( const LSET& aLayers ) const;
985
986 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
987 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
988 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
989
993 bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const;
994
1002 std::vector<PCB_SHAPE*> Recombine( bool aIsDryRun, int aMaxError );
1003
1004 wxString GetClass() const override
1005 {
1006 return wxT( "PAD" );
1007 }
1008
1012 const BOX2I GetBoundingBox() const override;
1013 const BOX2I GetBoundingBox( PCB_LAYER_ID aLayer ) const;
1014
1021 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
1022
1023 void Move( const VECTOR2I& aMoveVector ) override {
1024 SetPosition( GetPosition() + aMoveVector );
1025 }
1026
1027 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
1028
1029 void OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
1030 const EDA_ANGLE& aParentRotate ) override;
1031
1032 void OnFootprintTransformed() override;
1033
1034 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1035
1036 BITMAPS GetMenuImage() const override;
1037
1041 static wxString ShowPadShape( PAD_SHAPE aShape );
1042 wxString ShowPadShape( PCB_LAYER_ID aLayer ) const;
1043
1047 wxString ShowLegacyPadShape( PCB_LAYER_ID aLayer ) const;
1048
1052 wxString ShowPadAttr() const;
1053
1054 EDA_ITEM* Clone() const override;
1055
1061 PAD* ClonePad() const
1062 {
1063 return (PAD*) Clone();
1064 }
1065
1070 void BuildEffectiveShapes() const;
1071 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
1072
1073 virtual std::vector<int> ViewGetLayers() const override;
1074
1075 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1076
1077 virtual const BOX2I ViewBBox() const override;
1078
1080
1082
1083 void SetZoneLayerOverride( PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride );
1084
1085 BACKDRILL_MODE GetBackdrillMode() const { return m_padStack.GetBackdrillMode(); }
1086 void SetBackdrillMode( BACKDRILL_MODE aMode ) { m_padStack.SetBackdrillMode( aMode ); }
1087
1088 std::optional<int> GetBottomBackdrillSize() const { return m_padStack.GetBackdrillSize( false ); }
1089 void SetBottomBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( false, aSize ); }
1090
1091 PCB_LAYER_ID GetBottomBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( false ); }
1092 void SetBottomBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( false, aLayer ); }
1093
1094 std::optional<int> GetTopBackdrillSize() const { return m_padStack.GetBackdrillSize( true ); }
1095 void SetTopBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( true, aSize ); }
1096
1097 PCB_LAYER_ID GetTopBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( true ); }
1098 void SetTopBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( true, aLayer ); }
1099
1100 double Similarity( const BOARD_ITEM& aOther ) const override;
1101
1102 bool operator==( const PAD& aOther ) const;
1103 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
1104
1105#if defined(DEBUG)
1106 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1107#endif
1108
1109protected:
1110 virtual void swapData( BOARD_ITEM* aImage ) override;
1111
1112private:
1113 const SHAPE_COMPOUND& buildEffectiveShape( PCB_LAYER_ID aLayer ) const;
1114
1115 // Scale a primitive's runtime geometry to the current footprint scale, in the pad frame.
1116 void rebakePrimitiveToFootprint( PCB_SHAPE* aPrimitive ) const;
1117
1118 // Move the chamfered-rectangle corner flags across for a mirror in the given direction.
1119 void mirrorChamferPositions( FLIP_DIRECTION aFlipDirection );
1120
1122 {
1123 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
1124 typedef std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_COMPOUND>> LAYER_SHAPE_MAP;
1125 typedef std::map<PCB_LAYER_ID, std::array<std::shared_ptr<SHAPE_POLY_SET>, 2>> LAYER_POLYGON_MAP;
1126
1129 std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
1132 };
1133
1135
1136 std::shared_ptr<SHAPE_COMPOUND> getMaskShape( PCB_LAYER_ID aLayer, int aExpansion ) const;
1137
1138private:
1139 wxString m_number; // Pad name (pin number in schematic)
1140 wxString m_pinFunction; // Pin name in schematic
1141 wxString m_pinType; // Pin electrical type in schematic
1142
1143 VECTOR2I m_libPos; // Pad position in parent footprint's library frame
1144 EDA_ORIENTATION m_libOrientation; // Pad orientation in parent footprint's library frame
1145
1147
1148 // Mutex for shape building, poly building and zone layer overrides
1149 mutable std::mutex m_dataMutex;
1150
1151 mutable std::unique_ptr<PAD_DRAW_CACHE_DATA> m_drawCache;
1152
1153 // Mask apertures, keyed by expansion because that comes from settings, not geometry
1154 mutable std::mutex m_maskShapeMutex;
1155 mutable std::map<PCB_LAYER_ID, std::pair<int, std::shared_ptr<SHAPE_COMPOUND>>> m_maskShapes;
1156
1158
1159 int m_subRatsnest; // Variable used to handle subnet (block) number in
1160 // ratsnest computations
1161
1163
1164 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
1165
1166 int m_lengthPadToDie; // Length net from pad to die, inside the package
1167 int m_delayPadToDie; // Propagation delay from pad to die
1168
1170
1171 // Bools at the end for better memory layout
1172 mutable bool m_polyDirty[2];
1173 mutable bool m_shapesDirty;
1174
1175 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> m_zoneLayerOverrides;
1176};
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:75
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
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:99
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
FOOTPRINT * GetParentFootprint() const
Implement a canvas based on a wxGLCanvas.
double AsDegrees() const
Definition eda_angle.h:115
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:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:214
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
An "orientation", held as an angle constrained to the range [0, 360) degrees.
Definition eda_angle.h:497
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:65
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:161
MODE
! Copper geometry mode: controls how many unique copper layer shapes this padstack has
Definition padstack.h:174
Definition pad.h:61
VECTOR2I GetPrimaryDrillSize() const
Definition pad.cpp:795
void SetFrontPostMachiningSize(int aSize)
Definition pad.h:458
int GetBackPostMachiningSize() const
Definition pad.h:479
void SetAnchorPadShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition pad.h:249
bool IsAperturePad() const
Definition pad.h:589
void SetAttribute(PAD_ATTRIB aAttribute)
Definition pad.cpp:1563
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1953
std::optional< bool > GetPrimaryDrillFilled() const
Definition pad.h:524
void SetBackPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:465
PAD(FOOTPRINT *parent)
Definition pad.cpp:75
virtual void swapData(BOARD_ITEM *aImage) override
Definition pad.cpp:2995
PAD_PROP GetProperty() const
Definition pad.h:585
void SetFrontPostMachiningAngle(int aAngle)
Definition pad.h:462
bool GetRemoveUnconnected() const
Definition pad.h:900
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pad.cpp:2512
void SetPrimaryDrillFilledFlag(bool aFilled)
Definition pad.cpp:926
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pad.cpp:401
double GetFrontRoundRectRadiusRatio() const
Definition pad.h:844
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2524
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition pad.cpp:1918
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition pad.h:159
int GetBackdrillOrPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Definition pad.cpp:897
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition pad.h:579
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:375
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition pad.cpp:521
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:3480
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1053
void rebakePrimitiveToFootprint(PCB_SHAPE *aPrimitive) const
Definition pad.cpp:2483
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:697
void SetLocalThermalGapOverride(const std::optional< int > &aOverride)
Definition pad.h:803
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition pad.cpp:1233
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
Definition pad.cpp:3020
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:783
bool IsDirty() const
Definition pad.h:566
std::mutex m_maskShapeMutex
Definition pad.h:1154
void SetPadstackMode(PADSTACK::MODE aMode)
Definition pad.h:190
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:2166
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1545
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1039
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition pad.h:950
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:3369
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition pad.h:622
void SetFrontPostMachiningDepth(int aDepth)
Definition pad.h:460
void SetFrontShape(PAD_SHAPE aShape)
Definition pad.cpp:1620
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1098
const wxString & GetPinType() const
Definition pad.h:160
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition pad.cpp:531
void SetSecondaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:947
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
Definition pad.cpp:919
PAD_ATTRIB GetAttribute() const
Definition pad.h:582
static LSET PTHMask()
layer set for a through hole pad
Definition pad.cpp:620
int GetDrillSizeYProp() const
Definition pad.h:324
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition pad.cpp:2448
void SetRemoveUnconnected(bool aSet)
Definition pad.h:894
const wxString & GetPinFunction() const
Definition pad.h:154
void SetThermalGap(int aGap)
Definition pad.h:794
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:538
void SetFrontPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:445
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition pad.h:775
wxString m_pinType
Definition pad.h:1141
std::optional< int > GetBottomBackdrillSize() const
Definition pad.h:1088
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pad.cpp:450
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:2781
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:307
int GetSecondaryDrillSizeX() const
Definition pad.h:537
void SetSecondaryDrillSizeX(int aX)
Definition pad.cpp:954
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool aIgnoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:3036
void SetFrontRoundRectRadiusRatio(double aRadiusScale)
Definition pad.cpp:1073
void SetPrimaryDrillSizeX(int aX)
Definition pad.cpp:805
PAD_DRAW_CACHE_DATA & getDrawCache() const
Definition pad.cpp:1264
std::mutex m_dataMutex
Definition pad.h:1149
void BuildEffectiveShapes() const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition pad.cpp:1273
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:876
void SetSimElectricalType(PAD_SIM_ELECTRICAL_TYPE aType)
Definition pad.h:594
PAD_SHAPE GetFrontShape() const
Definition pad.h:210
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:448
static bool ClassOf(const EDA_ITEM *aItem)
Definition pad.h:87
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pad.cpp:366
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition pad.h:626
PAD & operator=(const PAD &aOther)
Definition pad.cpp:347
void SetLocalThermalSpokeWidthOverride(std::optional< int > aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition pad.h:759
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
Definition pad.h:196
void SetSecondaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:986
bool IsLocked() const override
Definition pad.cpp:582
wxString ShowLegacyPadShape(PCB_LAYER_ID aLayer) const
An older version still used by place file writer.
Definition pad.cpp:2546
void SetSizeXProp(int aX)
Definition pad.cpp:307
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:2494
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pad.h:329
VECTOR2I GetPosition() const override
Definition pad.cpp:255
void SetProperty(PAD_PROP aProperty)
Definition pad.cpp:1639
void SetThermalSpokeAngleDegrees(double aAngle)
Definition pad.h:785
void SetPrimaryDrillSizeY(int aY)
Definition pad.cpp:823
EDA_ANGLE GetThermalSpokeAngle() const
Definition pad.h:779
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition pad.h:1175
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition pad.h:930
PAD_ATTRIB m_attribute
Definition pad.h:1162
void Flip(const VECTOR2I &VECTOR2I, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pad.cpp:1690
int GetDrillSizeXProp() const
Definition pad.h:322
void SetBackPostMachiningSize(int aSize)
Definition pad.h:478
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pad.h:1023
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition pad.cpp:3142
PCB_LAYER_ID GetPrincipalLayer() const
Definition pad.cpp:669
void ClearTertiaryDrillSize()
Definition pad.cpp:1025
void SetDirty()
Definition pad.h:571
PAD_DRILL_SHAPE GetTertiaryDrillShape() const
Definition pad.h:559
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:564
int GetSizeXProp() const
Definition pad.cpp:321
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:641
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.h:301
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1092
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pad.cpp:2670
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1032
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.cpp:848
double GetOrientationDegrees() const
Definition pad.h:432
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:1086
VECTOR2I GetDrillSize() const
Definition pad.h:320
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pad.cpp:2459
int GetBackPostMachiningAngle() const
Definition pad.h:483
PADSTACK m_padStack
Definition pad.h:1146
void SetPadToDieDelay(int aDelay)
Definition pad.h:602
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:1733
VECTOR2I m_libPos
Definition pad.h:1143
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pad.h:562
void mirrorChamferPositions(FLIP_DIRECTION aFlipDirection)
Definition pad.cpp:1786
bool IsNoConnectPad() const
Definition pad.cpp:608
PCB_LAYER_ID GetPrimaryDrillStartLayer() const
Definition pad.h:441
PAD_PROP m_property
Definition pad.h:1164
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:837
int GetFrontPostMachiningSize() const
Definition pad.h:459
void SetKeepTopBottom(bool aSet)
Definition pad.h:909
void SetTertiaryDrillSizeX(int aX)
Definition pad.cpp:1007
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
Definition pad.cpp:3461
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition pad.cpp:1751
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition pad.h:920
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:205
PADSTACK & Padstack()
Definition pad.h:332
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:1085
void SetTertiaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1000
int GetTertiaryDrillSizeY() const
Definition pad.h:556
void SetFrontRoundRectRadiusSize(int aRadius)
Definition pad.cpp:1083
wxString ShowPadAttr() const
Definition pad.cpp:2562
wxString m_pinFunction
Definition pad.h:1140
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:993
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
Definition pad.cpp:3436
int GetFrontPostMachiningDepth() const
Definition pad.h:461
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.h:437
int m_effectiveBoundingRadius
Definition pad.h:1157
PADSTACK::MODE GetPadstackMode() const
Definition pad.h:191
void SetDrillSizeXProp(int aX)
Definition pad.cpp:817
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pad.h:609
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:468
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:837
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:237
bool GetKeepTopBottom() const
Definition pad.h:915
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition pad.h:632
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition pad.cpp:1103
void SetPrimaryDrillCappedFlag(bool aCapped)
Definition pad.cpp:940
bool GetPrimaryDrillFilledFlag() const
Definition pad.h:525
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1960
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:297
int GetPadToDieDelay() const
Definition pad.h:603
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:605
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition pad.cpp:2921
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:3345
std::unique_ptr< PAD_DRAW_CACHE_DATA > m_drawCache
Definition pad.h:1151
bool IsOnCopperLayer() const override
Definition pad.cpp:1862
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1046
void SetPadstack(const PADSTACK &aPadstack)
Definition pad.h:333
void SetPosition(const VECTOR2I &aPos) override
Definition pad.cpp:244
const SHAPE_COMPOUND & buildEffectiveShape(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1334
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:857
const PADSTACK & Padstack() const
Definition pad.h:331
PAD_DRILL_SHAPE GetSecondaryDrillShape() const
Definition pad.h:542
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1489
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition pad.cpp:634
void SetDrillSize(const VECTOR2I &aSize)
Definition pad.h:319
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
Definition pad.h:473
bool IsFreePad() const
Definition pad.cpp:614
int GetFrontPostMachiningAngle() const
Definition pad.h:463
void SetLibOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:290
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
Definition pad.h:453
wxString GetClass() const override
Return the class name.
Definition pad.h:1004
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetFrontPostMachining() const
Definition pad.h:446
bool IsNPTHWithNoCopper() const
Definition pad.cpp:552
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:533
bool CanFlashLayer(int aLayer)
Definition pad.h:965
void SetLibSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:276
int m_subRatsnest
Definition pad.h:1159
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1672
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:264
int m_delayPadToDie
Definition pad.h:1167
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:438
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:979
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:3408
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:878
void SetY(int y)
Definition pad.h:262
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:648
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetBackPostMachining() const
Definition pad.h:466
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pad.cpp:2881
UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition pad.h:925
VECTOR2I GetLibraryPosition() const
Definition pad.h:214
bool m_shapesDirty
Definition pad.h:1173
void SetRoundRectCornerRadius(PCB_LAYER_ID aLayer, double aRadius)
Definition pad.cpp:1059
void SetDrillSizeYProp(int aY)
Definition pad.cpp:831
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:627
std::optional< int > GetLocalSolderPasteMargin() const
Definition pad.h:615
int GetFrontRoundRectRadiusSize() const
Definition pad.cpp:1093
int GetTertiaryDrillSizeX() const
Definition pad.h:554
static void SwapShapePositions(PAD *aLhs, PAD *aRhs, PCB_LAYER_ID aActiveLayer)
Swap the visible shape positions of two pads, preserving each pad's own shape offset.
Definition pad.cpp:1839
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1111
void SetX(int x)
Definition pad.h:269
void SetChamferPositions(PCB_LAYER_ID aLayer, int aPositions)
Has meaning only for chamfered rectangular pads.
Definition pad.h:873
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pad.cpp:1124
int GetBackPostMachiningDepth() const
Definition pad.h:481
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
Definition pad.h:595
std::optional< int > GetLocalSolderMaskMargin() const
Definition pad.h:608
PAD_SIM_ELECTRICAL_TYPE m_simElectricalType
Definition pad.h:1169
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition pad.h:616
std::optional< int > GetLocalThermalGapOverride() const
Definition pad.h:799
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pad.cpp:663
void GetPrimitiveLibScale(double &aScaleX, double &aScaleY) const
Definition pad.cpp:2469
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pad.cpp:2576
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:153
EDA_ANGLE GetFPRelativeOrientation() const
Definition pad.cpp:1684
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:860
bool m_polyDirty[2]
Definition pad.h:1172
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:2341
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition pad.cpp:1659
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:1255
std::optional< int > GetTopBackdrillSize() const
Definition pad.h:1094
void ClearZoneLayerOverrides()
Definition pad.cpp:512
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition pad.cpp:1647
int GetPrimaryDrillSizeY() const
Definition pad.h:317
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:763
PAD_DRILL_SHAPE GetPrimaryDrillShape() const
Definition pad.h:435
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
Definition pad.cpp:883
bool HasCopperRemoved(PCB_LAYER_ID aLayer) const
Check whether backdrilling or post-machining left no copper at all on a layer.
Definition pad.cpp:889
void SetSizeYProp(int aY)
Definition pad.cpp:327
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:2022
void SetTopBackdrillSize(std::optional< int > aSize)
Definition pad.h:1095
std::optional< bool > GetPrimaryDrillCapped() const
Definition pad.h:529
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pad.cpp:2664
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:3421
int GetPrimaryDrillSizeX() const
Definition pad.h:315
wxString m_number
Definition pad.h:1139
std::map< PCB_LAYER_ID, std::pair< int, std::shared_ptr< SHAPE_COMPOUND > > > m_maskShapes
Definition pad.h:1155
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:869
void SetBackPostMachiningDepth(int aDepth)
Definition pad.h:480
bool HasDrilledHole() const override
Definition pad.h:118
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
Definition pad.cpp:933
void SetLibDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:283
PCB_LAYER_ID GetPrimaryDrillEndLayer() const
Definition pad.h:443
PCB_LAYER_ID GetBottomBackdrillLayer() const
Definition pad.h:1091
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Definition pad.h:285
void SetLocalClearance(std::optional< int > aClearance)
Definition pad.h:606
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pad.h:545
int GetSubRatsnest() const
Definition pad.h:886
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:550
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:633
void SetTertiaryDrillSizeY(int aY)
Definition pad.cpp:1018
int m_lengthPadToDie
Definition pad.h:1166
bool HasHole() const override
Definition pad.h:113
int GetSizeYProp() const
Definition pad.cpp:341
double GetThermalSpokeAngleDegrees() const
Definition pad.h:789
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition pad.h:1061
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition pad.h:227
int GetThermalGap() const
Definition pad.h:795
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1825
int GetSecondaryDrillSizeY() const
Definition pad.h:539
void SetSecondaryDrillSizeY(int aY)
Definition pad.cpp:965
PCB_LAYER_ID GetTopBackdrillLayer() const
Definition pad.h:1097
EDA_ORIENTATION m_libOrientation
Definition pad.h:1144
void SetOrientationDegrees(double aOrientation)
Definition pad.h:428
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition pad.cpp:2128
void SetLayerSet(const LSET &aLayers) override
Definition pad.cpp:1930
bool SharesNetTieGroup(const PAD *aOther) const
Definition pad.cpp:591
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
Definition pad.h:219
void SetBottomBackdrillSize(std::optional< int > aSize)
Definition pad.h:1089
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1065
void ClearSecondaryDrillSize()
Definition pad.cpp:972
bool GetPrimaryDrillCappedFlag() const
Definition pad.h:530
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:547
void SetSubRatsnest(int aSubRatsnest)
Definition pad.h:887
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition pad.cpp:2148
std::shared_ptr< SHAPE_COMPOUND > getMaskShape(PCB_LAYER_ID aLayer, int aExpansion) const
Definition pad.cpp:1207
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:3003
void SetPadToDieLength(int aLength)
Definition pad.h:599
bool IsFlipped() const
Definition pad.cpp:655
bool operator==(const PAD &aOther) const
Definition pad.cpp:3327
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:600
void SetBackPostMachiningAngle(int aAngle)
Definition pad.h:482
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pad.cpp:2686
Definition seg.h:38
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
@ NULL_CONSTRAINT
@ DEGREES_T
Definition eda_angle.h:30
@ NONE
Definition eda_fill.h:42
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:26
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
PAD_SIM_ELECTRICAL_TYPE
The electrical type of a pad.
Definition pad.h:53
PAD_DRILL_POST_MACHINING_MODE
Definition padstack.h:77
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:70
CUSTOM_SHAPE_ZONE_MODE
Definition padstack.h:141
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition padstack.h:98
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:104
@ PTH
Plated through hole pad.
Definition padstack.h:99
BACKDRILL_MODE
Definition padstack.h:85
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:53
@ RECTANGLE
Definition padstack.h:55
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition padstack.h:118
UNCONNECTED_LAYER_MODE
Definition padstack.h:132
std::map< PCB_LAYER_ID, std::array< std::shared_ptr< SHAPE_POLY_SET >, 2 > > LAYER_POLYGON_MAP
Definition pad.h:1125
LAYER_POLYGON_MAP m_effectivePolygons
Definition pad.h:1130
LAYER_SHAPE_MAP m_effectiveShapes
Definition pad.h:1128
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition pad.h:1129
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_COMPOUND > > LAYER_SHAPE_MAP
Definition pad.h:1124
BOX2I m_effectiveBoundingBox
Definition pad.h:1127
double m_lastGalZoomLevel
Definition pad.h:1131
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_LOCATE_NPTH_T
Definition typeinfo.h:125
@ PCB_LOCATE_PTH_T
Definition typeinfo.h:124
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_LOCATE_HOLE_T
Definition typeinfo.h:123
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43