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
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 SetSizeX( int aX );
296 int GetSizeX() const;
297
298 void SetSizeY( int aY );
299 int GetSizeY() 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 SetDrillSizeX( int aX );
322 int GetDrillSizeX() const { return GetPrimaryDrillSizeX(); }
323 void SetDrillSizeY( int aY );
324 int GetDrillSizeY() 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
386 void FlipPrimitives( FLIP_DIRECTION aFlipDirection );
387
392 void ReplacePrimitives( PCB_LAYER_ID aLayer,
393 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
394
399 void AppendPrimitives( PCB_LAYER_ID aLayer,
400 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
401
405 void AddPrimitive( PCB_LAYER_ID aLayer, PCB_SHAPE* aPrimitive );
406
412 void SetOrientation( const EDA_ANGLE& aAngle );
413 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
414
420
421 void GetPrimitiveLibScale( double& aScaleX, double& aScaleY ) const;
422
423 // For property system
424 void SetOrientationDegrees( double aOrientation )
425 {
426 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
427 }
428 double GetOrientationDegrees() const { return GetOrientation().AsDegrees(); }
429
431 PAD_DRILL_SHAPE GetPrimaryDrillShape() const { return m_padStack.Drill().shape; }
432
435
437 PCB_LAYER_ID GetPrimaryDrillStartLayer() const { return m_padStack.Drill().start; }
439 PCB_LAYER_ID GetPrimaryDrillEndLayer() const { return m_padStack.Drill().end; }
440
441 void SetFrontPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.FrontPostMachining().mode = aMode; }
442 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetFrontPostMachining() const { return m_padStack.FrontPostMachining().mode; }
443
445 {
446 m_padStack.FrontPostMachining().mode = aMode;
447 }
448
453
454 void SetFrontPostMachiningSize( int aSize ) { m_padStack.FrontPostMachining().size = aSize; }
455 int GetFrontPostMachiningSize() const { return m_padStack.FrontPostMachining().size; }
456 void SetFrontPostMachiningDepth( int aDepth ) { m_padStack.FrontPostMachining().depth = aDepth; }
457 int GetFrontPostMachiningDepth() const { return m_padStack.FrontPostMachining().depth; }
458 void SetFrontPostMachiningAngle( int aAngle ) { m_padStack.FrontPostMachining().angle = aAngle; }
459 int GetFrontPostMachiningAngle() const { return m_padStack.FrontPostMachining().angle; }
460
461 void SetBackPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.BackPostMachining().mode = aMode; }
462 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetBackPostMachining() const { return m_padStack.BackPostMachining().mode; }
463
465 {
466 m_padStack.BackPostMachining().mode = aMode;
467 }
468
473
474 void SetBackPostMachiningSize( int aSize ) { m_padStack.BackPostMachining().size = aSize; }
475 int GetBackPostMachiningSize() const { return m_padStack.BackPostMachining().size; }
476 void SetBackPostMachiningDepth( int aDepth ) { m_padStack.BackPostMachining().depth = aDepth; }
477 int GetBackPostMachiningDepth() const { return m_padStack.BackPostMachining().depth; }
478 void SetBackPostMachiningAngle( int aAngle ) { m_padStack.BackPostMachining().angle = aAngle; }
479 int GetBackPostMachiningAngle() const { return m_padStack.BackPostMachining().angle; }
480
490 bool IsBackdrilledOrPostMachined( PCB_LAYER_ID aLayer ) const;
491
498 int GetPostMachiningKnockout( PCB_LAYER_ID aLayer ) const;
499
500 void SetPrimaryDrillFilled( const std::optional<bool>& aFilled );
501 void SetPrimaryDrillFilledFlag( bool aFilled );
502 std::optional<bool> GetPrimaryDrillFilled() const { return m_padStack.Drill().is_filled; }
503 bool GetPrimaryDrillFilledFlag() const { return m_padStack.Drill().is_filled.value_or( false ); }
504
505 void SetPrimaryDrillCapped( const std::optional<bool>& aCapped );
506 void SetPrimaryDrillCappedFlag( bool aCapped );
507 std::optional<bool> GetPrimaryDrillCapped() const { return m_padStack.Drill().is_capped; }
508 bool GetPrimaryDrillCappedFlag() const { return m_padStack.Drill().is_capped.value_or( false ); }
509
510 void SetSecondaryDrillSize( const VECTOR2I& aSize );
511 const VECTOR2I& GetSecondaryDrillSize() const { return m_padStack.SecondaryDrill().size; }
513
514 void SetSecondaryDrillSizeX( int aX );
515 int GetSecondaryDrillSizeX() const { return m_padStack.SecondaryDrill().size.x; }
516 void SetSecondaryDrillSizeY( int aY );
517 int GetSecondaryDrillSizeY() const { return m_padStack.SecondaryDrill().size.y; }
518
520 PAD_DRILL_SHAPE GetSecondaryDrillShape() const { return m_padStack.SecondaryDrill().shape; }
521
523 PCB_LAYER_ID GetSecondaryDrillStartLayer() const { return m_padStack.SecondaryDrill().start; }
525 PCB_LAYER_ID GetSecondaryDrillEndLayer() const { return m_padStack.SecondaryDrill().end; }
526
527 void SetTertiaryDrillSize( const VECTOR2I& aSize );
528 const VECTOR2I& GetTertiaryDrillSize() const { return m_padStack.TertiaryDrill().size; }
530
531 void SetTertiaryDrillSizeX( int aX );
532 int GetTertiaryDrillSizeX() const { return m_padStack.TertiaryDrill().size.x; }
533 void SetTertiaryDrillSizeY( int aY );
534 int GetTertiaryDrillSizeY() const { return m_padStack.TertiaryDrill().size.y; }
535
537 PAD_DRILL_SHAPE GetTertiaryDrillShape() const { return m_padStack.TertiaryDrill().shape; }
538
540 PCB_LAYER_ID GetTertiaryDrillStartLayer() const { return m_padStack.TertiaryDrill().start; }
542 PCB_LAYER_ID GetTertiaryDrillEndLayer() const { return m_padStack.TertiaryDrill().end; }
543
544 bool IsDirty() const
545 {
547 }
548
549 void SetDirty()
550 {
551 m_shapesDirty = true;
554 }
555
556 void SetLayerSet( const LSET& aLayers ) override;
557 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
558
559 void SetAttribute( PAD_ATTRIB aAttribute );
561
562 void SetProperty( PAD_PROP aProperty );
563 PAD_PROP GetProperty() const { return m_property; }
564
565 // We don't currently have an attribute for APERTURE, and adding one will change the file
566 // format, so for now just infer a copper-less pad to be an APERTURE pad.
567 bool IsAperturePad() const
568 {
569 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
570 }
571
574
575 bool IsNPTHWithNoCopper() const;
576
577 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
578 int GetPadToDieLength() const { return m_lengthPadToDie; }
579
580 void SetPadToDieDelay( int aDelay ) { m_delayPadToDie = aDelay; }
581 int GetPadToDieDelay() const { return m_delayPadToDie; }
582
583 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
584 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
585
586 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
587 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
588 {
589 m_padStack.SolderMaskMargin( F_Mask ) = aMargin;
590 m_padStack.SolderMaskMargin( B_Mask ) = aMargin;
591 }
592
593 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
594 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
595 {
596 m_padStack.SolderPasteMargin( F_Paste ) = aMargin;
597 m_padStack.SolderPasteMargin( B_Paste ) = aMargin;
598 }
599
600 std::optional<double> GetLocalSolderPasteMarginRatio() const
601 {
602 return m_padStack.SolderPasteMarginRatio();
603 }
604 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
605 {
606 m_padStack.SolderPasteMarginRatio( F_Paste ) = aRatio;
607 m_padStack.SolderPasteMarginRatio( B_Paste ) = aRatio;
608 }
609
610 void SetLocalZoneConnection( ZONE_CONNECTION aType ) { m_padStack.ZoneConnection() = aType; }
612 {
613 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
614 }
615
623 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
624
625 double GetCoverageArea( int aTextMargin ) const override;
626
637 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
638 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
639 bool aIgnoreLineWidth = false ) const override;
640
650 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
651 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
652
670 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
672 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
673
674 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( PCB_LAYER_ID aLayer,
675 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
676
680 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
681 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
682
688 int GetBoundingRadius() const;
689
696 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
697
704 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
705
716 int GetSolderMaskExpansion( PCB_LAYER_ID aLayer ) const;
717
730
731 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
732
737 void SetLocalThermalSpokeWidthOverride( std::optional<int> aWidth )
738 {
739 m_padStack.ThermalSpokeWidth() = aWidth;
740 }
741 std::optional<int> GetLocalThermalSpokeWidthOverride() const
742 {
743 return m_padStack.ThermalSpokeWidth();
744 }
745
746 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
747
753 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
754 {
755 m_padStack.SetThermalSpokeAngle( aAngle );
756 }
758 {
759 return m_padStack.ThermalSpokeAngle();
760 }
761
762 // For property system
763 void SetThermalSpokeAngleDegrees( double aAngle )
764 {
765 m_padStack.SetThermalSpokeAngle( EDA_ANGLE( aAngle, DEGREES_T ) );
766 }
768 {
769 return m_padStack.ThermalSpokeAngle().AsDegrees();
770 }
771
772 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
773 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
774
775 int GetLocalThermalGapOverride( wxString* aSource ) const;
776
777 std::optional<int> GetLocalThermalGapOverride() const
778 {
779 return m_padStack.ThermalGap();
780 }
781 void SetLocalThermalGapOverride( const std::optional<int>& aOverride )
782 {
783 m_padStack.ThermalGap() = aOverride;
784 }
785
786 void SetRoundRectCornerRadius( PCB_LAYER_ID aLayer, double aRadius );
787
791 int GetRoundRectCornerRadius( PCB_LAYER_ID aLayer ) const;
792
793 VECTOR2I ShapePos( PCB_LAYER_ID aLayer ) const;
794
802 static void SwapShapePositions( PAD* aLhs, PAD* aRhs );
803
810 void SetRoundRectRadiusRatio( PCB_LAYER_ID aLayer, double aRadiusScale );
812 {
813 return m_padStack.RoundRectRadiusRatio( aLayer );
814 }
815
816 // For properties panel, which only supports normal padstacks
817 void SetFrontRoundRectRadiusRatio( double aRadiusScale );
819 {
820 return m_padStack.RoundRectRadiusRatio( F_Cu );
821 }
822
823 // For properties panel, which only supports normal padstacks
824 void SetFrontRoundRectRadiusSize( int aRadius );
825 int GetFrontRoundRectRadiusSize() const;
826
833 void SetChamferRectRatio( PCB_LAYER_ID aLayer, double aChamferScale );
834 double GetChamferRectRatio( PCB_LAYER_ID aLayer ) const
835 {
836 return m_padStack.ChamferRatio( aLayer );
837 }
838
847 void SetChamferPositions( PCB_LAYER_ID aLayer, int aPositions )
848 {
849 m_padStack.SetChamferPositions( aPositions, aLayer );
850 }
851
853 {
854 return m_padStack.ChamferPositions( aLayer );
855 }
856
860 int GetSubRatsnest() const { return m_subRatsnest; }
861 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
862
868 void SetRemoveUnconnected( bool aSet )
869 {
870 m_padStack.SetUnconnectedLayerMode( aSet ? UNCONNECTED_LAYER_MODE::REMOVE_ALL
872 }
873
875 {
876 return m_padStack.UnconnectedLayerMode() != UNCONNECTED_LAYER_MODE::KEEP_ALL;
877 }
878
883 void SetKeepTopBottom( bool aSet )
884 {
887 }
888
889 bool GetKeepTopBottom() const
890 {
892 }
893
895 {
896 m_padStack.SetUnconnectedLayerMode( aMode );
897 }
898
900 {
901 return m_padStack.UnconnectedLayerMode();
902 }
903
905 {
906 switch( m_padStack.UnconnectedLayerMode() )
907 {
909 return false;
910
912 return true;
913
916 return aLayer != m_padStack.Drill().start && aLayer != m_padStack.Drill().end;
917 }
918
919 return true;
920 }
921
922 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
923
924 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
925 {
926 return m_padStack.LayerSet().test( aLayer );
927 }
928
937 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
938
939 bool CanFlashLayer( int aLayer )
940 {
941 return FlashLayer( aLayer, true );
942 }
943
944 PCB_LAYER_ID GetLayer() const override;
945
950
958 bool FlashLayer( const LSET& aLayers ) const;
959
960 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
961 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
962 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
963
967 bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const;
968
976 std::vector<PCB_SHAPE*> Recombine( bool aIsDryRun, int aMaxError );
977
978 wxString GetClass() const override
979 {
980 return wxT( "PAD" );
981 }
982
986 const BOX2I GetBoundingBox() const override;
987 const BOX2I GetBoundingBox( PCB_LAYER_ID aLayer ) const;
988
995 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
996
997 void Move( const VECTOR2I& aMoveVector ) override {
998 SetPosition( GetPosition() + aMoveVector );
999 }
1000
1001 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
1002
1003 void OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
1004 const EDA_ANGLE& aParentRotate ) override;
1005
1006 void OnFootprintTransformed() override;
1007
1008 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1009
1010 BITMAPS GetMenuImage() const override;
1011
1015 static wxString ShowPadShape( PAD_SHAPE aShape );
1016 wxString ShowPadShape( PCB_LAYER_ID aLayer ) const;
1017
1021 wxString ShowLegacyPadShape( PCB_LAYER_ID aLayer ) const;
1022
1026 wxString ShowPadAttr() const;
1027
1028 EDA_ITEM* Clone() const override;
1029
1035 PAD* ClonePad() const
1036 {
1037 return (PAD*) Clone();
1038 }
1039
1044 void BuildEffectiveShapes() const;
1045 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
1046
1047 virtual std::vector<int> ViewGetLayers() const override;
1048
1049 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1050
1051 virtual const BOX2I ViewBBox() const override;
1052
1054
1056
1057 void SetZoneLayerOverride( PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride );
1058
1059 void CheckPad( UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1060 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1061
1062 BACKDRILL_MODE GetBackdrillMode() const { return m_padStack.GetBackdrillMode(); }
1063 void SetBackdrillMode( BACKDRILL_MODE aMode ) { m_padStack.SetBackdrillMode( aMode ); }
1064
1065 std::optional<int> GetBottomBackdrillSize() const { return m_padStack.GetBackdrillSize( false ); }
1066 void SetBottomBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( false, aSize ); }
1067
1068 PCB_LAYER_ID GetBottomBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( false ); }
1069 void SetBottomBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( false, aLayer ); }
1070
1071 std::optional<int> GetTopBackdrillSize() const { return m_padStack.GetBackdrillSize( true ); }
1072 void SetTopBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( true, aSize ); }
1073
1074 PCB_LAYER_ID GetTopBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( true ); }
1075 void SetTopBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( true, aLayer ); }
1076
1077 double Similarity( const BOARD_ITEM& aOther ) const override;
1078
1079 bool operator==( const PAD& aOther ) const;
1080 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
1081
1082#if defined(DEBUG)
1083 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1084#endif
1085
1086protected:
1087 virtual void swapData( BOARD_ITEM* aImage ) override;
1088
1089private:
1090 const SHAPE_COMPOUND& buildEffectiveShape( PCB_LAYER_ID aLayer ) const;
1091
1092 // Scale a primitive's runtime geometry to the current footprint scale, in the pad frame.
1093 void rebakePrimitiveToFootprint( PCB_SHAPE* aPrimitive ) const;
1094
1096 {
1097 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
1098 typedef std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_COMPOUND>> LAYER_SHAPE_MAP;
1099 typedef std::map<PCB_LAYER_ID, std::array<std::shared_ptr<SHAPE_POLY_SET>, 2>> LAYER_POLYGON_MAP;
1100
1103 std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
1106 };
1107
1109
1110 void doCheckPad( PCB_LAYER_ID aLayer, UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1111 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1112
1113private:
1114 wxString m_number; // Pad name (pin number in schematic)
1115 wxString m_pinFunction; // Pin name in schematic
1116 wxString m_pinType; // Pin electrical type in schematic
1117
1118 VECTOR2I m_libPos; // Pad position in parent footprint's library frame
1119 EDA_ORIENTATION m_libOrientation; // Pad orientation in parent footprint's library frame
1120
1122
1123 // Mutex for shape building, poly building and zone layer overrides
1124 mutable std::mutex m_dataMutex;
1125
1126 mutable std::unique_ptr<PAD_DRAW_CACHE_DATA> m_drawCache;
1127
1129
1130 int m_subRatsnest; // Variable used to handle subnet (block) number in
1131 // ratsnest computations
1132
1134
1135 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
1136
1137 int m_lengthPadToDie; // Length net from pad to die, inside the package
1138 int m_delayPadToDie; // Propagation delay from pad to die
1139
1141
1142 // Bools at the end for better memory layout
1143 mutable bool m_polyDirty[2];
1144 mutable bool m_shapesDirty;
1145
1146 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> m_zoneLayerOverrides;
1147};
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:72
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
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:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
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:473
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: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:156
MODE
! Copper geometry mode: controls how many unique copper layer shapes this padstack has
Definition padstack.h:169
Definition pad.h:61
VECTOR2I GetPrimaryDrillSize() const
Definition pad.cpp:785
void SetFrontPostMachiningSize(int aSize)
Definition pad.h:454
int GetBackPostMachiningSize() const
Definition pad.h:475
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:567
void SetAttribute(PAD_ATTRIB aAttribute)
Definition pad.cpp:1651
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1991
void CheckPad(UNITS_PROVIDER *aUnitsProvider, bool aForPadProperties, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition pad.cpp:3323
std::optional< bool > GetPrimaryDrillFilled() const
Definition pad.h:502
void SetBackPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:461
PAD(FOOTPRINT *parent)
Definition pad.cpp:76
virtual void swapData(BOARD_ITEM *aImage) override
Definition pad.cpp:3005
PAD_PROP GetProperty() const
Definition pad.h:563
void SetFrontPostMachiningAngle(int aAngle)
Definition pad.h:458
bool GetRemoveUnconnected() const
Definition pad.h:874
void SetSizeY(int aY)
Definition pad.cpp:328
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pad.cpp:2547
void SetPrimaryDrillFilledFlag(bool aFilled)
Definition pad.cpp:1055
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pad.cpp:402
double GetFrontRoundRectRadiusRatio() const
Definition pad.h:818
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:3438
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2559
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition pad.cpp:1956
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:557
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:517
int GetSizeX() const
Definition pad.cpp:322
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:3751
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1182
void rebakePrimitiveToFootprint(PCB_SHAPE *aPrimitive) const
Definition pad.cpp:2518
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:687
void SetLocalThermalGapOverride(const std::optional< int > &aOverride)
Definition pad.h:781
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:1328
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:3030
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:773
bool IsDirty() const
Definition pad.h:544
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:2205
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1635
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1168
void SetSizeX(int aX)
Definition pad.cpp:308
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition pad.h:924
int GetDrillSizeY() const
Definition pad.h:324
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:3645
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition pad.h:600
void SetFrontPostMachiningDepth(int aDepth)
Definition pad.h:456
void SetFrontShape(PAD_SHAPE aShape)
Definition pad.cpp:1705
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1075
const wxString & GetPinType() const
Definition pad.h:160
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition pad.cpp:527
void SetSecondaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1076
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
Definition pad.cpp:1048
PAD_ATTRIB GetAttribute() const
Definition pad.h:560
static LSET PTHMask()
layer set for a through hole pad
Definition pad.cpp:616
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition pad.cpp:2483
void SetRemoveUnconnected(bool aSet)
Definition pad.h:868
const wxString & GetPinFunction() const
Definition pad.h:154
void SetThermalGap(int aGap)
Definition pad.h:772
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:534
void SetFrontPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:441
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition pad.h:753
wxString m_pinType
Definition pad.h:1116
std::optional< int > GetBottomBackdrillSize() const
Definition pad.h:1065
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pad.cpp:449
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:2811
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:307
int GetSecondaryDrillSizeX() const
Definition pad.h:515
void SetSecondaryDrillSizeX(int aX)
Definition pad.cpp:1083
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:3046
void SetFrontRoundRectRadiusRatio(double aRadiusScale)
Definition pad.cpp:1202
void SetPrimaryDrillSizeX(int aX)
Definition pad.cpp:795
PAD_DRAW_CACHE_DATA & getDrawCache() const
Definition pad.cpp:1359
std::mutex m_dataMutex
Definition pad.h:1124
void BuildEffectiveShapes() const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition pad.cpp:1368
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:866
void SetSimElectricalType(PAD_SIM_ELECTRICAL_TYPE aType)
Definition pad.h:572
PAD_SHAPE GetFrontShape() const
Definition pad.h:210
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:444
static bool ClassOf(const EDA_ITEM *aItem)
Definition pad.h:87
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pad.cpp:367
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition pad.h:604
PAD & operator=(const PAD &aOther)
Definition pad.cpp:348
void SetLocalThermalSpokeWidthOverride(std::optional< int > aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition pad.h:737
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:1115
bool IsLocked() const override
Definition pad.cpp:578
wxString ShowLegacyPadShape(PCB_LAYER_ID aLayer) const
An older version still used by place file writer.
Definition pad.cpp:2581
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:2529
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:256
void SetProperty(PAD_PROP aProperty)
Definition pad.cpp:1724
void SetThermalSpokeAngleDegrees(double aAngle)
Definition pad.h:763
void SetPrimaryDrillSizeY(int aY)
Definition pad.cpp:813
EDA_ANGLE GetThermalSpokeAngle() const
Definition pad.h:757
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition pad.h:1146
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition pad.h:904
PAD_ATTRIB m_attribute
Definition pad.h:1133
void Flip(const VECTOR2I &VECTOR2I, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pad.cpp:1775
void SetBackPostMachiningSize(int aSize)
Definition pad.h:474
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pad.h:997
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition pad.cpp:3152
PCB_LAYER_ID GetPrincipalLayer() const
Definition pad.cpp:665
void ClearTertiaryDrillSize()
Definition pad.cpp:1154
void SetDirty()
Definition pad.h:549
PAD_DRILL_SHAPE GetTertiaryDrillShape() const
Definition pad.h:537
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:542
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:637
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.h:301
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1069
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pad.cpp:2700
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1161
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.cpp:838
double GetOrientationDegrees() const
Definition pad.h:428
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:1063
VECTOR2I GetDrillSize() const
Definition pad.h:320
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pad.cpp:2494
int GetBackPostMachiningAngle() const
Definition pad.h:479
PADSTACK m_padStack
Definition pad.h:1121
void SetPadToDieDelay(int aDelay)
Definition pad.h:580
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:1850
VECTOR2I m_libPos
Definition pad.h:1118
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pad.h:540
bool IsNoConnectPad() const
Definition pad.cpp:604
int GetDrillSizeX() const
Definition pad.h:322
PCB_LAYER_ID GetPrimaryDrillStartLayer() const
Definition pad.h:437
PAD_PROP m_property
Definition pad.h:1135
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:811
int GetFrontPostMachiningSize() const
Definition pad.h:455
void SetKeepTopBottom(bool aSet)
Definition pad.h:883
void SetTertiaryDrillSizeX(int aX)
Definition pad.cpp:1136
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
Definition pad.cpp:3732
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition pad.h:894
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:1062
void SetTertiaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1129
int GetTertiaryDrillSizeY() const
Definition pad.h:534
void SetFrontRoundRectRadiusSize(int aRadius)
Definition pad.cpp:1212
wxString ShowPadAttr() const
Definition pad.cpp:2597
wxString m_pinFunction
Definition pad.h:1115
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1122
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
Definition pad.cpp:3707
int GetFrontPostMachiningDepth() const
Definition pad.h:457
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.h:433
int m_effectiveBoundingRadius
Definition pad.h:1128
PADSTACK::MODE GetPadstackMode() const
Definition pad.h:191
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pad.h:587
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:464
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:827
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:889
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition pad.h:610
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition pad.cpp:1232
void SetPrimaryDrillCappedFlag(bool aCapped)
Definition pad.cpp:1069
bool GetPrimaryDrillFilledFlag() const
Definition pad.h:503
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1998
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:298
int GetPadToDieDelay() const
Definition pad.h:581
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:583
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition pad.cpp:2932
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:3621
std::unique_ptr< PAD_DRAW_CACHE_DATA > m_drawCache
Definition pad.h:1126
bool IsOnCopperLayer() const override
Definition pad.cpp:1900
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1175
void SetPadstack(const PADSTACK &aPadstack)
Definition pad.h:333
void SetPosition(const VECTOR2I &aPos) override
Definition pad.cpp:245
const SHAPE_COMPOUND & buildEffectiveShape(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1424
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:847
const PADSTACK & Padstack() const
Definition pad.h:331
PAD_DRILL_SHAPE GetSecondaryDrillShape() const
Definition pad.h:520
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1579
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition pad.cpp:630
void SetDrillSize(const VECTOR2I &aSize)
Definition pad.h:319
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
Definition pad.h:469
bool IsFreePad() const
Definition pad.cpp:610
int GetFrontPostMachiningAngle() const
Definition pad.h:459
void SetLibOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:291
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
Definition pad.h:449
wxString GetClass() const override
Return the class name.
Definition pad.h:978
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetFrontPostMachining() const
Definition pad.h:442
bool IsNPTHWithNoCopper() const
Definition pad.cpp:548
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:511
bool CanFlashLayer(int aLayer)
Definition pad.h:939
void SetLibSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:277
int m_subRatsnest
Definition pad.h:1130
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1757
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:265
int m_delayPadToDie
Definition pad.h:1138
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:434
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1108
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:3684
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:852
void SetY(int y)
Definition pad.h:262
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:644
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetBackPostMachining() const
Definition pad.h:462
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pad.cpp:2892
UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition pad.h:899
VECTOR2I GetLibraryPosition() const
Definition pad.h:214
bool m_shapesDirty
Definition pad.h:1144
void SetRoundRectCornerRadius(PCB_LAYER_ID aLayer, double aRadius)
Definition pad.cpp:1188
void SetDrillSizeY(int aY)
Definition pad.cpp:821
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:623
std::optional< int > GetLocalSolderPasteMargin() const
Definition pad.h:593
int GetFrontRoundRectRadiusSize() const
Definition pad.cpp:1222
int GetTertiaryDrillSizeX() const
Definition pad.h:532
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1240
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:847
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:1253
int GetBackPostMachiningDepth() const
Definition pad.h:477
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
Definition pad.h:573
std::optional< int > GetLocalSolderMaskMargin() const
Definition pad.h:586
void SetDrillSizeX(int aX)
Definition pad.cpp:807
PAD_SIM_ELECTRICAL_TYPE m_simElectricalType
Definition pad.h:1140
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition pad.h:594
int GetSizeY() const
Definition pad.cpp:342
std::optional< int > GetLocalThermalGapOverride() const
Definition pad.h:777
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pad.cpp:659
void GetPrimitiveLibScale(double &aScaleX, double &aScaleY) const
Definition pad.cpp:2504
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pad.cpp:2610
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:153
EDA_ANGLE GetFPRelativeOrientation() const
Definition pad.cpp:1769
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:834
bool m_polyDirty[2]
Definition pad.h:1143
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:2376
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition pad.cpp:1744
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:956
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition pad.cpp:1350
std::optional< int > GetTopBackdrillSize() const
Definition pad.h:1071
void ClearZoneLayerOverrides()
Definition pad.cpp:508
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition pad.cpp:1732
int GetPrimaryDrillSizeY() const
Definition pad.h:317
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:741
PAD_DRILL_SHAPE GetPrimaryDrillShape() const
Definition pad.h:431
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
Definition pad.cpp:873
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:2061
void SetTopBackdrillSize(std::optional< int > aSize)
Definition pad.h:1072
std::optional< bool > GetPrimaryDrillCapped() const
Definition pad.h:507
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pad.cpp:2694
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:3697
int GetPrimaryDrillSizeX() const
Definition pad.h:315
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:1882
wxString m_number
Definition pad.h:1114
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:859
void SetBackPostMachiningDepth(int aDepth)
Definition pad.h:476
bool HasDrilledHole() const override
Definition pad.h:118
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
Definition pad.cpp:1062
void SetLibDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:284
PCB_LAYER_ID GetPrimaryDrillEndLayer() const
Definition pad.h:439
PCB_LAYER_ID GetBottomBackdrillLayer() const
Definition pad.h:1068
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Definition pad.h:285
void SetLocalClearance(std::optional< int > aClearance)
Definition pad.h:584
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pad.h:523
int GetSubRatsnest() const
Definition pad.h:860
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:528
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:611
void SetTertiaryDrillSizeY(int aY)
Definition pad.cpp:1147
int m_lengthPadToDie
Definition pad.h:1137
bool HasHole() const override
Definition pad.h:113
double GetThermalSpokeAngleDegrees() const
Definition pad.h:767
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition pad.h:1035
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition pad.h:227
int GetThermalGap() const
Definition pad.h:773
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1868
int GetSecondaryDrillSizeY() const
Definition pad.h:517
void SetSecondaryDrillSizeY(int aY)
Definition pad.cpp:1094
PCB_LAYER_ID GetTopBackdrillLayer() const
Definition pad.h:1074
EDA_ORIENTATION m_libOrientation
Definition pad.h:1119
void SetOrientationDegrees(double aOrientation)
Definition pad.h:424
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition pad.cpp:2167
void SetLayerSet(const LSET &aLayers) override
Definition pad.cpp:1968
bool SharesNetTieGroup(const PAD *aOther) const
Definition pad.cpp:587
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
Definition pad.h:219
void SetBottomBackdrillSize(std::optional< int > aSize)
Definition pad.h:1066
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1194
void ClearSecondaryDrillSize()
Definition pad.cpp:1101
bool GetPrimaryDrillCappedFlag() const
Definition pad.h:508
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:525
void SetSubRatsnest(int aSubRatsnest)
Definition pad.h:861
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition pad.cpp:2187
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:3013
void SetPadToDieLength(int aLength)
Definition pad.h:577
bool IsFlipped() const
Definition pad.cpp:651
bool operator==(const PAD &aOther) const
Definition pad.cpp:3606
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:578
void SetBackPostMachiningAngle(int aAngle)
Definition pad.h:478
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pad.cpp:2716
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
DRC_CONSTRAINT_T
Definition drc_rule.h:49
@ NULL_CONSTRAINT
Definition drc_rule.h:50
@ 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:23
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:75
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:68
CUSTOM_SHAPE_ZONE_MODE
Definition padstack.h:136
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition padstack.h:96
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:102
@ PTH
Plated through hole pad.
Definition padstack.h:97
BACKDRILL_MODE
Definition padstack.h:83
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:51
@ RECTANGLE
Definition padstack.h:53
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition padstack.h:113
UNCONNECTED_LAYER_MODE
Definition padstack.h:127
std::map< PCB_LAYER_ID, std::array< std::shared_ptr< SHAPE_POLY_SET >, 2 > > LAYER_POLYGON_MAP
Definition pad.h:1099
LAYER_POLYGON_MAP m_effectivePolygons
Definition pad.h:1104
LAYER_SHAPE_MAP m_effectiveShapes
Definition pad.h:1102
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition pad.h:1103
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_COMPOUND > > LAYER_SHAPE_MAP
Definition pad.h:1098
BOX2I m_effectiveBoundingBox
Definition pad.h:1101
double m_lastGalZoomLevel
Definition pad.h:1105
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