KiCad PCB EDA Suite
FOOTPRINT Class Reference

#include <footprint.h>

Inheritance diagram for FOOTPRINT:
BOARD_ITEM_CONTAINER BOARD_ITEM EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE

Classes

struct  cmp_drawings
 
struct  cmp_pads
 
struct  cmp_zones
 

Public Member Functions

 FOOTPRINT (BOARD *parent)
 
 FOOTPRINT (const FOOTPRINT &aFootprint)
 
 FOOTPRINT (FOOTPRINT &&aFootprint)
 
 ~FOOTPRINT ()
 
FOOTPRINToperator= (const FOOTPRINT &aOther)
 
FOOTPRINToperator= (FOOTPRINT &&aOther)
 
LSET GetPrivateLayers () const
 
void SetPrivateLayers (LSET aLayers)
 Adds an item to the container. More...
 
void Add (BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
 Removes an item from the container. More...
 
void Remove (BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
 Removes an item from the container. More...
 
void ClearAllNets ()
 Clear (i.e. More...
 
bool FixUuids ()
 Old footprints do not always have a valid UUID (some can be set to null uuid) However null UUIDs, having a special meaning in editor, create issues when editing a footprint So all null uuids a re replaced by a valid uuid. More...
 
BOX2I GetFpPadsLocalBbox () const
 Return the bounding box containing pads when the footprint is on the front side, orientation 0, position 0,0. More...
 
SHAPE_POLY_SET GetBoundingHull () const
 Return a bounding polygon for the shapes and pads in the footprint. More...
 
const BOX2I GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
const BOX2I GetBoundingBox (bool aIncludeText, bool aIncludeInvisibleText) const
 
PADS & Pads ()
 
const PADS & Pads () const
 
DRAWINGS & GraphicalItems ()
 
const DRAWINGS & GraphicalItems () const
 
FP_ZONES & Zones ()
 
const FP_ZONES & Zones () const
 
FP_GROUPS & Groups ()
 
const FP_GROUPS & Groups () const
 
bool HasThroughHolePads () const
 
std::vector< FP_3DMODEL > & Models ()
 
const std::vector< FP_3DMODEL > & Models () const
 
void SetPosition (const VECTOR2I &aPos) override
 
VECTOR2I GetPosition () const override
 
void SetOrientation (const EDA_ANGLE &aNewAngle)
 
EDA_ANGLE GetOrientation () const
 
void SetLayerAndFlip (PCB_LAYER_ID aLayer)
 Used as Layer property setter – performs a flip if necessary to set the footprint layer. More...
 
PCB_LAYER_ID GetLayer () const override
 Return the primary layer this item is on. More...
 
void SetOrientationDegrees (double aOrientation)
 
double GetOrientationDegrees () const
 
const LIB_IDGetFPID () const
 
void SetFPID (const LIB_ID &aFPID)
 
wxString GetFPIDAsString () const
 
void SetFPIDAsString (const wxString &aFPID)
 
wxString GetDescription () const
 
void SetDescription (const wxString &aDoc)
 
wxString GetKeywords () const
 
void SetKeywords (const wxString &aKeywords)
 
const KIID_PATHGetPath () const
 
void SetPath (const KIID_PATH &aPath)
 
int GetLocalSolderMaskMargin () const
 
void SetLocalSolderMaskMargin (int aMargin)
 
int GetLocalClearance () const
 
void SetLocalClearance (int aClearance)
 
int GetLocalClearance (wxString *aSource) const
 
int GetLocalSolderPasteMargin () const
 
void SetLocalSolderPasteMargin (int aMargin)
 
double GetLocalSolderPasteMarginRatio () const
 
void SetLocalSolderPasteMarginRatio (double aRatio)
 
void SetZoneConnection (ZONE_CONNECTION aType)
 
ZONE_CONNECTION GetZoneConnection () const
 
int GetAttributes () const
 
void SetAttributes (int aAttributes)
 
void SetFlag (int aFlag)
 
void IncrementFlag ()
 
int GetFlag () const
 
bool IsNetTie () const
 
const std::vector< wxString > & GetNetTiePadGroups () const
 
void ClearNetTiePadGroups ()
 
void AddNetTiePadGroup (const wxString &aGroup)
 
std::map< wxString, int > MapPadNumbersToNetTieGroups () const
 
std::vector< PAD * > GetNetTiePads (PAD *aPad) const
 
int GetLikelyAttribute () const
 Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0) More...
 
void Move (const VECTOR2I &aMoveVector) override
 Move this object. More...
 
void Rotate (const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
 Rotate this object. More...
 
void Flip (const VECTOR2I &aCentre, bool aFlipLeftRight) override
 Flip this object, i.e. More...
 
void MoveAnchorPosition (const VECTOR2I &aMoveVector)
 Move the reference point of the footprint. More...
 
bool IsFlipped () const
 
bool IsOnLayer (PCB_LAYER_ID aLayer) const override
 A special IsOnLayer for footprints: return true if the footprint contains only items on the given layer, even if that layer is not one of the valid footprint layers F_Cu and B_Cu. More...
 
bool IsLocked () const override
 
void SetLocked (bool isLocked) override
 Set the #MODULE_is_LOCKED bit in the m_ModuleStatus. More...
 
bool IsConflicting () const
 
bool IsPlaced () const
 
void SetIsPlaced (bool isPlaced)
 
bool NeedsPlaced () const
 
void SetNeedsPlaced (bool needsPlaced)
 
bool LegacyPadsLocked () const
 
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 pads in the footprint. More...
 
void CheckPads (const std::function< void(const PAD *, int, const wxString &)> &aErrorHandler)
 Run non-board-specific DRC checks on footprint's pads. More...
 
void CheckShortingPads (const std::function< void(const PAD *, const PAD *, const VECTOR2I &)> &aErrorHandler)
 Check for overlapping, different-numbered, non-net-tie pads. More...
 
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. More...
 
void CheckNetTiePadGroups (const std::function< void(const wxString &)> &aErrorHandler)
 Sanity check net-tie pad groups. More...
 
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. More...
 
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 aBuffer. More...
 
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. More...
 
void GetContextualTextVars (wxArrayString *aVars) const
 Return the list of system text vars for this footprint. More...
 
bool ResolveTextVar (wxString *token, int aDepth=0) const
 Resolve any references to system tokens supported by the component. More...
 
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. More...
 
bool HitTest (const VECTOR2I &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTestAccurate (const VECTOR2I &aPosition, int aAccuracy=0) const
 Test if a point is inside the bounding polygon of the footprint. More...
 
bool HitTest (const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects this item. More...
 
const wxString & GetReference () const
 
void SetReference (const wxString &aReference)
 
wxString GetReferenceAsString () const
 
void IncrementReference (int aDelta)
 Bump the current reference by aDelta. More...
 
const wxString & GetValue () const
 
void SetValue (const wxString &aValue)
 
wxString GetValueAsString () const
 
FP_TEXTValue ()
 read/write accessors: More...
 
FP_TEXTReference ()
 
FP_TEXTValue () const
 The const versions to keep the compiler happy. More...
 
FP_TEXTReference () const
 
const std::map< wxString, wxString > & GetProperties () const
 
void SetProperties (const std::map< wxString, wxString > &aProps)
 
const wxString & GetProperty (const wxString &aKey)
 
bool HasProperty (const wxString &aKey)
 
void SetProperty (const wxString &aKey, const wxString &aVal)
 
bool IsBoardOnly () const
 
void SetBoardOnly (bool aIsBoardOnly=true)
 
bool IsExcludedFromPosFiles () const
 
void SetExcludedFromPosFiles (bool aExclude=true)
 
bool IsExcludedFromBOM () const
 
void SetExcludedFromBOM (bool aExclude=true)
 
bool AllowMissingCourtyard () const
 
void SetAllowMissingCourtyard (bool aAllow=true)
 
void SetFileFormatVersionAtLoad (int aVersion)
 
int GetFileFormatVersionAtLoad () const
 
PADFindPadByNumber (const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
 Return a PAD with a matching number. More...
 
PADGetPad (const VECTOR2I &aPosition, LSET aLayerMask=LSET::AllLayersMask())
 Get a pad at aPosition on aLayerMask in the footprint. More...
 
unsigned GetPadCount (INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
 Return the number of pads. More...
 
unsigned GetUniquePadCount (INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
 Return the number of unique non-blank pads. More...
 
wxString GetNextPadNumber (const wxString &aLastPadName) const
 Return the next available pad number in the footprint. More...
 
wxString GetTypeName () const
 Get the type of footprint. More...
 
double GetArea (int aPadding=0) const
 
KIID GetLink () const
 
void SetLink (const KIID &aLink)
 
BOARD_ITEMDuplicate () const override
 Create a copy of this BOARD_ITEM. More...
 
BOARD_ITEMDuplicateItem (const BOARD_ITEM *aItem, bool aAddToFootprint=false)
 Duplicate a given item within the footprint, optionally adding it to the board. More...
 
void Add3DModel (FP_3DMODEL *a3DModel)
 Add a3DModel definition to the end of the 3D model list. More...
 
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 data. More...
 
wxString GetClass () const override
 Return the class name. More...
 
wxString GetItemDescription (UNITS_PROVIDER *aUnitsProvider) const override
 Return a user-visible description string of this item. More...
 
BITMAPS GetMenuImage () const override
 Return a pointer to an image to be used in menus. More...
 
EDA_ITEMClone () const override
 Create a duplicate of this item with linked list members set to NULL. More...
 
void RunOnChildren (const std::function< void(BOARD_ITEM *)> &aFunction) const
 Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings, texts). More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the all the layers within the VIEW the object is painted on. More...
 
double ViewGetLOD (int aLayer, KIGFX::VIEW *aView) const override
 Return the level of detail (LOD) of the item. More...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
bool FootprintNeedsUpdate (const FOOTPRINT *aLibFootprint)
 Return true if a board footprint differs from the library version. More...
 
void SetInitialComments (wxArrayString *aInitialComments)
 Take ownership of caller's heap allocated aInitialComments block. More...
 
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 footprint. More...
 
const wxArrayString * GetInitialComments () const
 
const SHAPE_POLY_SETGetCourtyard (PCB_LAYER_ID aLayer) const
 Used in DRC to test the courtyard area (a complex polygon). More...
 
void BuildCourtyardCaches (OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
 Build complex polygons of the courtyard areas from graphic items on the courtyard layers. More...
 
std::shared_ptr< SHAPEGetEffectiveShape (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. More...
 
virtual void Delete (BOARD_ITEM *aItem)
 Removes an item from the container and deletes it. More...
 
virtual const ZONE_SETTINGSGetZoneSettings () const
 Fetch the zone settings for this container. More...
 
virtual void SetZoneSettings (const ZONE_SETTINGS &aSettings)
 Set the zone settings for this container. More...
 
void SetParentGroup (PCB_GROUP *aGroup)
 
PCB_GROUPGetParentGroup () const
 
int GetX () const
 
int GetY () const
 
virtual VECTOR2I GetCenter () const
 This defaults to the center of the bounding box if not overridden. More...
 
void SetX (int aX)
 
void SetY (int aY)
 
virtual bool IsConnected () const
 Returns information if the object is derived from BOARD_CONNECTED_ITEM. More...
 
virtual bool IsOnCopperLayer () const
 
virtual bool HasHole () const
 
virtual bool IsTented () const
 
virtual std::shared_ptr< SHAPE_SEGMENTGetEffectiveHoleShape () const
 
BOARD_ITEM_CONTAINERGetParent () const
 
BOARD_ITEM_CONTAINERGetParentFootprint () const
 
virtual bool HasLineStroke () const
 Check if this item has line stoke properties. More...
 
virtual STROKE_PARAMS GetStroke () const
 
virtual void SetStroke (const STROKE_PARAMS &aStroke)
 
virtual LSET GetLayerSet () const
 Return a std::bitset of all layers on which the item physically resides. More...
 
virtual void SetLayerSet (LSET aLayers)
 
virtual void SetLayer (PCB_LAYER_ID aLayer)
 Set the layer this item is on. More...
 
void SwapItemData (BOARD_ITEM *aImage)
 Swap data between aItem and aImage. More...
 
virtual bool IsKnockout () const
 
virtual void SetIsKnockout (bool aKnockout)
 
void DeleteStructure ()
 Delete this object after removing from its parent if it has one. More...
 
virtual const BOARDGetBoard () const
 Return the BOARD in which this BOARD_ITEM resides, or NULL if none. More...
 
virtual BOARDGetBoard ()
 
wxString GetLayerName () const
 Return the name of the PCB layer on which the item resides. More...
 
virtual void TransformShapeToPolygon (SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
 Convert the item shape to a closed polygon. More...
 
KICAD_T Type () const
 Returns the type of object. More...
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsBrightened () const
 
bool IsRollover () const
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (EDA_ITEM_FLAGS type) const
 
void SetState (EDA_ITEM_FLAGS type, bool state)
 
EDA_ITEM_FLAGS GetStatus () const
 
void SetStatus (EDA_ITEM_FLAGS aStatus)
 
void SetFlags (EDA_ITEM_FLAGS aMask)
 
void XorFlags (EDA_ITEM_FLAGS aMask)
 
void ClearFlags (EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
EDA_ITEM_FLAGS GetFlags () const
 
bool HasFlag (EDA_ITEM_FLAGS aFlag) const
 
EDA_ITEM_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
virtual bool RenderAsBitmap (double aWorldScale) const
 
void SetIsShownAsBitmap (bool aBitmap)
 
bool IsShownAsBitmap () const
 
virtual bool IsType (const std::vector< KICAD_T > &aScanTypes) const
 Check whether the item is one of the listed types. More...
 
void SetForceVisible (bool aEnable)
 Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual wxString GetFriendlyName () const
 
virtual const VECTOR2I GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual VECTOR2I GetSortPosition () const
 Return the coordinates that should be used for sorting this element visually compared to other elements. More...
 
wxString GetTypeDesc () const
 Return a translated description of the type for this EDA_ITEM for display in user facing messages. More...
 
virtual bool Matches (const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
 Compare the item against the search criteria in aSearchData. More...
 
virtual bool Replace (const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr)
 Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Override this method in any derived object that supports test find and replace. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Draw the parts of the object belonging to layer aLayer. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
std::optional< T > Get (const wxString &aProperty) const
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
static bool IsLibNameValid (const wxString &aName)
 Test for validity of a name of a footprint to be used in a footprint library ( no spaces, dir separators ... ). More...
 
static const wxChar * StringLibNameInvalidChars (bool aUserReadable)
 Test for validity of the name in a library of the footprint ( no spaces, dir separators ... ). More...
 
static double GetCoverageArea (const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
 Return the initial comments block or NULL if none, without transfer of ownership. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const EDA_SEARCH_DATA &aSearchData, wxString &aText)
 Perform a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 

Public Attributes

const KIID m_Uuid
 

Static Public Attributes

static VECTOR2I ZeroOffset
 A value of wxPoint(0,0) which can be passed to the Draw() functions. More...
 

Protected Member Functions

virtual void swapData (BOARD_ITEM *aImage) override
 
virtual wxString layerMaskDescribe () const
 Return a string (to be shown to the user) describing a layer mask. More...
 
bool Matches (const wxString &aText, const EDA_SEARCH_DATA &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 

Protected Attributes

PCB_LAYER_ID m_layer
 
bool m_isKnockout
 
bool m_isLocked
 
PCB_GROUPm_group
 
EDA_ITEM_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
EDA_ITEM_FLAGS m_flags
 

Private Attributes

DRAWINGS m_drawings
 
PADS m_pads
 
FP_ZONES m_fp_zones
 
FP_GROUPS m_fp_groups
 
EDA_ANGLE m_orient
 
VECTOR2I m_pos
 
FP_TEXTm_reference
 
FP_TEXTm_value
 
LIB_ID m_fpid
 
int m_attributes
 
int m_fpStatus
 
int m_fileFormatVersionAtLoad
 
BOX2I m_cachedBoundingBox
 
int m_boundingBoxCacheTimeStamp
 
BOX2I m_cachedVisibleBBox
 
int m_visibleBBoxCacheTimeStamp
 
BOX2I m_cachedTextExcludedBBox
 
int m_textExcludedBBoxCacheTimeStamp
 
SHAPE_POLY_SET m_cachedHull
 
int m_hullCacheTimeStamp
 
std::vector< wxString > m_netTiePadGroups
 
ZONE_CONNECTION m_zoneConnection
 
int m_localClearance
 
int m_localSolderMaskMargin
 
int m_localSolderPasteMargin
 
double m_localSolderPasteMarginRatio
 
wxString m_doc
 
wxString m_keywords
 
KIID_PATH m_path
 
timestamp_t m_lastEditTime
 
int m_arflag
 
KIID m_link
 
LSET m_privateLayers
 
std::vector< FP_3DMODELm_3D_Drawings
 
std::map< wxString, wxString > m_properties
 
wxArrayString * m_initial_comments
 
SHAPE_POLY_SET m_courtyard_cache_front
 
SHAPE_POLY_SET m_courtyard_cache_back
 
int m_courtyard_cache_timestamp
 
ZONE_SETTINGS m_zoneSettings
 
KICAD_T m_structType
 Run time identification, keep private so it can never be changed after a ctor sets it. More...
 
VIEW_ITEM_DATA * m_viewPrivData
 

Detailed Description

Definition at line 100 of file footprint.h.

Constructor & Destructor Documentation

◆ FOOTPRINT() [1/3]

FOOTPRINT::FOOTPRINT ( BOARD parent)

Definition at line 55 of file footprint.cpp.

55 :
61 m_initial_comments( nullptr ),
63{
64 m_attributes = 0;
65 m_layer = F_Cu;
68 m_arflag = 0;
69 m_link = 0;
77
78 // These are special and mandatory text fields
81
82 m_3D_Drawings.clear();
83}
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
PCB_LAYER_ID m_layer
Definition: board_item.h:329
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:865
int m_fpStatus
Definition: footprint.h:839
int m_localSolderPasteMargin
Definition: footprint.h:868
int m_attributes
Definition: footprint.h:838
std::vector< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:879
double m_localSolderPasteMarginRatio
Definition: footprint.h:869
wxArrayString * m_initial_comments
Definition: footprint.h:881
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:855
int m_localClearance
Definition: footprint.h:866
int m_arflag
Definition: footprint.h:875
int m_localSolderMaskMargin
Definition: footprint.h:867
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:857
int m_hullCacheTimeStamp
Definition: footprint.h:859
EDA_ANGLE m_orient
Definition: footprint.h:833
KIID m_link
Definition: footprint.h:876
FP_TEXT * m_value
Definition: footprint.h:836
timestamp_t m_lastEditTime
Definition: footprint.h:874
int m_fileFormatVersionAtLoad
Definition: footprint.h:840
int m_courtyard_cache_timestamp
Definition: footprint.h:886
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:853
FP_TEXT * m_reference
Definition: footprint.h:835
@ TEXT_is_REFERENCE
Definition: fp_text.h:49
@ TEXT_is_VALUE
Definition: fp_text.h:50
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
#define FP_PADS_are_LOCKED
Definition: footprint.h:337
@ F_Cu
Definition: layer_ids.h:64
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86

References ANGLE_0, F_Cu, FP_PADS_are_LOCKED, INHERITED, m_3D_Drawings, m_arflag, m_attributes, m_fileFormatVersionAtLoad, m_fpStatus, m_lastEditTime, BOARD_ITEM::m_layer, m_link, m_localClearance, m_localSolderMaskMargin, m_localSolderPasteMargin, m_localSolderPasteMarginRatio, m_orient, m_reference, m_value, m_zoneConnection, FP_TEXT::TEXT_is_REFERENCE, and FP_TEXT::TEXT_is_VALUE.

Referenced by Clone().

◆ FOOTPRINT() [2/3]

FOOTPRINT::FOOTPRINT ( const FOOTPRINT aFootprint)

Definition at line 86 of file footprint.cpp.

86 :
87 BOARD_ITEM_CONTAINER( aFootprint )
88{
89 m_pos = aFootprint.m_pos;
90 m_fpid = aFootprint.m_fpid;
91 m_attributes = aFootprint.m_attributes;
92 m_fpStatus = aFootprint.m_fpStatus;
93 m_orient = aFootprint.m_orient;
94 m_lastEditTime = aFootprint.m_lastEditTime;
95 m_link = aFootprint.m_link;
96 m_path = aFootprint.m_path;
97
104 m_cachedHull = aFootprint.m_cachedHull;
106
114
115 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
116
117 // Copy reference and value.
118 m_reference = new FP_TEXT( *aFootprint.m_reference );
119 m_reference->SetParent( this );
120 ptrMap[ aFootprint.m_reference ] = m_reference;
121
122 m_value = new FP_TEXT( *aFootprint.m_value );
123 m_value->SetParent( this );
124 ptrMap[ aFootprint.m_value ] = m_value;
125
126 // Copy pads
127 for( PAD* pad : aFootprint.Pads() )
128 {
129 PAD* newPad = static_cast<PAD*>( pad->Clone() );
130 ptrMap[ pad ] = newPad;
131 Add( newPad, ADD_MODE::APPEND ); // Append to ensure indexes are identical
132 }
133
134 // Copy zones
135 for( FP_ZONE* zone : aFootprint.Zones() )
136 {
137 FP_ZONE* newZone = static_cast<FP_ZONE*>( zone->Clone() );
138 ptrMap[ zone ] = newZone;
139 Add( newZone, ADD_MODE::APPEND ); // Append to ensure indexes are identical
140
141 // Ensure the net info is OK and especially uses the net info list
142 // living in the current board
143 // Needed when copying a fp from fp editor that has its own board
144 // Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
145 newZone->SetNetCode( -1 );
146 }
147
148 // Copy drawings
149 for( BOARD_ITEM* item : aFootprint.GraphicalItems() )
150 {
151 BOARD_ITEM* newItem = static_cast<BOARD_ITEM*>( item->Clone() );
152 ptrMap[ item ] = newItem;
153 Add( newItem, ADD_MODE::APPEND ); // Append to ensure indexes are identical
154 }
155
156 // Copy groups
157 for( PCB_GROUP* group : aFootprint.Groups() )
158 {
159 PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( group->Clone() );
160 ptrMap[ group ] = newGroup;
161 Add( newGroup, ADD_MODE::APPEND ); // Append to ensure indexes are identical
162 }
163
164 // Rebuild groups
165 for( PCB_GROUP* group : aFootprint.Groups() )
166 {
167 PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( ptrMap[ group ] );
168
169 newGroup->GetItems().clear();
170
171 for( BOARD_ITEM* member : group->GetItems() )
172 {
173 if( ptrMap.count( member ) )
174 newGroup->AddItem( ptrMap[ member ] );
175 }
176 }
177
178 // Copy auxiliary data
179 m_3D_Drawings = aFootprint.m_3D_Drawings;
180 m_doc = aFootprint.m_doc;
181 m_keywords = aFootprint.m_keywords;
182 m_properties = aFootprint.m_properties;
183 m_privateLayers = aFootprint.m_privateLayers;
184
185 m_arflag = 0;
186
188 new wxArrayString( *aFootprint.m_initial_comments ) : nullptr;
189}
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
LIB_ID m_fpid
Definition: footprint.h:837
KIID_PATH m_path
Definition: footprint.h:873
BOX2I m_cachedTextExcludedBBox
Definition: footprint.h:856
BOX2I m_cachedBoundingBox
Definition: footprint.h:852
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:858
BOX2I m_cachedVisibleBBox
Definition: footprint.h:854
std::map< wxString, wxString > m_properties
Definition: footprint.h:880
FP_GROUPS & Groups()
Definition: footprint.h:179
PADS & Pads()
Definition: footprint.h:170
LSET m_privateLayers
Definition: footprint.h:877
VECTOR2I m_pos
Definition: footprint.h:834
std::vector< wxString > m_netTiePadGroups
Definition: footprint.h:863
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:567
wxString m_keywords
Definition: footprint.h:872
wxString m_doc
Definition: footprint.h:871
FP_ZONES & Zones()
Definition: footprint.h:176
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
A specialization of ZONE for use in footprints.
Definition: zone.h:910
Definition: pad.h:59
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80

References Add(), PCB_GROUP::AddItem(), APPEND, PCB_GROUP::GetItems(), GraphicalItems(), group, Groups(), m_3D_Drawings, m_arflag, m_attributes, m_boundingBoxCacheTimeStamp, m_cachedBoundingBox, m_cachedHull, m_cachedTextExcludedBBox, m_cachedVisibleBBox, m_doc, m_fileFormatVersionAtLoad, m_fpid, m_fpStatus, m_hullCacheTimeStamp, m_initial_comments, m_keywords, m_lastEditTime, m_link, m_localClearance, m_localSolderMaskMargin, m_localSolderPasteMargin, m_localSolderPasteMarginRatio, m_netTiePadGroups, m_orient, m_path, m_pos, m_privateLayers, m_properties, m_reference, m_textExcludedBBoxCacheTimeStamp, m_value, m_visibleBBoxCacheTimeStamp, m_zoneConnection, pad, Pads(), BOARD_CONNECTED_ITEM::SetNetCode(), EDA_ITEM::SetParent(), and Zones().

◆ FOOTPRINT() [3/3]

FOOTPRINT::FOOTPRINT ( FOOTPRINT &&  aFootprint)

Definition at line 192 of file footprint.cpp.

192 :
193 BOARD_ITEM_CONTAINER( aFootprint )
194{
195 *this = std::move( aFootprint );
196}

◆ ~FOOTPRINT()

FOOTPRINT::~FOOTPRINT ( )

Definition at line 199 of file footprint.cpp.

200{
201 // Untangle group parents before doing any deleting
202 for( PCB_GROUP* group : m_fp_groups )
203 {
204 for( BOARD_ITEM* item : group->GetItems() )
205 item->SetParentGroup( nullptr );
206 }
207
208 // Clean up the owned elements
209 delete m_reference;
210 delete m_value;
211 delete m_initial_comments;
212
213 for( PAD* p : m_pads )
214 delete p;
215
216 m_pads.clear();
217
218 for( FP_ZONE* zone : m_fp_zones )
219 delete zone;
220
221 m_fp_zones.clear();
222
223 for( PCB_GROUP* group : m_fp_groups )
224 delete group;
225
226 m_fp_groups.clear();
227
228 for( BOARD_ITEM* d : m_drawings )
229 delete d;
230
231 m_drawings.clear();
232
233 if( BOARD* board = GetBoard() )
234 board->IncrementTimeStamp();
235}
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
FP_ZONES m_fp_zones
Definition: footprint.h:830
DRAWINGS m_drawings
Definition: footprint.h:828
PADS m_pads
Definition: footprint.h:829
FP_GROUPS m_fp_groups
Definition: footprint.h:831

References BOARD_ITEM::GetBoard(), group, m_drawings, m_fp_groups, m_fp_zones, m_initial_comments, m_pads, m_reference, and m_value.

Member Function Documentation

◆ Add()

void FOOTPRINT::Add ( BOARD_ITEM aItem,
ADD_MODE  aMode = ADD_MODE::INSERT,
bool  aSkipConnectivity = false 
)
overridevirtual

Removes an item from the container.

Implements BOARD_ITEM_CONTAINER.

Definition at line 567 of file footprint.cpp.

568{
569 switch( aBoardItem->Type() )
570 {
571 case PCB_FP_TEXT_T:
572 // Only user text can be added this way.
573 wxASSERT( static_cast<FP_TEXT*>( aBoardItem )->GetType() == FP_TEXT::TEXT_is_DIVERS );
575
581 case PCB_FP_SHAPE_T:
582 case PCB_FP_TEXTBOX_T:
583 case PCB_BITMAP_T:
584 if( aMode == ADD_MODE::APPEND )
585 m_drawings.push_back( aBoardItem );
586 else
587 m_drawings.push_front( aBoardItem );
588 break;
589
590 case PCB_PAD_T:
591 if( aMode == ADD_MODE::APPEND )
592 m_pads.push_back( static_cast<PAD*>( aBoardItem ) );
593 else
594 m_pads.push_front( static_cast<PAD*>( aBoardItem ) );
595 break;
596
597 case PCB_FP_ZONE_T:
598 if( aMode == ADD_MODE::APPEND )
599 m_fp_zones.push_back( static_cast<FP_ZONE*>( aBoardItem ) );
600 else
601 m_fp_zones.insert( m_fp_zones.begin(), static_cast<FP_ZONE*>( aBoardItem ) );
602 break;
603
604 case PCB_GROUP_T:
605 if( aMode == ADD_MODE::APPEND )
606 m_fp_groups.push_back( static_cast<PCB_GROUP*>( aBoardItem ) );
607 else
608 m_fp_groups.insert( m_fp_groups.begin(), static_cast<PCB_GROUP*>( aBoardItem ) );
609 break;
610
611 default:
612 {
613 wxString msg;
614 msg.Printf( wxT( "FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
615 aBoardItem->Type() );
616 wxFAIL_MSG( msg );
617
618 return;
619 }
620 }
621
622 aBoardItem->ClearEditFlags();
623 aBoardItem->SetParent( this );
624}
@ TEXT_is_DIVERS
Definition: fp_text.h:51
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

References APPEND, EDA_ITEM::ClearEditFlags(), KI_FALLTHROUGH, m_drawings, m_fp_groups, m_fp_zones, m_pads, PCB_BITMAP_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_PAD_T, EDA_ITEM::SetParent(), FP_TEXT::TEXT_is_DIVERS, and EDA_ITEM::Type().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PCAD2KICAD::PCB_ARC::AddToFootprint(), PCAD2KICAD::PCB_LINE::AddToFootprint(), PCAD2KICAD::PCB_POLYGON::AddToFootprint(), PCAD2KICAD::PCB_PAD::AddToFootprint(), ALTIUM_PCB::ConvertArcs6ToFootprintItem(), ALTIUM_PCB::ConvertArcs6ToFootprintItemOnLayer(), ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer(), ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper(), ALTIUM_PCB::ConvertPads6ToFootprintItemOnNonCopper(), ALTIUM_PCB::ConvertShapeBasedRegions6ToFootprintItem(), ALTIUM_PCB::ConvertShapeBasedRegions6ToFootprintItemOnLayer(), ALTIUM_PCB::ConvertTexts6ToFootprintItemOnLayer(), ALTIUM_PCB::ConvertTracks6ToFootprintItem(), ALTIUM_PCB::ConvertTracks6ToFootprintItemOnLayer(), MICROWAVE_TOOL::createBaseFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), MICROWAVE_TOOL::createPolygonShape(), KI_TEST::DrawArc(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), KI_TEST::DrawSegment(), DuplicateItem(), PCB_EDIT_FRAME::ExchangeFootprint(), FOOTPRINT(), PCB_BASE_FRAME::GetFootprintFromBoardByReference(), GROUP_TOOL::Group(), ALTIUM_PCB::HelperCreateAndAddShape(), ALTIUM_PCB::HelperPcpShapeAsFootprintKeepoutRegion(), LEGACY_PLUGIN::loadFOOTPRINT(), FABMASTER::loadFootprints(), LEGACY_PLUGIN::loadFP_SHAPE(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads(), LEGACY_PLUGIN::loadPAD(), operator=(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packageHole(), EAGLE_PLUGIN::packagePad(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageSMD(), EAGLE_PLUGIN::packageText(), EAGLE_PLUGIN::packageWire(), PCB_PARSER::resolveGroups(), CLIPBOARD_IO::SaveSelection(), FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow().

◆ Add3DModel()

void FOOTPRINT::Add3DModel ( FP_3DMODEL a3DModel)

Add a3DModel definition to the end of the 3D model list.

Parameters
a3DModelA pointer to a FP_3DMODEL to add to the list.

Definition at line 1260 of file footprint.cpp.

1261{
1262 if( nullptr == a3DModel )
1263 return;
1264
1265 if( !a3DModel->m_Filename.empty() )
1266 m_3D_Drawings.push_back( *a3DModel );
1267}
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:95

References m_3D_Drawings, and FP_3DMODEL::m_Filename.

◆ AddNetTiePadGroup()

void FOOTPRINT::AddNetTiePadGroup ( const wxString &  aGroup)
inline

Definition at line 279 of file footprint.h.

280 {
281 m_netTiePadGroups.emplace_back( aGroup );
282 }

References m_netTiePadGroups.

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow().

◆ AllowMissingCourtyard()

bool FOOTPRINT::AllowMissingCourtyard ( ) const
inline

Definition at line 610 of file footprint.h.

@ FP_ALLOW_MISSING_COURTYARD
Definition: footprint.h:75

References FP_ALLOW_MISSING_COURTYARD, and m_attributes.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ BuildCourtyardCaches()

void FOOTPRINT::BuildCourtyardCaches ( OUTLINE_ERROR_HANDLER aErrorHandler = nullptr)

Build complex polygons of the courtyard areas from graphic items on the courtyard layers.

Note
Set the MALFORMED_F_COURTYARD and MALFORMED_B_COURTYARD status flags if the given courtyard layer does not contain a (single) closed shape.

Definition at line 2227 of file footprint.cpp.

2228{
2232
2234
2235 // Build the courtyard area from graphic items on the courtyard.
2236 // Only PCB_FP_SHAPE_T have meaning, graphic texts are ignored.
2237 // Collect items:
2238 std::vector<PCB_SHAPE*> list_front;
2239 std::vector<PCB_SHAPE*> list_back;
2240
2241 for( BOARD_ITEM* item : GraphicalItems() )
2242 {
2243 if( item->GetLayer() == B_CrtYd && item->Type() == PCB_FP_SHAPE_T )
2244 list_back.push_back( static_cast<PCB_SHAPE*>( item ) );
2245
2246 if( item->GetLayer() == F_CrtYd && item->Type() == PCB_FP_SHAPE_T )
2247 list_front.push_back( static_cast<PCB_SHAPE*>( item ) );
2248 }
2249
2250 if( !list_front.size() && !list_back.size() )
2251 return;
2252
2253 int errorMax = pcbIUScale.mmToIU( 0.02 ); // max error for polygonization
2254 int chainingEpsilon = pcbIUScale.mmToIU( 0.02 ); // max dist from one endPt to next startPt
2255
2256 if( ConvertOutlineToPolygon( list_front, m_courtyard_cache_front, errorMax, chainingEpsilon,
2257 true, aErrorHandler ) )
2258 {
2259 // Touching courtyards, or courtyards -at- the clearance distance are legal.
2261
2263 }
2264 else
2265 {
2267 }
2268
2269 if( ConvertOutlineToPolygon( list_back, m_courtyard_cache_back, errorMax, chainingEpsilon,
2270 true, aErrorHandler ) )
2271 {
2272 // Touching courtyards, or courtyards -at- the clearance distance are legal.
2274
2276 }
2277 else
2278 {
2280 }
2281}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
int GetTimeStamp() const
Definition: board.h:288
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
SHAPE_POLY_SET m_courtyard_cache_back
Definition: footprint.h:885
SHAPE_POLY_SET m_courtyard_cache_front
Definition: footprint.h:884
@ CHAMFER_ACUTE_CORNERS
Acute angles are chamfered.
void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
bool ConvertOutlineToPolygon(std::vector< PCB_SHAPE * > &aShapeList, SHAPE_POLY_SET &aPolygons, int aErrorMax, int aChainingEpsilon, bool aAllowDisjoint, OUTLINE_ERROR_HANDLER *aErrorHandler)
Function ConvertOutlineToPolygon Build a polygon (with holes) from a PCB_SHAPE list,...
#define MALFORMED_F_COURTYARD
#define MALFORMED_B_COURTYARD
#define MALFORMED_COURTYARDS
@ F_CrtYd
Definition: layer_ids.h:117
@ B_CrtYd
Definition: layer_ids.h:116
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

References B_CrtYd, SHAPE_POLY_SET::CacheTriangulation(), SHAPE_POLY_SET::CHAMFER_ACUTE_CORNERS, EDA_ITEM::ClearFlags(), ConvertOutlineToPolygon(), F_CrtYd, BOARD_ITEM::GetBoard(), BOARD::GetTimeStamp(), GraphicalItems(), SHAPE_POLY_SET::Inflate(), m_courtyard_cache_back, m_courtyard_cache_front, m_courtyard_cache_timestamp, MALFORMED_B_COURTYARD, MALFORMED_COURTYARDS, MALFORMED_F_COURTYARD, EDA_IU_SCALE::mmToIU(), PCB_FP_SHAPE_T, pcbIUScale, SHAPE_POLY_SET::RemoveAllContours(), and EDA_ITEM::SetFlags().

Referenced by AR_AUTOPLACER::buildFpAreas(), GetCourtyard(), BOARD_INSPECTION_TOOL::makeDRCEngine(), and DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckFootprintAttributes()

void FOOTPRINT::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 pads in the footprint.

Footprints with plated through-hole pads should usually be marked through hole even if they also have SMD because they might not be auto-placed. Exceptions to this might be shielded connectors. Otherwise, footprints with SMD pads should be marked SMD. Footprints with no connecting pads should be marked "Other"

Parameters
aErrorHandlercallback to handle the error messages generated

Definition at line 2361 of file footprint.cpp.

2362{
2363 int likelyAttr = ( GetLikelyAttribute() & ( FP_SMD | FP_THROUGH_HOLE ) );
2364 int setAttr = ( GetAttributes() & ( FP_SMD | FP_THROUGH_HOLE ) );
2365
2366 if( setAttr && likelyAttr && setAttr != likelyAttr )
2367 {
2368 wxString msg;
2369
2370 switch( likelyAttr )
2371 {
2372 case FP_THROUGH_HOLE:
2373 msg.Printf( _( "(expected 'Through hole'; actual '%s')" ), GetTypeName() );
2374 break;
2375 case FP_SMD:
2376 msg.Printf( _( "(expected 'SMD'; actual '%s')" ), GetTypeName() );
2377 break;
2378 }
2379
2380 if( aErrorHandler )
2381 (aErrorHandler)( msg );
2382 }
2383}
int GetAttributes() const
Definition: footprint.h:250
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:769
int GetLikelyAttribute() const
Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)
Definition: footprint.cpp:719
#define _(s)
@ FP_SMD
Definition: footprint.h:69
@ FP_THROUGH_HOLE
Definition: footprint.h:68

References _, FP_SMD, FP_THROUGH_HOLE, GetAttributes(), GetLikelyAttribute(), and GetTypeName().

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckNetTiePadGroups()

void FOOTPRINT::CheckNetTiePadGroups ( const std::function< void(const wxString &)> &  aErrorHandler)

Sanity check net-tie pad groups.

Pads cannot be listed more than once, and pad numbers must correspond to a pad.

Parameters
aErrorHandlercallback to handle the error messages generated

Definition at line 2617 of file footprint.cpp.

2618{
2619 std::set<wxString> padNumbers;
2620 wxString msg;
2621
2622 auto ret = MapPadNumbersToNetTieGroups();
2623
2624 for( auto [ padNumber, _ ] : ret )
2625 {
2626 const PAD* pad = FindPadByNumber( padNumber );
2627
2628 if( !pad )
2629 {
2630 msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
2631 aErrorHandler( msg );
2632 }
2633 else if( !padNumbers.insert( pad->GetNumber() ).second )
2634 {
2635 msg.Printf( _( "(pad %s appears in more than one net-tie pad group)" ), padNumber );
2636 aErrorHandler( msg );
2637 }
2638 }
2639}
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
Definition: footprint.cpp:2284
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1174

References _, FindPadByNumber(), MapPadNumbersToNetTieGroups(), and pad.

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckNetTies()

void FOOTPRINT::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.

If two pads are shorted, they must both appear in one of the allowed-shorting lists.

Parameters
aErrorHandlercallback to handle the error messages generated

Definition at line 2511 of file footprint.cpp.

2515{
2516 // First build a map from pad numbers to allowed-shorting-group indexes. This ends up being
2517 // something like O(3n), but it still beats O(n^2) for large numbers of pads.
2518
2519 std::map<wxString, int> padNumberToGroupIdxMap = MapPadNumbersToNetTieGroups();
2520
2521 // Now collect all the footprint items which are on copper layers
2522
2523 std::vector<BOARD_ITEM*> copperItems;
2524
2525 for( BOARD_ITEM* item : m_drawings )
2526 {
2527 if( item->IsOnCopperLayer() )
2528 copperItems.push_back( item );
2529 }
2530
2531 for( ZONE* zone : m_fp_zones )
2532 {
2533 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
2534 copperItems.push_back( zone );
2535 }
2536
2538 copperItems.push_back( m_reference );
2539
2540 if( m_value->IsOnCopperLayer() )
2541 copperItems.push_back( m_value );
2542
2543 for( PCB_LAYER_ID layer : { F_Cu, In1_Cu, B_Cu } )
2544 {
2545 // Next, build a polygon-set for the copper on this layer. We don't really care about
2546 // nets here, we just want to end up with a set of outlines describing the distinct
2547 // copper polygons of the footprint.
2548
2549 SHAPE_POLY_SET copperOutlines;
2550 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
2551
2552 for( BOARD_ITEM* item : copperItems )
2553 {
2554 if( item->IsOnLayer( layer ) )
2555 {
2556 item->TransformShapeToPolygon( copperOutlines, layer, 0, ARC_HIGH_DEF,
2557 ERROR_OUTSIDE );
2558 }
2559 }
2560
2561 copperOutlines.Simplify( SHAPE_POLY_SET::PM_FAST );
2562
2563 // Index each pad to the outline in the set that it is part of.
2564
2565 for( const PAD* pad : m_pads )
2566 {
2567 for( int ii = 0; ii < copperOutlines.OutlineCount(); ++ii )
2568 {
2569 if( pad->GetEffectiveShape( layer )->Collide( &copperOutlines.Outline( ii ), 0 ) )
2570 outlineIdxToPadsMap[ ii ].emplace_back( pad );
2571 }
2572 }
2573
2574 // Finally, ensure that each outline which contains multiple pads has all its pads
2575 // listed in an allowed-shorting group.
2576
2577 for( const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
2578 {
2579 if( pads.size() > 1 )
2580 {
2581 const PAD* firstPad = pads[0];
2582 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->GetNumber() ];
2583
2584 for( size_t ii = 1; ii < pads.size(); ++ii )
2585 {
2586 const PAD* thisPad = pads[ii];
2587 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->GetNumber() ];
2588
2589 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
2590 {
2591 BOARD_ITEM* shortingItem = nullptr;
2592 VECTOR2I pos = ( firstPad->GetPosition() + thisPad->GetPosition() ) / 2;
2593
2594 pos = copperOutlines.Outline( outlineIdx ).NearestPoint( pos );
2595
2596 for( BOARD_ITEM* item : copperItems )
2597 {
2598 if( item->HitTest( pos, 1 ) )
2599 {
2600 shortingItem = item;
2601 break;
2602 }
2603 }
2604
2605 if( shortingItem )
2606 aErrorHandler( shortingItem, firstPad, thisPad, pos );
2607 else
2608 aErrorHandler( firstPad, thisPad, nullptr, pos );
2609 }
2610 }
2611 }
2612 }
2613 }
2614}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
virtual bool IsOnCopperLayer() const
Definition: board_item.h:123
const wxString & GetNumber() const
Definition: pad.h:135
VECTOR2I GetPosition() const override
Definition: pad.h:202
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
Represent a set of closed polygons.
void Simplify(POLYGON_MODE aFastMode)
SHAPE_LINE_CHAIN & Outline(int aIndex)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
@ ERROR_OUTSIDE
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ In1_Cu
Definition: layer_ids.h:65

References ARC_HIGH_DEF, B_Cu, ERROR_OUTSIDE, F_Cu, PAD::GetNumber(), PAD::GetPosition(), In1_Cu, BOARD_ITEM::IsOnCopperLayer(), m_drawings, m_fp_zones, m_pads, m_reference, m_value, MapPadNumbersToNetTieGroups(), SHAPE_LINE_CHAIN::NearestPoint(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), pad, SHAPE_POLY_SET::PM_FAST, and SHAPE_POLY_SET::Simplify().

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckPads()

void FOOTPRINT::CheckPads ( const std::function< void(const PAD *, int, const wxString &)> &  aErrorHandler)

Run non-board-specific DRC checks on footprint's pads.

These are the checks supported by both the PCB DRC and the Footprint Editor Footprint Checker.

Parameters
aErrorHandlercallback to handle the error messages generated

Definition at line 2386 of file footprint.cpp.

2388{
2389 if( aErrorHandler == nullptr )
2390 return;
2391
2392 for( PAD* pad: Pads() )
2393 {
2394 if( pad->GetAttribute() == PAD_ATTRIB::PTH || pad->GetAttribute() == PAD_ATTRIB::NPTH )
2395 {
2396 if( pad->GetDrillSizeX() < 1 || pad->GetDrillSizeY() < 1 )
2397 (aErrorHandler)( pad, DRCE_PAD_TH_WITH_NO_HOLE, wxEmptyString );
2398 }
2399
2400 if( pad->GetAttribute() == PAD_ATTRIB::PTH )
2401 {
2402 if( !pad->IsOnCopperLayer() )
2403 {
2404 (aErrorHandler)( pad, DRCE_PADSTACK, _( "(PTH pad has no copper layers)" ) );
2405 }
2406 else
2407 {
2408 LSET lset = pad->GetLayerSet() & LSET::AllCuMask();
2409 PCB_LAYER_ID layer = lset.Seq().at( 0 );
2410 SHAPE_POLY_SET padOutline;
2411
2412 pad->TransformShapeToPolygon( padOutline, layer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
2413
2414 std::shared_ptr<SHAPE_SEGMENT> hole = pad->GetEffectiveHoleShape();
2415 SHAPE_POLY_SET holeOutline;
2416
2417 TransformOvalToPolygon( holeOutline, hole->GetSeg().A, hole->GetSeg().B,
2418 hole->GetWidth(), ARC_HIGH_DEF, ERROR_INSIDE );
2419
2420 padOutline.BooleanSubtract( holeOutline, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
2421
2422 if( padOutline.IsEmpty() )
2423 aErrorHandler( pad, DRCE_PADSTACK, _( "(PTH pad's hole leaves no copper)" ) );
2424 }
2425 }
2426
2427 if( pad->GetAttribute() == PAD_ATTRIB::SMD )
2428 {
2429 if( pad->IsOnLayer( F_Cu ) && pad->IsOnLayer( B_Cu ) )
2430 {
2431 aErrorHandler( pad, DRCE_PADSTACK,
2432 _( "(SMD pad appears on both front and back copper)" ) );
2433 }
2434 else if( pad->IsOnLayer( F_Cu ) )
2435 {
2436 if( pad->IsOnLayer( B_Mask ) )
2437 {
2438 aErrorHandler( pad, DRCE_PADSTACK,
2439 _( "(SMD pad copper and mask layers don't match)" ) );
2440 }
2441 else if( pad->IsOnLayer( B_Paste ) )
2442 {
2443 aErrorHandler( pad, DRCE_PADSTACK,
2444 _( "(SMD pad copper and paste layers don't match)" ) );
2445 }
2446 }
2447 else if( pad->IsOnLayer( B_Cu ) )
2448 {
2449 if( pad->IsOnLayer( F_Mask ) )
2450 {
2451 aErrorHandler( pad, DRCE_PADSTACK,
2452 _( "(SMD pad copper and mask layers don't match)" ) );
2453 }
2454 else if( pad->IsOnLayer( F_Paste ) )
2455 {
2456 aErrorHandler( pad, DRCE_PADSTACK,
2457 _( "(SMD pad copper and paste layers don't match)" ) );
2458 }
2459 }
2460 }
2461 }
2462}
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
bool IsEmpty() const
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
@ DRCE_PADSTACK
Definition: drc_item.h:59
@ DRCE_PAD_TH_WITH_NO_HOLE
Definition: drc_item.h:78
@ ERROR_INSIDE
@ F_Paste
Definition: layer_ids.h:101
@ B_Mask
Definition: layer_ids.h:106
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ NPTH
like PAD_PTH, but not plated
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.

References _, LSET::AllCuMask(), ARC_HIGH_DEF, B_Cu, B_Mask, B_Paste, SHAPE_POLY_SET::BooleanSubtract(), DRCE_PAD_TH_WITH_NO_HOLE, DRCE_PADSTACK, ERROR_INSIDE, F_Cu, F_Mask, F_Paste, SHAPE_POLY_SET::IsEmpty(), NPTH, pad, Pads(), PTH, LSET::Seq(), SMD, and TransformOvalToPolygon().

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckShortingPads()

void FOOTPRINT::CheckShortingPads ( const std::function< void(const PAD *, const PAD *, const VECTOR2I &)> &  aErrorHandler)

Check for overlapping, different-numbered, non-net-tie pads.

Parameters
aErrorHandlercallback to handle the error messages generated

Definition at line 2465 of file footprint.cpp.

2467{
2468 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
2469
2470 for( PAD* pad : Pads() )
2471 {
2472 std::vector<PAD*> netTiePads = GetNetTiePads( pad );
2473
2474 for( PAD* other : Pads() )
2475 {
2476 if( other == pad || pad->SameLogicalPadAs( other ) )
2477 continue;
2478
2479 if( alg::contains( netTiePads, other ) )
2480 continue;
2481
2482 if( !( ( pad->GetLayerSet() & other->GetLayerSet() ) & LSET::AllCuMask() ).any() )
2483 continue;
2484
2485 // store canonical order so we don't collide in both directions (a:b and b:a)
2486 PAD* a = pad;
2487 PAD* b = other;
2488
2489 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
2490 std::swap( a, b );
2491
2492 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
2493 {
2494 checkedPairs[ { a, b } ] = 1;
2495
2496 if( pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
2497 {
2498 VECTOR2I pos;
2499 SHAPE* padShape = pad->GetEffectiveShape().get();
2500 SHAPE* otherShape = other->GetEffectiveShape().get();
2501
2502 if( padShape->Collide( otherShape, 0, nullptr, &pos ) )
2503 aErrorHandler( pad, other, pos );
2504 }
2505 }
2506 }
2507 }
2508}
std::vector< PAD * > GetNetTiePads(PAD *aPad) const
Definition: footprint.cpp:2339
An abstract shape on 2D plane.
Definition: shape.h:123
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Definition: shape.h:178
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References LSET::AllCuMask(), SHAPE::Collide(), alg::contains(), GetNetTiePads(), pad, and Pads().

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ ClassOf()

static bool FOOTPRINT::ClassOf ( const EDA_ITEM aItem)
inlinestatic

Definition at line 115 of file footprint.h.

116 {
117 return aItem && aItem->Type() == PCB_FOOTPRINT_T;
118 }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97

References PCB_FOOTPRINT_T, and EDA_ITEM::Type().

◆ ClearAllNets()

void FOOTPRINT::ClearAllNets ( )

Clear (i.e.

force the ORPHANED dummy net info) the net info which depends on a given board for all pads of the footprint.

This is needed when a footprint is copied between the fp editor and the board editor for instance, because net info become fully broken

Definition at line 558 of file footprint.cpp.

559{
560 // Force the ORPHANED dummy net info for all pads.
561 // ORPHANED dummy net does not depend on a board
562 for( PAD* pad : m_pads )
563 pad->SetNetCode( NETINFO_LIST::ORPHANED );
564}
static const int ORPHANED
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
Definition: netinfo.h:386

References m_pads, NETINFO_LIST::ORPHANED, and pad.

Referenced by PCB_BASE_FRAME::loadFootprint(), and FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearEditFlags()

◆ ClearFlags()

void EDA_ITEM::ClearFlags ( EDA_ITEM_FLAGS  aMask = EDA_ITEM_ALL_FLAGS)
inlineinherited

Definition at line 141 of file eda_item.h.

141{ m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:498

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), SCH_EDIT_TOOL::BreakWire(), BuildCourtyardCaches(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), SYMBOL_EDITOR_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), PCB_TOOL_BASE::doInteractiveItemPlacement(), KIGFX::SCH_PAINTER::draw(), SCH_ITEM::Duplicate(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Init(), EE_COLLECTOR::Inspect(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), DRC_TEST_PROVIDER_DISALLOW::Run(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetIsShownAsBitmap(), BOARD_COMMIT::Stage(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and EE_SELECTION_TOOL::unhighlight().

◆ ClearNetTiePadGroups()

void FOOTPRINT::ClearNetTiePadGroups ( )
inline

Definition at line 274 of file footprint.h.

275 {
276 m_netTiePadGroups.clear();
277 }

References m_netTiePadGroups.

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 153 of file eda_item.h.

154 {
156 }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define CANDIDATE
flag indicating that the structure is connected

References CANDIDATE, EDA_ITEM::ClearFlags(), IS_LINKED, SELECTED_BY_DRAG, and SKIP_STRUCT.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 143 of file view_item.h.

144 {
145 m_viewPrivData = nullptr;
146 }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:151

References KIGFX::VIEW_ITEM::m_viewPrivData.

Referenced by KIGFX::VIEW::OnDestroy().

◆ Clone()

EDA_ITEM * FOOTPRINT::Clone ( ) const
overridevirtual

Create a duplicate of this item with linked list members set to NULL.

The default version will return NULL in release builds and likely crash the program. In debug builds, a warning message indicating the derived class has not implemented cloning. This really should be a pure virtual function. Due to the fact that there are so many objects derived from EDA_ITEM, the decision was made to return NULL until all the objects derived from EDA_ITEM implement cloning. Once that happens, this function should be made pure.

Returns
A clone of the item.

Reimplemented from EDA_ITEM.

Definition at line 1373 of file footprint.cpp.

1374{
1375 return new FOOTPRINT( *this );
1376}
FOOTPRINT(BOARD *parent)
Definition: footprint.cpp:55

References FOOTPRINT().

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), PCB_PLUGIN::FootprintLoad(), FootprintNeedsUpdate(), PCB_PLUGIN::FootprintSave(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), and BOARD_NETLIST_UPDATER::updateFootprintParameters().

◆ CoverageRatio()

double FOOTPRINT::CoverageRatio ( const GENERAL_COLLECTOR aCollector) const

Calculate the ratio of total area of the footprint pads and graphical items to the area of the footprint.

Used by selection tool heuristics.

Returns
the ratio.

Definition at line 2111 of file footprint.cpp.

2112{
2113 int textMargin = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
2114
2115 SHAPE_POLY_SET footprintRegion( GetBoundingHull() );
2116 SHAPE_POLY_SET coveredRegion;
2117
2119
2120 TransformFPShapesToPolySet( coveredRegion, UNDEFINED_LAYER, textMargin, ARC_LOW_DEF,
2122 true, /* include text */
2123 false, /* include shapes */
2124 false /* include private items */ );
2125
2126 for( int i = 0; i < aCollector.GetCount(); ++i )
2127 {
2128 const BOARD_ITEM* item = aCollector[i];
2129
2130 switch( item->Type() )
2131 {
2132 case PCB_FP_TEXT_T:
2133 case PCB_FP_TEXTBOX_T:
2134 case PCB_FP_SHAPE_T:
2135 if( item->GetParent() != this )
2136 {
2137 item->TransformShapeToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
2138 ERROR_OUTSIDE );
2139 }
2140 break;
2141
2142 case PCB_TEXT_T:
2143 case PCB_TEXTBOX_T:
2144 case PCB_SHAPE_T:
2145 case PCB_TRACE_T:
2146 case PCB_ARC_T:
2147 case PCB_VIA_T:
2148 item->TransformShapeToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
2149 ERROR_OUTSIDE );
2150 break;
2151
2152 case PCB_FOOTPRINT_T:
2153 if( item != this )
2154 {
2155 const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( item );
2156 coveredRegion.AddOutline( footprint->GetBoundingHull().Outline( 0 ) );
2157 }
2158 break;
2159
2160 default:
2161 break;
2162 }
2163 }
2164
2165 double footprintRegionArea = polygonArea( footprintRegion );
2166 double uncoveredRegionArea = footprintRegionArea - polygonArea( coveredRegion );
2167 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2168 double ratio = ( coveredArea / footprintRegionArea );
2169
2170 // Test for negative ratio (should not occur).
2171 // better to be conservative (this will result in the disambiguate dialog)
2172 if( ratio < 0.0 )
2173 return 1.0;
2174
2175 return std::min( ratio, 1.0 );
2176}
constexpr int ARC_LOW_DEF
Definition: base_units.h:120
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
Definition: board_item.cpp:196
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
virtual double OnePixelInIU() const =0
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
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:2742
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:935
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:2815
const COLLECTORS_GUIDE * GetGuide() const
Definition: collectors.h:295
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
static double polygonArea(SHAPE_POLY_SET &aPolySet)
Definition: footprint.cpp:2012
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References SHAPE_POLY_SET::AddOutline(), ARC_LOW_DEF, ERROR_OUTSIDE, GetBoundingHull(), COLLECTOR::GetCount(), GENERAL_COLLECTOR::GetGuide(), BOARD_ITEM::GetParent(), KiROUND(), COLLECTORS_GUIDE::OnePixelInIU(), SHAPE_POLY_SET::Outline(), PCB_ARC_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, polygonArea(), TransformFPShapesToPolySet(), TransformPadsToPolySet(), BOARD_ITEM::TransformShapeToPolygon(), EDA_ITEM::Type(), and UNDEFINED_LAYER.

◆ Delete()

virtual void BOARD_ITEM_CONTAINER::Delete ( BOARD_ITEM aItem)
inlinevirtualinherited

Removes an item from the container and deletes it.

Definition at line 77 of file board_item_container.h.

78 {
79 Remove( aItem );
80 delete aItem;
81 }
virtual void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL)=0
Removes an item from the container.

References BOARD_ITEM_CONTAINER::Remove().

Referenced by DRC_ITEMS_PROVIDER::DeleteItem(), PCB_PARSER::parseBOARD_unchecked(), and BOARD_COMMIT::Push().

◆ DeleteStructure()

void BOARD_ITEM::DeleteStructure ( )
inherited

Delete this object after removing from its parent if it has one.

Definition at line 150 of file board_item.cpp.

151{
153
154 if( parent )
155 parent->Remove( this );
156
157 delete this;
158}
Abstract interface for BOARD_ITEMs capable of storing other items inside.

References BOARD_ITEM::GetParent(), and BOARD_ITEM_CONTAINER::Remove().

Referenced by DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow().

◆ Duplicate()

BOARD_ITEM * FOOTPRINT::Duplicate ( ) const
overridevirtual

Create a copy of this BOARD_ITEM.

Reimplemented from BOARD_ITEM.

Definition at line 1856 of file footprint.cpp.

1857{
1858 FOOTPRINT* dupe = static_cast<FOOTPRINT*>( BOARD_ITEM::Duplicate() );
1859
1860 dupe->RunOnChildren( [&]( BOARD_ITEM* child )
1861 {
1862 const_cast<KIID&>( child->m_Uuid ) = KIID();
1863 });
1864
1865 return dupe;
1866}
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:184
const KIID m_Uuid
Definition: eda_item.h:492
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:1379
Definition: kiid.h:48

References BOARD_ITEM::Duplicate(), EDA_ITEM::m_Uuid, and RunOnChildren().

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), FOOTPRINT_PREVIEW_PANEL::DisplayFootprint(), GPCB_PLUGIN::FootprintLoad(), PCB_PLUGIN::FootprintLoad(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), and CADSTAR_PCB_ARCHIVE_LOADER::loadComponents().

◆ DuplicateItem()

BOARD_ITEM * FOOTPRINT::DuplicateItem ( const BOARD_ITEM aItem,
bool  aAddToFootprint = false 
)

Duplicate a given item within the footprint, optionally adding it to the board.

Returns
the new item, or NULL if the item could not be duplicated.

Definition at line 1869 of file footprint.cpp.

1870{
1871 BOARD_ITEM* new_item = nullptr;
1872 FP_ZONE* new_zone = nullptr;
1873
1874 switch( aItem->Type() )
1875 {
1876 case PCB_PAD_T:
1877 {
1878 PAD* new_pad = new PAD( *static_cast<const PAD*>( aItem ) );
1879 const_cast<KIID&>( new_pad->m_Uuid ) = KIID();
1880
1881 if( aAddToFootprint )
1882 m_pads.push_back( new_pad );
1883
1884 new_item = new_pad;
1885 break;
1886 }
1887
1888 case PCB_FP_ZONE_T:
1889 {
1890 new_zone = new FP_ZONE( *static_cast<const FP_ZONE*>( aItem ) );
1891 const_cast<KIID&>( new_zone->m_Uuid ) = KIID();
1892
1893 if( aAddToFootprint )
1894 m_fp_zones.push_back( new_zone );
1895
1896 new_item = new_zone;
1897 break;
1898 }
1899
1900 case PCB_FP_TEXT_T:
1901 {
1902 FP_TEXT* new_text = new FP_TEXT( *static_cast<const FP_TEXT*>( aItem ) );
1903 const_cast<KIID&>( new_text->m_Uuid ) = KIID();
1904
1905 if( new_text->GetType() == FP_TEXT::TEXT_is_REFERENCE )
1906 {
1907 new_text->SetText( wxT( "${REFERENCE}" ) );
1908 new_text->SetType( FP_TEXT::TEXT_is_DIVERS );
1909 }
1910 else if( new_text->GetType() == FP_TEXT::TEXT_is_VALUE )
1911 {
1912 new_text->SetText( wxT( "${VALUE}" ) );
1913 new_text->SetType( FP_TEXT::TEXT_is_DIVERS );
1914 }
1915
1916 if( aAddToFootprint )
1917 Add( new_text );
1918
1919 new_item = new_text;
1920
1921 break;
1922 }
1923
1924 case PCB_FP_SHAPE_T:
1925 {
1926 FP_SHAPE* new_shape = new FP_SHAPE( *static_cast<const FP_SHAPE*>( aItem ) );
1927 const_cast<KIID&>( new_shape->m_Uuid ) = KIID();
1928
1929 if( aAddToFootprint )
1930 Add( new_shape );
1931
1932 new_item = new_shape;
1933 break;
1934 }
1935
1936 case PCB_FP_TEXTBOX_T:
1937 {
1938 FP_TEXTBOX* new_textbox = new FP_TEXTBOX( *static_cast<const FP_TEXTBOX*>( aItem ) );
1939 const_cast<KIID&>( new_textbox->m_Uuid ) = KIID();
1940
1941 if( aAddToFootprint )
1942 Add( new_textbox );
1943
1944 new_item = new_textbox;
1945 break;
1946 }
1947
1953 {
1954 PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( aItem->Duplicate() );
1955
1956 if( aAddToFootprint )
1957 Add( dimension );
1958
1959 new_item = dimension;
1960 break;
1961 }
1962
1963 case PCB_GROUP_T:
1964 new_item = static_cast<const PCB_GROUP*>( aItem )->DeepDuplicate();
1965 break;
1966
1967 case PCB_FOOTPRINT_T:
1968 // Ignore the footprint itself
1969 break;
1970
1971 default:
1972 // Un-handled item for duplication
1973 wxFAIL_MSG( wxT( "Duplication not supported for items of class " ) + aItem->GetClass() );
1974 break;
1975 }
1976
1977 return new_item;
1978}
virtual wxString GetClass() const =0
Return the class name.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
void SetType(TEXT_TYPE aType)
Definition: fp_text.h:119
TEXT_TYPE GetType() const
Definition: fp_text.h:120
Abstract dimension API.
Definition: pcb_dimension.h:96

References Add(), BOARD_ITEM::Duplicate(), EDA_ITEM::GetClass(), FP_TEXT::GetType(), m_fp_zones, m_pads, EDA_ITEM::m_Uuid, PAD, PCB_FOOTPRINT_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_PAD_T, EDA_TEXT::SetText(), FP_TEXT::SetType(), FP_TEXT::TEXT_is_DIVERS, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, and EDA_ITEM::Type().

Referenced by EDIT_TOOL::Duplicate(), and ARRAY_CREATOR::Invoke().

◆ FindPadByNumber()

PAD * FOOTPRINT::FindPadByNumber ( const wxString &  aPadNumber,
PAD aSearchAfterMe = nullptr 
) const

Return a PAD with a matching number.

Note
Numbers may not be unique depending on how the footprint was created.
Parameters
aPadNumberthe pad number to find.
aSearchAfterMe= not nullptr to find a pad living after aAfterMe
Returns
the first matching numbered PAD is returned or NULL if not found.

Definition at line 1174 of file footprint.cpp.

1175{
1176 bool can_select = aSearchAfterMe ? false : true;
1177
1178 for( PAD* pad : m_pads )
1179 {
1180 if( !can_select && pad == aSearchAfterMe )
1181 {
1182 can_select = true;
1183 continue;
1184 }
1185
1186 if( can_select && pad->GetNumber() == aPadNumber )
1187 return pad;
1188 }
1189
1190 return nullptr;
1191}

References m_pads, and pad.

Referenced by CheckNetTiePadGroups(), PCB_EDIT_FRAME::ExchangeFootprint(), BOARD_NETLIST_UPDATER::testConnectivity(), and DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist().

◆ FixUuids()

bool FOOTPRINT::FixUuids ( )

Old footprints do not always have a valid UUID (some can be set to null uuid) However null UUIDs, having a special meaning in editor, create issues when editing a footprint So all null uuids a re replaced by a valid uuid.

Returns
true if at least one uuid is changed, false if no change

Definition at line 238 of file footprint.cpp.

239{
240 // replace null UUIDs if any by a valid uuid
241 std::vector< BOARD_ITEM* > item_list;
242
243 item_list.push_back( m_reference );
244 item_list.push_back( m_value );
245
246 for( PAD* pad : m_pads )
247 item_list.push_back( pad );
248
249 for( BOARD_ITEM* gr_item : m_drawings )
250 item_list.push_back( gr_item );
251
252 // Note: one cannot fix null UUIDs inside the group, but it should not happen
253 // because null uuids can be found in old footprints, therefore without group
254 for( PCB_GROUP* group : m_fp_groups )
255 item_list.push_back( group );
256
257 // Probably notneeded, because old fp do not have zones. But just in case.
258 for( FP_ZONE* zone : m_fp_zones )
259 item_list.push_back( zone );
260
261 bool changed = false;
262
263 for( BOARD_ITEM* item : item_list )
264 {
265 if( item->m_Uuid == niluuid )
266 {
267 const_cast<KIID&>( item->m_Uuid ) = KIID();
268 changed = true;
269 }
270 }
271
272 return changed;
273}
KIID niluuid(0)

References group, m_drawings, m_fp_groups, m_fp_zones, m_pads, m_reference, m_value, niluuid, and pad.

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard().

◆ Flip()

void FOOTPRINT::Flip ( const VECTOR2I aCentre,
bool  aFlipLeftRight 
)
overridevirtual

Flip this object, i.e.

change the board side for this object.

Parameters
aCentrethe rotation point.
aFlipLeftRightmirror across Y axis instead of X (the default).

Mirror the Y position (around the X axis)

Reimplemented from BOARD_ITEM.

Definition at line 1586 of file footprint.cpp.

1587{
1588 // Move footprint to its final position:
1589 VECTOR2I finalPos = m_pos;
1590
1591 // Now Flip the footprint.
1592 // Flipping a footprint is a specific transform: it is not mirrored like a text.
1593 // We have to change the side, and ensure the footprint rotation is modified according to the
1594 // transform, because this parameter is used in pick and place files, and when updating the
1595 // footprint from library.
1596 // When flipped around the X axis (Y coordinates changed) orientation is negated
1597 // When flipped around the Y axis (X coordinates changed) orientation is 180 - old orient.
1598 // Because it is specific to a footprint, we flip around the X axis, and after rotate 180 deg
1599
1600 MIRROR( finalPos.y, aCentre.y );
1601
1602 SetPosition( finalPos );
1603
1604 // Flip layer
1606
1607 // Reverse mirror orientation.
1608 m_orient = -m_orient;
1610
1611 // Mirror pads to other side of board.
1612 for( PAD* pad : m_pads )
1613 pad->Flip( m_pos, false );
1614
1615 // Mirror zones to other side of board.
1616 for( ZONE* zone : m_fp_zones )
1617 zone->Flip( m_pos, false );
1618
1619 // Mirror reference and value.
1620 m_reference->Flip( m_pos, false );
1621 m_value->Flip( m_pos, false );
1622
1623 // Reverse mirror footprint graphics and texts.
1624 for( BOARD_ITEM* item : m_drawings )
1625 {
1626 switch( item->Type() )
1627 {
1628 case PCB_FP_SHAPE_T:
1629 static_cast<FP_SHAPE*>( item )->Flip( m_pos, false );
1630 break;
1631
1632 case PCB_FP_TEXT_T:
1633 static_cast<FP_TEXT*>( item )->Flip( m_pos, false );
1634 break;
1635
1636 case PCB_FP_TEXTBOX_T:
1637 static_cast<FP_TEXTBOX*>( item )->Flip( m_pos, false );
1638 break;
1639
1645 static_cast<PCB_DIMENSION_BASE*>( item )->Flip( m_pos, false );
1646 break;
1647
1648 default:
1649 wxMessageBox( wxString::Format( wxT( "FOOTPRINT::Flip() error: Unknown Draw Type %d" ),
1650 (int)item->Type() ) );
1651 break;
1652 }
1653 }
1654
1655 // Now rotate 180 deg if required
1656 if( aFlipLeftRight )
1657 Rotate( aCentre, ANGLE_180 );
1658
1663
1664 m_cachedHull.Mirror( aFlipLeftRight, !aFlipLeftRight, m_pos );
1665
1667}
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
EDA_ANGLE Normalize180()
Definition: eda_angle.h:271
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1670
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: footprint.cpp:1551
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:200
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1586
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity during footprint flip.
Definition: fp_text.cpp:137
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:416
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:544
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
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

References ANGLE_180, Flip(), FP_TEXT::Flip(), FlipLayer(), Format(), GetLayer(), m_boundingBoxCacheTimeStamp, m_cachedHull, m_courtyard_cache_back, m_courtyard_cache_front, m_courtyard_cache_timestamp, m_drawings, m_fp_zones, m_orient, m_pads, m_pos, m_reference, m_textExcludedBBoxCacheTimeStamp, m_value, m_visibleBBoxCacheTimeStamp, SHAPE_POLY_SET::Mirror(), MIRROR(), EDA_ANGLE::Normalize180(), pad, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, Rotate(), BOARD_ITEM::SetLayer(), SetPosition(), and VECTOR2< T >::y.

Referenced by PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCB_EDIT_FRAME::ExchangeFootprint(), Flip(), PCB_PLUGIN::FootprintSave(), DSN::SPECCTRA_DB::FromSESSION(), CADSTAR_PCB_ARCHIVE_LOADER::loadComponents(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FABMASTER::loadFootprints(), EAGLE_PLUGIN::orientFootprintAndText(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SetLayerAndFlip(), and DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow().

◆ FootprintNeedsUpdate()

bool FOOTPRINT::FootprintNeedsUpdate ( const FOOTPRINT aLibFootprint)

Return true if a board footprint differs from the library version.

Definition at line 348 of file drc_test_provider_library_parity.cpp.

349{
350#define TEST_ATTR( a, b, attr ) TEST( ( a & attr ), ( b & attr ) );
351 wxASSERT( aLibFootprint );
352
353 if( IsFlipped() )
354 {
355 std::unique_ptr<FOOTPRINT> temp( static_cast<FOOTPRINT*>( Clone() ) );
356 temp->Flip( {0,0}, false );
357 temp->SetParentGroup( nullptr );
358 return temp->FootprintNeedsUpdate( aLibFootprint );
359 }
360
361 TEST( GetDescription(), aLibFootprint->GetDescription() );
362 TEST( GetKeywords(), aLibFootprint->GetKeywords() );
363
365 TEST_ATTR( GetAttributes(), aLibFootprint->GetAttributes(), FP_SMD );
368
369 // Clearance and zone connection overrides are as likely to be set at the board level as in
370 // the library.
371 //
372 // If we ignore them and someone *does* change one of them in the library, then stale
373 // footprints won't be caught.
374 //
375 // On the other hand, if we report them then boards that override at the board level are
376 // going to be VERY noisy.
377#if 0
378 TEST( GetLocalClearance(), aLibFootprint->GetLocalClearance() );
382
383 TEST( GetZoneConnection(), aLibFootprint->GetZoneConnection() );
384#endif
385
386 TEST( GetNetTiePadGroups().size(), aLibFootprint->GetNetTiePadGroups().size() );
387
388 for( size_t ii = 0; ii < GetNetTiePadGroups().size(); ++ii )
389 TEST( GetNetTiePadGroups()[ii], aLibFootprint->GetNetTiePadGroups()[ii] );
390
391 // Text items are really problematic. We don't want to test the reference, but after that
392 // it gets messy.
393 //
394 // What about the value? Depends on whether or not it's a singleton part.
395 //
396 // And what about other texts? They might be added only to instances on the board, or even
397 // changed for instances on the board. Or they might want to be tested for equality.
398 //
399 // Currently we punt and ignore all the text items.
400
401 // Drawings and pads are also somewhat problematic as there's no guarantee that they'll be
402 // in the same order in the two footprints. Rather than building some sophisticated hashing
403 // algorithm we use the footprint sorting functions to attempt to sort them in the same
404 // order.
405
406 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> aShapes;
407 std::copy_if( GraphicalItems().begin(), GraphicalItems().end(),
408 std::inserter( aShapes, aShapes.begin() ),
409 []( BOARD_ITEM* item )
410 {
411 return item->Type() == PCB_FP_SHAPE_T;
412 } );
413 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> bShapes;
414 std::copy_if( aLibFootprint->GraphicalItems().begin(), aLibFootprint->GraphicalItems().end(),
415 std::inserter( bShapes, bShapes.begin() ),
416 []( BOARD_ITEM* item )
417 {
418 return item->Type() == PCB_FP_SHAPE_T;
419 } );
420
421 std::set<PAD*, FOOTPRINT::cmp_pads> aPads( Pads().begin(), Pads().end() );
422 std::set<PAD*, FOOTPRINT::cmp_pads> bPads( aLibFootprint->Pads().begin(), aLibFootprint->Pads().end() );
423
424 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> aZones( Zones().begin(), Zones().end() );
425 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> bZones( aLibFootprint->Zones().begin(), aLibFootprint->Zones().end() );
426
427 TEST( aPads.size(), bPads.size() );
428 TEST( aZones.size(), bZones.size() );
429 TEST( aShapes.size(), bShapes.size() );
430
431 for( auto aIt = aPads.begin(), bIt = bPads.begin(); aIt != aPads.end(); aIt++, bIt++ )
432 TEST_PADS( *aIt, *bIt );
433
434 for( auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
435 {
436 if( ( *aIt )->Type() == PCB_FP_SHAPE_T )
437 TEST_SHAPES( static_cast<FP_SHAPE*>( *aIt ), static_cast<FP_SHAPE*>( *bIt ) );
438 }
439
440 for( auto aIt = aZones.begin(), bIt = bZones.begin(); aIt != aZones.end(); aIt++, bIt++ )
441 TEST_ZONES( *aIt, *bIt );
442
443 TEST( Models().size(), aLibFootprint->Models().size() );
444
445 for( size_t ii = 0; ii < Models().size(); ++ii )
446 TEST_MODELS( Models()[ii], aLibFootprint->Models()[ii] );
447
448 return false;
449}
int GetLocalClearance() const
Definition: footprint.h:230
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1373
wxString GetDescription() const
Definition: footprint.h:218
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:244
bool IsFlipped() const
Definition: footprint.h:324
int GetLocalSolderPasteMargin() const
Definition: footprint.h:241
const std::vector< wxString > & GetNetTiePadGroups() const
Definition: footprint.h:272
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:184
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:248
wxString GetKeywords() const
Definition: footprint.h:221
int GetLocalSolderMaskMargin() const
Definition: footprint.h:227
#define TEST_ATTR(a, b, attr)
#define TEST_ZONES(a, b)
#define TEST(a, b)
#define TEST_MODELS(a, b)
#define TEST_SHAPES(a, b)
#define TEST_PADS(a, b)
#define TEST_D(a, b)
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:74

References Clone(), FP_ALLOW_MISSING_COURTYARD, FP_ALLOW_SOLDERMASK_BRIDGES, FP_SMD, FP_THROUGH_HOLE, GetAttributes(), GetDescription(), GetKeywords(), GetLocalClearance(), GetLocalSolderMaskMargin(), GetLocalSolderPasteMargin(), GetLocalSolderPasteMarginRatio(), GetNetTiePadGroups(), GetZoneConnection(), GraphicalItems(), IsFlipped(), Models(), Pads(), PCB_FP_SHAPE_T, TEST, TEST_ATTR, TEST_D, TEST_MODELS, TEST_PADS, TEST_SHAPES, TEST_ZONES, and Zones().

Referenced by DIALOG_EXCHANGE_FOOTPRINTS::processFootprint().

◆ Get() [1/3]

template<typename T >
std::optional< T > INSPECTABLE::Get ( const wxString &  aProperty) const
inlineinherited

Definition at line 104 of file inspectable.h.

105 {
107 TYPE_ID thisType = TYPE_HASH( *this );
108 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
109 std::optional<T> ret;
110
111 if( prop )
112 {
113 const void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114
115 if( object )
116 ret = prop->get<T>( object );
117 }
118
119 return ret;
120 }
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
T get(const void *aObject) const
Definition: property.h:316
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
#define TYPE_HASH(x)
Definition: property.h:62
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:46

References PROPERTY_BASE::get(), PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Get() [2/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 84 of file inspectable.h.

85 {
87 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
88 return object ? aProperty->getter( object ) : wxAny();
89 }
virtual wxAny getter(const void *aObject) const =0

References PROPERTY_BASE::getter(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by BOOST_AUTO_TEST_CASE(), CLASS_D_DESC::CLASS_D_DESC(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PROPERTIES_PANEL::getItemValue(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [3/3]

template<typename T >
T INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 92 of file inspectable.h.

93 {
95 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
96
97 if( !object )
98 throw std::runtime_error( "Could not cast INSPECTABLE to the requested type" );
99
100 return aProperty->get<T>( object );
101 }

References PROPERTY_BASE::get(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ GetArea()

double FOOTPRINT::GetArea ( int  aPadding = 0) const

Definition at line 709 of file footprint.cpp.

710{
711 BOX2I bbox = GetBoundingBox( false, false );
712
713 double w = std::abs( static_cast<double>( bbox.GetWidth() ) ) + aPadding;
714 double h = std::abs( static_cast<double>( bbox.GetHeight() ) ) + aPadding;
715 return w * h;
716}
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:804
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401

References std::abs(), GetBoundingBox(), BOX2< Vec >::GetHeight(), and BOX2< Vec >::GetWidth().

Referenced by sortFootprintsByComplexity(), and sortFootprintsByRatsnestSize().

◆ GetAttributes()

◆ GetBoard() [1/2]

BOARD * BOARD_ITEM::GetBoard ( )
virtualinherited

Definition at line 57 of file board_item.cpp.

58{
59 if( Type() == PCB_T )
60 return static_cast<BOARD*>( this );
61
62 BOARD_ITEM* parent = GetParent();
63
64 if( parent )
65 return parent->GetBoard();
66
67 return nullptr;
68}
@ PCB_T
Definition: typeinfo.h:82

References BOARD_ITEM::GetBoard(), BOARD_ITEM::GetParent(), PCB_T, and EDA_ITEM::Type().

◆ GetBoard() [2/2]

const BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

Return the BOARD in which this BOARD_ITEM resides, or NULL if none.

Definition at line 43 of file board_item.cpp.

44{
45 if( Type() == PCB_T )
46 return static_cast<const BOARD*>( this );
47
48 BOARD_ITEM* parent = GetParent();
49
50 if( parent )
51 return parent->GetBoard();
52
53 return nullptr;
54}

References BOARD_ITEM::GetBoard(), BOARD_ITEM::GetParent(), PCB_T, and EDA_ITEM::Type().

Referenced by BOARD_ADAPTER::addShape(), BuildCourtyardCaches(), PAD::BuildEffectivePolygon(), PAD::BuildEffectiveShapes(), ZONE::BuildSmoothedPoly(), ZONE::CacheBoundingBox(), collidesWithArea(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), enclosedByAreaFunc(), existsOnLayerFunc(), PCB_VIA::FlashLayer(), PAD::FlashLayer(), FP_SHAPE::Flip(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_DIMENSION_BASE::Flip(), PCB_SHAPE::Flip(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), PCB_TEXTBOX::Flip(), PCB_TRACK::Flip(), PCB_ARC::Flip(), PCB_VIA::Flip(), ZONE::Flip(), PCB_PLUGIN::format(), fromToFunc(), BOARD_ITEM::GetBoard(), PCB_EXPR_CONTEXT::GetBoard(), NETINFO_ITEM::GetBoundingBox(), ZONE::GetBoundingBox(), GetBoundingBox(), GetBoundingHull(), GetCourtyard(), BOARD_CONNECTED_ITEM::GetEffectiveNetClass(), FP_TEXT::GetEffectiveShape(), PCB_TEXT::GetEffectiveShape(), getFieldFunc(), ZONE::GetInteractingZones(), ZONE::GetItemDescription(), BOARD_ITEM::GetLayerName(), PCB_VIA::GetMinAnnulus(), NETINFO_ITEM::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), BOARD_CONNECTED_ITEM::GetOwnClearance(), PAD::GetOwnClearance(), PCB_MARKER::GetSeverity(), PAD::GetSolderMaskExpansion(), PCB_VIA::GetSolderMaskExpansion(), PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), PCB_TRACK::GetWidthConstraint(), inDiffPairFunc(), ROUTER_TOOL::Init(), intersectsAreaFunc(), intersectsBackCourtyardFunc(), intersectsCourtyardFunc(), intersectsFrontCourtyardFunc(), BOARD_ITEM::IsLocked(), PCB_VIA::IsTented(), BOARD_ITEM::layerMaskDescribe(), PCB_VIA::layerMaskDescribe(), PAD::MergePrimitivesAsPolygon(), ZONE::Move(), DIALOG_TEXTBOX_PROPERTIES::onBorderChecked(), EAGLE_PLUGIN::packageWire(), padsNeedUpdate(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD::ResolveDRCExclusions(), ResolveTextVar(), BOARD_CONNECTED_ITEM::SetNetCode(), TEARDROP_DIALOG::TEARDROP_DIALOG(), DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems(), CONNECTIVITY_DATA::TestTrackEndpointDangling(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), ZONE::TransformSmoothedOutlineToPolygon(), BOARD::UpdateRatsnestExclusions(), ViewBBox(), PAD::ViewBBox(), PCB_TRACK::ViewBBox(), PAD::ViewGetLOD(), PCB_BITMAP::ViewGetLOD(), PCB_VIA::ViewGetLOD(), ~FOOTPRINT(), and ZONE::~ZONE().

◆ GetBoundingBox() [1/2]

const BOX2I FOOTPRINT::GetBoundingBox ( ) const
overridevirtual

Return the orthogonal bounding box of this object for display purposes.

This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.

Reimplemented from EDA_ITEM.

Definition at line 804 of file footprint.cpp.

805{
806 return GetBoundingBox( true, true );
807}

References GetBoundingBox().

Referenced by AR_AUTOPLACER::buildFpAreas(), PCB_GRID_HELPER::computeAnchors(), KIGFX::PCB_PAINTER::draw(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), GetArea(), GetBoundingBox(), GetBoundingBoxes(), FOOTPRINT_EDIT_FRAME::GetDocumentExtents(), AR_AUTOPLACER::getOptimalFPPlacement(), HitTest(), PCB_SELECTION_TOOL::hitTestDistance(), SpreadFootprints(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), AR_AUTOPLACER::testFootprintOnBoard(), and ViewBBox().

◆ GetBoundingBox() [2/2]

const BOX2I FOOTPRINT::GetBoundingBox ( bool  aIncludeText,
bool  aIncludeInvisibleText 
) const

Definition at line 810 of file footprint.cpp.

811{
812 const BOARD* board = GetBoard();
813 bool isFPEdit = board && board->IsFootprintHolder();
814
815 if( board )
816 {
817 if( aIncludeText && aIncludeInvisibleText )
818 {
820 return m_cachedBoundingBox;
821 }
822 else if( aIncludeText )
823 {
825 return m_cachedVisibleBBox;
826 }
827 else
828 {
831 }
832 }
833
834 BOX2I bbox( m_pos );
835 bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
836
837 for( BOARD_ITEM* item : m_drawings )
838 {
839 if( m_privateLayers.test( item->GetLayer() ) && !isFPEdit )
840 continue;
841
842 // We want the bitmap bounding box just in the footprint editor
843 // so it will start with the correct initial zoom
844 if( item->Type() == PCB_BITMAP_T && !isFPEdit )
845 continue;
846
847 // Handle text separately
848 if( item->Type() == PCB_FP_TEXT_T )
849 continue;
850
851 bbox.Merge( item->GetBoundingBox() );
852 }
853
854 for( PAD* pad : m_pads )
855 bbox.Merge( pad->GetBoundingBox() );
856
857 for( FP_ZONE* zone : m_fp_zones )
858 bbox.Merge( zone->GetBoundingBox() );
859
860 bool noDrawItems = ( m_drawings.empty() && m_pads.empty() && m_fp_zones.empty() );
861
862 // Groups do not contribute to the rect, only their members
863 if( aIncludeText || noDrawItems )
864 {
865 for( BOARD_ITEM* item : m_drawings )
866 {
867 if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
868 continue;
869
870 // Only FP_TEXT items are independently selectable; FP_TEXTBOX items go in with
871 // other graphic items above.
872 if( item->Type() == PCB_FP_TEXT_T )
873 bbox.Merge( item->GetBoundingBox() );
874 }
875
876 // This can be further optimized when aIncludeInvisibleText is true, but currently
877 // leaving this as is until it's determined there is a noticeable speed hit.
878 bool valueLayerIsVisible = true;
879 bool refLayerIsVisible = true;
880
881 if( board )
882 {
883 // The first "&&" conditional handles the user turning layers off as well as layers
884 // not being present in the current PCB stackup. Values, references, and all
885 // footprint text can also be turned off via the GAL meta-layers, so the 2nd and
886 // 3rd "&&" conditionals handle that.
887 valueLayerIsVisible = board->IsLayerVisible( m_value->GetLayer() )
889 && board->IsElementVisible( LAYER_MOD_TEXT );
890
891 refLayerIsVisible = board->IsLayerVisible( m_reference->GetLayer() )
893 && board->IsElementVisible( LAYER_MOD_TEXT );
894 }
895
896
897 if( ( m_value->IsVisible() && valueLayerIsVisible )
898 || aIncludeInvisibleText
899 || noDrawItems )
900 {
901 bbox.Merge( m_value->GetBoundingBox() );
902 }
903
904 if( ( m_reference->IsVisible() && refLayerIsVisible )
905 || aIncludeInvisibleText
906 || noDrawItems )
907 {
908 bbox.Merge( m_reference->GetBoundingBox() );
909 }
910 }
911
912 if( board )
913 {
914 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
915 {
917 m_cachedBoundingBox = bbox;
918 }
919 else if( aIncludeText )
920 {
922 m_cachedVisibleBBox = bbox;
923 }
924 else
925 {
928 }
929 }
930
931 return bbox;
932}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:295
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:631
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:571
virtual bool IsVisible() const
Definition: eda_text.h:136
const BOX2I GetBoundingBox() const override
Set absolute coordinates.
Definition: fp_text.cpp:235
@ LAYER_MOD_TEXT
Definition: layer_ids.h:198
@ LAYER_MOD_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:210
@ LAYER_MOD_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:211

References BOARD_ITEM::GetBoard(), FP_TEXT::GetBoundingBox(), BOARD_ITEM::GetLayer(), BOARD::GetTimeStamp(), BOX2< Vec >::Inflate(), BOARD::IsElementVisible(), BOARD::IsFootprintHolder(), BOARD::IsLayerVisible(), EDA_TEXT::IsVisible(), LAYER_MOD_REFERENCES, LAYER_MOD_TEXT, LAYER_MOD_VALUES, m_boundingBoxCacheTimeStamp, m_cachedBoundingBox, m_cachedTextExcludedBBox, m_cachedVisibleBBox, m_drawings, m_fp_zones, m_pads, m_pos, m_privateLayers, m_reference, m_textExcludedBBoxCacheTimeStamp, m_value, m_visibleBBoxCacheTimeStamp, BOX2< Vec >::Merge(), EDA_IU_SCALE::mmToIU(), pad, PCB_BITMAP_T, PCB_FP_TEXT_T, and pcbIUScale.

◆ GetBoundingHull()

SHAPE_POLY_SET FOOTPRINT::GetBoundingHull ( ) const

Return a bounding polygon for the shapes and pads in the footprint.

This operation is slower but more accurate than calculating a bounding box.

Definition at line 935 of file footprint.cpp.

936{
937 const BOARD* board = GetBoard();
938 bool isFPEdit = board && board->IsFootprintHolder();
939
940 if( board )
941 {
942 if( m_hullCacheTimeStamp >= board->GetTimeStamp() )
943 return m_cachedHull;
944 }
945
946 SHAPE_POLY_SET rawPolys;
947 SHAPE_POLY_SET hull;
948
949 for( BOARD_ITEM* item : m_drawings )
950 {
951 if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
952 continue;
953
954 if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_BITMAP_T )
955 {
956 item->TransformShapeToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
958 }
959
960 // We intentionally exclude footprint text from the bounding hull.
961 }
962
963 for( PAD* pad : m_pads )
964 {
965 pad->TransformShapeToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
966 // In case hole is larger than pad
967 pad->TransformHoleToPolygon( rawPolys, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
968 }
969
970 for( FP_ZONE* zone : m_fp_zones )
971 {
972 for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
973 {
974 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
975
976 for( int ii = 0; ii < layerPoly.OutlineCount(); ii++ )
977 {
978 const SHAPE_LINE_CHAIN& poly = layerPoly.COutline( ii );
979 rawPolys.AddOutline( poly );
980 }
981 }
982 }
983
984 // If there are some graphic items, build the actual hull.
985 // However if no items, create a minimal polygon (can happen if a footprint
986 // is created with no item: it contains only 2 texts.
987 if( rawPolys.OutlineCount() == 0 )
988 {
989 // generate a small dummy rectangular outline around the anchor
990 const int halfsize = pcbIUScale.mmToIU( 1.0 );
991
992 rawPolys.NewOutline();
993
994 // add a square:
995 rawPolys.Append( GetPosition().x - halfsize, GetPosition().y - halfsize );
996 rawPolys.Append( GetPosition().x + halfsize, GetPosition().y - halfsize );
997 rawPolys.Append( GetPosition().x + halfsize, GetPosition().y + halfsize );
998 rawPolys.Append( GetPosition().x - halfsize, GetPosition().y + halfsize );
999 }
1000
1001 std::vector<VECTOR2I> convex_hull;
1002 BuildConvexHull( convex_hull, rawPolys );
1003
1006
1007 for( const VECTOR2I& pt : convex_hull )
1008 m_cachedHull.Append( pt );
1009
1010 if( board )
1012
1013 return m_cachedHull;
1014}
VECTOR2I GetPosition() const override
Definition: footprint.h:188
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
Definition: convex_hull.cpp:87

References SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::Append(), ARC_LOW_DEF, BuildConvexHull(), SHAPE_POLY_SET::COutline(), ERROR_OUTSIDE, BOARD_ITEM::GetBoard(), GetPosition(), BOARD::GetTimeStamp(), BOARD::IsFootprintHolder(), m_cachedHull, m_drawings, m_fp_zones, m_hullCacheTimeStamp, m_pads, m_privateLayers, EDA_IU_SCALE::mmToIU(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), pad, PCB_BITMAP_T, PCB_FP_TEXT_T, pcbIUScale, SHAPE_POLY_SET::RemoveAllContours(), and UNDEFINED_LAYER.

Referenced by CoverageRatio(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), GetCoverageArea(), HitTestAccurate(), and PCB_SELECTION_TOOL::hitTestDistance().

◆ GetCenter()

virtual VECTOR2I BOARD_ITEM::GetCenter ( ) const
inlinevirtualinherited

This defaults to the center of the bounding box if not overridden.

Returns
center point of the item

Reimplemented in PAD, PCB_MARKER, PCB_SHAPE, and PCB_ARC.

Definition at line 93 of file board_item.h.

94 {
95 return GetBoundingBox().GetCenter();
96 }
const Vec GetCenter() const
Definition: box2.h:195
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74

References EDA_ITEM::GetBoundingBox(), and BOX2< Vec >::GetCenter().

Referenced by PCB_GRID_HELPER::computeAnchors(), PCB_SELECTION_TOOL::FindItem(), and ALTIUM_PCB::HelperParseDimensions6Radial().

◆ GetClass()

wxString FOOTPRINT::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Implements EDA_ITEM.

Definition at line 702 of file footprint.h.

703 {
704 return wxT( "FOOTPRINT" );
705 }

Referenced by Visit().

◆ GetContextualTextVars()

void FOOTPRINT::GetContextualTextVars ( wxArrayString *  aVars) const

Return the list of system text vars for this footprint.

Definition at line 480 of file footprint.cpp.

481{
482 aVars->push_back( wxT( "REFERENCE" ) );
483 aVars->push_back( wxT( "VALUE" ) );
484 aVars->push_back( wxT( "LAYER" ) );
485 aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
486 aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
487 aVars->push_back( wxT( "NET_NAME(<pad_number>)" ) );
488 aVars->push_back( wxT( "NET_CLASS(<pad_number>)" ) );
489 aVars->push_back( wxT( "PIN_NAME(<pad_number>)" ) );
490}

◆ GetCourtyard()

const SHAPE_POLY_SET & FOOTPRINT::GetCourtyard ( PCB_LAYER_ID  aLayer) const

Used in DRC to test the courtyard area (a complex polygon).

Returns
the courtyard polygon.

Definition at line 2215 of file footprint.cpp.

2216{
2217 if( GetBoard() && GetBoard()->GetTimeStamp() > m_courtyard_cache_timestamp )
2218 const_cast<FOOTPRINT*>( this )->BuildCourtyardCaches();
2219
2220 if( IsBackLayer( aLayer ) )
2222 else
2224}
void BuildCourtyardCaches(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Build complex polygons of the courtyard areas from graphic items on the courtyard layers.
Definition: footprint.cpp:2227
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:922

References BuildCourtyardCaches(), BOARD_ITEM::GetBoard(), IsBackLayer(), m_courtyard_cache_back, m_courtyard_cache_front, and m_courtyard_cache_timestamp.

Referenced by AR_AUTOPLACER::buildFpAreas(), collidesWithArea(), collidesWithCourtyard(), KIGFX::PCB_PAINTER::draw(), DRC_ENGINE::EvalRules(), GetEffectiveShape(), BOARD_INSPECTION_TOOL::InspectClearance(), and DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances().

◆ GetCoverageArea()

double FOOTPRINT::GetCoverageArea ( const BOARD_ITEM aItem,
const GENERAL_COLLECTOR aCollector 
)
static

Return the initial comments block or NULL if none, without transfer of ownership.

Definition at line 2028 of file footprint.cpp.

2029{
2030 int textMargin = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
2031 SHAPE_POLY_SET poly;
2032
2033 if( aItem->Type() == PCB_MARKER_T )
2034 {
2035 const PCB_MARKER* marker = static_cast<const PCB_MARKER*>( aItem );
2036 SHAPE_LINE_CHAIN markerShape;
2037
2038 marker->ShapeToPolygon( markerShape );
2039 return markerShape.Area();
2040 }
2041 else if( aItem->Type() == PCB_GROUP_T )
2042 {
2043 double combinedArea = 0.0;
2044
2045 for( BOARD_ITEM* member : static_cast<const PCB_GROUP*>( aItem )->GetItems() )
2046 combinedArea += GetCoverageArea( member, aCollector );
2047
2048 return combinedArea;
2049 }
2050 if( aItem->Type() == PCB_FOOTPRINT_T )
2051 {
2052 const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( aItem );
2053
2054 poly = footprint->GetBoundingHull();
2055 }
2056 else if( aItem->Type() == PCB_FP_TEXT_T )
2057 {
2058 const FP_TEXT* text = static_cast<const FP_TEXT*>( aItem );
2059
2060 text->TransformTextToPolySet( poly, UNDEFINED_LAYER, textMargin, ARC_LOW_DEF, ERROR_OUTSIDE );
2061 }
2062 else if( aItem->Type() == PCB_FP_TEXTBOX_T )
2063 {
2064 const FP_TEXTBOX* tb = static_cast<const FP_TEXTBOX*>( aItem );
2065
2067 }
2068 else if( aItem->Type() == PCB_SHAPE_T )
2069 {
2070 // Approximate "linear" shapes with just their width squared, as we don't want to consider
2071 // a linear shape as being much bigger than another for purposes of selection filtering
2072 // just because it happens to be really long.
2073
2074 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
2075
2076 switch( shape->GetShape() )
2077 {
2078 case SHAPE_T::SEGMENT:
2079 case SHAPE_T::ARC:
2080 case SHAPE_T::BEZIER:
2081 return shape->GetWidth() * shape->GetWidth();
2082
2083 case SHAPE_T::RECT:
2084 case SHAPE_T::CIRCLE:
2085 case SHAPE_T::POLY:
2086 {
2087 if( !shape->IsFilled() )
2088 return shape->GetWidth() * shape->GetWidth();
2089
2091 }
2092
2093 default:
2095 }
2096 }
2097 else if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
2098 {
2099 double width = static_cast<const PCB_TRACK*>( aItem )->GetWidth();
2100 return width * width;
2101 }
2102 else
2103 {
2105 }
2106
2107 return polygonArea( poly );
2108}
bool IsFilled() const
Definition: eda_shape.h:90
SHAPE_T GetShape() const
Definition: eda_shape.h:113
int GetWidth() const
Definition: eda_shape.h:109
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:2028
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Definition: fp_textbox.cpp:433
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:390
double Area(bool aAbsolute=true) const
Return the area of this chain.
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104

References ARC, ARC_LOW_DEF, SHAPE_LINE_CHAIN::Area(), BEZIER, CIRCLE, ERROR_OUTSIDE, GetBoundingHull(), GetCoverageArea(), GENERAL_COLLECTOR::GetGuide(), PCB_GROUP::GetItems(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetWidth(), EDA_SHAPE::IsFilled(), KI_FALLTHROUGH, KiROUND(), COLLECTORS_GUIDE::OnePixelInIU(), PCB_ARC_T, PCB_FOOTPRINT_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_GROUP_T, PCB_MARKER_T, PCB_SHAPE_T, PCB_TRACE_T, POLY, polygonArea(), RECT, SEGMENT, MARKER_BASE::ShapeToPolygon(), text, BOARD_ITEM::TransformShapeToPolygon(), PCB_SHAPE::TransformShapeToPolygon(), FP_TEXTBOX::TransformTextToPolySet(), EDA_ITEM::Type(), and UNDEFINED_LAYER.

Referenced by GetCoverageArea(), and PCB_SELECTION_TOOL::GuessSelectionCandidates().

◆ GetDescription()

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 145 of file eda_item.h.

146 {
147 constexpr int mask =
149
150 return m_flags & mask;
151 }
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_CHANGED
Item was edited, and modified.
#define IS_NEW
New item, just created.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.

References IS_BROKEN, IS_CHANGED, IS_MOVING, IS_NEW, IS_PASTED, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), SYMBOL_EDITOR_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_SYMBOL::GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow().

◆ GetEffectiveHoleShape()

std::shared_ptr< SHAPE_SEGMENT > BOARD_ITEM::GetEffectiveHoleShape ( ) const
virtualinherited

◆ GetEffectiveShape()

std::shared_ptr< SHAPE > FOOTPRINT::GetEffectiveShape ( PCB_LAYER_ID  aLayer = UNDEFINED_LAYER,
FLASHING  aFlash = FLASHING::DEFAULT 
) const
overridevirtual

Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.

This routine returns a COMPOUND shape (set of simple shapes which make up the pad for use with routing, collision determination, etc).

Note
This list can contain a SHAPE_SIMPLE (a simple single-outline non-intersecting polygon), but should never contain a SHAPE_POLY_SET (a complex polygon consisting of multiple outlines and/or holes).
Parameters
aLayerin case of items spanning multiple layers, only the shapes belonging to aLayer will be returned. Pass UNDEFINED_LAYER to return shapes for all layers.
aFlashoptional parameter allowing a caller to force the pad to be flashed (or not flashed) on the current layer (default is to honour the pad's setting and the current connections for the given layer).

Reimplemented from BOARD_ITEM.

Definition at line 2179 of file footprint.cpp.

2180{
2181 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2182
2183 // There are several possible interpretations here:
2184 // 1) the bounding box (without or without invisible items)
2185 // 2) just the pads and "edges" (ie: non-text graphic items)
2186 // 3) the courtyard
2187
2188 // We'll go with (2) for now, unless the caller is clearly looking for (3)
2189
2190 if( aLayer == F_CrtYd || aLayer == B_CrtYd )
2191 {
2192 const SHAPE_POLY_SET& courtyard = GetCourtyard( aLayer );
2193
2194 if( courtyard.OutlineCount() == 0 ) // malformed/empty polygon
2195 return shape;
2196
2197 shape->AddShape( new SHAPE_SIMPLE( courtyard.COutline( 0 ) ) );
2198 }
2199 else
2200 {
2201 for( PAD* pad : Pads() )
2202 shape->AddShape( pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2203
2204 for( BOARD_ITEM* item : GraphicalItems() )
2205 {
2206 if( item->Type() == PCB_FP_SHAPE_T )
2207 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2208 }
2209 }
2210
2211 return shape;
2212}
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2215
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42

References B_CrtYd, SHAPE_POLY_SET::COutline(), F_CrtYd, GetCourtyard(), GraphicalItems(), SHAPE_POLY_SET::OutlineCount(), pad, Pads(), and PCB_FP_SHAPE_T.

◆ GetFileFormatVersionAtLoad()

int FOOTPRINT::GetFileFormatVersionAtLoad ( ) const
inline

Definition at line 620 of file footprint.h.

References m_fileFormatVersionAtLoad.

◆ GetFlag()

int FOOTPRINT::GetFlag ( ) const
inline

Definition at line 255 of file footprint.h.

255{ return m_arflag; }

References m_arflag.

Referenced by KI_TEST::CheckFootprint(), AR_AUTOPLACER::pickFootprint(), and sortFootprintsByRatsnestSize().

◆ GetFlags()

◆ GetFocusPosition()

virtual const VECTOR2I EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

Similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented in BOARD, PCB_SHAPE, and PCB_TRACK.

Definition at line 256 of file eda_item.h.

256{ return GetPosition(); }
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249

References EDA_ITEM::GetPosition().

Referenced by SCH_EDIT_FRAME::FocusOnItem().

◆ GetFPID()

const LIB_ID & FOOTPRINT::GetFPID ( ) const
inline

Definition at line 212 of file footprint.h.

212{ return m_fpid; }

References m_fpid.

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), BASIC_FOOTPRINT_INFO::BASIC_FOOTPRINT_INFO(), FOOTPRINT_EDIT_FRAME::canCloseWindow(), FOOTPRINT_EDIT_FRAME::ClearModify(), EXPORTER_STEP::composePCB(), CreateDevicesSection(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), doPushPadProperties(), FOOTPRINT_EDITOR_CONTROL::DuplicateFootprint(), FOOTPRINT_EDIT_FRAME::DuplicateFootprint(), FOOTPRINT_EDIT_FRAME::editFootprintProperties(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PCB_EDIT_FRAME::ExchangeFootprint(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), BOARD_EDITOR_CONTROL::ExportNetlist(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), PCB_PLUGIN::FootprintSave(), FP_LIB_TABLE::FootprintSave(), PCB_PLUGIN::format(), PLACE_FILE_EXPORTER::GenPositionData(), FOOTPRINT_EDIT_FRAME::GetLoadedFPID(), GetMsgPanelInfo(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), idf_export_footprint(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), PCBNEW_JOBS_HANDLER::JobExportFpSvg(), LEGACY_PLUGIN::loadFOOTPRINT(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), PCB_EDIT_FRAME::LoadFootprints(), LEGACY_PLUGIN::loadFP_SHAPE(), LEGACY_PLUGIN::loadPAD(), DSN::SPECCTRA_DB::makeIMAGE(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), EAGLE_PLUGIN::packageText(), DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), DIALOG_EXCHANGE_FOOTPRINTS::processMatchingFootprints(), BOARD_NETLIST_UPDATER::replaceFootprint(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), setLibNickname(), PCB_EDIT_FRAME::ShowFootprintPropertiesDialog(), BOARD_NETLIST_UPDATER::testConnectivity(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetFPIDAsString()

wxString FOOTPRINT::GetFPIDAsString ( ) const
inline

Definition at line 215 of file footprint.h.

215{ return m_fpid.Format(); }
UTF8 Format() const
Definition: lib_id.cpp:117

References LIB_ID::Format(), and m_fpid.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ GetFpPadsLocalBbox()

BOX2I FOOTPRINT::GetFpPadsLocalBbox ( ) const

Return the bounding box containing pads when the footprint is on the front side, orientation 0, position 0,0.

Mainly used in Gerber place file to draw a footprint outline when the courtyard is missing or broken.

Returns
The rectangle containing the pads for the normalized footprint.

Definition at line 781 of file footprint.cpp.

782{
783 BOX2I bbox;
784
785 // We want the bounding box of the footprint pads at rot 0, not flipped
786 // Create such a image:
787 FOOTPRINT dummy( *this );
788
789 dummy.SetPosition( VECTOR2I( 0, 0 ) );
790 dummy.SetOrientation( ANGLE_0 );
791
792 if( dummy.IsFlipped() )
793 dummy.Flip( VECTOR2I( 0, 0 ), false );
794
795 for( PAD* pad : dummy.Pads() )
796 bbox.Merge( pad->GetBoundingBox() );
797
798 dummy.SetParent( nullptr );
799
800 return bbox;
801}
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
std::vector< FAB_LAYER_COLOR > dummy
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References ANGLE_0, dummy, BOX2< Vec >::Merge(), and pad.

◆ GetFriendlyName()

wxString EDA_ITEM::GetFriendlyName ( ) const
virtualinherited

Reimplemented in PCB_SHAPE, PCB_TRACK, and ZONE.

Definition at line 310 of file eda_item.cpp.

311{
312 return GetTypeDesc();
313}
wxString GetTypeDesc() const
Return a translated description of the type for this EDA_ITEM for display in user facing messages.
Definition: eda_item.cpp:301

References EDA_ITEM::GetTypeDesc().

Referenced by PROPERTIES_PANEL::rebuildProperties().

◆ GetInitialComments()

const wxArrayString * FOOTPRINT::GetInitialComments ( ) const
inline

Definition at line 784 of file footprint.h.

784{ return m_initial_comments; }

References m_initial_comments.

Referenced by PCB_PLUGIN::format().

◆ GetItemDescription()

wxString FOOTPRINT::GetItemDescription ( UNITS_PROVIDER aUnitsProvider) const
overridevirtual

Return a user-visible description string of this item.

This description is used in disambiguation menus, the message panel, ERC/DRC reports, etc.

The default version of this function raises an assertion in the debug mode and returns a string to indicate that it was not overridden to provide the object specific text.

Returns
The menu text string.

Reimplemented from EDA_ITEM.

Definition at line 1356 of file footprint.cpp.

1357{
1358 wxString reference = GetReference();
1359
1360 if( reference.IsEmpty() )
1361 reference = _( "<no reference designator>" );
1362
1363 return wxString::Format( _( "Footprint %s" ), reference );
1364}
const wxString & GetReference() const
Definition: footprint.h:519

References _, Format(), and GetReference().

Referenced by DRC_ENGINE::EvalRules().

◆ GetKeywords()

◆ GetLayer()

◆ GetLayerName()

wxString BOARD_ITEM::GetLayerName ( ) const
inherited

Return the name of the PCB layer on which the item resides.

Returns
the layer name associated with this item.

Definition at line 94 of file board_item.cpp.

95{
96 const BOARD* board = GetBoard();
97
98 if( board )
99 return board->GetLayerName( m_layer );
100
101 // If no parent, return standard name
103}
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:696
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:452

References BOARD_ITEM::GetBoard(), BOARD::GetLayerName(), BOARD::GetStandardLayerName(), and BOARD_ITEM::m_layer.

Referenced by FP_SHAPE::GetItemDescription(), PCB_DIMENSION_BASE::GetItemDescription(), PCB_SHAPE::GetItemDescription(), PCB_TEXT::GetItemDescription(), PCB_TEXTBOX::GetItemDescription(), PCB_TRACK::GetItemDescription(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_DIM_LEADER::GetMsgPanelInfo(), PCB_SHAPE::GetMsgPanelInfo(), PCB_TARGET::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), FOOTPRINT_SEARCH_HANDLER::GetResultCell(), PCB_TEXT::GetShownText(), PCB_TEXTBOX::GetShownText(), and ResolveTextVar().

◆ GetLayerSet()

virtual LSET BOARD_ITEM::GetLayerSet ( ) const
inlinevirtualinherited

Return a std::bitset of all layers on which the item physically resides.

Reimplemented in PCB_GROUP, PAD, PCB_VIA, and ZONE.

Definition at line 185 of file board_item.h.

186 {
187 if( m_layer == UNDEFINED_LAYER )
188 return LSET();
189 else
190 return LSET( m_layer );
191 }

References BOARD_ITEM::m_layer, and UNDEFINED_LAYER.

Referenced by PCB_GRID_HELPER::BestSnapAnchor(), KI_TEST::CheckFpShape(), collidesWithArea(), BOARD_COMMIT::dirtyIntersectingZones(), APPEARANCE_CONTROLS::doApplyLayerPreset(), DIALOG_GLOBAL_DELETION::DoGlobalDeletions(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), DRAWING_TOOL::DrawVia(), DRC_ENGINE::EvalRules(), existsOnLayerFunc(), extractDiffPairCoupledItems(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_TEXT::Flip(), PCB_TEXTBOX::Flip(), hash_board_item(), BOARD_INSPECTION_TOOL::InspectClearance(), PNS_KICAD_IFACE::IsItemVisible(), isMaskAperture(), BOARD_ITEM::layerMaskDescribe(), FABMASTER::loadZone(), PCB_DIMENSION_BASE::Mirror(), PCB_GRID_HELPER::nearestAnchor(), PCB_POINT_EDITOR::OnSelectionChange(), DIALOG_CLEANUP_GRAPHICS::OnSelectItem(), DIALOG_FOOTPRINT_CHECKER::OnSelectItem(), CN_VISITOR::operator()(), BOARD_ITEM::ptr_cmp::operator()(), KI_TEST::kitest_cmp_drawings::operator()(), DRC_ENGINE::ProcessAssertions(), EDIT_TOOL::Properties(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run(), PCB_SELECTION_CONDITIONS::sameLayerFunc(), PCB_SELECTION_TOOL::selectAllConnectedTracks(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), PANEL_SETUP_LAYERS::TransferDataFromWindow(), and PCB_CONTROL::UpdateMessagePanel().

◆ GetLikelyAttribute()

int FOOTPRINT::GetLikelyAttribute ( ) const

Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)

Returns
0/FP_SMD/FP_THROUGH_HOLE

Definition at line 719 of file footprint.cpp.

720{
721 int smd_count = 0;
722 int tht_count = 0;
723
724 for( PAD* pad : m_pads )
725 {
726 switch( pad->GetProperty() )
727 {
730 continue;
731
734 continue;
735
736 case PAD_PROP::NONE:
737 case PAD_PROP::BGA:
739 break;
740 }
741
742 switch( pad->GetAttribute() )
743 {
744 case PAD_ATTRIB::PTH:
745 tht_count++;
746 break;
747
748 case PAD_ATTRIB::SMD:
749 if( pad->IsOnCopperLayer() )
750 smd_count++;
751
752 break;
753
754 default:
755 break;
756 }
757 }
758
759 if( smd_count > 0 )
760 return FP_SMD;
761
762 if( tht_count > 0 )
763 return FP_THROUGH_HOLE;
764
765 return 0;
766}
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
@ NONE
no special fabrication property
@ TESTPOINT
a test point pad
@ CASTELLATED
a pad with a castellated through hole
@ BGA
Smd pad, used in BGA footprints.

References BGA, CASTELLATED, FIDUCIAL_GLBL, FIDUCIAL_LOCAL, FP_SMD, FP_THROUGH_HOLE, HEATSINK, m_pads, NONE, pad, PTH, SMD, and TESTPOINT.

Referenced by CheckFootprintAttributes().

◆ GetLink()

◆ GetLocalClearance() [1/2]

◆ GetLocalClearance() [2/2]

int FOOTPRINT::GetLocalClearance ( wxString *  aSource) const
inline

Definition at line 233 of file footprint.h.

234 {
235 if( aSource )
236 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
237
238 return m_localClearance;
239 }

References _, Format(), GetReference(), and m_localClearance.

◆ GetLocalSolderMaskMargin()

◆ GetLocalSolderPasteMargin()

◆ GetLocalSolderPasteMarginRatio()

◆ GetMenuImage()

BITMAPS FOOTPRINT::GetMenuImage ( ) const
overridevirtual

Return a pointer to an image to be used in menus.

The default version returns the right arrow image. Override this function to provide object specific menu images.

Returns
The menu image associated with the item.

Reimplemented from EDA_ITEM.

Definition at line 1367 of file footprint.cpp.

1368{
1369 return BITMAPS::module;
1370}

References module.

◆ GetMsgPanelInfo()

void FOOTPRINT::GetMsgPanelInfo ( EDA_DRAW_FRAME aFrame,
std::vector< MSG_PANEL_ITEM > &  aList 
)
overridevirtual

Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.

Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Definition at line 1017 of file footprint.cpp.

1018{
1019 wxString msg, msg2;
1020
1021 aList.emplace_back( m_reference->GetShownText(), m_value->GetShownText() );
1022
1023 if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER )
1025 || aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
1026 {
1027 size_t padCount = GetPadCount( DO_NOT_INCLUDE_NPTH );
1028
1029 aList.emplace_back( _( "Library" ), GetFPID().GetLibNickname().wx_str() );
1030
1031 aList.emplace_back( _( "Footprint Name" ), GetFPID().GetLibItemName().wx_str() );
1032
1033 aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%zu" ), padCount ) );
1034
1035 aList.emplace_back( wxString::Format( _( "Doc: %s" ), GetDescription() ),
1036 wxString::Format( _( "Keywords: %s" ), GetKeywords() ) );
1037
1038 return;
1039 }
1040
1041 // aFrame is the board editor:
1042 aList.emplace_back( _( "Board Side" ), IsFlipped() ? _( "Back (Flipped)" ) : _( "Front" ) );
1043
1044 auto addToken = []( wxString* aStr, const wxString& aAttr )
1045 {
1046 if( !aStr->IsEmpty() )
1047 *aStr += wxT( ", " );
1048
1049 *aStr += aAttr;
1050 };
1051
1052 wxString status;
1053 wxString attrs;
1054
1055 if( IsLocked() )
1056 addToken( &status, _( "Locked" ) );
1057
1058 if( m_fpStatus & FP_is_PLACED )
1059 addToken( &status, _( "autoplaced" ) );
1060
1062 addToken( &attrs, _( "not in schematic" ) );
1063
1065 addToken( &attrs, _( "exclude from pos files" ) );
1066
1068 addToken( &attrs, _( "exclude from BOM" ) );
1069
1070 aList.emplace_back( _( "Status: " ) + status, _( "Attributes:" ) + wxS( " " ) + attrs );
1071
1072 aList.emplace_back( _( "Rotation" ), wxString::Format( wxT( "%.4g" ),
1073 GetOrientation().AsDegrees() ) );
1074
1075 msg.Printf( _( "Footprint: %s" ), m_fpid.GetUniStringLibId() );
1076 msg2.Printf( _( "3D-Shape: %s" ), m_3D_Drawings.empty() ? _( "<none>" )
1077 : m_3D_Drawings.front().m_Filename );
1078 aList.emplace_back( msg, msg2 );
1079
1080 msg.Printf( _( "Doc: %s" ), m_doc );
1081 msg2.Printf( _( "Keywords: %s" ), m_keywords );
1082 aList.emplace_back( msg, msg2 );
1083}
bool IsType(FRAME_T aType) const
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1210
const LIB_ID & GetFPID() const
Definition: footprint.h:212
bool IsLocked() const override
Definition: footprint.h:340
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:415
wxString GetUniStringLibId() const
Definition: lib_id.h:148
@ DO_NOT_INCLUDE_NPTH
Definition: footprint.h:57
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:70
@ FP_BOARD_ONLY
Definition: footprint.h:72
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:71
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:335
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41

References _, DO_NOT_INCLUDE_NPTH, Format(), FP_BOARD_ONLY, FP_EXCLUDE_FROM_BOM, FP_EXCLUDE_FROM_POS_FILES, FP_is_PLACED, FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_VIEWER, FRAME_FOOTPRINT_VIEWER_MODAL, GetDescription(), GetFPID(), GetKeywords(), GetOrientation(), GetPadCount(), FP_TEXT::GetShownText(), LIB_ID::GetUniStringLibId(), IsFlipped(), IsLocked(), EDA_BASE_FRAME::IsType(), m_3D_Drawings, m_attributes, m_doc, m_fpid, m_fpStatus, m_keywords, m_reference, and m_value.

Referenced by PCB_CONTROL::UpdateMessagePanel(), DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel(), FOOTPRINT_EDIT_FRAME::UpdateMsgPanel(), and FOOTPRINT_VIEWER_FRAME::UpdateMsgPanel().

◆ GetNetTiePadGroups()

const std::vector< wxString > & FOOTPRINT::GetNetTiePadGroups ( ) const
inline
Returns
a list of pad groups, each of which is allowed to short nets within their group. A pad group is a comma-separated list of pad numbers.

Definition at line 272 of file footprint.h.

272{ return m_netTiePadGroups; }

References m_netTiePadGroups.

Referenced by FootprintNeedsUpdate(), PCB_PLUGIN::format(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow().

◆ GetNetTiePads()

std::vector< PAD * > FOOTPRINT::GetNetTiePads ( PAD aPad) const
Returns
a list of pads that appear in aPad's net-tie pad group.

Definition at line 2339 of file footprint.cpp.

2340{
2341 // First build a map from pad numbers to allowed-shorting-group indexes. This ends up being
2342 // something like O(3n), but it still beats O(n^2) for large numbers of pads.
2343
2344 std::map<wxString, int> padToNetTieGroupMap = MapPadNumbersToNetTieGroups();
2345 int groupIdx = padToNetTieGroupMap[ aPad->GetNumber() ];
2346 std::vector<PAD*> otherPads;
2347
2348 if( groupIdx >= 0 )
2349 {
2350 for( PAD* pad : m_pads )
2351 {
2352 if( padToNetTieGroupMap[ pad->GetNumber() ] == groupIdx )
2353 otherPads.push_back( pad );
2354 }
2355 }
2356
2357 return otherPads;
2358}

References PAD::GetNumber(), m_pads, MapPadNumbersToNetTieGroups(), and pad.

Referenced by CheckShortingPads().

◆ GetNextPadNumber()

wxString FOOTPRINT::GetNextPadNumber ( const wxString &  aLastPadName) const

Return the next available pad number in the footprint.

Parameters
aFillSequenceGapstrue if the numbering should "fill in" gaps in the sequence, else return the highest value + 1
Returns
the next available pad number

Definition at line 1981 of file footprint.cpp.

1982{
1983 std::set<wxString> usedNumbers;
1984
1985 // Create a set of used pad numbers
1986 for( PAD* pad : m_pads )
1987 usedNumbers.insert( pad->GetNumber() );
1988
1989 // Pad numbers aren't technically reference designators, but the formatting is close enough
1990 // for these to give us what we need.
1991 wxString prefix = UTIL::GetRefDesPrefix( aLastPadNumber );
1992 int num = GetTrailingInt( aLastPadNumber );
1993
1994 while( usedNumbers.count( wxString::Format( wxT( "%s%d" ), prefix, num ) ) )
1995 num++;
1996
1997 return wxString::Format( wxT( "%s%d" ), prefix, num );
1998}
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.

References Format(), UTIL::GetRefDesPrefix(), GetTrailingInt(), m_pads, and pad.

Referenced by EDIT_TOOL::Duplicate().

◆ GetOrientation()

◆ GetOrientationDegrees()

double FOOTPRINT::GetOrientationDegrees ( ) const
inline

Definition at line 207 of file footprint.h.

208 {
209 return m_orient.AsDegrees();
210 }
double AsDegrees() const
Definition: eda_angle.h:149

References EDA_ANGLE::AsDegrees(), and m_orient.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ GetPad()

PAD * FOOTPRINT::GetPad ( const VECTOR2I aPosition,
LSET  aLayerMask = LSET::AllLayersMask() 
)

Get a pad at aPosition on aLayerMask in the footprint.

Parameters
aPositionA VECTOR2I object containing the position to hit test.
aLayerMaskA layer or layers to mask the hit test.
Returns
A pointer to a PAD object if found otherwise NULL.

Definition at line 1194 of file footprint.cpp.

1195{
1196 for( PAD* pad : m_pads )
1197 {
1198 // ... and on the correct layer.
1199 if( !( pad->GetLayerSet() & aLayerMask ).any() )
1200 continue;
1201
1202 if( pad->HitTest( aPosition ) )
1203 return pad;
1204 }
1205
1206 return nullptr;
1207}

References m_pads, and pad.

◆ GetPadCount()

unsigned FOOTPRINT::GetPadCount ( INCLUDE_NPTH_T  aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH)) const

Return the number of pads.

Parameters
aIncludeNPTHincludes non-plated through holes when true. Does not include non-plated through holes when false.
Returns
the number of pads according to aIncludeNPTH.

Definition at line 1210 of file footprint.cpp.

1211{
1212 if( aIncludeNPTH )
1213 return m_pads.size();
1214
1215 unsigned cnt = 0;
1216
1217 for( PAD* pad : m_pads )
1218 {
1219 if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
1220 continue;
1221
1222 cnt++;
1223 }
1224
1225 return cnt;
1226}

References m_pads, NPTH, and pad.

Referenced by BASIC_FOOTPRINT_INFO::BASIC_FOOTPRINT_INFO(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), GetMsgPanelInfo(), FOOTPRINT_INFO_IMPL::load(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), sortFootprintsByComplexity(), and AR_AUTOPLACER::testFootprintOnBoard().

◆ GetParent()

BOARD_ITEM_CONTAINER * BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 163 of file board_item.h.

163{ return (BOARD_ITEM_CONTAINER*) m_parent; }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496

References EDA_ITEM::m_parent.

Referenced by PCB_POINT_EDITOR::addCorner(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), PNS_KICAD_IFACE::Commit(), CoverageRatio(), BOARD_ITEM::DeleteStructure(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), EDIT_TOOL::DragArcTrack(), KIGFX::PCB_PAINTER::draw(), EDIT_TOOL::Duplicate(), PCB_SELECTION_TOOL::FilterCollectorForFreePads(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), PCB_PLUGIN::format(), FormatProbeItem(), BOARD_ITEM::GetBoard(), getClosestGroup(), FP_TEXT::GetItemDescription(), FP_TEXTBOX::GetItemDescription(), BOARD_ITEM::GetParentFootprint(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), FP_TEXT::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXT::GetShownText(), PCB_TEXTBOX::GetShownText(), ALTIUM_PCB::HelperShapeSetLocalCoord(), GENERAL_COLLECTOR::Inspect(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), PCB_SELECTION_TOOL::itemPassesFilter(), memberOfFunc(), EDIT_TOOL::MoveExact(), BRDITEMS_PLOTTER::PlotFootprintShape(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BOARD_COMMIT::Push(), PCB_PARSER::resolveGroups(), PCB_BASE_EDIT_FRAME::saveCopyInUndoList(), CLIPBOARD_IO::SaveSelection(), PCB_SELECTION_TOOL::Selectable(), BOARD_ITEM::SwapItemData(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), FP_ZONE::ViewGetLOD(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetParentFootprint()

◆ GetParentGroup()

◆ GetPath()

◆ GetPosition()

VECTOR2I FOOTPRINT::GetPosition ( ) const
inlineoverridevirtual

Reimplemented from EDA_ITEM.

Definition at line 188 of file footprint.h.

188{ return m_pos; }

References m_pos.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCAD2KICAD::PCB_PAD::AddToFootprint(), KI_TEST::CheckFootprint(), PNS_KICAD_IFACE::Commit(), EXPORTER_STEP::composePCB(), PCB_GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), MICROWAVE_TOOL::createBaseFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), KIGFX::PCB_PAINTER::draw(), PCB_EDIT_FRAME::ExchangeFootprint(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), PCB_PLUGIN::FootprintSave(), PCB_PLUGIN::format(), FP_TEXT::FP_TEXT(), DSN::SPECCTRA_DB::FromSESSION(), GetBoundingHull(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), AR_AUTOPLACER::getOptimalFPPlacement(), PCB_SHAPE::getParentPosition(), hash_fp_item(), ALTIUM_PCB::HelperShapeSetLocalCoord(), idf_export_footprint(), ROUTER_TOOL::InlineDrag(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FABMASTER::loadFootprints(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers(), LEGACY_PLUGIN::loadPAD(), DSN::SPECCTRA_DB::makeIMAGE(), EAGLE_PLUGIN::orientFootprintAndText(), EAGLE_PLUGIN::packageHole(), EAGLE_PLUGIN::packageText(), PAD::PAD(), ALTIUM_PCB::ParseComponentsBodies6Data(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BRDITEMS_PLOTTER::PlotFootprintShape(), RENDER_3D_OPENGL::renderFootprint(), CLIPBOARD_IO::SaveSelection(), DRAWING_TOOL::SetAnchor(), FP_SHAPE::SetDrawCoord(), FP_TEXT::SetDrawCoord(), PAD::SetDrawCoord(), SetLayerAndFlip(), FP_SHAPE::SetLocalCoord(), FP_TEXT::SetLocalCoord(), PAD::SetLocalCoord(), SetOrientation(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), EAGLE_PLUGIN::transferPad(), and zonesNeedUpdate().

◆ GetPrivateLayers()

◆ GetProperties()

const std::map< wxString, wxString > & FOOTPRINT::GetProperties ( ) const
inline

◆ GetProperty()

const wxString & FOOTPRINT::GetProperty ( const wxString &  aKey)
inline

Definition at line 576 of file footprint.h.

576{ return m_properties[ aKey ]; }

References m_properties.

Referenced by getFieldFunc().

◆ GetReference()

const wxString & FOOTPRINT::GetReference ( void  ) const
inline
Returns
reference designator text.

Definition at line 519 of file footprint.h.

520 {
521 return m_reference->GetText();
522 }
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87

References EDA_TEXT::GetText(), and m_reference.

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), AR_AUTOPLACER::AutoplaceFootprints(), BOOST_AUTO_TEST_CASE(), FOOTPRINT_EDIT_FRAME::CanCloseFPFromBoard(), FOOTPRINT_EDIT_FRAME::canCloseWindow(), KI_TEST::CheckFootprint(), collectItemsForSyncParts(), CollisionMatchesExpected(), compareFootprintsbyRef(), EXPORTER_STEP::composePCB(), DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper(), PCB_BASE_FRAME::CreateNewFootprint(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), EDIT_TOOL::doMoveSelection(), BOARD_EDITOR_CONTROL::ExportNetlist(), FormatProbeItem(), GetItemDescription(), GetLocalClearance(), FP_SHAPE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), DIALOG_BOARD_REANNOTATE::GetNewRefDes(), CADSTAR_PCB_ARCHIVE_LOADER::getPadReference(), GetReferenceAsString(), FOOTPRINT_SEARCH_HANDLER::GetResultCell(), getShapeName(), IncrementReference(), GENERAL_COLLECTOR::Inspect(), InvalidMatchesExpected(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), EAGLE_PLUGIN::loadElements(), CADSTAR_PCB_ARCHIVE_LOADER::loadNets(), EDA_3D_CANVAS::OnMouseMove(), EAGLE_PLUGIN::packageText(), BRDITEMS_PLOTTER::PlotFootprintShape(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPad(), DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), BOARD_NETLIST_UPDATER::replaceFootprint(), CLIPBOARD_IO::SaveSelection(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), BOARD_NETLIST_UPDATER::updateFootprintParameters(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetReferenceAsString()

wxString FOOTPRINT::GetReferenceAsString ( ) const
inline

Definition at line 534 of file footprint.h.

535 {
536 return GetReference();
537 }

References GetReference().

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ GetSortPosition()

virtual VECTOR2I EDA_ITEM::GetSortPosition ( ) const
inlinevirtualinherited

Return the coordinates that should be used for sorting this element visually compared to other elements.

For instance, for lines the midpoint might be a better sorting point than either end.

Returns
X,Y coordinate of the sort point

Reimplemented in SCH_LINE.

Definition at line 265 of file eda_item.h.

265{ return GetPosition(); }

References EDA_ITEM::GetPosition().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 123 of file eda_item.h.

124 {
125 return m_status & type;
126 }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:495

References EDA_ITEM::m_status.

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 136 of file eda_item.h.

136{ return m_status; }

References EDA_ITEM::m_status.

◆ GetStroke()

STROKE_PARAMS BOARD_ITEM::GetStroke ( ) const
virtualinherited

Reimplemented in PCB_SHAPE.

Definition at line 82 of file board_item.cpp.

83{
84 wxCHECK( false, STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) ) );
85}
#define DEFAULT_LINE_WIDTH
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88

References DEFAULT_LINE_WIDTH, EDA_IU_SCALE::mmToIU(), and pcbIUScale.

Referenced by CONVERT_TOOL::CreatePolys(), and PCB_BASE_EDIT_FRAME::ShowGraphicItemPropertiesDialog().

◆ GetTypeDesc()

wxString EDA_ITEM::GetTypeDesc ( ) const
inherited

Return a translated description of the type for this EDA_ITEM for display in user facing messages.

Definition at line 301 of file eda_item.cpp.

302{
303 //@see EDA_ITEM_DESC for definition of ENUM_MAP<KICAD_T>
304 wxString typeDescr = ENUM_MAP<KICAD_T>::Instance().ToString( Type() );
305
306 return wxGetTranslation( typeDescr );
307}
static ENUM_MAP< T > & Instance()
Definition: property.h:573

References ENUM_MAP< T >::Instance(), and EDA_ITEM::Type().

Referenced by PCB_GROUP::AddItem(), EDIT_TOOL::doMoveSelection(), and EDA_ITEM::GetFriendlyName().

◆ GetTypeName()

wxString FOOTPRINT::GetTypeName ( ) const

Get the type of footprint.

Returns
"SMD"/"Through hole"/"Other" based on attributes

Definition at line 769 of file footprint.cpp.

770{
771 if( ( m_attributes & FP_SMD ) == FP_SMD )
772 return _( "SMD" );
773
775 return _( "Through hole" );
776
777 return _( "Other" );
778}

References _, FP_SMD, FP_THROUGH_HOLE, and m_attributes.

Referenced by KI_TEST::CheckFootprint(), and CheckFootprintAttributes().

◆ GetUniquePadCount()

unsigned FOOTPRINT::GetUniquePadCount ( INCLUDE_NPTH_T  aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH)) const

Return the number of unique non-blank pads.

A complex pad can be built with many pads having the same pad name to create a complex shape or fragmented solder paste areas.

Parameters
aIncludeNPTHincludes non-plated through holes when true. Does not include non-plated through holes when false.
Returns
the number of unique pads according to aIncludeNPTH.

Definition at line 1229 of file footprint.cpp.

1230{
1231 std::set<wxString> usedNumbers;
1232
1233 // Create a set of used pad numbers
1234 for( PAD* pad : m_pads )
1235 {
1236 // Skip pads not on copper layers (used to build complex
1237 // solder paste shapes for instance)
1238 if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none() )
1239 continue;
1240
1241 // Skip pads with no name, because they are usually "mechanical"
1242 // pads, not "electrical" pads
1243 if( pad->GetNumber().IsEmpty() )
1244 continue;
1245
1246 if( !aIncludeNPTH )
1247 {
1248 // skip NPTH
1249 if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
1250 continue;
1251 }
1252
1253 usedNumbers.insert( pad->GetNumber() );
1254 }
1255
1256 return usedNumbers.size();
1257}

References LSET::AllCuMask(), m_pads, NPTH, and pad.

Referenced by BASIC_FOOTPRINT_INFO::BASIC_FOOTPRINT_INFO(), and FOOTPRINT_INFO_IMPL::load().

◆ GetValue()

◆ GetValueAsString()

wxString FOOTPRINT::GetValueAsString ( ) const
inline

Definition at line 561 of file footprint.h.

562 {
563 return GetValue();
564 }
const wxString & GetValue() const
Definition: footprint.h:547

References GetValue().

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ GetX()

◆ GetY()

◆ GetZoneConnection()

◆ GetZoneSettings()

virtual const ZONE_SETTINGS & BOARD_ITEM_CONTAINER::GetZoneSettings ( ) const
inlinevirtualinherited

Fetch the zone settings for this container.

Reimplemented in BOARD.

Definition at line 86 of file board_item_container.h.

87 {
88 return m_zoneSettings;
89 }

References BOARD_ITEM_CONTAINER::m_zoneSettings.

Referenced by ZONE::ZONE().

◆ GraphicalItems() [1/2]

◆ GraphicalItems() [2/2]

const DRAWINGS & FOOTPRINT::GraphicalItems ( ) const
inline

Definition at line 174 of file footprint.h.

174{ return m_drawings; }

References m_drawings.

◆ Groups() [1/2]

◆ Groups() [2/2]

const FP_GROUPS & FOOTPRINT::Groups ( ) const
inline

Definition at line 180 of file footprint.h.

180{ return m_fp_groups; }

References m_fp_groups.

◆ HasFlag()

◆ HasHole()

◆ HasLineStroke()

virtual bool BOARD_ITEM::HasLineStroke ( ) const
inlinevirtualinherited

Check if this item has line stoke properties.

See also
STROKE_PARAMS

Reimplemented in PCB_SHAPE.

Definition at line 172 of file board_item.h.

172{ return false; }

◆ HasProperty()

bool FOOTPRINT::HasProperty ( const wxString &  aKey)
inline

Definition at line 577 of file footprint.h.

578 {
579 return m_properties.find( aKey ) != m_properties.end();
580 }

References m_properties.

Referenced by getFieldFunc().

◆ HasThroughHolePads()

bool FOOTPRINT::HasThroughHolePads ( ) const

Definition at line 2650 of file footprint.cpp.

2651{
2652 for( PAD* pad : Pads() )
2653 {
2654 if( pad->GetAttribute() != PAD_ATTRIB::SMD )
2655 return true;
2656 }
2657
2658 return false;
2659}

References pad, Pads(), and SMD.

◆ HitTest() [1/2]

bool FOOTPRINT::HitTest ( const BOX2I aRect,
bool  aContained,
int  aAccuracy = 0 
) const
overridevirtual

Test if aRect intersects this item.

Parameters
aRectA reference to a BOX2I object containing the rectangle to test.
aContainedSet to true to test for containment instead of an intersection.
aAccuracyIncrease aRect by this amount.
Returns
True if aRect contains or intersects the item bounding box.

Reimplemented from EDA_ITEM.

Definition at line 1122 of file footprint.cpp.

1123{
1124 BOX2I arect = aRect;
1125 arect.Inflate( aAccuracy );
1126
1127 if( aContained )
1128 {
1129 return arect.Contains( GetBoundingBox( false, false ) );
1130 }
1131 else
1132 {
1133 // If the rect does not intersect the bounding box, skip any tests
1134 if( !aRect.Intersects( GetBoundingBox( false, false ) ) )
1135 return false;
1136
1137 // The empty footprint dummy rectangle intersects the selection area.
1138 if( m_pads.empty() && m_fp_zones.empty() && m_drawings.empty() )
1139 return GetBoundingBox( true, false ).Intersects( arect );
1140
1141 // Determine if any elements in the FOOTPRINT intersect the rect
1142 for( PAD* pad : m_pads )
1143 {
1144 if( pad->HitTest( arect, false, 0 ) )
1145 return true;
1146 }
1147
1148 for( FP_ZONE* zone : m_fp_zones )
1149 {
1150 if( zone->HitTest( arect, false, 0 ) )
1151 return true;
1152 }
1153
1154 for( BOARD_ITEM* item : m_drawings )
1155 {
1156 // Text items are selectable on their own, and are therefore excluded from this
1157 // test. TextBox items are NOT selectable on their own, and so MUST be included
1158 // here. Bitmaps aren't selectable since they aren't displayed.
1159 if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_FP_TEXT_T
1160 && item->HitTest( arect, false, 0 ) )
1161 {
1162 return true;
1163 }
1164 }
1165
1166 // Groups are not hit-tested; only their members
1167
1168 // No items were hit
1169 return false;
1170 }
1171}
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506

References BOX2< Vec >::Contains(), GetBoundingBox(), BOX2< Vec >::Inflate(), BOX2< Vec >::Intersects(), m_drawings, m_fp_zones, m_pads, pad, and PCB_FP_TEXT_T.

◆ HitTest() [2/2]

bool FOOTPRINT::HitTest ( const VECTOR2I aPosition,
int  aAccuracy = 0 
) const
overridevirtual

Test if aPosition is inside or on the boundary of this item.

Parameters
aPositionA reference to a VECTOR2I object containing the coordinates to test.
aAccuracyIncrease the item bounding box by this amount.
Returns
True if aPosition is within the item bounding box.

Reimplemented from EDA_ITEM.

Definition at line 1109 of file footprint.cpp.

1110{
1111 BOX2I rect = GetBoundingBox( false, false );
1112 return rect.Inflate( aAccuracy ).Contains( aPosition );
1113}

References BOX2< Vec >::Contains(), GetBoundingBox(), and BOX2< Vec >::Inflate().

Referenced by GENERAL_COLLECTOR::Inspect().

◆ HitTestAccurate()

bool FOOTPRINT::HitTestAccurate ( const VECTOR2I aPosition,
int  aAccuracy = 0 
) const

Test if a point is inside the bounding polygon of the footprint.

The other hit test methods are just checking the bounding box, which can be quite inaccurate for rotated or oddly-shaped footprints.

Parameters
aPositionis the point to test
Returns
true if aPosition is inside the bounding polygon

Definition at line 1116 of file footprint.cpp.

1117{
1118 return GetBoundingHull().Collide( aPosition, aAccuracy );
1119}
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...

References SHAPE_POLY_SET::Collide(), and GetBoundingHull().

Referenced by GENERAL_COLLECTOR::Inspect().

◆ IncrementFlag()

void FOOTPRINT::IncrementFlag ( )
inline

Definition at line 254 of file footprint.h.

254{ m_arflag += 1; }

References m_arflag.

◆ IncrementReference()

void FOOTPRINT::IncrementReference ( int  aDelta)

Bump the current reference by aDelta.

Definition at line 2001 of file footprint.cpp.

2002{
2003 const wxString& refdes = GetReference();
2004
2005 SetReference( wxString::Format( wxT( "%s%i" ),
2006 UTIL::GetRefDesPrefix( refdes ),
2007 GetTrailingInt( refdes ) + aDelta ) );
2008}
void SetReference(const wxString &aReference)
Definition: footprint.h:528

References Format(), UTIL::GetRefDesPrefix(), GetReference(), GetTrailingInt(), and SetReference().

◆ IsBoardOnly()

bool FOOTPRINT::IsBoardOnly ( ) const
inline

Definition at line 583 of file footprint.h.

583{ return m_attributes & FP_BOARD_ONLY; }

References FP_BOARD_ONLY, and m_attributes.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ IsBrightened()

◆ IsConflicting()

bool FOOTPRINT::IsConflicting ( ) const
Returns
true if the footprint is flagged with conflicting with some item

Definition at line 474 of file footprint.cpp.

475{
476 return HasFlag( COURTYARD_CONFLICT );
477}
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
#define COURTYARD_CONFLICT
temporary set when moving footprints having courtyard overlapping

References COURTYARD_CONFLICT, and EDA_ITEM::HasFlag().

Referenced by ViewGetLayers(), and ViewGetLOD().

◆ IsConnected()

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 107 of file eda_item.h.

107{ return m_flags & ENTERED; }
#define ENTERED
indicates a group has been entered

References ENTERED, and EDA_ITEM::m_flags.

Referenced by KIGFX::PCB_PAINTER::draw().

◆ IsExcludedFromBOM()

bool FOOTPRINT::IsExcludedFromBOM ( ) const
inline

Definition at line 601 of file footprint.h.

References FP_EXCLUDE_FROM_BOM, and m_attributes.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ IsExcludedFromPosFiles()

bool FOOTPRINT::IsExcludedFromPosFiles ( ) const
inline

Definition at line 592 of file footprint.h.

References FP_EXCLUDE_FROM_POS_FILES, and m_attributes.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC().

◆ IsFlipped()

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 201 of file eda_item.h.

201{ return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:497

References EDA_ITEM::m_forceVisible.

Referenced by KIGFX::SCH_PAINTER::draw(), and SCH_FIELD::Print().

◆ IsKnockout()

◆ IsLibNameValid()

bool FOOTPRINT::IsLibNameValid ( const wxString &  aName)
static

Test for validity of a name of a footprint to be used in a footprint library ( no spaces, dir separators ... ).

Parameters
aNameis the name in library to validate.
Returns
true if the given name is valid

Definition at line 1516 of file footprint.cpp.

1517{
1518 const wxChar * invalids = StringLibNameInvalidChars( false );
1519
1520 if( aName.find_first_of( invalids ) != std::string::npos )
1521 return false;
1522
1523 return true;
1524}
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:1527

References StringLibNameInvalidChars().

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::checkFootprintName().

◆ IsLocked()

bool FOOTPRINT::IsLocked ( ) const
inlineoverridevirtual

Reimplemented from BOARD_ITEM.

Definition at line 340 of file footprint.h.

341 {
342 return ( m_fpStatus & FP_is_LOCKED ) != 0;
343 }
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition: footprint.h:334

References FP_is_LOCKED, and m_fpStatus.

Referenced by PCB_EDIT_FRAME::ExchangeFootprint(), PCB_PLUGIN::format(), GetMsgPanelInfo(), itemIsIncludedByFilter(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), and ViewGetLayers().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 102 of file eda_item.h.

102{ return m_flags & IS_CHANGED; }

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNetTie()

bool FOOTPRINT::IsNetTie ( ) const
inline

Definition at line 257 of file footprint.h.

258 {
259 for( const wxString& group : m_netTiePadGroups )
260 {
261 if( !group.IsEmpty() )
262 return true;
263 }
264
265 return false;
266 }

References group, and m_netTiePadGroups.

Referenced by DRC_TEST_PROVIDER_SOLDER_MASK::checkItemMask(), PCB_PLUGIN::format(), DRC_ENGINE::IsNetTieExclusion(), DIALOG_FOOTPRINT_CHECKER::runChecks(), and PAD::SharesNetTieGroup().

◆ IsNew()

◆ IsOnCopperLayer()

virtual bool BOARD_ITEM::IsOnCopperLayer ( ) const
inlinevirtualinherited
Returns
true if the object is on any copper layer, false otherwise.

Reimplemented in PAD, PCB_TRACK, and ZONE.

Definition at line 123 of file board_item.h.

124 {
125 return IsCopperLayer( GetLayer() );
126 }
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825

References BOARD_ITEM::GetLayer(), and IsCopperLayer().

Referenced by CN_CONNECTIVITY_ALGO::Add(), CheckNetTies(), DRC_ENGINE::EvalRules(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_CONNECTED_ITEM::SetNetCode(), and PCB_CONTROL::UpdateMessagePanel().

◆ IsOnLayer()

bool FOOTPRINT::IsOnLayer ( PCB_LAYER_ID  aLayer) const
overridevirtual

A special IsOnLayer for footprints: return true if the footprint contains only items on the given layer, even if that layer is not one of the valid footprint layers F_Cu and B_Cu.

This allows selection of "graphic" footprints that contain only silkscreen, for example.

Reimplemented from BOARD_ITEM.

Definition at line 1086 of file footprint.cpp.

1087{
1088 // If we have any pads, fall back on normal checking
1089 if( !m_pads.empty() )
1090 return m_layer == aLayer;
1091
1092 // No pads? Check if this entire footprint exists on the given layer
1093 for( FP_ZONE* zone : m_fp_zones )
1094 {
1095 if( !zone->IsOnLayer( aLayer ) )
1096 return false;
1097 }
1098
1099 for( BOARD_ITEM* item : m_drawings )
1100 {
1101 if( !item->IsOnLayer( aLayer ) )
1102 return false;
1103 }
1104
1105 return true;
1106}

References m_drawings, m_fp_zones, BOARD_ITEM::m_layer, and m_pads.

◆ IsPlaced()

bool FOOTPRINT::IsPlaced ( ) const
inline

Definition at line 363 of file footprint.h.

363{ return m_fpStatus & FP_is_PLACED; }

References FP_is_PLACED, and m_fpStatus.

Referenced by PCB_PLUGIN::format().

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

Override this method in any derived object that supports test find and replace.

Returns
True if the item has replaceable text that can be modified using the find and replace dialog.

Reimplemented in LIB_TEXTBOX, SCH_FIELD, SCH_LABEL, SCH_SHEET, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, and SCH_TEXTBOX.

Definition at line 420 of file eda_item.h.

420{ return false; }

Referenced by EDA_ITEM::Matches().

◆ IsRollover()

bool EDA_ITEM::IsRollover ( ) const
inlineinherited

Definition at line 110 of file eda_item.h.

111 {
112 return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
113 }
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.

References IS_MOVING, IS_ROLLOVER, and EDA_ITEM::m_flags.

Referenced by KIGFX::SCH_PAINTER::draw().

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 106 of file eda_item.h.

106{ return m_flags & SELECTED; }

References EDA_ITEM::m_flags, and SELECTED.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), EDIT_TOOL::doMoveSelection(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_SCREEN::MarkConnections(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), KIGFX::SCH_PAINTER::nonCached(), SCH_MOVE_TOOL::orthoLineDrag(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), EE_SELECTION_TOOL::RebuildSelection(), PCB_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< T >::saveCopyInUndoList(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), HIERARCHY_PANE::UpdateHierarchySelection(), PCB_BASE_FRAME::UpdateUserUnits(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem().

◆ IsShownAsBitmap()

bool EDA_ITEM::IsShownAsBitmap ( ) const
inlineinherited

Definition at line 173 of file eda_item.h.

173{ return m_flags & IS_SHOWN_AS_BITMAP; }
#define IS_SHOWN_AS_BITMAP

References IS_SHOWN_AS_BITMAP, and EDA_ITEM::m_flags.

◆ IsTented()

virtual bool BOARD_ITEM::IsTented ( ) const
inlinevirtualinherited

Reimplemented in PCB_VIA.

Definition at line 133 of file board_item.h.

134 {
135 return false;
136 }

Referenced by BOARD_INSPECTION_TOOL::InspectClearance(), and DRC_TEST_PROVIDER_SILK_CLEARANCE::Run().

◆ IsType()

virtual bool EDA_ITEM::IsType ( const std::vector< KICAD_T > &  aScanTypes) const
inlinevirtualinherited

Check whether the item is one of the listed types.

Parameters
aScanTypesList of item types
Returns
true if the item type is contained in the list aScanTypes

Reimplemented in SCH_FIELD, SCH_ITEM, SCH_LABEL_BASE, SCH_LINE, FP_SHAPE, FP_TEXT, FP_TEXTBOX, PAD, PCB_DIMENSION_BASE, PCB_SHAPE, PCB_TEXT, PCB_TEXTBOX, and PCB_VIA.

Definition at line 181 of file eda_item.h.

182 {
183 for( KICAD_T scanType : aScanTypes )
184 {
185 if( scanType == SCH_LOCATE_ANY_T || scanType == m_structType )
186 return true;
187 }
188
189 return false;
190 }
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:505
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LOCATE_ANY_T
Definition: typeinfo.h:183

References EDA_ITEM::m_structType, and SCH_LOCATE_ANY_T.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_FIELD::GetCanonicalName(), KIGFX::SCH_PAINTER::getLineWidth(), SCH_FIELD::GetName(), KIGFX::SCH_PAINTER::getRenderColor(), SCH_FIELD::GetShownText(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), SCH_ITEM::IsType(), FP_TEXT::IsType(), FP_TEXTBOX::IsType(), PAD::IsType(), PCB_DIMENSION_BASE::IsType(), PCB_SHAPE::IsType(), PCB_TEXT::IsType(), PCB_TEXTBOX::IsType(), PCB_VIA::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), CONVERT_TOOL::makePolysFromChainedSegs(), EE_SELECTION_TOOL::RequestSelection(), SCH_FIELD::SetId(), SCH_BASE_FRAME::UpdateItem(), and EDA_ITEM::Visit().

◆ IterateForward() [1/2]

template<class T >
static INSPECT_RESULT EDA_ITEM::IterateForward ( std::deque< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const std::vector< KICAD_T > &  scanTypes 
)
inlinestaticinherited

This changes first parameter to avoid the DList and use the main queue instead.

Definition at line 302 of file eda_item.h.

304 {
305 for( const auto& it : aList )
306 {
307 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
308 testData,
309 scanTypes ) == INSPECT_RESULT::QUIT )
310 {
312 }
313 }
314
316 }
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:91

References CONTINUE, QUIT, and EDA_ITEM::Visit().

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

template<class T >
static INSPECT_RESULT EDA_ITEM::IterateForward ( std::vector< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const std::vector< KICAD_T > &  scanTypes 
)
inlinestaticinherited

Change first parameter to avoid the DList and use std::vector instead.

Definition at line 322 of file eda_item.h.

324 {
325 for( const auto& it : aList )
326 {
327 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
328 testData,
329 scanTypes ) == INSPECT_RESULT::QUIT )
330 {
332 }
333 }
334
336 }

References CONTINUE, QUIT, and EDA_ITEM::Visit().

◆ layerMaskDescribe()

wxString BOARD_ITEM::layerMaskDescribe ( ) const
protectedvirtualinherited

Return a string (to be shown to the user) describing a layer mask.

Reimplemented in PCB_VIA.

Definition at line 106 of file board_item.cpp.

107{
108 const BOARD* board = GetBoard();
109 LSET layers = GetLayerSet();
110
111 // Try to be smart and useful. Check all copper first.
112 if( layers[F_Cu] && layers[B_Cu] )
113 return _( "all copper layers" );
114
115 LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
116 LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
117
118 for( LSET testLayers : { copperLayers, techLayers, layers } )
119 {
120 for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
121 {
122 if( testLayers[ bit ] )
123 {
124 wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
125
126 if( testLayers.count() > 1 )
127 layerInfo << wxS( " " ) + _( "and others" );
128
129 return layerInfo;
130 }
131 }
132 }
133
134 // No copper, no technicals: no layer
135 return _( "no layers" );
136}
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:565
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:841
@ PCBNEW_LAYER_ID_START
Definition: layer_ids.h:63
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137

References _, LSET::AllCuMask(), LSET::AllTechMask(), B_Cu, F_Cu, BOARD_ITEM::GetBoard(), BOARD::GetEnabledLayers(), BOARD::GetLayerName(), BOARD_ITEM::GetLayerSet(), PCB_LAYER_ID_COUNT, and PCBNEW_LAYER_ID_START.

Referenced by PAD::GetItemDescription(), PAD::GetMsgPanelInfo(), and PCB_TRACK::GetMsgPanelInfo().

◆ LegacyPadsLocked()

bool FOOTPRINT::LegacyPadsLocked ( ) const
inline

Definition at line 381 of file footprint.h.

381{ return m_fpStatus & FP_PADS_are_LOCKED; }

References FP_PADS_are_LOCKED, and m_fpStatus.

◆ MapPadNumbersToNetTieGroups()

std::map< wxString, int > FOOTPRINT::MapPadNumbersToNetTieGroups ( ) const
Returns
a map from pad numbers to net-tie group indices. If a pad is not a member of a net-tie group its index will be -1.

Definition at line 2284 of file footprint.cpp.

2285{
2286 std::map<wxString, int> padNumberToGroupIdxMap;
2287
2288 for( const PAD* pad : m_pads )
2289 padNumberToGroupIdxMap[ pad->GetNumber() ] = -1;
2290
2291 auto processPad =
2292 [&]( wxString aPad, int aGroup )
2293 {
2294 aPad.Trim( true ).Trim( false );
2295
2296 if( !aPad.IsEmpty() )
2297 padNumberToGroupIdxMap[ aPad ] = aGroup;
2298 };
2299
2300 for( int ii = 0; ii < (int) m_netTiePadGroups.size(); ++ii )
2301 {
2302 wxString group( m_netTiePadGroups[ ii ] );
2303 bool esc = false;
2304 wxString pad;
2305
2306 for( wxUniCharRef ch : group )
2307 {
2308 if( esc )
2309 {
2310 esc = false;
2311 pad.Append( ch );
2312 continue;
2313 }
2314
2315 switch( static_cast<unsigned char>( ch ) )
2316 {
2317 case '\\':
2318 esc = true;
2319 break;
2320
2321 case ',':
2322 processPad( pad, ii );
2323 pad.Clear();
2324 break;
2325
2326 default:
2327 pad.Append( ch );
2328 break;
2329 }
2330 }
2331
2332 processPad( pad, ii );
2333 }
2334
2335 return padNumberToGroupIdxMap;
2336}

References group, m_netTiePadGroups, m_pads, and pad.

Referenced by DRC_TEST_PROVIDER_SOLDER_MASK::checkItemMask(), CheckNetTiePadGroups(), CheckNetTies(), GetNetTiePads(), DRC_ENGINE::IsNetTieExclusion(), GRAPHICS_CLEANER::mergePads(), PAD::SharesNetTieGroup(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem().

◆ Matches() [1/2]

virtual bool EDA_ITEM::Matches ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData 
) const
inlinevirtualinherited

Compare the item against the search criteria in aSearchData.

The base class returns false since many of the objects derived from EDA_ITEM do not have any text to search.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item's text matches the search criteria in aSearchData.

Reimplemented in SCH_MARKER, LIB_TEXTBOX, SCH_FIELD, SCH_LABEL_BASE, SCH_PIN, SCH_SHEET, SCH_SHEET_PIN, SCH_SYMBOL, SCH_TEXT, SCH_TEXTBOX, FP_TEXT, FP_TEXTBOX, NETINFO_ITEM, PCB_MARKER, PCB_TEXT, PCB_TEXTBOX, and ZONE.

Definition at line 382 of file eda_item.h.

383 {
384 return false;
385 }

Referenced by SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_FIND_REPLACE_TOOL::HasMatch(), SCH_MARKER::Matches(), LIB_TEXTBOX::Matches(), SCH_FIELD::Matches(), SCH_LABEL_BASE::Matches(), SCH_PIN::Matches(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), SCH_TEXTBOX::Matches(), FP_TEXT::Matches(), FP_TEXTBOX::Matches(), NETINFO_ITEM::Matches(), PCB_MARKER::Matches(), PCB_TEXT::Matches(), PCB_TEXTBOX::Matches(), ZONE::Matches(), SCH_FIND_REPLACE_TOOL::ReplaceAndFindNext(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ Matches() [2/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
const EDA_SEARCH_DATA aSearchData 
) const
protectedinherited

Compare aText against search criteria in aSearchData.

This is a helper function for simplify derived class logic.

Parameters
aTextA reference to a wxString object containing the string to test.
aSearchDataThe criteria to search against.
Returns
True if aText matches the search criteria in aSearchData.

Definition at line 117 of file eda_item.cpp.

118{
119 wxString text = aText;
120 wxString searchText = aSearchData.findString;
121
122 // Don't match if searching for replaceable item and the item doesn't support text replace.
123 if( aSearchData.searchAndReplace && !IsReplaceable() )
124 return false;
125
126 if( !aSearchData.matchCase )
127 {
128 text.MakeUpper();
129 searchText.MakeUpper();
130 }
131
133 {
134 int ii = 0;
135
136 while( ii < (int) text.length() )
137 {
138 int next = text.find( searchText, ii );
139
140 if( next == wxNOT_FOUND )
141 return false;
142
143 ii = next;
144 next += searchText.length();
145
146 bool startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
147 bool endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
148
149 if( startOK && endOK )
150 return true;
151 else
152 ii++;
153 }
154
155 return false;
156 }
157 else if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WILDCARD )
158 {
159 return text.Matches( searchText );
160 }
161 else
162 {
163 return text.Find( searchText ) != wxNOT_FOUND;
164 }
165}
virtual bool IsReplaceable() const
Override this method in any derived object that supports test find and replace.
Definition: eda_item.h:420
CITER next(CITER it)
Definition: ptree.cpp:126
EDA_SEARCH_MATCH_MODE matchMode

References EDA_SEARCH_DATA::findString, EDA_ITEM::IsReplaceable(), EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::searchAndReplace, text, WHOLEWORD, and WILDCARD.

◆ Models() [1/2]

◆ Models() [2/2]

const std::vector< FP_3DMODEL > & FOOTPRINT::Models ( ) const
inline

Definition at line 185 of file footprint.h.

185{ return m_3D_Drawings; }

References m_3D_Drawings.

◆ Move()

void FOOTPRINT::Move ( const VECTOR2I aMoveVector)
overridevirtual

Move this object.

Parameters
aMoveVectorthe move vector for this object.

Reimplemented from BOARD_ITEM.

Definition at line 1544 of file footprint.cpp.

1545{
1546 VECTOR2I newpos = m_pos + aMoveVector;
1547 SetPosition( newpos );
1548}

References m_pos, and SetPosition().

Referenced by ROUTER_TOOL::InlineDrag(), CLIPBOARD_IO::SaveSelection(), and SpreadFootprints().

◆ MoveAnchorPosition()

void FOOTPRINT::MoveAnchorPosition ( const VECTOR2I aMoveVector)

Move the reference point of the footprint.

It looks like a move footprint: the footprints elements (pads, outlines, edges .. ) are moved However:

  • the footprint position is not modified.
  • the relative (local) coordinates of these items are modified (a move footprint does not change these local coordinates, but changes the footprint position)

Definition at line 1728 of file footprint.cpp.

1729{
1730 /*
1731 * Move the reference point of the footprint
1732 * the footprints elements (pads, outlines, edges .. ) are moved
1733 * but:
1734 * - the footprint position is not modified.
1735 * - the relative (local) coordinates of these items are modified
1736 * - Draw coordinates are updated
1737 */
1738
1739 // Update (move) the relative coordinates relative to the new anchor point.
1740 VECTOR2I moveVector = aMoveVector;
1741 RotatePoint( moveVector, -GetOrientation() );
1742
1743 // Update of the reference and value.
1744 m_reference->SetPos0( m_reference->GetPos0() + moveVector );
1746 m_value->SetPos0( m_value->GetPos0() + moveVector );
1748
1749 // Update the pad local coordinates.
1750 for( PAD* pad : m_pads )
1751 {
1752 pad->SetPos0( pad->GetPos0() + moveVector );
1753 pad->SetDrawCoord();
1754 }
1755
1756 // Update the draw element coordinates.
1757 for( BOARD_ITEM* item : GraphicalItems() )
1758 {
1759 switch( item->Type() )
1760 {
1761 case PCB_FP_SHAPE_T:
1762 case PCB_FP_TEXTBOX_T:
1763 {
1764 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
1765 shape->Move( moveVector );
1766 break;
1767 }
1768
1769 case PCB_FP_TEXT_T:
1770 {
1771 FP_TEXT* text = static_cast<FP_TEXT*>( item );
1772 text->SetPos0( text->GetPos0() + moveVector );
1773 text->SetDrawCoord();
1774 break;
1775 }
1776
1777 default:
1778 break;
1779 }
1780 }
1781
1782 // Update the keepout zones
1783 for( ZONE* zone : Zones() )
1784 {
1785 zone->Move( moveVector );
1786 }
1787
1788 // Update the 3D models
1789 for( FP_3DMODEL& model : Models() )
1790 {
1791 model.m_Offset.x += pcbIUScale.IUTomm( moveVector.x );
1792 model.m_Offset.y -= pcbIUScale.IUTomm( moveVector.y );
1793 }
1794
1795 m_cachedBoundingBox.Move( moveVector );
1796 m_cachedVisibleBBox.Move( moveVector );
1797 m_cachedTextExcludedBBox.Move( moveVector );
1798 m_cachedHull.Move( moveVector );
1799}
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: box2.h:111
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: fp_shape.cpp:355
const VECTOR2I & GetPos0() const
Definition: fp_text.h:124
void SetDrawCoord()
Set relative coordinates.
Definition: fp_text.cpp:203
void SetPos0(const VECTOR2I &aPos)
Definition: fp_text.h:123
void Move(const VECTOR2I &aVector) override
constexpr double IUTomm(int iu) const
Definition: base_units.h:87
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References GetOrientation(), FP_TEXT::GetPos0(), GraphicalItems(), EDA_IU_SCALE::IUTomm(), m_cachedBoundingBox, m_cachedHull, m_cachedTextExcludedBBox, m_cachedVisibleBBox, m_pads, m_reference, m_value, Models(), BOX2< Vec >::Move(), FP_SHAPE::Move(), SHAPE_POLY_SET::Move(), pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, pcbIUScale, RotatePoint(), FP_TEXT::SetDrawCoord(), FP_TEXT::SetPos0(), text, VECTOR2< T >::x, VECTOR2< T >::y, and Zones().

Referenced by CLIPBOARD_IO::SaveSelection(), and DRAWING_TOOL::SetAnchor().

◆ NeedsPlaced()

bool FOOTPRINT::NeedsPlaced ( ) const
inline

Definition at line 372 of file footprint.h.

372{ return m_fpStatus & FP_to_PLACE; }
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition: footprint.h:336

References FP_to_PLACE, and m_fpStatus.

Referenced by AR_AUTOPLACER::pickFootprint().

◆ operator<()

bool EDA_ITEM::operator< ( const EDA_ITEM aItem) const
inherited

Test if another item is less than this object.

Parameters
aItem- Item to compare against.
Returns
- True if aItem is less than the item.

Definition at line 231 of file eda_item.cpp.

232{
233 wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
234 GetClass() ) );
235
236 return false;
237}

References Format(), and EDA_ITEM::GetClass().

◆ operator=() [1/2]

FOOTPRINT & FOOTPRINT::operator= ( const FOOTPRINT aOther)

Definition at line 373 of file footprint.cpp.

374{
375 BOARD_ITEM::operator=( aOther );
376
377 m_pos = aOther.m_pos;
378 m_fpid = aOther.m_fpid;
379 m_attributes = aOther.m_attributes;
380 m_fpStatus = aOther.m_fpStatus;
381 m_orient = aOther.m_orient;
383 m_link = aOther.m_link;
384 m_path = aOther.m_path;
385
392 m_cachedHull = aOther.m_cachedHull;
394
401
402 // Copy reference and value
403 *m_reference = *aOther.m_reference;
404 m_reference->SetParent( this );
405 *m_value = *aOther.m_value;
406 m_value->SetParent( this );
407
408 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
409
410 // Copy pads
411 m_pads.clear();
412
413 for( PAD* pad : aOther.Pads() )
414 {
415 PAD* newPad = new PAD( *pad );
416 ptrMap[ pad ] = newPad;
417 Add( newPad );