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 GetFPIDAsString() const { return m_fpid.Format(); }
199  void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); }
200 
201  const wxString& GetDescription() const { return m_doc; }
202  void SetDescription( const wxString& aDoc ) { m_doc = aDoc; }
203 
204  const wxString& GetKeywords() const { return m_keywords; }
205  void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
206 
207  const KIID_PATH& GetPath() const { return m_path; }
208  void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
209 
211  void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
212 
213  int GetLocalClearance() const { return m_localClearance; }
214  void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
215 
216  int GetLocalClearance( wxString* aSource ) const
217  {
218  if( aSource )
219  *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
220 
221  return m_localClearance;
222  }
223 
225  void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
226 
229 
232 
233  void SetThermalWidth( int aWidth ) { m_thermalWidth = aWidth; }
234  int GetThermalWidth() const { return m_thermalWidth; }
235 
236  void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
237  int GetThermalGap() const { return m_thermalGap; }
238 
239  int GetAttributes() const { return m_attributes; }
240  void SetAttributes( int aAttributes ) { m_attributes = aAttributes; }
241 
242  void SetFlag( int aFlag ) { m_arflag = aFlag; }
243  void IncrementFlag() { m_arflag += 1; }
244  int GetFlag() const { return m_arflag; }
245 
246  // A bit of a hack until net ties are supported as first class citizens
247  bool IsNetTie() const
248  {
249  return GetKeywords().StartsWith( wxT( "net tie" ) );
250  }
251 
257  int GetLikelyAttribute() const;
258 
259  void Move( const wxPoint& aMoveVector ) override;
260 
261  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
262 
263  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
264 
276  void MoveAnchorPosition( const wxPoint& aMoveVector );
277 
281  bool IsFlipped() const { return GetLayer() == B_Cu; }
282 
288  bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
289 
290 // m_footprintStatus bits:
291 #define FP_is_LOCKED 0x01
292 #define FP_is_PLACED 0x02
293 #define FP_to_PLACE 0x04
294 #define FP_PADS_are_LOCKED 0x08
295 
296 
297  bool IsLocked() const override
298  {
299  return ( m_fpStatus & FP_is_LOCKED ) != 0;
300  }
301 
307  void SetLocked( bool isLocked ) override
308  {
309  if( isLocked )
311  else
313  }
314 
315  bool IsPlaced() const { return m_fpStatus & FP_is_PLACED; }
316  void SetIsPlaced( bool isPlaced )
317  {
318  if( isPlaced )
320  else
322  }
323 
324  bool NeedsPlaced() const { return m_fpStatus & FP_to_PLACE; }
325  void SetNeedsPlaced( bool needsPlaced )
326  {
327  if( needsPlaced )
329  else
331  }
332 
333  bool LegacyPadsLocked() const { return m_fpStatus & FP_PADS_are_LOCKED; }
334 
335  /*
336  void SetPadsLocked( bool aPadsLocked )
337  {
338  if( aPadsLocked )
339  m_fpStatus |= FP_PADS_are_LOCKED;
340  else
341  m_fpStatus &= ~FP_PADS_are_LOCKED;
342  }
343  */
344 
345  void SetLastEditTime( timestamp_t aTime ) { m_lastEditTime = aTime; }
347 
358  void CheckFootprintAttributes( const std::function<void( const wxString& msg )>* aErrorHandler );
359 
370  void CheckFootprintTHPadNoHoles( const std::function
371  <void( const wxString& msg, const wxPoint& position )>*
372  aErrorHandler );
373 
395  PCB_LAYER_ID aLayer, int aClearance,
396  int aMaxError, ERROR_LOC aErrorLoc,
397  bool aSkipNPTHPadsWihNoCopper = false,
398  bool aSkipPlatedPads = false,
399  bool aSkipNonPlatedPads = false ) const;
400 
416  PCB_LAYER_ID aLayer, int aClearance,
417  int aError, ERROR_LOC aErrorLoc,
418  bool aIncludeText = true,
419  bool aIncludeShapes = true ) const;
420 
426  PCB_LAYER_ID aLayer, int aClearance,
427  int aError, ERROR_LOC aErrorLoc ) const
428  {
429  TransformFPShapesWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance, aError,
430  aErrorLoc, true, false );
431  }
432 
436  void GetContextualTextVars( wxArrayString* aVars ) const;
437 
443  bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
444 
446  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
447 
448  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
449 
459  bool HitTestAccurate( const wxPoint& aPosition, int aAccuracy = 0 ) const;
460 
461  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
462 
466  const wxString& GetReference() const
467  {
468  return m_reference->GetText();
469  }
470 
475  void SetReference( const wxString& aReference )
476  {
477  m_reference->SetText( aReference );
478  }
479 
483  void IncrementReference( int aDelta );
484 
488  const wxString& GetValue() const
489  {
490  return m_value->GetText();
491  }
492 
496  void SetValue( const wxString& aValue )
497  {
498  m_value->SetText( aValue );
499  }
500 
502  FP_TEXT& Value() { return *m_value; }
503  FP_TEXT& Reference() { return *m_reference; }
504 
506  FP_TEXT& Value() const { return *m_value; }
507  FP_TEXT& Reference() const { return *m_reference; }
508 
509  const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
510  void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
511  const wxString& GetProperty( const wxString& aKey) { return m_properties[ aKey ]; }
512  bool HasProperty( const wxString& aKey)
513  {
514  return m_properties.find( aKey ) != m_properties.end();
515  }
516  void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
517 
527  PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
528 
536  PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask = LSET::AllLayersMask() );
537 
538  PAD* GetTopLeftPad();
539 
547  unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
548 
559  unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
560 
568  wxString GetNextPadNumber( const wxString& aLastPadName ) const;
569 
574  wxString GetTypeName() const;
575 
576  double GetArea( int aPadding = 0 ) const;
577 
578  KIID GetLink() const { return m_link; }
579  void SetLink( const KIID& aLink ) { m_link = aLink; }
580 
581  int GetPlacementCost180() const { return m_rot180Cost; }
582  void SetPlacementCost180( int aCost ) { m_rot180Cost = aCost; }
583 
584  int GetPlacementCost90() const { return m_rot90Cost; }
585  void SetPlacementCost90( int aCost ) { m_rot90Cost = aCost; }
586 
587  BOARD_ITEM* Duplicate() const override;
588 
594  BOARD_ITEM* DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootprint = false );
595 
601  void Add3DModel( FP_3DMODEL* a3DModel );
602 
603  SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
604 
605  wxString GetClass() const override
606  {
607  return wxT( "FOOTPRINT" );
608  }
609 
610  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
611 
612  BITMAPS GetMenuImage() const override;
613 
614  EDA_ITEM* Clone() const override;
615 
623  void RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction ) const;
624 
632  void GetAllDrawingLayers( int aLayers[], int& aCount, bool aIncludePads = true ) const;
633 
634  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
635 
636  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
637 
638  virtual const BOX2I ViewBBox() const override;
639 
647  static bool IsLibNameValid( const wxString& aName );
648 
658  static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
659 
674  void SetInitialComments( wxArrayString* aInitialComments )
675  {
676  delete m_initial_comments;
677  m_initial_comments = aInitialComments;
678  }
679 
686  double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
687 
688  static double GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLECTOR& aCollector );
689 
691  const wxArrayString* GetInitialComments() const { return m_initial_comments; }
692 
699  {
700  if( IsBackLayer( aLayer ) )
701  return m_poly_courtyard_back;
702  else
703  return m_poly_courtyard_front;
704  }
705 
712  void BuildPolyCourtyards( OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
713 
714  virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
715  FLASHING aFlash = FLASHING::DEFAULT ) const override;
716 
717  virtual void SwapData( BOARD_ITEM* aImage ) override;
718 
720  {
721  bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
722  };
723 
724  struct cmp_pads
725  {
726  bool operator()( const PAD* aFirst, const PAD* aSecond ) const;
727  };
728 
729 
730 #if defined(DEBUG)
731  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
732 #endif
733 
734 private:
735  DRAWINGS m_drawings; // BOARD_ITEMs for drawings on the board, owned by pointer.
736  PADS m_pads; // PAD items, owned by pointer
737  FP_ZONES m_fp_zones; // FP_ZONE items, owned by pointer
738  FP_GROUPS m_fp_groups; // PCB_GROUP items, owned by pointer
739 
740  double m_orient; // Orientation in tenths of a degree, 900=90.0 degrees.
741  wxPoint m_pos; // Position of footprint on the board in internal units.
742  FP_TEXT* m_reference; // Component reference designator value (U34, R18..)
743  FP_TEXT* m_value; // Component value (74LS00, 22K..)
744  LIB_ID m_fpid; // The #LIB_ID of the FOOTPRINT.
745  int m_attributes; // Flag bits ( see FOOTPRINT_ATTR_T )
746  int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
747 
748  // Bounding box caching strategy:
749  // While we attempt to notice the low-hanging fruit operations and update the bounding boxes
750  // accordingly, we rely mostly on a "if anything changed then the caches are stale" approach.
751  // We implement this by having PCB_BASE_FRAME's OnModify() method increment an operation
752  // counter, and storing that as a timestamp for the various caches.
753  // This means caches will get regenerated often -- but still far less often than if we had no
754  // caches at all. The principal opitmization would be to change to dirty flag and make sure
755  // that any edit that could affect the bounding boxes (including edits to the footprint
756  // children) marked the bounding boxes dirty. It would definitely be faster -- but also more
757  // fragile.
765  mutable int m_hullCacheTimeStamp;
766 
771  int m_localSolderMaskMargin; // Solder mask margin
772  int m_localSolderPasteMargin; // Solder paste margin absolute value
773  double m_localSolderPasteMarginRatio; // Solder mask margin ratio value of pad size
774 
775  wxString m_doc; // File name and path for documentation file.
776  wxString m_keywords; // Search keywords to find footprint in library.
777  KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
779  int m_arflag; // Use to trace ratsnest and auto routing.
780  KIID m_link; // Temporary logical link used during editing
781  int m_rot90Cost; // Horizontal automatic placement cost ( 0..10 ).
782  int m_rot180Cost; // Vertical automatic placement cost ( 0..10 ).
783 
784  std::list<FP_3DMODEL> m_3D_Drawings; // Linked list of 3D models.
785  std::map<wxString, wxString> m_properties;
786  wxArrayString* m_initial_comments; // s-expression comments in the footprint,
787  // lazily allocated only if needed for speed
788 
789  SHAPE_POLY_SET m_poly_courtyard_front; // Note that a footprint can have both front and back
790  SHAPE_POLY_SET m_poly_courtyard_back; // courtyards populated.
791 };
792 
793 #endif // FOOTPRINT_H
void SetReference(const wxString &aReference)
Definition: footprint.h:475
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:772
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:297
bool NeedsPlaced() const
Definition: footprint.h:324
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:1398
const wxString & GetDescription() const
Definition: footprint.h:201
void SetInitialComments(wxArrayString *aInitialComments)
Take ownership of caller's heap allocated aInitialComments block.
Definition: footprint.h:674
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:760
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:1276
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:325
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:993
const wxString & GetValue() const
Definition: footprint.h:488
FP_TEXT & Value() const
The const versions to keep the compiler happy.
Definition: footprint.h:506
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:243
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: footprint.h:230
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1130
const KIID_PATH & GetPath() const
Definition: footprint.h:207
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:767
double m_localSolderPasteMarginRatio
Definition: footprint.h:773
SHAPE_POLY_SET m_poly_courtyard_back
Definition: footprint.h:790
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:581
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:208
#define FP_PADS_are_LOCKED
Definition: footprint.h:294
void SetIsPlaced(bool isPlaced)
Definition: footprint.h:316
double m_orient
Definition: footprint.h:740
const wxString GetFPIDAsString() const
Definition: footprint.h:198
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:778
void IncrementFlag()
Definition: footprint.h:243
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:425
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:333
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: footprint.h:228
void SetOrientationDegrees(double aOrientation)
Definition: footprint.h:190
FP_TEXT * m_reference
Definition: footprint.h:742
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:761
INCLUDE_NPTH_T
Definition: footprint.h:55
void SetThermalGap(int aGap)
Definition: footprint.h:236
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:1287
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:346
bool operator()(const PAD *aFirst, const PAD *aSecond) const
Definition: footprint.cpp:2196
void SetAttributes(int aAttributes)
Definition: footprint.h:240
int m_rot90Cost
Definition: footprint.h:781
PADS & Pads()
Definition: footprint.h:169
void SetPlacementCost180(int aCost)
Definition: footprint.h:582
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:1180
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:502
FP_TEXT * m_value
Definition: footprint.h:743
PAD * GetTopLeftPad()
Definition: footprint.cpp:1111
void SetThermalWidth(int aWidth)
Definition: footprint.h:233
void SetDescription(const wxString &aDoc)
Definition: footprint.h:202
int m_arflag
Definition: footprint.h:779
KIID m_link
Definition: footprint.h:780
FP_TEXT & Reference()
Definition: footprint.h:503
const FP_ZONES & Zones() const
Definition: footprint.h:176
int m_localSolderMaskMargin
Definition: footprint.h:771
virtual 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:2016
EDA_RECT m_cachedBoundingBox
Definition: footprint.h:758
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:746
int GetFlag() const
Definition: footprint.h:244
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: footprint.cpp:1415
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
FP_ZONES m_fp_zones
Definition: footprint.h:737
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:907
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:1352
SHAPE_POLY_SET m_poly_courtyard_front
Definition: footprint.h:789
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:764
PAD * GetPad(const wxPoint &aPosition, LSET aLayerMask=LSET::AllLayersMask())
Get a pad at aPosition on aLayerMask in the footprint.
Definition: footprint.cpp:1095
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: footprint.cpp:1459
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1681
const DRAWINGS & GraphicalItems() const
Definition: footprint.h:173
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1491
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:1075
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:1191
int m_thermalGap
Definition: footprint.h:769
void SetLocalClearance(int aClearance)
Definition: footprint.h:214
int GetLocalClearance() const
Definition: footprint.h:213
bool IsNetTie() const
Definition: footprint.h:247
const PADS & Pads() const
Definition: footprint.h:170
const wxString & GetReference() const
Definition: footprint.h:466
#define _(s)
double m_Opacity
Definition: footprint.h:97
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1725
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:698
void MoveAnchorPosition(const wxPoint &aMoveVector)
Move the reference point of the footprint.
Definition: footprint.cpp:1608
static LSET AllLayersMask()
Definition: lset.cpp:796
bool IsPlaced() const
Definition: footprint.h:315
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:507
wxPoint m_pos
Definition: footprint.h:741
void SetValue(const wxString &aValue)
Definition: footprint.h:496
void SetFlag(int aFlag)
Definition: footprint.h:242
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: footprint.cpp:1466
const wxString & GetKeywords() const
Definition: footprint.h:204
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:234
UTF8 Format() const
Definition: lib_id.cpp:116
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:153
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:759
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition: footprint.h:293
KIID GetLink() const
Definition: footprint.h:578
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition: footprint.h:291
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KIID_PATH m_path
Definition: footprint.h:777
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:691
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:216
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:281
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:579
double GetOrientationDegrees() const
Definition: footprint.h:192
int m_thermalWidth
Definition: footprint.h:768
wxString m_keywords
Definition: footprint.h:776
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:49
int GetLocalSolderMaskMargin() const
Definition: footprint.h:210
FOOTPRINT(BOARD *parent)
Definition: footprint.cpp:51
int m_localClearance
Definition: footprint.h:770
void SetProperty(const wxString &aKey, const wxString &aVal)
Definition: footprint.h:516
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:95
int GetAttributes() const
Definition: footprint.h:239
int m_rot180Cost
Definition: footprint.h:782
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:763
wxString GetClass() const override
Return the class name.
Definition: footprint.h:605
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:2286
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:744
void SetLastEditTime(timestamp_t aTime)
Definition: footprint.h:345
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:205
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:307
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:1149
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:762
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:227
DRAWINGS m_drawings
Definition: footprint.h:735
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:509
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:1325
void SetFPIDAsString(const wxString &aFPID)
Definition: footprint.h:199
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:1299
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:231
int GetPlacementCost90() const
Definition: footprint.h:584
std::map< wxString, wxString > m_properties
Definition: footprint.h:785
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:1433
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:1016
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:224
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:510
wxArrayString * m_initial_comments
Definition: footprint.h:786
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:292
const wxString & GetProperty(const wxString &aKey)
Definition: footprint.h:511
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1562
SEARCH_RESULT
Definition: eda_item.h:41
FP_GROUPS m_fp_groups
Definition: footprint.h:738
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1293
bool HasProperty(const wxString &aKey)
Definition: footprint.h:512
bool HasThroughHolePads() const
Definition: footprint.cpp:2159
wxString m_doc
Definition: footprint.h:775
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
bool HitTestAccurate(const wxPoint &aPosition, int aAccuracy=0) const
Test if a point is inside the bounding polygon of the footprint.
Definition: footprint.cpp:1023
int GetThermalGap() const
Definition: footprint.h:237
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:784
PADS m_pads
Definition: footprint.h:736
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:1444
int m_hullCacheTimeStamp
Definition: footprint.h:765
void SetPlacementCost90(int aCost)
Definition: footprint.h:585
int m_attributes
Definition: footprint.h:745
void SetLocalSolderMaskMargin(int aMargin)
Definition: footprint.h:211
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
void SetLocalSolderPasteMargin(int aMargin)
Definition: footprint.h:225