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 (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef FOOTPRINT_H
26#define FOOTPRINT_H
27
28#include <deque>
29
31#include <board_item.h>
32#include <collectors.h>
33#include <layer_ids.h> // ALL_LAYERS definition.
34#include <lib_id.h>
35#include <list>
36
37#include <zones.h>
39#include <pcb_item_containers.h>
40#include <pcb_text.h>
41#include <functional>
42#include <math/vector3.h>
43
44class LINE_READER;
45class EDA_3D_CANVAS;
46class PAD;
47class BOARD;
48class MSG_PANEL_ITEM;
49class SHAPE;
50class REPORTER;
51
52namespace KIGFX {
53class VIEW;
54}
55
57{
59 INCLUDE_NPTH = true
60};
61
68{
70 FP_SMD = 0x0002,
73 FP_BOARD_ONLY = 0x0010, // Footprint has no corresponding symbol
74 FP_JUST_ADDED = 0x0020, // Footprint just added by netlist update
77 FP_DNP = 0x0100
78};
79
81{
82public:
84 // Initialize with sensible values
85 m_Scale { 1, 1, 1 },
86 m_Rotation { 0, 0, 0 },
87 m_Offset { 0, 0, 0 },
88 m_Opacity( 1.0 ),
89 m_Show( true )
90 {
91 }
92
96 double m_Opacity;
97 wxString m_Filename;
98 bool m_Show;
99};
100
101
103{
104public:
105 FOOTPRINT( BOARD* parent );
106
107 FOOTPRINT( const FOOTPRINT& aFootprint );
108
109 // Move constructor and operator needed due to std containers inside the footprint
110 FOOTPRINT( FOOTPRINT&& aFootprint );
111
112 ~FOOTPRINT();
113
114 FOOTPRINT& operator=( const FOOTPRINT& aOther );
115 FOOTPRINT& operator=( FOOTPRINT&& aOther );
116
117 static inline bool ClassOf( const EDA_ITEM* aItem )
118 {
119 return aItem && aItem->Type() == PCB_FOOTPRINT_T;
120 }
121
123 void SetPrivateLayers( LSET aLayers ) { m_privateLayers = aLayers; }
124
126 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
127 bool aSkipConnectivity = false ) override;
128
130 void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
131
139 void ClearAllNets();
140
148 bool FixUuids();
149
160
167
168 // Virtual function
169 const BOX2I GetBoundingBox() const override;
170 const BOX2I GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const;
171
172 PADS& Pads() { return m_pads; }
173 const PADS& Pads() const { return m_pads; }
174
175 DRAWINGS& GraphicalItems() { return m_drawings; }
176 const DRAWINGS& GraphicalItems() const { return m_drawings; }
177
178 ZONES& Zones() { return m_zones; }
179 const ZONES& Zones() const { return m_zones; }
180
181 GROUPS& Groups() { return m_groups; }
182 const GROUPS& Groups() const { return m_groups; }
183
184 bool HasThroughHolePads() const;
185
186 std::vector<FP_3DMODEL>& Models() { return m_3D_Drawings; }
187 const std::vector<FP_3DMODEL>& Models() const { return m_3D_Drawings; }
188
189 void SetPosition( const VECTOR2I& aPos ) override;
190 VECTOR2I GetPosition() const override { return m_pos; }
191
192 void SetOrientation( const EDA_ANGLE& aNewAngle );
194
199 void SetLayerAndFlip( PCB_LAYER_ID aLayer );
200
201 // to make property magic work
202 PCB_LAYER_ID GetLayer() const override { return BOARD_ITEM::GetLayer(); }
203
204 // For property system:
205 void SetOrientationDegrees( double aOrientation )
206 {
207 SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
208 }
210 {
211 return m_orient.AsDegrees();
212 }
213
214 const LIB_ID& GetFPID() const { return m_fpid; }
215 void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
216
217 wxString GetFPIDAsString() const { return m_fpid.Format(); }
218 void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); }
219
220 wxString GetDescription() const { return m_doc; }
221 void SetDescription( const wxString& aDoc ) { m_doc = aDoc; }
222
223 wxString GetKeywords() const { return m_keywords; }
224 void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
225
226 const KIID_PATH& GetPath() const { return m_path; }
227 void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
228
230 void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
231
232 int GetLocalClearance() const { return m_localClearance; }
233 void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
234
235 int GetLocalClearance( wxString* aSource ) const
236 {
237 if( aSource )
238 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
239
240 return m_localClearance;
241 }
242
244 void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
245
248
251
252 int GetAttributes() const { return m_attributes; }
253 void SetAttributes( int aAttributes ) { m_attributes = aAttributes; }
254
255 void SetFlag( int aFlag ) { m_arflag = aFlag; }
256 void IncrementFlag() { m_arflag += 1; }
257 int GetFlag() const { return m_arflag; }
258
259 bool IsNetTie() const
260 {
261 for( const wxString& group : m_netTiePadGroups )
262 {
263 if( !group.IsEmpty() )
264 return true;
265 }
266
267 return false;
268 }
269
274 const std::vector<wxString>& GetNetTiePadGroups() const { return m_netTiePadGroups; }
275
277 {
278 m_netTiePadGroups.clear();
279 }
280
281 void AddNetTiePadGroup( const wxString& aGroup )
282 {
283 m_netTiePadGroups.emplace_back( aGroup );
284 }
285
290 std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
291
295 std::vector<PAD*> GetNetTiePads( PAD* aPad ) const;
296
302 int GetLikelyAttribute() const;
303
304 void Move( const VECTOR2I& aMoveVector ) override;
305
306 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
307
308 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
309
321 void MoveAnchorPosition( const VECTOR2I& aMoveVector );
322
326 bool IsFlipped() const { return GetLayer() == B_Cu; }
327
333 bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const override;
334
335// m_footprintStatus bits:
336#define FP_is_LOCKED 0x01
337#define FP_is_PLACED 0x02
338#define FP_to_PLACE 0x04
339#define FP_PADS_are_LOCKED 0x08
340
341
342 bool IsLocked() const override
343 {
344 return ( m_fpStatus & FP_is_LOCKED ) != 0;
345 }
346
352 void SetLocked( bool isLocked ) override
353 {
354 if( isLocked )
356 else
357 m_fpStatus &= ~FP_is_LOCKED;
358 }
359
363 bool IsConflicting() const;
364
365 bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
366 void SetIsPlaced( bool isPlaced )
367 {
368 if( isPlaced )
370 else
371 m_fpStatus &= ~FP_is_PLACED;
372 }
373
374 bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
375 void SetNeedsPlaced( bool needsPlaced )
376 {
377 if( needsPlaced )
379 else
380 m_fpStatus &= ~FP_to_PLACE;
381 }
382
384
395 void CheckFootprintAttributes( const std::function<void( const wxString& )>& aErrorHandler );
396
403 void CheckPads( const std::function<void( const PAD*, int, const wxString& )>& aErrorHandler );
404
410 void CheckShortingPads( const std::function<void( const PAD*,
411 const PAD*,
412 const VECTOR2I& )>& aErrorHandler );
413
420 void CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
421 const BOARD_ITEM* bItem,
422 const BOARD_ITEM* cItem,
423 const VECTOR2I& )>& aErrorHandler );
424
431 void CheckNetTiePadGroups( const std::function<void( const wxString& )>& aErrorHandler );
432
453 void TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
454 int aMaxError, ERROR_LOC aErrorLoc,
455 bool aSkipNPTHPadsWihNoCopper = false,
456 bool aSkipPlatedPads = false,
457 bool aSkipNonPlatedPads = false ) const;
458
473 void TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
474 int aError, ERROR_LOC aErrorLoc,
475 bool aIncludeText = true,
476 bool aIncludeShapes = true,
477 bool aIncludePrivateItems = false ) const;
478
482 void TransformFPTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
483 int aError, ERROR_LOC aErrorLoc ) const
484 {
485 TransformFPShapesToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc, true, false );
486 }
487
491 void GetContextualTextVars( wxArrayString* aVars ) const;
492
498 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
499
501 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
502
503 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
504
514 bool HitTestAccurate( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
515
516 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
517
521 const wxString& GetReference() const
522 {
523 return m_reference->GetText();
524 }
525
530 void SetReference( const wxString& aReference )
531 {
532 m_reference->SetText( aReference );
533 }
534
535 // Property system doesn't like const references
536 wxString GetReferenceAsString() const
537 {
538 return GetReference();
539 }
540
544 void IncrementReference( int aDelta );
545
549 const wxString& GetValue() const
550 {
551 return m_value->GetText();
552 }
553
557 void SetValue( const wxString& aValue )
558 {
559 m_value->SetText( aValue );
560 }
561
562 // Property system doesn't like const references
563 wxString GetValueAsString() const
564 {
565 return GetValue();
566 }
567
569 PCB_TEXT& Value() { return *m_value; }
571
573 PCB_TEXT& Value() const { return *m_value; }
574 PCB_TEXT& Reference() const { return *m_reference; }
575
576 const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
577 void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
578 const wxString& GetProperty( const wxString& aKey) { return m_properties[ aKey ]; }
579 bool HasProperty( const wxString& aKey)
580 {
581 return m_properties.find( aKey ) != m_properties.end();
582 }
583 void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
584
585 bool IsBoardOnly() const { return m_attributes & FP_BOARD_ONLY; }
586 void SetBoardOnly( bool aIsBoardOnly = true )
587 {
588 if( aIsBoardOnly )
590 else
591 m_attributes &= ~FP_BOARD_ONLY;
592 }
593
595 void SetExcludedFromPosFiles( bool aExclude = true )
596 {
597 if( aExclude )
599 else
600 m_attributes &= ~FP_EXCLUDE_FROM_POS_FILES;
601 }
602
604 void SetExcludedFromBOM( bool aExclude = true )
605 {
606 if( aExclude )
608 else
609 m_attributes &= ~FP_EXCLUDE_FROM_BOM;
610 }
611
613 void SetAllowMissingCourtyard( bool aAllow = true )
614 {
615 if( aAllow )
617 else
618 m_attributes &= ~FP_ALLOW_MISSING_COURTYARD;
619 }
620
621 bool IsDNP() const { return m_attributes & FP_DNP; }
622 void SetDNP( bool aDNP = true )
623 {
624 if( aDNP )
626 else
627 m_attributes &= ~FP_DNP;
628 }
629
630 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
632
642 PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
643
651 PAD* GetPad( const VECTOR2I& aPosition, LSET aLayerMask = LSET::AllLayersMask() );
652
660 unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
661
672 unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
673
681 wxString GetNextPadNumber( const wxString& aLastPadName ) const;
682
687 wxString GetTypeName() const;
688
689 double GetArea( int aPadding = 0 ) const;
690
691 KIID GetLink() const { return m_link; }
692 void SetLink( const KIID& aLink ) { m_link = aLink; }
693
694 BOARD_ITEM* Duplicate() const override;
695
701 BOARD_ITEM* DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootprint = false );
702
708 void Add3DModel( FP_3DMODEL* a3DModel );
709
710 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
711 const std::vector<KICAD_T>& aScanTypes ) override;
712
713 wxString GetClass() const override
714 {
715 return wxT( "FOOTPRINT" );
716 }
717
718 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
719
720 BITMAPS GetMenuImage() const override;
721
722 EDA_ITEM* Clone() const override;
723
731 void RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction ) const;
732
733 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
734
735 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
736
737 virtual const BOX2I ViewBBox() const override;
738
746 static bool IsLibNameValid( const wxString& aName );
747
757 static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
758
762 bool FootprintNeedsUpdate( const FOOTPRINT* aLibFootprint, REPORTER* aReporter = nullptr );
763
778 void SetInitialComments( wxArrayString* aInitialComments )
779 {
780 delete m_initial_comments;
781 m_initial_comments = aInitialComments;
782 }
783
790 double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
791
792 static double GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLECTOR& aCollector );
793
795 const wxArrayString* GetInitialComments() const { return m_initial_comments; }
796
802 const SHAPE_POLY_SET& GetCourtyard( PCB_LAYER_ID aLayer ) const;
803
810 void BuildCourtyardCaches( OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
811
812 // @copydoc BOARD_ITEM::GetEffectiveShape
813 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
814 FLASHING aFlash = FLASHING::DEFAULT ) const override;
815
816#if defined(DEBUG)
817 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
818#endif
819
821 {
822 bool operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const;
823 };
824
825 struct cmp_pads
826 {
827 bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
828 };
829
831 {
832 bool operator()( const ZONE* aFirst, const ZONE* aSecond ) const;
833 };
834
835protected:
836 virtual void swapData( BOARD_ITEM* aImage ) override;
837
838private:
839 DRAWINGS m_drawings; // BOARD_ITEMs for drawings on the board, owned by pointer.
840 PADS m_pads; // PAD items, owned by pointer
841 ZONES m_zones; // PCB_ZONE items, owned by pointer
842 GROUPS m_groups; // PCB_GROUP items, owned by pointer
843
844 EDA_ANGLE m_orient; // Orientation
845 VECTOR2I m_pos; // Position of footprint on the board in internal units.
846 PCB_TEXT* m_reference; // Component reference designator value (U34, R18..)
847 PCB_TEXT* m_value; // Component value (74LS00, 22K..)
848 LIB_ID m_fpid; // The #LIB_ID of the FOOTPRINT.
849 int m_attributes; // Flag bits (see FOOTPRINT_ATTR_T)
850 int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
852
853 // Bounding box caching strategy:
854 // While we attempt to notice the low-hanging fruit operations and update the bounding boxes
855 // accordingly, we rely mostly on a "if anything changed then the caches are stale" approach.
856 // We implement this by having PCB_BASE_FRAME's OnModify() method increment an operation
857 // counter, and storing that as a timestamp for the various caches.
858 // This means caches will get regenerated often -- but still far less often than if we had no
859 // caches at all. The principal opitmization would be to change to dirty flag and make sure
860 // that any edit that could affect the bounding boxes (including edits to the footprint
861 // children) marked the bounding boxes dirty. It would definitely be faster -- but also more
862 // fragile.
871
872 // A list of pad groups, each of which is allowed to short nets within their group.
873 // A pad group is a comma-separated list of pad numbers.
874 std::vector<wxString> m_netTiePadGroups;
875
878 int m_localSolderMaskMargin; // Solder mask margin
879 int m_localSolderPasteMargin; // Solder paste margin absolute value
880 double m_localSolderPasteMarginRatio; // Solder mask margin ratio value of pad size
881
882 wxString m_doc; // File name and path for documentation file.
883 wxString m_keywords; // Search keywords to find footprint in library.
884 KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
886 int m_arflag; // Use to trace ratsnest and auto routing.
887 KIID m_link; // Temporary logical link used during editing
888 LSET m_privateLayers; // Layers visible only in the footprint editor
889
890 std::vector<FP_3DMODEL> m_3D_Drawings; // 3D models.
891 std::map<wxString, wxString> m_properties;
892 wxArrayString* m_initial_comments; // s-expression comments in the footprint,
893 // lazily allocated only if needed for speed
894
895 SHAPE_POLY_SET m_courtyard_cache_front; // Note that a footprint can have both front and back
896 SHAPE_POLY_SET m_courtyard_cache_back; // courtyards populated.
898};
899
900#endif // FOOTPRINT_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:71
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:196
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
double AsDegrees() const
Definition: eda_angle.h:149
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:92
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:175
bool FixUuids()
Old footprints do not always have a valid UUID (some can be set to null uuid) However null UUIDs,...
Definition: footprint.cpp:239
void CheckShortingPads(const std::function< void(const PAD *, const PAD *, const VECTOR2I &)> &aErrorHandler)
Check for overlapping, different-numbered, non-net-tie pads.
Definition: footprint.cpp:2357
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1656
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:215
LIB_ID m_fpid
Definition: footprint.h:848
void SetLink(const KIID &aLink)
Definition: footprint.h:692
KIID_PATH m_path
Definition: footprint.h:884
bool IsBoardOnly() const
Definition: footprint.h:585
BOX2I m_cachedTextExcludedBBox
Definition: footprint.h:867
void CheckPads(const std::function< void(const PAD *, int, const wxString &)> &aErrorHandler)
Run non-board-specific DRC checks on footprint's pads.
Definition: footprint.cpp:2278
bool IsDNP() const
Definition: footprint.h:621
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:352
std::vector< PAD * > GetNetTiePads(PAD *aPad) const
Definition: footprint.cpp:2231
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:494
EDA_ANGLE GetOrientation() const
Definition: footprint.h:193
ZONES & Zones()
Definition: footprint.h:178
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:628
void SetIsPlaced(bool isPlaced)
Definition: footprint.h:366
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:876
BOX2I m_cachedBoundingBox
Definition: footprint.h:863
static double GetCoverageArea(const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
Definition: footprint.cpp:1927
bool IsExcludedFromBOM() const
Definition: footprint.h:603
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:1728
void SetFlag(int aFlag)
Definition: footprint.h:255
void SetDNP(bool aDNP=true)
Definition: footprint.h:622
static bool IsLibNameValid(const wxString &aName)
Test for validity of a name of a footprint to be used in a footprint library ( no spaces,...
Definition: footprint.cpp:1526
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1223
void IncrementFlag()
Definition: footprint.h:256
PCB_TEXT * m_value
Definition: footprint.h:847
bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const override
A special IsOnLayer for footprints: return true if the footprint contains only items on the given lay...
Definition: footprint.cpp:1097
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.
Definition: footprint.cpp:2403
void SetExcludedFromBOM(bool aExclude=true)
Definition: footprint.h:604
int m_fpStatus
Definition: footprint.h:850
void SetDescription(const wxString &aDoc)
Definition: footprint.h:221
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:227
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: footprint.cpp:1470
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:869
int GetLocalClearance() const
Definition: footprint.h:232
void SetAllowMissingCourtyard(bool aAllow=true)
Definition: footprint.h:613
void SetKeywords(const wxString &aKeywords)
Definition: footprint.h:224
const DRAWINGS & GraphicalItems() const
Definition: footprint.h:176
int m_localSolderPasteMargin
Definition: footprint.h:879
void SetInitialComments(wxArrayString *aInitialComments)
Take ownership of caller's heap allocated aInitialComments block.
Definition: footprint.h:778
int m_attributes
Definition: footprint.h:849
PCB_TEXT & Value()
read/write accessors:
Definition: footprint.h:569
std::vector< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:890
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...
Definition: footprint.cpp:2010
BOARD_ITEM * DuplicateItem(const BOARD_ITEM *aItem, bool aAddToFootprint=false)
Duplicate a given item within the footprint, optionally adding it to the board.
Definition: footprint.cpp:1770
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.
Definition: footprint.cpp:2071
void SetAttributes(int aAttributes)
Definition: footprint.h:253
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: footprint.cpp:1380
double m_localSolderPasteMarginRatio
Definition: footprint.h:880
PCB_TEXT * m_reference
Definition: footprint.h:846
void TransformPadsToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aSkipNPTHPadsWihNoCopper=false, bool aSkipPlatedPads=false, bool aSkipNonPlatedPads=false) const
Generate pads shapes on layer aLayer as polygons and adds these polygons to aBuffer.
Definition: footprint.cpp:2634
wxArrayString * m_initial_comments
Definition: footprint.h:892
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1386
wxString GetDescription() const
Definition: footprint.h:220
BOX2I m_cachedVisibleBBox
Definition: footprint.h:865
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:246
BOX2I GetFpPadsLocalBbox() const
Return the bounding box containing pads when the footprint is on the front side, orientation 0,...
Definition: footprint.cpp:783
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:866
std::map< wxString, wxString > m_properties
Definition: footprint.h:891
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: footprint.cpp:1561
void SetFileFormatVersionAtLoad(int aVersion)
Definition: footprint.h:630
void SetExcludedFromPosFiles(bool aExclude=true)
Definition: footprint.h:595
int m_localClearance
Definition: footprint.h:877
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: footprint.h:247
void SetOrientationDegrees(double aOrientation)
Definition: footprint.h:205
void SetPrivateLayers(LSET aLayers)
Adds an item to the container.
Definition: footprint.h:123
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
Definition: footprint.cpp:2176
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:482
void MoveAnchorPosition(const VECTOR2I &aMoveVector)
Move the reference point of the footprint.
Definition: footprint.cpp:1683
void SetProperty(const wxString &aKey, const wxString &aVal)
Definition: footprint.h:583
FOOTPRINT & operator=(const FOOTPRINT &aOther)
Definition: footprint.cpp:374
int m_arflag
Definition: footprint.h:886
double GetOrientationDegrees() const
Definition: footprint.h:209
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1757
void SetLocalSolderPasteMargin(int aMargin)
Definition: footprint.h:244
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...
Definition: footprint.cpp:1284
int GetAttributes() const
Definition: footprint.h:252
int m_localSolderMaskMargin
Definition: footprint.h:878
void ClearNetTiePadGroups()
Definition: footprint.h:276
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:202
LSET GetPrivateLayers() const
Definition: footprint.h:122
wxString GetFPIDAsString() const
Definition: footprint.h:217
wxString GetValueAsString() const
Definition: footprint.h:563
bool AllowMissingCourtyard() const
Definition: footprint.h:612
const ZONES & Zones() const
Definition: footprint.h:179
bool IsFlipped() const
Definition: footprint.h:326
int GetLocalClearance(wxString *aSource) const
Definition: footprint.h:235
PADS & Pads()
Definition: footprint.h:172
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:941
int GetLocalSolderPasteMargin() const
Definition: footprint.h:243
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...
Definition: footprint.cpp:2707
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:771
DRAWINGS m_drawings
Definition: footprint.h:839
bool NeedsPlaced() const
Definition: footprint.h:374
SHAPE_POLY_SET m_courtyard_cache_back
Definition: footprint.h:896
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:868
const std::vector< wxString > & GetNetTiePadGroups() const
Definition: footprint.h:274
void SetLocalClearance(int aClearance)
Definition: footprint.h:233
const LIB_ID & GetFPID() const
Definition: footprint.h:214
void SetReference(const wxString &aReference)
Definition: footprint.h:530
bool IsLocked() const override
Definition: footprint.h:342
const GROUPS & Groups() const
Definition: footprint.h:182
bool IsExcludedFromPosFiles() const
Definition: footprint.h:594
void SetLayerAndFlip(PCB_LAYER_ID aLayer)
Used as Layer property setter – performs a flip if necessary to set the footprint layer.
Definition: footprint.cpp:1587
void SetLocalSolderMaskMargin(int aMargin)
Definition: footprint.h:230
ZONES m_zones
Definition: footprint.h:841
int m_hullCacheTimeStamp
Definition: footprint.h:870
unsigned GetUniquePadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of unique non-blank pads.
Definition: footprint.cpp:1242
void AddNetTiePadGroup(const wxString &aGroup)
Definition: footprint.h:281
bool LegacyPadsLocked() const
Definition: footprint.h:383
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: footprint.cpp:1511
LSET m_privateLayers
Definition: footprint.h:888
int GetLikelyAttribute() const
Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)
Definition: footprint.cpp:721
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: footprint.cpp:1554
static bool ClassOf(const EDA_ITEM *aItem)
Definition: footprint.h:117
bool FootprintNeedsUpdate(const FOOTPRINT *aLibFootprint, REPORTER *aReporter=nullptr)
Return true if a board footprint differs from the library version.
VECTOR2I m_pos
Definition: footprint.h:845
std::vector< wxString > m_netTiePadGroups
Definition: footprint.h:874
PAD * GetPad(const VECTOR2I &aPosition, LSET aLayerMask=LSET::AllLayersMask())
Get a pad at aPosition on aLayerMask in the footprint.
Definition: footprint.cpp:1207
void Add3DModel(FP_3DMODEL *a3DModel)
Add a3DModel definition to the end of the 3D model list.
Definition: footprint.cpp:1273
void SetValue(const wxString &aValue)
Definition: footprint.h:557
bool HasProperty(const wxString &aKey)
Definition: footprint.h:579
GROUPS m_groups
Definition: footprint.h:842
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: footprint.cpp:1023
wxString GetReferenceAsString() const
Definition: footprint.h:536
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars for this footprint.
Definition: footprint.cpp:481
SHAPE_POLY_SET m_courtyard_cache_front
Definition: footprint.h:895
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:568
PCB_TEXT & Reference()
Definition: footprint.h:570
wxString m_keywords
Definition: footprint.h:883
void ClearAllNets()
Clear (i.e.
Definition: footprint.cpp:559
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: footprint.h:249
bool HasThroughHolePads() const
Definition: footprint.cpp:2542
void BuildCourtyardCaches(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Build complex polygons of the courtyard areas from graphic items on the courtyard layers.
Definition: footprint.cpp:2119
EDA_ANGLE m_orient
Definition: footprint.h:844
bool HitTestAccurate(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if a point is inside the bounding polygon of the footprint.
Definition: footprint.cpp:1132
bool IsNetTie() const
Definition: footprint.h:259
wxString GetClass() const override
Return the class name.
Definition: footprint.h:713
const PADS & Pads() const
Definition: footprint.h:173
void IncrementReference(int aDelta)
Bump the current reference by aDelta.
Definition: footprint.cpp:1900
int GetFileFormatVersionAtLoad() const
Definition: footprint.h:631
KIID m_link
Definition: footprint.h:887
GROUPS & Groups()
Definition: footprint.h:181
PCB_TEXT & Reference() const
Definition: footprint.h:574
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: footprint.h:795
KIID GetLink() const
Definition: footprint.h:691
bool IsConflicting() const
Definition: footprint.cpp:475
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:186
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1392
PCB_TEXT & Value() const
The const versions to keep the compiler happy.
Definition: footprint.h:573
static const wxChar * StringLibNameInvalidChars(bool aUserReadable)
Test for validity of the name in a library of the footprint ( no spaces, dir separators ....
Definition: footprint.cpp:1537
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1596
const wxString & GetValue() const
Definition: footprint.h:549
double GetArea(int aPadding=0) const
Definition: footprint.cpp:711
void SetNeedsPlaced(bool needsPlaced)
Definition: footprint.h:375
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:250
const wxString & GetReference() const
Definition: footprint.h:521
void CheckNetTiePadGroups(const std::function< void(const wxString &)> &aErrorHandler)
Sanity check net-tie pad groups.
Definition: footprint.cpp:2509
void SetFPIDAsString(const wxString &aFPID)
Definition: footprint.h:218
void SetBoardOnly(bool aIsBoardOnly=true)
Definition: footprint.h:586
const std::vector< FP_3DMODEL > & Models() const
Definition: footprint.h:187
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:577
timestamp_t m_lastEditTime
Definition: footprint.h:885
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2107
int GetFlag() const
Definition: footprint.h:257
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: footprint.cpp:1418
int m_fileFormatVersionAtLoad
Definition: footprint.h:851
wxString m_doc
Definition: footprint.h:882
const KIID_PATH & GetPath() const
Definition: footprint.h:226
wxString GetKeywords() const
Definition: footprint.h:223
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...
Definition: footprint.cpp:2253
const wxString & GetProperty(const wxString &aKey)
Definition: footprint.h:578
PADS m_pads
Definition: footprint.h:840
virtual void swapData(BOARD_ITEM *aImage) override
Definition: footprint.cpp:2534
wxString GetNextPadNumber(const wxString &aLastPadName) const
Return the next available pad number in the footprint.
Definition: footprint.cpp:1880
bool IsPlaced() const
Definition: footprint.h:365
int m_courtyard_cache_timestamp
Definition: footprint.h:897
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:864
VECTOR2I GetPosition() const override
Definition: footprint.h:190
DRAWINGS & GraphicalItems()
Definition: footprint.h:175
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: footprint.cpp:1125
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: footprint.cpp:1369
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1187
int GetLocalSolderMaskMargin() const
Definition: footprint.h:229
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:576
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:806
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:95
double m_Opacity
Definition: footprint.h:96
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:94
FP_3DMODEL()
Definition: footprint.h:83
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:93
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:97
bool m_Show
Include model in rendering.
Definition: footprint.h:98
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
Definition: kiid.h:48
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:50
UTF8 Format() const
Definition: lib_id.cpp:117
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:536
static LSET AllLayersMask()
Definition: lset.cpp:808
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Definition: pad.h:59
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
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:72
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:44
#define _(s)
@ DEGREES_T
Definition: eda_angle.h:31
INSPECT_RESULT
Definition: eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:78
INCLUDE_NPTH_T
Definition: footprint.h:57
@ INCLUDE_NPTH
Definition: footprint.h:59
@ DO_NOT_INCLUDE_NPTH
Definition: footprint.h:58
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition: footprint.h:68
@ FP_SMD
Definition: footprint.h:70
@ FP_DNP
Definition: footprint.h:77
@ FP_ALLOW_MISSING_COURTYARD
Definition: footprint.h:76
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:71
@ FP_BOARD_ONLY
Definition: footprint.h:73
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:72
@ FP_JUST_ADDED
Definition: footprint.h:74
@ FP_THROUGH_HOLE
Definition: footprint.h:69
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:75
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:337
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition: footprint.h:336
#define FP_PADS_are_LOCKED
Definition: footprint.h:339
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition: footprint.h:338
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
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:147
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
bool operator()(const BOARD_ITEM *itemA, const BOARD_ITEM *itemB) const
Definition: footprint.cpp:2558
bool operator()(const PAD *aFirst, const PAD *aSecond) const
Definition: footprint.cpp:2599
bool operator()(const ZONE *aFirst, const ZONE *aSecond) const
Definition: footprint.cpp:2615
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:49