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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#pragma once
26
27#include <mutex>
28#include <array>
29#include <optional>
30
32#include <core/arraydim.h>
33#include <core/mirror.h>
34#include <geometry/eda_angle.h>
37#include <lset.h>
38#include <padstack.h>
39#include <zones.h>
40
41class PCB_SHAPE;
42class SHAPE;
43class SHAPE_SEGMENT;
44
45class LINE_READER;
46class EDA_3D_CANVAS;
47class FOOTPRINT;
48
49namespace KIGFX
50{
51 class VIEW;
52}
53
54
57{
58 NONE = 0,
61};
62
63
65{
66public:
67 PAD( FOOTPRINT* parent );
68
69 // Copy constructor & operator= are needed because the list of basic shapes
70 // must be duplicated in copy.
71 PAD( const PAD& aPad );
72 PAD& operator=( const PAD &aOther );
73
74 void CopyFrom( const BOARD_ITEM* aOther ) override;
75
76 void Serialize( google::protobuf::Any &aContainer ) const override;
77 bool Deserialize( const google::protobuf::Any &aContainer ) override;
78
79 /*
80 * Default layers used for pads, according to the pad type.
81 *
82 * This is default values only, they can be changed for a given pad.
83 */
84 static LSET PTHMask();
85 static LSET SMDMask();
86 static LSET ConnSMDMask();
88 static LSET UnplatedHoleMask();
89 static LSET ApertureMask();
90
91 static inline bool ClassOf( const EDA_ITEM* aItem )
92 {
93 return aItem && PCB_PAD_T == aItem->Type();
94 }
95
96 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
97 {
98 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
99 return true;
100
101 for( KICAD_T scanType : aScanTypes )
102 {
103 if( HasHole() )
104 {
105 if( scanType == PCB_LOCATE_HOLE_T )
106 return true;
107 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
108 return true;
109 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
110 return true;
111 }
112 }
113
114 return false;
115 }
116
117 bool HasHole() const override
118 {
119 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
120 }
121
122 bool HasDrilledHole() const override
123 {
124 return HasHole() && GetDrillSizeX() == GetDrillSizeY();
125 }
126
127 bool IsLocked() const override;
128
136 void ImportSettingsFrom( const PAD& aMasterPad );
137
141 bool IsFlipped() const;
142
146 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
147 const wxString& GetNumber() const { return m_number; }
148
152 bool CanHaveNumber() const;
153
157 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
158 const wxString& GetPinFunction() const { return m_pinFunction; }
159
163 void SetPinType( const wxString& aType ) { m_pinType = aType; }
164 const wxString& GetPinType() const { return m_pinType; }
165
170 bool SameLogicalPadAs( const PAD* aOther ) const
171 {
172 // hide tricks behind sensible API
173 return GetParentFootprint() == aOther->GetParentFootprint()
174 && !m_number.IsEmpty() && m_number == aOther->m_number;
175 }
176
180 bool SharesNetTieGroup( const PAD* aOther ) const;
181
186 bool IsNoConnectPad() const;
187
192 bool IsFreePad() const;
193
197 void SetShape( PCB_LAYER_ID aLayer, PAD_SHAPE aShape )
198 {
199 m_padStack.SetShape( aShape, aLayer );
200 SetDirty();
201 }
202
206 PAD_SHAPE GetShape( PCB_LAYER_ID aLayer ) const { return m_padStack.Shape( aLayer ); }
207
208 // Used for the properties panel, which does not support padstacks at the moment
209 void SetFrontShape( PAD_SHAPE aShape );
210
211 PAD_SHAPE GetFrontShape() const { return m_padStack.Shape( F_Cu ); }
212
213 void SetPosition( const VECTOR2I& aPos ) override
214 {
215 m_pos = aPos;
216 SetDirty();
217 }
218
219 VECTOR2I GetPosition() const override { return m_pos; }
220
225 {
226 return m_padStack.AnchorShape( aLayer );
227 }
228
233 {
234 return m_padStack.CustomShapeInZoneMode();
235 }
236
243 {
244 m_padStack.SetCustomShapeInZoneMode( aOption );
245 }
246
254 {
255 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE ? PAD_SHAPE::RECTANGLE
257 aLayer );
258 SetDirty();
259 }
260
264 bool IsOnCopperLayer() const override;
265
266 void SetY( int y ) { m_pos.y = y; SetDirty(); }
267 void SetX( int x ) { m_pos.x = x; SetDirty(); }
268
269 void SetSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
270 {
271 m_padStack.SetSize( aSize, aLayer );
272 SetDirty();
273 }
274 const VECTOR2I& GetSize( PCB_LAYER_ID aLayer ) const { return m_padStack.Size( aLayer ); }
275
277 {
278 return m_padStack.HasExplicitDefinitionForLayer( aLayer );
279 }
280
281 // These accessors are for the properties panel, which does not have the ability to deal with
282 // custom padstacks where the properties can vary by layer. The properties should be disabled
283 // in the GUI when the padstack mode is set to anything other than NORMAL, but so that the code
284 // compiles, these are set up to work with the front layer (in other words, assume the mode is
285 // NORMAL, where F_Cu stores the whole padstack data)
286 void SetSizeX( const int aX )
287 {
288 if( aX > 0 )
289 {
290 int y = m_padStack.Size( PADSTACK::ALL_LAYERS ).y;
291
293 y = aX;
294
295 m_padStack.SetSize( { aX, y }, PADSTACK::ALL_LAYERS );
296 SetDirty();
297 }
298 }
299
300 int GetSizeX() const { return m_padStack.Size( PADSTACK::ALL_LAYERS ).x; }
301
302 void SetSizeY( const int aY )
303 {
304 if( aY > 0 )
305 {
306 int x = m_padStack.Size( PADSTACK::ALL_LAYERS ).x;
307
309 x = aY;
310
311 m_padStack.SetSize( { x, aY }, PADSTACK::ALL_LAYERS );
312 SetDirty();
313 }
314 }
315
316 int GetSizeY() const { return m_padStack.Size( PADSTACK::ALL_LAYERS ).y; }
317
318 void SetDelta( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
319 {
320 m_padStack.TrapezoidDeltaSize( aLayer ) = aSize;
321 SetDirty();
322 }
323
324 const VECTOR2I& GetDelta( PCB_LAYER_ID aLayer ) const
325 {
326 return m_padStack.TrapezoidDeltaSize( aLayer );
327 }
328
329 void SetPrimaryDrillSize( const VECTOR2I& aSize );
330 const VECTOR2I& GetPrimaryDrillSize() const { return m_padStack.Drill().size; }
331 void SetPrimaryDrillSizeX( int aX );
332 int GetPrimaryDrillSizeX() const { return m_padStack.Drill().size.x; }
333 void SetPrimaryDrillSizeY( int aY );
334 int GetPrimaryDrillSizeY() const { return m_padStack.Drill().size.y; }
335
336 void SetDrillSize( const VECTOR2I& aSize ) { SetPrimaryDrillSize( aSize ); }
337 const VECTOR2I& GetDrillSize() const { return GetPrimaryDrillSize(); }
338 void SetDrillSizeX( int aX );
339 int GetDrillSizeX() const { return GetPrimaryDrillSizeX(); }
340 void SetDrillSizeY( int aY );
341 int GetDrillSizeY() const { return GetPrimaryDrillSizeY(); }
342
343 void SetOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset )
344 {
345 m_padStack.Offset( aLayer ) = aOffset;
346 SetDirty();
347 }
348
349 const VECTOR2I& GetOffset( PCB_LAYER_ID aLayer ) const { return m_padStack.Offset( aLayer ); }
350
351 VECTOR2I GetCenter() const override { return GetPosition(); }
352
353 const PADSTACK& Padstack() const { return m_padStack; }
355 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
356
368 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPoly, int aThickness,
369 bool aFilled );
370 void AddPrimitivePoly( PCB_LAYER_ID aLayer, const std::vector<VECTOR2I>& aPoly, int aThickness,
371 bool aFilled );
372
385 void MergePrimitivesAsPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aMergedPolygon,
386 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
387
393
397 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives( PCB_LAYER_ID aLayer ) const
398 {
399 return m_padStack.Primitives( aLayer );
400 }
401
402 void Flip( const VECTOR2I& VECTOR2I, FLIP_DIRECTION aFlipDirection ) override;
403
408 void FlipPrimitives( FLIP_DIRECTION aFlipDirection );
409
414 void ReplacePrimitives( PCB_LAYER_ID aLayer,
415 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
416
421 void AppendPrimitives( PCB_LAYER_ID aLayer,
422 const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
423
427 void AddPrimitive( PCB_LAYER_ID aLayer, PCB_SHAPE* aPrimitive );
428
434 void SetOrientation( const EDA_ANGLE& aAngle );
435 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
436
440 EDA_ANGLE GetOrientation() const { return m_padStack.GetOrientation(); }
442
443 // For property system
444 void SetOrientationDegrees( double aOrientation )
445 {
446 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
447 }
449 {
450 return m_padStack.GetOrientation().AsDegrees();
451 }
452
454 PAD_DRILL_SHAPE GetPrimaryDrillShape() const { return m_padStack.Drill().shape; }
455
458
460 PCB_LAYER_ID GetPrimaryDrillStartLayer() const { return m_padStack.Drill().start; }
462 PCB_LAYER_ID GetPrimaryDrillEndLayer() const { return m_padStack.Drill().end; }
463
464 void SetFrontPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.FrontPostMachining().mode = aMode; }
465 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetFrontPostMachining() const { return m_padStack.FrontPostMachining().mode; }
466
468 {
469 m_padStack.FrontPostMachining().mode = aMode;
470 }
471
476
477 void SetFrontPostMachiningSize( int aSize ) { m_padStack.FrontPostMachining().size = aSize; }
478 int GetFrontPostMachiningSize() const { return m_padStack.FrontPostMachining().size; }
479 void SetFrontPostMachiningDepth( int aDepth ) { m_padStack.FrontPostMachining().depth = aDepth; }
480 int GetFrontPostMachiningDepth() const { return m_padStack.FrontPostMachining().depth; }
481 void SetFrontPostMachiningAngle( int aAngle ) { m_padStack.FrontPostMachining().angle = aAngle; }
482 int GetFrontPostMachiningAngle() const { return m_padStack.FrontPostMachining().angle; }
483
484 void SetBackPostMachining( const std::optional<PAD_DRILL_POST_MACHINING_MODE>& aMode ) { m_padStack.BackPostMachining().mode = aMode; }
485 std::optional<PAD_DRILL_POST_MACHINING_MODE> GetBackPostMachining() const { return m_padStack.BackPostMachining().mode; }
486
488 {
489 m_padStack.BackPostMachining().mode = aMode;
490 }
491
496
497 void SetBackPostMachiningSize( int aSize ) { m_padStack.BackPostMachining().size = aSize; }
498 int GetBackPostMachiningSize() const { return m_padStack.BackPostMachining().size; }
499 void SetBackPostMachiningDepth( int aDepth ) { m_padStack.BackPostMachining().depth = aDepth; }
500 int GetBackPostMachiningDepth() const { return m_padStack.BackPostMachining().depth; }
501 void SetBackPostMachiningAngle( int aAngle ) { m_padStack.BackPostMachining().angle = aAngle; }
502 int GetBackPostMachiningAngle() const { return m_padStack.BackPostMachining().angle; }
503
513 bool IsBackdrilledOrPostMachined( PCB_LAYER_ID aLayer ) const;
514
521 int GetPostMachiningKnockout( PCB_LAYER_ID aLayer ) const;
522
523 void SetPrimaryDrillFilled( const std::optional<bool>& aFilled );
524 void SetPrimaryDrillFilledFlag( bool aFilled );
525 std::optional<bool> GetPrimaryDrillFilled() const { return m_padStack.Drill().is_filled; }
526 bool GetPrimaryDrillFilledFlag() const { return m_padStack.Drill().is_filled.value_or( false ); }
527
528 void SetPrimaryDrillCapped( const std::optional<bool>& aCapped );
529 void SetPrimaryDrillCappedFlag( bool aCapped );
530 std::optional<bool> GetPrimaryDrillCapped() const { return m_padStack.Drill().is_capped; }
531 bool GetPrimaryDrillCappedFlag() const { return m_padStack.Drill().is_capped.value_or( false ); }
532
533 void SetSecondaryDrillSize( const VECTOR2I& aSize );
534 const VECTOR2I& GetSecondaryDrillSize() const { return m_padStack.SecondaryDrill().size; }
536
537 void SetSecondaryDrillSizeX( int aX );
538 int GetSecondaryDrillSizeX() const { return m_padStack.SecondaryDrill().size.x; }
539 void SetSecondaryDrillSizeY( int aY );
540 int GetSecondaryDrillSizeY() const { return m_padStack.SecondaryDrill().size.y; }
541
543 PAD_DRILL_SHAPE GetSecondaryDrillShape() const { return m_padStack.SecondaryDrill().shape; }
544
546 PCB_LAYER_ID GetSecondaryDrillStartLayer() const { return m_padStack.SecondaryDrill().start; }
548 PCB_LAYER_ID GetSecondaryDrillEndLayer() const { return m_padStack.SecondaryDrill().end; }
549
550 void SetTertiaryDrillSize( const VECTOR2I& aSize );
551 const VECTOR2I& GetTertiaryDrillSize() const { return m_padStack.TertiaryDrill().size; }
553
554 void SetTertiaryDrillSizeX( int aX );
555 int GetTertiaryDrillSizeX() const { return m_padStack.TertiaryDrill().size.x; }
556 void SetTertiaryDrillSizeY( int aY );
557 int GetTertiaryDrillSizeY() const { return m_padStack.TertiaryDrill().size.y; }
558
560 PAD_DRILL_SHAPE GetTertiaryDrillShape() const { return m_padStack.TertiaryDrill().shape; }
561
563 PCB_LAYER_ID GetTertiaryDrillStartLayer() const { return m_padStack.TertiaryDrill().start; }
565 PCB_LAYER_ID GetTertiaryDrillEndLayer() const { return m_padStack.TertiaryDrill().end; }
566
567 bool IsDirty() const
568 {
570 }
571
572 void SetDirty()
573 {
574 m_shapesDirty = true;
577 }
578
579 void SetLayerSet( const LSET& aLayers ) override;
580 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
581
582 void SetAttribute( PAD_ATTRIB aAttribute );
584
585 void SetProperty( PAD_PROP aProperty );
586 PAD_PROP GetProperty() const { return m_property; }
587
588 // We don't currently have an attribute for APERTURE, and adding one will change the file
589 // format, so for now just infer a copper-less pad to be an APERTURE pad.
590 bool IsAperturePad() const
591 {
592 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
593 }
594
597
598 bool IsNPTHWithNoCopper() const;
599
600 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
601 int GetPadToDieLength() const { return m_lengthPadToDie; }
602
603 void SetPadToDieDelay( int aDelay ) { m_delayPadToDie = aDelay; }
604 int GetPadToDieDelay() const { return m_delayPadToDie; }
605
606 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
607 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
608
609 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
610 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
611 {
612 m_padStack.SolderMaskMargin( F_Mask ) = aMargin;
613 m_padStack.SolderMaskMargin( B_Mask ) = aMargin;
614 }
615
616 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
617 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
618 {
619 m_padStack.SolderPasteMargin( F_Paste ) = aMargin;
620 m_padStack.SolderPasteMargin( B_Paste ) = aMargin;
621 }
622
623 std::optional<double> GetLocalSolderPasteMarginRatio() const
624 {
625 return m_padStack.SolderPasteMarginRatio();
626 }
627 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
628 {
629 m_padStack.SolderPasteMarginRatio( F_Paste ) = aRatio;
630 m_padStack.SolderPasteMarginRatio( B_Paste ) = aRatio;
631 }
632
633 void SetLocalZoneConnection( ZONE_CONNECTION aType ) { m_padStack.ZoneConnection() = aType; }
635 {
636 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
637 }
638
646 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
647
657 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
658 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
659 bool ignoreLineWidth = false ) const override;
660
670 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
671 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
672
687 virtual std::shared_ptr<SHAPE>
689 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
690
691 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( PCB_LAYER_ID aLayer,
692 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
693
697 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
698
704 int GetBoundingRadius() const;
705
712 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
713
720 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
721
732 int GetSolderMaskExpansion( PCB_LAYER_ID aLayer ) const;
733
746
747 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
748
753 void SetLocalThermalSpokeWidthOverride( std::optional<int> aWidth )
754 {
755 m_padStack.ThermalSpokeWidth() = aWidth;
756 }
757 std::optional<int> GetLocalThermalSpokeWidthOverride() const
758 {
759 return m_padStack.ThermalSpokeWidth();
760 }
761
762 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
763
769 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
770 {
771 m_padStack.SetThermalSpokeAngle( aAngle );
772 }
774 {
775 return m_padStack.ThermalSpokeAngle();
776 }
777
778 // For property system
779 void SetThermalSpokeAngleDegrees( double aAngle )
780 {
781 m_padStack.SetThermalSpokeAngle( EDA_ANGLE( aAngle, DEGREES_T ) );
782 }
784 {
785 return m_padStack.ThermalSpokeAngle().AsDegrees();
786 }
787
788 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
789 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
790
791 int GetLocalThermalGapOverride( wxString* aSource ) const;
792
793 std::optional<int> GetLocalThermalGapOverride() const
794 {
795 return m_padStack.ThermalGap();
796 }
797 void SetLocalThermalGapOverride( const std::optional<int>& aOverride )
798 {
799 m_padStack.ThermalGap() = aOverride;
800 }
801
807 void SetRoundRectCornerRadius( PCB_LAYER_ID aLayer, double aRadius );
808 int GetRoundRectCornerRadius( PCB_LAYER_ID aLayer ) const;
809
810 VECTOR2I ShapePos( PCB_LAYER_ID aLayer ) const;
811
819 static void SwapShapePositions( PAD* aLhs, PAD* aRhs );
820
827 void SetRoundRectRadiusRatio( PCB_LAYER_ID aLayer, double aRadiusScale );
829 {
830 return m_padStack.RoundRectRadiusRatio( aLayer );
831 }
832
833 // For properties panel, which only supports normal padstacks
834 void SetFrontRoundRectRadiusRatio( double aRadiusScale );
836 {
837 return m_padStack.RoundRectRadiusRatio( F_Cu );
838 }
839
840 // For properties panel, which only supports normal padstacks
841 void SetFrontRoundRectRadiusSize( int aRadius );
842 int GetFrontRoundRectRadiusSize() const;
843
850 void SetChamferRectRatio( PCB_LAYER_ID aLayer, double aChamferScale );
851 double GetChamferRectRatio( PCB_LAYER_ID aLayer ) const
852 {
853 return m_padStack.ChamferRatio( aLayer );
854 }
855
863 void SetChamferPositions( PCB_LAYER_ID aLayer, int aPositions )
864 {
865 m_padStack.SetChamferPositions( aPositions, aLayer );
866 }
867
869 {
870 return m_padStack.ChamferPositions( aLayer );
871 }
872
876 int GetSubRatsnest() const { return m_subRatsnest; }
877 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
878
884 void SetRemoveUnconnected( bool aSet )
885 {
886 m_padStack.SetUnconnectedLayerMode( aSet ? UNCONNECTED_LAYER_MODE::REMOVE_ALL
888 }
889
891 {
892 return m_padStack.UnconnectedLayerMode() != UNCONNECTED_LAYER_MODE::KEEP_ALL;
893 }
894
899 void SetKeepTopBottom( bool aSet )
900 {
903 }
904
905 bool GetKeepTopBottom() const
906 {
908 }
909
911 {
912 m_padStack.SetUnconnectedLayerMode( aMode );
913 }
914
916 {
917 return m_padStack.UnconnectedLayerMode();
918 }
919
921 {
922 switch( m_padStack.UnconnectedLayerMode() )
923 {
925 return false;
926
928 return true;
929
932 return aLayer != m_padStack.Drill().start && aLayer != m_padStack.Drill().end;
933 }
934
935 return true;
936 }
937
938 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
939
940 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
941 {
942 return m_padStack.LayerSet().test( aLayer );
943 }
944
953 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
954
955 bool CanFlashLayer( int aLayer )
956 {
957 return FlashLayer( aLayer, true );
958 }
959
960 PCB_LAYER_ID GetLayer() const override;
961
966
974 bool FlashLayer( const LSET& aLayers ) const;
975
976 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
977 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
978 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
979
983 bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const;
984
992 std::vector<PCB_SHAPE*> Recombine( bool aIsDryRun, int aMaxError );
993
994 wxString GetClass() const override
995 {
996 return wxT( "PAD" );
997 }
998
1002 const BOX2I GetBoundingBox() const override;
1003 const BOX2I GetBoundingBox( PCB_LAYER_ID aLayer ) const;
1004
1011 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
1012
1013 void Move( const VECTOR2I& aMoveVector ) override
1014 {
1015 m_pos += aMoveVector;
1016 SetDirty();
1017 }
1018
1019 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
1020
1021 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1022
1023 BITMAPS GetMenuImage() const override;
1024
1028 static wxString ShowPadShape( PAD_SHAPE aShape );
1029 wxString ShowPadShape( PCB_LAYER_ID aLayer ) const;
1030
1034 wxString ShowLegacyPadShape( PCB_LAYER_ID aLayer ) const;
1035
1039 wxString ShowPadAttr() const;
1040
1041 EDA_ITEM* Clone() const override;
1042
1048 PAD* ClonePad() const
1049 {
1050 return (PAD*) Clone();
1051 }
1052
1057 void BuildEffectiveShapes() const;
1058 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
1059
1060 virtual std::vector<int> ViewGetLayers() const override;
1061
1062 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1063
1064 virtual const BOX2I ViewBBox() const override;
1065
1067
1069
1070 void SetZoneLayerOverride( PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride );
1071
1072 void CheckPad( UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1073 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1074
1075 BACKDRILL_MODE GetBackdrillMode() const { return m_padStack.GetBackdrillMode(); }
1076 void SetBackdrillMode( BACKDRILL_MODE aMode ) { m_padStack.SetBackdrillMode( aMode ); }
1077
1078 std::optional<int> GetBottomBackdrillSize() const { return m_padStack.GetBackdrillSize( false ); }
1079 void SetBottomBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( false, aSize ); }
1080
1081 PCB_LAYER_ID GetBottomBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( false ); }
1082 void SetBottomBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( false, aLayer ); }
1083
1084 std::optional<int> GetTopBackdrillSize() const { return m_padStack.GetBackdrillSize( true ); }
1085 void SetTopBackdrillSize( std::optional<int> aSize ) { m_padStack.SetBackdrillSize( true, aSize ); }
1086
1087 PCB_LAYER_ID GetTopBackdrillLayer() const { return m_padStack.GetBackdrillEndLayer( true ); }
1088 void SetTopBackdrillLayer( PCB_LAYER_ID aLayer ) { m_padStack.SetBackdrillEndLayer( true, aLayer ); }
1089
1090 double Similarity( const BOARD_ITEM& aOther ) const override;
1091
1092 bool operator==( const PAD& aOther ) const;
1093 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
1094
1095#if defined(DEBUG)
1096 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1097#endif
1098
1099protected:
1100 virtual void swapData( BOARD_ITEM* aImage ) override;
1101
1102private:
1103 const SHAPE_COMPOUND& buildEffectiveShape( PCB_LAYER_ID aLayer ) const;
1104
1106 {
1107 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
1108 typedef std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_COMPOUND>> LAYER_SHAPE_MAP;
1109 typedef std::map<PCB_LAYER_ID, std::array<std::shared_ptr<SHAPE_POLY_SET>, 2>> LAYER_POLYGON_MAP;
1110
1113 std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
1116 };
1117
1119
1120 void doCheckPad( PCB_LAYER_ID aLayer, UNITS_PROVIDER* aUnitsProvider, bool aForPadProperties,
1121 const std::function<void( int aErrorCode, const wxString& aMsg )>& aErrorHandler ) const;
1122
1123private:
1124 wxString m_number; // Pad name (pin number in schematic)
1125 wxString m_pinFunction; // Pin name in schematic
1126 wxString m_pinType; // Pin electrical type in schematic
1127
1128 VECTOR2I m_pos; // Pad Position on board
1129
1131
1132 // Mutex for shape building, poly building and zone layer overrides
1133 mutable std::mutex m_dataMutex;
1134
1135 mutable std::unique_ptr<PAD_DRAW_CACHE_DATA> m_drawCache;
1136
1138
1139 int m_subRatsnest; // Variable used to handle subnet (block) number in
1140 // ratsnest computations
1141
1143
1144 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
1145
1146 int m_lengthPadToDie; // Length net from pad to die, inside the package
1147 int m_delayPadToDie; // Propagation delay from pad to die
1148
1150
1151 // Bools at the end for better memory layout
1152 mutable bool m_polyDirty[2];
1153 mutable bool m_shapesDirty;
1154
1155 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> m_zoneLayerOverrides;
1156};
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:922
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.
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:100
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:206
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:67
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:66
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:599
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition padstack.h:157
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:65
void SetFrontPostMachiningSize(int aSize)
Definition pad.h:477
int GetBackPostMachiningSize() const
Definition pad.h:498
void SetAnchorPadShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition pad.h:253
bool IsAperturePad() const
Definition pad.h:590
void SetAttribute(PAD_ATTRIB aAttribute)
Definition pad.cpp:1374
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1676
void CheckPad(UNITS_PROVIDER *aUnitsProvider, bool aForPadProperties, const std::function< void(int aErrorCode, const wxString &aMsg)> &aErrorHandler) const
Definition pad.cpp:2865
std::optional< bool > GetPrimaryDrillFilled() const
Definition pad.h:525
void SetBackPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:484
PAD(FOOTPRINT *parent)
Definition pad.cpp:79
virtual void swapData(BOARD_ITEM *aImage) override
Definition pad.cpp:2588
PAD_PROP GetProperty() const
Definition pad.h:586
void SetFrontPostMachiningAngle(int aAngle)
Definition pad.h:481
bool GetRemoveUnconnected() const
Definition pad.h:890
void SetPrimaryDrillFilledFlag(bool aFilled)
Definition pad.cpp:767
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pad.cpp:184
double GetFrontRoundRectRadiusRatio() const
Definition pad.h:835
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:2980
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2176
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition pad.cpp:1651
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition pad.h:163
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition pad.h:580
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:397
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition pad.cpp:273
int GetSizeX() const
Definition pad.h:300
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:3279
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:894
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:443
void SetLocalThermalGapOverride(const std::optional< int > &aOverride)
Definition pad.h:797
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:526
bool IsDirty() const
Definition pad.h:567
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pad.cpp:966
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:1890
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1358
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:880
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition pad.h:940
int GetDrillSizeY() const
Definition pad.h:341
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:3187
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition pad.h:623
void SetFrontPostMachiningDepth(int aDepth)
Definition pad.h:479
void SetFrontShape(PAD_SHAPE aShape)
Definition pad.cpp:1428
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1088
const wxString & GetPinType() const
Definition pad.h:164
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition pad.cpp:283
void SetSecondaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:788
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
Definition pad.cpp:760
const VECTOR2I & GetDrillSize() const
Definition pad.h:337
PAD_ATTRIB GetAttribute() const
Definition pad.h:583
static LSET PTHMask()
layer set for a through hole pad
Definition pad.cpp:372
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition pad.cpp:2156
void SetRemoveUnconnected(bool aSet)
Definition pad.h:884
const wxString & GetPinFunction() const
Definition pad.h:158
void SetThermalGap(int aGap)
Definition pad.h:788
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:290
void SetFrontPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
Definition pad.h:464
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition pad.h:769
wxString m_pinType
Definition pad.h:1126
std::optional< int > GetBottomBackdrillSize() const
Definition pad.h:1078
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pad.cpp:221
const wxString & GetNumber() const
Definition pad.h:147
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition pad.cpp:2409
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:324
int GetSecondaryDrillSizeX() const
Definition pad.h:538
void SetSecondaryDrillSizeX(int aX)
Definition pad.cpp:795
void SetFrontRoundRectRadiusRatio(double aRadiusScale)
Definition pad.cpp:914
void SetPrimaryDrillSizeX(int aX)
Definition pad.cpp:533
PAD_DRAW_CACHE_DATA & getDrawCache() const
Definition pad.cpp:1088
std::mutex m_dataMutex
Definition pad.h:1133
void BuildEffectiveShapes() const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition pad.cpp:1097
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:582
void SetSimElectricalType(PAD_SIM_ELECTRICAL_TYPE aType)
Definition pad.h:595
PAD_SHAPE GetFrontShape() const
Definition pad.h:211
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:467
static bool ClassOf(const EDA_ITEM *aItem)
Definition pad.h:91
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pad.cpp:149
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition pad.h:627
PAD & operator=(const PAD &aOther)
Definition pad.cpp:130
void SetLocalThermalSpokeWidthOverride(std::optional< int > aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition pad.h:753
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
Definition pad.h:197
void SetSecondaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:827
bool IsLocked() const override
Definition pad.cpp:334
wxString ShowLegacyPadShape(PCB_LAYER_ID aLayer) const
An older version still used by place file writer.
Definition pad.cpp:2198
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pad.h:351
VECTOR2I GetPosition() const override
Definition pad.h:219
void SetProperty(PAD_PROP aProperty)
Definition pad.cpp:1447
void SetThermalSpokeAngleDegrees(double aAngle)
Definition pad.h:779
void SetPrimaryDrillSizeY(int aY)
Definition pad.cpp:550
EDA_ANGLE GetThermalSpokeAngle() const
Definition pad.h:773
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition pad.h:1155
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition pad.h:920
PAD_ATTRIB m_attribute
Definition pad.h:1142
void Flip(const VECTOR2I &VECTOR2I, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pad.cpp:1480
void SetBackPostMachiningSize(int aSize)
Definition pad.h:497
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pad.h:1013
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition pad.cpp:2719
PCB_LAYER_ID GetPrincipalLayer() const
Definition pad.cpp:421
void ClearTertiaryDrillSize()
Definition pad.cpp:866
void SetDirty()
Definition pad.h:572
PAD_DRILL_SHAPE GetTertiaryDrillShape() const
Definition pad.h:560
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:565
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:393
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.h:318
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1082
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pad.cpp:2317
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:873
double GetOrientationDegrees() const
Definition pad.h:448
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:170
void SetBackdrillMode(BACKDRILL_MODE aMode)
Definition pad.h:1076
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pad.cpp:2167
int GetBackPostMachiningAngle() const
Definition pad.h:502
PADSTACK m_padStack
Definition pad.h:1130
void SetPadToDieDelay(int aDelay)
Definition pad.h:603
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:1544
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pad.h:563
bool IsNoConnectPad() const
Definition pad.cpp:360
int GetDrillSizeX() const
Definition pad.h:339
PCB_LAYER_ID GetPrimaryDrillStartLayer() const
Definition pad.h:460
PAD_PROP m_property
Definition pad.h:1144
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:828
int GetFrontPostMachiningSize() const
Definition pad.h:478
void SetKeepTopBottom(bool aSet)
Definition pad.h:899
void SetTertiaryDrillSizeX(int aX)
Definition pad.cpp:848
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
Definition pad.cpp:3260
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition pad.h:910
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:206
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:2613
PADSTACK & Padstack()
Definition pad.h:354
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition pad.h:146
BACKDRILL_MODE GetBackdrillMode() const
Definition pad.h:1075
void SetTertiaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:841
int GetTertiaryDrillSizeY() const
Definition pad.h:557
void SetFrontRoundRectRadiusSize(int aRadius)
Definition pad.cpp:924
wxString ShowPadAttr() const
Definition pad.cpp:2214
wxString m_pinFunction
Definition pad.h:1125
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:834
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
Definition pad.cpp:3251
int GetFrontPostMachiningDepth() const
Definition pad.h:480
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.h:456
int m_effectiveBoundingRadius
Definition pad.h:1137
const VECTOR2I & GetPrimaryDrillSize() const
Definition pad.h:330
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pad.h:610
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:487
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.h:343
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:242
bool GetKeepTopBottom() const
Definition pad.h:905
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition pad.h:633
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition pad.cpp:944
void SetPrimaryDrillCappedFlag(bool aCapped)
Definition pad.cpp:781
bool GetPrimaryDrillFilledFlag() const
Definition pad.h:526
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1683
int GetPadToDieDelay() const
Definition pad.h:604
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:606
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition pad.cpp:2516
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:3163
std::unique_ptr< PAD_DRAW_CACHE_DATA > m_drawCache
Definition pad.h:1135
bool IsOnCopperLayer() const override
Definition pad.cpp:1595
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:887
void SetPadstack(const PADSTACK &aPadstack)
Definition pad.h:355
void SetPosition(const VECTOR2I &aPos) override
Definition pad.h:213
const SHAPE_COMPOUND & buildEffectiveShape(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1147
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:563
const PADSTACK & Padstack() const
Definition pad.h:353
const VECTOR2I & GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.h:349
VECTOR2I m_pos
Definition pad.h:1128
PAD_DRILL_SHAPE GetSecondaryDrillShape() const
Definition pad.h:543
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1302
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition pad.cpp:386
void SetDrillSize(const VECTOR2I &aSize)
Definition pad.h:336
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
Definition pad.h:492
bool IsFreePad() const
Definition pad.cpp:366
int GetFrontPostMachiningAngle() const
Definition pad.h:482
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
Definition pad.h:472
wxString GetClass() const override
Return the class name.
Definition pad.h:994
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetFrontPostMachining() const
Definition pad.h:465
bool IsNPTHWithNoCopper() const
Definition pad.cpp:304
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:534
bool CanFlashLayer(int aLayer)
Definition pad.h:955
int m_subRatsnest
Definition pad.h:1139
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.h:440
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.h:269
int m_delayPadToDie
Definition pad.h:1147
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:457
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:820
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:3228
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:868
void SetY(int y)
Definition pad.h:266
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:400
std::optional< PAD_DRILL_POST_MACHINING_MODE > GetBackPostMachining() const
Definition pad.h:485
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pad.cpp:2482
UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition pad.h:915
bool m_shapesDirty
Definition pad.h:1153
void SetRoundRectCornerRadius(PCB_LAYER_ID aLayer, double aRadius)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:900
void SetDrillSizeY(int aY)
Definition pad.cpp:557
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:379
std::optional< int > GetLocalSolderPasteMargin() const
Definition pad.h:616
int GetFrontRoundRectRadiusSize() const
Definition pad.cpp:934
int GetTertiaryDrillSizeX() const
Definition pad.h:555
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:952
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:863
int GetBackPostMachiningDepth() const
Definition pad.h:500
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
Definition pad.h:596
std::optional< int > GetLocalSolderMaskMargin() const
Definition pad.h:609
void SetDrillSizeX(int aX)
Definition pad.cpp:544
PAD_SIM_ELECTRICAL_TYPE m_simElectricalType
Definition pad.h:1149
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition pad.h:617
int GetSizeY() const
Definition pad.h:316
std::optional< int > GetLocalThermalGapOverride() const
Definition pad.h:793
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pad.cpp:415
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pad.cpp:2227
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:157
EDA_ANGLE GetFPRelativeOrientation() const
Definition pad.cpp:1471
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:851
bool m_polyDirty[2]
Definition pad.h:1152
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:2049
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition pad.cpp:1462
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:666
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition pad.cpp:1079
std::optional< int > GetTopBackdrillSize() const
Definition pad.h:1084
void ClearZoneLayerOverrides()
Definition pad.cpp:264
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition pad.cpp:1455
int GetPrimaryDrillSizeY() const
Definition pad.h:334
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:757
PAD_DRILL_SHAPE GetPrimaryDrillShape() const
Definition pad.h:454
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
Definition pad.cpp:589
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:1746
void SetTopBackdrillSize(std::optional< int > aSize)
Definition pad.h:1085
std::optional< bool > GetPrimaryDrillCapped() const
Definition pad.h:530
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pad.cpp:2311
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:3241
int GetPrimaryDrillSizeX() const
Definition pad.h:332
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:1577
wxString m_number
Definition pad.h:1124
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:575
void SetBackPostMachiningDepth(int aDepth)
Definition pad.h:499
bool HasDrilledHole() const override
Definition pad.h:122
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
Definition pad.cpp:774
PCB_LAYER_ID GetPrimaryDrillEndLayer() const
Definition pad.h:462
PCB_LAYER_ID GetBottomBackdrillLayer() const
Definition pad.h:1081
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Definition pad.h:276
void SetLocalClearance(std::optional< int > aClearance)
Definition pad.h:607
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pad.h:546
int GetSubRatsnest() const
Definition pad.h:876
void SetSizeX(const int aX)
Definition pad.h:286
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:551
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:634
void SetTertiaryDrillSizeY(int aY)
Definition pad.cpp:859
int m_lengthPadToDie
Definition pad.h:1146
bool HasHole() const override
Definition pad.h:117
double GetThermalSpokeAngleDegrees() const
Definition pad.h:783
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition pad.h:1048
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition pad.h:232
int GetThermalGap() const
Definition pad.h:789
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1562
int GetSecondaryDrillSizeY() const
Definition pad.h:540
void SetSecondaryDrillSizeY(int aY)
Definition pad.cpp:806
PCB_LAYER_ID GetTopBackdrillLayer() const
Definition pad.h:1087
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition pad.cpp:1070
void SetOrientationDegrees(double aOrientation)
Definition pad.h:444
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition pad.cpp:1852
void SetLayerSet(const LSET &aLayers) override
Definition pad.cpp:1663
bool SharesNetTieGroup(const PAD *aOther) const
Definition pad.cpp:343
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
Definition pad.h:224
void SetBottomBackdrillSize(std::optional< int > aSize)
Definition pad.h:1079
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:906
void ClearSecondaryDrillSize()
Definition pad.cpp:813
bool GetPrimaryDrillCappedFlag() const
Definition pad.h:531
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:548
void SetSubRatsnest(int aSubRatsnest)
Definition pad.h:877
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition pad.cpp:1872
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:2596
void SetPadToDieLength(int aLength)
Definition pad.h:600
bool IsFlipped() const
Definition pad.cpp:407
bool operator==(const PAD &aOther) const
Definition pad.cpp:3148
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition pad.h:96
void SetSizeY(const int aY)
Definition pad.h:302
int GetPadToDieLength() const
Definition pad.h:601
void SetBackPostMachiningAngle(int aAngle)
Definition pad.h:501
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
Definition pad.h:274
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pad.cpp:2333
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:128
@ DEGREES_T
Definition eda_angle.h:31
@ NONE
Definition eda_shape.h:76
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:184
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:185
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ F_Paste
Definition layer_ids.h:104
@ B_Mask
Definition layer_ids.h:98
@ F_Mask
Definition layer_ids.h:97
@ B_Paste
Definition layer_ids.h:105
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ F_Cu
Definition layer_ids.h:64
FLIP_DIRECTION
Definition mirror.h:27
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
PAD_SIM_ELECTRICAL_TYPE
The electrical type of a pad.
Definition pad.h:57
PAD_DRILL_POST_MACHINING_MODE
Definition padstack.h:76
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:69
CUSTOM_SHAPE_ZONE_MODE
Definition padstack.h:137
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition padstack.h:97
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:103
@ PTH
Plated through hole pad.
Definition padstack.h:98
BACKDRILL_MODE
Definition padstack.h:84
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:52
@ RECTANGLE
Definition padstack.h:54
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition padstack.h:114
UNCONNECTED_LAYER_MODE
Definition padstack.h:128
std::map< PCB_LAYER_ID, std::array< std::shared_ptr< SHAPE_POLY_SET >, 2 > > LAYER_POLYGON_MAP
Definition pad.h:1109
LAYER_POLYGON_MAP m_effectivePolygons
Definition pad.h:1114
LAYER_SHAPE_MAP m_effectiveShapes
Definition pad.h:1112
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition pad.h:1113
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_COMPOUND > > LAYER_SHAPE_MAP
Definition pad.h:1108
BOX2I m_effectiveBoundingBox
Definition pad.h:1111
double m_lastGalZoomLevel
Definition pad.h:1115
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:75
@ PCB_LOCATE_NPTH_T
Definition typeinfo.h:130
@ PCB_LOCATE_PTH_T
Definition typeinfo.h:129
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:84
@ PCB_LOCATE_HOLE_T
Definition typeinfo.h:128
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:47