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, 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 FOOTPRINT_H
26#define FOOTPRINT_H
27
28#include <deque>
29#include <mutex>
30#include <unordered_set>
31
32#include <template_fieldnames.h>
33
35#include <board_item.h>
36#include <embedded_files.h>
37#include <layer_ids.h> // ALL_LAYERS definition.
38#include <lset.h>
39#include <lib_id.h>
40#include <lib_tree_item.h>
41#include <list>
42
43#include <zones.h>
45#include <pcb_item_containers.h>
46#include <pcb_field.h>
47#include <functional>
48#include <math/vector3.h>
50
51class LINE_READER;
52class EDA_3D_CANVAS;
53class PAD;
54class BOARD;
55class COMPONENT_CLASS;
57class MSG_PANEL_ITEM;
58class SHAPE;
59class REPORTER;
61class PCB_POINT;
62
63namespace KIGFX {
64class VIEW;
65}
66
67namespace KIFONT {
68class OUTLINE_FONT;
69}
70
76
83{
85 FP_SMD = 0x0002,
88 FP_BOARD_ONLY = 0x0010, // Footprint has no corresponding symbol
89 FP_JUST_ADDED = 0x0020, // Footprint just added by netlist update
90 FP_DNP = 0x0040
91};
92
106
108{
109public:
111 // Initialize with sensible values
112 m_Scale { 1, 1, 1 },
113 m_Rotation { 0, 0, 0 },
114 m_Offset { 0, 0, 0 },
115 m_Opacity( 1.0 ),
116 m_Show( true )
117 {
118 }
119
123 double m_Opacity;
124 wxString m_Filename;
125 bool m_Show;
126
127 bool operator==( const FP_3DMODEL& aOther ) const
128 {
129 return m_Scale == aOther.m_Scale
130 && m_Rotation == aOther.m_Rotation
131 && m_Offset == aOther.m_Offset
132 && m_Opacity == aOther.m_Opacity
133 && m_Filename == aOther.m_Filename
134 && m_Show == aOther.m_Show;
135 }
136};
137
138
140{
141 SHAPE_POLY_SET front; // Note that a footprint can have both front and back courtyards populated.
145};
146
147
157
158
166{
167public:
168 FOOTPRINT_VARIANT( const wxString& aName = wxEmptyString ) :
169 m_name( aName ),
170 m_dnp( false ),
171 m_excludedFromBOM( false ),
173 {
174 }
175
176 wxString GetName() const { return m_name; }
177 void SetName( const wxString& aName ) { m_name = aName; }
178
179 bool GetDNP() const { return m_dnp; }
180 void SetDNP( bool aDNP ) { m_dnp = aDNP; }
181
182 bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
183 void SetExcludedFromBOM( bool aExclude ) { m_excludedFromBOM = aExclude; }
184
186 void SetExcludedFromPosFiles( bool aExclude ) { m_excludedFromPosFiles = aExclude; }
187
193 wxString GetFieldValue( const wxString& aFieldName ) const
194 {
195 auto it = m_fields.find( aFieldName );
196
197 if( it != m_fields.end() )
198 return it->second;
199
200 return wxString();
201 }
202
208 void SetFieldValue( const wxString& aFieldName, const wxString& aValue )
209 {
210 m_fields[aFieldName] = aValue;
211 }
212
213 bool HasFieldValue( const wxString& aFieldName ) const
214 {
215 return m_fields.find( aFieldName ) != m_fields.end();
216 }
217
218 const std::map<wxString, wxString>& GetFields() const { return m_fields; }
219
220 bool operator==( const FOOTPRINT_VARIANT& aOther ) const
221 {
222 return m_name == aOther.m_name
223 && m_dnp == aOther.m_dnp
226 && m_fields == aOther.m_fields;
227 }
228
229private:
230 wxString m_name;
231 bool m_dnp;
234 std::map<wxString, wxString> m_fields;
235};
236
237
239{
240public:
241 FOOTPRINT( BOARD* parent );
242
243 FOOTPRINT( const FOOTPRINT& aFootprint );
244
245 // Move constructor and operator needed due to std containers inside the footprint
246 FOOTPRINT( FOOTPRINT&& aFootprint );
247
248 ~FOOTPRINT();
249
250 FOOTPRINT& operator=( const FOOTPRINT& aOther );
251 FOOTPRINT& operator=( FOOTPRINT&& aOther );
252
253 void CopyFrom( const BOARD_ITEM* aOther ) override;
254
255 void Serialize( google::protobuf::Any &aContainer ) const override;
256 bool Deserialize( const google::protobuf::Any &aContainer ) override;
257
258 static inline bool ClassOf( const EDA_ITEM* aItem )
259 {
260 return aItem && aItem->Type() == PCB_FOOTPRINT_T;
261 }
262
265
267 void SetPrivateLayers( const LSET& aLayers ) { m_privateLayers = aLayers; }
268
270 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
271 bool aSkipConnectivity = false ) override;
272
274 void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
275
283 void ClearAllNets();
284
292 bool FixUuids();
293
304
312
313 bool TextOnly() const;
314
315 // Virtual function
316 const BOX2I GetBoundingBox() const override;
317 const BOX2I GetBoundingBox( bool aIncludeText ) const;
318
322 const BOX2I GetLayerBoundingBox( const LSET& aLayers ) const;
323
324 VECTOR2I GetCenter() const override { return GetBoundingBox( false ).GetCenter(); }
325
326 std::deque<PAD*>& Pads() { return m_pads; }
327 const std::deque<PAD*>& Pads() const { return m_pads; }
328
330 const DRAWINGS& GraphicalItems() const { return m_drawings; }
331
332 ZONES& Zones() { return m_zones; }
333 const ZONES& Zones() const { return m_zones; }
334
335 GROUPS& Groups() { return m_groups; }
336 const GROUPS& Groups() const { return m_groups; }
337
339 const PCB_POINTS& Points() const { return m_points; }
340
341 bool HasThroughHolePads() const;
342
343 std::vector<FP_3DMODEL>& Models() { return m_3D_Drawings; }
344 const std::vector<FP_3DMODEL>& Models() const { return m_3D_Drawings; }
345
346 void SetPosition( const VECTOR2I& aPos ) override;
347 VECTOR2I GetPosition() const override { return m_pos; }
348
349 void SetOrientation( const EDA_ANGLE& aNewAngle );
351
356 void SetLayerAndFlip( PCB_LAYER_ID aLayer );
357
358 // to make property magic work
359 PCB_LAYER_ID GetLayer() const override { return BOARD_ITEM::GetLayer(); }
360
361 // For property system:
362 void SetOrientationDegrees( double aOrientation )
363 {
364 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
365 }
367 {
368 return m_orient.AsDegrees();
369 }
370
371 const LIB_ID& GetFPID() const { return m_fpid; }
372 void SetFPID( const LIB_ID& aFPID )
373 {
374 m_fpid = aFPID;
375 }
376
377 wxString GetFPIDAsString() const { return m_fpid.Format(); }
378 void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); }
379
380 // LIB_TREE_ITEM interface
381 LIB_ID GetLIB_ID() const override { return m_fpid; }
382 wxString GetName() const override { return m_fpid.GetLibItemName(); }
383 wxString GetLibNickname() const override { return m_fpid.GetLibNickname(); }
384 wxString GetDesc() override { return GetLibDescription(); }
385 int GetPinCount() override { return static_cast<int>( GetUniquePadCount( DO_NOT_INCLUDE_NPTH ) ); }
386 std::vector<SEARCH_TERM>& GetSearchTerms() override;
387
388 wxString GetLibDescription() const { return m_libDescription; }
389 void SetLibDescription( const wxString& aDesc ) { m_libDescription = aDesc; }
390
391 wxString GetKeywords() const { return m_keywords; }
392 void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
393
394 const KIID_PATH& GetPath() const { return m_path; }
395 void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
396
397 wxString GetSheetname() const { return m_sheetname; }
398 void SetSheetname( const wxString& aSheetname ) { m_sheetname = aSheetname; }
399
400 wxString GetSheetfile() const { return m_sheetfile; }
401 void SetSheetfile( const wxString& aSheetfile ) { m_sheetfile = aSheetfile; }
402
403 wxString GetFilters() const { return m_filters; }
404 void SetFilters( const wxString& aFilters ) { m_filters = aFilters; }
405
406 std::optional<int> GetLocalClearance() const { return m_clearance; }
407 void SetLocalClearance( std::optional<int> aClearance ) { m_clearance = aClearance; }
408
409 std::optional<int> GetLocalSolderMaskMargin() const { return m_solderMaskMargin; }
410 void SetLocalSolderMaskMargin( std::optional<int> aMargin ) { m_solderMaskMargin = aMargin; }
411
412 std::optional<int> GetLocalSolderPasteMargin() const { return m_solderPasteMargin; }
413 void SetLocalSolderPasteMargin( std::optional<int> aMargin ) { m_solderPasteMargin = aMargin; }
414
415 std::optional<double> GetLocalSolderPasteMarginRatio() const { return m_solderPasteMarginRatio; }
416 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio ) { m_solderPasteMarginRatio = aRatio; }
417
420
427 void SetStackupMode( FOOTPRINT_STACKUP aMode );
429
434 void SetStackupLayers( LSET aLayers );
435 const LSET& GetStackupLayers() const { return m_stackupLayers; }
436
437 int GetAttributes() const { return m_attributes; }
438 void SetAttributes( int aAttributes ) { m_attributes = aAttributes; }
439
441 void SetAllowMissingCourtyard( bool aAllow ) { m_allowMissingCourtyard = aAllow; }
442
444 void SetAllowSolderMaskBridges( bool aAllow ) { m_allowSolderMaskBridges = aAllow; }
445
446 void SetFlag( int aFlag ) { m_arflag = aFlag; }
447 void IncrementFlag() { m_arflag += 1; }
448 int GetFlag() const { return m_arflag; }
449
450 bool IsNetTie() const
451 {
452 for( const wxString& group : m_netTiePadGroups )
453 {
454 if( !group.IsEmpty() )
455 return true;
456 }
457
458 return false;
459 }
460
461 std::optional<int> GetLocalClearance( wxString* aSource ) const
462 {
463 if( m_clearance.has_value() && aSource )
464 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
465
466 return m_clearance;
467 }
468
475 std::optional<int> GetClearanceOverrides( wxString* aSource ) const
476 {
477 return GetLocalClearance( aSource );
478 }
479
481 {
483 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
484
485 return m_zoneConnection;
486 }
487
492 const std::vector<wxString>& GetNetTiePadGroups() const { return m_netTiePadGroups; }
493
495 {
496 m_netTiePadGroups.clear();
497 }
498
499 void AddNetTiePadGroup( const wxString& aGroup )
500 {
501 m_netTiePadGroups.emplace_back( aGroup );
502 }
503
508 std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
509
513 std::vector<PAD*> GetNetTiePads( PAD* aPad ) const;
514
520 int GetLikelyAttribute() const;
521
522 void Move( const VECTOR2I& aMoveVector ) override;
523
524 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
525
526 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
527
539 void MoveAnchorPosition( const VECTOR2I& aMoveVector );
540
544 bool IsFlipped() const { return GetLayer() == B_Cu; }
545
550 PCB_LAYER_ID GetSide() const;
551
555 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
556
557// m_footprintStatus bits:
558#define FP_is_LOCKED 0x01
559#define FP_is_PLACED 0x02
560#define FP_to_PLACE 0x04
561#define FP_PADS_are_LOCKED 0x08
562
563
564 bool IsLocked() const override
565 {
566 return ( m_fpStatus & FP_is_LOCKED ) != 0;
567 }
568
574 void SetLocked( bool isLocked ) override
575 {
576 if( isLocked )
578 else
580 }
581
585 bool IsConflicting() const;
586
587 bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
588 void SetIsPlaced( bool isPlaced )
589 {
590 if( isPlaced )
592 else
594 }
595
596 bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
597 void SetNeedsPlaced( bool needsPlaced )
598 {
599 if( needsPlaced )
601 else
603 }
604
606
617 void CheckFootprintAttributes( const std::function<void( const wxString& )>& aErrorHandler );
618
625 void CheckPads( UNITS_PROVIDER* aUnitsProvider,
626 const std::function<void( const PAD*, int, const wxString& )>& aErrorHandler );
627
633 void CheckShortingPads( const std::function<void( const PAD*, const PAD*, int aErrorCode,
634 const VECTOR2I& )>& aErrorHandler );
635
642 void CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
643 const BOARD_ITEM* bItem,
644 const BOARD_ITEM* cItem,
645 const VECTOR2I& )>& aErrorHandler );
646
653 void CheckNetTiePadGroups( const std::function<void( const wxString& )>& aErrorHandler );
654
655 void CheckClippedSilk( const std::function<void( BOARD_ITEM* aItemA,
656 BOARD_ITEM* aItemB,
657 const VECTOR2I& aPt )>& aErrorHandler );
661 void BuildNetTieCache();
662
666 const std::set<int>& GetNetTieCache( const BOARD_ITEM* aItem ) const
667 {
668 static const std::set<int> emptySet;
669
670 auto it = m_netTieCache.find( aItem );
671
672 if( it == m_netTieCache.end() )
673 return emptySet;
674
675 return it->second;
676 }
677
690 void TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
691 int aMaxError, ERROR_LOC aErrorLoc ) const;
692
707 void TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
708 int aError, ERROR_LOC aErrorLoc,
709 bool aIncludeText = true,
710 bool aIncludeShapes = true,
711 bool aIncludePrivateItems = false ) const;
712
716 void TransformFPTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
717 int aError, ERROR_LOC aErrorLoc ) const
718 {
719 TransformFPShapesToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc, true, false );
720 }
721
725 void GetContextualTextVars( wxArrayString* aVars ) const;
726
732 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
733
735 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
736
737 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
738
739 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
740
750 bool HitTestAccurate( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
751
752 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
753
754 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
755
764 bool HitTestOnLayer( const VECTOR2I& aPosition, PCB_LAYER_ID aLayer, int aAccuracy = 0 ) const;
765
766 bool HitTestOnLayer( const BOX2I& aRect, bool aContained, PCB_LAYER_ID aLayer, int aAccuracy = 0 ) const;
767
771 const wxString& GetReference() const { return Reference().GetText(); }
772
777 void SetReference( const wxString& aReference ) { Reference().SetText( aReference ); }
778
779 // Property system doesn't like const references
780 wxString GetReferenceAsString() const
781 {
782 return GetReference();
783 }
784
788 void IncrementReference( int aDelta );
789
793 const wxString& GetValue() const { return Value().GetText(); }
794
798 void SetValue( const wxString& aValue ) { Value().SetText( aValue ); }
799
800 // Property system doesn't like const references
801 wxString GetValueAsString() const
802 {
803 return GetValue();
804 }
805
809
811 const PCB_FIELD& Value() const { return *GetField( FIELD_T::VALUE ); }
812 const PCB_FIELD& Reference() const { return *GetField( FIELD_T::REFERENCE ); }
813
814 //-----<Fields>-----------------------------------------------------------
815
820 PCB_FIELD* GetField( FIELD_T aFieldType );
821 const PCB_FIELD* GetField( FIELD_T aFieldNdx ) const;
822
830 PCB_FIELD* GetField( const wxString& aFieldName ) const;
831
832 bool HasField( const wxString& aFieldName ) const;
833
840 void GetFields( std::vector<PCB_FIELD*>& aVector, bool aVisibleOnly ) const;
841
845 const std::deque<PCB_FIELD*>& GetFields() const { return m_fields; }
846 std::deque<PCB_FIELD*>& GetFields() { return m_fields; }
847
851 int GetNextFieldOrdinal() const;
852
860 void ApplyDefaultSettings( const BOARD& board, bool aStyleFields, bool aStyleText,
861 bool aStyleShapes, bool aStyleDimensions, bool aStyleBarcodes );
862
864 {
865 wxString m_unitName; // e.g. A
866 std::vector<wxString> m_pins; // pin numbers in this unit
867 };
868
869 void SetUnitInfo( const std::vector<FP_UNIT_INFO>& aUnits ) { m_unitInfo = aUnits; }
870 const std::vector<FP_UNIT_INFO>& GetUnitInfo() const { return m_unitInfo; }
871
872 bool IsBoardOnly() const { return m_attributes & FP_BOARD_ONLY; }
873 void SetBoardOnly( bool aIsBoardOnly = true )
874 {
875 if( aIsBoardOnly )
877 else
879 }
880
882 void SetExcludedFromPosFiles( bool aExclude = true )
883 {
884 if( aExclude )
886 else
888 }
889
891 void SetExcludedFromBOM( bool aExclude = true )
892 {
893 if( aExclude )
895 else
897 }
898
899 bool IsDNP() const { return m_attributes & FP_DNP; }
900 void SetDNP( bool aDNP = true )
901 {
902 if( aDNP )
904 else
906 }
907
908 // =====================================================================
909 // Variant Support
910 // =====================================================================
911
917 const FOOTPRINT_VARIANT* GetVariant( const wxString& aVariantName ) const;
918
924 FOOTPRINT_VARIANT* GetVariant( const wxString& aVariantName );
925
930 void SetVariant( const FOOTPRINT_VARIANT& aVariant );
931
937 FOOTPRINT_VARIANT* AddVariant( const wxString& aVariantName );
938
943 void DeleteVariant( const wxString& aVariantName );
944
950 void RenameVariant( const wxString& aOldName, const wxString& aNewName );
951
957 bool HasVariant( const wxString& aVariantName ) const;
958
964
973 bool GetDNPForVariant( const wxString& aVariantName ) const;
974
983 bool GetExcludedFromBOMForVariant( const wxString& aVariantName ) const;
984
993 bool GetExcludedFromPosFilesForVariant( const wxString& aVariantName ) const;
994
1004 wxString GetFieldValueForVariant( const wxString& aVariantName, const wxString& aFieldName ) const;
1005
1006 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
1008
1018 PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
1019
1027 PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask = LSET::AllLayersMask() );
1028
1029 std::vector<const PAD*> GetPads( const wxString& aPadNumber, const PAD* aIgnore = nullptr ) const;
1030
1038 unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
1039
1050 unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
1051
1055 std::set<wxString>
1057
1065 wxString GetNextPadNumber( const wxString& aLastPadName ) const;
1066
1069
1074 std::vector<std::set<wxString>>& JumperPadGroups() { return m_jumperPadGroups; }
1075 const std::vector<std::set<wxString>>& JumperPadGroups() const { return m_jumperPadGroups; }
1076
1078 std::optional<const std::set<wxString>> GetJumperPadGroup( const wxString& aPadNumber ) const;
1079
1083 void AutoPositionFields();
1084
1089 wxString GetTypeName() const;
1090
1091 double GetArea( int aPadding = 0 ) const;
1092
1093 KIID GetLink() const { return m_link; }
1094 void SetLink( const KIID& aLink ) { m_link = aLink; }
1095
1096 BOARD_ITEM* Duplicate( bool addToParentGroup, BOARD_COMMIT* aCommit = nullptr ) const override;
1097
1103 BOARD_ITEM* DuplicateItem( bool addToParentGroup, BOARD_COMMIT* aCommit, const BOARD_ITEM* aItem,
1104 bool addToFootprint = false );
1105
1111 void Add3DModel( FP_3DMODEL* a3DModel );
1112
1113 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
1114 const std::vector<KICAD_T>& aScanTypes ) override;
1115
1116 wxString GetClass() const override
1117 {
1118 return wxT( "FOOTPRINT" );
1119 }
1120
1121 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1122
1123 wxString DisambiguateItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1124
1125 BITMAPS GetMenuImage() const override;
1126
1127 EDA_ITEM* Clone() const override;
1128
1130 void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
1131
1132 virtual std::vector<int> ViewGetLayers() const override;
1133
1134 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1135
1136 virtual const BOX2I ViewBBox() const override;
1137
1145 static bool IsLibNameValid( const wxString& aName );
1146
1156 static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
1157
1161 bool FootprintNeedsUpdate( const FOOTPRINT* aLibFP, int aCompareFlags = 0,
1162 REPORTER* aReporter = nullptr );
1163
1178 void SetInitialComments( wxArrayString* aInitialComments )
1179 {
1180 delete m_initial_comments;
1181 m_initial_comments = aInitialComments;
1182 }
1183
1190 double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
1191
1192 static double GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLECTOR& aCollector );
1193
1195 const wxArrayString* GetInitialComments() const { return m_initial_comments; }
1196
1202 const SHAPE_POLY_SET& GetCourtyard( PCB_LAYER_ID aLayer ) const;
1203
1209 const SHAPE_POLY_SET& GetCachedCourtyard( PCB_LAYER_ID aLayer ) const;
1210
1217 void BuildCourtyardCaches( OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
1218
1219 // @copydoc BOARD_ITEM::GetEffectiveShape
1220 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
1221 FLASHING aFlash = FLASHING::DEFAULT ) const override;
1222
1224 {
1225 return static_cast<EMBEDDED_FILES*>( this );
1226 }
1227
1229 {
1230 return static_cast<const EMBEDDED_FILES*>( this );
1231 }
1232
1236 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
1237
1238 void EmbedFonts() override;
1239
1240 double Similarity( const BOARD_ITEM& aOther ) const override;
1241
1243 void SetStaticComponentClass( const COMPONENT_CLASS* aClass ) const;
1244
1247
1249 const COMPONENT_CLASS* GetComponentClass() const;
1250
1252 wxString GetComponentClassAsString() const;
1253
1255 void RecomputeComponentClass() const;
1256
1258 void InvalidateComponentClassCache() const;
1259
1266 void SetTransientComponentClassNames( const std::unordered_set<wxString>& classNames )
1267 {
1268 m_transientComponentClassNames = classNames;
1269 }
1270
1272 const std::unordered_set<wxString>& GetTransientComponentClassNames()
1273 {
1275 }
1276
1279
1281 void ResolveComponentClassNames( BOARD* aBoard,
1282 const std::unordered_set<wxString>& aComponentClassNames );
1283
1285 void FixUpPadsForBoard( BOARD* aBoard );
1286
1287 bool operator==( const BOARD_ITEM& aOther ) const override;
1288 bool operator==( const FOOTPRINT& aOther ) const;
1289
1290#if defined(DEBUG)
1291 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1292#endif
1293
1295 {
1296 bool operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const;
1297 };
1298
1300 {
1301 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
1302 };
1303 // TODO(JE) padstacks -- this code isn't used anywhere though
1304#if 0
1305 struct cmp_padstack
1306 {
1307 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
1308 };
1309#endif
1311 {
1312 bool operator()( const ZONE* aFirst, const ZONE* aSecond ) const;
1313 };
1314
1315protected:
1316 virtual void swapData( BOARD_ITEM* aImage ) override;
1317
1319
1320private:
1321 std::deque<PCB_FIELD*> m_fields; // Fields, mapped by name, owned by pointer
1322 std::deque<BOARD_ITEM*> m_drawings; // Drawings in the footprint, owned by pointer
1323 std::deque<PAD*> m_pads; // Pads, owned by pointer
1324 std::vector<ZONE*> m_zones; // Rule area zones, owned by pointer
1325 std::deque<PCB_GROUP*> m_groups; // Groups, owned by pointer
1326 std::deque<PCB_POINT*> m_points; // Points, owned by pointer
1327
1328 EDA_ANGLE m_orient; // Orientation
1329 VECTOR2I m_pos; // Position of footprint on the board in internal units.
1330 LIB_ID m_fpid; // The #LIB_ID of the FOOTPRINT.
1331 int m_attributes; // Flag bits (see FOOTPRINT_ATTR_T)
1332 int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
1334
1337
1338 // Bounding box caching strategy:
1339 // While we attempt to notice the low-hanging fruit operations and update the bounding boxes
1340 // accordingly, we rely mostly on a "if anything changed then the caches are stale" approach.
1341 // We implement this by having PCB_BASE_FRAME's OnModify() method increment an operation
1342 // counter, and storing that as a timestamp for the various caches.
1343 // This means caches will get regenerated often -- but still far less often than if we had no
1344 // caches at all. The principal opitmization would be to change to dirty flag and make sure
1345 // that any edit that could affect the bounding boxes (including edits to the footprint
1346 // children) marked the bounding boxes dirty. It would definitely be faster -- but also more
1347 // fragile.
1348 mutable std::mutex m_geometry_cache_mutex;
1349 mutable std::unique_ptr<FOOTPRINT_GEOMETRY_CACHE_DATA> m_geometry_cache;
1350
1351 // A list of pad groups, each of which is allowed to short nets within their group.
1352 // A pad group is a comma-separated list of pad numbers.
1353 std::vector<wxString> m_netTiePadGroups;
1354
1355 // A list of 1:N footprint item to allowed net numbers
1356 std::map<const BOARD_ITEM*, std::set<int>> m_netTieCache;
1357
1360 std::vector<std::set<wxString>> m_jumperPadGroups;
1361
1365
1368
1369 // Optional overrides
1371 std::optional<int> m_clearance;
1372 std::optional<int> m_solderMaskMargin; // Solder mask margin
1373 std::optional<int> m_solderPasteMargin; // Solder paste margin absolute value
1374 std::optional<double> m_solderPasteMarginRatio; // Solder mask margin ratio of pad size
1375 // The final margin is the sum of these 2 values
1376
1377 LSET m_stackupLayers; // Layers in the stackup
1378 FOOTPRINT_STACKUP m_stackupMode; // Stackup mode for this footprint
1379 LSET m_privateLayers; // Layers visible only in the footprint editor
1380
1381 wxString m_libDescription; // File name and path for documentation file.
1382 wxString m_keywords; // Search keywords to find footprint in library.
1383 KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
1384 wxString m_sheetname; // Name of the sheet containing the symbol for this footprint
1385 wxString m_sheetfile; // File of the sheet containing the symbol for this footprint
1386 wxString m_filters; // Footprint filters from symbol
1388 int m_arflag; // Use to trace ratsnest and auto routing.
1389 KIID m_link; // Temporary logical link used during editing
1390
1391 std::vector<FP_3DMODEL> m_3D_Drawings; // 3D models.
1392 wxArrayString* m_initial_comments; // s-expression comments in the footprint,
1393 // lazily allocated only if needed for speed
1394
1395 mutable std::unique_ptr<FOOTPRINT_COURTYARD_CACHE_DATA> m_courtyard_cache;
1396 mutable std::mutex m_courtyard_cache_mutex;
1397
1398 std::unordered_set<wxString> m_transientComponentClassNames;
1399 std::unique_ptr<COMPONENT_CLASS_CACHE_PROXY> m_componentClassCacheProxy;
1400
1401 // Optional unit mapping information for multi-unit symbols
1402 std::vector<FP_UNIT_INFO> m_unitInfo;
1403
1404 std::vector<SEARCH_TERM> m_searchTerms;
1405};
1406
1407#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:922
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:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:268
friend class BOARD
Definition board_item.h:494
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
constexpr const Vec GetCenter() const
Definition box2.h:230
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:100
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:109
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:254
EMBEDDED_FILES()=default
Variant information for a footprint.
Definition footprint.h:166
wxString GetName() const
Definition footprint.h:176
FOOTPRINT_VARIANT(const wxString &aName=wxEmptyString)
Definition footprint.h:168
bool HasFieldValue(const wxString &aFieldName) const
Definition footprint.h:213
bool m_excludedFromPosFiles
Definition footprint.h:233
void SetExcludedFromPosFiles(bool aExclude)
Definition footprint.h:186
wxString GetFieldValue(const wxString &aFieldName) const
Get a field value override for this variant.
Definition footprint.h:193
void SetName(const wxString &aName)
Definition footprint.h:177
const std::map< wxString, wxString > & GetFields() const
Definition footprint.h:218
bool GetExcludedFromBOM() const
Definition footprint.h:182
bool operator==(const FOOTPRINT_VARIANT &aOther) const
Definition footprint.h:220
void SetDNP(bool aDNP)
Definition footprint.h:180
bool GetExcludedFromPosFiles() const
Definition footprint.h:185
bool GetDNP() const
Definition footprint.h:179
std::map< wxString, wxString > m_fields
Field value overrides for this variant.
Definition footprint.h:234
void SetFieldValue(const wxString &aFieldName, const wxString &aValue)
Set a field value override for this variant.
Definition footprint.h:208
void SetExcludedFromBOM(bool aExclude)
Definition footprint.h:183
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:1067
const CASE_INSENSITIVE_MAP< FOOTPRINT_VARIANT > & GetVariants() const
Get all variants.
Definition footprint.h:963
std::optional< int > GetClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition footprint.h:475
void EmbedFonts() override
bool AllowSolderMaskBridges() const
Definition footprint.h:443
void SetPosition(const VECTOR2I &aPos) override
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:372
LIB_ID m_fpid
Definition footprint.h:1330
wxString GetLibDescription() const
Definition footprint.h:388
ZONE_CONNECTION GetLocalZoneConnection() const
Definition footprint.h:419
void SetLink(const KIID &aLink)
Definition footprint.h:1094
KIID_PATH m_path
Definition footprint.h:1383
std::deque< BOARD_ITEM * > m_drawings
Definition footprint.h:1322
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:872
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:327
bool IsDNP() const
Definition footprint.h:899
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition footprint.h:574
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition footprint.h:324
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:350
ZONES & Zones()
Definition footprint.h:332
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:1326
void CheckClippedSilk(const std::function< void(BOARD_ITEM *aItemA, BOARD_ITEM *aItemB, const VECTOR2I &aPt)> &aErrorHandler)
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:588
ZONE_CONNECTION m_zoneConnection
Definition footprint.h:1370
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this footprint.
PCB_POINTS & Points()
Definition footprint.h:338
static double GetCoverageArea(const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
bool IsExcludedFromBOM() const
Definition footprint.h:890
void SetOrientation(const EDA_ANGLE &aNewAngle)
void SetFlag(int aFlag)
Definition footprint.h:446
std::optional< double > m_solderPasteMarginRatio
Definition footprint.h:1374
void SetDNP(bool aDNP=true)
Definition footprint.h:900
void SetAllowSolderMaskBridges(bool aAllow)
Definition footprint.h:444
void RecomputeComponentClass() const
Forces immediate recalculation of the component class for this footprint.
std::vector< ZONE * > m_zones
Definition footprint.h:1324
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:416
std::vector< SEARCH_TERM > & GetSearchTerms() override
void IncrementFlag()
Definition footprint.h:447
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:1371
bool m_duplicatePadNumbersAreJumpers
Flag that this footprint should automatically treat sets of two or more pads with the same number as ...
Definition footprint.h:1364
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:891
wxString GetSheetname() const
Definition footprint.h:397
int m_fpStatus
Definition footprint.h:1332
void SetPath(const KIID_PATH &aPath)
Definition footprint.h:395
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:404
void SetKeywords(const wxString &aKeywords)
Definition footprint.h:392
void SetStaticComponentClass(const COMPONENT_CLASS *aClass) const
Sets the component class object pointer for this footprint.
const DRAWINGS & GraphicalItems() const
Definition footprint.h:330
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:1178
int m_attributes
Definition footprint.h:1331
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:383
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:1391
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:1366
const std::vector< FP_UNIT_INFO > & GetUnitInfo() const
Definition footprint.h:870
std::unordered_set< wxString > m_transientComponentClassNames
Definition footprint.h:1398
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:438
void SetSheetfile(const wxString &aSheetfile)
Definition footprint.h:401
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
std::optional< int > GetLocalSolderPasteMargin() const
Definition footprint.h:412
std::unique_ptr< COMPONENT_CLASS_CACHE_PROXY > m_componentClassCacheProxy
Definition footprint.h:1399
wxArrayString * m_initial_comments
Definition footprint.h:1392
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:381
std::deque< PCB_FIELD * > m_fields
Definition footprint.h:1321
std::mutex m_geometry_cache_mutex
Definition footprint.h:1348
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:807
const EMBEDDED_FILES * GetEmbeddedFiles() const
Definition footprint.h:1228
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::optional< int > m_solderPasteMargin
Definition footprint.h:1373
const std::vector< std::set< wxString > > & JumperPadGroups() const
Definition footprint.h:1075
void SetFileFormatVersionAtLoad(int aVersion)
Definition footprint.h:1006
std::mutex m_courtyard_cache_mutex
Definition footprint.h:1396
void SetExcludedFromPosFiles(bool aExclude=true)
Definition footprint.h:882
void SetOrientationDegrees(double aOrientation)
Definition footprint.h:362
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:406
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:716
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:1074
void SetDuplicatePadNumbersAreJumpers(bool aEnabled)
Definition footprint.h:1068
bool m_allowSolderMaskBridges
Definition footprint.h:1367
FOOTPRINT & operator=(const FOOTPRINT &aOther)
bool HasField(const wxString &aFieldName) const
PCB_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this footprint.
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.
double GetOrientationDegrees() const
Definition footprint.h:366
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:326
void ResolveComponentClassNames(BOARD *aBoard, const std::unordered_set< wxString > &aComponentClassNames)
Resolves a set of component class names to this footprint's actual component class.
wxString GetDesc() override
Definition footprint.h:384
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetAttributes() const
Definition footprint.h:437
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:461
const COMPONENT_CLASS * GetComponentClass() const
Returns the component class for this footprint.
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition footprint.h:418
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:84
void ClearNetTiePadGroups()
Definition footprint.h:494
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:359
LSET GetPrivateLayers() const
Definition footprint.h:266
wxString GetFPIDAsString() const
Definition footprint.h:377
CASE_INSENSITIVE_MAP< FOOTPRINT_VARIANT > m_variants
Variant data for this footprint, keyed by variant name.
Definition footprint.h:1336
wxString GetValueAsString() const
Definition footprint.h:801
bool AllowMissingCourtyard() const
Definition footprint.h:440
void DeleteVariant(const wxString &aVariantName)
Delete a variant by name.
const ZONES & Zones() const
Definition footprint.h:333
wxString GetComponentClassAsString() const
Used for display in the properties panel.
bool IsFlipped() const
Definition footprint.h:544
wxString GetSheetfile() const
Definition footprint.h:400
int GetPinCount() override
The pin count for symbols or the unique pad count for footprints.
Definition footprint.h:385
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...
wxString GetTypeName() const
Get the type of footprint.
bool NeedsPlaced() const
Definition footprint.h:596
const std::vector< wxString > & GetNetTiePadGroups() const
Definition footprint.h:492
const LIB_ID & GetFPID() const
Definition footprint.h:371
const std::unordered_set< wxString > & GetTransientComponentClassNames()
Gets the transient component class names.
Definition footprint.h:1272
void SetReference(const wxString &aReference)
Definition footprint.h:777
bool IsLocked() const override
Definition footprint.h:564
std::vector< FP_UNIT_INFO > m_unitInfo
Definition footprint.h:1402
const GROUPS & Groups() const
Definition footprint.h:336
bool IsExcludedFromPosFiles() const
Definition footprint.h:881
void SetLayerAndFlip(PCB_LAYER_ID aLayer)
Used as Layer property setter – performs a flip if necessary to set the footprint layer.
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:499
bool LegacyPadsLocked() const
Definition footprint.h:605
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
LSET m_privateLayers
Definition footprint.h:1379
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:666
const LSET & GetStackupLayers() const
Definition footprint.h:435
const std::deque< PCB_FIELD * > & GetFields() const
Return a reference to the deque holding the footprint's fields.
Definition footprint.h:845
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:1325
void Move(const VECTOR2I &aMoveVector) override
Move this object.
static bool ClassOf(const EDA_ITEM *aItem)
Definition footprint.h:258
wxString m_libDescription
Definition footprint.h:1381
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.
VECTOR2I m_pos
Definition footprint.h:1329
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:1278
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource) const
Definition footprint.h:480
std::vector< wxString > m_netTiePadGroups
Definition footprint.h:1353
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:798
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.
FOOTPRINT_STACKUP m_stackupMode
Definition footprint.h:1378
PCB_FIELD & Reference()
Definition footprint.h:808
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:1360
const PCB_FIELD & Value() const
The const versions to keep the compiler happy.
Definition footprint.h:811
wxString GetReferenceAsString() const
Definition footprint.h:780
wxString m_sheetfile
Definition footprint.h:1385
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars for this footprint.
std::optional< int > m_solderMaskMargin
Definition footprint.h:1372
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:869
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:1382
const PCB_FIELD & Reference() const
Definition footprint.h:812
void SetTransientComponentClassNames(const std::unordered_set< wxString > &classNames)
Sets the transient component class names.
Definition footprint.h:1266
void ClearAllNets()
Clear (i.e.
std::deque< PAD * > m_pads
Definition footprint.h:1323
bool HasThroughHolePads() const
const PCB_POINTS & Points() const
Definition footprint.h:339
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.
EDA_ANGLE m_orient
Definition footprint.h:1328
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:450
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:1116
void SetVariant(const FOOTPRINT_VARIANT &aVariant)
Add or update a variant.
std::unique_ptr< FOOTPRINT_COURTYARD_CACHE_DATA > m_courtyard_cache
Definition footprint.h:1395
void IncrementReference(int aDelta)
Bump the current reference by aDelta.
int GetFileFormatVersionAtLoad() const
Definition footprint.h:1007
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition footprint.h:415
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
KIID m_link
Definition footprint.h:1389
GROUPS & Groups()
Definition footprint.h:335
wxString GetFilters() const
Definition footprint.h:403
void SetSheetname(const wxString &aSheetname)
Definition footprint.h:398
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition footprint.h:1195
KIID GetLink() const
Definition footprint.h:1093
void SetAllowMissingCourtyard(bool aAllow)
Definition footprint.h:441
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:343
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:846
wxString GetName() const override
Definition footprint.h:382
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:389
bool TextOnly() const
const wxString & GetValue() const
Definition footprint.h:793
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:597
wxString m_filters
Definition footprint.h:1386
const wxString & GetReference() const
Definition footprint.h:771
std::unique_ptr< FOOTPRINT_GEOMETRY_CACHE_DATA > m_geometry_cache
Definition footprint.h:1349
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:378
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:873
const std::vector< FP_3DMODEL > & Models() const
Definition footprint.h:344
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition footprint.h:410
timestamp_t m_lastEditTime
Definition footprint.h:1387
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:448
std::map< const BOARD_ITEM *, std::set< int > > m_netTieCache
Definition footprint.h:1356
wxString m_sheetname
Definition footprint.h:1384
LSET m_stackupLayers
Definition footprint.h:1377
int m_fileFormatVersionAtLoad
Definition footprint.h:1333
void SetLocalClearance(std::optional< int > aClearance)
Definition footprint.h:407
void SetPrivateLayers(const LSET &aLayers)
Adds an item to the container.
Definition footprint.h:267
const KIID_PATH & GetPath() const
Definition footprint.h:394
std::optional< int > GetLocalSolderMaskMargin() const
Definition footprint.h:409
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition footprint.h:413
wxString GetKeywords() const
Definition footprint.h:391
bool operator==(const BOARD_ITEM &aOther) const override
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition footprint.h:1223
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:428
virtual void swapData(BOARD_ITEM *aImage) override
wxString GetNextPadNumber(const wxString &aLastPadName) const
Return the next available pad number in the footprint.
bool IsPlaced() const
Definition footprint.h:587
bool HasVariant(const wxString &aVariantName) const
Check if a variant exists.
VECTOR2I GetPosition() const override
Definition footprint.h:347
DRAWINGS & GraphicalItems()
Definition footprint.h:329
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:1404
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:127
VECTOR3D m_Offset
3D model offset (mm)
Definition footprint.h:122
double m_Opacity
Definition footprint.h:123
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition footprint.h:121
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition footprint.h:120
wxString m_Filename
The 3D shape filename in 3D library.
Definition footprint.h:124
bool m_Show
Include model in rendering.
Definition footprint.h:125
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:207
Class OUTLINE_FONT implements outline font drawing.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:67
Definition kiid.h:48
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
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:66
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllLayersMask()
Definition lset.cpp:641
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:54
Definition pad.h:55
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:43
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
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:126
Handle a list of polygons defining a copper zone.
Definition zone.h:74
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:52
INSPECT_RESULT
Definition eda_item.h:46
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:93
INCLUDE_NPTH_T
Definition footprint.h:72
@ INCLUDE_NPTH
Definition footprint.h:74
@ DO_NOT_INCLUDE_NPTH
Definition footprint.h:73
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition footprint.h:83
@ FP_SMD
Definition footprint.h:85
@ FP_DNP
Definition footprint.h:90
@ FP_EXCLUDE_FROM_POS_FILES
Definition footprint.h:86
@ FP_BOARD_ONLY
Definition footprint.h:88
@ FP_EXCLUDE_FROM_BOM
Definition footprint.h:87
@ FP_JUST_ADDED
Definition footprint.h:89
@ FP_THROUGH_HOLE
Definition footprint.h:84
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition footprint.h:559
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition footprint.h:558
#define FP_PADS_are_LOCKED
Definition footprint.h:561
FOOTPRINT_STACKUP
Definition footprint.h:94
@ EXPAND_INNER_LAYERS
The 'normal' stackup handling, where there is a single inner layer (In1) and rule areas using it expa...
Definition footprint.h:99
@ CUSTOM_LAYERS
Stackup handling where the footprint can have any number of copper layers, and objects on those layer...
Definition footprint.h:104
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition footprint.h:560
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:45
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:184
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:185
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ B_Cu
Definition layer_ids.h:65
@ UNDEFINED_LAYER
Definition layer_ids.h:61
FLIP_DIRECTION
Definition mirror.h:27
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
std::vector< ZONE * > ZONES
std::deque< PCB_GROUP * > GROUPS
std::deque< BOARD_ITEM * > DRAWINGS
std::deque< PCB_POINT * > PCB_POINTS
std::vector< wxString > m_pins
Definition footprint.h:866
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:36
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:83
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
VECTOR3< double > VECTOR3D
Definition vector3.h:230
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:47