KiCad PCB EDA Suite
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-2021 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 
30 #include <board_item_container.h>
31 #include <board_item.h>
32 #include <collectors.h>
33 #include <convert_to_biu.h>
34 #include <layer_ids.h> // ALL_LAYERS definition.
35 #include <lib_id.h>
36 #include <list>
37 
38 #include <zones.h>
40 #include <pcb_item_containers.h>
41 #include <fp_text.h>
42 #include <functional>
43 
44 class LINE_READER;
45 class EDA_3D_CANVAS;
46 class PAD;
47 class BOARD;
48 class MSG_PANEL_ITEM;
49 class SHAPE;
50 
51 namespace KIGFX {
52 class VIEW;
53 }
54 
56 {
58  INCLUDE_NPTH = true
59 };
60 
67 {
68  FP_THROUGH_HOLE = 0x0001,
69  FP_SMD = 0x0002,
72  FP_BOARD_ONLY = 0x0010, // Footprint has no corresponding symbol
73  FP_JUST_ADDED = 0x0020 // Footprint just added by netlist update
74 };
75 
77 {
78 public:
80  // Initialize with sensible values
81  m_Scale { 1, 1, 1 },
82  m_Rotation { 0, 0, 0 },
83  m_Offset { 0, 0, 0 },
84  m_Opacity( 1.0 ),
85  m_Show( true )
86  {
87  }
88 
89  struct VECTOR3D
90  {
91  double x, y, z;
92  };
93 
97  double m_Opacity;
98  wxString m_Filename;
99  bool m_Show;
100 };
101 
102 
104 {
105 public:
106  FOOTPRINT( BOARD* parent );
107 
108  FOOTPRINT( const FOOTPRINT& aFootprint );
109 
110  // Move constructor and operator needed due to std containers inside the footprint
111  FOOTPRINT( FOOTPRINT&& aFootprint );
112 
113  ~FOOTPRINT();
114 
115  FOOTPRINT& operator=( const FOOTPRINT& aOther );
116  FOOTPRINT& operator=( FOOTPRINT&& aOther );
117 
118  static inline bool ClassOf( const EDA_ITEM* aItem )
119  {
120  return aItem && aItem->Type() == PCB_FOOTPRINT_T;
121  }
122 
124  void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) override;
125 
127  void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
128 
136  void ClearAllNets();
137 
145  bool FixUuids();
146 
157 
164 
165  // Virtual function
166  const EDA_RECT GetBoundingBox() const override;
167  const EDA_RECT GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const;
168 
169  PADS& Pads() { return m_pads; }
170  const PADS& Pads() const { return m_pads; }
171 
172  DRAWINGS& GraphicalItems() { return m_drawings; }
173  const DRAWINGS& GraphicalItems() const { return m_drawings; }
174 
175  FP_ZONES& Zones() { return m_fp_zones; }
176  const FP_ZONES& Zones() const { return m_fp_zones; }
177 
178  FP_GROUPS& Groups() { return m_fp_groups; }
179  const FP_GROUPS& Groups() const { return m_fp_groups; }
180 
181  bool HasThroughHolePads() const;
182 
183  std::list<FP_3DMODEL>& Models() { return m_3D_Drawings; }
184  const std::list<FP_3DMODEL>& Models() const { return m_3D_Drawings; }
185 
186  void SetPosition( const wxPoint& aPos ) override;
187  wxPoint GetPosition() const override { return m_pos; }
188 
189  void SetOrientation( double aNewAngle );
190  void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation * 10.0 ); }
191  double GetOrientation() const { return m_orient; }
192  double GetOrientationDegrees() const { return m_orient / 10.0; }
193  double GetOrientationRadians() const { return m_orient * M_PI / 1800; }
194 
195  const LIB_ID& GetFPID() const { return m_fpid; }
196  void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
197 
198  const wxString& GetDescription() const { return m_doc; }
199  void SetDescription( const wxString& aDoc ) { m_doc = aDoc; }
200 
201  const wxString& GetKeywords() const { return m_keywords; }
202  void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
203 
204  const KIID_PATH& GetPath() const { return m_path; }
205  void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
206 
208  void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
209 
210  int GetLocalClearance() const { return m_localClearance; }
211  void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
212 
213  int GetLocalClearance( wxString* aSource ) const
214  {
215  if( aSource )
216  *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
217 
218  return m_localClearance;
219  }
220 
222  void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
223 
226 
229 
230  void SetThermalWidth( int aWidth ) { m_thermalWidth = aWidth; }
231  int GetThermalWidth() const { return m_thermalWidth; }
232 
233  void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
234  int GetThermalGap() const { return m_thermalGap; }
235 
236  int GetAttributes() const { return m_attributes; }
237  void SetAttributes( int aAttributes ) { m_attributes = aAttributes; }
238 
239  void SetFlag( int aFlag ) { m_arflag = aFlag; }
240  void IncrementFlag() { m_arflag += 1; }
241  int GetFlag() const { return m_arflag; }
242 
243  // A bit of a hack until net ties are supported as first class citizens
244  bool IsNetTie() const
245  {
246  return GetKeywords().StartsWith( wxT( "net tie" ) );
247  }
248 
254  int GetLikelyAttribute() const;
255 
256  void Move( const wxPoint& aMoveVector ) override;
257 
258  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
259 
260  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
261 
273  void MoveAnchorPosition( const wxPoint& aMoveVector );
274 
278  bool IsFlipped() const { return GetLayer() == B_Cu; }
279 
285  bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
286 
287 // m_footprintStatus bits:
288 #define FP_is_LOCKED 0x01
289 #define FP_is_PLACED 0x02
290 #define FP_to_PLACE 0x04
291 #define FP_PADS_are_LOCKED 0x08
292 
293 
294  bool IsLocked() const override
295  {
296  return ( m_fpStatus & FP_is_LOCKED ) != 0;
297  }
298 
304  void SetLocked( bool isLocked ) override
305  {
306  if( isLocked )
308  else
310  }
311 
312  bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
313  void SetIsPlaced( bool isPlaced )
314  {
315  if( isPlaced )
317  else
319  }
320 
321  bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
322  void SetNeedsPlaced( bool needsPlaced )
323  {
324  if( needsPlaced )
326  else
328  }
329 
330  bool LegacyPadsLocked() const { return m_fpStatus & FP_PADS_are_LOCKED; }
331 
332  /*
333  void SetPadsLocked( bool aPadsLocked )
334  {
335  if( aPadsLocked )
336  m_fpStatus |= FP_PADS_are_LOCKED;
337  else
338  m_fpStatus &= ~FP_PADS_are_LOCKED;
339  }
340  */
341 
342  void SetLastEditTime( timestamp_t aTime ) { m_lastEditTime = aTime; }
343  void SetLastEditTime() { m_lastEditTime = time( nullptr ); }
345 
356  void CheckFootprintAttributes( const std::function<void( const wxString& msg )>* aErrorHandler );
357 
368  void CheckFootprintTHPadNoHoles( const std::function
369  <void( const wxString& msg, const wxPoint& position )>*
370  aErrorHandler );
371 
393  PCB_LAYER_ID aLayer, int aClearance,
394  int aMaxError, ERROR_LOC aErrorLoc,
395  bool aSkipNPTHPadsWihNoCopper = false,
396  bool aSkipPlatedPads = false,
397  bool aSkipNonPlatedPads = false ) const;
398 
414  PCB_LAYER_ID aLayer, int aClearance,
415  int aError, ERROR_LOC aErrorLoc,
416  bool aIncludeText = true,
417  bool aIncludeShapes = true ) const;
418 
424  PCB_LAYER_ID aLayer, int aClearance,
425  int aError, ERROR_LOC aErrorLoc ) const
426  {
427  TransformFPShapesWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance, aError,
428  aErrorLoc, true, false );
429  }
430 
434  void GetContextualTextVars( wxArrayString* aVars ) const;
435 
441  bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
442 
444  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
445 
446  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
447 
457  bool HitTestAccurate( const wxPoint& aPosition, int aAccuracy = 0 ) const;
458 
459  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
460 
464  const wxString& GetReference() const
465  {
466  return m_reference->GetText();
467  }
468 
473  void SetReference( const wxString& aReference )
474  {
475  m_reference->SetText( aReference );
476  }
477 
481  void IncrementReference( int aDelta );
482 
486  const wxString& GetValue() const
487  {
488  return m_value->GetText();
489  }
490 
494  void SetValue( const wxString& aValue )
495  {
496  m_value->SetText( aValue );
497  }
498 
500  FP_TEXT& Value() { return *m_value; }
501  FP_TEXT& Reference() { return *m_reference; }
502 
504  FP_TEXT& Value() const { return *m_value; }
505  FP_TEXT& Reference() const { return *m_reference; }
506 
507  const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
508  void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
509  const wxString& GetProperty( const wxString& aKey) { return m_properties[ aKey ]; }
510  bool HasProperty( const wxString& aKey)
511  {
512  return m_properties.find( aKey ) != m_properties.end();
513  }
514  void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
515 
525  PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
526 
534  PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask = LSET::AllLayersMask() );
535 
536  PAD* GetTopLeftPad();
537 
545  unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
546 
557  unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
558 
566  wxString GetNextPadNumber( const wxString& aLastPadName ) const;
567 
572  wxString GetTypeName() const;
573 
574  double GetArea( int aPadding = 0 ) const;
575 
576  KIID GetLink() const { return m_link; }
577  void SetLink( const KIID& aLink ) { m_link = aLink; }
578 
579  int GetPlacementCost180() const { return m_rot180Cost; }
580  void SetPlacementCost180( int aCost ) { m_rot180Cost = aCost; }
581 
582  int GetPlacementCost90() const { return m_rot90Cost; }
583  void SetPlacementCost90( int aCost ) { m_rot90Cost = aCost; }
584 
585  BOARD_ITEM* Duplicate() const override;
586 
592  BOARD_ITEM* DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootprint = false );
593 
599  void Add3DModel( FP_3DMODEL* a3DModel );
600 
601  SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
602 
603  wxString GetClass() const override
604  {
605  return wxT( "FOOTPRINT" );
606  }
607 
608  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
609 
610  BITMAPS GetMenuImage() const override;
611 
612  EDA_ITEM* Clone() const override;
613 
621  void RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction ) const;
622 
630  void GetAllDrawingLayers( int aLayers[], int& aCount, bool aIncludePads = true ) const;
631 
632  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
633 
634  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
635 
636  virtual const BOX2I ViewBBox() const override;
637 
645  static bool IsLibNameValid( const wxString& aName );
646 
656  static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
657 
672  void SetInitialComments( wxArrayString* aInitialComments )
673  {
674  delete m_initial_comments;
675  m_initial_comments = aInitialComments;
676  }
677 
684  double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
685 
686  static double GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLECTOR& aCollector );
687 
689  const wxArrayString* GetInitialComments() const { return m_initial_comments; }
690 
697  {
698  if( IsBackLayer( aLayer ) )
699  return m_poly_courtyard_back;
700  else
701  return m_poly_courtyard_front;
702  }
703 
710  void BuildPolyCourtyards( OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
711 
712  virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
713 
714  virtual void SwapData( BOARD_ITEM* aImage ) override;
715 
717  {
718  bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
719  };
720 
721  struct cmp_pads
722  {
723  bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
724  };
725 
726 
727 #if defined(DEBUG)
728  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
729 #endif
730 
731 private:
732  DRAWINGS m_drawings; // BOARD_ITEMs for drawings on the board, owned by pointer.
733  PADS m_pads; // PAD items, owned by pointer
734  FP_ZONES m_fp_zones; // FP_ZONE items, owned by pointer
735  FP_GROUPS m_fp_groups; // PCB_GROUP items, owned by pointer
736 
737  double m_orient; // Orientation in tenths of a degree, 900=90.0 degrees.
738  wxPoint m_pos; // Position of footprint on the board in internal units.
739  FP_TEXT* m_reference; // Component reference designator value (U34, R18..)
740  FP_TEXT* m_value; // Component value (74LS00, 22K..)
741  LIB_ID m_fpid; // The #LIB_ID of the FOOTPRINT.
742  int m_attributes; // Flag bits ( see FOOTPRINT_ATTR_T )
743  int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
744 
745  // Bounding box caching strategy:
746  // While we attempt to notice the low-hanging fruit operations and update the bounding boxes
747  // accordingly, we rely mostly on a "if anything changed then the caches are stale" approach.
748  // We implement this by having PCB_BASE_FRAME's OnModify() method increment an operation
749  // counter, and storing that as a timestamp for the various caches.
750  // This means caches will get regenerated often -- but still far less often than if we had no
751  // caches at all. The principal opitmization would be to change to dirty flag and make sure
752  // that any edit that could affect the bounding boxes (including edits to the footprint
753  // children) marked the bounding boxes dirty. It would definitely be faster -- but also more
754  // fragile.
762  mutable int m_hullCacheTimeStamp;
763 
768  int m_localSolderMaskMargin; // Solder mask margin
769  int m_localSolderPasteMargin; // Solder paste margin absolute value
770  double m_localSolderPasteMarginRatio; // Solder mask margin ratio value of pad size
771 
772  wxString m_doc; // File name and path for documentation file.
773  wxString m_keywords; // Search keywords to find footprint in library.
774  KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
776  int m_arflag; // Use to trace ratsnest and auto routing.
777  KIID m_link; // Temporary logical link used during editing
778  int m_rot90Cost; // Horizontal automatic placement cost ( 0..10 ).
779  int m_rot180Cost; // Vertical automatic placement cost ( 0..10 ).
780 
781  std::list<FP_3DMODEL> m_3D_Drawings; // Linked list of 3D models.
782  std::map<wxString, wxString> m_properties;
783  wxArrayString* m_initial_comments; // s-expression comments in the footprint,
784  // lazily allocated only if needed for speed
785 
786  SHAPE_POLY_SET m_poly_courtyard_front; // Note that a footprint can have both front and back
787  SHAPE_POLY_SET m_poly_courtyard_back; // courtyards populated.
788 };
789 
790 #endif // FOOTPRINT_H
void SetReference(const wxString &aReference)
Definition: footprint.h:473
void BuildPolyCourtyards(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Build complex polygons of the courtyard areas from graphic items on the courtyard layers.
Definition: footprint.cpp:2040
int m_localSolderPasteMargin
Definition: footprint.h:769
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:1738
static double GetCoverageArea(const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: footprint.cpp:1870
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
bool IsLocked() const override
Definition: footprint.h:294
bool NeedsPlaced() const
Definition: footprint.h:321
double GetArea(int aPadding=0) const
Definition: footprint.cpp:643
void ClearAllNets()
Clear (i.e.
Definition: footprint.cpp:504
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: footprint.cpp:1397
const wxString & GetDescription() const
Definition: footprint.h:198
void SetInitialComments(wxArrayString *aInitialComments)
Take ownership of caller's heap allocated aInitialComments block.
Definition: footprint.h:672
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
EDA_RECT m_cachedVisibleBBox
Definition: footprint.h:757
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:847
double GetOrientationRadians() const
Definition: footprint.h:193
bool FixUuids()
Old footprints do not alway have a valid UUID (some can be set to null uuid) However null UUIDs,...
Definition: footprint.cpp:227
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: footprint.cpp:1275
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:183
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:926
void SetNeedsPlaced(bool needsPlaced)
Definition: footprint.h:322
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
A special IsOnLayer for footprints: return true if the footprint contains only items on the given lay...
Definition: footprint.cpp:992
const wxString & GetValue() const
Definition: footprint.h:486
FP_TEXT & Value() const
The const versions to keep the compiler happy.
Definition: footprint.h:504
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:243
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: footprint.h:227
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1129
const KIID_PATH & GetPath() const
Definition: footprint.h:204
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:764
double m_localSolderPasteMarginRatio
Definition: footprint.h:770
SHAPE_POLY_SET m_poly_courtyard_back
Definition: footprint.h:787
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
int GetPlacementCost180() const
Definition: footprint.h:579
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:205
#define FP_PADS_are_LOCKED
Definition: footprint.h:291
void SetIsPlaced(bool isPlaced)
Definition: footprint.h:313
double m_orient
Definition: footprint.h:737
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:477
void CheckFootprintAttributes(const std::function< void(const wxString &msg)> *aErrorHandler)
Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the p...
Definition: footprint.cpp:2095
timestamp_t m_lastEditTime
Definition: footprint.h:775
void IncrementFlag()
Definition: footprint.h:240
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:566
double GetOrientation() const
Definition: footprint.h:191
void TransformFPTextWithClearanceToPolygonSet(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
This function is the same as TransformGraphicShapesWithClearanceToPolygonSet but only generate text.
Definition: footprint.h:423
FP_3DMODEL()
Definition: footprint.h:79
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:1950
bool LegacyPadsLocked() const
Definition: footprint.h:330
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: footprint.h:225
void SetOrientationDegrees(double aOrientation)
Definition: footprint.h:190
FP_TEXT * m_reference
Definition: footprint.h:739
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:758
INCLUDE_NPTH_T
Definition: footprint.h:55
void SetThermalGap(int aGap)
Definition: footprint.h:233
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
The base class for create windows for drawing purpose.
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:96
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: footprint.cpp:1286
void CheckFootprintTHPadNoHoles(const std::function< void(const wxString &msg, const wxPoint &position)> *aErrorHandler)
Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the p...
Definition: footprint.cpp:2126
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition: footprint.h:66
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:93
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
timestamp_t GetLastEditTime() const
Definition: footprint.h:344
bool operator()(const PAD *aFirst, const PAD *aSecond) const
Definition: footprint.cpp:2196
void SetAttributes(int aAttributes)
Definition: footprint.h:237
int m_rot90Cost
Definition: footprint.h:778
PADS & Pads()
Definition: footprint.h:169
void SetPlacementCost180(int aCost)
Definition: footprint.h:580
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: footprint.cpp:2151
void Add3DModel(FP_3DMODEL *a3DModel)
Add a3DModel definition to the end of the 3D model list.
Definition: footprint.cpp:1179
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:500
FP_TEXT * m_value
Definition: footprint.h:740
PAD * GetTopLeftPad()
Definition: footprint.cpp:1110
void SetThermalWidth(int aWidth)
Definition: footprint.h:230
void SetDescription(const wxString &aDoc)
Definition: footprint.h:199
int m_arflag
Definition: footprint.h:776
KIID m_link
Definition: footprint.h:777
FP_TEXT & Reference()
Definition: footprint.h:501
const FP_ZONES & Zones() const
Definition: footprint.h:176
int m_localSolderMaskMargin
Definition: footprint.h:768
EDA_RECT m_cachedBoundingBox
Definition: footprint.h:755
int GetLikelyAttribute() const
Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)
Definition: footprint.cpp:653
FP_ZONES & Zones()
Definition: footprint.h:175
Definition: kiid.h:44
bool m_Show
Include model in rendering.
Definition: footprint.h:99
int m_fpStatus
Definition: footprint.h:743
int GetFlag() const
Definition: footprint.h:241
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: footprint.cpp:1414
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
FP_ZONES m_fp_zones
Definition: footprint.h:734
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:896
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:1351
SHAPE_POLY_SET m_poly_courtyard_front
Definition: footprint.h:786
void IncrementReference(int aDelta)
Bump the current reference by aDelta.
Definition: footprint.cpp:1843
Represent a set of closed polygons.
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:761
PAD * GetPad(const wxPoint &aPosition, LSET aLayerMask=LSET::AllLayersMask())
Get a pad at aPosition on aLayerMask in the footprint.
Definition: footprint.cpp:1094
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: footprint.cpp:1458
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1680
const DRAWINGS & GraphicalItems() const
Definition: footprint.h:173
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1490
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:94
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1074
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: footprint.cpp:1190
int m_thermalGap
Definition: footprint.h:766
void SetLocalClearance(int aClearance)
Definition: footprint.h:211
int GetLocalClearance() const
Definition: footprint.h:210
bool IsNetTie() const
Definition: footprint.h:244
const PADS & Pads() const
Definition: footprint.h:170
const wxString & GetReference() const
Definition: footprint.h:464
#define _(s)
double m_Opacity
Definition: footprint.h:97
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1724
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
const SHAPE_POLY_SET & GetPolyCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.h:696
void MoveAnchorPosition(const wxPoint &aMoveVector)
Move the reference point of the footprint.
Definition: footprint.cpp:1607
static LSET AllLayersMask()
Definition: lset.cpp:796
bool IsPlaced() const
Definition: footprint.h:312
const LIB_ID & GetFPID() const
Definition: footprint.h:195
const FP_GROUPS & Groups() const
Definition: footprint.h:179
An abstract shape on 2D plane.
Definition: shape.h:116
wxString GetNextPadNumber(const wxString &aLastPadName) const
Return the next available pad number in the footprint.
Definition: footprint.cpp:1823
FP_TEXT & Reference() const
Definition: footprint.h:505
wxPoint m_pos
Definition: footprint.h:738
void SetValue(const wxString &aValue)
Definition: footprint.h:494
void SetFlag(int aFlag)
Definition: footprint.h:239
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: footprint.cpp:1465
const wxString & GetKeywords() const
Definition: footprint.h:201
void TransformPadsWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, 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 aCornerBuffer.
Definition: footprint.cpp:2208
int GetThermalWidth() const
Definition: footprint.h:231
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:756
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition: footprint.h:290
KIID GetLink() const
Definition: footprint.h:576
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition: footprint.h:288
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KIID_PATH m_path
Definition: footprint.h:774
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:98
const wxArrayString * GetInitialComments() const
Definition: footprint.h:689
EDA_UNITS
Definition: eda_units.h:38
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:32
int GetLocalClearance(wxString *aSource) const
Definition: footprint.h:213
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: footprint.cpp:2171
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars for this footprint.
Definition: footprint.cpp:469
bool IsFlipped() const
Definition: footprint.h:278
FP_GROUPS & Groups()
Definition: footprint.h:178
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:196
void SetLink(const KIID &aLink)
Definition: footprint.h:577
double GetOrientationDegrees() const
Definition: footprint.h:192
int m_thermalWidth
Definition: footprint.h:765
wxString m_keywords
Definition: footprint.h:773
int GetLocalSolderMaskMargin() const
Definition: footprint.h:207
FOOTPRINT(BOARD *parent)
Definition: footprint.cpp:51
int m_localClearance
Definition: footprint.h:767
void SetProperty(const wxString &aKey, const wxString &aVal)
Definition: footprint.h:514
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:95
int GetAttributes() const
Definition: footprint.h:236
int m_rot180Cost
Definition: footprint.h:779
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:760
wxString GetClass() const override
Return the class name.
Definition: footprint.h:603
void TransformFPShapesWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIncludeText=true, bool aIncludeShapes=true) const
Generate shapes of graphic items (outlines) on layer aLayer as polygons and adds these polygons to aC...
Definition: footprint.cpp:2306
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
const std::list< FP_3DMODEL > & Models() const
Definition: footprint.h:184
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
LIB_ID m_fpid
Definition: footprint.h:741
void SetLastEditTime(timestamp_t aTime)
Definition: footprint.h:342
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:736
void SetKeywords(const wxString &aKeywords)
Definition: footprint.h:202
Handle the component boundary box.
Definition: eda_rect.h:42
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:304
FOOTPRINT & operator=(const FOOTPRINT &aOther)
Definition: footprint.cpp:365
unsigned GetUniquePadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of unique non-blank pads.
Definition: footprint.cpp:1148
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
EDA_RECT m_cachedTextExcludedBBox
Definition: footprint.h:759
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:701
wxPoint GetPosition() const override
Definition: footprint.h:187
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:224
DRAWINGS m_drawings
Definition: footprint.h:732
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:507
void GetAllDrawingLayers(int aLayers[], int &aCount, bool aIncludePads=true) const
Return a set of all layers that this footprint has drawings on similar to ViewGetLayers().
Definition: footprint.cpp:1324
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const wxPoint &pt)> OUTLINE_ERROR_HANDLER
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:1298
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:228
int GetPlacementCost90() const
Definition: footprint.h:582
void SetLastEditTime()
Definition: footprint.h:343
std::map< wxString, wxString > m_properties
Definition: footprint.h:782
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:1432
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: footprint.cpp:1015
static bool ClassOf(const EDA_ITEM *aItem)
Adds an item to the container.
Definition: footprint.h:118
Abstract interface for BOARD_ITEMs capable of storing other items inside.
int GetLocalSolderPasteMargin() const
Definition: footprint.h:221
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:508
wxArrayString * m_initial_comments
Definition: footprint.h:783
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:289
const wxString & GetProperty(const wxString &aKey)
Definition: footprint.h:509
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1561
SEARCH_RESULT
Definition: eda_item.h:41
FP_GROUPS m_fp_groups
Definition: footprint.h:735
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1292
bool HasProperty(const wxString &aKey)
Definition: footprint.h:510
bool HasThroughHolePads() const
Definition: footprint.cpp:2159
wxString m_doc
Definition: footprint.h:772
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
bool HitTestAccurate(const wxPoint &aPosition, int aAccuracy=0) const
Test if a point is inside the bounding polygon of the footprint.
Definition: footprint.cpp:1022
int GetThermalGap() const
Definition: footprint.h:234
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
std::list< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:781
PADS m_pads
Definition: footprint.h:733
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:1443
int m_hullCacheTimeStamp
Definition: footprint.h:762
void SetPlacementCost90(int aCost)
Definition: footprint.h:583
int m_attributes
Definition: footprint.h:742
void SetLocalSolderMaskMargin(int aMargin)
Definition: footprint.h:208
EDA_RECT GetFpPadsLocalBbox() const
Return the bounding box containing pads when the footprint is on the front side, orientation 0,...
Definition: footprint.cpp:713
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: footprint.cpp:2016
void SetLocalSolderPasteMargin(int aMargin)
Definition: footprint.h:222