KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef FOOTPRINT_H
22#define FOOTPRINT_H
23
24#include <deque>
25#include <mutex>
26#include <optional>
27#include <unordered_set>
28
29#include <template_fieldnames.h>
30
32#include <board_item.h>
33#include <embedded_files.h>
34#include <layer_ids.h> // ALL_LAYERS definition.
35#include <lset.h>
36#include <lib_id.h>
37#include <lib_tree_item.h>
38#include <list>
39
40#include <zones.h>
42#include <pcb_item_containers.h>
43#include <pcb_field.h>
44#include <functional>
45#include <math/vector3.h>
48#include <gal/color4d.h>
49
50class LINE_READER;
51class EDA_3D_CANVAS;
52class PAD;
53class BOARD;
54class COMPONENT_CLASS;
56class MSG_PANEL_ITEM;
57class SHAPE;
58class REPORTER;
60class PCB_POINT;
61
62namespace KIGFX {
63class VIEW;
64}
65
66namespace KIFONT {
67class OUTLINE_FONT;
68}
69
75
82{
84 FP_SMD = 0x0002,
87 FP_BOARD_ONLY = 0x0010, // Footprint has no corresponding symbol
88 FP_JUST_ADDED = 0x0020, // Footprint just added by netlist update
89 FP_DNP = 0x0040
90};
91
99
101{
102public:
103 EXTRUDED_3D_BODY() = default;
104
105 int m_height = 0;
106 int m_standoff = 0;
110 bool m_show = true;
111
112 VECTOR3D m_scale{ 1.0, 1.0, 1.0 };
113 VECTOR3D m_rotation{ 0.0, 0.0, 0.0 };
114 VECTOR3D m_offset{ 0.0, 0.0, 0.0 };
115
117 {
118 switch( aMaterial )
119 {
120 default:
121 case EXTRUSION_MATERIAL::PLASTIC: return KIGFX::COLOR4D( 0.2, 0.2, 0.2, 1.0 );
122 case EXTRUSION_MATERIAL::MATTE: return KIGFX::COLOR4D( 0.4, 0.4, 0.4, 1.0 );
123 case EXTRUSION_MATERIAL::METAL: return KIGFX::COLOR4D( 0.7, 0.7, 0.7, 1.0 );
124 case EXTRUSION_MATERIAL::COPPER: return KIGFX::COLOR4D( 0.72, 0.45, 0.2, 1.0 );
125 }
126 }
127
128 bool operator==( const EXTRUDED_3D_BODY& aOther ) const
129 {
130 return m_height == aOther.m_height && m_standoff == aOther.m_standoff && m_layer == aOther.m_layer
131 && m_color == aOther.m_color && m_material == aOther.m_material && m_scale == aOther.m_scale
132 && m_rotation == aOther.m_rotation && m_offset == aOther.m_offset && m_show == aOther.m_show;
133 }
134
135 static uint32_t PackColorKey( const KIGFX::COLOR4D& aColor )
136 {
137 return ( (uint8_t) ( aColor.r * 255 ) << 24 ) | ( (uint8_t) ( aColor.g * 255 ) << 16 )
138 | ( (uint8_t) ( aColor.b * 255 ) << 8 ) | (uint8_t) ( aColor.a * 255 );
139 }
140};
141
155
157{
158public:
160 // Initialize with sensible values
161 m_Scale { 1, 1, 1 },
162 m_Rotation { 0, 0, 0 },
163 m_Offset { 0, 0, 0 },
164 m_Opacity( 1.0 ),
165 m_Show( true )
166 {
167 }
168
172 double m_Opacity;
173 wxString m_Filename;
174 bool m_Show;
175
176 bool operator==( const FP_3DMODEL& aOther ) const
177 {
178 return m_Scale == aOther.m_Scale
179 && m_Rotation == aOther.m_Rotation
180 && m_Offset == aOther.m_Offset
181 && m_Opacity == aOther.m_Opacity
182 && m_Filename == aOther.m_Filename
183 && m_Show == aOther.m_Show;
184 }
185};
186
187
189{
190 SHAPE_POLY_SET front; // Note that a footprint can have both front and back courtyards populated.
194};
195
196
206
207
215{
216public:
217 FOOTPRINT_VARIANT( const wxString& aName = wxEmptyString ) :
218 m_name( aName ),
219 m_dnp( false ),
220 m_excludedFromBOM( false ),
222 {
223 }
224
225 wxString GetName() const { return m_name; }
226 void SetName( const wxString& aName ) { m_name = aName; }
227
228 bool GetDNP() const { return m_dnp; }
229 void SetDNP( bool aDNP ) { m_dnp = aDNP; }
230
231 bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
232 void SetExcludedFromBOM( bool aExclude ) { m_excludedFromBOM = aExclude; }
233
235 void SetExcludedFromPosFiles( bool aExclude ) { m_excludedFromPosFiles = aExclude; }
236
242 wxString GetFieldValue( const wxString& aFieldName ) const
243 {
244 auto it = m_fields.find( aFieldName );
245
246 if( it != m_fields.end() )
247 return it->second;
248
249 return wxString();
250 }
251
257 void SetFieldValue( const wxString& aFieldName, const wxString& aValue )
258 {
259 m_fields[aFieldName] = aValue;
260 }
261
262 bool HasFieldValue( const wxString& aFieldName ) const
263 {
264 return m_fields.find( aFieldName ) != m_fields.end();
265 }
266
267 const std::map<wxString, wxString>& GetFields() const { return m_fields; }
268
269 bool operator==( const FOOTPRINT_VARIANT& aOther ) const
270 {
271 return m_name == aOther.m_name
272 && m_dnp == aOther.m_dnp
275 && m_fields == aOther.m_fields;
276 }
277
278private:
279 wxString m_name;
280 bool m_dnp;
283 std::map<wxString, wxString> m_fields;
284};
285
286
288{
289public:
290 FOOTPRINT( BOARD* parent );
291
292 FOOTPRINT( const FOOTPRINT& aFootprint );
293
294 // Move constructor and operator needed due to std containers inside the footprint
295 FOOTPRINT( FOOTPRINT&& aFootprint );
296
297 ~FOOTPRINT();
298
299 FOOTPRINT& operator=( const FOOTPRINT& aOther );
300 FOOTPRINT& operator=( FOOTPRINT&& aOther );
301
302 void CopyFrom( const BOARD_ITEM* aOther ) override;
303
304 void Serialize( google::protobuf::Any &aContainer ) const override;
305 bool Deserialize( const google::protobuf::Any &aContainer ) override;
306
307 static inline bool ClassOf( const EDA_ITEM* aItem )
308 {
309 return aItem && aItem->Type() == PCB_FOOTPRINT_T;
310 }
311
314
316 void SetPrivateLayers( const LSET& aLayers ) { m_privateLayers = aLayers; }
317
319 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
320 bool aSkipConnectivity = false ) override;
321
323 void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
324
332 void ClearAllNets();
333
341 bool FixUuids();
342
353
361
362 bool TextOnly() const;
363
364 // Virtual function
365 const BOX2I GetBoundingBox() const override;
366 const BOX2I GetBoundingBox( bool aIncludeText ) const;
367
371 const BOX2I GetLayerBoundingBox( const LSET& aLayers ) const;
372
373 VECTOR2I GetCenter() const override { return GetBoundingBox( false ).GetCenter(); }
374
375 std::deque<PAD*>& Pads() { return m_pads; }
376 const std::deque<PAD*>& Pads() const { return m_pads; }
377
379 const DRAWINGS& GraphicalItems() const { return m_drawings; }
380
381 ZONES& Zones() { return m_zones; }
382 const ZONES& Zones() const { return m_zones; }
383
384 GROUPS& Groups() { return m_groups; }
385 const GROUPS& Groups() const { return m_groups; }
386
388 const CONSTRAINTS& Constraints() const { return m_constraints; }
389
391 const PCB_POINTS& Points() const { return m_points; }
392
393 bool HasThroughHolePads() const;
394
395 std::vector<FP_3DMODEL>& Models() { return m_3D_Drawings; }
396 const std::vector<FP_3DMODEL>& Models() const { return m_3D_Drawings; }
397
398 bool HasExtrudedBody() const { return m_extrudedBody != nullptr; }
399 const EXTRUDED_3D_BODY* GetExtrudedBody() const { return m_extrudedBody.get(); }
402 void SetExtrudedBody( std::unique_ptr<EXTRUDED_3D_BODY> aBody );
404
405 void SetPosition( const VECTOR2I& aPos ) override;
406 VECTOR2I GetPosition() const override { return m_transform.GetTranslate(); }
407
408 void SetOrientation( const EDA_ANGLE& aNewAngle );
409 EDA_ANGLE GetOrientation() const { return m_transform.GetRotate(); }
410
415 void SetLayerAndFlip( PCB_LAYER_ID aLayer );
416
417 void SetLayer( PCB_LAYER_ID aLayer ) override;
418
419 // to make property magic work
420 PCB_LAYER_ID GetLayer() const override { return BOARD_ITEM::GetLayer(); }
421
422 const TRANSFORM_TRS& GetTransform() const { return m_transform; }
423
424 void SetTransformScale( double aScaleX, double aScaleY );
425
426 double GetScaleX() const { return m_transform.GetScaleX(); }
427 double GetScaleY() const { return m_transform.GetScaleY(); }
428
429 void SetScaleX( double aScaleX ) { SetTransformScale( aScaleX, m_transform.GetScaleY() ); }
430
431 void SetScaleY( double aScaleY ) { SetTransformScale( m_transform.GetScaleX(), aScaleY ); }
432
433 void RescaleAroundPoint( const VECTOR2I& aCenter, double aSx, double aSy );
434
435 void SetOrientationDegrees( double aOrientation )
436 {
437 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
438 }
440 {
441 return m_transform.GetRotate().AsDegrees();
442 }
443
444 const LIB_ID& GetFPID() const { return m_fpid; }
445 void SetFPID( const LIB_ID& aFPID )
446 {
447 m_fpid = aFPID;
448 }
449
450 wxString GetFPIDAsString() const { return m_fpid.Format(); }
451 void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); }
452
453 // LIB_TREE_ITEM interface
454 LIB_ID GetLIB_ID() const override { return m_fpid; }
455 wxString GetName() const override { return m_fpid.GetLibItemName(); }
456 wxString GetLibNickname() const override { return m_fpid.GetLibNickname(); }
457 wxString GetDesc() override { return GetLibDescription(); }
458 int GetPinCount() override { return static_cast<int>( GetNumberedPadCount() ); }
459 std::vector<SEARCH_TERM>& GetSearchTerms() override;
460
461 wxString GetLibDescription() const { return m_libDescription; }
462 void SetLibDescription( const wxString& aDesc ) { m_libDescription = aDesc; }
463
464 wxString GetKeywords() const { return m_keywords; }
465 void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
466
467 const KIID_PATH& GetPath() const { return m_path; }
468 void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
469
470 wxString GetSheetname() const { return m_sheetname; }
471 void SetSheetname( const wxString& aSheetname ) { m_sheetname = aSheetname; }
472
473 wxString GetSheetfile() const { return m_sheetfile; }
474 void SetSheetfile( const wxString& aSheetfile ) { m_sheetfile = aSheetfile; }
475
476 wxString GetFilters() const { return m_filters; }
477 void SetFilters( const wxString& aFilters ) { m_filters = aFilters; }
478
479 std::optional<int> GetLocalClearance() const { return m_clearance; }
480 void SetLocalClearance( std::optional<int> aClearance ) { m_clearance = aClearance; }
481
482 std::optional<int> GetLocalSolderMaskMargin() const { return m_solderMaskMargin; }
483 void SetLocalSolderMaskMargin( std::optional<int> aMargin ) { m_solderMaskMargin = aMargin; }
484
485 std::optional<int> GetLocalSolderPasteMargin() const { return m_solderPasteMargin; }
486 void SetLocalSolderPasteMargin( std::optional<int> aMargin ) { m_solderPasteMargin = aMargin; }
487
488 std::optional<double> GetLocalSolderPasteMarginRatio() const { return m_solderPasteMarginRatio; }
489 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio ) { m_solderPasteMarginRatio = aRatio; }
490
493
500 void SetStackupMode( FOOTPRINT_STACKUP aMode );
502
507 void SetStackupLayers( LSET aLayers );
508 const LSET& GetStackupLayers() const { return m_stackupLayers; }
509
510 int GetAttributes() const { return m_attributes; }
511 void SetAttributes( int aAttributes ) { m_attributes = aAttributes; }
512
514 void SetAllowMissingCourtyard( bool aAllow ) { m_allowMissingCourtyard = aAllow; }
515
517 void SetAllowSolderMaskBridges( bool aAllow ) { m_allowSolderMaskBridges = aAllow; }
518
519 void SetFlag( int aFlag ) { m_arflag = aFlag; }
520 void IncrementFlag() { m_arflag += 1; }
521 int GetFlag() const { return m_arflag; }
522
523 bool IsNetTie() const
524 {
525 for( const wxString& group : m_netTiePadGroups )
526 {
527 if( !group.IsEmpty() )
528 return true;
529 }
530
531 return false;
532 }
533
534 std::optional<int> GetLocalClearance( wxString* aSource ) const
535 {
536 if( m_clearance.has_value() && aSource )
537 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
538
539 return m_clearance;
540 }
541
548 std::optional<int> GetClearanceOverrides( wxString* aSource ) const
549 {
550 return GetLocalClearance( aSource );
551 }
552
554 {
556 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
557
558 return m_zoneConnection;
559 }
560
565 const std::vector<wxString>& GetNetTiePadGroups() const { return m_netTiePadGroups; }
566
568 {
569 m_netTiePadGroups.clear();
570 }
571
572 void AddNetTiePadGroup( const wxString& aGroup )
573 {
574 m_netTiePadGroups.emplace_back( aGroup );
575 }
576
581 std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
582
586 std::vector<PAD*> GetNetTiePads( PAD* aPad ) const;
587
593 int GetLikelyAttribute() const;
594
595 void Move( const VECTOR2I& aMoveVector ) override;
596
597 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
598
599 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
600
612 void MoveAnchorPosition( const VECTOR2I& aMoveVector );
613
617 bool IsFlipped() const { return GetLayer() == B_Cu; }
618
623 PCB_LAYER_ID GetSide() const;
624
628 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
629
630// m_footprintStatus bits:
631#define FP_is_LOCKED 0x01
632#define FP_is_PLACED 0x02
633#define FP_to_PLACE 0x04
634#define FP_PADS_are_LOCKED 0x08
635
636
637 bool IsLocked() const override
638 {
639 return ( m_fpStatus & FP_is_LOCKED ) != 0;
640 }
641
645 bool IsLayerAgnostic() const override { return true; }
646
650 bool FitsEnabledLayers( const LSET& aEnabledLayers, int aCopperLayerCount ) const override
651 {
652 return GetLayer() == F_Cu || GetLayer() == B_Cu;
653 }
654
660 void SetLocked( bool isLocked ) override
661 {
662 if( isLocked )
664 else
666 }
667
671 bool IsConflicting() const;
672
673 bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
674 void SetIsPlaced( bool isPlaced )
675 {
676 if( isPlaced )
678 else
680 }
681
682 bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
683 void SetNeedsPlaced( bool needsPlaced )
684 {
685 if( needsPlaced )
687 else
689 }
690
692
703 void CheckFootprintAttributes( const std::function<void( const wxString& )>& aErrorHandler );
704
711 void CheckPads( UNITS_PROVIDER* aUnitsProvider,
712 const std::function<void( const PAD*, int, const wxString& )>& aErrorHandler );
713
719 void CheckShortingPads( const std::function<void( const PAD*, const PAD*, int aErrorCode,
720 const VECTOR2I& )>& aErrorHandler );
721
728 void CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
729 const BOARD_ITEM* bItem,
730 const BOARD_ITEM* cItem,
731 const VECTOR2I& )>& aErrorHandler );
732
739 void CheckNetTiePadGroups( const std::function<void( const wxString& )>& aErrorHandler );
740
741 void CheckClippedSilk( const std::function<void( BOARD_ITEM* aItemA,
742 BOARD_ITEM* aItemB,
743 const VECTOR2I& aPt )>& aErrorHandler );
747 void BuildNetTieCache();
748
752 const std::set<int>& GetNetTieCache( const BOARD_ITEM* aItem ) const
753 {
754 static const std::set<int> emptySet;
755
756 auto it = m_netTieCache.find( aItem );
757
758 if( it == m_netTieCache.end() )
759 return emptySet;
760
761 return it->second;
762 }
763
776 void TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
777 int aMaxError, ERROR_LOC aErrorLoc ) const;
778
793 void TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
794 int aError, ERROR_LOC aErrorLoc,
795 bool aIncludeText = true,
796 bool aIncludeShapes = true,
797 bool aIncludePrivateItems = false ) const;
798
802 void TransformFPTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
803 int aError, ERROR_LOC aErrorLoc ) const
804 {
805 TransformFPShapesToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc, true, false );
806 }
807
811 void GetContextualTextVars( wxArrayString* aVars ) const;
812
818 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
819
821 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
822
823 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
824
825 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
826
836 bool HitTestAccurate( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
837
838 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
839
840 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
841
850 bool HitTestOnLayer( const VECTOR2I& aPosition, PCB_LAYER_ID aLayer, int aAccuracy = 0 ) const;
851
852 bool HitTestOnLayer( const BOX2I& aRect, bool aContained, PCB_LAYER_ID aLayer, int aAccuracy = 0 ) const;
853
857 const wxString& GetReference() const { return Reference().GetText(); }
858
863 void SetReference( const wxString& aReference ) { Reference().SetText( aReference ); }
864
865 // Property system doesn't like const references
866 wxString GetReferenceAsString() const
867 {
868 return GetReference();
869 }
870
874 void IncrementReference( int aDelta );
875
879 const wxString& GetValue() const { return Value().GetText(); }
880
884 void SetValue( const wxString& aValue ) { Value().SetText( aValue ); }
885
886 // Property system doesn't like const references
887 wxString GetValueAsString() const
888 {
889 return GetValue();
890 }
891
895
897 const PCB_FIELD& Value() const { return *GetField( FIELD_T::VALUE ); }
898 const PCB_FIELD& Reference() const { return *GetField( FIELD_T::REFERENCE ); }
899
900 //-----<Fields>-----------------------------------------------------------
901
906 PCB_FIELD* GetField( FIELD_T aFieldType );
907 const PCB_FIELD* GetField( FIELD_T aFieldNdx ) const;
908
916 PCB_FIELD* GetField( const wxString& aFieldName ) const;
917
918 bool HasField( const wxString& aFieldName ) const;
919
926 void GetFields( std::vector<PCB_FIELD*>& aVector, bool aVisibleOnly ) const;
927
931 const std::deque<PCB_FIELD*>& GetFields() const { return m_fields; }
932 std::deque<PCB_FIELD*>& GetFields() { return m_fields; }
933
937 int GetNextFieldOrdinal() const;
938
946 void ApplyDefaultSettings( const BOARD& board, bool aStyleFields, bool aStyleText,
947 bool aStyleShapes, bool aStyleDimensions, bool aStyleBarcodes );
948
950 {
951 wxString m_unitName; // e.g. A
952 std::vector<wxString> m_pins; // pin numbers in this unit
953 };
954
955 void SetUnitInfo( const std::vector<FP_UNIT_INFO>& aUnits ) { m_unitInfo = aUnits; }
956 const std::vector<FP_UNIT_INFO>& GetUnitInfo() const { return m_unitInfo; }
957
958 bool IsBoardOnly() const { return m_attributes & FP_BOARD_ONLY; }
959 void SetBoardOnly( bool aIsBoardOnly = true )
960 {
961 if( aIsBoardOnly )
963 else
965 }
966
968 void SetExcludedFromPosFiles( bool aExclude = true )
969 {
970 if( aExclude )
972 else
974 }
975
977 void SetExcludedFromBOM( bool aExclude = true )
978 {
979 if( aExclude )
981 else
983 }
984
985 bool IsDNP() const { return m_attributes & FP_DNP; }
986 void SetDNP( bool aDNP = true )
987 {
988 if( aDNP )
990 else
992 }
993
994 // =====================================================================
995 // Variant Support
996 // =====================================================================
997
1003 const FOOTPRINT_VARIANT* GetVariant( const wxString& aVariantName ) const;
1004
1010 FOOTPRINT_VARIANT* GetVariant( const wxString& aVariantName );
1011
1016 void SetVariant( const FOOTPRINT_VARIANT& aVariant );
1017
1023 FOOTPRINT_VARIANT* AddVariant( const wxString& aVariantName );
1024
1029 void DeleteVariant( const wxString& aVariantName );
1030
1036 void RenameVariant( const wxString& aOldName, const wxString& aNewName );
1037
1043 bool HasVariant( const wxString& aVariantName ) const;
1044
1050
1059 bool GetDNPForVariant( const wxString& aVariantName ) const;
1060
1069 bool GetExcludedFromBOMForVariant( const wxString& aVariantName ) const;
1070
1079 bool GetExcludedFromPosFilesForVariant( const wxString& aVariantName ) const;
1080
1090 wxString GetFieldValueForVariant( const wxString& aVariantName, const wxString& aFieldName ) const;
1091
1092 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
1094
1104 PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
1105
1106 PAD* FindPadByUuid( const KIID& aUuid ) const;
1107
1115 PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask = LSET::AllLayersMask() );
1116
1117 std::vector<const PAD*> GetPads( const wxString& aPadNumber, const PAD* aIgnore = nullptr ) const;
1118
1126 unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
1127
1138 unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
1139
1143 std::set<wxString>
1145
1154 unsigned GetNumberedPadCount() const;
1155
1163 wxString GetNextPadNumber( const wxString& aLastPadName ) const;
1164
1167
1172 std::vector<std::set<wxString>>& JumperPadGroups() { return m_jumperPadGroups; }
1173 const std::vector<std::set<wxString>>& JumperPadGroups() const { return m_jumperPadGroups; }
1174
1176 std::optional<const std::set<wxString>> GetJumperPadGroup( const wxString& aPadNumber ) const;
1177
1181 void AutoPositionFields();
1182
1187 wxString GetTypeName() const;
1188
1189 double GetArea( int aPadding = 0 ) const;
1190
1191 KIID GetLink() const { return m_link; }
1192 void SetLink( const KIID& aLink ) { m_link = aLink; }
1193
1194 BOARD_ITEM* Duplicate( bool addToParentGroup, BOARD_COMMIT* aCommit = nullptr ) const override;
1195
1201 BOARD_ITEM* DuplicateItem( bool addToParentGroup, BOARD_COMMIT* aCommit, const BOARD_ITEM* aItem,
1202 bool addToFootprint = false );
1203
1209 void Add3DModel( FP_3DMODEL* a3DModel );
1210
1211 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
1212 const std::vector<KICAD_T>& aScanTypes ) override;
1213
1214 wxString GetClass() const override
1215 {
1216 return wxT( "FOOTPRINT" );
1217 }
1218
1219 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1220
1221 wxString DisambiguateItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1222
1223 BITMAPS GetMenuImage() const override;
1224
1225 EDA_ITEM* Clone() const override;
1226
1228 void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
1229
1230 virtual std::vector<int> ViewGetLayers() const override;
1231
1232 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1233
1234 virtual const BOX2I ViewBBox() const override;
1235
1243 static bool IsLibNameValid( const wxString& aName );
1244
1254 static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
1255
1259 bool FootprintNeedsUpdate( const FOOTPRINT* aLibFP, int aCompareFlags = 0,
1260 REPORTER* aReporter = nullptr );
1261
1276 void SetInitialComments( wxArrayString* aInitialComments )
1277 {
1278 delete m_initial_comments;
1279 m_initial_comments = aInitialComments;
1280 }
1281
1288 double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
1289
1290 static double GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLECTOR& aCollector );
1291
1293 const wxArrayString* GetInitialComments() const { return m_initial_comments; }
1294
1300 const SHAPE_POLY_SET& GetCourtyard( PCB_LAYER_ID aLayer ) const;
1301
1307 const SHAPE_POLY_SET& GetCachedCourtyard( PCB_LAYER_ID aLayer ) const;
1308
1315 void BuildCourtyardCaches( OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
1316
1317 // @copydoc BOARD_ITEM::GetEffectiveShape
1318 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
1319 FLASHING aFlash = FLASHING::DEFAULT ) const override;
1320
1322 {
1323 return static_cast<EMBEDDED_FILES*>( this );
1324 }
1325
1327 {
1328 return static_cast<const EMBEDDED_FILES*>( this );
1329 }
1330
1334 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
1335
1336 void EmbedFonts() override;
1337
1338 double Similarity( const BOARD_ITEM& aOther ) const override;
1339
1341 void SetStaticComponentClass( const COMPONENT_CLASS* aClass ) const;
1342
1345
1347 const COMPONENT_CLASS* GetComponentClass() const;
1348
1350 wxString GetComponentClassAsString() const;
1351
1353 void RecomputeComponentClass() const;
1354
1356 void InvalidateComponentClassCache() const;
1357
1364 void SetTransientComponentClassNames( const std::unordered_set<wxString>& classNames )
1365 {
1366 m_transientComponentClassNames = classNames;
1367 }
1368
1370 const std::unordered_set<wxString>& GetTransientComponentClassNames()
1371 {
1373 }
1374
1377
1379 void ResolveComponentClassNames( BOARD* aBoard,
1380 const std::unordered_set<wxString>& aComponentClassNames );
1381
1383 void FixUpPadsForBoard( BOARD* aBoard );
1384
1385 bool operator==( const BOARD_ITEM& aOther ) const override;
1386 bool operator==( const FOOTPRINT& aOther ) const;
1387
1388#if defined(DEBUG)
1389 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1390#endif
1391
1393 {
1394 bool operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const;
1395 };
1396
1398 {
1399 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
1400 };
1401 // TODO(JE) padstacks -- this code isn't used anywhere though
1402#if 0
1403 struct cmp_padstack
1404 {
1405 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
1406 };
1407#endif
1409 {
1410 bool operator()( const ZONE* aFirst, const ZONE* aSecond ) const;
1411 };
1412
1413protected:
1414 virtual void swapData( BOARD_ITEM* aImage ) override;
1415
1417
1418private:
1419 std::deque<PCB_FIELD*> m_fields; // Fields, mapped by name, owned by pointer
1420 std::deque<BOARD_ITEM*> m_drawings; // Drawings in the footprint, owned by pointer
1421 std::deque<PAD*> m_pads; // Pads, owned by pointer
1422 std::vector<ZONE*> m_zones; // Rule area zones, owned by pointer
1423 std::deque<PCB_GROUP*> m_groups; // Groups, owned by pointer
1424 std::deque<PCB_CONSTRAINT*> m_constraints; // Geometric constraints, owned by pointer
1425 std::deque<PCB_POINT*> m_points; // Points, owned by pointer
1426
1428 bool m_flipped = false;
1430 int m_attributes; // Flag bits (see FOOTPRINT_ATTR_T)
1431 int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
1433
1436
1437 // Bounding box caching strategy:
1438 // While we attempt to notice the low-hanging fruit operations and update the bounding boxes
1439 // accordingly, we rely mostly on a "if anything changed then the caches are stale" approach.
1440 // We implement this by having PCB_BASE_FRAME's OnModify() method increment an operation
1441 // counter, and storing that as a timestamp for the various caches.
1442 // This means caches will get regenerated often -- but still far less often than if we had no
1443 // caches at all. The principal opitmization would be to change to dirty flag and make sure
1444 // that any edit that could affect the bounding boxes (including edits to the footprint
1445 // children) marked the bounding boxes dirty. It would definitely be faster -- but also more
1446 // fragile.
1447 mutable std::mutex m_geometry_cache_mutex;
1448 mutable std::unique_ptr<FOOTPRINT_GEOMETRY_CACHE_DATA> m_geometry_cache;
1449
1450 // A list of pad groups, each of which is allowed to short nets within their group.
1451 // A pad group is a comma-separated list of pad numbers.
1452 std::vector<wxString> m_netTiePadGroups;
1453
1454 // A list of 1:N footprint item to allowed net numbers
1455 std::map<const BOARD_ITEM*, std::set<int>> m_netTieCache;
1456
1459 std::vector<std::set<wxString>> m_jumperPadGroups;
1460
1464
1467
1468 // Optional overrides
1470 std::optional<int> m_clearance;
1471 std::optional<int> m_solderMaskMargin; // Solder mask margin
1472 std::optional<int> m_solderPasteMargin; // Solder paste margin absolute value
1473 std::optional<double> m_solderPasteMarginRatio; // Solder mask margin ratio of pad size
1474 // The final margin is the sum of these 2 values
1475
1476 LSET m_stackupLayers; // Layers in the stackup
1477 FOOTPRINT_STACKUP m_stackupMode; // Stackup mode for this footprint
1478 LSET m_privateLayers; // Layers visible only in the footprint editor
1479
1480 wxString m_libDescription; // File name and path for documentation file.
1481 wxString m_keywords; // Search keywords to find footprint in library.
1482 KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
1483 wxString m_sheetname; // Name of the sheet containing the symbol for this footprint
1484 wxString m_sheetfile; // File of the sheet containing the symbol for this footprint
1485 wxString m_filters; // Footprint filters from symbol
1487 int m_arflag; // Use to trace ratsnest and auto routing.
1488 KIID m_link; // Temporary logical link used during editing
1489
1490 std::vector<FP_3DMODEL> m_3D_Drawings; // 3D models.
1491
1492 std::unique_ptr<EXTRUDED_3D_BODY> m_extrudedBody; // nullptr = disabled
1493
1494 wxArrayString* m_initial_comments; // s-expression comments in the footprint,
1495 // lazily allocated only if needed for speed
1496
1497 mutable std::unique_ptr<FOOTPRINT_COURTYARD_CACHE_DATA> m_courtyard_cache;
1498 mutable std::mutex m_courtyard_cache_mutex;
1499
1500 std::unordered_set<wxString> m_transientComponentClassNames;
1501 std::unique_ptr<COMPONENT_CLASS_CACHE_PROXY> m_componentClassCacheProxy;
1502
1503 // Optional unit mapping information for multi-unit symbols
1504 std::vector<FP_UNIT_INFO> m_unitInfo;
1505
1506 std::vector<SEARCH_TERM> m_searchTerms;
1507};
1508
1509#endif // FOOTPRINT_H
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
std::map< wxString, ValueType, DETAIL::CASE_INSENSITIVE_COMPARER > CASE_INSENSITIVE_MAP
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:83
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:85
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:295
friend class BOARD
Definition board_item.h:548
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
constexpr const Vec GetCenter() const
Definition box2.h:226
A lightweight representation of a component class.
Implement a canvas based on a wxGLCanvas.
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:265
EMBEDDED_FILES()=default
bool operator==(const EXTRUDED_3D_BODY &aOther) const
Definition footprint.h:128
KIGFX::COLOR4D m_color
Definition footprint.h:108
VECTOR3D m_offset
Definition footprint.h:114
EXTRUDED_3D_BODY()=default
PCB_LAYER_ID m_layer
Definition footprint.h:107
static KIGFX::COLOR4D GetDefaultColor(EXTRUSION_MATERIAL aMaterial)
Definition footprint.h:116
VECTOR3D m_rotation
Definition footprint.h:113
static uint32_t PackColorKey(const KIGFX::COLOR4D &aColor)
Definition footprint.h:135
VECTOR3D m_scale
Definition footprint.h:112
EXTRUSION_MATERIAL m_material
Definition footprint.h:109
Variant information for a footprint.
Definition footprint.h:215
wxString GetName() const
Definition footprint.h:225
FOOTPRINT_VARIANT(const wxString &aName=wxEmptyString)
Definition footprint.h:217
bool HasFieldValue(const wxString &aFieldName) const
Definition footprint.h:262
bool m_excludedFromPosFiles
Definition footprint.h:282
void SetExcludedFromPosFiles(bool aExclude)
Definition footprint.h:235
wxString GetFieldValue(const wxString &aFieldName) const
Get a field value override for this variant.
Definition footprint.h:242
void SetName(const wxString &aName)
Definition footprint.h:226
const std::map< wxString, wxString > & GetFields() const
Definition footprint.h:267
bool GetExcludedFromBOM() const
Definition footprint.h:231
bool operator==(const FOOTPRINT_VARIANT &aOther) const
Definition footprint.h:269
void SetDNP(bool aDNP)
Definition footprint.h:229
bool GetExcludedFromPosFiles() const
Definition footprint.h:234
bool GetDNP() const
Definition footprint.h:228
std::map< wxString, wxString > m_fields
Field value overrides for this variant.
Definition footprint.h:283
void SetFieldValue(const wxString &aFieldName, const wxString &aValue)
Set a field value override for this variant.
Definition footprint.h:257
void SetExcludedFromBOM(bool aExclude)
Definition footprint.h:232
bool FixUuids()
Old footprints do not always have a valid UUID (some can be set to null uuid) However null UUIDs,...
bool GetDuplicatePadNumbersAreJumpers() const
Definition footprint.h:1165
const CASE_INSENSITIVE_MAP< FOOTPRINT_VARIANT > & GetVariants() const
Get all variants.
Definition footprint.h:1049
std::optional< int > GetClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition footprint.h:548
void EmbedFonts() override
bool AllowSolderMaskBridges() const
Definition footprint.h:516
void SetPosition(const VECTOR2I &aPos) override
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:445
LIB_ID m_fpid
Definition footprint.h:1429
wxString GetLibDescription() const
Definition footprint.h:461
ZONE_CONNECTION GetLocalZoneConnection() const
Definition footprint.h:492
void SetLink(const KIID &aLink)
Definition footprint.h:1192
KIID_PATH m_path
Definition footprint.h:1482
std::deque< BOARD_ITEM * > m_drawings
Definition footprint.h:1420
void SetStackupLayers(LSET aLayers)
If the footprint has a non-default stackup, set the layers that should be used for the stackup.
bool IsBoardOnly() const
Definition footprint.h:958
void InvalidateComponentClassCache() const
Forces deferred (on next access) recalculation of the component class for this footprint.
const std::deque< PAD * > & Pads() const
Definition footprint.h:376
bool IsDNP() const
Definition footprint.h:985
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition footprint.h:660
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition footprint.h:373
std::vector< PAD * > GetNetTiePads(PAD *aPad) const
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
EDA_ANGLE GetOrientation() const
Definition footprint.h:409
ZONES & Zones()
Definition footprint.h:381
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
std::deque< PCB_POINT * > m_points
Definition footprint.h:1425
void CheckClippedSilk(const std::function< void(BOARD_ITEM *aItemA, BOARD_ITEM *aItemB, const VECTOR2I &aPt)> &aErrorHandler)
std::unique_ptr< EXTRUDED_3D_BODY > m_extrudedBody
Definition footprint.h:1492
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
void SetIsPlaced(bool isPlaced)
Definition footprint.h:674
ZONE_CONNECTION m_zoneConnection
Definition footprint.h:1469
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this footprint.
PCB_POINTS & Points()
Definition footprint.h:390
static double GetCoverageArea(const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
bool IsExcludedFromBOM() const
Definition footprint.h:976
void SetOrientation(const EDA_ANGLE &aNewAngle)
void SetFlag(int aFlag)
Definition footprint.h:519
std::optional< double > m_solderPasteMarginRatio
Definition footprint.h:1473
void SetDNP(bool aDNP=true)
Definition footprint.h:986
void SetAllowSolderMaskBridges(bool aAllow)
Definition footprint.h:517
void RecomputeComponentClass() const
Forces immediate recalculation of the component class for this footprint.
std::vector< ZONE * > m_zones
Definition footprint.h:1422
const TRANSFORM_TRS & GetTransform() const
Definition footprint.h:422
static bool IsLibNameValid(const wxString &aName)
Test for validity of a name of a footprint to be used in a footprint library ( no spaces,...
void SetStackupMode(FOOTPRINT_STACKUP aMode)
Set the stackup mode for this footprint.
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition footprint.h:489
std::vector< SEARCH_TERM > & GetSearchTerms() override
void IncrementFlag()
Definition footprint.h:520
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
std::optional< int > m_clearance
Definition footprint.h:1470
bool m_duplicatePadNumbersAreJumpers
Flag that this footprint should automatically treat sets of two or more pads with the same number as ...
Definition footprint.h:1463
void CheckNetTies(const std::function< void(const BOARD_ITEM *aItem, const BOARD_ITEM *bItem, const BOARD_ITEM *cItem, const VECTOR2I &)> &aErrorHandler)
Check for un-allowed shorting of pads in net-tie footprints.
void CheckPads(UNITS_PROVIDER *aUnitsProvider, const std::function< void(const PAD *, int, const wxString &)> &aErrorHandler)
Run non-board-specific DRC checks on footprint's pads.
void SetExcludedFromBOM(bool aExclude=true)
Definition footprint.h:977
wxString GetSheetname() const
Definition footprint.h:470
int m_fpStatus
Definition footprint.h:1431
void SetPath(const KIID_PATH &aPath)
Definition footprint.h:468
std::set< wxString > GetUniquePadNumbers(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the names of the unique, non-blank pads.
void SetFilters(const wxString &aFilters)
Definition footprint.h:477
void SetKeywords(const wxString &aKeywords)
Definition footprint.h:465
void SetStaticComponentClass(const COMPONENT_CLASS *aClass) const
Sets the component class object pointer for this footprint.
const DRAWINGS & GraphicalItems() const
Definition footprint.h:379
wxString DisambiguateItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
void SetInitialComments(wxArrayString *aInitialComments)
Take ownership of caller's heap allocated aInitialComments block.
Definition footprint.h:1276
int m_attributes
Definition footprint.h:1430
PCB_LAYER_ID GetSide() const
Use instead of IsFlipped() when you also need to account for unsided footprints (those purely on user...
wxString GetLibNickname() const override
Definition footprint.h:456
const BOX2I GetLayerBoundingBox(const LSET &aLayers) const
Return the bounding box of the footprint on a given set of layers.
std::vector< FP_3DMODEL > m_3D_Drawings
Definition footprint.h:1490
double CoverageRatio(const GENERAL_COLLECTOR &aCollector) const
Calculate the ratio of total area of the footprint pads and graphical items to the area of the footpr...
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
bool FootprintNeedsUpdate(const FOOTPRINT *aLibFP, int aCompareFlags=0, REPORTER *aReporter=nullptr)
Return true if a board footprint differs from the library version.
bool m_allowMissingCourtyard
Definition footprint.h:1465
const std::vector< FP_UNIT_INFO > & GetUnitInfo() const
Definition footprint.h:956
const EXTRUDED_3D_BODY * GetExtrudedBody() const
Definition footprint.h:399
std::unordered_set< wxString > m_transientComponentClassNames
Definition footprint.h:1500
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetAttributes(int aAttributes)
Definition footprint.h:511
void SetSheetfile(const wxString &aSheetfile)
Definition footprint.h:474
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
std::optional< int > GetLocalSolderPasteMargin() const
Definition footprint.h:485
std::unique_ptr< COMPONENT_CLASS_CACHE_PROXY > m_componentClassCacheProxy
Definition footprint.h:1501
wxArrayString * m_initial_comments
Definition footprint.h:1494
EDA_ITEM * Clone() const override
Invoke a function on all children.
BOX2I GetFpPadsLocalBbox() const
Return the bounding box containing pads when the footprint is on the front side, orientation 0,...
LIB_ID GetLIB_ID() const override
Definition footprint.h:454
std::deque< PCB_FIELD * > m_fields
Definition footprint.h:1419
std::mutex m_geometry_cache_mutex
Definition footprint.h:1447
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:893
const EMBEDDED_FILES * GetEmbeddedFiles() const
Definition footprint.h:1326
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::optional< int > m_solderPasteMargin
Definition footprint.h:1472
const std::vector< std::set< wxString > > & JumperPadGroups() const
Definition footprint.h:1173
void SetFileFormatVersionAtLoad(int aVersion)
Definition footprint.h:1092
std::mutex m_courtyard_cache_mutex
Definition footprint.h:1498
void SetExcludedFromPosFiles(bool aExclude=true)
Definition footprint.h:968
void SetOrientationDegrees(double aOrientation)
Definition footprint.h:435
bool HasExtrudedBody() const
Definition footprint.h:398
std::optional< const std::set< wxString > > GetJumperPadGroup(const wxString &aPadNumber) const
Retrieves the jumper group containing the specified pad number, if one exists.
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
std::optional< int > GetLocalClearance() const
Definition footprint.h:479
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void TransformFPTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
This function is the same as TransformFPShapesToPolySet but only generates text.
Definition footprint.h:802
const FOOTPRINT_VARIANT * GetVariant(const wxString &aVariantName) const
Get a variant by name.
void MoveAnchorPosition(const VECTOR2I &aMoveVector)
Move the reference point of the footprint.
std::vector< std::set< wxString > > & JumperPadGroups()
Each jumper pad group is a set of pad numbers that should be treated as internally connected.
Definition footprint.h:1172
void SetDuplicatePadNumbersAreJumpers(bool aEnabled)
Definition footprint.h:1166
bool m_allowSolderMaskBridges
Definition footprint.h:1466
FOOTPRINT & operator=(const FOOTPRINT &aOther)
bool HasField(const wxString &aFieldName) const
CONSTRAINTS & Constraints()
Definition footprint.h:387
PCB_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this footprint.
void SetScaleY(double aScaleY)
Definition footprint.h:431
void TransformPadsToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Generate pads shapes on layer aLayer as polygons and adds these polygons to aBuffer.
void ClearExtrudedBody()
Definition footprint.h:403
double GetOrientationDegrees() const
Definition footprint.h:439
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
std::deque< PAD * > & Pads()
Definition footprint.h:375
void ResolveComponentClassNames(BOARD *aBoard, const std::unordered_set< wxString > &aComponentClassNames)
Resolves a set of component class names to this footprint's actual component class.
EXTRUDED_3D_BODY & EnsureExtrudedBody()
wxString GetDesc() override
Definition footprint.h:457
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetAttributes() const
Definition footprint.h:510
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
std::optional< int > GetLocalClearance(wxString *aSource) const
Definition footprint.h:534
const COMPONENT_CLASS * GetComponentClass() const
Returns the component class for this footprint.
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition footprint.h:491
BOARD_ITEM * DuplicateItem(bool addToParentGroup, BOARD_COMMIT *aCommit, const BOARD_ITEM *aItem, bool addToFootprint=false)
Duplicate a given item within the footprint, optionally adding it to the board.
FOOTPRINT(BOARD *parent)
Definition footprint.cpp:83
void ClearNetTiePadGroups()
Definition footprint.h:567
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:420
LSET GetPrivateLayers() const
Definition footprint.h:315
void SetExtrudedBody(std::unique_ptr< EXTRUDED_3D_BODY > aBody)
wxString GetFPIDAsString() const
Definition footprint.h:450
CASE_INSENSITIVE_MAP< FOOTPRINT_VARIANT > m_variants
Variant data for this footprint, keyed by variant name.
Definition footprint.h:1435
double GetScaleX() const
Definition footprint.h:426
wxString GetValueAsString() const
Definition footprint.h:887
bool AllowMissingCourtyard() const
Definition footprint.h:513
void DeleteVariant(const wxString &aVariantName)
Delete a variant by name.
const ZONES & Zones() const
Definition footprint.h:382
wxString GetComponentClassAsString() const
Used for display in the properties panel.
bool IsFlipped() const
Definition footprint.h:617
wxString GetSheetfile() const
Definition footprint.h:473
bool IsLayerAgnostic() const override
Check if this item's layer set must not be confined to a board's enabled layers.
Definition footprint.h:645
int GetPinCount() override
The pin count for symbols or the unique pad count for footprints.
Definition footprint.h:458
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
void TransformFPShapesToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIncludeText=true, bool aIncludeShapes=true, bool aIncludePrivateItems=false) const
Generate shapes of graphic items (outlines) on layer aLayer as polygons and adds these polygons to aB...
const CONSTRAINTS & Constraints() const
Definition footprint.h:388
bool m_flipped
Definition footprint.h:1428
std::deque< PCB_CONSTRAINT * > m_constraints
Definition footprint.h:1424
wxString GetTypeName() const
Get the type of footprint.
bool NeedsPlaced() const
Definition footprint.h:682
const std::vector< wxString > & GetNetTiePadGroups() const
Definition footprint.h:565
const LIB_ID & GetFPID() const
Definition footprint.h:444
const std::unordered_set< wxString > & GetTransientComponentClassNames()
Gets the transient component class names.
Definition footprint.h:1370
void SetReference(const wxString &aReference)
Definition footprint.h:863
bool IsLocked() const override
Definition footprint.h:637
std::vector< FP_UNIT_INFO > m_unitInfo
Definition footprint.h:1504
const GROUPS & Groups() const
Definition footprint.h:385
bool IsExcludedFromPosFiles() const
Definition footprint.h:967
void SetLayerAndFlip(PCB_LAYER_ID aLayer)
Used as Layer property setter – performs a flip if necessary to set the footprint layer.
unsigned GetNumberedPadCount() const
Return the number of unique pads whose pad number represents an electrical pin.
wxString GetFieldValueForVariant(const wxString &aVariantName, const wxString &aFieldName) const
Get a field value for a specific variant.
unsigned GetUniquePadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of unique non-blank pads.
void AddNetTiePadGroup(const wxString &aGroup)
Definition footprint.h:572
bool LegacyPadsLocked() const
Definition footprint.h:691
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
LSET m_privateLayers
Definition footprint.h:1478
const std::set< int > & GetNetTieCache(const BOARD_ITEM *aItem) const
Get the set of net codes that are allowed to connect to a footprint item.
Definition footprint.h:752
const LSET & GetStackupLayers() const
Definition footprint.h:508
const std::deque< PCB_FIELD * > & GetFields() const
Return a reference to the deque holding the footprint's fields.
Definition footprint.h:931
int GetLikelyAttribute() const
Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)
std::deque< PCB_GROUP * > m_groups
Definition footprint.h:1423
void Move(const VECTOR2I &aMoveVector) override
Move this object.
static bool ClassOf(const EDA_ITEM *aItem)
Definition footprint.h:307
wxString m_libDescription
Definition footprint.h:1480
bool HitTestOnLayer(const VECTOR2I &aPosition, PCB_LAYER_ID aLayer, int aAccuracy=0) const
Test if the point hits one or more of the footprint elements on a given layer.
void ApplyDefaultSettings(const BOARD &board, bool aStyleFields, bool aStyleText, bool aStyleShapes, bool aStyleDimensions, bool aStyleBarcodes)
Apply default board settings to the footprint field text properties.
void ClearTransientComponentClassNames()
Remove the transient component class names.
Definition footprint.h:1376
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource) const
Definition footprint.h:553
std::vector< wxString > m_netTiePadGroups
Definition footprint.h:1452
void InvalidateGeometryCaches()
Resets the caches for this footprint, for example if it was modified via the API.
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get a list of outline fonts referenced in the footprint.
void Add3DModel(FP_3DMODEL *a3DModel)
Add a3DModel definition to the end of the 3D model list.
void SetValue(const wxString &aValue)
Definition footprint.h:884
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.
void SetTransformScale(double aScaleX, double aScaleY)
FOOTPRINT_STACKUP m_stackupMode
Definition footprint.h:1477
PCB_FIELD & Reference()
Definition footprint.h:894
std::vector< std::set< wxString > > m_jumperPadGroups
A list of jumper pad groups, each of which is a set of pad numbers that should be jumpered together (...
Definition footprint.h:1459
const PCB_FIELD & Value() const
The const versions to keep the compiler happy.
Definition footprint.h:897
wxString GetReferenceAsString() const
Definition footprint.h:866
wxString m_sheetfile
Definition footprint.h:1484
PAD * FindPadByUuid(const KIID &aUuid) const
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars for this footprint.
std::optional< int > m_solderMaskMargin
Definition footprint.h:1471
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetUnitInfo(const std::vector< FP_UNIT_INFO > &aUnits)
Definition footprint.h:955
std::vector< const PAD * > GetPads(const wxString &aPadNumber, const PAD *aIgnore=nullptr) const
void AutoPositionFields()
Position Reference and Value fields at the top and bottom of footprint's bounding box.
void addMandatoryFields()
wxString m_keywords
Definition footprint.h:1481
const PCB_FIELD & Reference() const
Definition footprint.h:898
void SetTransientComponentClassNames(const std::unordered_set< wxString > &classNames)
Sets the transient component class names.
Definition footprint.h:1364
void SetScaleX(double aScaleX)
Definition footprint.h:429
void ClearAllNets()
Clear (i.e.
std::deque< PAD * > m_pads
Definition footprint.h:1421
void RescaleAroundPoint(const VECTOR2I &aCenter, double aSx, double aSy)
bool HasThroughHolePads() const
const PCB_POINTS & Points() const
Definition footprint.h:391
bool FitsEnabledLayers(const LSET &aEnabledLayers, int aCopperLayerCount) const override
Check if a board offering aEnabledLayers can hold this item.
Definition footprint.h:650
void BuildCourtyardCaches(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Build complex polygons of the courtyard areas from graphic items on the courtyard layers.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
bool HitTestAccurate(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if a point is inside the bounding polygon of the footprint.
bool IsNetTie() const
Definition footprint.h:523
bool GetDNPForVariant(const wxString &aVariantName) const
Get the DNP status for a specific variant.
wxString GetClass() const override
Return the class name.
Definition footprint.h:1214
void SetVariant(const FOOTPRINT_VARIANT &aVariant)
Add or update a variant.
std::unique_ptr< FOOTPRINT_COURTYARD_CACHE_DATA > m_courtyard_cache
Definition footprint.h:1497
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void IncrementReference(int aDelta)
Bump the current reference by aDelta.
int GetFileFormatVersionAtLoad() const
Definition footprint.h:1093
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition footprint.h:488
EXTRUDED_3D_BODY * GetExtrudedBody()
Definition footprint.h:400
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
KIID m_link
Definition footprint.h:1488
GROUPS & Groups()
Definition footprint.h:384
wxString GetFilters() const
Definition footprint.h:476
void SetSheetname(const wxString &aSheetname)
Definition footprint.h:471
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition footprint.h:1293
KIID GetLink() const
Definition footprint.h:1191
void SetAllowMissingCourtyard(bool aAllow)
Definition footprint.h:514
void BuildNetTieCache()
Cache the pads that are allowed to connect to each other in the footprint.
bool IsConflicting() const
std::vector< FP_3DMODEL > & Models()
Definition footprint.h:395
BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const override
Create a copy of this BOARD_ITEM.
const SHAPE_POLY_SET & GetCachedCourtyard(PCB_LAYER_ID aLayer) const
Return the cached courtyard area.
std::deque< PCB_FIELD * > & GetFields()
Definition footprint.h:932
wxString GetName() const override
Definition footprint.h:455
static const wxChar * StringLibNameInvalidChars(bool aUserReadable)
Test for validity of the name in a library of the footprint ( no spaces, dir separators ....
void SetLibDescription(const wxString &aDesc)
Definition footprint.h:462
bool TextOnly() const
const wxString & GetValue() const
Definition footprint.h:879
const COMPONENT_CLASS * GetStaticComponentClass() const
Returns the component class for this footprint.
void FixUpPadsForBoard(BOARD *aBoard)
Used post-loading of a footprint to adjust the layers on pads to match board inner layers.
bool GetExcludedFromPosFilesForVariant(const wxString &aVariantName) const
Get the exclude-from-position-files status for a specific variant.
void CheckShortingPads(const std::function< void(const PAD *, const PAD *, int aErrorCode, const VECTOR2I &)> &aErrorHandler)
Check for overlapping, different-numbered, non-net-tie pads.
FOOTPRINT_VARIANT * AddVariant(const wxString &aVariantName)
Add a new variant with the given name.
double GetArea(int aPadding=0) const
void SetNeedsPlaced(bool needsPlaced)
Definition footprint.h:683
wxString m_filters
Definition footprint.h:1485
const wxString & GetReference() const
Definition footprint.h:857
std::unique_ptr< FOOTPRINT_GEOMETRY_CACHE_DATA > m_geometry_cache
Definition footprint.h:1448
bool GetExcludedFromBOMForVariant(const wxString &aVariantName) const
Get the exclude-from-BOM status for a specific variant.
void CopyFrom(const BOARD_ITEM *aOther) override
void CheckNetTiePadGroups(const std::function< void(const wxString &)> &aErrorHandler)
Sanity check net-tie pad groups.
void SetFPIDAsString(const wxString &aFPID)
Definition footprint.h:451
void RenameVariant(const wxString &aOldName, const wxString &aNewName)
Rename a variant.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void SetBoardOnly(bool aIsBoardOnly=true)
Definition footprint.h:959
const std::vector< FP_3DMODEL > & Models() const
Definition footprint.h:396
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition footprint.h:483
TRANSFORM_TRS m_transform
Definition footprint.h:1427
timestamp_t m_lastEditTime
Definition footprint.h:1486
PAD * GetPad(const VECTOR2I &aPosition, const LSET &aLayerMask=LSET::AllLayersMask())
Get a pad at aPosition on aLayerMask in the footprint.
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
int GetFlag() const
Definition footprint.h:521
std::map< const BOARD_ITEM *, std::set< int > > m_netTieCache
Definition footprint.h:1455
wxString m_sheetname
Definition footprint.h:1483
LSET m_stackupLayers
Definition footprint.h:1476
int m_fileFormatVersionAtLoad
Definition footprint.h:1432
void SetLocalClearance(std::optional< int > aClearance)
Definition footprint.h:480
void SetPrivateLayers(const LSET &aLayers)
Adds an item to the container.
Definition footprint.h:316
const KIID_PATH & GetPath() const
Definition footprint.h:467
std::optional< int > GetLocalSolderMaskMargin() const
Definition footprint.h:482
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition footprint.h:486
wxString GetKeywords() const
Definition footprint.h:464
bool operator==(const BOARD_ITEM &aOther) const override
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition footprint.h:1321
void CheckFootprintAttributes(const std::function< void(const wxString &)> &aErrorHandler)
Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the p...
FOOTPRINT_STACKUP GetStackupMode() const
Definition footprint.h:501
virtual void swapData(BOARD_ITEM *aImage) override
wxString GetNextPadNumber(const wxString &aLastPadName) const
Return the next available pad number in the footprint.
double GetScaleY() const
Definition footprint.h:427
bool IsPlaced() const
Definition footprint.h:673
bool HasVariant(const wxString &aVariantName) const
Check if a variant exists.
VECTOR2I GetPosition() const override
Definition footprint.h:406
DRAWINGS & GraphicalItems()
Definition footprint.h:378
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
std::vector< SEARCH_TERM > m_searchTerms
Definition footprint.h:1506
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool operator==(const FP_3DMODEL &aOther) const
Definition footprint.h:176
VECTOR3D m_Offset
3D model offset (mm)
Definition footprint.h:171
double m_Opacity
Definition footprint.h:172
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition footprint.h:170
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition footprint.h:169
wxString m_Filename
The 3D shape filename in 3D library.
Definition footprint.h:173
bool m_Show
Include model in rendering.
Definition footprint.h:174
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:203
Class OUTLINE_FONT implements outline font drawing.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
double r
Red component.
Definition color4d.h:389
double g
Green component.
Definition color4d.h:390
double a
Alpha component.
Definition color4d.h:392
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
double b
Blue component.
Definition color4d.h:391
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:62
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllLayersMask()
Definition lset.cpp:637
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
Definition pad.h:61
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:39
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:72
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition shape.h:124
Handle a list of polygons defining a copper zone.
Definition zone.h:70
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
#define _(s)
@ DEGREES_T
Definition eda_angle.h:31
RECURSE_MODE
Definition eda_item.h:48
INSPECT_RESULT
Definition eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:89
EXTRUSION_MATERIAL
Definition footprint.h:93
INCLUDE_NPTH_T
Definition footprint.h:71
@ INCLUDE_NPTH
Definition footprint.h:73
@ DO_NOT_INCLUDE_NPTH
Definition footprint.h:72
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition footprint.h:82
@ FP_SMD
Definition footprint.h:84
@ FP_DNP
Definition footprint.h:89
@ FP_EXCLUDE_FROM_POS_FILES
Definition footprint.h:85
@ FP_BOARD_ONLY
Definition footprint.h:87
@ FP_EXCLUDE_FROM_BOM
Definition footprint.h:86
@ FP_JUST_ADDED
Definition footprint.h:88
@ FP_THROUGH_HOLE
Definition footprint.h:83
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition footprint.h:632
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition footprint.h:631
#define FP_PADS_are_LOCKED
Definition footprint.h:634
FOOTPRINT_STACKUP
Definition footprint.h:143
@ EXPAND_INNER_LAYERS
The 'normal' stackup handling, where there is a single inner layer (In1) and rule areas using it expa...
Definition footprint.h:148
@ CUSTOM_LAYERS
Stackup handling where the footprint can have any number of copper layers, and objects on those layer...
Definition footprint.h:153
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition footprint.h:633
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition kiid.h:43
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:181
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ B_Cu
Definition layer_ids.h:61
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
FLIP_DIRECTION
Definition mirror.h:23
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
std::vector< ZONE * > ZONES
std::deque< PCB_GROUP * > GROUPS
std::deque< PCB_CONSTRAINT * > CONSTRAINTS
std::deque< BOARD_ITEM * > DRAWINGS
std::deque< PCB_POINT * > PCB_POINTS
std::vector< wxString > m_pins
Definition footprint.h:952
bool operator()(const BOARD_ITEM *itemA, const BOARD_ITEM *itemB) const
bool operator()(const PAD *aFirst, const PAD *aSecond) const
bool operator()(const ZONE *aFirst, const ZONE *aSecond) const
A storage class for 128-bit hash value.
Definition hash_128.h:32
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:79
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR3< double > VECTOR3D
Definition vector3.h:230
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43