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 <map>
26#include <memory>
27#include <mutex>
28#include <optional>
29#include <unordered_set>
30
31#include <template_fieldnames.h>
32
34#include <board_item.h>
35#include <embedded_files.h>
36#include <jumper_group.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
42#include <zones.h>
44#include <pcb_item_containers.h>
45#include <pcb_field.h>
46#include <functional>
47#include <math/vector3.h>
50#include <gal/color4d.h>
51
52class LINE_READER;
53class EDA_3D_CANVAS;
54class PAD;
55class BOARD;
56class COMPONENT_CLASS;
58class MSG_PANEL_ITEM;
59class SHAPE;
60class REPORTER;
63class PCB_3D_BODY;
64class PCB_POINT;
65
66namespace KIGFX {
67class VIEW;
68}
69
70namespace KIFONT {
71class OUTLINE_FONT;
72}
73
74namespace kiapi::board::types
75{
76class Footprint;
77}
78
85{
87 FP_SMD = 0x0002,
90 FP_BOARD_ONLY = 0x0010, // Footprint has no corresponding symbol
91 FP_JUST_ADDED = 0x0020, // Footprint just added by netlist update
92 FP_DNP = 0x0040,
94};
95
96
103
104
118
120{
121public:
123 // Initialize with sensible values
124 m_Scale { 1, 1, 1 },
125 m_Rotation { 0, 0, 0 },
126 m_Offset { 0, 0, 0 },
127 m_Opacity( 1.0 ),
128 m_Show( true )
129 {
130 }
131
135 double m_Opacity;
136 wxString m_Filename;
137 bool m_Show;
138
139 bool operator==( const FP_3DMODEL& aOther ) const
140 {
141 return m_Scale == aOther.m_Scale
142 && m_Rotation == aOther.m_Rotation
143 && m_Offset == aOther.m_Offset
144 && m_Opacity == aOther.m_Opacity
145 && m_Filename == aOther.m_Filename
146 && m_Show == aOther.m_Show;
147 }
148};
149
150
152{
153 SHAPE_POLY_SET front; // Note that a footprint can have both front and back courtyards populated.
157};
158
159
169
170
178{
179public:
180 FOOTPRINT_VARIANT( const wxString& aName = wxEmptyString ) :
181 m_name( aName ),
182 m_dnp( false ),
183 m_excludedFromBOM( false ),
184 m_excludedFromSim( false ),
186 {
187 }
188
189 wxString GetName() const { return m_name; }
190 void SetName( const wxString& aName ) { m_name = aName; }
191
192 bool GetDNP() const { return m_dnp; }
193 void SetDNP( bool aDNP ) { m_dnp = aDNP; }
194
195 bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
196 void SetExcludedFromBOM( bool aExclude ) { m_excludedFromBOM = aExclude; }
197
198 bool GetExcludedFromSim() const { return m_excludedFromSim; }
199 void SetExcludedFromSim( bool aExclude ) { m_excludedFromSim = aExclude; }
200
202 void SetExcludedFromPosFiles( bool aExclude ) { m_excludedFromPosFiles = aExclude; }
203
209 wxString GetFieldValue( const wxString& aFieldName ) const
210 {
211 auto it = m_fields.find( aFieldName );
212
213 if( it != m_fields.end() )
214 return it->second;
215
216 return wxString();
217 }
218
224 void SetFieldValue( const wxString& aFieldName, const wxString& aValue )
225 {
226 m_fields[aFieldName] = aValue;
227 }
228
232 void RemoveFieldValue( const wxString& aFieldName )
233 {
234 m_fields.erase( aFieldName );
235 }
236
237 bool HasFieldValue( const wxString& aFieldName ) const
238 {
239 return m_fields.find( aFieldName ) != m_fields.end();
240 }
241
242 const std::map<wxString, wxString>& GetFields() const { return m_fields; }
243
244 bool operator==( const FOOTPRINT_VARIANT& aOther ) const
245 {
246 return m_name == aOther.m_name
247 && m_dnp == aOther.m_dnp
251 && m_fields == aOther.m_fields;
252 }
253
254private:
255 wxString m_name;
256 bool m_dnp;
260 std::map<wxString, wxString> m_fields;
261};
262
263
265{
266public:
267 FOOTPRINT( BOARD* parent );
268
269 FOOTPRINT( const FOOTPRINT& aFootprint );
270
271 // Move constructor and operator needed due to std containers inside the footprint
272 FOOTPRINT( FOOTPRINT&& aFootprint );
273
274 ~FOOTPRINT();
275
276 FOOTPRINT& operator=( const FOOTPRINT& aOther );
277 FOOTPRINT& operator=( FOOTPRINT&& aOther );
278
279 void CopyFrom( const BOARD_ITEM* aOther ) override;
280
281 void Serialize( google::protobuf::Any &aContainer ) const override;
282 bool Deserialize( const google::protobuf::Any &aContainer ) override;
283
284 void SerializeDefinition( kiapi::board::types::Footprint* aOutput ) const;
285 bool DeserializeDefinition( const kiapi::board::types::Footprint& aInput );
286
287 static inline bool ClassOf( const EDA_ITEM* aItem )
288 {
289 return aItem && aItem->Type() == PCB_FOOTPRINT_T;
290 }
291
294
296 void SetPrivateLayers( const LSET& aLayers ) { m_privateLayers = aLayers; }
297
299 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
300 bool aSkipConnectivity = false ) override;
301
303 void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
304
312 void ClearAllNets();
313
321 bool FixUuids();
322
333
341
342 bool TextOnly() const;
343
344 // Virtual function
345 const BOX2I GetBoundingBox() const override;
346 const BOX2I GetBoundingBox( bool aIncludeText ) const;
347
351 const BOX2I GetLayerBoundingBox( const LSET& aLayers ) const;
352
353 VECTOR2I GetCenter() const override { return GetBoundingBox( false ).GetCenter(); }
354
355 std::deque<PAD*>& Pads() { return m_pads; }
356 const std::deque<PAD*>& Pads() const { return m_pads; }
357
359 const DRAWINGS& GraphicalItems() const { return m_drawings; }
360
361 ZONES& Zones() { return m_zones; }
362 const ZONES& Zones() const { return m_zones; }
363
364 GROUPS& Groups() { return m_groups; }
365 const GROUPS& Groups() const { return m_groups; }
366
368 const CONSTRAINTS& Constraints() const { return m_constraints; }
369
371 const PCB_POINTS& Points() const { return m_points; }
372
373 bool HasThroughHolePads() const;
374
375 std::vector<FP_3DMODEL>& Models() { return m_3D_Drawings; }
376 const std::vector<FP_3DMODEL>& Models() const { return m_3D_Drawings; }
377
378 void SetPosition( const VECTOR2I& aPos ) override;
379 VECTOR2I GetPosition() const override { return m_transform.GetTranslate(); }
380
381 void SetOrientation( const EDA_ANGLE& aNewAngle );
382 EDA_ANGLE GetOrientation() const { return m_transform.GetRotate(); }
383
388 void SetLayerAndFlip( PCB_LAYER_ID aLayer );
389
390 void SetLayer( PCB_LAYER_ID aLayer ) override;
391
392 // A footprint's m_layer is set to F_Cu or B_Cu to encode which side of the board it's on.
393 PCB_LAYER_ID GetLayer() const override { return m_layer; }
394
395 const TRANSFORM_TRS& GetTransform() const { return m_transform; }
396
397 void SetTransformScale( double aScaleX, double aScaleY );
398
399 double GetScaleX() const { return m_transform.GetScaleX(); }
400 double GetScaleY() const { return m_transform.GetScaleY(); }
401
402 void SetScaleX( double aScaleX ) { SetTransformScale( aScaleX, m_transform.GetScaleY() ); }
403
404 void SetScaleY( double aScaleY ) { SetTransformScale( m_transform.GetScaleX(), aScaleY ); }
405
406 void RescaleAroundPoint( const VECTOR2I& aCenter, double aSx, double aSy );
407
408 void SetOrientationDegrees( double aOrientation )
409 {
410 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
411 }
413 {
414 return m_transform.GetRotate().AsDegrees();
415 }
416
417 const LIB_ID& GetFPID() const { return m_fpid; }
418 void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
419 wxString GetFPIDAsString() const { return m_fpid.Format(); }
420 void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); }
421
422 std::deque<PCB_3D_BODY*>& Bodies() { return m_bodies; }
423 const std::deque<PCB_3D_BODY*>& Bodies() const { return m_bodies; }
424
426 bool HasBody() const { return !m_bodies.empty(); }
427 const PCB_3D_BODY* GetBody() const { return m_bodies.empty() ? nullptr : m_bodies.front(); }
428 PCB_3D_BODY* GetBody() { return m_bodies.empty() ? nullptr : m_bodies.front(); }
430 void ClearBody();
431
438 int GetHeight() const { return m_height; }
439 void SetHeight( int aHeight ) { m_height = aHeight; }
440
441 // LIB_TREE_ITEM interface
442 LIB_ID GetLIB_ID() const override { return m_fpid; }
443 wxString GetName() const override { return m_fpid.GetLibItemName(); }
444 wxString GetLibNickname() const override { return m_fpid.GetLibNickname(); }
445 wxString GetDesc() override { return GetLibDescription(); }
446 int GetPinCount() const override { return static_cast<int>( GetNumberedPadCount() ); }
447 std::vector<SEARCH_TERM>& GetSearchTerms() override;
448
449 wxString GetLibDescription() const { return m_libDescription; }
450 void SetLibDescription( const wxString& aDesc ) { m_libDescription = aDesc; }
451
452 wxString GetKeywords() const { return m_keywords; }
453 void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
454
455 const KIID_PATH& GetPath() const { return m_path; }
456 void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
457
467 bool IsWithinSchematicSheet( const KIID_PATH& aSheetPath ) const;
468
469 wxString GetSheetname() const { return m_sheetname; }
470 void SetSheetname( const wxString& aSheetname ) { m_sheetname = aSheetname; }
471
472 wxString GetSheetfile() const { return m_sheetfile; }
473 void SetSheetfile( const wxString& aSheetfile ) { m_sheetfile = aSheetfile; }
474
475 wxString GetFilters() const { return m_filters; }
476 void SetFilters( const wxString& aFilters ) { m_filters = aFilters; }
477
478 std::optional<int> GetLocalClearance() const { return m_clearance; }
479 void SetLocalClearance( std::optional<int> aClearance ) { m_clearance = aClearance; }
480
481 std::optional<int> GetLocalSolderMaskMargin() const { return m_solderMaskMargin; }
482 void SetLocalSolderMaskMargin( std::optional<int> aMargin ) { m_solderMaskMargin = aMargin; }
483
484 std::optional<int> GetLocalSolderPasteMargin() const { return m_solderPasteMargin; }
485 void SetLocalSolderPasteMargin( std::optional<int> aMargin ) { m_solderPasteMargin = aMargin; }
486
487 std::optional<double> GetLocalSolderPasteMarginRatio() const { return m_solderPasteMarginRatio; }
488 void SetLocalSolderPasteMarginRatio( std::optional<double> aRatio ) { m_solderPasteMarginRatio = aRatio; }
489
492
499 void SetStackupMode( FOOTPRINT_STACKUP aMode );
501
506 void SetStackupLayers( LSET aLayers );
507 const LSET& GetStackupLayers() const { return m_stackupLayers; }
508
509 int GetAttributes() const { return m_attributes; }
510 void SetAttributes( int aAttributes ) { m_attributes = aAttributes; }
511
513 void SetFootprintType( FOOTPRINT_TYPE aFootprintType );
514
516 void SetAllowMissingCourtyard( bool aAllow ) { m_allowMissingCourtyard = aAllow; }
517
519 void SetAllowSolderMaskBridges( bool aAllow ) { m_allowSolderMaskBridges = aAllow; }
520
521 void SetFlag( int aFlag ) { m_arflag = aFlag; }
522 void IncrementFlag() { m_arflag += 1; }
523 int GetFlag() const { return m_arflag; }
524
525 bool IsNetTie() const
526 {
527 for( const wxString& group : m_netTiePadGroups )
528 {
529 if( !group.IsEmpty() )
530 return true;
531 }
532
533 return false;
534 }
535
536 std::optional<int> GetLocalClearance( wxString* aSource ) const
537 {
538 if( m_clearance.has_value() && aSource )
539 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
540
541 return m_clearance;
542 }
543
550 std::optional<int> GetClearanceOverrides( wxString* aSource ) const
551 {
552 return GetLocalClearance( aSource );
553 }
554
556 {
558 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
559
560 return m_zoneConnection;
561 }
562
567 const std::vector<wxString>& GetNetTiePadGroups() const { return m_netTiePadGroups; }
568
570 {
571 m_netTiePadGroups.clear();
572 }
573
574 void AddNetTiePadGroup( const wxString& aGroup )
575 {
576 m_netTiePadGroups.emplace_back( aGroup );
577 }
578
583 std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
584
588 std::vector<PAD*> GetNetTiePads( PAD* aPad ) const;
589
596 int GetLikelyAttribute() const;
597
598 void Move( const VECTOR2I& aMoveVector ) override;
599
600 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
601
602 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
603
615 void MoveAnchorPosition( const VECTOR2I& aMoveVector );
616
620 bool IsFlipped() const { return GetLayer() == B_Cu; }
621
626 PCB_LAYER_ID GetSide() const;
627
631 bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
632
633// m_footprintStatus bits:
634#define FP_is_PLACED 0x02
635#define FP_to_PLACE 0x04
636
637
641 bool IsLayerAgnostic() const override { return true; }
642
646 bool FitsEnabledLayers( const LSET& aEnabledLayers, int aCopperLayerCount ) const override
647 {
648 return GetLayer() == F_Cu || GetLayer() == B_Cu;
649 }
650
654 bool IsConflicting() const;
655
656 bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
657 void SetIsPlaced( bool isPlaced )
658 {
659 if( isPlaced )
661 else
663 }
664
665 bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
666 void SetNeedsPlaced( bool needsPlaced )
667 {
668 if( needsPlaced )
670 else
672 }
673
677 void BuildNetTieCache();
678
682 const std::set<int>& GetNetTieCache( const BOARD_ITEM* aItem ) const
683 {
684 static const std::set<int> emptySet;
685
686 auto it = m_netTieCache.find( aItem );
687
688 if( it == m_netTieCache.end() )
689 return emptySet;
690
691 return it->second;
692 }
693
707 void TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
708 int aMaxError, ERROR_LOC aErrorLoc ) const;
709
726 void TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
727 int aError, ERROR_LOC aErrorLoc,
728 bool aIncludeText = true,
729 bool aIncludeShapes = true,
730 bool aIncludePrivateItems = false ) const;
731
735 void TransformFPTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
736 int aError, ERROR_LOC aErrorLoc ) const
737 {
738 TransformFPShapesToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc, true, false );
739 }
740
744 void GetContextualTextVars( wxArrayString* aVars ) const;
745
752 bool ResolveTextVar( wxString* aToken, int aDepth = 0 ) const;
753 bool ResolveTextVar( wxString* aToken, const wxString& aVariantName, int aDepth = 0 ) const;
754
756 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
757
758 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
759
760 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
761
772 bool HitTestAccurate( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
773
774 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
775
776 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
777
786 bool HitTestOnLayer( const VECTOR2I& aPosition, PCB_LAYER_ID aLayer, int aAccuracy = 0 ) const;
787
788 bool HitTestOnLayer( const BOX2I& aRect, bool aContained, PCB_LAYER_ID aLayer, int aAccuracy = 0 ) const;
789
793 const wxString& GetReference() const { return Reference().GetText(); }
794
799 void SetReference( const wxString& aReference ) { Reference().SetText( aReference ); }
800
801 // Property system doesn't like const references
802 wxString GetReferenceAsString() const
803 {
804 return GetReference();
805 }
806
810 void IncrementReference( int aDelta );
811
812 bool IsAnnotated() const { return !GetReference().IsEmpty() && GetReference().Last() != '?'; }
813
817 const wxString& GetValue() const { return Value().GetText(); }
818
822 void SetValue( const wxString& aValue ) { Value().SetText( aValue ); }
823
824 // Property system doesn't like const references
825 wxString GetValueAsString() const
826 {
827 return GetValue();
828 }
829
833
835 const PCB_FIELD& Value() const { return *GetField( FIELD_T::VALUE ); }
836 const PCB_FIELD& Reference() const { return *GetField( FIELD_T::REFERENCE ); }
837
838 //-----<Fields>-----------------------------------------------------------
839
844 PCB_FIELD* GetField( FIELD_T aFieldType );
845 const PCB_FIELD* GetField( FIELD_T aFieldNdx ) const;
846
854 PCB_FIELD* GetField( const wxString& aFieldName ) const;
855
856 bool HasField( const wxString& aFieldName ) const;
857
864 void GetFields( std::vector<PCB_FIELD*>& aVector, bool aVisibleOnly ) const;
865
869 const std::deque<PCB_FIELD*>& GetFields() const { return m_fields; }
870 std::deque<PCB_FIELD*>& GetFields() { return m_fields; }
871
884 void UpdateFields( const std::vector<PCB_FIELD>& aFields, std::vector<PCB_FIELD*>& aAdded,
885 std::vector<PCB_FIELD*>& aDetached );
886
890 int GetNextFieldOrdinal() const;
891
899 void ApplyDefaultSettings( const BOARD& board, bool aStyleFields, bool aStyleText,
900 bool aStyleShapes, bool aStyleDimensions, bool aStyleBarcodes );
901
903 {
904 wxString m_unitName; // e.g. A
905 std::vector<wxString> m_pins; // pin numbers in this unit
906 };
907
908 void SetUnitInfo( const std::vector<FP_UNIT_INFO>& aUnits ) { m_unitInfo = aUnits; }
909 const std::vector<FP_UNIT_INFO>& GetUnitInfo() const { return m_unitInfo; }
910
911 bool IsBoardOnly() const { return m_attributes & FP_BOARD_ONLY; }
912 void SetBoardOnly( bool aIsBoardOnly = true )
913 {
914 if( aIsBoardOnly )
916 else
918 }
919
921 void SetExcludedFromPosFiles( bool aExclude = true )
922 {
923 if( aExclude )
925 else
927 }
928
930 void SetExcludedFromBOM( bool aExclude = true )
931 {
932 if( aExclude )
934 else
936 }
937
939 void SetExcludedFromSim( bool aExclude = true )
940 {
941 if( aExclude )
943 else
945 }
946
947 bool IsDNP() const { return m_attributes & FP_DNP; }
948 void SetDNP( bool aDNP = true )
949 {
950 if( aDNP )
952 else
954 }
955
956 // =====================================================================
957 // Variant Support
958 // =====================================================================
959
965 const FOOTPRINT_VARIANT* GetVariant( const wxString& aVariantName ) const;
966
972 FOOTPRINT_VARIANT* GetVariant( const wxString& aVariantName );
973
978 void SetVariant( const FOOTPRINT_VARIANT& aVariant );
979
985 FOOTPRINT_VARIANT* AddVariant( const wxString& aVariantName );
986
991 void DeleteVariant( const wxString& aVariantName );
992
998 void RenameVariant( const wxString& aOldName, const wxString& aNewName );
999
1005 bool HasVariant( const wxString& aVariantName ) const;
1006
1012
1021 bool GetDNPForVariant( const wxString& aVariantName ) const;
1022
1031 bool GetExcludedFromBOMForVariant( const wxString& aVariantName ) const;
1032
1041 bool GetExcludedFromSimForVariant( const wxString& aVariantName ) const;
1042
1051 bool GetExcludedFromPosFilesForVariant( const wxString& aVariantName ) const;
1052
1065 wxString GetFieldValueForVariant( const wxString& aVariantName, const wxString& aFieldName ) const;
1066
1067 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
1069
1070 std::vector<PROPERTY_BASE*> GetDynamicProperties() const override;
1071
1081 PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
1082
1083 PAD* FindPadByUuid( const KIID& aUuid ) const;
1084
1092 PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask = LSET::AllLayersMask() );
1093
1094 std::vector<const PAD*> GetPads( const wxString& aPadNumber, const PAD* aIgnore = nullptr ) const;
1095
1099 unsigned GetPadCount() const;
1100
1107 std::set<wxString> GetUniquePadNumbers() const;
1108
1117 unsigned GetNumberedPadCount() const;
1118
1125 wxString GetNextPadNumber( const wxString& aLastPadName ) const;
1126
1129
1136
1140 void AutoPositionFields();
1141
1146 wxString GetTypeName() const;
1147
1148 double GetArea( int aPadding = 0 ) const;
1149
1150 KIID GetLink() const { return m_link; }
1151 void SetLink( const KIID& aLink ) { m_link = aLink; }
1152
1153 BOARD_ITEM* Duplicate( bool addToParentGroup, BOARD_COMMIT* aCommit = nullptr ) const override;
1154
1160 BOARD_ITEM* DuplicateItem( bool addToParentGroup, BOARD_COMMIT* aCommit, const BOARD_ITEM* aItem,
1161 bool addToFootprint = false );
1162
1168 void Add3DModel( FP_3DMODEL* a3DModel );
1169
1170 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
1171 const std::vector<KICAD_T>& aScanTypes ) override;
1172
1173 wxString GetClass() const override
1174 {
1175 return wxT( "FOOTPRINT" );
1176 }
1177
1178 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1179
1180 wxString DisambiguateItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
1181
1182 BITMAPS GetMenuImage() const override;
1183
1184 EDA_ITEM* Clone() const override;
1185
1187 void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
1188
1189 virtual std::vector<int> ViewGetLayers() const override;
1190
1191 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
1192
1193 virtual const BOX2I ViewBBox() const override;
1194
1202 static bool IsLibNameValid( const wxString& aName );
1203
1213 static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
1214
1218 bool FootprintNeedsUpdate( const FOOTPRINT* aLibFP, int aCompareFlags = 0, REPORTER* aReporter = nullptr );
1219
1234 void SetInitialComments( wxArrayString* aInitialComments )
1235 {
1236 delete m_initial_comments;
1237 m_initial_comments = aInitialComments;
1238 }
1239
1246 double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
1247
1248 double GetCoverageArea( int aTextMargin ) const override;
1249
1251 const wxArrayString* GetInitialComments() const { return m_initial_comments; }
1252
1258 const SHAPE_POLY_SET& GetCourtyard( PCB_LAYER_ID aLayer ) const;
1259
1265 const SHAPE_POLY_SET& GetCachedCourtyard( PCB_LAYER_ID aLayer ) const;
1266
1273 void BuildCourtyardCaches( OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
1274
1275 // @copydoc BOARD_ITEM::GetEffectiveShape
1276 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
1277 FLASHING aFlash = FLASHING::DEFAULT,
1278 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
1279
1281 {
1282 return static_cast<EMBEDDED_FILES*>( this );
1283 }
1284
1286 {
1287 return static_cast<const EMBEDDED_FILES*>( this );
1288 }
1289
1293 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
1294
1295 void EmbedFonts() override;
1296
1297 double Similarity( const BOARD_ITEM& aOther ) const override;
1298
1300 void SetStaticComponentClass( const COMPONENT_CLASS* aClass ) const;
1301
1304
1306 const COMPONENT_CLASS* GetComponentClass() const;
1307
1309 wxString GetComponentClassAsString() const;
1310
1312 void RecomputeComponentClass() const;
1313
1315 void InvalidateComponentClassCache() const;
1316
1323 void SetTransientComponentClassNames( const std::unordered_set<wxString>& classNames )
1324 {
1325 m_transientComponentClassNames = classNames;
1326 }
1327
1329 const std::unordered_set<wxString>& GetTransientComponentClassNames()
1330 {
1332 }
1333
1336
1338 void ResolveComponentClassNames( BOARD* aBoard,
1339 const std::unordered_set<wxString>& aComponentClassNames );
1340
1342 void FixUpPadsForBoard( BOARD* aBoard );
1343
1344 bool operator==( const BOARD_ITEM& aOther ) const override;
1345 bool operator==( const FOOTPRINT& aOther ) const;
1346
1347#if defined(DEBUG)
1348 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1349#endif
1350
1352 {
1353 bool operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const;
1354 };
1355
1357 {
1358 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
1359 };
1360 // TODO(JE) padstacks -- this code isn't used anywhere though
1361#if 0
1362 struct cmp_padstack
1363 {
1364 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
1365 };
1366#endif
1368 {
1369 bool operator()( const ZONE* aFirst, const ZONE* aSecond ) const;
1370 };
1371
1372protected:
1373 virtual void swapData( BOARD_ITEM* aImage ) override;
1374
1376
1377private:
1378 std::deque<PCB_FIELD*> m_fields; // Fields, mapped by name, owned by pointer
1379 std::deque<BOARD_ITEM*> m_drawings; // Drawings in the footprint, owned by pointer
1380 std::deque<PAD*> m_pads; // Pads, owned by pointer
1381 std::vector<ZONE*> m_zones; // Rule area zones, owned by pointer
1382 std::deque<PCB_GROUP*> m_groups; // Groups, owned by pointer
1383 std::deque<PCB_CONSTRAINT*> m_constraints; // Geometric constraints, owned by pointer
1384 std::deque<PCB_POINT*> m_points; // Points, owned by pointer
1385
1387 bool m_flipped = false;
1389 int m_attributes; // Flag bits (see FOOTPRINT_ATTR_T)
1390 int m_fpStatus = 0; // For autoplace: flags (PLACED, TO_PLACE)
1392
1395
1396 // Bounding box caching strategy:
1397 // While we attempt to notice the low-hanging fruit operations and update the bounding boxes
1398 // accordingly, we rely mostly on a "if anything changed then the caches are stale" approach.
1399 // We implement this by having PCB_BASE_FRAME's OnModify() method increment an operation
1400 // counter, and storing that as a timestamp for the various caches.
1401 // This means caches will get regenerated often -- but still far less often than if we had no
1402 // caches at all. The principal opitmization would be to change to dirty flag and make sure
1403 // that any edit that could affect the bounding boxes (including edits to the footprint
1404 // children) marked the bounding boxes dirty. It would definitely be faster -- but also more
1405 // fragile.
1406 mutable std::mutex m_geometry_cache_mutex;
1407 mutable std::unique_ptr<FOOTPRINT_GEOMETRY_CACHE_DATA> m_geometry_cache;
1408
1411 mutable std::map<wxString, std::unique_ptr<PCB_FOOTPRINT_FIELD_PROPERTY>> m_fieldPropsStorageCache;
1412
1413 // A list of pad groups, each of which is allowed to short nets within their group.
1414 // A pad group is a comma-separated list of pad numbers.
1415 std::vector<wxString> m_netTiePadGroups;
1416
1417 // A list of 1:N footprint item to allowed net numbers
1418 std::map<const BOARD_ITEM*, std::set<int>> m_netTieCache;
1419
1423
1427
1430
1431 // Optional overrides
1433 std::optional<int> m_clearance;
1434 std::optional<int> m_solderMaskMargin; // Solder mask margin
1435 std::optional<int> m_solderPasteMargin; // Solder paste margin absolute value
1436 std::optional<double> m_solderPasteMarginRatio; // Solder mask margin ratio of pad size
1437 // The final margin is the sum of these 2 values
1438
1439 LSET m_stackupLayers; // Layers in the stackup
1440 FOOTPRINT_STACKUP m_stackupMode; // Stackup mode for this footprint
1441 LSET m_privateLayers; // Layers visible only in the footprint editor
1442
1443 wxString m_libDescription; // File name and path for documentation file.
1444 wxString m_keywords; // Search keywords to find footprint in library.
1445 KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
1446 wxString m_sheetname; // Name of the sheet containing the symbol for this footprint
1447 wxString m_sheetfile; // File of the sheet containing the symbol for this footprint
1448 wxString m_filters; // Footprint filters from symbol
1450 int m_arflag; // Use to trace ratsnest and auto routing.
1451 KIID m_link; // Temporary logical link used during editing
1452 std::deque<PCB_3D_BODY*> m_bodies; // 3D bodies (extruded or model), owned by pointer
1453 std::vector<FP_3DMODEL> m_3D_Drawings; // 3D models.
1454 int m_height = 0;
1455
1456 wxArrayString* m_initial_comments; // s-expression comments in the footprint,
1457 // lazily allocated only if needed for speed
1458
1459 mutable std::unique_ptr<FOOTPRINT_COURTYARD_CACHE_DATA> m_courtyard_cache;
1460 mutable std::mutex m_courtyard_cache_mutex;
1461
1462 std::unordered_set<wxString> m_transientComponentClassNames;
1463 std::unique_ptr<COMPONENT_CLASS_CACHE_PROXY> m_componentClassCacheProxy;
1464
1465 // Optional unit mapping information for multi-unit symbols
1466 std::vector<FP_UNIT_INFO> m_unitInfo;
1467
1468 std::vector<SEARCH_TERM> m_searchTerms;
1469};
1470
1471#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:914
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:85
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:87
PCB_LAYER_ID m_layer
Definition board_item.h:600
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
constexpr const Vec GetCenter() const
Definition box2.h:227
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:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:236
EMBEDDED_FILES()=default
Variant information for a footprint.
Definition footprint.h:178
wxString GetName() const
Definition footprint.h:189
FOOTPRINT_VARIANT(const wxString &aName=wxEmptyString)
Definition footprint.h:180
bool HasFieldValue(const wxString &aFieldName) const
Definition footprint.h:237
bool m_excludedFromPosFiles
Definition footprint.h:259
void SetExcludedFromPosFiles(bool aExclude)
Definition footprint.h:202
wxString GetFieldValue(const wxString &aFieldName) const
Get a field value override for this variant.
Definition footprint.h:209
void SetName(const wxString &aName)
Definition footprint.h:190
const std::map< wxString, wxString > & GetFields() const
Definition footprint.h:242
bool GetExcludedFromSim() const
Definition footprint.h:198
bool GetExcludedFromBOM() const
Definition footprint.h:195
bool operator==(const FOOTPRINT_VARIANT &aOther) const
Definition footprint.h:244
void SetExcludedFromSim(bool aExclude)
Definition footprint.h:199
void SetDNP(bool aDNP)
Definition footprint.h:193
bool GetExcludedFromPosFiles() const
Definition footprint.h:201
void RemoveFieldValue(const wxString &aFieldName)
Remove a field value override for this variant.
Definition footprint.h:232
bool GetDNP() const
Definition footprint.h:192
std::map< wxString, wxString > m_fields
Field value overrides for this variant.
Definition footprint.h:260
void SetFieldValue(const wxString &aFieldName, const wxString &aValue)
Set a field value override for this variant.
Definition footprint.h:224
void SetExcludedFromBOM(bool aExclude)
Definition footprint.h:196
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:1127
const CASE_INSENSITIVE_MAP< FOOTPRINT_VARIANT > & GetVariants() const
Get all variants.
Definition footprint.h:1011
std::optional< int > GetClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition footprint.h:550
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
void EmbedFonts() override
bool AllowSolderMaskBridges() const
Definition footprint.h:518
void SetPosition(const VECTOR2I &aPos) override
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:418
LIB_ID m_fpid
Definition footprint.h:1388
wxString GetLibDescription() const
Definition footprint.h:449
ZONE_CONNECTION GetLocalZoneConnection() const
Definition footprint.h:491
void SetLink(const KIID &aLink)
Definition footprint.h:1151
KIID_PATH m_path
Definition footprint.h:1445
std::deque< BOARD_ITEM * > m_drawings
Definition footprint.h:1379
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:911
void SerializeDefinition(kiapi::board::types::Footprint *aOutput) const
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:356
bool IsDNP() const
Definition footprint.h:947
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition footprint.h:353
void SetFootprintType(FOOTPRINT_TYPE aFootprintType)
std::vector< PAD * > GetNetTiePads(PAD *aPad) const
EDA_ANGLE GetOrientation() const
Definition footprint.h:382
PCB_3D_BODY & EnsureBody()
ZONES & Zones()
Definition footprint.h:361
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:1384
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:657
ZONE_CONNECTION m_zoneConnection
Definition footprint.h:1432
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this footprint.
PCB_POINTS & Points()
Definition footprint.h:370
bool IsExcludedFromBOM() const
Definition footprint.h:929
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetOrientation(const EDA_ANGLE &aNewAngle)
void SetFlag(int aFlag)
Definition footprint.h:521
std::optional< double > m_solderPasteMarginRatio
Definition footprint.h:1436
void SetDNP(bool aDNP=true)
Definition footprint.h:948
void SetAllowSolderMaskBridges(bool aAllow)
Definition footprint.h:519
void RecomputeComponentClass() const
Forces immediate recalculation of the component class for this footprint.
std::vector< ZONE * > m_zones
Definition footprint.h:1381
bool GetExcludedFromSimForVariant(const wxString &aVariantName) const
Get the exclude-from-simulation status for a specific variant.
const TRANSFORM_TRS & GetTransform() const
Definition footprint.h:395
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.
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition footprint.h:488
std::vector< SEARCH_TERM > & GetSearchTerms() override
void IncrementFlag()
Definition footprint.h:522
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
bool IsAnnotated() const
Definition footprint.h:812
std::optional< int > m_clearance
Definition footprint.h:1433
bool m_duplicatePadNumbersAreJumpers
Flag that this footprint should automatically treat sets of two or more pads with the same number as ...
Definition footprint.h:1426
void SetExcludedFromSim(bool aExclude=true)
Definition footprint.h:939
const JUMPER_GROUP_SET & JumperPadGroups() const
Definition footprint.h:1135
void SetExcludedFromBOM(bool aExclude=true)
Definition footprint.h:930
wxString GetSheetname() const
Definition footprint.h:469
int m_fpStatus
Definition footprint.h:1390
std::map< wxString, std::unique_ptr< PCB_FOOTPRINT_FIELD_PROPERTY > > m_fieldPropsStorageCache
Per-object cache of dynamic property descriptors for custom fields, keyed by descriptor name and popu...
Definition footprint.h:1411
void SetPath(const KIID_PATH &aPath)
Definition footprint.h:456
void SetFilters(const wxString &aFilters)
Definition footprint.h:476
void SetKeywords(const wxString &aKeywords)
Definition footprint.h:453
void SetStaticComponentClass(const COMPONENT_CLASS *aClass) const
Sets the component class object pointer for this footprint.
const DRAWINGS & GraphicalItems() const
Definition footprint.h:359
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:1234
int m_attributes
Definition footprint.h:1389
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:444
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:1453
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...
FOOTPRINT_TYPE GetFootprintType() const
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:1428
const std::vector< FP_UNIT_INFO > & GetUnitInfo() const
Definition footprint.h:909
std::unordered_set< wxString > m_transientComponentClassNames
Definition footprint.h:1462
void SetAttributes(int aAttributes)
Definition footprint.h:510
void SetSheetfile(const wxString &aSheetfile)
Definition footprint.h:473
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
std::optional< int > GetLocalSolderPasteMargin() const
Definition footprint.h:484
std::unique_ptr< COMPONENT_CLASS_CACHE_PROXY > m_componentClassCacheProxy
Definition footprint.h:1463
wxArrayString * m_initial_comments
Definition footprint.h:1456
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
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:442
std::deque< PCB_FIELD * > m_fields
Definition footprint.h:1378
std::mutex m_geometry_cache_mutex
Definition footprint.h:1406
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:831
const EMBEDDED_FILES * GetEmbeddedFiles() const
Definition footprint.h:1285
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::optional< int > m_solderPasteMargin
Definition footprint.h:1435
void SetFileFormatVersionAtLoad(int aVersion)
Definition footprint.h:1067
std::mutex m_courtyard_cache_mutex
Definition footprint.h:1460
void SetExcludedFromPosFiles(bool aExclude=true)
Definition footprint.h:921
bool IsWithinSchematicSheet(const KIID_PATH &aSheetPath) const
Test whether this footprint's symbol lives on aSheetPath or any sheet below it.
void SetOrientationDegrees(double aOrientation)
Definition footprint.h:408
unsigned GetPadCount() const
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
std::optional< int > GetLocalClearance() const
Definition footprint.h:478
void UpdateFields(const std::vector< PCB_FIELD > &aFields, std::vector< PCB_FIELD * > &aAdded, std::vector< PCB_FIELD * > &aDetached)
Replace the fields with aFields, reusing the existing mandatory field objects.
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:735
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.
void SetDuplicatePadNumbersAreJumpers(bool aEnabled)
Definition footprint.h:1128
bool m_allowSolderMaskBridges
Definition footprint.h:1429
FOOTPRINT & operator=(const FOOTPRINT &aOther)
bool HasField(const wxString &aFieldName) const
CONSTRAINTS & Constraints()
Definition footprint.h:367
PCB_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this footprint.
void SetScaleY(double aScaleY)
Definition footprint.h:404
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:412
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:355
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:445
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetAttributes() const
Definition footprint.h:509
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:536
const COMPONENT_CLASS * GetComponentClass() const
Returns the component class for this footprint.
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition footprint.h:490
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)
void ClearNetTiePadGroups()
Definition footprint.h:569
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:393
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the component.
LSET GetPrivateLayers() const
Definition footprint.h:295
wxString GetFPIDAsString() const
Definition footprint.h:419
CASE_INSENSITIVE_MAP< FOOTPRINT_VARIANT > m_variants
Variant data for this footprint, keyed by variant name.
Definition footprint.h:1394
double GetScaleX() const
Definition footprint.h:399
wxString GetValueAsString() const
Definition footprint.h:825
bool AllowMissingCourtyard() const
Definition footprint.h:515
void DeleteVariant(const wxString &aVariantName)
Delete a variant by name.
const ZONES & Zones() const
Definition footprint.h:362
wxString GetComponentClassAsString() const
Used for display in the properties panel.
bool IsFlipped() const
Definition footprint.h:620
wxString GetSheetfile() const
Definition footprint.h:472
bool IsLayerAgnostic() const override
Check if this item's layer set must not be confined to a board's enabled layers.
Definition footprint.h:641
JUMPER_GROUP_SET 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:1422
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:368
bool m_flipped
Definition footprint.h:1387
std::deque< PCB_CONSTRAINT * > m_constraints
Definition footprint.h:1383
wxString GetTypeName() const
Get the type of footprint.
bool NeedsPlaced() const
Definition footprint.h:665
const std::vector< wxString > & GetNetTiePadGroups() const
Definition footprint.h:567
const PCB_3D_BODY * GetBody() const
Definition footprint.h:427
const LIB_ID & GetFPID() const
Definition footprint.h:417
int GetHeight() const
The overall height of the footprint, or 0 if not specified.
Definition footprint.h:438
bool DeserializeDefinition(const kiapi::board::types::Footprint &aInput)
const std::unordered_set< wxString > & GetTransientComponentClassNames()
Gets the transient component class names.
Definition footprint.h:1329
void SetReference(const wxString &aReference)
Definition footprint.h:799
std::vector< FP_UNIT_INFO > m_unitInfo
Definition footprint.h:1466
const GROUPS & Groups() const
Definition footprint.h:365
bool IsExcludedFromPosFiles() const
Definition footprint.h:920
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.
void SetHeight(int aHeight)
Definition footprint.h:439
wxString GetFieldValueForVariant(const wxString &aVariantName, const wxString &aFieldName) const
Get a field value for a specific variant.
int GetPinCount() const override
The pin count for symbols or the unique pad count for footprints.
Definition footprint.h:446
void AddNetTiePadGroup(const wxString &aGroup)
Definition footprint.h:574
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
LSET m_privateLayers
Definition footprint.h:1441
bool IsExcludedFromSim() const
Definition footprint.h:938
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:682
const LSET & GetStackupLayers() const
Definition footprint.h:507
const std::deque< PCB_FIELD * > & GetFields() const
Return a reference to the deque holding the footprint's fields.
Definition footprint.h:869
int GetLikelyAttribute() const
Return the most likely attribute based on pads.
std::deque< PCB_GROUP * > m_groups
Definition footprint.h:1382
void Move(const VECTOR2I &aMoveVector) override
Move this object.
static bool ClassOf(const EDA_ITEM *aItem)
Definition footprint.h:287
wxString m_libDescription
Definition footprint.h:1443
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:1335
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource) const
Definition footprint.h:555
std::vector< wxString > m_netTiePadGroups
Definition footprint.h:1415
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:822
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:1440
PCB_FIELD & Reference()
Definition footprint.h:832
const PCB_FIELD & Value() const
The const versions to keep the compiler happy.
Definition footprint.h:835
wxString GetReferenceAsString() const
Definition footprint.h:802
JUMPER_GROUP_SET & JumperPadGroups()
Each jumper pad group is a set of pad numbers that should be treated as internally connected.
Definition footprint.h:1134
std::deque< PCB_3D_BODY * > m_bodies
Definition footprint.h:1452
wxString m_sheetfile
Definition footprint.h:1447
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:1434
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Adds an item to the container.
void SetUnitInfo(const std::vector< FP_UNIT_INFO > &aUnits)
Definition footprint.h:908
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:1444
const PCB_FIELD & Reference() const
Definition footprint.h:836
void SetTransientComponentClassNames(const std::unordered_set< wxString > &classNames)
Sets the transient component class names.
Definition footprint.h:1323
void SetScaleX(double aScaleX)
Definition footprint.h:402
void ClearAllNets()
Clear (i.e.
std::deque< PAD * > m_pads
Definition footprint.h:1380
void RescaleAroundPoint(const VECTOR2I &aCenter, double aSx, double aSy)
bool HasThroughHolePads() const
const PCB_POINTS & Points() const
Definition footprint.h:371
bool FitsEnabledLayers(const LSET &aEnabledLayers, int aCopperLayerCount) const override
Check if a board offering aEnabledLayers can hold this item.
Definition footprint.h:646
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:525
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:1173
void SetVariant(const FOOTPRINT_VARIANT &aVariant)
Add or update a variant.
std::unique_ptr< FOOTPRINT_COURTYARD_CACHE_DATA > m_courtyard_cache
Definition footprint.h:1459
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:1068
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition footprint.h:487
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
KIID m_link
Definition footprint.h:1451
GROUPS & Groups()
Definition footprint.h:364
wxString GetFilters() const
Definition footprint.h:475
void SetSheetname(const wxString &aSheetname)
Definition footprint.h:470
const std::deque< PCB_3D_BODY * > & Bodies() const
Definition footprint.h:423
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition footprint.h:1251
KIID GetLink() const
Definition footprint.h:1150
std::set< wxString > GetUniquePadNumbers() const
A complex pad can be built with many pads having the same pad name to create a complex shape or fragm...
void SetAllowMissingCourtyard(bool aAllow)
Definition footprint.h:516
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:375
BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const override
Create a copy of this BOARD_ITEM.
void ClearBody()
const SHAPE_POLY_SET & GetCachedCourtyard(PCB_LAYER_ID aLayer) const
Return the cached courtyard area.
std::deque< PCB_FIELD * > & GetFields()
Definition footprint.h:870
wxString GetName() const override
Definition footprint.h:443
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:450
bool TextOnly() const
PCB_3D_BODY * GetBody()
Definition footprint.h:428
const wxString & GetValue() const
Definition footprint.h:817
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.
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:666
bool HasBody() const
Convenience accessors for now while we restrict to only one body per footprint.
Definition footprint.h:426
wxString m_filters
Definition footprint.h:1448
const wxString & GetReference() const
Definition footprint.h:793
std::unique_ptr< FOOTPRINT_GEOMETRY_CACHE_DATA > m_geometry_cache
Definition footprint.h:1407
bool GetExcludedFromBOMForVariant(const wxString &aVariantName) const
Get the exclude-from-BOM status for a specific variant.
void CopyFrom(const BOARD_ITEM *aOther) override
void SetFPIDAsString(const wxString &aFPID)
Definition footprint.h:420
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:912
const std::vector< FP_3DMODEL > & Models() const
Definition footprint.h:376
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition footprint.h:482
TRANSFORM_TRS m_transform
Definition footprint.h:1386
timestamp_t m_lastEditTime
Definition footprint.h:1449
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:523
std::map< const BOARD_ITEM *, std::set< int > > m_netTieCache
Definition footprint.h:1418
std::vector< PROPERTY_BASE * > GetDynamicProperties() const override
Return dynamically-computed properties specific to this object instance (e.g.
wxString m_sheetname
Definition footprint.h:1446
LSET m_stackupLayers
Definition footprint.h:1439
int m_fileFormatVersionAtLoad
Definition footprint.h:1391
void SetLocalClearance(std::optional< int > aClearance)
Definition footprint.h:479
void SetPrivateLayers(const LSET &aLayers)
Definition footprint.h:296
const KIID_PATH & GetPath() const
Definition footprint.h:455
std::optional< int > GetLocalSolderMaskMargin() const
Definition footprint.h:481
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition footprint.h:485
wxString GetKeywords() const
Definition footprint.h:452
bool operator==(const BOARD_ITEM &aOther) const override
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition footprint.h:1280
std::deque< PCB_3D_BODY * > & Bodies()
Definition footprint.h:422
FOOTPRINT_STACKUP GetStackupMode() const
Definition footprint.h:500
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:400
bool IsPlaced() const
Definition footprint.h:656
bool HasVariant(const wxString &aVariantName) const
Check if a variant exists.
VECTOR2I GetPosition() const override
Definition footprint.h:379
DRAWINGS & GraphicalItems()
Definition footprint.h:358
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:1468
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:139
VECTOR3D m_Offset
3D model offset (mm)
Definition footprint.h:134
double m_Opacity
Definition footprint.h:135
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition footprint.h:133
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition footprint.h:132
wxString m_Filename
The 3D shape filename in 3D library.
Definition footprint.h:136
bool m_Show
Include model in rendering.
Definition footprint.h:137
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:203
Represents an (ordered) list of JUMPER_GROUP objects.
Implement outline font drawing.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
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:65
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 3D body attached to a footprint (or, later, placed on a board).
Definition pcb_3d_body.h:93
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:73
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 UNSPECIFIED
@ NULL_CONSTRAINT
#define _(s)
@ DEGREES_T
Definition eda_angle.h:30
RECURSE_MODE
Definition eda_item.h:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
FOOTPRINT_TYPE
Definition footprint.h:98
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition footprint.h:85
@ FP_SMD
Definition footprint.h:87
@ FP_DNP
Definition footprint.h:92
@ FP_EXCLUDE_FROM_POS_FILES
Definition footprint.h:88
@ FP_BOARD_ONLY
Definition footprint.h:90
@ FP_EXCLUDE_FROM_BOM
Definition footprint.h:89
@ FP_JUST_ADDED
Definition footprint.h:91
@ FP_EXCLUDE_FROM_SIM
Definition footprint.h:93
@ FP_THROUGH_HOLE
Definition footprint.h:86
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition footprint.h:634
FOOTPRINT_STACKUP
Definition footprint.h:106
@ EXPAND_INNER_LAYERS
The 'normal' stackup handling, where there is a single inner layer (In1) and rule areas using it expa...
Definition footprint.h:111
@ CUSTOM_LAYERS
Stackup handling where the footprint can have any number of copper layers, and objects on those layer...
Definition footprint.h:116
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition footprint.h:635
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:30
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:905
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:33
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:78
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR3< double > VECTOR3D
Definition vector3.h:230
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43