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
249 {
250 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE ? PAD_SHAPE::RECTANGLE
252 aLayer );
253 SetDirty();
254 }
255
259 bool IsOnCopperLayer() const override;
260
261 void SetY( int y )
262 {
263 VECTOR2I p = GetPosition();
264 p.y = y;
265 SetPosition( p );
266 }
267 void SetX( int x )
268 {
269 VECTOR2I p = GetPosition();
270 p.x = x;
271 SetPosition( p );
272 }
273
274 void SetSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize );
275 VECTOR2I GetSize( PCB_LAYER_ID aLayer ) const;
276
277 // Lib-frame setters used by the parser. These store the value as-is in the
278 // padstack without inverse-scaling against the parent FP transform.
279 void SetLibSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize );
280 void SetLibDrillSize( const VECTOR2I& aSize );
281 void SetLibOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset );
282
284 {
285 return m_padStack.HasExplicitDefinitionForLayer( aLayer );
286 }
287
288 // These accessors are for the properties panel, which does not have the ability to deal with
289 // custom padstacks where the properties can vary by layer. The properties should be disabled
290 // in the GUI when the padstack mode is set to anything other than NORMAL, but so that the code
291 // compiles, these are set up to work with the front layer (in other words, assume the mode is
292 // NORMAL, where F_Cu stores the whole padstack data)
293 void SetSizeX( int aX );
294 int GetSizeX() const;
295
296 void SetSizeY( int aY );
297 int GetSizeY() const;
298
299 void SetDelta( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
300 {
301 m_padStack.TrapezoidDeltaSize( aLayer ) = aSize;
302 SetDirty();
303 }
304
305 const VECTOR2I& GetDelta( PCB_LAYER_ID aLayer ) const
306 {
307 return m_padStack.TrapezoidDeltaSize( aLayer );
308 }
309
310 void SetPrimaryDrillSize( const VECTOR2I& aSize );
312 void SetPrimaryDrillSizeX( int aX );
314 void SetPrimaryDrillSizeY( int aY );
316
317 void SetDrillSize( const VECTOR2I& aSize ) { SetPrimaryDrillSize( aSize ); }
319 void SetDrillSizeX( int aX );
320 int GetDrillSizeX() const { return GetPrimaryDrillSizeX(); }
321 void SetDrillSizeY( int aY );
322 int GetDrillSizeY() const { return GetPrimaryDrillSizeY(); }
323
324 void SetOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset );
325 VECTOR2I GetOffset( PCB_LAYER_ID aLayer ) const;
326
327 VECTOR2I GetCenter() const override { return GetPosition(); }
328
329 const PADSTACK& Padstack() const { return m_padStack; }
331 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
332
344 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPoly, int aThickness,
345 bool aFilled );
346 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const std::vector<VECTOR2I>& aPoly, int aThickness,
347 bool aFilled );
348
361 void MergePrimitivesAsPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aMergedPolygon,
362 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
363
369
373 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives( PCB_LAYER_ID aLayer ) const
374 {
375 return m_padStack.Primitives( aLayer );
376 }
377
378 void Flip( const VECTOR2I& VECTOR2I, FLIP_DIRECTION aFlipDirection ) override;
379
384 void FlipPrimitives( FLIP_DIRECTION aFlipDirection );
385
390 void ReplacePrimitives( PCB_LAYER_ID aLayer,
391 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
392
397 void AppendPrimitives( PCB_LAYER_ID aLayer,
398 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
399
403 void AddPrimitive( PCB_LAYER_ID aLayer, PCB_SHAPE* aPrimitive );
404
410 void SetOrientation( const EDA_ANGLE& aAngle );
411 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
412
418
419 void GetPrimitiveLibScale( double& aScaleX, double& aScaleY ) const;
420
421 // For property system
422 void SetOrientationDegrees( double aOrientation )
423 {
424 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
425 }
426 double GetOrientationDegrees() const { return GetOrientation().AsDegrees(); }
427
429 PAD_DRILL_SHAPE GetPrimaryDrillShape() const { return m_padStack.Drill().shape; }
430
433
435 PCB_LAYER_ID GetPrimaryDrillStartLayer() const { return m_padStack.Drill().start; }
437 PCB_LAYER_ID GetPrimaryDrillEndLayer() const { return m_padStack.Drill().end; }
438
439 void SetFrontPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.FrontPostMachining().mode = aMode; }
440 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetFrontPostMachining() const { return m_padStack.FrontPostMachining().mode; }
441
443 {
444 m_padStack.FrontPostMachining().mode = aMode;
445 }
446
451
452 void SetFrontPostMachiningSize( int aSize ) { m_padStack.FrontPostMachining().size = aSize; }
453 int GetFrontPostMachiningSize() const { return m_padStack.FrontPostMachining().size; }
454 void SetFrontPostMachiningDepth( int aDepth ) { m_padStack.FrontPostMachining().depth = aDepth; }
455 int GetFrontPostMachiningDepth() const { return m_padStack.FrontPostMachining().depth; }
456 void SetFrontPostMachiningAngle( int aAngle ) { m_padStack.FrontPostMachining().angle = aAngle; }
457 int GetFrontPostMachiningAngle() const { return m_padStack.FrontPostMachining().angle; }
458
459 void SetBackPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.BackPostMachining().mode = aMode; }
460 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetBackPostMachining() const { return m_padStack.BackPostMachining().mode; }
461
463 {
464 m_padStack.BackPostMachining().mode = aMode;
465 }
466
471
472 void SetBackPostMachiningSize( int aSize ) { m_padStack.BackPostMachining().size = aSize; }
473 int GetBackPostMachiningSize() const { return m_padStack.BackPostMachining().size; }
474 void SetBackPostMachiningDepth( int aDepth ) { m_padStack.BackPostMachining().depth = aDepth; }
475 int GetBackPostMachiningDepth() const { return m_padStack.BackPostMachining().depth; }
476 void SetBackPostMachiningAngle( int aAngle ) { m_padStack.BackPostMachining().angle = aAngle; }
477 int GetBackPostMachiningAngle() const { return m_padStack.BackPostMachining().angle; }
478
488 bool IsBackdrilledOrPostMachined( PCB_LAYER_ID aLayer ) const;
489
496 int GetPostMachiningKnockout( PCB_LAYER_ID aLayer ) const;
497
498 void SetPrimaryDrillFilled( const std::optional<bool>& aFilled );
499 void SetPrimaryDrillFilledFlag( bool aFilled );
500 std::optional<bool> GetPrimaryDrillFilled() const { return m_padStack.Drill().is_filled; }
501 bool GetPrimaryDrillFilledFlag() const { return m_padStack.Drill().is_filled.value_or( false ); }
502
503 void SetPrimaryDrillCapped( const std::optional<bool>& aCapped );
504 void SetPrimaryDrillCappedFlag( bool aCapped );
505 std::optional<bool> GetPrimaryDrillCapped() const { return m_padStack.Drill().is_capped; }
506 bool GetPrimaryDrillCappedFlag() const { return m_padStack.Drill().is_capped.value_or( false ); }
507
508 void SetSecondaryDrillSize( const VECTOR2I& aSize );
509 const VECTOR2I& GetSecondaryDrillSize() const { return m_padStack.SecondaryDrill().size; }
511
512 void SetSecondaryDrillSizeX( int aX );
513 int GetSecondaryDrillSizeX() const { return m_padStack.SecondaryDrill().size.x; }
514 void SetSecondaryDrillSizeY( int aY );
515 int GetSecondaryDrillSizeY() const { return m_padStack.SecondaryDrill().size.y; }
516
518 PAD_DRILL_SHAPE GetSecondaryDrillShape() const { return m_padStack.SecondaryDrill().shape; }
519
521 PCB_LAYER_ID GetSecondaryDrillStartLayer() const { return m_padStack.SecondaryDrill().start; }
523 PCB_LAYER_ID GetSecondaryDrillEndLayer() const { return m_padStack.SecondaryDrill().end; }
524
525 void SetTertiaryDrillSize( const VECTOR2I& aSize );
526 const VECTOR2I& GetTertiaryDrillSize() const { return m_padStack.TertiaryDrill().size; }
528
529 void SetTertiaryDrillSizeX( int aX );
530 int GetTertiaryDrillSizeX() const { return m_padStack.TertiaryDrill().size.x; }
531 void SetTertiaryDrillSizeY( int aY );
532 int GetTertiaryDrillSizeY() const { return m_padStack.TertiaryDrill().size.y; }
533
535 PAD_DRILL_SHAPE GetTertiaryDrillShape() const { return m_padStack.TertiaryDrill().shape; }
536
538 PCB_LAYER_ID GetTertiaryDrillStartLayer() const { return m_padStack.TertiaryDrill().start; }
540 PCB_LAYER_ID GetTertiaryDrillEndLayer() const { return m_padStack.TertiaryDrill().end; }
541
542 bool IsDirty() const
543 {
545 }
546
547 void SetDirty()
548 {
549 m_shapesDirty = true;
552 }
553
554 void SetLayerSet( const LSET& aLayers ) override;
555 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
556
557 void SetAttribute( PAD_ATTRIB aAttribute );
559
560 void SetProperty( PAD_PROP aProperty );
561 PAD_PROP GetProperty() const { return m_property; }
562
563 // We don't currently have an attribute for APERTURE, and adding one will change the file
564 // format, so for now just infer a copper-less pad to be an APERTURE pad.
565 bool IsAperturePad() const
566 {
567 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
568 }
569
572
573 bool IsNPTHWithNoCopper() const;
574
575 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
576 int GetPadToDieLength() const { return m_lengthPadToDie; }
577
578 void SetPadToDieDelay( int aDelay ) { m_delayPadToDie = aDelay; }
579 int GetPadToDieDelay() const { return m_delayPadToDie; }
580
581 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
582 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
583
584 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
585 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
586 {
587 m_padStack.SolderMaskMargin( F_Mask ) = aMargin;
588 m_padStack.SolderMaskMargin( B_Mask ) = aMargin;
589 }
590
591 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
592 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
593 {
594 m_padStack.SolderPasteMargin( F_Paste ) = aMargin;
595 m_padStack.SolderPasteMargin( B_Paste ) = aMargin;
596 }
597
598 std::optional<double> GetLocalSolderPasteMarginRatio() const
599 {
600 return m_padStack.SolderPasteMarginRatio();
601 }
602 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
603 {
604 m_padStack.SolderPasteMarginRatio( F_Paste ) = aRatio;
605 m_padStack.SolderPasteMarginRatio( B_Paste ) = aRatio;
606 }
607
608 void SetLocalZoneConnection( ZONE_CONNECTION aType ) { m_padStack.ZoneConnection() = aType; }
610 {
611 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
612 }
613
621 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
622
632 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
633 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
634 bool ignoreLineWidth = false ) const override;
635
645 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
646 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
647
665 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
667 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
668
669 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( PCB_LAYER_ID aLayer,
670 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
671
675 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
676 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
677
683 int GetBoundingRadius() const;
684
691 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
692
699 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
700
711 int GetSolderMaskExpansion( PCB_LAYER_ID aLayer ) const;
712
725
726 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
727
732 void SetLocalThermalSpokeWidthOverride( std::optional<int> aWidth )
733 {
734 m_padStack.ThermalSpokeWidth() = aWidth;
735 }
736 std::optional<int> GetLocalThermalSpokeWidthOverride() const
737 {
738 return m_padStack.ThermalSpokeWidth();
739 }
740
741 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
742
748 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
749 {
750 m_padStack.SetThermalSpokeAngle( aAngle );
751 }
753 {
754 return m_padStack.ThermalSpokeAngle();
755 }
756
757 // For property system
758 void SetThermalSpokeAngleDegrees( double aAngle )
759 {
760 m_padStack.SetThermalSpokeAngle( EDA_ANGLE( aAngle, DEGREES_T ) );
761 }
763 {
764 return m_padStack.ThermalSpokeAngle().AsDegrees();
765 }
766
767 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
768 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
769
770 int GetLocalThermalGapOverride( wxString* aSource ) const;
771
772 std::optional<int> GetLocalThermalGapOverride() const
773 {
774 return m_padStack.ThermalGap();
775 }
776 void SetLocalThermalGapOverride( const std::optional<int>& aOverride )
777 {
778 m_padStack.ThermalGap() = aOverride;
779 }
780
786 void SetRoundRectCornerRadius( PCB_LAYER_ID aLayer, double aRadius );
787 int GetRoundRectCornerRadius( PCB_LAYER_ID aLayer ) const;
788
789 VECTOR2I ShapePos( PCB_LAYER_ID aLayer ) const;
790
798 static void SwapShapePositions( PAD* aLhs, PAD* aRhs );
799
806 void SetRoundRectRadiusRatio( PCB_LAYER_ID aLayer, double aRadiusScale );
808 {
809 return m_padStack.RoundRectRadiusRatio( aLayer );
810 }
811
812 // For properties panel, which only supports normal padstacks
813 void SetFrontRoundRectRadiusRatio( double aRadiusScale );
815 {
816 return m_padStack.RoundRectRadiusRatio( F_Cu );
817 }
818
819 // For properties panel, which only supports normal padstacks
820 void SetFrontRoundRectRadiusSize( int aRadius );
821 int GetFrontRoundRectRadiusSize() const;
822
829 void SetChamferRectRatio( PCB_LAYER_ID aLayer, double aChamferScale );
830 double GetChamferRectRatio( PCB_LAYER_ID aLayer ) const
831 {
832 return m_padStack.ChamferRatio( aLayer );
833 }
834
842 void SetChamferPositions( PCB_LAYER_ID aLayer, int aPositions )
843 {
844 m_padStack.SetChamferPositions( aPositions, aLayer );
845 }
846
848 {
849 return m_padStack.ChamferPositions( aLayer );
850 }
851
855 int GetSubRatsnest() const { return m_subRatsnest; }
856 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
857
863 void SetRemoveUnconnected( bool aSet )
864 {
865 m_padStack.SetUnconnectedLayerMode( aSet ? UNCONNECTED_LAYER_MODE::REMOVE_ALL
867 }
868
870 {
871 return m_padStack.UnconnectedLayerMode() != UNCONNECTED_LAYER_MODE::KEEP_ALL;
872 }
873
878 void SetKeepTopBottom( bool aSet )
879 {
882 }
883
884 bool GetKeepTopBottom() const
885 {
887 }
888
890 {
891 m_padStack.SetUnconnectedLayerMode( aMode );
892 }
893
895 {
896 return m_padStack.UnconnectedLayerMode();
897 }
898
900 {
901 switch( m_padStack.UnconnectedLayerMode() )
902 {
904 return false;
905
907 return true;
908
911 return aLayer != m_padStack.Drill().start && aLayer != m_padStack.Drill().end;
912 }
913
914 return true;
915 }
916
917 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
918
919 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
920 {
921 return m_padStack.LayerSet().test( aLayer );
922 }
923
932 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
933
934 bool CanFlashLayer( int aLayer )
935 {
936 return FlashLayer( aLayer, true );
937 }
938
939 PCB_LAYER_ID GetLayer() const override;
940
945
953 bool FlashLayer( const LSET& aLayers ) const;
954
955 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
956 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
957 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
958
962 bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const;
963
971 std::vector<PCB_SHAPE*> Recombine( bool aIsDryRun, int aMaxError );
972
973 wxString GetClass() const override
974 {
975 return wxT( "PAD" );
976 }
977
981 const BOX2I GetBoundingBox() const override;
982 const BOX2I GetBoundingBox( PCB_LAYER_ID aLayer ) const;
983
990 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
991
992 void Move( const VECTOR2I& aMoveVector ) override {
993 SetPosition( GetPosition() + aMoveVector );
994 }
995
996 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
997
998 void OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
999 const EDA_ANGLE& aParentRotate ) override;
1000
1001 void OnFootprintTransformed() override;
1002
1003 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1004
1005 BITMAPS GetMenuImage() const override;
1006
1010 static wxString ShowPadShape( PAD_SHAPE aShape );
1011 wxString ShowPadShape( PCB_LAYER_ID aLayer ) const;
1012
1016 wxString ShowLegacyPadShape( PCB_LAYER_ID aLayer ) const;
1017
1021 wxString ShowPadAttr() const;
1022
1023 EDA_ITEM* Clone() const override;
1024
1030 PAD* ClonePad() const
1031 {
1032 return (PAD*) Clone();
1033 }
1034
1039 void BuildEffectiveShapes() const;
1040 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
1041
1042 virtual std::vector<int> ViewGetLayers() const override;
1043
1044 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1045
1046 virtual const BOX2I ViewBBox() const override;
1047
1049
1051
1052 void SetZoneLayerOverride( PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride );
1053
1054 void CheckPad( UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1055 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1056
1057 BACKDRILL_MODE GetBackdrillMode() const { return m_padStack.GetBackdrillMode(); }
1058 void SetBackdrillMode( BACKDRILL_MODE aMode ) { m_padStack.SetBackdrillMode( aMode ); }
1059
1060 std::optional<int> GetBottomBackdrillSize() const { return m_padStack.GetBackdrillSize( false ); }
1061 void SetBottomBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( false, aSize ); }
1062
1063 PCB_LAYER_ID GetBottomBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( false ); }
1064 void SetBottomBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( false, aLayer ); }
1065
1066 std::optional<int> GetTopBackdrillSize() const { return m_padStack.GetBackdrillSize( true ); }
1067 void SetTopBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( true, aSize ); }
1068
1069 PCB_LAYER_ID GetTopBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( true ); }
1070 void SetTopBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( true, aLayer ); }
1071
1072 double Similarity( const BOARD_ITEM& aOther ) const override;
1073
1074 bool operator==( const PAD& aOther ) const;
1075 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
1076
1077#if defined(DEBUG)
1078 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1079#endif
1080
1081protected:
1082 virtual void swapData( BOARD_ITEM* aImage ) override;
1083
1084private:
1085 const SHAPE_COMPOUND& buildEffectiveShape( PCB_LAYER_ID aLayer ) const;
1086
1087 // Scale a primitive's runtime geometry to the current footprint scale, in the pad frame.
1088 void rebakePrimitiveToFootprint( PCB_SHAPE* aPrimitive ) const;
1089
1091 {
1092 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
1093 typedef std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_COMPOUND>> LAYER_SHAPE_MAP;
1094 typedef std::map<PCB_LAYER_ID, std::array<std::shared_ptr<SHAPE_POLY_SET>, 2>> LAYER_POLYGON_MAP;
1095
1098 std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
1101 };
1102
1104
1105 void doCheckPad( PCB_LAYER_ID aLayer, UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1106 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1107
1108private:
1109 wxString m_number; // Pad name (pin number in schematic)
1110 wxString m_pinFunction; // Pin name in schematic
1111 wxString m_pinType; // Pin electrical type in schematic
1112
1113 VECTOR2I m_libPos; // Pad position in parent footprint's library frame
1114 EDA_ANGLE m_libOrientation; // Pad orientation in parent footprint's library frame
1115
1117
1118 // Mutex for shape building, poly building and zone layer overrides
1119 mutable std::mutex m_dataMutex;
1120
1121 mutable std::unique_ptr<PAD_DRAW_CACHE_DATA> m_drawCache;
1122
1124
1125 int m_subRatsnest; // Variable used to handle subnet (block) number in
1126 // ratsnest computations
1127
1129
1130 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
1131
1132 int m_lengthPadToDie; // Length net from pad to die, inside the package
1133 int m_delayPadToDie; // Propagation delay from pad to die
1134
1136
1137 // Bools at the end for better memory layout
1138 mutable bool m_polyDirty[2];
1139 mutable bool m_shapesDirty;
1140
1141 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> m_zoneLayerOverrides;
1142};
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:927
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:116
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h: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
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:774
void SetFrontPostMachiningSize(int aSize)
Definition pad.h:452
int GetBackPostMachiningSize() const
Definition pad.h:473
void SetAnchorPadShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition pad.h:248
bool IsAperturePad() const
Definition pad.h:565
void SetAttribute(PAD_ATTRIB aAttribute)
Definition pad.cpp:1639
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1972
void CheckPad(UNITS_PROVIDER *aUnitsProvider, bool aForPadProperties, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition pad.cpp:3287
std::optional< bool > GetPrimaryDrillFilled() const
Definition pad.h:500
void SetBackPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:459
PAD(FOOTPRINT *parent)
Definition pad.cpp:76
virtual void swapData(BOARD_ITEM *aImage) override
Definition pad.cpp:2985
PAD_PROP GetProperty() const
Definition pad.h:561
void SetFrontPostMachiningAngle(int aAngle)
Definition pad.h:456
bool GetRemoveUnconnected() const
Definition pad.h:869
void SetSizeY(int aY)
Definition pad.cpp:318
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pad.cpp:2528
void SetPrimaryDrillFilledFlag(bool aFilled)
Definition pad.cpp:1043
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pad.cpp:392
double GetFrontRoundRectRadiusRatio() const
Definition pad.h:814
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:3402
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2540
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition pad.cpp:1943
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:555
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:373
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition pad.cpp:507
int GetSizeX() const
Definition pad.cpp:312
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:3715
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1170
void rebakePrimitiveToFootprint(PCB_SHAPE *aPrimitive) const
Definition pad.cpp:2499
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:677
void SetLocalThermalGapOverride(const std::optional< int > &aOverride)
Definition pad.h:776
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:1316
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:763
bool IsDirty() const
Definition pad.h:542
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:2186
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1623
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1156
void SetSizeX(int aX)
Definition pad.cpp:298
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition pad.h:919
int GetDrillSizeY() const
Definition pad.h:322
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:3609
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition pad.h:598
void SetFrontPostMachiningDepth(int aDepth)
Definition pad.h:454
void SetFrontShape(PAD_SHAPE aShape)
Definition pad.cpp:1693
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1070
const wxString & GetPinType() const
Definition pad.h:160
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition pad.cpp:517
void SetSecondaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1064
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
Definition pad.cpp:1036
PAD_ATTRIB GetAttribute() const
Definition pad.h:558
static LSET PTHMask()
layer set for a through hole pad
Definition pad.cpp:606
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition pad.cpp:2464
void SetRemoveUnconnected(bool aSet)
Definition pad.h:863
const wxString & GetPinFunction() const
Definition pad.h:154
void SetThermalGap(int aGap)
Definition pad.h:767
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:524
void SetFrontPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:439
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition pad.h:748
wxString m_pinType
Definition pad.h:1111
std::optional< int > GetBottomBackdrillSize() const
Definition pad.h:1060
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pad.cpp:439
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:2792
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:305
int GetSecondaryDrillSizeX() const
Definition pad.h:513
void SetSecondaryDrillSizeX(int aX)
Definition pad.cpp:1071
void SetFrontRoundRectRadiusRatio(double aRadiusScale)
Definition pad.cpp:1190
void SetPrimaryDrillSizeX(int aX)
Definition pad.cpp:783
PAD_DRAW_CACHE_DATA & getDrawCache() const
Definition pad.cpp:1347
std::mutex m_dataMutex
Definition pad.h:1119
void BuildEffectiveShapes() const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition pad.cpp:1356
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:854
void SetSimElectricalType(PAD_SIM_ELECTRICAL_TYPE aType)
Definition pad.h:570
PAD_SHAPE GetFrontShape() const
Definition pad.h:210
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:442
static bool ClassOf(const EDA_ITEM *aItem)
Definition pad.h:87
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pad.cpp:357
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition pad.h:602
PAD & operator=(const PAD &aOther)
Definition pad.cpp:338
void SetLocalThermalSpokeWidthOverride(std::optional< int > aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition pad.h:732
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:1103
bool IsLocked() const override
Definition pad.cpp:568
wxString ShowLegacyPadShape(PCB_LAYER_ID aLayer) const
An older version still used by place file writer.
Definition pad.cpp:2562
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:2510
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pad.h:327
VECTOR2I GetPosition() const override
Definition pad.cpp:246
void SetProperty(PAD_PROP aProperty)
Definition pad.cpp:1712
void SetThermalSpokeAngleDegrees(double aAngle)
Definition pad.h:758
void SetPrimaryDrillSizeY(int aY)
Definition pad.cpp:801
EDA_ANGLE GetThermalSpokeAngle() const
Definition pad.h:752
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition pad.h:1141
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition pad.h:899
PAD_ATTRIB m_attribute
Definition pad.h:1128
void Flip(const VECTOR2I &VECTOR2I, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pad.cpp:1762
void SetBackPostMachiningSize(int aSize)
Definition pad.h:472
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pad.h:992
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition pad.cpp:3116
PCB_LAYER_ID GetPrincipalLayer() const
Definition pad.cpp:655
void ClearTertiaryDrillSize()
Definition pad.cpp:1142
void SetDirty()
Definition pad.h:547
PAD_DRILL_SHAPE GetTertiaryDrillShape() const
Definition pad.h:535
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:540
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:627
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.h:299
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1064
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pad.cpp:2681
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1149
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.cpp:826
double GetOrientationDegrees() const
Definition pad.h:426
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:1058
VECTOR2I GetDrillSize() const
Definition pad.h:318
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pad.cpp:2475
int GetBackPostMachiningAngle() const
Definition pad.h:477
PADSTACK m_padStack
Definition pad.h:1116
void SetPadToDieDelay(int aDelay)
Definition pad.h:578
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:1837
VECTOR2I m_libPos
Definition pad.h:1113
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pad.h:538
EDA_ANGLE m_libOrientation
Definition pad.h:1114
bool IsNoConnectPad() const
Definition pad.cpp:594
int GetDrillSizeX() const
Definition pad.h:320
PCB_LAYER_ID GetPrimaryDrillStartLayer() const
Definition pad.h:435
PAD_PROP m_property
Definition pad.h:1130
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:807
int GetFrontPostMachiningSize() const
Definition pad.h:453
void SetKeepTopBottom(bool aSet)
Definition pad.h:878
void SetTertiaryDrillSizeX(int aX)
Definition pad.cpp:1124
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
Definition pad.cpp:3696
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition pad.h:889
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:205
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:3010
PADSTACK & Padstack()
Definition pad.h:330
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:1057
void SetTertiaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1117
int GetTertiaryDrillSizeY() const
Definition pad.h:532
void SetFrontRoundRectRadiusSize(int aRadius)
Definition pad.cpp:1200
wxString ShowPadAttr() const
Definition pad.cpp:2578
wxString m_pinFunction
Definition pad.h:1110
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1110
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
Definition pad.cpp:3671
int GetFrontPostMachiningDepth() const
Definition pad.h:455
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.h:431
int m_effectiveBoundingRadius
Definition pad.h:1123
PADSTACK::MODE GetPadstackMode() const
Definition pad.h:191
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pad.h:585
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:462
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:815
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:884
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition pad.h:608
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition pad.cpp:1220
void SetPrimaryDrillCappedFlag(bool aCapped)
Definition pad.cpp:1057
bool GetPrimaryDrillFilledFlag() const
Definition pad.h:501
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1979
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:288
int GetPadToDieDelay() const
Definition pad.h:579
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:581
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition pad.cpp:2913
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:3585
std::unique_ptr< PAD_DRAW_CACHE_DATA > m_drawCache
Definition pad.h:1121
bool IsOnCopperLayer() const override
Definition pad.cpp:1887
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1163
void SetPadstack(const PADSTACK &aPadstack)
Definition pad.h:331
void SetPosition(const VECTOR2I &aPos) override
Definition pad.cpp:235
const SHAPE_COMPOUND & buildEffectiveShape(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1412
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:835
const PADSTACK & Padstack() const
Definition pad.h:329
PAD_DRILL_SHAPE GetSecondaryDrillShape() const
Definition pad.h:518
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1567
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition pad.cpp:620
void SetDrillSize(const VECTOR2I &aSize)
Definition pad.h:317
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
Definition pad.h:467
bool IsFreePad() const
Definition pad.cpp:600
int GetFrontPostMachiningAngle() const
Definition pad.h:457
void SetLibOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:281
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
Definition pad.h:447
wxString GetClass() const override
Return the class name.
Definition pad.h:973
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetFrontPostMachining() const
Definition pad.h:440
bool IsNPTHWithNoCopper() const
Definition pad.cpp:538
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:509
bool CanFlashLayer(int aLayer)
Definition pad.h:934
void SetLibSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:267
int m_subRatsnest
Definition pad.h:1125
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1747
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:255
int m_delayPadToDie
Definition pad.h:1133
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:432
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1096
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:3648
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:847
void SetY(int y)
Definition pad.h:261
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:634
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetBackPostMachining() const
Definition pad.h:460
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pad.cpp:2873
UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition pad.h:894
VECTOR2I GetLibraryPosition() const
Definition pad.h:214
bool m_shapesDirty
Definition pad.h:1139
void SetRoundRectCornerRadius(PCB_LAYER_ID aLayer, double aRadius)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1176
void SetDrillSizeY(int aY)
Definition pad.cpp:809
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:613
std::optional< int > GetLocalSolderPasteMargin() const
Definition pad.h:591
int GetFrontRoundRectRadiusSize() const
Definition pad.cpp:1210
int GetTertiaryDrillSizeX() const
Definition pad.h:530
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1228
void SetX(int x)
Definition pad.h:267
void SetChamferPositions(PCB_LAYER_ID aLayer, int aPositions)
Has meaning only for chamfered rectangular pads.
Definition pad.h:842
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:1241
int GetBackPostMachiningDepth() const
Definition pad.h:475
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
Definition pad.h:571
std::optional< int > GetLocalSolderMaskMargin() const
Definition pad.h:584
void SetDrillSizeX(int aX)
Definition pad.cpp:795
PAD_SIM_ELECTRICAL_TYPE m_simElectricalType
Definition pad.h:1135
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition pad.h:592
int GetSizeY() const
Definition pad.cpp:332
std::optional< int > GetLocalThermalGapOverride() const
Definition pad.h:772
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pad.cpp:649
void GetPrimitiveLibScale(double &aScaleX, double &aScaleY) const
Definition pad.cpp:2485
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pad.cpp:2591
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:153
EDA_ANGLE GetFPRelativeOrientation() const
Definition pad.cpp:1756
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:830
bool m_polyDirty[2]
Definition pad.h:1138
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:2357
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition pad.cpp:1733
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:944
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition pad.cpp:1338
std::optional< int > GetTopBackdrillSize() const
Definition pad.h:1066
void ClearZoneLayerOverrides()
Definition pad.cpp:498
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition pad.cpp:1720
int GetPrimaryDrillSizeY() const
Definition pad.h:315
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:736
PAD_DRILL_SHAPE GetPrimaryDrillShape() const
Definition pad.h:429
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
Definition pad.cpp:861
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:2042
void SetTopBackdrillSize(std::optional< int > aSize)
Definition pad.h:1067
std::optional< bool > GetPrimaryDrillCapped() const
Definition pad.h:505
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pad.cpp:2675
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:3661
int GetPrimaryDrillSizeX() const
Definition pad.h:313
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:1869
wxString m_number
Definition pad.h:1109
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:847
void SetBackPostMachiningDepth(int aDepth)
Definition pad.h:474
bool HasDrilledHole() const override
Definition pad.h:118
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
Definition pad.cpp:1050
void SetLibDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:274
PCB_LAYER_ID GetPrimaryDrillEndLayer() const
Definition pad.h:437
PCB_LAYER_ID GetBottomBackdrillLayer() const
Definition pad.h:1063
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Definition pad.h:283
void SetLocalClearance(std::optional< int > aClearance)
Definition pad.h:582
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pad.h:521
int GetSubRatsnest() const
Definition pad.h:855
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:526
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:609
void SetTertiaryDrillSizeY(int aY)
Definition pad.cpp:1135
int m_lengthPadToDie
Definition pad.h:1132
bool HasHole() const override
Definition pad.h:113
double GetThermalSpokeAngleDegrees() const
Definition pad.h:762
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition pad.h:1030
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition pad.h:227
int GetThermalGap() const
Definition pad.h:768
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1855
int GetSecondaryDrillSizeY() const
Definition pad.h:515
void SetSecondaryDrillSizeY(int aY)
Definition pad.cpp:1082
PCB_LAYER_ID GetTopBackdrillLayer() const
Definition pad.h:1069
void SetOrientationDegrees(double aOrientation)
Definition pad.h:422
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition pad.cpp:2148
void SetLayerSet(const LSET &aLayers) override
Definition pad.cpp:1955
bool SharesNetTieGroup(const PAD *aOther) const
Definition pad.cpp:577
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
Definition pad.h:219
void SetBottomBackdrillSize(std::optional< int > aSize)
Definition pad.h:1061
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1182
void ClearSecondaryDrillSize()
Definition pad.cpp:1089
bool GetPrimaryDrillCappedFlag() const
Definition pad.h:506
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:523
void SetSubRatsnest(int aSubRatsnest)
Definition pad.h:856
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition pad.cpp:2168
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:2993
void SetPadToDieLength(int aLength)
Definition pad.h:575
bool IsFlipped() const
Definition pad.cpp:641
bool operator==(const PAD &aOther) const
Definition pad.cpp:3570
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:576
void SetBackPostMachiningAngle(int aAngle)
Definition pad.h:476
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pad.cpp:2697
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:31
@ 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:1094
LAYER_POLYGON_MAP m_effectivePolygons
Definition pad.h:1099
LAYER_SHAPE_MAP m_effectiveShapes
Definition pad.h:1097
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition pad.h:1098
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_COMPOUND > > LAYER_SHAPE_MAP
Definition pad.h:1093
BOX2I m_effectiveBoundingBox
Definition pad.h:1096
double m_lastGalZoomLevel
Definition pad.h:1100
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:683
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43