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-2023 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>
36#include <core/arraydim.h>
37
38class PCB_SHAPE;
39class SHAPE;
40class SHAPE_SEGMENT;
41
43{
46};
47
48class LINE_READER;
49class EDA_3D_CANVAS;
50class FOOTPRINT;
51
52namespace KIGFX
53{
54 class VIEW;
55}
56
58{
59public:
60 PAD( FOOTPRINT* parent );
61
62 // Copy constructor & operator= are needed because the list of basic shapes
63 // must be duplicated in copy.
64 PAD( const PAD& aPad );
65 PAD& operator=( const PAD &aOther );
66
67 /*
68 * Default layers used for pads, according to the pad type.
69 *
70 * This is default values only, they can be changed for a given pad.
71 */
72 static LSET PTHMask();
73 static LSET SMDMask();
74 static LSET ConnSMDMask();
76 static LSET UnplatedHoleMask();
77 static LSET ApertureMask();
78
79 static inline bool ClassOf( const EDA_ITEM* aItem )
80 {
81 return aItem && PCB_PAD_T == aItem->Type();
82 }
83
84 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
85 {
86 if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
87 return true;
88
89 for( KICAD_T scanType : aScanTypes )
90 {
91 if( HasHole() )
92 {
93 if( scanType == PCB_LOCATE_HOLE_T )
94 return true;
95 else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
96 return true;
97 else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
98 return true;
99 }
100 }
101
102 return false;
103 }
104
105 bool HasHole() const override
106 {
107 return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
108 }
109
110 bool IsLocked() const override;
111
119 void ImportSettingsFrom( const PAD& aMasterPad );
120
124 bool IsFlipped() const;
125
129 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
130 const wxString& GetNumber() const { return m_number; }
131
135 bool CanHaveNumber() const;
136
140 void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
141 const wxString& GetPinFunction() const { return m_pinFunction; }
142
146 void SetPinType( const wxString& aType ) { m_pinType = aType; }
147 const wxString& GetPinType() const { return m_pinType; }
148
153 bool SameLogicalPadAs( const PAD* aOther ) const
154 {
155 // hide tricks behind sensible API
156 return GetParentFootprint() == aOther->GetParentFootprint()
157 && !m_number.IsEmpty() && m_number == aOther->m_number;
158 }
159
163 bool SharesNetTieGroup( const PAD* aOther ) const;
164
169 bool IsNoConnectPad() const;
170
175 bool IsFreePad() const;
176
180 void SetShape( PAD_SHAPE aShape )
181 {
182 m_padShape = aShape;
183 SetDirty();
184 }
185
189 PAD_SHAPE GetShape() const { return m_padShape; }
190
191 void SetPosition( const VECTOR2I& aPos ) override
192 {
193 m_pos = aPos;
194 SetDirty();
195 }
196
197 VECTOR2I GetPosition() const override { return m_pos; }
198
203
208 {
210 }
211
218 {
220 }
221
229 {
230 m_anchorPadShape = ( aShape == PAD_SHAPE::RECTANGLE ) ? PAD_SHAPE::RECTANGLE : PAD_SHAPE::CIRCLE;
231 SetDirty();
232 }
233
237 bool IsOnCopperLayer() const override;
238
239 void SetY( int y ) { m_pos.y = y; SetDirty(); }
240 void SetX( int x ) { m_pos.x = x; SetDirty(); }
241
242 void SetSize( const VECTOR2I& aSize ) { m_size = aSize; SetDirty(); }
243 const VECTOR2I& GetSize() const { return m_size; }
244 void SetSizeX( const int aX ) { if( aX > 0 ) { m_size.x = aX; SetDirty(); } }
245 int GetSizeX() const { return m_size.x; }
246 void SetSizeY( const int aY ) { if( aY > 0 ) { m_size.y = aY; SetDirty(); } }
247 int GetSizeY() const { return m_size.y; }
248
249 void SetDelta( const VECTOR2I& aSize ) { m_deltaSize = aSize; SetDirty(); }
250 const VECTOR2I& GetDelta() const { return m_deltaSize; }
251
252 void SetDrillSize( const VECTOR2I& aSize ) { m_drill = aSize; SetDirty(); }
253 const VECTOR2I& GetDrillSize() const { return m_drill; }
254 void SetDrillSizeX( const int aX ) { m_drill.x = aX; SetDirty(); }
255 int GetDrillSizeX() const { return m_drill.x; }
256 void SetDrillSizeY( const int aY ) { m_drill.y = aY; SetDirty(); }
257 int GetDrillSizeY() const { return m_drill.y; }
258
259 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; SetDirty(); }
260 const VECTOR2I& GetOffset() const { return m_offset; }
261
262 VECTOR2I GetCenter() const override { return GetPosition(); }
263
275 void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
276 void AddPrimitivePoly( const std::vector<VECTOR2I>& aPoly, int aThickness, bool aFilled );
277
289 void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
290 ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
291
296
300 const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
301 {
302 return m_editPrimitives;
303 }
304
305 void Flip( const VECTOR2I& VECTOR2I, bool aFlipLeftRight ) override;
306
311 void FlipPrimitives( bool aFlipLeftRight );
312
317 void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
318
323 void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
324
328 void AddPrimitive( PCB_SHAPE* aPrimitive );
329
335 void SetOrientation( const EDA_ANGLE& aAngle );
336 void SetFPRelativeOrientation( const EDA_ANGLE& aAngle );
337
343
344 // For property system
345 void SetOrientationDegrees( double aOrientation )
346 {
347 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
348 }
350 {
351 return m_orient.AsDegrees();
352 }
353
354 void SetDrillShape( PAD_DRILL_SHAPE_T aShape ) { m_drillShape = aShape; m_shapesDirty = true; }
356
357 bool IsDirty() const
358 {
359 return m_shapesDirty || m_polyDirty;
360 }
361
362 void SetDirty()
363 {
364 m_shapesDirty = true;
365 m_polyDirty = true;
366 }
367
368 void SetLayerSet( LSET aLayers ) override { m_layerMask = aLayers; }
369 LSET GetLayerSet() const override { return m_layerMask; }
370
371 void SetAttribute( PAD_ATTRIB aAttribute );
373
374 void SetProperty( PAD_PROP aProperty );
375 PAD_PROP GetProperty() const { return m_property; }
376
377 // We don't currently have an attribute for APERTURE, and adding one will change the file
378 // format, so for now just infer a copper-less pad to be an APERTURE pad.
379 bool IsAperturePad() const
380 {
381 return ( m_layerMask & LSET::AllCuMask() ).none();
382 }
383
384 void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
385 int GetPadToDieLength() const { return m_lengthPadToDie; }
386
388 void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
389
390 int GetLocalClearance( wxString* aSource ) const override;
391 int GetLocalClearance() const { return m_localClearance; }
392 void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
393
395 void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
396
399
400 int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const override;
401
411 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
412 int aMaxError, ERROR_LOC aErrorLoc,
413 bool ignoreLineWidth = false ) const override;
414
424 bool TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
425 ERROR_LOC aErrorLoc ) const;
426
442 virtual std::shared_ptr<SHAPE>
444 FLASHING flashPTHPads = FLASHING::DEFAULT ) const override;
445
446 const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon() const;
447
451 std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
452
458 int GetBoundingRadius() const;
459
466 int GetLocalClearanceOverrides( wxString* aSource ) const override;
467
478 int GetSolderMaskExpansion() const;
479
492
495
496 ZONE_CONNECTION GetLocalZoneConnectionOverride( wxString* aSource = nullptr ) const;
497
502 void SetThermalSpokeWidth( int aWidth ) { m_thermalSpokeWidth = aWidth; }
504
505 int GetLocalSpokeWidthOverride( wxString* aSource = nullptr ) const;
506
512 void SetThermalSpokeAngle( const EDA_ANGLE& aAngle ) { m_thermalSpokeAngle = aAngle; }
514
515 // For property system
516 void SetThermalSpokeAngleDegrees( double aAngle )
517 {
519 }
521 {
523 }
524
525 void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
526 int GetThermalGap() const { return m_thermalGap; }
527
528 int GetLocalThermalGapOverride( wxString* aSource = nullptr ) const;
529
535 void SetRoundRectCornerRadius( double aRadius );
536 int GetRoundRectCornerRadius() const;
537
538 VECTOR2I ShapePos() const;
539
546 void SetRoundRectRadiusRatio( double aRadiusScale );
548
555 void SetChamferRectRatio( double aChamferScale );
556 double GetChamferRectRatio() const { return m_chamferScale; }
557
565 void SetChamferPositions( int aPositions ) { m_chamferPositions = aPositions; }
567
571 int GetSubRatsnest() const { return m_subRatsnest; }
572 void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
573
580 void SetRemoveUnconnected( bool aSet ) { m_removeUnconnectedLayer = aSet; }
582
586 void SetKeepTopBottom( bool aSet ) { m_keepTopBottomLayer = aSet; }
587 bool GetKeepTopBottom() const { return m_keepTopBottomLayer; }
588
590 {
592 return false;
593
594 if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) )
595 return false;
596
597 return true;
598 }
599
600 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
601
602 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
603 {
604 return m_layerMask[aLayer];
605 }
606
615 bool FlashLayer( int aLayer, bool aOnlyCheckIfPermitted = false ) const;
616
617 bool CanFlashLayer( int aLayer )
618 {
619 return FlashLayer( aLayer, true );
620 }
621
622 PCB_LAYER_ID GetLayer() const override;
623
628
636 bool FlashLayer( LSET aLayers ) const;
637
638 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
639 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
640
641 wxString GetClass() const override
642 {
643 return wxT( "PAD" );
644 }
645
649 const BOX2I GetBoundingBox() const override;
650
657 static int Compare( const PAD* aPadRef, const PAD* aPadCmp );
658
659 void Move( const VECTOR2I& aMoveVector ) override
660 {
661 m_pos += aMoveVector;
662 SetDirty();
663 }
664
665 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
666
667 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
668
669 BITMAPS GetMenuImage() const override;
670
674 wxString ShowPadShape() const;
675
679 wxString ShowPadAttr() const;
680
681 EDA_ITEM* Clone() const override;
682
688 PAD* ClonePad() const
689 {
690 return (PAD*) Clone();
691 }
692
697 void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
698 void BuildEffectivePolygon() const;
699
700 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
701
702 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
703
704 virtual const BOX2I ViewBBox() const override;
705
707 {
709 }
710
712 {
713 return m_zoneLayerOverrides.at( aLayer );
714 }
715
717 {
718 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
719 m_zoneLayerOverrides.at( aLayer ) = aOverride;
720 }
721
722#if defined(DEBUG)
723 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
724#endif
725
726protected:
727 virtual void swapData( BOARD_ITEM* aImage ) override;
728
729private:
730 void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
731 ERROR_LOC aErrorLoc ) const;
732
733private:
734 wxString m_number; // Pad name (pin number in schematic)
735 wxString m_pinFunction; // Pin name in schematic
736 wxString m_pinType; // Pin electrical type in schematic
737
738 VECTOR2I m_pos; // Pad Position on board
739
740 PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECTANGLE,
741 // PAD_SHAPE::OVAL, PAD_SHAPE::TRAPEZOID,
742 // PAD_SHAPE::ROUNDRECT, PAD_SHAPE::CHAMFERED_RECT,
743 // PAD_SHAPE::CUSTOM
744 /*
745 * Editing definitions of primitives for custom pad shapes. In local coordinates relative
746 * to m_Pos (NOT shapePos) at orient 0.
747 */
748 std::vector<std::shared_ptr<PCB_SHAPE>> m_editPrimitives;
749
750 // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
751 mutable bool m_shapesDirty;
752 mutable std::mutex m_shapesBuildingLock;
754 mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
755 mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
756
757 mutable bool m_polyDirty;
758 mutable std::mutex m_polyBuildingLock;
759 mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon;
761
762 int m_subRatsnest; // Variable used to handle subnet (block) number in
763 // ratsnest computations
764
765 VECTOR2I m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
766 VECTOR2I m_size; // X and Y size (relative to orient 0)
767
768 PAD_DRILL_SHAPE_T m_drillShape; // PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG
769
770 double m_roundedCornerScale; // Scaling factor of min(width, height) to corner
771 // radius, default 0.25
772 double m_chamferScale; // Scaling factor of min(width, height) to chamfer
773 // size, default 0.25
774 int m_chamferPositions; // The positions of the chamfers (at orient 0)
775
776 PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
777 // PAD_SHAPE::RECTANGLE, PAD_SHAPE::CIRCLE
778
779 /*
780 * Most of the time the hole is the center of the shape (m_Offset = 0). But some designers
781 * use oblong/rect pads with a hole moved to one of the oblong/rect pad shape ends.
782 * In all cases the hole is at the pad position. This offset is from the hole to the center
783 * of the pad shape (ie: the copper area around the hole).
784 * ShapePos() returns the board shape position according to the offset and the pad rotation.
785 */
787
788 LSET m_layerMask; // Bitwise layer: 1 = copper layer, 15 = cmp,
789 // 2..14 = internal layers, 16..31 = technical layers
790
791 VECTOR2I m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
792 // one end and half expands the other. It is only valid
793 // to have a single axis be non-0.
794
795 PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
796 // PAD_ATTRIB::NPTH
797 PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
798
800
801 int m_lengthPadToDie; // Length net from pad to die, inside the package
802
805
808
809 /*
810 * Pad clearances, margins, etc. exist in a hierarchy. If a given level is specified then
811 * the remaining levels are NOT consulted.
812 *
813 * LEVEL 1: (highest priority) local overrides (pad, footprint, etc.)
814 * LEVEL 2: Rules
815 * LEVEL 3: Accumulated local settings, netclass settings, & board design settings
816 *
817 * These are the LEVEL 1 settings for a pad.
818 */
820 int m_localSolderMaskMargin; // Local solder mask margin
821 int m_localSolderPasteMargin; // Local solder paste margin absolute value
822 double m_localSolderPasteMarginRatio; // Local solder mask margin ratio of pad size
823 // The final margin is the sum of these 2 values
824
825 /*
826 * How to build the custom shape in zone, to create the clearance area:
827 * CUST_PAD_SHAPE_IN_ZONE_OUTLINE = use pad shape
828 * CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL = use the convex hull of the pad shape
829 */
831
832 ZONE_CONNECTION m_zoneConnection; // No connection, thermal relief, etc.
833 int m_thermalSpokeWidth; // Thermal spoke width.
834 EDA_ANGLE m_thermalSpokeAngle; // Rotation of the spokes. 45° will produce an X,
835 // while 90° will produce a +.
837
839 std::array<ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS> m_zoneLayerOverrides;
840};
841
842#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:247
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
double AsDegrees() const
Definition: eda_angle.h:149
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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:172
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
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:552
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
Definition: pad.h:58
PAD_DRILL_SHAPE_T m_drillShape
Definition: pad.h:768
bool IsAperturePad() const
Definition: pad.h:379
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:645
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return an item's "own" clearance in internal units.
Definition: pad.cpp:826
void SetLayerSet(LSET aLayers) override
Definition: pad.h:368
int m_localClearance
Definition: pad.h:819
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pad.cpp:1553
PAD_PROP GetProperty() const
Definition: pad.h:375
bool GetRemoveUnconnected() const
Definition: pad.h:581
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:355
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:146
int m_localSolderMaskMargin
Definition: pad.h:820
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:369
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
Definition: pad.h:830
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:711
int GetSizeX() const
Definition: pad.h:245
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:265
VECTOR2I m_size
Definition: pad.h:766
bool IsDirty() const
Definition: pad.h:357
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:967
double m_localSolderPasteMarginRatio
Definition: pad.h:822
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:636
VECTOR2I m_drill
Definition: pad.h:765
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:602
int GetSolderMaskExpansion() const
Definition: pad.cpp:852
int m_chamferPositions
Definition: pad.h:774
VECTOR2I m_offset
Definition: pad.h:786
int GetDrillSizeY() const
Definition: pad.h:257
const wxString & GetPinType() const
Definition: pad.h:147
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pad.h:716
const VECTOR2I & GetDrillSize() const
Definition: pad.h:253
PAD_ATTRIB GetAttribute() const
Definition: pad.h:372
void SetLocalSolderPasteMargin(int aMargin)
Definition: pad.h:395
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:194
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1135
VECTOR2I m_deltaSize
Definition: pad.h:791
ZONE_CONNECTION GetZoneConnection() const
Definition: pad.h:494
void SetRemoveUnconnected(bool aSet)
Set the unconnected removal property.
Definition: pad.h:580
const wxString & GetPinFunction() const
Definition: pad.h:141
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:423
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition: pad.cpp:1578
std::mutex m_shapesBuildingLock
Definition: pad.h:752
void SetThermalGap(int aGap)
Definition: pad.h:525
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition: pad.cpp:141
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition: pad.h:512
wxString m_pinType
Definition: pad.h:736
double m_roundedCornerScale
Definition: pad.h:770
const wxString & GetNumber() const
Definition: pad.h:130
EDA_ANGLE m_orient
Definition: pad.h:799
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:747
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
double GetLocalSolderPasteMarginRatio() const
Definition: pad.h:397
int GetRoundRectCornerRadius() const
Definition: pad.cpp:328
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pad.h:79
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
Definition: pad.h:748
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:122
void DeletePrimitivesList()
Clear the basic shapes list.
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:755
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pad.cpp:1251
bool IsLocked() const override
Definition: pad.cpp:155
bool TransformHoleToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Build the corner list of the polygonal drill shape in the board coordinate system.
Definition: pad.cpp:1561
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pad.h:262
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
Definition: pad.h:354
VECTOR2I GetPosition() const override
Definition: pad.h:197
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:656
void SetThermalSpokeAngleDegrees(double aAngle)
Definition: pad.h:516
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:300
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:513
bool ConditionallyFlashed(PCB_LAYER_ID aLayer) const
Definition: pad.h:589
void SetOffset(const VECTOR2I &aOffset)
Definition: pad.h:259
PAD_ATTRIB m_attribute
Definition: pad.h:795
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pad.h:659
PCB_LAYER_ID GetPrincipalLayer() const
Definition: pad.cpp:243
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:351
void SetDirty()
Definition: pad.h:362
const VECTOR2I & GetOffset() const
Definition: pad.h:260
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:215
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1304
double GetOrientationDegrees() const
Definition: pad.h:349
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:153
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pad.cpp:1211
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:334
bool IsNoConnectPad() const
Definition: pad.cpp:181
int GetDrillSizeX() const
Definition: pad.h:255
void SetLocalClearance(int aClearance)
Definition: pad.h:392
PAD_PROP m_property
Definition: pad.h:797
void SetKeepTopBottom(bool aSet)
Set whether we keep the top and bottom connections even if they are not connected.
Definition: pad.h:586
VECTOR2I ShapePos() const
Definition: pad.cpp:756
int m_localSolderPasteMargin
Definition: pad.h:821
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:129
int GetLocalThermalGapOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:958
wxString ShowPadAttr() const
Definition: pad.cpp:1238
wxString m_pinFunction
Definition: pad.h:735
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:493
wxString ShowPadShape() const
Definition: pad.cpp:1222
int m_effectiveBoundingRadius
Definition: pad.h:760
int GetLocalSolderMaskMargin() const
Definition: pad.h:387
LSET m_layerMask
Definition: pad.h:788
bool GetKeepTopBottom() const
Definition: pad.h:587
int m_thermalGap
Definition: pad.h:836
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:207
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1469
ZONE_CONNECTION m_zoneConnection
Definition: pad.h:832
void SetDelta(const VECTOR2I &aSize)
Definition: pad.h:249
bool IsOnCopperLayer() const override
Definition: pad.cpp:771
void SetDrillSizeX(const int aX)
Definition: pad.h:254
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:191
int m_thermalSpokeWidth
Definition: pad.h:833
VECTOR2I m_pos
Definition: pad.h:738
const VECTOR2I & GetDelta() const
Definition: pad.h:250
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:208
void SetDrillSize(const VECTOR2I &aSize)
Definition: pad.h:252
bool IsFreePad() const
Definition: pad.cpp:187
int GetLocalClearance() const
Definition: pad.h:391
wxString GetClass() const override
Return the class name.
Definition: pad.h:641
PAD_SHAPE GetShape() const
Definition: pad.h:189
bool CanFlashLayer(int aLayer)
Definition: pad.h:617
int m_subRatsnest
Definition: pad.h:762
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:341
EDA_ANGLE GetFPRelativeOrientation()
Definition: pad.cpp:682
void Flip(const VECTOR2I &VECTOR2I, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:691
void SetY(int y)
Definition: pad.h:239
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:892
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:222
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1445
bool m_shapesDirty
Definition: pad.h:751
std::mutex m_polyBuildingLock
Definition: pad.h:758
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:201
void SetX(int x)
Definition: pad.h:240
double m_chamferScale
Definition: pad.h:772
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:359
int GetLocalClearanceOverrides(wxString *aSource) const override
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:803
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: pad.h:398
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:180
int GetSizeY() const
Definition: pad.h:247
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:237
int GetThermalSpokeWidth() const
Definition: pad.h:503
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:140
int GetLocalSolderPasteMargin() const
Definition: pad.h:394
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:1081
void BuildEffectivePolygon() const
Definition: pad.cpp:598
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition: pad.cpp:673
PAD_SHAPE m_padShape
Definition: pad.h:740
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:414
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:217
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:343
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:228
void ClearZoneLayerOverrides()
Definition: pad.h:706
std::array< ZONE_LAYER_OVERRIDE, MAX_CU_LAYERS > m_zoneLayerOverrides
Definition: pad.h:839
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:664
std::mutex m_zoneLayerOverridesMutex
Definition: pad.h:838
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
ZONE_CONNECTION GetLocalZoneConnectionOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:940
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1298
int GetChamferPositions() const
Definition: pad.h:566
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:1310
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:734
bool m_removeUnconnectedLayer
< If true, the pad copper is removed for layers that are not connected.
Definition: pad.h:804
void SetLocalSolderMaskMargin(int aMargin)
Definition: pad.h:388
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:368
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
int GetSubRatsnest() const
Definition: pad.h:571
void SetSizeX(const int aX)
Definition: pad.h:244
bool m_keepTopBottomLayer
Definition: pad.h:807
int m_lengthPadToDie
Definition: pad.h:801
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:502
bool HasHole() const override
Definition: pad.h:105
void SetSize(const VECTOR2I &aSize)
Definition: pad.h:242
void SetDrillSizeY(const int aY)
Definition: pad.h:256
double GetThermalSpokeAngleDegrees() const
Definition: pad.h:520
PAD * ClonePad() const
Same as Clone, but returns a PAD item.
Definition: pad.h:688
double GetRoundRectRadiusRatio() const
Definition: pad.h:547
int GetThermalGap() const
Definition: pad.h:526
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:405
void SetOrientationDegrees(double aOrientation)
Definition: pad.h:345
bool SharesNetTieGroup(const PAD *aOther) const
Definition: pad.cpp:164
const VECTOR2I & GetSize() const
Definition: pad.h:243
PAD_SHAPE m_anchorPadShape
Definition: pad.h:776
EDA_ANGLE m_thermalSpokeAngle
Definition: pad.h:834
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1376
bool m_polyDirty
Definition: pad.h:757
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:572
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:754
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:565
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition: pad.cpp:949
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:202
double GetChamferRectRatio() const
Definition: pad.h:556
void SetPadToDieLength(int aLength)
Definition: pad.h:384
bool IsFlipped() const
Definition: pad.cpp:229
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pad.h:84
void SetSizeY(const int aY)
Definition: pad.h:246
int GetPadToDieLength() const
Definition: pad.h:385
BOX2I m_effectiveBoundingBox
Definition: pad.h:753
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon
Definition: pad.h:759
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition: shape.h:126
@ DEGREES_T
Definition: eda_angle.h:31
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_INSIDE
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:148
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:96
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:65
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
CUST_PAD_SHAPE_IN_ZONE
Definition: pad.h:43
@ CUST_PAD_SHAPE_IN_ZONE_OUTLINE
Definition: pad.h:44
@ CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL
Definition: pad.h:45
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: pad_shapes.h:81
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:69
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:97
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:126
@ PCB_LOCATE_PTH_T
Definition: typeinfo.h:125
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_LOCATE_HOLE_T
Definition: typeinfo.h:124
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:49