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 SetOrientationDegrees (double aOrientation)
 
double GetOrientationDegrees () const
 
const LIB_IDGetFPID () const
 
void SetFPID (const LIB_ID &aFPID)
 
const wxString GetFPIDAsString () const
 
void SetFPIDAsString (const wxString &aFPID)
 
const wxString & GetDescription () const
 
void SetDescription (const wxString &aDoc)
 
const 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 TransformPadsWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aSkipNPTHPadsWihNoCopper=false, bool aSkipPlatedPads=false, bool aSkipNonPlatedPads=false) const
 Generate pads shapes on layer aLayer as polygons and adds these polygons to aCornerBuffer. More...
 
void TransformFPShapesWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, 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 aCornerBuffer. More...
 
void TransformFPTextWithClearanceToPolygonSet (SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
 This function is the same as TransformGraphicShapesWithClearanceToPolygonSet but only generate text. 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)
 
void IncrementReference (int aDelta)
 Bump the current reference by aDelta. More...
 
const wxString & GetValue () const
 
void SetValue (const wxString &aValue)
 
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)
 
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 GetSelectMenuText (UNITS_PROVIDER *aUnitsProvider) const override
 Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. 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...
 
virtual 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 SwapData (BOARD_ITEM *aImage) override
 Swap data between aItem and aImage. 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 PCB_LAYER_ID GetLayer () const
 Return the primary layer this item is on. More...
 
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...
 
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 TransformShapeWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, 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 IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsResized () const
 
bool IsBrightened () const
 
bool IsRollover () const
 
void SetWireImage ()
 
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 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 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 ()
 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 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
 
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 104 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;
76
77 // These are special and mandatory text fields
80
81 m_3D_Drawings.clear();
82}
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:52
PCB_LAYER_ID m_layer
Definition: board_item.h:319
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:812
int m_fpStatus
Definition: footprint.h:787
int m_localSolderPasteMargin
Definition: footprint.h:815
int m_attributes
Definition: footprint.h:786
std::vector< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:826
double m_localSolderPasteMarginRatio
Definition: footprint.h:816
wxArrayString * m_initial_comments
Definition: footprint.h:828
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:802
int m_localClearance
Definition: footprint.h:813
int m_arflag
Definition: footprint.h:822
int m_localSolderMaskMargin
Definition: footprint.h:814
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:804
int m_hullCacheTimeStamp
Definition: footprint.h:806
EDA_ANGLE m_orient
Definition: footprint.h:781
KIID m_link
Definition: footprint.h:823
FP_TEXT * m_value
Definition: footprint.h:784
timestamp_t m_lastEditTime
Definition: footprint.h:821
int m_courtyard_cache_timestamp
Definition: footprint.h:833
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:800
FP_TEXT * m_reference
Definition: footprint.h:783
@ 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:332
@ 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_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 85 of file footprint.cpp.

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

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_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 190 of file footprint.cpp.

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

◆ ~FOOTPRINT()

FOOTPRINT::~FOOTPRINT ( )

Definition at line 197 of file footprint.cpp.

198{
199 // Clean up the owned elements
200 delete m_reference;
201 delete m_value;
202 delete m_initial_comments;
203
204 for( PAD* p : m_pads )
205 delete p;
206
207 m_pads.clear();
208
209 for( FP_ZONE* zone : m_fp_zones )
210 delete zone;
211
212 m_fp_zones.clear();
213
214 for( PCB_GROUP* group : m_fp_groups )
215 delete group;
216
217 m_fp_groups.clear();
218
219 for( BOARD_ITEM* d : m_drawings )
220 delete d;
221
222 m_drawings.clear();
223}
FP_ZONES m_fp_zones
Definition: footprint.h:778
DRAWINGS m_drawings
Definition: footprint.h:776
PADS m_pads
Definition: footprint.h:777
FP_GROUPS m_fp_groups
Definition: footprint.h:779

References 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 549 of file footprint.cpp.

550{
551 switch( aBoardItem->Type() )
552 {
553 case PCB_FP_TEXT_T:
554 // Only user text can be added this way.
555 wxASSERT( static_cast<FP_TEXT*>( aBoardItem )->GetType() == FP_TEXT::TEXT_is_DIVERS );
557
563 case PCB_FP_SHAPE_T:
564 case PCB_FP_TEXTBOX_T:
565 case PCB_BITMAP_T:
566 if( aMode == ADD_MODE::APPEND )
567 m_drawings.push_back( aBoardItem );
568 else
569 m_drawings.push_front( aBoardItem );
570 break;
571
572 case PCB_PAD_T:
573 if( aMode == ADD_MODE::APPEND )
574 m_pads.push_back( static_cast<PAD*>( aBoardItem ) );
575 else
576 m_pads.push_front( static_cast<PAD*>( aBoardItem ) );
577 break;
578
579 case PCB_FP_ZONE_T:
580 if( aMode == ADD_MODE::APPEND )
581 m_fp_zones.push_back( static_cast<FP_ZONE*>( aBoardItem ) );
582 else
583 m_fp_zones.insert( m_fp_zones.begin(), static_cast<FP_ZONE*>( aBoardItem ) );
584 break;
585
586 case PCB_GROUP_T:
587 if( aMode == ADD_MODE::APPEND )
588 m_fp_groups.push_back( static_cast<PCB_GROUP*>( aBoardItem ) );
589 else
590 m_fp_groups.insert( m_fp_groups.begin(), static_cast<PCB_GROUP*>( aBoardItem ) );
591 break;
592
593 default:
594 {
595 wxString msg;
596 msg.Printf( wxT( "FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
597 aBoardItem->Type() );
598 wxFAIL_MSG( msg );
599
600 return;
601 }
602 }
603
604 aBoardItem->ClearEditFlags();
605 aBoardItem->SetParent( this );
606}
@ 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 1237 of file footprint.cpp.

1238{
1239 if( nullptr == a3DModel )
1240 return;
1241
1242 if( !a3DModel->m_Filename.empty() )
1243 m_3D_Drawings.push_back( *a3DModel );
1244}
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:99

References m_3D_Drawings, and FP_3DMODEL::m_Filename.

◆ AddNetTiePadGroup()

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

Definition at line 274 of file footprint.h.

275 {
276 m_netTiePadGroups.emplace_back( aGroup );
277 }

References m_netTiePadGroups.

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow().

◆ 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 2195 of file footprint.cpp.

2196{
2200
2202
2203 // Build the courtyard area from graphic items on the courtyard.
2204 // Only PCB_FP_SHAPE_T have meaning, graphic texts are ignored.
2205 // Collect items:
2206 std::vector<PCB_SHAPE*> list_front;
2207 std::vector<PCB_SHAPE*> list_back;
2208
2209 for( BOARD_ITEM* item : GraphicalItems() )
2210 {
2211 if( item->GetLayer() == B_CrtYd && item->Type() == PCB_FP_SHAPE_T )
2212 list_back.push_back( static_cast<PCB_SHAPE*>( item ) );
2213
2214 if( item->GetLayer() == F_CrtYd && item->Type() == PCB_FP_SHAPE_T )
2215 list_front.push_back( static_cast<PCB_SHAPE*>( item ) );
2216 }
2217
2218 if( !list_front.size() && !list_back.size() )
2219 return;
2220
2221 int errorMax = pcbIUScale.mmToIU( 0.02 ); // max error for polygonization
2222 int chainingEpsilon = pcbIUScale.mmToIU( 0.02 ); // max dist from one endPt to next startPt
2223
2224 if( ConvertOutlineToPolygon( list_front, m_courtyard_cache_front, errorMax, chainingEpsilon,
2225 aErrorHandler ) )
2226 {
2227 // Touching courtyards, or courtyards -at- the clearance distance are legal.
2229
2231 }
2232 else
2233 {
2235 }
2236
2237 if( ConvertOutlineToPolygon( list_back, m_courtyard_cache_back, errorMax, chainingEpsilon,
2238 aErrorHandler ) )
2239 {
2240 // Touching courtyards, or courtyards -at- the clearance distance are legal.
2242
2244 }
2245 else
2246 {
2248 }
2249}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:37
int GetTimeStamp() const
Definition: board.h:288
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:156
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:157
SHAPE_POLY_SET m_courtyard_cache_back
Definition: footprint.h:832
SHAPE_POLY_SET m_courtyard_cache_front
Definition: footprint.h:831
@ CHAMFER_ACUTE_CORNERS
Acute angles are chamfered.
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
void CacheTriangulation(bool aPartition=true)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
bool ConvertOutlineToPolygon(std::vector< PCB_SHAPE * > &aSegList, SHAPE_POLY_SET &aPolygons, int aErrorMax, int aChainingEpsilon, 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 2294 of file footprint.cpp.

2295{
2296 int likelyAttr = GetLikelyAttribute();
2297 int setAttr = ( GetAttributes() & ( FP_SMD | FP_THROUGH_HOLE ) );
2298
2299 // This is only valid if the footprint doesn't have FP_SMD and FP_THROUGH_HOLE set
2300 // Which is, unfortunately, possible in theory but not in the UI (I think)
2301 if( aErrorHandler && likelyAttr != setAttr )
2302 {
2303 wxString msg;
2304
2305 switch( likelyAttr )
2306 {
2307 case FP_THROUGH_HOLE:
2308 msg.Printf( _( "(expected 'Through hole'; actual '%s')" ), GetTypeName() );
2309 break;
2310 case FP_SMD:
2311 msg.Printf( _( "(expected 'SMD'; actual '%s')" ), GetTypeName() );
2312 break;
2313 default:
2314 msg.Printf( _( "(expected 'Other'; actual '%s')" ), GetTypeName() );
2315 break;
2316 }
2317
2318 (aErrorHandler)( msg );
2319 }
2320}
int GetAttributes() const
Definition: footprint.h:245
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:749
int GetLikelyAttribute() const
Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)
Definition: footprint.cpp:701
#define _(s)
@ FP_SMD
Definition: footprint.h:68
@ FP_THROUGH_HOLE
Definition: footprint.h:67

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 2555 of file footprint.cpp.

2556{
2557 std::set<wxString> padNumbers;
2558 wxString msg;
2559
2560 for( size_t ii = 0; ii < m_netTiePadGroups.size(); ++ii )
2561 {
2562 wxStringTokenizer groupParser( m_netTiePadGroups[ ii ], "," );
2563
2564 while( groupParser.HasMoreTokens() )
2565 {
2566 wxString padNumber( groupParser.GetNextToken().Trim( false ).Trim( true ) );
2567 const PAD* pad = FindPadByNumber( padNumber );
2568
2569 if( !pad )
2570 {
2571 msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
2572 aErrorHandler( msg );
2573 }
2574 else if( !padNumbers.insert( pad->GetNumber() ).second )
2575 {
2576 msg.Printf( _( "(pad %s appears in more than one net-tie pad group)" ), padNumber );
2577 aErrorHandler( msg );
2578 }
2579 }
2580 }
2581}
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1151

References _, FindPadByNumber(), m_netTiePadGroups, 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 2449 of file footprint.cpp.

2453{
2454 // First build a map from pad numbers to allowed-shorting-group indexes. This ends up being
2455 // something like O(3n), but it still beats O(n^2) for large numbers of pads.
2456
2457 std::map<wxString, int> padNumberToGroupIdxMap = MapPadNumbersToNetTieGroups();
2458
2459 // Now collect all the footprint items which are on copper layers
2460
2461 std::vector<BOARD_ITEM*> copperItems;
2462
2463 for( BOARD_ITEM* item : m_drawings )
2464 {
2465 if( item->IsOnCopperLayer() )
2466 copperItems.push_back( item );
2467 }
2468
2469 for( ZONE* zone : m_fp_zones )
2470 {
2471 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
2472 copperItems.push_back( zone );
2473 }
2474
2476 copperItems.push_back( m_reference );
2477
2478 if( m_value->IsOnCopperLayer() )
2479 copperItems.push_back( m_value );
2480
2481 for( PCB_LAYER_ID layer : { F_Cu, In1_Cu, B_Cu } )
2482 {
2483 // Next, build a polygon-set for the copper on this layer. We don't really care about
2484 // nets here, we just want to end up with a set of outlines describing the distinct
2485 // copper polygons of the footprint.
2486
2487 SHAPE_POLY_SET copperOutlines;
2488 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
2489
2490 for( BOARD_ITEM* item : copperItems )
2491 {
2492 if( item->IsOnLayer( layer ) )
2493 {
2494 item->TransformShapeWithClearanceToPolygon( copperOutlines, layer, 0,
2496 }
2497 }
2498
2499 copperOutlines.Simplify( SHAPE_POLY_SET::PM_FAST );
2500
2501 // Index each pad to the outline in the set that it is part of.
2502
2503 for( const PAD* pad : m_pads )
2504 {
2505 for( int ii = 0; ii < copperOutlines.OutlineCount(); ++ii )
2506 {
2507 if( pad->GetEffectiveShape( layer )->Collide( &copperOutlines.Outline( ii ), 0 ) )
2508 outlineIdxToPadsMap[ ii ].emplace_back( pad );
2509 }
2510 }
2511
2512 // Finally, ensure that each outline which contains multiple pads has all its pads
2513 // listed in an allowed-shorting group.
2514
2515 for( const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
2516 {
2517 if( pads.size() > 1 )
2518 {
2519 const PAD* firstPad = pads[0];
2520 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->GetNumber() ];
2521
2522 for( size_t ii = 1; ii < pads.size(); ++ii )
2523 {
2524 const PAD* thisPad = pads[ii];
2525 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->GetNumber() ];
2526
2527 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
2528 {
2529 BOARD_ITEM* shortingItem = nullptr;
2530 VECTOR2I pos = ( firstPad->GetPosition() + thisPad->GetPosition() ) / 2;
2531
2532 pos = copperOutlines.Outline( outlineIdx ).NearestPoint( pos );
2533
2534 for( BOARD_ITEM* item : copperItems )
2535 {
2536 if( item->HitTest( pos, 1 ) )
2537 {
2538 shortingItem = item;
2539 break;
2540 }
2541 }
2542
2543 if( shortingItem )
2544 aErrorHandler( shortingItem, firstPad, thisPad, pos );
2545 else
2546 aErrorHandler( firstPad, thisPad, nullptr, pos );
2547 }
2548 }
2549 }
2550 }
2551 }
2552}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
virtual bool IsOnCopperLayer() const
Definition: board_item.h:115
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
Definition: footprint.cpp:2252
const wxString & GetNumber() const
Definition: pad.h:134
VECTOR2I GetPosition() const override
Definition: pad.h:196
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 2323 of file footprint.cpp.

2325{
2326 if( aErrorHandler == nullptr )
2327 return;
2328
2329 for( PAD* pad: Pads() )
2330 {
2331 if( pad->GetAttribute() == PAD_ATTRIB::PTH || pad->GetAttribute() == PAD_ATTRIB::NPTH )
2332 {
2333 if( pad->GetDrillSizeX() < 1 || pad->GetDrillSizeY() < 1 )
2334 (aErrorHandler)( pad, DRCE_PAD_TH_WITH_NO_HOLE, wxEmptyString );
2335 }
2336
2337 if( pad->GetAttribute() == PAD_ATTRIB::PTH )
2338 {
2339 if( !pad->IsOnCopperLayer() )
2340 {
2341 (aErrorHandler)( pad, DRCE_PADSTACK, _( "(PTH pad has no copper layers)" ) );
2342 }
2343 else
2344 {
2345 LSET lset = pad->GetLayerSet() & LSET::AllCuMask();
2346 PCB_LAYER_ID layer = lset.Seq().at( 0 );
2347 SHAPE_POLY_SET padOutline;
2348
2349 pad->TransformShapeWithClearanceToPolygon( padOutline, layer, 0, ARC_HIGH_DEF,
2351
2352 std::shared_ptr<SHAPE_SEGMENT> hole = pad->GetEffectiveHoleShape();
2353 SHAPE_POLY_SET holeOutline;
2354
2355 TransformOvalToPolygon( holeOutline, hole->GetSeg().A, hole->GetSeg().B,
2356 hole->GetWidth(), ARC_HIGH_DEF, ERROR_LOC::ERROR_INSIDE );
2357
2358 padOutline.BooleanSubtract( holeOutline, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
2359
2360 if( padOutline.IsEmpty() )
2361 aErrorHandler( pad, DRCE_PADSTACK, _( "(PTH pad's hole leaves no copper)" ) );
2362 }
2363 }
2364
2365 if( pad->GetAttribute() == PAD_ATTRIB::SMD )
2366 {
2367 if( pad->IsOnLayer( F_Cu ) && pad->IsOnLayer( B_Cu ) )
2368 {
2369 aErrorHandler( pad, DRCE_PADSTACK,
2370 _( "(SMD pad appears on both front and back copper)" ) );
2371 }
2372 else if( pad->IsOnLayer( F_Cu ) )
2373 {
2374 if( pad->IsOnLayer( B_Mask ) )
2375 {
2376 aErrorHandler( pad, DRCE_PADSTACK,
2377 _( "(SMD pad copper and mask layers don't match)" ) );
2378 }
2379 else if( pad->IsOnLayer( B_Paste ) )
2380 {
2381 aErrorHandler( pad, DRCE_PADSTACK,
2382 _( "(SMD pad copper and paste layers don't match)" ) );
2383 }
2384 }
2385 else if( pad->IsOnLayer( B_Cu ) )
2386 {
2387 if( pad->IsOnLayer( F_Mask ) )
2388 {
2389 aErrorHandler( pad, DRCE_PADSTACK,
2390 _( "(SMD pad copper and mask layers don't match)" ) );
2391 }
2392 else if( pad->IsOnLayer( F_Paste ) )
2393 {
2394 aErrorHandler( pad, DRCE_PADSTACK,
2395 _( "(SMD pad copper and paste layers don't match)" ) );
2396 }
2397 }
2398 }
2399 }
2400}
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 &aCornerBuffer, 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 2403 of file footprint.cpp.

2405{
2406 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
2407
2408 for( PAD* pad : Pads() )
2409 {
2410 std::vector<PAD*> netTiePads = GetNetTiePads( pad );
2411
2412 for( PAD* other : Pads() )
2413 {
2414 if( other == pad || pad->SameLogicalPadAs( other ) )
2415 continue;
2416
2417 if( alg::contains( netTiePads, other ) )
2418 continue;
2419
2420 if( !( ( pad->GetLayerSet() & other->GetLayerSet() ) & LSET::AllCuMask() ).any() )
2421 continue;
2422
2423 // store canonical order so we don't collide in both directions (a:b and b:a)
2424 PAD* a = pad;
2425 PAD* b = other;
2426
2427 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
2428 std::swap( a, b );
2429
2430 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
2431 {
2432 checkedPairs[ { a, b } ] = 1;
2433
2434 if( pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
2435 {
2436 VECTOR2I pos;
2437 SHAPE* padShape = pad->GetEffectiveShape().get();
2438 SHAPE* otherShape = other->GetEffectiveShape().get();
2439
2440 if( padShape->Collide( otherShape, 0, nullptr, &pos ) )
2441 aErrorHandler( pad, other, pos );
2442 }
2443 }
2444 }
2445 }
2446}
std::vector< PAD * > GetNetTiePads(PAD *aPad) const
Definition: footprint.cpp:2272
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 119 of file footprint.h.

120 {
121 return aItem && aItem->Type() == PCB_FOOTPRINT_T;
122 }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:111

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 540 of file footprint.cpp.

541{
542 // Force the ORPHANED dummy net info for all pads.
543 // ORPHANED dummy net does not depend on a board
544 for( PAD* pad : m_pads )
545 pad->SetNetCode( NETINFO_LIST::ORPHANED );
546}
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:377

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 157 of file eda_item.h.

157{ m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:512

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), BuildCourtyardCaches(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), ConvertOutlineToPolygon(), 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(), 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_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::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(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetIsShownAsBitmap(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and EE_SELECTION_TOOL::unhighlight().

◆ ClearNetTiePadGroups()

void FOOTPRINT::ClearNetTiePadGroups ( )
inline

Definition at line 269 of file footprint.h.

270 {
271 m_netTiePadGroups.clear();
272 }

References m_netTiePadGroups.

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 169 of file eda_item.h.

170 {
172 }
#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 DO_NOT_DRAW
Used to disable draw function.
#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(), DO_NOT_DRAW, 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 1350 of file footprint.cpp.

1351{
1352 return new FOOTPRINT( *this );
1353}
FOOTPRINT(BOARD *parent)
Definition: footprint.cpp:55

References FOOTPRINT().

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), 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 2078 of file footprint.cpp.

2079{
2080 int textMargin = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
2081
2082 SHAPE_POLY_SET footprintRegion( GetBoundingHull() );
2083 SHAPE_POLY_SET coveredRegion;
2084
2086 ERROR_OUTSIDE );
2087
2088 TransformFPShapesWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, textMargin,
2090 true, /* include text */
2091 false, /* include shapes */
2092 false /* include private items */ );
2093
2094 for( int i = 0; i < aCollector.GetCount(); ++i )
2095 {
2096 const BOARD_ITEM* item = aCollector[i];
2097
2098 switch( item->Type() )
2099 {
2100 case PCB_FP_TEXT_T:
2101 case PCB_FP_TEXTBOX_T:
2102 case PCB_FP_SHAPE_T:
2103 if( item->GetParent() != this )
2104 {
2107 }
2108 break;
2109
2110 case PCB_TEXT_T:
2111 case PCB_TEXTBOX_T:
2112 case PCB_SHAPE_T:
2113 case PCB_TRACE_T:
2114 case PCB_ARC_T:
2115 case PCB_VIA_T:
2118 break;
2119
2120 case PCB_FOOTPRINT_T:
2121 if( item != this )
2122 {
2123 const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( item );
2124 coveredRegion.AddOutline( footprint->GetBoundingHull().Outline( 0 ) );
2125 }
2126 break;
2127
2128 default:
2129 break;
2130 }
2131 }
2132
2133 double footprintRegionArea = polygonArea( footprintRegion );
2134 double uncoveredRegionArea = footprintRegionArea - polygonArea( coveredRegion );
2135 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2136 double ratio = ( coveredArea / footprintRegionArea );
2137
2138 // Test for negative ratio (should not occur).
2139 // better to be conservative (this will result in the disambiguate dialog)
2140 if( ratio < 0.0 )
2141 return 1.0;
2142
2143 return std::min( ratio, 1.0 );
2144}
constexpr int ARC_LOW_DEF
Definition: base_units.h:120
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:152
virtual void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
Definition: board_item.cpp:172
virtual double OnePixelInIU() const =0
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
void TransformFPShapesWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, 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 aC...
Definition: footprint.cpp:2761
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:913
void TransformPadsWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aSkipNPTHPadsWihNoCopper=false, bool aSkipPlatedPads=false, bool aSkipNonPlatedPads=false) const
Generate pads shapes on layer aLayer as polygons and adds these polygons to aCornerBuffer.
Definition: footprint.cpp:2683
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:1975
@ 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:80

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(), TransformFPShapesWithClearanceToPolygon(), TransformPadsWithClearanceToPolygon(), BOARD_ITEM::TransformShapeWithClearanceToPolygon(), 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 144 of file board_item.cpp.

145{
147
148 if( parent )
149 parent->Remove( this );
150
151 delete this;
152}
Abstract interface for BOARD_ITEMs capable of storing other items inside.

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

Referenced by BOARD::PadDelete(), and 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 1819 of file footprint.cpp.

1820{
1821 FOOTPRINT* dupe = static_cast<FOOTPRINT*>( BOARD_ITEM::Duplicate() );
1822
1823 dupe->RunOnChildren( [&]( BOARD_ITEM* child )
1824 {
1825 const_cast<KIID&>( child->m_Uuid ) = KIID();
1826 });
1827
1828 return dupe;
1829}
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:160
const KIID m_Uuid
Definition: eda_item.h:506
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:1356
Definition: kiid.h:47

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 1832 of file footprint.cpp.

1833{
1834 BOARD_ITEM* new_item = nullptr;
1835 FP_ZONE* new_zone = nullptr;
1836
1837 switch( aItem->Type() )
1838 {
1839 case PCB_PAD_T:
1840 {
1841 PAD* new_pad = new PAD( *static_cast<const PAD*>( aItem ) );
1842 const_cast<KIID&>( new_pad->m_Uuid ) = KIID();
1843
1844 if( aAddToFootprint )
1845 m_pads.push_back( new_pad );
1846
1847 new_item = new_pad;
1848 break;
1849 }
1850
1851 case PCB_FP_ZONE_T:
1852 {
1853 new_zone = new FP_ZONE( *static_cast<const FP_ZONE*>( aItem ) );
1854 const_cast<KIID&>( new_zone->m_Uuid ) = KIID();
1855
1856 if( aAddToFootprint )
1857 m_fp_zones.push_back( new_zone );
1858
1859 new_item = new_zone;
1860 break;
1861 }
1862
1863 case PCB_FP_TEXT_T:
1864 {
1865 FP_TEXT* new_text = new FP_TEXT( *static_cast<const FP_TEXT*>( aItem ) );
1866 const_cast<KIID&>( new_text->m_Uuid ) = KIID();
1867
1868 if( new_text->GetType() == FP_TEXT::TEXT_is_REFERENCE )
1869 {
1870 new_text->SetText( wxT( "${REFERENCE}" ) );
1871 new_text->SetType( FP_TEXT::TEXT_is_DIVERS );
1872 }
1873 else if( new_text->GetType() == FP_TEXT::TEXT_is_VALUE )
1874 {
1875 new_text->SetText( wxT( "${VALUE}" ) );
1876 new_text->SetType( FP_TEXT::TEXT_is_DIVERS );
1877 }
1878
1879 if( aAddToFootprint )
1880 Add( new_text );
1881
1882 new_item = new_text;
1883
1884 break;
1885 }
1886
1887 case PCB_FP_SHAPE_T:
1888 {
1889 FP_SHAPE* new_shape = new FP_SHAPE( *static_cast<const FP_SHAPE*>( aItem ) );
1890 const_cast<KIID&>( new_shape->m_Uuid ) = KIID();
1891
1892 if( aAddToFootprint )
1893 Add( new_shape );
1894
1895 new_item = new_shape;
1896 break;
1897 }
1898
1899 case PCB_FP_TEXTBOX_T:
1900 {
1901 FP_TEXTBOX* new_textbox = new FP_TEXTBOX( *static_cast<const FP_TEXTBOX*>( aItem ) );
1902 const_cast<KIID&>( new_textbox->m_Uuid ) = KIID();
1903
1904 if( aAddToFootprint )
1905 Add( new_textbox );
1906
1907 new_item = new_textbox;
1908 break;
1909 }
1910
1916 {
1917 PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( aItem->Duplicate() );
1918
1919 if( aAddToFootprint )
1920 Add( dimension );
1921
1922 new_item = dimension;
1923 break;
1924 }
1925
1926 case PCB_GROUP_T:
1927 new_item = static_cast<const PCB_GROUP*>( aItem )->DeepDuplicate();
1928 break;
1929
1930 case PCB_FOOTPRINT_T:
1931 // Ignore the footprint itself
1932 break;
1933
1934 default:
1935 // Un-handled item for duplication
1936 wxFAIL_MSG( wxT( "Duplication not supported for items of class " ) + aItem->GetClass() );
1937 break;
1938 }
1939
1940 return new_item;
1941}
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 1151 of file footprint.cpp.

1152{
1153 bool can_select = aSearchAfterMe ? false : true;
1154
1155 for( PAD* pad : m_pads )
1156 {
1157 if( !can_select && pad == aSearchAfterMe )
1158 {
1159 can_select = true;
1160 continue;
1161 }
1162
1163 if( can_select && pad->GetNumber() == aPadNumber )
1164 return pad;
1165 }
1166
1167 return nullptr;
1168}

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 226 of file footprint.cpp.

227{
228 // replace null UUIDs if any by a valid uuid
229 std::vector< BOARD_ITEM* > item_list;
230
231 item_list.push_back( m_reference );
232 item_list.push_back( m_value );
233
234 for( PAD* pad : m_pads )
235 item_list.push_back( pad );
236
237 for( BOARD_ITEM* gr_item : m_drawings )
238 item_list.push_back( gr_item );
239
240 // Note: one cannot fix null UUIDs inside the group, but it should not happen
241 // because null uuids can be found in old footprints, therefore without group
242 for( PCB_GROUP* group : m_fp_groups )
243 item_list.push_back( group );
244
245 // Probably notneeded, because old fp do not have zones. But just in case.
246 for( FP_ZONE* zone : m_fp_zones )
247 item_list.push_back( zone );
248
249 bool changed = false;
250
251 for( BOARD_ITEM* item : item_list )
252 {
253 if( item->m_Uuid == niluuid )
254 {
255 const_cast<KIID&>( item->m_Uuid ) = KIID();
256 changed = true;
257 }
258 }
259
260 return changed;
261}
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 1553 of file footprint.cpp.

1554{
1555 // Move footprint to its final position:
1556 VECTOR2I finalPos = m_pos;
1557
1558 // Now Flip the footprint.
1559 // Flipping a footprint is a specific transform: it is not mirrored like a text.
1560 // We have to change the side, and ensure the footprint rotation is modified according to the
1561 // transform, because this parameter is used in pick and place files, and when updating the
1562 // footprint from library.
1563 // When flipped around the X axis (Y coordinates changed) orientation is negated
1564 // When flipped around the Y axis (X coordinates changed) orientation is 180 - old orient.
1565 // Because it is specific to a footprint, we flip around the X axis, and after rotate 180 deg
1566
1567 MIRROR( finalPos.y, aCentre.y );
1568
1569 SetPosition( finalPos );
1570
1571 // Flip layer
1572 SetLayer( FlipLayer( GetLayer() ) );
1573
1574 // Reverse mirror orientation.
1575 m_orient = -m_orient;
1577
1578 // Mirror pads to other side of board.
1579 for( PAD* pad : m_pads )
1580 pad->Flip( m_pos, false );
1581
1582 // Mirror zones to other side of board.
1583 for( ZONE* zone : m_fp_zones )
1584 zone->Flip( m_pos, false );
1585
1586 // Mirror reference and value.
1587 m_reference->Flip( m_pos, false );
1588 m_value->Flip( m_pos, false );
1589
1590 // Reverse mirror footprint graphics and texts.
1591 for( BOARD_ITEM* item : m_drawings )
1592 {
1593 switch( item->Type() )
1594 {
1595 case PCB_FP_SHAPE_T:
1596 static_cast<FP_SHAPE*>( item )->Flip( m_pos, false );
1597 break;
1598
1599 case PCB_FP_TEXT_T:
1600 static_cast<FP_TEXT*>( item )->Flip( m_pos, false );
1601 break;
1602
1603 case PCB_FP_TEXTBOX_T:
1604 static_cast<FP_TEXTBOX*>( item )->Flip( m_pos, false );
1605 break;
1606
1612 static_cast<PCB_DIMENSION_BASE*>( item )->Flip( m_pos, false );
1613 break;
1614
1615 default:
1616 wxMessageBox( wxString::Format( wxT( "FOOTPRINT::Flip() error: Unknown Draw Type %d" ),
1617 (int)item->Type() ) );
1618 break;
1619 }
1620 }
1621
1622 // Now rotate 180 deg if required
1623 if( aFlipLeftRight )
1624 Rotate( aCentre, ANGLE_180 );
1625
1629
1630 m_cachedHull.Mirror( aFlipLeftRight, !aFlipLeftRight, m_pos );
1631
1633}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:169
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:203
EDA_ANGLE Normalize180()
Definition: eda_angle.h:271
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1636
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: footprint.cpp:1528
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1553
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(), BOARD_ITEM::GetLayer(), m_boundingBoxCacheTimeStamp, m_cachedHull, m_courtyard_cache_back, m_courtyard_cache_front, 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(), EDIT_TOOL::Swap(), 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 342 of file drc_test_provider_library_parity.cpp.

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

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:270
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:63
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
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:60
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42

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(), 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 691 of file footprint.cpp.

692{
693 BOX2I bbox = GetBoundingBox( false, false );
694
695 double w = std::abs( static_cast<double>( bbox.GetWidth() ) ) + aPadding;
696 double h = std::abs( static_cast<double>( bbox.GetHeight() ) ) + aPadding;
697 return w * h;
698}
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:782
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(), sortFootprintsByRatsnestSize(), and SpreadFootprints().

◆ GetAttributes()

◆ GetBoard() [1/2]

BOARD * BOARD_ITEM::GetBoard ( )
virtualinherited

Definition at line 51 of file board_item.cpp.

52{
53 if( Type() == PCB_T )
54 return static_cast<BOARD*>( this );
55
56 BOARD_ITEM* parent = GetParent();
57
58 if( parent )
59 return parent->GetBoard();
60
61 return nullptr;
62}
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
@ 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 37 of file board_item.cpp.

38{
39 if( Type() == PCB_T )
40 return static_cast<const BOARD*>( this );
41
42 BOARD_ITEM* parent = GetParent();
43
44 if( parent )
45 return parent->GetBoard();
46
47 return nullptr;
48}

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

Referenced by ZONE_FILLER::addHoleKnockout(), BOARD_ADAPTER::addShape(), BuildCourtyardCaches(), PAD::BuildEffectivePolygon(), PAD::BuildEffectiveShapes(), ZONE::BuildSmoothedPoly(), collidesWithArea(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), enclosedByAreaFunc(), existsOnLayerFunc(), PAD::FlashLayer(), PCB_VIA::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(), fromToFunc(), BOARD_ITEM::GetBoard(), PCB_EXPR_CONTEXT::GetBoard(), NETINFO_ITEM::GetBoundingBox(), GetBoundingBox(), GetBoundingHull(), GetCourtyard(), BOARD_CONNECTED_ITEM::GetEffectiveNetClass(), PCB_VIA::GetEffectiveShape(), getFieldFunc(), ZONE::GetInteractingZones(), 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(), ZONE::GetSelectMenuText(), PCB_MARKER::GetSeverity(), FP_TEXT::GetShownText(), FP_TEXTBOX::GetShownText(), PAD::GetSolderMaskExpansion(), PCB_VIA::GetSolderMaskExpansion(), PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), PCB_TRACK::GetWidthConstraint(), inDiffPairFunc(), intersectsAreaFunc(), intersectsBackCourtyardFunc(), intersectsCourtyardFunc(), intersectsFrontCourtyardFunc(), BOARD_ITEM::IsLocked(), PCB_VIA::IsTented(), BOARD_ITEM::layerMaskDescribe(), PCB_VIA::layerMaskDescribe(), PAD::MergePrimitivesAsPolygon(), DIALOG_TEXTBOX_PROPERTIES::onBorderChecked(), EAGLE_PLUGIN::packageWire(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD::ResolveDRCExclusions(), 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(), ViewBBox(), PCB_TRACK::ViewBBox(), PAD::ViewGetLOD(), PCB_BITMAP::ViewGetLOD(), and PCB_VIA::ViewGetLOD().

◆ 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 782 of file footprint.cpp.

783{
784 return GetBoundingBox( true, true );
785}

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(), moveFootprintsInArea(), 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 788 of file footprint.cpp.

789{
790 const BOARD* board = GetBoard();
791 bool isFPEdit = board && board->IsFootprintHolder();
792
793 if( board )
794 {
795 if( aIncludeText && aIncludeInvisibleText )
796 {
798 return m_cachedBoundingBox;
799 }
800 else if( aIncludeText )
801 {
803 return m_cachedVisibleBBox;
804 }
805 else
806 {
809 }
810 }
811
812 BOX2I bbox( m_pos );
813 bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
814
815 for( BOARD_ITEM* item : m_drawings )
816 {
817 if( m_privateLayers.test( item->GetLayer() ) && !isFPEdit )
818 continue;
819
820 // We want the bitmap bounding box just in the footprint editor
821 // so it will start with the correct initial zoom
822 if( item->Type() == PCB_BITMAP_T && !isFPEdit )
823 continue;
824
825 // Handle text separately
826 if( item->Type() == PCB_FP_TEXT_T )
827 continue;
828
829 bbox.Merge( item->GetBoundingBox() );
830 }
831
832 for( PAD* pad : m_pads )
833 bbox.Merge( pad->GetBoundingBox() );
834
835 for( FP_ZONE* zone : m_fp_zones )
836 bbox.Merge( zone->GetBoundingBox() );
837
838 bool noDrawItems = ( m_drawings.empty() && m_pads.empty() && m_fp_zones.empty() );
839
840 // Groups do not contribute to the rect, only their members
841 if( aIncludeText || noDrawItems )
842 {
843 for( BOARD_ITEM* item : m_drawings )
844 {
845 if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
846 continue;
847
848 // Only FP_TEXT items are independently selectable; FP_TEXTBOX items go in with
849 // other graphic items above.
850 if( item->Type() == PCB_FP_TEXT_T )
851 bbox.Merge( item->GetBoundingBox() );
852 }
853
854 // This can be further optimized when aIncludeInvisibleText is true, but currently
855 // leaving this as is until it's determined there is a noticeable speed hit.
856 bool valueLayerIsVisible = true;
857 bool refLayerIsVisible = true;
858
859 if( board )
860 {
861 // The first "&&" conditional handles the user turning layers off as well as layers
862 // not being present in the current PCB stackup. Values, references, and all
863 // footprint text can also be turned off via the GAL meta-layers, so the 2nd and
864 // 3rd "&&" conditionals handle that.
865 valueLayerIsVisible = board->IsLayerVisible( m_value->GetLayer() )
867 && board->IsElementVisible( LAYER_MOD_TEXT );
868
869 refLayerIsVisible = board->IsLayerVisible( m_reference->GetLayer() )
871 && board->IsElementVisible( LAYER_MOD_TEXT );
872 }
873
874
875 if( ( m_value->IsVisible() && valueLayerIsVisible )
876 || aIncludeInvisibleText
877 || noDrawItems )
878 {
879 bbox.Merge( m_value->GetBoundingBox() );
880 }
881
882 if( ( m_reference->IsVisible() && refLayerIsVisible )
883 || aIncludeInvisibleText
884 || noDrawItems )
885 {
886 bbox.Merge( m_reference->GetBoundingBox() );
887 }
888 }
889
890 if( board )
891 {
892 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
893 {
895 m_cachedBoundingBox = bbox;
896 }
897 else if( aIncludeText )
898 {
900 m_cachedVisibleBBox = bbox;
901 }
902 else
903 {
906 }
907 }
908
909 return bbox;
910}
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:551
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:491
virtual bool IsVisible() const
Definition: eda_text.h:126
const BOX2I GetBoundingBox() const override
Set absolute coordinates.
Definition: fp_text.cpp:232
@ 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 913 of file footprint.cpp.

914{
915 const BOARD* board = GetBoard();
916 bool isFPEdit = board && board->IsFootprintHolder();
917
918 if( board )
919 {
920 if( m_hullCacheTimeStamp >= board->GetTimeStamp() )
921 return m_cachedHull;
922 }
923
924 SHAPE_POLY_SET rawPolys;
925 SHAPE_POLY_SET hull;
926
927 for( BOARD_ITEM* item : m_drawings )
928 {
929 if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
930 continue;
931
932 if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_BITMAP_T )
933 {
934 item->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
936 }
937
938 // We intentionally exclude footprint text from the bounding hull.
939 }
940
941 for( PAD* pad : m_pads )
942 {
943 pad->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
945 // In case hole is larger than pad
946 pad->TransformHoleWithClearanceToPolygon( rawPolys, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
947 }
948
949 for( FP_ZONE* zone : m_fp_zones )
950 {
951 for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
952 {
953 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
954
955 for( int ii = 0; ii < layerPoly.OutlineCount(); ii++ )
956 {
957 const SHAPE_LINE_CHAIN& poly = layerPoly.COutline( ii );
958 rawPolys.AddOutline( poly );
959 }
960 }
961 }
962
963 // If there are some graphic items, build the actual hull.
964 // However if no items, create a minimal polygon (can happen if a footprint
965 // is created with no item: it contains only 2 texts.
966 if( rawPolys.OutlineCount() == 0 )
967 {
968 // generate a small dummy rectangular outline around the anchor
969 const int halfsize = pcbIUScale.mmToIU( 1.0 );
970
971 rawPolys.NewOutline();
972
973 // add a square:
974 rawPolys.Append( GetPosition().x - halfsize, GetPosition().y - halfsize );
975 rawPolys.Append( GetPosition().x + halfsize, GetPosition().y - halfsize );
976 rawPolys.Append( GetPosition().x + halfsize, GetPosition().y + halfsize );
977 rawPolys.Append( GetPosition().x - halfsize, GetPosition().y + halfsize );
978 }
979
980 std::vector<VECTOR2I> convex_hull;
981 BuildConvexHull( convex_hull, rawPolys );
982
985
986 for( const VECTOR2I& pt : convex_hull )
987 m_cachedHull.Append( pt );
988
989 if( board )
991
992 return m_cachedHull;
993}
VECTOR2I GetPosition() const override
Definition: footprint.h:192
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 85 of file board_item.h.

86 {
87 return GetBoundingBox().GetCenter();
88 }
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 651 of file footprint.h.

652 {
653 return wxT( "FOOTPRINT" );
654 }

Referenced by Visit().

◆ GetContextualTextVars()

void FOOTPRINT::GetContextualTextVars ( wxArrayString *  aVars) const

Return the list of system text vars for this footprint.

Definition at line 468 of file footprint.cpp.

469{
470 aVars->push_back( wxT( "REFERENCE" ) );
471 aVars->push_back( wxT( "VALUE" ) );
472 aVars->push_back( wxT( "LAYER" ) );
473 aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
474 aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
475 aVars->push_back( wxT( "NET_NAME(<pad_number>)" ) );
476 aVars->push_back( wxT( "NET_CLASS(<pad_number>)" ) );
477 aVars->push_back( wxT( "PIN_NAME(<pad_number>)" ) );
478}

◆ 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 2183 of file footprint.cpp.

2184{
2185 if( GetBoard() && GetBoard()->GetTimeStamp() > m_courtyard_cache_timestamp )
2186 const_cast<FOOTPRINT*>( this )->BuildCourtyardCaches();
2187
2188 if( IsBackLayer( aLayer ) )
2190 else
2192}
void BuildCourtyardCaches(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Build complex polygons of the courtyard areas from graphic items on the courtyard layers.
Definition: footprint.cpp:2195
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:920

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 1991 of file footprint.cpp.

1992{
1993 int textMargin = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
1994 SHAPE_POLY_SET poly;
1995
1996 if( aItem->Type() == PCB_MARKER_T )
1997 {
1998 const PCB_MARKER* marker = static_cast<const PCB_MARKER*>( aItem );
1999 SHAPE_LINE_CHAIN markerShape;
2000
2001 marker->ShapeToPolygon( markerShape );
2002 return markerShape.Area();
2003 }
2004 else if( aItem->Type() == PCB_GROUP_T )
2005 {
2006 double combinedArea = 0.0;
2007
2008 for( BOARD_ITEM* member : static_cast<const PCB_GROUP*>( aItem )->GetItems() )
2009 combinedArea += GetCoverageArea( member, aCollector );
2010
2011 return combinedArea;
2012 }
2013 if( aItem->Type() == PCB_FOOTPRINT_T )
2014 {
2015 const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( aItem );
2016
2017 poly = footprint->GetBoundingHull();
2018 }
2019 else if( aItem->Type() == PCB_FP_TEXT_T )
2020 {
2021 const FP_TEXT* text = static_cast<const FP_TEXT*>( aItem );
2022
2023 text->TransformTextShapeWithClearanceToPolygon( poly, UNDEFINED_LAYER, textMargin,
2025 }
2026 else if( aItem->Type() == PCB_FP_TEXTBOX_T )
2027 {
2028 const FP_TEXTBOX* textbox = static_cast<const FP_TEXTBOX*>( aItem );
2029
2032 }
2033 else if( aItem->Type() == PCB_SHAPE_T )
2034 {
2035 // Approximate "linear" shapes with just their width squared, as we don't want to consider
2036 // a linear shape as being much bigger than another for purposes of selection filtering
2037 // just because it happens to be really long.
2038
2039 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
2040
2041 switch( shape->GetShape() )
2042 {
2043 case SHAPE_T::SEGMENT:
2044 case SHAPE_T::ARC:
2045 case SHAPE_T::BEZIER:
2046 return shape->GetWidth() * shape->GetWidth();
2047
2048 case SHAPE_T::RECT:
2049 case SHAPE_T::CIRCLE:
2050 case SHAPE_T::POLY:
2051 {
2052 if( !shape->IsFilled() )
2053 return shape->GetWidth() * shape->GetWidth();
2054
2056 }
2057
2058 default:
2061 }
2062 }
2063 else if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
2064 {
2065 double width = static_cast<const PCB_TRACK*>( aItem )->GetWidth();
2066 return width * width;
2067 }
2068 else
2069 {
2072 }
2073
2074 return polygonArea( poly );
2075}
bool IsFilled() const
Definition: eda_shape.h:91
SHAPE_T GetShape() const
Definition: eda_shape.h:112
int GetWidth() const
Definition: eda_shape.h:108
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:1991
void TransformTextShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc) const
Definition: fp_textbox.cpp:443
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 TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:383
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::TransformShapeWithClearanceToPolygon(), PCB_SHAPE::TransformShapeWithClearanceToPolygon(), FP_TEXTBOX::TransformTextShapeWithClearanceToPolygon(), 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 161 of file eda_item.h.

162 {
163 constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
165
166 return m_flags & mask;
167 }
#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_DRAGGING
Item being dragged.
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.
#define IS_RESIZING
Item being resized.

References IS_CHANGED, IS_DRAGGING, IS_MOVING, IS_NEW, IS_PASTED, IS_RESIZING, IS_WIRE_IMAGE, 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.

Reimplemented from BOARD_ITEM.

Definition at line 2147 of file footprint.cpp.

2148{
2149 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2150
2151 // There are several possible interpretations here:
2152 // 1) the bounding box (without or without invisible items)
2153 // 2) just the pads and "edges" (ie: non-text graphic items)
2154 // 3) the courtyard
2155
2156 // We'll go with (2) for now, unless the caller is clearly looking for (3)
2157
2158 if( aLayer == F_CrtYd || aLayer == B_CrtYd )
2159 {
2160 const SHAPE_POLY_SET& courtyard = GetCourtyard( aLayer );
2161
2162 if( courtyard.OutlineCount() == 0 ) // malformed/empty polygon
2163 return shape;
2164
2165 shape->AddShape( new SHAPE_SIMPLE( courtyard.COutline( 0 ) ) );
2166 }
2167 else
2168 {
2169 for( PAD* pad : Pads() )
2170 shape->AddShape( pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2171
2172 for( BOARD_ITEM* item : GraphicalItems() )
2173 {
2174 if( item->Type() == PCB_FP_SHAPE_T )
2175 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2176 }
2177 }
2178
2179 return shape;
2180}
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2183
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.

◆ GetFlag()

int FOOTPRINT::GetFlag ( ) const
inline

Definition at line 250 of file footprint.h.

250{ 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 270 of file eda_item.h.

270{ return GetPosition(); }
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:263

References EDA_ITEM::GetPosition().

Referenced by SCH_EDIT_FRAME::FocusOnItem().

◆ GetFPID()

const LIB_ID & FOOTPRINT::GetFPID ( ) const
inline

Definition at line 207 of file footprint.h.

207{ 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(), CreateDevicesSection(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), 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(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), idf_export_footprint(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), 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(), PCB_CONTROL::UpdateMessagePanel(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetFPIDAsString()

const wxString FOOTPRINT::GetFPIDAsString ( ) const
inline

Definition at line 210 of file footprint.h.

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

References LIB_ID::Format(), and m_fpid.

◆ 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 761 of file footprint.cpp.

762{
763 BOX2I bbox;
764
765 // We want the bounding box of the footprint pads at rot 0, not flipped
766 // Create such a image:
767 FOOTPRINT dummy( *this );
768
769 dummy.SetPosition( VECTOR2I( 0, 0 ) );
770 dummy.SetOrientation( ANGLE_0 );
771
772 if( dummy.IsFlipped() )
773 dummy.Flip( VECTOR2I( 0, 0 ), false );
774
775 for( PAD* pad : dummy.Pads() )
776 bbox.Merge( pad->GetBoundingBox() );
777
778 return bbox;
779}
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:264
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

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

◆ GetInitialComments()

const wxArrayString * FOOTPRINT::GetInitialComments ( ) const
inline

Definition at line 733 of file footprint.h.

733{ return m_initial_comments; }

References m_initial_comments.

Referenced by PCB_PLUGIN::format().

◆ GetKeywords()

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Return the primary layer this item is on.

Reimplemented in PAD, and ZONE.

Definition at line 169 of file board_item.h.

169{ return m_layer; }

References BOARD_ITEM::m_layer.

Referenced by BOARD::Add(), CN_LIST::Add(), BOARD_ADAPTER::addFootprintShapes(), TEARDROP_MANAGER::addTeardropsOnTracks(), GRAPHICS_CLEANER::areEquivalent(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), AR_AUTOPLACER::buildFpAreas(), PNS::ITEM::collideSimple(), TEARDROP_MANAGER::ComputePointsOnPadVia(), CreateBoardSection(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewFootprint(), TEARDROP_MANAGER::createTeardrop(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDIT_TOOL::DragArcTrack(), KIGFX::PCB_PAINTER::draw(), PCB_EDIT_FRAME::ExchangeFootprint(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), extractDiffPairCoupledItems(), EDIT_TOOL::FilletTracks(), TEARDROP_MANAGER::findAnchorPointsOnTrack(), TEARDROP_MANAGER::findTouchingTrack(), Flip(), 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(), FOOTPRINT_DESC::FOOTPRINT_DESC(), PCB_PLUGIN::FootprintSave(), FootprintWriteShape(), PCB_PLUGIN::format(), FP_TEXT::FP_TEXT(), DSN::SPECCTRA_DB::FromSESSION(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), GetBoundingBox(), PAD::GetLayer(), ZONE::GetLayer(), getMatchingTextItem(), PCB_TRACK::GetMsgPanelInfo(), PCB_VIA::GetMsgPanelInfo(), AR_AUTOPLACER::getOptimalFPPlacement(), BOARD::GetPad(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), idf_export_footprint(), GENERAL_COLLECTOR::Inspect(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), BOARD_INSPECTION_TOOL::InspectDRCError(), IsFlipped(), PAD::IsFlipped(), BOARD_ITEM::IsOnCopperLayer(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), TEARDROP_MANAGER::isViaAndTrackInSameZone(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FABMASTER::loadFootprints(), FABMASTER::loadOutline(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_TEXTBOX_PROPERTIES::onBorderChecked(), BOARD::cmp_items::operator()(), BOARD::cmp_drawings::operator()(), PCB_SHAPE::cmp_drawings::operator()(), FOOTPRINT::cmp_drawings::operator()(), PCB_TRACK::cmp_tracks::operator()(), EAGLE_PLUGIN::packagePad(), PCB_SHAPE_DESC::PCB_SHAPE_DESC(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotFootprintGraphicItems(), BRDITEMS_PLOTTER::PlotFootprintShape(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), BRDITEMS_PLOTTER::PlotPcbGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), BRDITEMS_PLOTTER::PlotPcbTarget(), DRC_ENGINE::ProcessAssertions(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), PCB_CONTROL::pruneItemLayers(), PAD_TOOL::RecombinePad(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), CLIPBOARD_IO::SaveSelection(), PCB_SELECTION_TOOL::Selectable(), shapesNeedUpdate(), EDIT_TOOL::Swap(), GLOBAL_EDIT_TOOL::swapBoardItem(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncTrack(), PNS_KICAD_IFACE_BASE::SyncWorld(), AR_AUTOPLACER::testFootprintOnBoard(), DRC_TEST_PROVIDER_MISC::testTextVars(), CONNECTIVITY_DATA::TestTrackEndpointDangling(), textsNeedUpdate(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), BOARD_ADAPTER::transformFPShapesToPolygon(), TransformFPShapesWithClearanceToPolygon(), PCB_CONTROL::UpdateMessagePanel(), FP_TEXT::ViewGetLayers(), FP_TEXTBOX::ViewGetLayers(), PCB_TRACK::ViewGetLayers(), FP_TEXT::ViewGetLOD(), FP_TEXTBOX::ViewGetLOD(), FP_ZONE::ViewGetLOD(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem().

◆ 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 88 of file board_item.cpp.

89{
90 const BOARD* board = GetBoard();
91
92 if( board )
93 return board->GetLayerName( m_layer );
94
95 // If no parent, return standard name
97}
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:689
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:384

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

Referenced by 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(), FP_SHAPE::GetSelectMenuText(), PCB_DIMENSION_BASE::GetSelectMenuText(), PCB_SHAPE::GetSelectMenuText(), PCB_TEXT::GetSelectMenuText(), PCB_TEXTBOX::GetSelectMenuText(), PCB_TRACK::GetSelectMenuText(), 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 174 of file board_item.h.

175 {
176 if( m_layer == UNDEFINED_LAYER )
177 return LSET();
178 else
179 return LSET( m_layer );
180 }

References BOARD_ITEM::m_layer, and UNDEFINED_LAYER.

Referenced by PCB_GRID_HELPER::BestSnapAnchor(), KI_TEST::CheckFpShape(), KI_TEST::CheckFpText(), 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(), hash_board_item(), BOARD_INSPECTION_TOOL::InspectClearance(), PNS_KICAD_IFACE::IsItemVisible(), isMaskAperture(), BOARD_ITEM::layerMaskDescribe(), FABMASTER::loadZone(), 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 701 of file footprint.cpp.

702{
703 int smd_count = 0;
704 int tht_count = 0;
705
706 for( PAD* pad : m_pads )
707 {
708 switch( pad->GetProperty() )
709 {
712 continue;
713
716 continue;
717
718 case PAD_PROP::NONE:
719 case PAD_PROP::BGA:
721 break;
722 }
723
724 switch( pad->GetAttribute() )
725 {
726 case PAD_ATTRIB::PTH:
727 tht_count++;
728 break;
729
730 case PAD_ATTRIB::SMD:
731 smd_count++;
732 break;
733
734 default:
735 break;
736 }
737 }
738
739 if( tht_count > 0 )
740 return FP_THROUGH_HOLE;
741
742 if( smd_count > 0 )
743 return FP_SMD;
744
745 return 0;
746}
@ 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 228 of file footprint.h.

229 {
230 if( aSource )
231 *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
232
233 return m_localClearance;
234 }
const wxString & GetReference() const
Definition: footprint.h:519

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 1344 of file footprint.cpp.

1345{
1346 return BITMAPS::module;
1347}

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 996 of file footprint.cpp.

997{
998 wxString msg, msg2;
999
1000 aList.emplace_back( m_reference->GetShownText(), m_value->GetShownText() );
1001
1002 if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER )
1004 || aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
1005 {
1006 wxDateTime date( static_cast<time_t>( m_lastEditTime ) );
1007
1008 // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1009 if( m_lastEditTime && date.IsValid() )
1010 msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1011 else
1012 msg = _( "Unknown" );
1013
1014 aList.emplace_back( _( "Last Change" ), msg );
1015 }
1016 else if( aFrame->IsType( FRAME_PCB_EDITOR ) )
1017 {
1018 aList.emplace_back( _( "Board Side" ), IsFlipped() ? _( "Back (Flipped)" ) : _( "Front" ) );
1019 }
1020
1021 auto addToken = []( wxString* aStr, const wxString& aAttr )
1022 {
1023 if( !aStr->IsEmpty() )
1024 *aStr += wxT( ", " );
1025
1026 *aStr += aAttr;
1027 };
1028
1029 wxString status;
1030 wxString attrs;
1031
1032 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
1033 addToken( &status, _( "Locked" ) );
1034
1035 if( m_fpStatus & FP_is_PLACED )
1036 addToken( &status, _( "autoplaced" ) );
1037
1039 addToken( &attrs, _( "not in schematic" ) );
1040
1042 addToken( &attrs, _( "exclude from pos files" ) );
1043
1045 addToken( &attrs, _( "exclude from BOM" ) );
1046
1047 aList.emplace_back( _( "Status: " ) + status, _( "Attributes:" ) + wxS( " " ) + attrs );
1048
1049 aList.emplace_back( _( "Rotation" ), wxString::Format( wxT( "%.4g" ),
1050 GetOrientation().AsDegrees() ) );
1051
1052 msg.Printf( _( "Footprint: %s" ), m_fpid.GetUniStringLibId() );
1053 msg2.Printf( _( "3D-Shape: %s" ), m_3D_Drawings.empty() ? _( "<none>" )
1054 : m_3D_Drawings.front().m_Filename );
1055 aList.emplace_back( msg, msg2 );
1056
1057 msg.Printf( _( "Doc: %s" ), m_doc );
1058 msg2.Printf( _( "Keywords: %s" ), m_keywords );
1059 aList.emplace_back( msg, msg2 );
1060}
bool IsType(FRAME_T aType) const
EDA_ANGLE GetOrientation() const
Definition: footprint.h:195
bool IsLocked() const override
Definition: footprint.h:335
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:412
wxString GetUniStringLibId() const
Definition: lib_id.h:141
#define PCB_EDIT_FRAME_NAME
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:69
@ FP_BOARD_ONLY
Definition: footprint.h:71
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:70
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:330
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ 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 _, 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, FRAME_PCB_EDITOR, GetOrientation(), 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_lastEditTime, m_reference, m_value, and PCB_EDIT_FRAME_NAME.

Referenced by DISPLAY_FOOTPRINTS_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 267 of file footprint.h.

267{ 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 2272 of file footprint.cpp.

2273{
2274 // First build a map from pad numbers to allowed-shorting-group indexes. This ends up being
2275 // something like O(3n), but it still beats O(n^2) for large numbers of pads.
2276
2277 std::map<wxString, int> padToNetTieGroupMap = MapPadNumbersToNetTieGroups();
2278 int groupIdx = padToNetTieGroupMap[ aPad->GetNumber() ];
2279 std::vector<PAD*> otherPads;
2280
2281 if( groupIdx >= 0 )
2282 {
2283 for( PAD* pad : m_pads )
2284 {
2285 if( padToNetTieGroupMap[ pad->GetNumber() ] == groupIdx )
2286 otherPads.push_back( pad );
2287 }
2288 }
2289
2290 return otherPads;
2291}

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 1944 of file footprint.cpp.

1945{
1946 std::set<wxString> usedNumbers;
1947
1948 // Create a set of used pad numbers
1949 for( PAD* pad : m_pads )
1950 usedNumbers.insert( pad->GetNumber() );
1951
1952 // Pad numbers aren't technically reference designators, but the formatting is close enough
1953 // for these to give us what we need.
1954 wxString prefix = UTIL::GetRefDesPrefix( aLastPadNumber );
1955 int num = GetTrailingInt( aLastPadNumber );
1956
1957 while( usedNumbers.count( wxString::Format( wxT( "%s%d" ), prefix, num ) ) )
1958 num++;
1959
1960 return wxString::Format( wxT( "%s%d" ), prefix, num );
1961}
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 202 of file footprint.h.

203 {
204 return m_orient.AsDegrees();
205 }
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 1171 of file footprint.cpp.

1172{
1173 for( PAD* pad : m_pads )
1174 {
1175 // ... and on the correct layer.
1176 if( !( pad->GetLayerSet() & aLayerMask ).any() )
1177 continue;
1178
1179 if( pad->HitTest( aPosition ) )
1180 return pad;
1181 }
1182
1183 return nullptr;
1184}

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 1187 of file footprint.cpp.

1188{
1189 if( aIncludeNPTH )
1190 return m_pads.size();
1191
1192 unsigned cnt = 0;
1193
1194 for( PAD* pad : m_pads )
1195 {
1196 if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
1197 continue;
1198
1199 cnt++;
1200 }
1201
1202 return cnt;
1203}

References m_pads, NPTH, and pad.

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

◆ GetParent()

BOARD_ITEM_CONTAINER * BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 152 of file board_item.h.

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

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(), BOARD_ITEM::GetParentFootprint(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), FP_TEXT::GetSelectMenuText(), FP_TEXTBOX::GetSelectMenuText(), FP_TEXT::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXT::GetShownText(), PCB_TEXTBOX::GetShownText(), getTopLevelGroup(), 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(), 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 192 of file footprint.h.

192{ 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(), 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(), moveFootprintsInArea(), 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(), 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 564 of file footprint.h.

564{ 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(), DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper(), PCB_BASE_FRAME::CreateNewFootprint(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), BOARD_EDITOR_CONTROL::ExportNetlist(), FormatProbeItem(), GetLocalClearance(), FP_SHAPE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), DIALOG_BOARD_REANNOTATE::GetNewRefDes(), CADSTAR_PCB_ARCHIVE_LOADER::getPadReference(), FOOTPRINT_SEARCH_HANDLER::GetResultCell(), GetSelectMenuText(), 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().

◆ GetSelectMenuText()

wxString FOOTPRINT::GetSelectMenuText ( UNITS_PROVIDER aUnitsProvider) const
overridevirtual

Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position.

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 1333 of file footprint.cpp.

1334{
1335 wxString reference = GetReference();
1336
1337 if( reference.IsEmpty() )
1338 reference = _( "<no reference designator>" );
1339
1340 return wxString::Format( _( "Footprint %s" ), reference );
1341}

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

Referenced by DRC_ENGINE::EvalRules().

◆ 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 279 of file eda_item.h.

279{ return GetPosition(); }

References EDA_ITEM::GetPosition().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 140 of file eda_item.h.

141 {
142 return m_status & type;
143 }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:509

References EDA_ITEM::m_status.

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 153 of file eda_item.h.

153{ return m_status; }

References EDA_ITEM::m_status.

◆ GetStroke()

STROKE_PARAMS BOARD_ITEM::GetStroke ( ) const
virtualinherited

Reimplemented in PCB_SHAPE.

Definition at line 76 of file board_item.cpp.

77{
78 wxCHECK( false, STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) ) );
79}
#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 PCB_BASE_EDIT_FRAME::ShowGraphicItemPropertiesDialog().

◆ GetTypeDesc()

wxString EDA_ITEM::GetTypeDesc ( )
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:512

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

Referenced by PROPERTIES_PANEL::update().

◆ GetTypeName()

wxString FOOTPRINT::GetTypeName ( ) const

Get the type of footprint.

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

Definition at line 749 of file footprint.cpp.

750{
751 if( ( m_attributes & FP_SMD ) == FP_SMD )
752 return _( "SMD" );
753
755 return _( "Through hole" );
756
757 return _( "Other" );
758}

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 1206 of file footprint.cpp.

1207{
1208 std::set<wxString> usedNumbers;
1209
1210 // Create a set of used pad numbers
1211 for( PAD* pad : m_pads )
1212 {
1213 // Skip pads not on copper layers (used to build complex
1214 // solder paste shapes for instance)
1215 if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none() )
1216 continue;
1217
1218 // Skip pads with no name, because they are usually "mechanical"
1219 // pads, not "electrical" pads
1220 if( pad->GetNumber().IsEmpty() )
1221 continue;
1222
1223 if( !aIncludeNPTH )
1224 {
1225 // skip NPTH
1226 if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
1227 continue;
1228 }
1229
1230 usedNumbers.insert( pad->GetNumber() );
1231 }
1232
1233 return usedNumbers.size();
1234}

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

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

◆ GetValue()

◆ 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 178 of file footprint.h.

178{ return m_drawings; }

References m_drawings.

◆ Groups() [1/2]

◆ Groups() [2/2]

const FP_GROUPS & FOOTPRINT::Groups ( ) const
inline

Definition at line 184 of file footprint.h.

184{ 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 161 of file board_item.h.

161{ return false; }

◆ HasProperty()

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

Definition at line 565 of file footprint.h.

566 {
567 return m_properties.find( aKey ) != m_properties.end();
568 }

References m_properties.

Referenced by getFieldFunc().

◆ HasThroughHolePads()

bool FOOTPRINT::HasThroughHolePads ( ) const

Definition at line 2592 of file footprint.cpp.

2593{
2594 for( PAD* pad : Pads() )
2595 {
2596 if( pad->GetAttribute() != PAD_ATTRIB::SMD )
2597 return true;
2598 }
2599
2600 return false;
2601}

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 1099 of file footprint.cpp.

1100{
1101 BOX2I arect = aRect;
1102 arect.Inflate( aAccuracy );
1103
1104 if( aContained )
1105 {
1106 return arect.Contains( GetBoundingBox( false, false ) );
1107 }
1108 else
1109 {
1110 // If the rect does not intersect the bounding box, skip any tests
1111 if( !aRect.Intersects( GetBoundingBox( false, false ) ) )
1112 return false;
1113
1114 // The empty footprint dummy rectangle intersects the selection area.
1115 if( m_pads.empty() && m_fp_zones.empty() && m_drawings.empty() )
1116 return GetBoundingBox( true, false ).Intersects( arect );
1117
1118 // Determine if any elements in the FOOTPRINT intersect the rect
1119 for( PAD* pad : m_pads )
1120 {
1121 if( pad->HitTest( arect, false, 0 ) )
1122 return true;
1123 }
1124
1125 for( FP_ZONE* zone : m_fp_zones )
1126 {
1127 if( zone->HitTest( arect, false, 0 ) )
1128 return true;
1129 }
1130
1131 for( BOARD_ITEM* item : m_drawings )
1132 {
1133 // Text items are selectable on their own, and are therefore excluded from this
1134 // test. TextBox items are NOT selectable on their own, and so MUST be included
1135 // here. Bitmaps aren't selectable since they aren't displayed.
1136 if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_FP_TEXT_T
1137 && item->HitTest( arect, false, 0 ) )
1138 {
1139 return true;
1140 }
1141 }
1142
1143 // Groups are not hit-tested; only their members
1144
1145 // No items were hit
1146 return false;
1147 }
1148}
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 1086 of file footprint.cpp.

1087{
1088 BOX2I rect = GetBoundingBox( false, false );
1089 return rect.Inflate( aAccuracy ).Contains( aPosition );
1090}

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 1093 of file footprint.cpp.

1094{
1095 return GetBoundingHull().Collide( aPosition, aAccuracy );
1096}
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 249 of file footprint.h.

249{ m_arflag += 1; }

References m_arflag.

◆ IncrementReference()

void FOOTPRINT::IncrementReference ( int  aDelta)

Bump the current reference by aDelta.

Definition at line 1964 of file footprint.cpp.

1965{
1966 const wxString& refdes = GetReference();
1967
1968 SetReference( wxString::Format( wxT( "%s%i" ),
1969 UTIL::GetRefDesPrefix( refdes ),
1970 GetTrailingInt( refdes ) + aDelta ) );
1971}
void SetReference(const wxString &aReference)
Definition: footprint.h:528

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

◆ IsBrightened()

◆ IsConflicting()

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

Definition at line 462 of file footprint.cpp.

463{
464 return HasFlag( COURTYARD_CONFLICT );
465}
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:159
#define COURTYARD_CONFLICT
temporary set when moving footprints having courtyard overlapping

References COURTYARD_CONFLICT, and EDA_ITEM::HasFlag().

Referenced by ViewGetLayers(), and ViewGetLOD().

◆ IsConnected()

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 119 of file eda_item.h.

119{ return m_flags & IS_DRAGGING; }

References IS_DRAGGING, and EDA_ITEM::m_flags.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES().

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 122 of file eda_item.h.

122{ 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().

◆ IsFlipped()

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 217 of file eda_item.h.

217{ return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:511

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 1493 of file footprint.cpp.

1494{
1495 const wxChar * invalids = StringLibNameInvalidChars( false );
1496
1497 if( aName.find_first_of( invalids ) != std::string::npos )
1498 return false;
1499
1500 return true;
1501}
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:1504

References StringLibNameInvalidChars().

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::checkFootprintName().

◆ IsLocked()

bool FOOTPRINT::IsLocked ( ) const
inlineoverridevirtual

Reimplemented from BOARD_ITEM.

Definition at line 335 of file footprint.h.

336 {
337 return ( m_fpStatus & FP_is_LOCKED ) != 0;
338 }
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition: footprint.h:329

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 116 of file eda_item.h.

116{ 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 252 of file footprint.h.

253 {
254 for( const wxString& group : m_netTiePadGroups )
255 {
256 if( !group.IsEmpty() )
257 return true;
258 }
259
260 return false;
261 }

References group, and m_netTiePadGroups.

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

◆ 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 115 of file board_item.h.

116 {
117 return IsCopperLayer( GetLayer() );
118 }
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:823

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 1063 of file footprint.cpp.

1064{
1065 // If we have any pads, fall back on normal checking
1066 if( !m_pads.empty() )
1067 return m_layer == aLayer;
1068
1069 // No pads? Check if this entire footprint exists on the given layer
1070 for( FP_ZONE* zone : m_fp_zones )
1071 {
1072 if( !zone->IsOnLayer( aLayer ) )
1073 return false;
1074 }
1075
1076 for( BOARD_ITEM* item : m_drawings )
1077 {
1078 if( !item->IsOnLayer( aLayer ) )
1079 return false;
1080 }
1081
1082 return true;
1083}

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

◆ IsPlaced()

bool FOOTPRINT::IsPlaced ( ) const
inline

Definition at line 358 of file footprint.h.

358{ 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 434 of file eda_item.h.

434{ return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 123 of file eda_item.h.

123{ return m_flags & IS_RESIZING; }

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsRollover()

bool EDA_ITEM::IsRollover ( ) const
inlineinherited

Definition at line 126 of file eda_item.h.

127 {
128 return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
129 }
#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 121 of file eda_item.h.

121{ 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(), 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_MOVE_TOOL::Main(), SCH_SCREEN::MarkConnections(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), KIGFX::SCH_PAINTER::nonCached(), 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(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), GERBVIEW_SELECTION_TOOL::unselect(), 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 189 of file eda_item.h.

189{ 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 125 of file board_item.h.

126 {
127 return false;
128 }

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 197 of file eda_item.h.

198 {
199 for( KICAD_T scanType : aScanTypes )
200 {
201 if( scanType == SCH_LOCATE_ANY_T || scanType == m_structType )
202 return true;
203 }
204
205 return false;
206 }
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:519
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:182

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(), EE_SELECTION_TOOL::RequestSelection(), SCH_FIELD::SetId(), SCH_BASE_FRAME::UpdateItem(), and EDA_ITEM::Visit().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 120 of file eda_item.h.

120{ return m_flags & IS_WIRE_IMAGE; }

References IS_WIRE_IMAGE, and EDA_ITEM::m_flags.

◆ 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 316 of file eda_item.h.

318 {
319 for( const auto& it : aList )
320 {
321 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
322 testData,
323 scanTypes ) == INSPECT_RESULT::QUIT )
324 {
326 }
327 }
328
330 }
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
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 336 of file eda_item.h.

338 {
339 for( const auto& it : aList )
340 {
341 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
342 testData,
343 scanTypes ) == INSPECT_RESULT::QUIT )
344 {
346 }
347 }
348
350 }

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 100 of file board_item.cpp.

101{
102 const BOARD* board = GetBoard();
103 LSET layers = GetLayerSet();
104
105 // Try to be smart and useful. Check all copper first.
106 if( layers[F_Cu] && layers[B_Cu] )
107 return _( "all copper layers" );
108
109 LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
110 LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
111
112 for( LSET testLayers : { copperLayers, techLayers, layers } )
113 {
114 for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
115 {
116 if( testLayers[ bit ] )
117 {
118 wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
119
120 if( testLayers.count() > 1 )
121 layerInfo << wxS( " " ) + _( "and others" );
122
123 return layerInfo;
124 }
125 }
126 }
127
128 // No copper, no technicals: no layer
129 return _( "no layers" );
130}
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:174
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:485
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::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), and PAD::GetSelectMenuText().

◆ LegacyPadsLocked()

bool FOOTPRINT::LegacyPadsLocked ( ) const
inline

Definition at line 376 of file footprint.h.

376{ 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 indicies. If a pad is not a member of a net-tie group its index will be -1.

Definition at line 2252 of file footprint.cpp.

2253{
2254 std::map<wxString, int> padNumberToGroupIdxMap;
2255
2256 for( const PAD* pad : m_pads )
2257 padNumberToGroupIdxMap[ pad->GetNumber() ] = -1;
2258
2259 for( size_t ii = 0; ii < m_netTiePadGroups.size(); ++ii )
2260 {
2261 wxStringTokenizer groupParser( m_netTiePadGroups[ ii ], "," );
2262 std::vector<wxString> numbersInGroup;
2263
2264 while( groupParser.HasMoreTokens() )
2265 padNumberToGroupIdxMap[ groupParser.GetNextToken().Trim( false ).Trim( true ) ] = ii;
2266 }
2267
2268 return padNumberToGroupIdxMap;
2269}

References m_netTiePadGroups, m_pads, and pad.

Referenced by DRC_TEST_PROVIDER_SOLDER_MASK::checkItemMask(), CheckNetTies(), GetNetTiePads(), DRC_ENGINE::IsNetTieExclusion(), GRAPHICS_CLEANER::mergePads(), 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_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 396 of file eda_item.h.

397 {
398 return false;
399 }

Referenced by SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_EDITOR_CONTROL::HasMatch(), SCH_MARKER::Matches(), LIB_TEXTBOX::Matches(), SCH_FIELD::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_EDITOR_CONTROL::ReplaceAndFindNext(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_EDITOR_CONTROL::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:434
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 189 of file footprint.h.

189{ 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 1521 of file footprint.cpp.

1522{
1523 VECTOR2I newpos = m_pos + aMoveVector;
1524 SetPosition( newpos );
1525}

References m_pos, and SetPosition().

Referenced by moveFootprintsInArea(), and CLIPBOARD_IO::SaveSelection().

◆ 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 1692 of file footprint.cpp.

1693{
1694 /*
1695 * Move the reference point of the footprint
1696 * the footprints elements (pads, outlines, edges .. ) are moved
1697 * but:
1698 * - the footprint position is not modified.
1699 * - the relative (local) coordinates of these items are modified
1700 * - Draw coordinates are updated
1701 */
1702
1703 // Update (move) the relative coordinates relative to the new anchor point.
1704 VECTOR2I moveVector = aMoveVector;
1705 RotatePoint( moveVector, -GetOrientation() );
1706
1707 // Update of the reference and value.
1708 m_reference->SetPos0( m_reference->GetPos0() + moveVector );
1710 m_value->SetPos0( m_value->GetPos0() + moveVector );
1712
1713 // Update the pad local coordinates.
1714 for( PAD* pad : m_pads )
1715 {
1716 pad->SetPos0( pad->GetPos0() + moveVector );
1717 pad->SetDrawCoord();
1718 }
1719
1720 // Update the draw element coordinates.
1721 for( BOARD_ITEM* item : GraphicalItems() )
1722 {
1723 switch( item->Type() )
1724 {
1725 case PCB_FP_SHAPE_T:
1726 case PCB_FP_TEXTBOX_T:
1727 {
1728 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
1729 shape->Move( moveVector );
1730 break;
1731 }
1732
1733 case PCB_FP_TEXT_T:
1734 {
1735 FP_TEXT* text = static_cast<FP_TEXT*>( item );
1736 text->SetPos0( text->GetPos0() + moveVector );
1737 text->SetDrawCoord();
1738 break;
1739 }
1740
1741 default:
1742 break;
1743 }
1744 }
1745
1746 // Update the keepout zones
1747 for( ZONE* zone : Zones() )
1748 {
1749 zone->Move( moveVector );
1750 }
1751
1752 // Update the 3D models
1753 for( FP_3DMODEL& model : Models() )
1754 {
1755 model.m_Offset.x += pcbIUScale.IUTomm( moveVector.x );
1756 model.m_Offset.y -= pcbIUScale.IUTomm( moveVector.y );
1757 }
1758
1759 m_cachedBoundingBox.Move( moveVector );
1760 m_cachedVisibleBBox.Move( moveVector );
1761 m_cachedTextExcludedBBox.Move( moveVector );
1762 m_cachedHull.Move( moveVector );
1763}
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:200
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 367 of file footprint.h.

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

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 361 of file footprint.cpp.

362{
363 BOARD_ITEM::operator=( aOther );
364
365 m_pos = aOther.m_pos;
366 m_fpid = aOther.m_fpid;
367 m_attributes = aOther.m_attributes;
368 m_fpStatus = aOther.m_fpStatus;
369 m_orient = aOther.m_orient;
371 m_link = aOther.m_link;
372 m_path = aOther.m_path;
373
380 m_cachedHull = aOther.m_cachedHull;
382
389
390 // Copy reference and value
391 *m_reference = *aOther.m_reference;
392 m_reference->SetParent( this );
393 *m_value = *aOther.m_value;
394 m_value->SetParent( this );
395
396 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
397
398 // Copy pads
399 m_pads.clear();
400
401 for( PAD* pad : aOther.Pads() )
402 {
403 PAD* newPad = new PAD( *pad );
404 ptrMap[ pad ] = newPad;
405 Add( newPad );
406 }
407
408 // Copy zones
409 m_fp_zones.clear();
410
411 for( FP_ZONE* zone : aOther.Zones() )
412 {
413 FP_ZONE* newZone = static_cast<FP_ZONE*>( zone->Clone() );
414 ptrMap[ zone ] = newZone;
415 Add( newZone );
416
417 // Ensure the net info is OK and especially uses the net info list
418 // living in the current board
419 // Needed when copying a fp from fp editor that has its own board
420 // Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
421 newZone->SetNetCode( -1 );
422 }
423
424 // Copy drawings
425 m_drawings.clear();
426
427 for( BOARD_ITEM* item : aOther.GraphicalItems() )
428 {
429 BOARD_ITEM* newItem = static_cast<BOARD_ITEM*>( item->Clone() );
430 ptrMap[ item ] = newItem;
431 Add( newItem );
432 }
433
434 // Copy groups
435 m_fp_groups.clear();
436
437 for( PCB_GROUP* group : aOther.Groups() )
438 {
439 PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( group->Clone() );
440 newGroup->GetItems().clear();
441
442 for( BOARD_ITEM* member : group->GetItems() )
443 newGroup->AddItem( ptrMap[ member ] );
444
445 Add( newGroup );
446 }
447
448 // Copy auxiliary data
450 m_doc = aOther.m_doc;
451 m_keywords = aOther.m_keywords;
452 m_properties = aOther.m_properties;
454
456 new wxArrayString( *aOther.m_initial_comments ) : nullptr;
457
458 return *this;
459}
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
Definition: eda_item.cpp:240

References Add(), PCB_GROUP::AddItem(), PCB_GROUP::GetItems(), GraphicalItems(), group, Groups(), m_3D_Drawings, m_attributes, m_boundingBoxCacheTimeStamp, m_cachedBoundingBox, m_cachedHull, m_cachedTextExcludedBBox, m_cachedVisibleBBox, m_doc, m_drawings, m_fp_groups, m_fp_zones, 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_pads, m_path, m_pos, m_privateLayers, m_properties, m_reference, m_textExcludedBBoxCacheTimeStamp, m_value, m_visibleBBoxCacheTimeStamp, m_zoneConnection, EDA_ITEM::operator=(), pad, PAD, Pads(), BOARD_CONNECTED_ITEM::SetNetCode(), EDA_ITEM::SetParent(), and Zones().

◆ operator=() [2/2]

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

Definition at line 264 of file footprint.cpp.

265{
266 BOARD_ITEM::operator=( aOther );
267
268 m_pos = aOther.m_pos;
269 m_fpid = aOther.m_fpid;
270 m_attributes = aOther.m_attributes;