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 (C) 1992-2024 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#ifndef PAD_H
26#define PAD_H
27
28#include <mutex>
29#include <array>
30#include <zones.h>
34#include <padstack.h>
35#include <geometry/eda_angle.h>
37#include <core/arraydim.h>
38
39class PCB_SHAPE;
40class SHAPE;
41class SHAPE_SEGMENT;
42
43class LINE_READER;
44class EDA_3D_CANVAS;
45class FOOTPRINT;
46
47namespace KIGFX
48{
49 class VIEW;
50}
51
53{
54public:
55 PAD( FOOTPRINT* parent );
56
57 // Copy constructor & operator= are needed because the list of basic shapes
58 // must be duplicated in copy.
59 PAD( const PAD& aPad );
60 PAD& operator=( const PAD &aOther );
61
62 void Serialize( google::protobuf::Any &aContainer ) const override;
63 bool Deserialize( const google::protobuf::Any &aContainer ) override;
64
65 /*
66 * Default layers used for pads, according to the pad type.
67 *
68 * This is default values only, they can be changed for a given pad.
69 */
70 static LSET PTHMask();
71 static LSET SMDMask();
72 static LSET ConnSMDMask();
74 static LSET UnplatedHoleMask();
75 static LSET ApertureMask();
76
77 static inline bool ClassOf( const EDA_ITEM* aItem )
78 {
79 return aItem && PCB_PAD_T == aItem->Type();
80 }
81
82 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
83 {
84 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
85 return true;
86
87 for( KICAD_T scanType : aScanTypes )
88 {
89 if( HasHole() )
90 {
91 if( scanType == PCB_LOCATE_HOLE_T )
92 return true;
93 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
94 return true;
95 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
96 return true;
97 }
98 }
99
100 return false;
101 }
102
103 bool HasHole() const override
104 {
105 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
106 }
107
108 bool IsLocked() const override;
109
117 void ImportSettingsFrom( const PAD& aMasterPad );
118
122 bool IsFlipped() const;
123
127 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
128 const wxString& GetNumber() const { return m_number; }
129
133 bool CanHaveNumber() const;
134
138 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
139 const wxString& GetPinFunction() const { return m_pinFunction; }
140
144 void SetPinType( const wxString& aType ) { m_pinType = aType; }
145 const wxString& GetPinType() const { return m_pinType; }
146
151 bool SameLogicalPadAs( const PAD* aOther ) const
152 {
153 // hide tricks behind sensible API
154 return GetParentFootprint() == aOther->GetParentFootprint()
155 && !m_number.IsEmpty() && m_number == aOther->m_number;
156 }
157
161 bool SharesNetTieGroup( const PAD* aOther ) const;
162
167 bool IsNoConnectPad() const;
168
173 bool IsFreePad() const;
174
178 void SetShape( PAD_SHAPE aShape )
179 {
180 m_padStack.SetShape( aShape );
181 SetDirty();
182 }
183
187 PAD_SHAPE GetShape() const { return m_padStack.Shape(); }
188
189 void SetPosition( const VECTOR2I& aPos ) override
190 {
191 m_pos = aPos;
192 SetDirty();
193 }
194
195 VECTOR2I GetPosition() const override { return m_pos; }
196
201 {
202 return m_padStack.AnchorShape();
203 }
204
209 {
211 }
212
219 {
221 }
222
230 {
231 m_padStack.SetAnchorShape( aShape == PAD_SHAPE::RECTANGLE
232 ? PAD_SHAPE::RECTANGLE
233 : PAD_SHAPE::CIRCLE );
234 SetDirty();
235 }
236
240 bool IsOnCopperLayer() const override;
241
242 void SetY( int y ) { m_pos.y = y; SetDirty(); }
243 void SetX( int x ) { m_pos.x = x; SetDirty(); }
244
245 void SetSize( const VECTOR2I& aSize )
246 {
247 m_padStack.Size() = aSize;
248 SetDirty();
249 }
250 const VECTOR2I& GetSize() const { return m_padStack.Size(); }
251
252 void SetSizeX( const int aX ) { if( aX > 0 ) { m_padStack.Size().x = aX; SetDirty(); } }
253 int GetSizeX() const { return m_padStack.Size().x; }
254 void SetSizeY( const int aY ) { if( aY > 0 ) { m_padStack.Size().y = aY; SetDirty(); } }
255 int GetSizeY() const { return m_padStack.Size().y; }
256
257 void SetDelta( const VECTOR2I& aSize ) { m_padStack.TrapezoidDeltaSize() = aSize; SetDirty(); }
258 const VECTOR2I& GetDelta() const { return m_padStack.TrapezoidDeltaSize(); }
259
260 void SetDrillSize( const VECTOR2I& aSize ) { m_padStack.Drill().size = aSize; SetDirty(); }
261 const VECTOR2I& GetDrillSize() const { return m_padStack.Drill().size; }
262 void SetDrillSizeX( const int aX ) { m_padStack.Drill().size.x = aX; SetDirty(); }
263 int GetDrillSizeX() const { return m_padStack.Drill().size.x; }
264 void SetDrillSizeY( const int aY ) { m_padStack.Drill().size.y = aY; SetDirty(); }
265 int GetDrillSizeY() const { return m_padStack.Drill().size.y; }
266
267 void SetOffset( const VECTOR2I& aOffset ) { m_padStack.Offset() = aOffset; SetDirty(); }
268 const VECTOR2I& GetOffset() const { return m_padStack.Offset(); }
269
270 VECTOR2I GetCenter() const override { return GetPosition(); }
271
272 const PADSTACK& Padstack() const { return m_padStack; }
274 void SetPadstack( const PADSTACK& aPadstack ) { m_padStack = aPadstack; }
275
287 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
288 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
289
301 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
302 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
303
308
312 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
313 {
314 return m_editPrimitives;
315 }
316
317 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
318
323 void FlipPrimitives( bool aFlipLeftRight );
324
329 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
330
335 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
336
340 void AddPrimitive( PCB_SHAPE* aPrimitive );
341
347 void SetOrientation( const EDA_ANGLE& aAngle );
348 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
349
355
356 // For property system
357 void SetOrientationDegrees( double aOrientation )
358 {
359 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
360 }
362 {
363 return m_orient.AsDegrees();
364 }
365
367 {
368 m_padStack.Drill().shape = aShape;
369 m_shapesDirty = true;
370 }
372
373 bool IsDirty() const
374 {
376 }
377
378 void SetDirty()
379 {
380 m_shapesDirty = true;
383 }
384
385 void SetLayerSet( LSET aLayers ) override { m_padStack.SetLayerSet( aLayers ); }
386 LSET GetLayerSet() const override { return m_padStack.LayerSet(); }
387
388 void SetAttribute( PAD_ATTRIB aAttribute );
390
391 void SetProperty( PAD_PROP aProperty );
392 PAD_PROP GetProperty() const { return m_property; }
393
394 // We don't currently have an attribute for APERTURE, and adding one will change the file
395 // format, so for now just infer a copper-less pad to be an APERTURE pad.
396 bool IsAperturePad() const
397 {
398 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).none();
399 }
400
401 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
402 int GetPadToDieLength() const { return m_lengthPadToDie; }
403
404 std::optional<int> GetLocalClearance() const override { return m_padStack.Clearance(); }
405 void SetLocalClearance( std::optional<int> aClearance ) { m_padStack.Clearance() = aClearance; }
406
407 std::optional<int> GetLocalSolderMaskMargin() const { return m_padStack.SolderMaskMargin(); }
408 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
409 {
410 m_padStack.SolderMaskMargin() = aMargin;
411 }
412
413 std::optional<int> GetLocalSolderPasteMargin() const { return m_padStack.SolderPasteMargin(); }
414 void SetLocalSolderPasteMargin( std::optional<int> aMargin )
415 {
416 m_padStack.SolderPasteMargin() = aMargin;
417 }
418
419 std::optional<double> GetLocalSolderPasteMarginRatio() const
420 {
422 }
423 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio )
424 {
426 }
427
430 {
431 return m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
432 }
433
441 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
442
452 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
453 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
454 bool ignoreLineWidth = false ) const override;
455
465 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
466 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
467
483 virtual std::shared_ptr<SHAPE>
485 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
486
487 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
488
492 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
493
499 int GetBoundingRadius() const;
500
507 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
508
515 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
516
527 int GetSolderMaskExpansion() const;
528
541
542 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
543
548 void SetThermalSpokeWidth( int aWidth ) { m_padStack.ThermalSpokeWidth() = aWidth; }
549 int GetThermalSpokeWidth() const { return m_padStack.ThermalSpokeWidth().value_or( 0 ); }
550
551 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
552
558 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle )
559 {
561 }
563 {
565 }
566
567 // For property system
568 void SetThermalSpokeAngleDegrees( double aAngle )
569 {
571 }
573 {
575 }
576
577 void SetThermalGap( int aGap ) { m_padStack.ThermalGap() = aGap; }
578 int GetThermalGap() const { return m_padStack.ThermalGap().value_or( 0 ); }
579
580 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
581
587 void SetRoundRectCornerRadius( double aRadius );
588 int GetRoundRectCornerRadius() const;
589
590 VECTOR2I ShapePos() const;
591
598 void SetRoundRectRadiusRatio( double aRadiusScale );
600
607 void SetChamferRectRatio( double aChamferScale );
608 double GetChamferRectRatio() const { return m_padStack.ChamferRatio(); }
609
617 void SetChamferPositions( int aPositions ) { m_padStack.SetChamferPositions( aPositions ); }
619
623 int GetSubRatsnest() const { return m_subRatsnest; }
624 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
625
631 void SetRemoveUnconnected( bool aSet )
632 {
636 }
637
639 {
641 }
642
647 void SetKeepTopBottom( bool aSet )
648 {
652 }
653
654 bool GetKeepTopBottom() const
655 {
658 }
659
661 {
663 }
664
666 {
668 }
669
671 {
673 {
675 return false;
676
678 return true;
679
681 {
682 if( aLayer == m_padStack.Drill().start || aLayer == m_padStack.Drill().end )
683 return false;
684 }
685 }
686
687 return true;
688 }
689
690 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
691
692 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
693 {
694 return m_padStack.LayerSet().test( aLayer );
695 }
696
705 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
706
707 bool CanFlashLayer( int aLayer )
708 {
709 return FlashLayer( aLayer, true );
710 }
711
712 PCB_LAYER_ID GetLayer() const override;
713
718
726 bool FlashLayer( LSET aLayers ) const;
727
728 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
729 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
730
731 wxString GetClass() const override
732 {
733 return wxT( "PAD" );
734 }
735
739 const BOX2I GetBoundingBox() const override;
740
747 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
748
749 void Move( const VECTOR2I& aMoveVector ) override
750 {
751 m_pos += aMoveVector;
752 SetDirty();
753 }
754
755 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
756
757 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
758
759 BITMAPS GetMenuImage() const override;
760
764 wxString ShowPadShape() const;
765
769 wxString ShowPadAttr() const;
770
771 EDA_ITEM* Clone() const override;
772
778 PAD* ClonePad() const
779 {
780 return (PAD*) Clone();
781 }
782
787 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
788 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
789
790 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
791
792 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
793
794 virtual const BOX2I ViewBBox() const override;
795
797 {
799 }
800
802 {
803 return m_zoneLayerOverrides.at( aLayer );
804 }
805
807 {
808 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
809 m_zoneLayerOverrides.at( aLayer ) = aOverride;
810 }
811
812 double Similarity( const BOARD_ITEM& aOther ) const override;
813
814 bool operator==( const BOARD_ITEM& aOther ) const override;
815 bool operator!=( const BOARD_ITEM& aOther ) const { return !operator==( aOther ); }
816
817#if defined(DEBUG)
818 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
819#endif
820
821protected:
822 virtual void swapData( BOARD_ITEM* aImage ) override;
823
824private:
825 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
826 ERROR_LOC aErrorLoc ) const;
827
828private:
829 wxString m_number; // Pad name (pin number in schematic)
830 wxString m_pinFunction; // Pin name in schematic
831 wxString m_pinType; // Pin electrical type in schematic
832
833 VECTOR2I m_pos; // Pad Position on board
834
836 /*
837 * Editing definitions of primitives for custom pad shapes. In local coordinates relative
838 * to m_Pos (NOT shapePos) at orient 0.
839 */
840 std::vector<std::shared_ptr<PCB_SHAPE>> m_editPrimitives;
841
842 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
843 mutable bool m_shapesDirty;
844 mutable std::mutex m_shapesBuildingLock;
846 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
847 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
848
849 mutable bool m_polyDirty[2];
850 mutable std::mutex m_polyBuildingLock;
851 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon[2];
853
854 int m_subRatsnest; // Variable used to handle subnet (block) number in
855 // ratsnest computations
856
857 PAD_ATTRIB m_attribute = PAD_ATTRIB::PTH;
858
859 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
860
862
863 int m_lengthPadToDie; // Length net from pad to die, inside the package
864
866 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
867};
868
869#endif // PAD_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
Definition: board_item.h:64
@ ZLO_NONE
Definition: board_item.h:65
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
double AsDegrees() const
Definition: eda_angle.h:155
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:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:175
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:575
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition: padstack.h:115
CUSTOM_SHAPE_ZONE_MODE CustomShapeInZoneMode() const
Definition: padstack.h:262
void SetCustomShapeInZoneMode(CUSTOM_SHAPE_ZONE_MODE aM)
Definition: padstack.h:263
std::optional< int > & Clearance(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:281
void SetChamferPositions(int aPositions, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:275
std::optional< double > & SolderPasteMarginRatio(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:317
void SetAnchorShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:204
void SetThermalSpokeAngle(EDA_ANGLE aAngle, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:377
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:254
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:341
std::optional< int > & SolderPasteMargin(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:305
std::optional< int > & SolderMaskMargin(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:293
const LSET & LayerSet() const
Definition: padstack.h:240
PAD_SHAPE AnchorShape(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:198
EDA_ANGLE ThermalSpokeAngle(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:365
int & ChamferPositions(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:263
UNCONNECTED_LAYER_MODE UnconnectedLayerMode() const
Definition: padstack.h:253
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:353
DRILL_PROPS & Drill()
Definition: padstack.h:247
double RoundRectRadiusRatio(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:222
VECTOR2I & TrapezoidDeltaSize(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:210
CUSTOM_SHAPE_ZONE_MODE
Definition: padstack.h:142
VECTOR2I & Offset(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:186
VECTOR2I & Size(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:162
UNCONNECTED_LAYER_MODE
! Whether or not to remove the copper shape for unconnected layers
Definition: padstack.h:135
double ChamferRatio(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:251
PAD_SHAPE Shape(PCB_LAYER_ID aLayer=F_Cu) const
Definition: padstack.cpp:150
void SetLayerSet(const LSET &aSet)
Definition: padstack.h:242
std::optional< ZONE_CONNECTION > & ZoneConnection(PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:329
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer=F_Cu)
Definition: padstack.cpp:156
Definition: pad.h:53
bool IsAperturePad() const
Definition: pad.h:396
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:771
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition: pad.cpp:998
void SetLayerSet(LSET aLayers) override
Definition: pad.h:385
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1775
PAD_PROP GetProperty() const
Definition: pad.h:392
bool GetRemoveUnconnected() const
Definition: pad.h:638
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pad.cpp:133
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:986
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:144
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:386
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:801
int GetSizeX() const
Definition: pad.h:253
void AppendPrimitives(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.
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition: pad.cpp:383
bool IsDirty() const
Definition: pad.h:373
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:1152
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:762
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:692
int GetSolderMaskExpansion() const
Definition: pad.cpp:1024
int GetDrillSizeY() const
Definition: pad.h:265
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition: pad.h:419
const wxString & GetPinType() const
Definition: pad.h:145
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:806
const VECTOR2I & GetDrillSize() const
Definition: pad.h:261
PAD_ATTRIB GetAttribute() const
Definition: pad.h:389
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:312
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1334
void SetUnconnectedLayerMode(PADSTACK::UNCONNECTED_LAYER_MODE aMode)
Definition: pad.h:660
void SetRemoveUnconnected(bool aSet)
Definition: pad.h:631
const wxString & GetPinFunction() const
Definition: pad.h:139
void BuildEffectiveShapes(PCB_LAYER_ID aLayer) const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition: pad.cpp:543
std::mutex m_shapesBuildingLock
Definition: pad.h:844
void SetThermalGap(int aGap)
Definition: pad.h:577
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon[2]
Definition: pad.h:851
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:259
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:558
wxString m_pinType
Definition: pad.h:831
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pad.cpp:193
const wxString & GetNumber() const
Definition: pad.h:128
EDA_ANGLE m_orient
Definition: pad.h:861
void FlipPrimitives(bool aFlipLeftRight)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
Definition: pad.cpp:914
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
int GetRoundRectCornerRadius() const
Definition: pad.cpp:451
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:77
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
Definition: pad.h:840
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition: pad.h:423
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:116
void DeletePrimitivesList()
Clear the basic shapes list.
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:847
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1465
bool IsLocked() const override
Definition: pad.cpp:273
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:270
VECTOR2I GetPosition() const override
Definition: pad.h:195
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:819
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:568
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:312
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:562
bool operator==(const BOARD_ITEM &aOther) const override
Definition: pad.cpp:1904
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:670
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:267
PAD_ATTRIB m_attribute
Definition: pad.h:857
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:749
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:361
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:471
bool operator!=(const BOARD_ITEM &aOther) const
Definition: pad.h:815
void SetDirty()
Definition: pad.h:378
const VECTOR2I & GetOffset() const
Definition: pad.h:268
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:333
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1518
double GetOrientationDegrees() const
Definition: pad.h:361
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:151
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1425
PADSTACK m_padStack
Definition: pad.h:835
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:457
bool IsNoConnectPad() const
Definition: pad.cpp:299
int GetDrillSizeX() const
Definition: pad.h:263
PAD_PROP m_property
Definition: pad.h:859
void SetKeepTopBottom(bool aSet)
Definition: pad.h:647
VECTOR2I ShapePos() const
Definition: pad.cpp:923
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:1800
PADSTACK & Padstack()
Definition: pad.h:273
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:127
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1143
wxString ShowPadAttr() const
Definition: pad.cpp:1452
wxString m_pinFunction
Definition: pad.h:830
wxString ShowPadShape() const
Definition: pad.cpp:1436
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition: pad.h:366
int m_effectiveBoundingRadius
Definition: pad.h:852
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pad.h:408
bool GetKeepTopBottom() const
Definition: pad.h:654
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:479
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:428
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.h:404
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1683
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:1996
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:257
bool IsOnCopperLayer() const override
Definition: pad.cpp:938
void SetDrillSizeX(const int aX)
Definition: pad.h:262
void SetPadstack(const PADSTACK &aPadstack)
Definition: pad.h:274
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:189
const PADSTACK & Padstack() const
Definition: pad.h:272
VECTOR2I m_pos
Definition: pad.h:833
const VECTOR2I & GetDelta() const
Definition: pad.h:258
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:719
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:326
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:260
bool IsFreePad() const
Definition: pad.cpp:305
wxString GetClass() const override
Return the class name.
Definition: pad.h:731
PAD_SHAPE GetShape() const
Definition: pad.h:187
bool CanFlashLayer(int aLayer)
Definition: pad.h:707
int m_subRatsnest
Definition: pad.h:854
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:353
PADSTACK::CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition: pad.h:208
PAD_DRILL_SHAPE GetDrillShape() const
Definition: pad.h:371
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:854
void SetY(int y)
Definition: pad.h:242
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:1061
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:340
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1659
bool m_shapesDirty
Definition: pad.h:843
std::mutex m_polyBuildingLock
Definition: pad.h:850
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:319
std::optional< int > GetLocalSolderPasteMargin() const
Definition: pad.h:413
void SetX(int x)
Definition: pad.h:243
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pad.h:407
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition: pad.h:414
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:178
int GetSizeY() const
Definition: pad.h:255
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:355
int GetThermalSpokeWidth() const
Definition: pad.h:549
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:138
EDA_ANGLE GetFPRelativeOrientation() const
Definition: pad.cpp:845
bool m_polyDirty[2]
Definition: pad.h:849
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:1280
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition: pad.cpp:836
void SetCustomShapeInZoneOpt(PADSTACK::CUSTOM_SHAPE_ZONE_MODE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition: pad.h:218
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:534
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:463
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:229
void ClearZoneLayerOverrides()
Definition: pad.h:796
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:866
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition: pad.cpp:827
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:865
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
PADSTACK::UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition: pad.h:665
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1512
int GetChamferPositions() const
Definition: pad.h:618
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: pad.cpp:1524
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
wxString m_number
Definition: pad.h:829
void SetLocalClearance(std::optional< int > aClearance)
Definition: pad.h:405
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:488
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:623
void SetSizeX(const int aX)
Definition: pad.h:252
ZONE_CONNECTION GetLocalZoneConnection() const
Definition: pad.h:429
int m_lengthPadToDie
Definition: pad.h:863
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:548
bool HasHole() const override
Definition: pad.h:103
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:245
void SetDrillSizeY(const int aY)
Definition: pad.h:264
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:572
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:778
double GetRoundRectRadiusRatio() const
Definition: pad.h:599
int GetThermalGap() const
Definition: pad.h:578
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:525
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:357
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition: pad.cpp:1114
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:282
const VECTOR2I & GetSize() const
Definition: pad.h:250
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1590
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:624
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:846
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:617
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1134
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:200
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:1783
double GetChamferRectRatio() const
Definition: pad.h:608
void SetPadToDieLength(int aLength)
Definition: pad.h:401
bool IsFlipped() const
Definition: pad.cpp:347
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:82
void SetSizeY(const int aY)
Definition: pad.h:254
int GetPadToDieLength() const
Definition: pad.h:402
BOX2I m_effectiveBoundingBox
Definition: pad.h:845
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition: shape.h:126
@ DEGREES_T
Definition: eda_angle.h:31
a few functions useful in geometry calculations.
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
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:149
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:61
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: padstack.h:72
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: padstack.h:44
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: padstack.h:89
PCB_LAYER_ID start
Definition: padstack.h:222
PCB_LAYER_ID end
Definition: padstack.h:223
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
Definition: padstack.h:220
PAD_DRILL_SHAPE shape
Definition: padstack.h:221
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_LOCATE_NPTH_T
Definition: typeinfo.h:129
@ PCB_LOCATE_PTH_T
Definition: typeinfo.h:128
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_LOCATE_HOLE_T
Definition: typeinfo.h:127
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:47