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 <pad_shapes.h>
35#include <geometry/eda_angle.h>
37#include <core/arraydim.h>
38
39class PCB_SHAPE;
40class SHAPE;
41class SHAPE_SEGMENT;
42
44{
47};
48
49class LINE_READER;
50class EDA_3D_CANVAS;
51class FOOTPRINT;
52
53namespace KIGFX
54{
55 class VIEW;
56}
57
59{
60public:
61 PAD( FOOTPRINT* parent );
62
63 // Copy constructor & operator= are needed because the list of basic shapes
64 // must be duplicated in copy.
65 PAD( const PAD& aPad );
66 PAD& operator=( const PAD &aOther );
67
68 void Serialize( google::protobuf::Any &aContainer ) const override;
69 bool Deserialize( const google::protobuf::Any &aContainer ) override;
70
71 /*
72 * Default layers used for pads, according to the pad type.
73 *
74 * This is default values only, they can be changed for a given pad.
75 */
76 static LSET PTHMask();
77 static LSET SMDMask();
78 static LSET ConnSMDMask();
80 static LSET UnplatedHoleMask();
81 static LSET ApertureMask();
82
83 static inline bool ClassOf( const EDA_ITEM* aItem )
84 {
85 return aItem && PCB_PAD_T == aItem->Type();
86 }
87
88 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
89 {
90 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
91 return true;
92
93 for( KICAD_T scanType : aScanTypes )
94 {
95 if( HasHole() )
96 {
97 if( scanType == PCB_LOCATE_HOLE_T )
98 return true;
99 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
100 return true;
101 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
102 return true;
103 }
104 }
105
106 return false;
107 }
108
109 bool HasHole() const override
110 {
111 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
112 }
113
114 bool IsLocked() const override;
115
123 void ImportSettingsFrom( const PAD& aMasterPad );
124
128 bool IsFlipped() const;
129
133 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
134 const wxString& GetNumber() const { return m_number; }
135
139 bool CanHaveNumber() const;
140
144 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
145 const wxString& GetPinFunction() const { return m_pinFunction; }
146
150 void SetPinType( const wxString& aType ) { m_pinType = aType; }
151 const wxString& GetPinType() const { return m_pinType; }
152
157 bool SameLogicalPadAs( const PAD* aOther ) const
158 {
159 // hide tricks behind sensible API
160 return GetParentFootprint() == aOther->GetParentFootprint()
161 && !m_number.IsEmpty() && m_number == aOther->m_number;
162 }
163
167 bool SharesNetTieGroup( const PAD* aOther ) const;
168
173 bool IsNoConnectPad() const;
174
179 bool IsFreePad() const;
180
184 void SetShape( PAD_SHAPE aShape )
185 {
186 m_padShape = aShape;
187 SetDirty();
188 }
189
193 PAD_SHAPE GetShape() const { return m_padShape; }
194
195 void SetPosition( const VECTOR2I& aPos ) override
196 {
197 m_pos = aPos;
198 SetDirty();
199 }
200
201 VECTOR2I GetPosition() const override { return m_pos; }
202
207
212 {
214 }
215
222 {
224 }
225
233 {
234 m_anchorPadShape = ( aShape == PAD_SHAPE::RECTANGLE ) ? PAD_SHAPE::RECTANGLE : PAD_SHAPE::CIRCLE;
235 SetDirty();
236 }
237
241 bool IsOnCopperLayer() const override;
242
243 void SetY( int y ) { m_pos.y = y; SetDirty(); }
244 void SetX( int x ) { m_pos.x = x; SetDirty(); }
245
246 void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); }
247 const VECTOR2I& GetSize() const { return m_size; }
248 void SetSizeX( const int aX ) { if( aX > 0 ) { m_size.x = aX; SetDirty(); } }
249 int GetSizeX() const { return m_size.x; }
250 void SetSizeY( const int aY ) { if( aY > 0 ) { m_size.y = aY; SetDirty(); } }
251 int GetSizeY() const { return m_size.y; }
252
253 void SetDelta( const VECTOR2I& aSize ) { m_deltaSize = aSize; SetDirty(); }
254 const VECTOR2I& GetDelta() const { return m_deltaSize; }
255
256 void SetDrillSize( const VECTOR2I& aSize ) { m_drill = aSize; SetDirty(); }
257 const VECTOR2I& GetDrillSize() const { return m_drill; }
258 void SetDrillSizeX( const int aX ) { m_drill.x = aX; SetDirty(); }
259 int GetDrillSizeX() const { return m_drill.x; }
260 void SetDrillSizeY( const int aY ) { m_drill.y = aY; SetDirty(); }
261 int GetDrillSizeY() const { return m_drill.y; }
262
263 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; SetDirty(); }
264 const VECTOR2I& GetOffset() const { return m_offset; }
265
266 VECTOR2I GetCenter() const override { return GetPosition(); }
267
279 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
280 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
281
293 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
294 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
295
300
304 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
305 {
306 return m_editPrimitives;
307 }
308
309 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
310
315 void FlipPrimitives( bool aFlipLeftRight );
316
321 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
322
327 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
328
332 void AddPrimitive( PCB_SHAPE* aPrimitive );
333
339 void SetOrientation( const EDA_ANGLE& aAngle );
340 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
341
347
348 // For property system
349 void SetOrientationDegrees( double aOrientation )
350 {
351 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
352 }
354 {
355 return m_orient.AsDegrees();
356 }
357
358 void SetDrillShape( PAD_DRILL_SHAPE_T aShape ) { m_drillShape = aShape; m_shapesDirty = true; }
360
361 bool IsDirty() const
362 {
364 }
365
366 void SetDirty()
367 {
368 m_shapesDirty = true;
371 }
372
373 void SetLayerSet( LSET aLayers ) override { m_layerMask = aLayers; }
374 LSET GetLayerSet() const override { return m_layerMask; }
375
376 void SetAttribute( PAD_ATTRIB aAttribute );
378
379 void SetProperty( PAD_PROP aProperty );
380 PAD_PROP GetProperty() const { return m_property; }
381
382 // We don't currently have an attribute for APERTURE, and adding one will change the file
383 // format, so for now just infer a copper-less pad to be an APERTURE pad.
384 bool IsAperturePad() const
385 {
386 return ( m_layerMask & LSET::AllCuMask() ).none();
387 }
388
389 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
390 int GetPadToDieLength() const { return m_lengthPadToDie; }
391
392 std::optional<int> GetLocalClearance() const override { return m_clearance; }
393 void SetLocalClearance( std::optional<int> aClearance ) { m_clearance = aClearance; }
394
395 std::optional<int> GetLocalSolderMaskMargin() const { return m_solderMaskMargin; }
396 void SetLocalSolderMaskMargin( std::optional<int> aMargin ) { m_solderMaskMargin = aMargin; }
397
398 std::optional<int> GetLocalSolderPasteMargin() const { return m_solderPasteMargin; }
399 void SetLocalSolderPasteMargin( std::optional<int> aMargin ) { m_solderPasteMargin = aMargin; }
400
401 std::optional<double> GetLocalSolderPasteMarginRatio() const { return m_solderPasteMarginRatio; }
402 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio ) { m_solderPasteMarginRatio = aRatio; }
403
406
414 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
415
425 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
426 int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE,
427 bool ignoreLineWidth = false ) const override;
428
438 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
439 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
440
456 virtual std::shared_ptr<SHAPE>
458 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
459
460 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
461
465 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
466
472 int GetBoundingRadius() const;
473
480 std::optional<int> GetLocalClearance( wxString* aSource ) const override;
481
488 std::optional<int> GetClearanceOverrides( wxString* aSource ) const override;
489
500 int GetSolderMaskExpansion() const;
501
514
515 ZONE_CONNECTION GetZoneConnectionOverrides( wxString* aSource = nullptr ) const;
516
521 void SetThermalSpokeWidth( int aWidth ) { m_thermalSpokeWidth = aWidth; }
523
524 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
525
531 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle ) { m_thermalSpokeAngle = aAngle; }
533
534 // For property system
535 void SetThermalSpokeAngleDegrees( double aAngle )
536 {
538 }
540 {
542 }
543
544 void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
545 int GetThermalGap() const { return m_thermalGap; }
546
547 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
548
554 void SetRoundRectCornerRadius( double aRadius );
555 int GetRoundRectCornerRadius() const;
556
557 VECTOR2I ShapePos() const;
558
565 void SetRoundRectRadiusRatio( double aRadiusScale );
567
574 void SetChamferRectRatio( double aChamferScale );
575 double GetChamferRectRatio() const { return m_chamferScale; }
576
584 void SetChamferPositions( int aPositions ) { m_chamferPositions = aPositions; }
586
590 int GetSubRatsnest() const { return m_subRatsnest; }
591 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
592
599 void SetRemoveUnconnected( bool aSet ) { m_removeUnconnectedLayer = aSet; }
601
605 void SetKeepTopBottom( bool aSet ) { m_keepTopBottomLayer = aSet; }
606 bool GetKeepTopBottom() const { return m_keepTopBottomLayer; }
607
609 {
611 return false;
612
613 if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) )
614 return false;
615
616 return true;
617 }
618
619 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
620
621 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
622 {
623 return m_layerMask[aLayer];
624 }
625
634 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
635
636 bool CanFlashLayer( int aLayer )
637 {
638 return FlashLayer( aLayer, true );
639 }
640
641 PCB_LAYER_ID GetLayer() const override;
642
647
655 bool FlashLayer( LSET aLayers ) const;
656
657 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
658 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
659
660 wxString GetClass() const override
661 {
662 return wxT( "PAD" );
663 }
664
668 const BOX2I GetBoundingBox() const override;
669
676 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
677
678 void Move( const VECTOR2I& aMoveVector ) override
679 {
680 m_pos += aMoveVector;
681 SetDirty();
682 }
683
684 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
685
686 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
687
688 BITMAPS GetMenuImage() const override;
689
693 wxString ShowPadShape() const;
694
698 wxString ShowPadAttr() const;
699
700 EDA_ITEM* Clone() const override;
701
707 PAD* ClonePad() const
708 {
709 return (PAD*) Clone();
710 }
711
716 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
717 void BuildEffectivePolygon( ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
718
719 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
720
721 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
722
723 virtual const BOX2I ViewBBox() const override;
724
726 {
728 }
729
731 {
732 return m_zoneLayerOverrides.at( aLayer );
733 }
734
736 {
737 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
738 m_zoneLayerOverrides.at( aLayer ) = aOverride;
739 }
740
741 double Similarity( const BOARD_ITEM& aOther ) const override;
742
743 bool operator==( const BOARD_ITEM& aOther ) const override;
744 bool operator!=( const BOARD_ITEM& aOther ) const { return !operator==( aOther ); }
745
746#if defined(DEBUG)
747 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
748#endif
749
750protected:
751 virtual void swapData( BOARD_ITEM* aImage ) override;
752
753private:
754 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
755 ERROR_LOC aErrorLoc ) const;
756
757private:
758 wxString m_number; // Pad name (pin number in schematic)
759 wxString m_pinFunction; // Pin name in schematic
760 wxString m_pinType; // Pin electrical type in schematic
761
762 VECTOR2I m_pos; // Pad Position on board
763
764 PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECTANGLE,
765 // PAD_SHAPE::OVAL, PAD_SHAPE::TRAPEZOID,
766 // PAD_SHAPE::ROUNDRECT, PAD_SHAPE::CHAMFERED_RECT,
767 // PAD_SHAPE::CUSTOM
768 /*
769 * Editing definitions of primitives for custom pad shapes. In local coordinates relative
770 * to m_Pos (NOT shapePos) at orient 0.
771 */
772 std::vector<std::shared_ptr<PCB_SHAPE>> m_editPrimitives;
773
774 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
775 mutable bool m_shapesDirty;
776 mutable std::mutex m_shapesBuildingLock;
778 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
779 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
780
781 mutable bool m_polyDirty[2];
782 mutable std::mutex m_polyBuildingLock;
783 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon[2];
785
786 int m_subRatsnest; // Variable used to handle subnet (block) number in
787 // ratsnest computations
788
789 VECTOR2I m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
790 VECTOR2I m_size; // X and Y size (relative to orient 0)
791
792 PAD_DRILL_SHAPE_T m_drillShape; // PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG
793
794 double m_roundedCornerScale; // Scaling factor of min(width, height) to corner
795 // radius, default 0.25
796 double m_chamferScale; // Scaling factor of min(width, height) to chamfer
797 // size, default 0.25
798 int m_chamferPositions; // The positions of the chamfers (at orient 0)
799
800 PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
801 // PAD_SHAPE::RECTANGLE, PAD_SHAPE::CIRCLE
802
803 /*
804 * Most of the time the hole is the center of the shape (m_Offset = 0). But some designers
805 * use oblong/rect pads with a hole moved to one of the oblong/rect pad shape ends.
806 * In all cases the hole is at the pad position. This offset is from the hole to the center
807 * of the pad shape (ie: the copper area around the hole).
808 * ShapePos() returns the board shape position according to the offset and the pad rotation.
809 */
811
812 LSET m_layerMask; // Bitwise layer: 1 = copper layer, 15 = cmp,
813 // 2..14 = internal layers, 16..31 = technical layers
814
815 VECTOR2I m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
816 // one end and half expands the other. It is only valid
817 // to have a single axis be non-0.
818
819 PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
820 // PAD_ATTRIB::NPTH
821 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
822
824
825 int m_lengthPadToDie; // Length net from pad to die, inside the package
826
829
832
833 /*
834 * Pad clearances, margins, etc. exist in a hierarchy. If a given level is specified then
835 * the remaining levels are NOT consulted.
836 *
837 * LEVEL 1: (highest priority) local overrides (pad, footprint, etc.)
838 * LEVEL 2: Rules
839 * LEVEL 3: Accumulated local settings, netclass settings, & board design settings
840 *
841 * These are the LEVEL 1 settings (overrides) for a pad.
842 */
843 std::optional<int> m_clearance;
844 std::optional<int> m_solderMaskMargin; // Solder mask margin
845 std::optional<int> m_solderPasteMargin; // Solder paste margin absolute value
846 std::optional<double> m_solderPasteMarginRatio; // Solder mask margin ratio of pad size
847 // The final margin is the sum of these 2 values
848
849 /*
850 * How to build the custom shape in zone, to create the clearance area:
851 * CUST_PAD_SHAPE_IN_ZONE_OUTLINE = use pad shape
852 * CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL = use the convex hull of the pad shape
853 */
855
856 ZONE_CONNECTION m_zoneConnection; // No connection, thermal relief, etc.
857 int m_thermalSpokeWidth; // Thermal spoke width.
858 EDA_ANGLE m_thermalSpokeAngle; // Rotation of the spokes. 45° will produce an X,
859 // while 90° will produce a +.
861
863 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
864};
865
866#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
Definition: pad.h:59
PAD_DRILL_SHAPE_T m_drillShape
Definition: pad.h:792
bool IsAperturePad() const
Definition: pad.h:384
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:805
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition: pad.cpp:1012
void SetLayerSet(LSET aLayers) override
Definition: pad.h:373
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1773
PAD_PROP GetProperty() const
Definition: pad.h:380
bool GetRemoveUnconnected() const
Definition: pad.h:600
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:359
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pad.cpp:142
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:1000
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:150
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:374
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
Definition: pad.h:854
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:730
int GetSizeX() const
Definition: pad.h:249
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:420
VECTOR2I m_size
Definition: pad.h:790
bool IsDirty() const
Definition: pad.h:361
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:1166
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:796
VECTOR2I m_drill
Definition: pad.h:789
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:621
int GetSolderMaskExpansion() const
Definition: pad.cpp:1038
int m_chamferPositions
Definition: pad.h:798
VECTOR2I m_offset
Definition: pad.h:810
int GetDrillSizeY() const
Definition: pad.h:261
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition: pad.h:401
const wxString & GetPinType() const
Definition: pad.h:151
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:735
const VECTOR2I & GetDrillSize() const
Definition: pad.h:257
PAD_ATTRIB GetAttribute() const
Definition: pad.h:377
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:349
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1345
VECTOR2I m_deltaSize
Definition: pad.h:815
void SetRemoveUnconnected(bool aSet)
Set the unconnected removal property.
Definition: pad.h:599
const wxString & GetPinFunction() const
Definition: pad.h:145
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:578
std::mutex m_shapesBuildingLock
Definition: pad.h:776
void SetThermalGap(int aGap)
Definition: pad.h:544
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon[2]
Definition: pad.h:783
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:296
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:531
wxString m_pinType
Definition: pad.h:760
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pad.cpp:214
double m_roundedCornerScale
Definition: pad.h:794
const wxString & GetNumber() const
Definition: pad.h:134
EDA_ANGLE m_orient
Definition: pad.h:823
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:935
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:483
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:83
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
Definition: pad.h:772
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition: pad.h:402
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:123
void DeletePrimitivesList()
Clear the basic shapes list.
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:779
std::optional< int > m_solderMaskMargin
Definition: pad.h:844
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1461
bool IsLocked() const override
Definition: pad.cpp:310
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:266
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
Definition: pad.h:358
VECTOR2I GetPosition() const override
Definition: pad.h:201
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:844
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:535
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:304
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:532
bool operator==(const BOARD_ITEM &aOther) const override
Definition: pad.cpp:1902
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:608
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:263
PAD_ATTRIB m_attribute
Definition: pad.h:819
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:678
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:398
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:506
bool operator!=(const BOARD_ITEM &aOther) const
Definition: pad.h:744
void SetDirty()
Definition: pad.h:366
const VECTOR2I & GetOffset() const
Definition: pad.h:264
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:370
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1514
double GetOrientationDegrees() const
Definition: pad.h:353
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:157
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1421
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:489
bool IsNoConnectPad() const
Definition: pad.cpp:336
int GetDrillSizeX() const
Definition: pad.h:259
PAD_PROP m_property
Definition: pad.h:821
void SetKeepTopBottom(bool aSet)
Set whether we keep the top and bottom connections even if they are not connected.
Definition: pad.h:605
VECTOR2I ShapePos() const
Definition: pad.cpp:944
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:1798
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:133
std::optional< int > m_solderPasteMargin
Definition: pad.h:845
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1157
wxString ShowPadAttr() const
Definition: pad.cpp:1448
wxString m_pinFunction
Definition: pad.h:759
wxString ShowPadShape() const
Definition: pad.cpp:1432
int m_effectiveBoundingRadius
Definition: pad.h:784
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pad.h:396
LSET m_layerMask
Definition: pad.h:812
bool GetKeepTopBottom() const
Definition: pad.h:606
int m_thermalGap
Definition: pad.h:860
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:514
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:404
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:211
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.h:392
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1679
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:1994
ZONE_CONNECTION m_zoneConnection
Definition: pad.h:856
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:253
bool IsOnCopperLayer() const override
Definition: pad.cpp:959
void SetDrillSizeX(const int aX)
Definition: pad.h:258
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:195
int m_thermalSpokeWidth
Definition: pad.h:857
VECTOR2I m_pos
Definition: pad.h:762
const VECTOR2I & GetDelta() const
Definition: pad.h:254
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:753
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:363
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:256
bool IsFreePad() const
Definition: pad.cpp:342
wxString GetClass() const override
Return the class name.
Definition: pad.h:660
PAD_SHAPE GetShape() const
Definition: pad.h:193
bool CanFlashLayer(int aLayer)
Definition: pad.h:636
int m_subRatsnest
Definition: pad.h:786
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:345
EDA_ANGLE GetFPRelativeOrientation()
Definition: pad.cpp:870
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:879
void SetY(int y)
Definition: pad.h:243
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:1075
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:377
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1655
bool m_shapesDirty
Definition: pad.h:775
std::mutex m_polyBuildingLock
Definition: pad.h:782
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:356
std::optional< int > GetLocalSolderPasteMargin() const
Definition: pad.h:398
void SetX(int x)
Definition: pad.h:244
double m_chamferScale
Definition: pad.h:796
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pad.h:395
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition: pad.h:399
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:184
int GetSizeY() const
Definition: pad.h:251
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:392
int GetThermalSpokeWidth() const
Definition: pad.h:522
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:144
bool m_polyDirty[2]
Definition: pad.h:781
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:1291
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition: pad.cpp:861
std::optional< int > m_clearance
Definition: pad.h:843
PAD_SHAPE m_padShape
Definition: pad.h:764
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:569
void SetCustomShapeInZoneOpt(CUST_PAD_SHAPE_IN_ZONE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition: pad.h:221
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:498
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:232
void ClearZoneLayerOverrides()
Definition: pad.h:725
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:863
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:852
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:862
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1508
int GetChamferPositions() const
Definition: pad.h:585
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:1520
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:758
std::optional< double > m_solderPasteMarginRatio
Definition: pad.h:846
bool m_removeUnconnectedLayer
< If true, the pad copper is removed for layers that are not connected.
Definition: pad.h:828
void SetLocalClearance(std::optional< int > aClearance)
Definition: pad.h:393
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:523
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:590
void SetSizeX(const int aX)
Definition: pad.h:248
bool m_keepTopBottomLayer
Definition: pad.h:831
ZONE_CONNECTION GetLocalZoneConnection() const
Definition: pad.h:405
int m_lengthPadToDie
Definition: pad.h:825
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:521
bool HasHole() const override
Definition: pad.h:109
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:246
void SetDrillSizeY(const int aY)
Definition: pad.h:260
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:539
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:707
double GetRoundRectRadiusRatio() const
Definition: pad.h:566
int GetThermalGap() const
Definition: pad.h:545
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:560
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:349
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition: pad.cpp:1128
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:319
const VECTOR2I & GetSize() const
Definition: pad.h:247
PAD_SHAPE m_anchorPadShape
Definition: pad.h:800
EDA_ANGLE m_thermalSpokeAngle
Definition: pad.h:858
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1586
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:591
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:778
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:584
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:1148
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:206
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:1781
double GetChamferRectRatio() const
Definition: pad.h:575
void SetPadToDieLength(int aLength)
Definition: pad.h:389
bool IsFlipped() const
Definition: pad.cpp:384
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:88
void SetSizeY(const int aY)
Definition: pad.h:250
int GetPadToDieLength() const
Definition: pad.h:390
BOX2I m_effectiveBoundingBox
Definition: pad.h:777
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
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
CUST_PAD_SHAPE_IN_ZONE
Definition: pad.h:44
@ CUST_PAD_SHAPE_IN_ZONE_OUTLINE
Definition: pad.h:45
@ CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL
Definition: pad.h:46
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: pad_shapes.h:65
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:53
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: pad_shapes.h:35
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: pad_shapes.h:81
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