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
 

Public Member Functions

 FOOTPRINT (BOARD *parent)
 
 FOOTPRINT (const FOOTPRINT &aFootprint)
 
 FOOTPRINT (FOOTPRINT &&aFootprint)
 
 ~FOOTPRINT ()
 
FOOTPRINToperator= (const FOOTPRINT &aOther)
 
FOOTPRINToperator= (FOOTPRINT &&aOther)
 
void Add (BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) 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 alway 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...
 
EDA_RECT 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 EDA_RECT GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
const EDA_RECT 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::list< FP_3DMODEL > & Models ()
 
const std::list< FP_3DMODEL > & Models () const
 
void SetPosition (const wxPoint &aPos) override
 
wxPoint GetPosition () const override
 
void SetOrientation (double aNewAngle)
 
void SetOrientationDegrees (double aOrientation)
 
double GetOrientation () const
 
double GetOrientationDegrees () const
 
double GetOrientationRadians () const
 
const LIB_IDGetFPID () const
 
void SetFPID (const LIB_ID &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
 
void SetThermalWidth (int aWidth)
 
int GetThermalWidth () const
 
void SetThermalGap (int aGap)
 
int GetThermalGap () const
 
int GetAttributes () const
 
void SetAttributes (int aAttributes)
 
void SetFlag (int aFlag)
 
void IncrementFlag ()
 
int GetFlag () const
 
bool IsNetTie () const
 
int GetLikelyAttribute () const
 Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0) More...
 
void Move (const wxPoint &aMoveVector) override
 Move this object. More...
 
void Rotate (const wxPoint &aRotCentre, double aAngle) override
 Rotate this object. More...
 
void Flip (const wxPoint &aCentre, bool aFlipLeftRight) override
 Flip this object, i.e. More...
 
void MoveAnchorPosition (const wxPoint &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 IsPlaced () const
 
void SetIsPlaced (bool isPlaced)
 
bool NeedsPlaced () const
 
void SetNeedsPlaced (bool needsPlaced)
 
bool LegacyPadsLocked () const
 
void SetLastEditTime (timestamp_t aTime)
 
void SetLastEditTime ()
 
timestamp_t GetLastEditTime () const
 
void CheckFootprintAttributes (const std::function< void(const wxString &msg)> *aErrorHandler)
 Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the pads in the footprint. More...
 
void CheckFootprintTHPadNoHoles (const std::function< void(const wxString &msg, const wxPoint &position)> *aErrorHandler)
 Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the pads in the footprint. 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) 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 wxPoint &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTestAccurate (const wxPoint &aPosition, int aAccuracy=0) const
 Test if a point is inside the bounding polygon of the footprint. More...
 
bool HitTest (const EDA_RECT &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 wxPoint &aPosition, LSET aLayerMask=LSET::AllLayersMask())
 Get a pad at aPosition on aLayerMask in the footprint. More...
 
PADGetTopLeftPad ()
 
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)
 
int GetPlacementCost180 () const
 
void SetPlacementCost180 (int aCost)
 
int GetPlacementCost90 () const
 
void SetPlacementCost90 (int aCost)
 
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...
 
SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
 May be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
wxString GetClass () const override
 Return the class name. More...
 
wxString GetSelectMenuText (EDA_UNITS aUnits) 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...
 
void GetAllDrawingLayers (int aLayers[], int &aCount, bool aIncludePads=true) const
 Return a set of all layers that this footprint has drawings on similar to ViewGetLayers(). 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...
 
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_SETGetPolyCourtyard (PCB_LAYER_ID aLayer) const
 Used in DRC to test the courtyard area (a complex polygon). More...
 
void BuildPolyCourtyards (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) 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 wxPoint 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
 
BOARD_ITEM_CONTAINERGetParent () const
 
BOARD_ITEM_CONTAINERGetParentFootprint () const
 
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...
 
bool IsTrack () const
 Test to see if this object is a track or via (or microvia). More...
 
void DeleteStructure ()
 Delete this object after removing from its parent if it has one. More...
 
void Move (const VECTOR2I &aMoveVector)
 
void Rotate (const VECTOR2I &aRotCentre, double aAngle)
 
void Flip (const VECTOR2I &aCentre, bool aFlipLeftRight)
 
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
 
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 IsType (const 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 wxPoint GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual bool Matches (const wxFindReplaceData &aSearchData, void *aAuxData) const
 Compare the item against the search criteria in aSearchData. More...
 
virtual bool Replace (const wxFindReplaceData &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)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 Adds an item to the container. More...
 
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 SEARCH_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const wxFindReplaceData &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 wxPoint 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 wxFindReplaceData &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 

Protected Attributes

PCB_LAYER_ID m_layer
 
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
 
double m_orient
 
wxPoint m_pos
 
FP_TEXTm_reference
 
FP_TEXTm_value
 
LIB_ID m_fpid
 
int m_attributes
 
int m_fpStatus
 
EDA_RECT m_cachedBoundingBox
 
int m_boundingBoxCacheTimeStamp
 
EDA_RECT m_cachedVisibleBBox
 
int m_visibleBBoxCacheTimeStamp
 
EDA_RECT m_cachedTextExcludedBBox
 
int m_textExcludedBBoxCacheTimeStamp
 
SHAPE_POLY_SET m_cachedHull
 
int m_hullCacheTimeStamp
 
ZONE_CONNECTION m_zoneConnection
 
int m_thermalWidth
 
int m_thermalGap
 
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
 
int m_rot90Cost
 
int m_rot180Cost
 
std::list< FP_3DMODELm_3D_Drawings
 
std::map< wxString, wxString > m_properties
 
wxArrayString * m_initial_comments
 
SHAPE_POLY_SET m_poly_courtyard_front
 
SHAPE_POLY_SET m_poly_courtyard_back
 

Detailed Description

Definition at line 103 of file footprint.h.

Constructor & Destructor Documentation

◆ FOOTPRINT() [1/3]

FOOTPRINT::FOOTPRINT ( BOARD parent)

Definition at line 51 of file footprint.cpp.

51  :
57  m_initial_comments( nullptr )
58 {
59  m_attributes = 0;
60  m_layer = F_Cu;
61  m_orient = 0;
63  m_arflag = 0;
65  m_link = 0;
66  m_lastEditTime = 0;
67  m_localClearance = 0;
71  m_zoneConnection = ZONE_CONNECTION::INHERITED; // Use zone setting by default
72  m_thermalWidth = 0; // Use zone setting by default
73  m_thermalGap = 0; // Use zone setting by default
74 
75  // These are special and mandatory text fields
77  m_value = new FP_TEXT( this, FP_TEXT::TEXT_is_VALUE );
78 
79  m_3D_Drawings.clear();
80 }
int m_localSolderPasteMargin
Definition: footprint.h:769
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:764
double m_localSolderPasteMarginRatio
Definition: footprint.h:770
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
#define FP_PADS_are_LOCKED
Definition: footprint.h:291
double m_orient
Definition: footprint.h:737
timestamp_t m_lastEditTime
Definition: footprint.h:775
FP_TEXT * m_reference
Definition: footprint.h:739
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:758
int m_rot90Cost
Definition: footprint.h:778
FP_TEXT * m_value
Definition: footprint.h:740
int m_arflag
Definition: footprint.h:776
KIID m_link
Definition: footprint.h:777
int m_localSolderMaskMargin
Definition: footprint.h:768
int m_fpStatus
Definition: footprint.h:743
int m_thermalGap
Definition: footprint.h:766
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:756
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
int m_thermalWidth
Definition: footprint.h:765
int m_localClearance
Definition: footprint.h:767
int m_rot180Cost
Definition: footprint.h:779
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:760
Definition: layer_ids.h:71
PCB_LAYER_ID m_layer
Definition: board_item.h:318
wxArrayString * m_initial_comments
Definition: footprint.h:783
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
std::list< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:781
int m_hullCacheTimeStamp
Definition: footprint.h:762
int m_attributes
Definition: footprint.h:742

References 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_rot180Cost, m_rot90Cost, m_thermalGap, m_thermalWidth, 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 83 of file footprint.cpp.

83  :
84  BOARD_ITEM_CONTAINER( aFootprint )
85 {
86  m_pos = aFootprint.m_pos;
87  m_fpid = aFootprint.m_fpid;
88  m_attributes = aFootprint.m_attributes;
89  m_fpStatus = aFootprint.m_fpStatus;
90  m_orient = aFootprint.m_orient;
91  m_rot90Cost = aFootprint.m_rot90Cost;
92  m_rot180Cost = aFootprint.m_rot180Cost;
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 
106  m_localClearance = aFootprint.m_localClearance;
110  m_zoneConnection = aFootprint.m_zoneConnection;
111  m_thermalWidth = aFootprint.m_thermalWidth;
112  m_thermalGap = aFootprint.m_thermalGap;
113 
114  std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
115 
116  // Copy reference and value.
117  m_reference = new FP_TEXT( *aFootprint.m_reference );
118  m_reference->SetParent( this );
119  ptrMap[ aFootprint.m_reference ] = m_reference;
120 
121  m_value = new FP_TEXT( *aFootprint.m_value );
122  m_value->SetParent( this );
123  ptrMap[ aFootprint.m_value ] = m_value;
124 
125  // Copy pads
126  for( PAD* pad : aFootprint.Pads() )
127  {
128  PAD* newPad = static_cast<PAD*>( pad->Clone() );
129  ptrMap[ pad ] = newPad;
130  Add( newPad, ADD_MODE::APPEND ); // Append to ensure indexes are identical
131  }
132 
133  // Copy zones
134  for( FP_ZONE* zone : aFootprint.Zones() )
135  {
136  FP_ZONE* newZone = static_cast<FP_ZONE*>( zone->Clone() );
137  ptrMap[ zone ] = newZone;
138  Add( newZone, ADD_MODE::APPEND ); // Append to ensure indexes are identical
139 
140  // Ensure the net info is OK and especially uses the net info list
141  // living in the current board
142  // Needed when copying a fp from fp editor that has its own board
143  // Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
144  newZone->SetNetCode( -1 );
145  }
146 
147  // Copy drawings
148  for( BOARD_ITEM* item : aFootprint.GraphicalItems() )
149  {
150  BOARD_ITEM* newItem = static_cast<BOARD_ITEM*>( item->Clone() );
151  ptrMap[ item ] = newItem;
152  Add( newItem, ADD_MODE::APPEND ); // Append to ensure indexes are identical
153  }
154 
155  // Copy groups
156  for( PCB_GROUP* group : aFootprint.Groups() )
157  {
158  PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( group->Clone() );
159  ptrMap[ group ] = newGroup;
160  Add( newGroup, ADD_MODE::APPEND ); // Append to ensure indexes are identical
161  }
162 
163  // Rebuild groups
164  for( PCB_GROUP* group : aFootprint.Groups() )
165  {
166  PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( ptrMap[ group ] );
167 
168  newGroup->GetItems().clear();
169 
170  for( BOARD_ITEM* member : group->GetItems() )
171  {
172  if( ptrMap.count( member ) )
173  newGroup->AddItem( ptrMap[ member ] );
174  }
175  }
176 
177  // Copy auxiliary data: 3D_Drawings info
178  m_3D_Drawings = aFootprint.m_3D_Drawings;
179 
180  m_doc = aFootprint.m_doc;
181  m_keywords = aFootprint.m_keywords;
182  m_properties = aFootprint.m_properties;
183 
184  m_arflag = 0;
185 
187  new wxArrayString( *aFootprint.m_initial_comments ) : nullptr;
188 }
int m_localSolderPasteMargin
Definition: footprint.h:769
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:39
EDA_RECT m_cachedVisibleBBox
Definition: footprint.h:757
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:764
double m_localSolderPasteMarginRatio
Definition: footprint.h:770
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
double m_orient
Definition: footprint.h:737
timestamp_t m_lastEditTime
Definition: footprint.h:775
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
FP_TEXT * m_reference
Definition: footprint.h:739
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:758
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
int m_rot90Cost
Definition: footprint.h:778
PADS & Pads()
Definition: footprint.h:169
FP_TEXT * m_value
Definition: footprint.h:740
int m_arflag
Definition: footprint.h:776
KIID m_link
Definition: footprint.h:777
int m_localSolderMaskMargin
Definition: footprint.h:768
EDA_RECT m_cachedBoundingBox
Definition: footprint.h:755
FP_ZONES & Zones()
Definition: footprint.h:175
int m_fpStatus
Definition: footprint.h:743
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:761
int m_thermalGap
Definition: footprint.h:766
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
wxPoint m_pos
Definition: footprint.h:738
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:756
KIID_PATH m_path
Definition: footprint.h:774
FP_GROUPS & Groups()
Definition: footprint.h:178
int m_thermalWidth
Definition: footprint.h:765
wxString m_keywords
Definition: footprint.h:773
int m_localClearance
Definition: footprint.h:767
int m_rot180Cost
Definition: footprint.h:779
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:760
LIB_ID m_fpid
Definition: footprint.h:741
EDA_RECT m_cachedTextExcludedBBox
Definition: footprint.h:759
std::map< wxString, wxString > m_properties
Definition: footprint.h:782
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
wxArrayString * m_initial_comments
Definition: footprint.h:783
Definition: pad.h:57
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
wxString m_doc
Definition: footprint.h:772
std::list< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:781
A specialization of ZONE for use in footprints.
Definition: zone.h:945
int m_hullCacheTimeStamp
Definition: footprint.h:762
int m_attributes
Definition: footprint.h:742

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_orient, m_path, m_pos, m_properties, m_reference, m_rot180Cost, m_rot90Cost, m_textExcludedBBoxCacheTimeStamp, m_thermalGap, m_thermalWidth, 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 191 of file footprint.cpp.

191  :
192  BOARD_ITEM_CONTAINER( aFootprint )
193 {
194  *this = std::move( aFootprint );
195 }
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)

◆ ~FOOTPRINT()

FOOTPRINT::~FOOTPRINT ( )

Definition at line 198 of file footprint.cpp.

199 {
200  // Clean up the owned elements
201  delete m_reference;
202  delete m_value;
203  delete m_initial_comments;
204 
205  for( PAD* p : m_pads )
206  delete p;
207 
208  m_pads.clear();
209 
210  for( FP_ZONE* zone : m_fp_zones )
211  delete zone;
212 
213  m_fp_zones.clear();
214 
215  for( PCB_GROUP* group : m_fp_groups )
216  delete group;
217 
218  m_fp_groups.clear();
219 
220  for( BOARD_ITEM* d : m_drawings )
221  delete d;
222 
223  m_drawings.clear();
224 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
FP_TEXT * m_reference
Definition: footprint.h:739
FP_TEXT * m_value
Definition: footprint.h:740
FP_ZONES m_fp_zones
Definition: footprint.h:734
DRAWINGS m_drawings
Definition: footprint.h:732
wxArrayString * m_initial_comments
Definition: footprint.h:783
Definition: pad.h:57
FP_GROUPS m_fp_groups
Definition: footprint.h:735
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733

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 
)
overridevirtual

Removes an item from the container.

Implements BOARD_ITEM_CONTAINER.

Definition at line 513 of file footprint.cpp.

514 {
515  switch( aBoardItem->Type() )
516  {
517  case PCB_FP_TEXT_T:
518  // Only user text can be added this way.
519  wxASSERT( static_cast<FP_TEXT*>( aBoardItem )->GetType() == FP_TEXT::TEXT_is_DIVERS );
521 
522  case PCB_FP_SHAPE_T:
523  if( aMode == ADD_MODE::APPEND )
524  m_drawings.push_back( aBoardItem );
525  else
526  m_drawings.push_front( aBoardItem );
527  break;
528 
529  case PCB_PAD_T:
530  if( aMode == ADD_MODE::APPEND )
531  m_pads.push_back( static_cast<PAD*>( aBoardItem ) );
532  else
533  m_pads.push_front( static_cast<PAD*>( aBoardItem ) );
534  break;
535 
536  case PCB_FP_ZONE_T:
537  if( aMode == ADD_MODE::APPEND )
538  m_fp_zones.push_back( static_cast<FP_ZONE*>( aBoardItem ) );
539  else
540  m_fp_zones.insert( m_fp_zones.begin(), static_cast<FP_ZONE*>( aBoardItem ) );
541  break;
542 
543  case PCB_GROUP_T:
544  if( aMode == ADD_MODE::APPEND )
545  m_fp_groups.push_back( static_cast<PCB_GROUP*>( aBoardItem ) );
546  else
547  m_fp_groups.insert( m_fp_groups.begin(), static_cast<PCB_GROUP*>( aBoardItem ) );
548  break;
549 
550  default:
551  {
552  wxString msg;
553  msg.Printf( wxT( "FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
554  aBoardItem->Type() );
555  wxFAIL_MSG( msg );
556 
557  return;
558  }
559  }
560 
561  aBoardItem->ClearEditFlags();
562  aBoardItem->SetParent( this );
563 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
FP_ZONES m_fp_zones
Definition: footprint.h:734
class ZONE, managed by a footprint
Definition: typeinfo.h:94
DRAWINGS m_drawings
Definition: footprint.h:732
FP_GROUPS m_fp_groups
Definition: footprint.h:735
PADS m_pads
Definition: footprint.h:733

References APPEND, EDA_ITEM::ClearEditFlags(), KI_FALLTHROUGH, m_drawings, m_fp_groups, m_fp_zones, m_pads, PCB_FP_SHAPE_T, PCB_FP_TEXT_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(), 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(), 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(), ALTIUM_PCB::ParsePads6Data(), ALTIUM_PCB::ParseTexts6Data(), CLIPBOARD_IO::SaveSelection(), FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), and DIALOG_FOOTPRINT_PROPERTIES::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 1179 of file footprint.cpp.

1180 {
1181  if( nullptr == a3DModel )
1182  return;
1183 
1184  if( !a3DModel->m_Filename.empty() )
1185  m_3D_Drawings.push_back( *a3DModel );
1186 }
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:98
std::list< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:781

References m_3D_Drawings, and FP_3DMODEL::m_Filename.

◆ BuildPolyCourtyards()

void FOOTPRINT::BuildPolyCourtyards ( 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 2040 of file footprint.cpp.

2041 {
2045 
2046  // Build the courtyard area from graphic items on the courtyard.
2047  // Only PCB_FP_SHAPE_T have meaning, graphic texts are ignored.
2048  // Collect items:
2049  std::vector<PCB_SHAPE*> list_front;
2050  std::vector<PCB_SHAPE*> list_back;
2051 
2052  for( BOARD_ITEM* item : GraphicalItems() )
2053  {
2054  if( item->GetLayer() == B_CrtYd && item->Type() == PCB_FP_SHAPE_T )
2055  list_back.push_back( static_cast<PCB_SHAPE*>( item ) );
2056 
2057  if( item->GetLayer() == F_CrtYd && item->Type() == PCB_FP_SHAPE_T )
2058  list_front.push_back( static_cast<PCB_SHAPE*>( item ) );
2059  }
2060 
2061  if( !list_front.size() && !list_back.size() )
2062  return;
2063 
2064  int errorMax = Millimeter2iu( 0.02 ); // max error for polygonization
2065  int chainingEpsilon = Millimeter2iu( 0.02 ); // max dist from one endPt to next startPt
2066 
2067  if( ConvertOutlineToPolygon( list_front, m_poly_courtyard_front, errorMax, chainingEpsilon,
2068  aErrorHandler ) )
2069  {
2070  // Touching courtyards, or courtyards -at- the clearance distance are legal.
2072 
2074  }
2075  else
2076  {
2078  }
2079 
2080  if( ConvertOutlineToPolygon( list_back, m_poly_courtyard_back, errorMax, chainingEpsilon,
2081  aErrorHandler ) )
2082  {
2083  // Touching courtyards, or courtyards -at- the clearance distance are legal.
2085 
2087  }
2088  else
2089  {
2091  }
2092 }
#define MALFORMED_B_COURTYARD
SHAPE_POLY_SET m_poly_courtyard_back
Definition: footprint.h:787
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
#define MALFORMED_F_COURTYARD
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
SHAPE_POLY_SET m_poly_courtyard_front
Definition: footprint.h:786
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
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)
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_COURTYARDS
static constexpr int Millimeter2iu(double mm)

References B_CrtYd, SHAPE_POLY_SET::CacheTriangulation(), SHAPE_POLY_SET::CHAMFER_ACUTE_CORNERS, EDA_ITEM::ClearFlags(), ConvertOutlineToPolygon(), F_CrtYd, GraphicalItems(), SHAPE_POLY_SET::Inflate(), m_poly_courtyard_back, m_poly_courtyard_front, MALFORMED_B_COURTYARD, MALFORMED_COURTYARDS, MALFORMED_F_COURTYARD, Millimeter2iu(), PCB_FP_SHAPE_T, SHAPE_POLY_SET::RemoveAllContours(), and EDA_ITEM::SetFlags().

Referenced by AR_AUTOPLACER::buildFpAreas(), BOARD_INSPECTION_TOOL::InspectConstraints(), BOARD_INSPECTION_TOOL::reportClearance(), and DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckFootprintAttributes()

void FOOTPRINT::CheckFootprintAttributes ( const std::function< void(const wxString &msg)> *  aErrorHandler)

Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the 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 2095 of file footprint.cpp.

2096 {
2097 
2098  int likelyAttr = GetLikelyAttribute();
2099  int setAttr = ( GetAttributes() & ( FP_SMD | FP_THROUGH_HOLE ) );
2100 
2101  // This is only valid if the footprint doesn't have FP_SMD and FP_THROUGH_HOLE set
2102  // Which is, unfortunately, possible in theory but not in the UI (I think)
2103  if( aErrorHandler && likelyAttr != setAttr )
2104  {
2105  wxString msg;
2106 
2107  if( likelyAttr == FP_THROUGH_HOLE )
2108  {
2109  msg.Printf( _( "Expected \"Through hole\" type but set to \"%s\"" ), GetTypeName() );
2110  }
2111  else if( likelyAttr == FP_SMD )
2112  {
2113  msg.Printf( _( "Expected \"SMD\" type but set to \"%s\"" ), GetTypeName() );
2114  }
2115  else
2116  {
2117  msg.Printf( _( "Expected \"Other\" type but set to \"%s\"" ), GetTypeName() );
2118  }
2119 
2120  msg = "(" + msg + ")";
2121 
2122  (*aErrorHandler)( msg );
2123  }
2124 }
int GetLikelyAttribute() const
Returns the most likely attribute based on pads Either FP_THROUGH_HOLE/FP_SMD/OTHER(0)
Definition: footprint.cpp:653
#define _(s)
int GetAttributes() const
Definition: footprint.h:236
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:701

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

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ CheckFootprintTHPadNoHoles()

void FOOTPRINT::CheckFootprintTHPadNoHoles ( const std::function< void(const wxString &msg, const wxPoint &position)> *  aErrorHandler)

Test if footprint attributes for type (SMD/Through hole/Other) match the expected type based on the 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 2126 of file footprint.cpp.

2129 {
2130  if( aErrorHandler == nullptr )
2131  return;
2132 
2133  for( const PAD* pad: Pads() )
2134  {
2135 
2136  if( pad->GetAttribute() != PAD_ATTRIB::PTH
2137  && pad->GetAttribute() != PAD_ATTRIB::NPTH )
2138  continue;
2139 
2140  if( pad->GetDrillSizeX() < 1 || pad->GetDrillSizeX() < 1 )
2141  {
2142  wxString msg;
2143  msg.Printf( _( "(pad \"%s\")" ), pad->GetNumber() );
2144 
2145  (*aErrorHandler)( msg, pad->GetPosition() );
2146  }
2147  }
2148 }
PADS & Pads()
Definition: footprint.h:169
Plated through hole pad.
like PAD_PTH, but not plated
#define _(s)
Definition: pad.h:57

References _, NPTH, pad, Pads(), and PTH.

Referenced by DIALOG_FOOTPRINT_CHECKER::runChecks().

◆ ClassOf()

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

Adds an item to the container.

Parameters
aModedecides whether the item is added in the beginning or at the end of the list.

Definition at line 118 of file footprint.h.

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

505 {
506  // Force the ORPHANED dummy net info for all pads.
507  // ORPHANED dummy net does not depend on a board
508  for( PAD* pad : m_pads )
509  pad->SetNetCode( NETINFO_LIST::ORPHANED );
510 }
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:376
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

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

153 { m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), BuildPolyCourtyards(), 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(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), EE_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::narrowSelection(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 165 of file eda_item.h.

166  {
168  DO_NOT_DRAW );
169  }
#define DO_NOT_DRAW
Used to disable draw function.
#define STARTPOINT
When a line is selected, these flags indicate which.
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define CANDIDATE
flag indicating that the structure is connected
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define TEMP_SELECTED
flag indicating that the structure has already selected

References CANDIDATE, EDA_ITEM::ClearFlags(), DO_NOT_DRAW, ENDPOINT, IS_LINKED, SKIP_STRUCT, STARTPOINT, and TEMP_SELECTED.

Referenced by 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 1292 of file footprint.cpp.

1293 {
1294  return new FOOTPRINT( *this );
1295 }
FOOTPRINT(BOARD *parent)
Definition: footprint.cpp:51

References FOOTPRINT().

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

1951 {
1952  int textMargin = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
1953 
1954  SHAPE_POLY_SET footprintRegion( GetBoundingHull() );
1955  SHAPE_POLY_SET coveredRegion;
1956 
1957  TransformPadsWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
1958  ERROR_OUTSIDE );
1959 
1960  TransformFPShapesWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, textMargin,
1961  ARC_LOW_DEF, ERROR_OUTSIDE,
1962  true, /* include text */
1963  false /* include shapes */ );
1964 
1965  for( int i = 0; i < aCollector.GetCount(); ++i )
1966  {
1967  const BOARD_ITEM* item = aCollector[i];
1968 
1969  switch( item->Type() )
1970  {
1971  case PCB_FP_TEXT_T:
1972  case PCB_FP_SHAPE_T:
1973  if( item->GetParent() != this )
1974  {
1975  item->TransformShapeWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, 0,
1976  ARC_LOW_DEF, ERROR_OUTSIDE );
1977  }
1978  break;
1979 
1980  case PCB_TEXT_T:
1981  case PCB_SHAPE_T:
1982  case PCB_TRACE_T:
1983  case PCB_ARC_T:
1984  case PCB_VIA_T:
1985  item->TransformShapeWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, 0,
1986  ARC_LOW_DEF, ERROR_OUTSIDE );
1987  break;
1988 
1989  case PCB_FOOTPRINT_T:
1990  if( item != this )
1991  {
1992  const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( item );
1993  coveredRegion.AddOutline( footprint->GetBoundingHull().Outline( 0 ) );
1994  }
1995  break;
1996 
1997  default:
1998  break;
1999  }
2000  }
2001 
2002  double footprintRegionArea = polygonArea( footprintRegion );
2003  double uncoveredRegionArea = footprintRegionArea - polygonArea( coveredRegion );
2004  double coveredArea = footprintRegionArea - uncoveredRegionArea;
2005  double ratio = ( coveredArea / footprintRegionArea );
2006 
2007  // Test for negative ratio (should not occur).
2008  // better to be conservative (this will result in the disambiguate dialog)
2009  if( ratio < 0.0 )
2010  return 1.0;
2011 
2012  return std::min( ratio, 1.0 );
2013 }
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:847
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual double OnePixelInIU() const =0
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
const COLLECTORS_GUIDE * GetGuide() const
Definition: collectors.h:339
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
void TransformPadsWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aSkipNPTHPadsWihNoCopper=false, bool aSkipPlatedPads=false, bool aSkipNonPlatedPads=false) const
Generate pads shapes on layer aLayer as polygons and adds these polygons to aCornerBuffer.
Definition: footprint.cpp:2208
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void TransformFPShapesWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIncludeText=true, bool aIncludeShapes=true) const
Generate shapes of graphic items (outlines) on layer aLayer as polygons and adds these polygons to aC...
Definition: footprint.cpp:2306
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:73
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
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:144
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
static double polygonArea(SHAPE_POLY_SET &aPolySet)
Definition: footprint.cpp:1854

References SHAPE_POLY_SET::AddOutline(), 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_SHAPE_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, polygonArea(), TransformFPShapesWithClearanceToPolygon(), TransformPadsWithClearanceToPolygon(), BOARD_ITEM::TransformShapeWithClearanceToPolygon(), EDA_ITEM::Type(), and UNDEFINED_LAYER.

Referenced by PCB_SELECTION_TOOL::GuessSelectionCandidates().

◆ Delete()

virtual void BOARD_ITEM_CONTAINER::Delete ( BOARD_ITEM aItem)
inlinevirtualinherited

Removes an item from the container and deletes it.

Definition at line 74 of file board_item_container.h.

75  {
76  Remove( aItem );
77  delete aItem;
78  }
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 BOARD_DRC_ITEMS_PROVIDER::DeleteItem(), 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 128 of file board_item.cpp.

129 {
130  BOARD_ITEM_CONTAINER* parent = GetParent();
131 
132  if( parent )
133  parent->Remove( this );
134 
135  delete this;
136 }
virtual void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL)=0
Removes an item from the container.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135

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

1725 {
1726  FOOTPRINT* dupe = (FOOTPRINT*) Clone();
1727  const_cast<KIID&>( dupe->m_Uuid ) = KIID();
1728 
1729  dupe->RunOnChildren( [&]( BOARD_ITEM* child )
1730  {
1731  const_cast<KIID&>( child->m_Uuid ) = KIID();
1732  });
1733 
1734  return static_cast<BOARD_ITEM*>( dupe );
1735 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:474
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1298
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1292

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

1739 {
1740  BOARD_ITEM* new_item = nullptr;
1741  FP_ZONE* new_zone = nullptr;
1742 
1743  switch( aItem->Type() )
1744  {
1745  case PCB_PAD_T:
1746  {
1747  PAD* new_pad = new PAD( *static_cast<const PAD*>( aItem ) );
1748  const_cast<KIID&>( new_pad->m_Uuid ) = KIID();
1749 
1750  if( aAddToFootprint )
1751  m_pads.push_back( new_pad );
1752 
1753  new_item = new_pad;
1754  break;
1755  }
1756 
1757  case PCB_FP_ZONE_T:
1758  {
1759  new_zone = new FP_ZONE( *static_cast<const FP_ZONE*>( aItem ) );
1760  const_cast<KIID&>( new_zone->m_Uuid ) = KIID();
1761 
1762  if( aAddToFootprint )
1763  m_fp_zones.push_back( new_zone );
1764 
1765  new_item = new_zone;
1766  break;
1767  }
1768 
1769  case PCB_FP_TEXT_T:
1770  {
1771  FP_TEXT* new_text = new FP_TEXT( *static_cast<const FP_TEXT*>( aItem ) );
1772  const_cast<KIID&>( new_text->m_Uuid ) = KIID();
1773 
1774  if( new_text->GetType() == FP_TEXT::TEXT_is_REFERENCE )
1775  {
1776  new_text->SetText( wxT( "${REFERENCE}" ) );
1777  new_text->SetType( FP_TEXT::TEXT_is_DIVERS );
1778  }
1779  else if( new_text->GetType() == FP_TEXT::TEXT_is_VALUE )
1780  {
1781  new_text->SetText( wxT( "${VALUE}" ) );
1782  new_text->SetType( FP_TEXT::TEXT_is_DIVERS );
1783  }
1784 
1785  if( aAddToFootprint )
1786  Add( new_text );
1787 
1788  new_item = new_text;
1789 
1790  break;
1791  }
1792 
1793  case PCB_FP_SHAPE_T:
1794  {
1795  FP_SHAPE* new_shape = new FP_SHAPE( *static_cast<const FP_SHAPE*>( aItem ) );
1796  const_cast<KIID&>( new_shape->m_Uuid ) = KIID();
1797 
1798  if( aAddToFootprint )
1799  Add( new_shape );
1800 
1801  new_item = new_shape;
1802  break;
1803  }
1804 
1805  case PCB_GROUP_T:
1806  new_item = static_cast<const PCB_GROUP*>( aItem )->DeepDuplicate();
1807  break;
1808 
1809  case PCB_FOOTPRINT_T:
1810  // Ignore the footprint itself
1811  break;
1812 
1813  default:
1814  // Un-handled item for duplication
1815  wxFAIL_MSG( "Duplication not supported for items of class " + aItem->GetClass() );
1816  break;
1817  }
1818 
1819  return new_item;
1820 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void SetType(TEXT_TYPE aType)
Definition: fp_text.h:140
Definition: kiid.h:44
FP_ZONES m_fp_zones
Definition: footprint.h:734
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
TEXT_TYPE GetType() const
Definition: fp_text.h:141
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
const KIID m_Uuid
Definition: eda_item.h:474
virtual wxString GetClass() const =0
Return the class name.
class ZONE, managed by a footprint
Definition: typeinfo.h:94
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
Definition: pad.h:57
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References Add(), EDA_ITEM::GetClass(), FP_TEXT::GetType(), m_fp_zones, m_pads, EDA_ITEM::m_Uuid, PAD, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_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 1074 of file footprint.cpp.

1075 {
1076  bool can_select = aSearchAfterMe ? false : true;
1077 
1078  for( PAD* pad : m_pads )
1079  {
1080  if( !can_select && pad == aSearchAfterMe )
1081  {
1082  can_select = true;
1083  continue;
1084  }
1085 
1086  if( can_select && pad->GetNumber() == aPadNumber )
1087  return pad;
1088  }
1089 
1090  return nullptr;
1091 }
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

References m_pads, and pad.

Referenced by PCB_EDIT_FRAME::ExchangeFootprint(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), BOARD_NETLIST_UPDATER::testConnectivity(), and DRC_TEST_PROVIDER_LVS::testFootprints().

◆ FixUuids()

bool FOOTPRINT::FixUuids ( )

Old footprints do not alway 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 227 of file footprint.cpp.

228 {
229  // replace null UUIDs if any by a valid uuid
230  std::vector< BOARD_ITEM* > item_list;
231 
232  item_list.push_back( m_reference );
233  item_list.push_back( m_value );
234 
235  for( PAD* pad : m_pads )
236  item_list.push_back( pad );
237 
238  for( BOARD_ITEM* gr_item : m_drawings )
239  item_list.push_back( gr_item );
240 
241  // Note: one cannot fix null UUIDs inside the group, but it should not happen
242  // because null uuids can be found in old footprints, therefore without group
243  for( PCB_GROUP* group : m_fp_groups )
244  item_list.push_back( group );
245 
246  // Probably notneeded, because old fp do not have zones. But just in case.
247  for( FP_ZONE* zone : m_fp_zones )
248  item_list.push_back( zone );
249 
250  bool changed = false;
251 
252  for( BOARD_ITEM* item : item_list )
253  {
254  if( item->m_Uuid == niluuid )
255  {
256  const_cast<KIID&>( item->m_Uuid ) = KIID();
257  changed = true;
258  }
259  }
260 
261  return changed;
262 }
KIID niluuid(0)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
FP_TEXT * m_reference
Definition: footprint.h:739
FP_TEXT * m_value
Definition: footprint.h:740
Definition: kiid.h:44
FP_ZONES m_fp_zones
Definition: footprint.h:734
DRAWINGS m_drawings
Definition: footprint.h:732
Definition: pad.h:57
FP_GROUPS m_fp_groups
Definition: footprint.h:735
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733

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() [1/2]

void FOOTPRINT::Flip ( const wxPoint &  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 1490 of file footprint.cpp.

1491 {
1492  // Move footprint to its final position:
1493  wxPoint finalPos = m_pos;
1494 
1495  // Now Flip the footprint.
1496  // Flipping a footprint is a specific transform: it is not mirrored like a text.
1497  // We have to change the side, and ensure the footprint rotation is modified according to the
1498  // transform, because this parameter is used in pick and place files, and when updating the
1499  // footprint from library.
1500  // When flipped around the X axis (Y coordinates changed) orientation is negated
1501  // When flipped around the Y axis (X coordinates changed) orientation is 180 - old orient.
1502  // Because it is specific to a footprint, we flip around the X axis, and after rotate 180 deg
1503 
1504  MIRROR( finalPos.y, aCentre.y );
1505 
1506  SetPosition( finalPos );
1507 
1508  // Flip layer
1509  SetLayer( FlipLayer( GetLayer() ) );
1510 
1511  // Reverse mirror orientation.
1512  m_orient = -m_orient;
1513 
1515 
1516  // Mirror pads to other side of board.
1517  for( PAD* pad : m_pads )
1518  pad->Flip( m_pos, false );
1519 
1520  // Mirror zones to other side of board.
1521  for( ZONE* zone : m_fp_zones )
1522  zone->Flip( m_pos, false );
1523 
1524  // Mirror reference and value.
1525  m_reference->Flip( m_pos, false );
1526  m_value->Flip( m_pos, false );
1527 
1528  // Reverse mirror footprint graphics and texts.
1529  for( BOARD_ITEM* item : m_drawings )
1530  {
1531  switch( item->Type() )
1532  {
1533  case PCB_FP_SHAPE_T:
1534  static_cast<FP_SHAPE*>( item )->Flip( m_pos, false );
1535  break;
1536 
1537  case PCB_FP_TEXT_T:
1538  static_cast<FP_TEXT*>( item )->Flip( m_pos, false );
1539  break;
1540 
1541  default:
1542  wxMessageBox( wxT( "FOOTPRINT::Flip() error: Unknown Draw Type" ) );
1543  break;
1544  }
1545  }
1546 
1547  // Now rotate 180 deg if required
1548  if( aFlipLeftRight )
1549  Rotate( aCentre, 1800.0 );
1550 
1554 
1555  m_cachedHull.Mirror( aFlipLeftRight, !aFlipLeftRight, m_pos );
1556 
1558 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
SHAPE_POLY_SET m_poly_courtyard_back
Definition: footprint.h:787
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
double m_orient
Definition: footprint.h:737
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:530
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
FP_TEXT * m_reference
Definition: footprint.h:739
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:758
void NORMALIZE_ANGLE_180(T &Angle)
Definition: trigo.h:398
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
FP_TEXT * m_value
Definition: footprint.h:740
FP_ZONES m_fp_zones
Definition: footprint.h:734
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip entity during footprint flip.
Definition: fp_text.cpp:137
SHAPE_POLY_SET m_poly_courtyard_front
Definition: footprint.h:786
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:761
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
wxPoint m_pos
Definition: footprint.h:738
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: footprint.cpp:1465
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:756
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:760
DRAWINGS m_drawings
Definition: footprint.h:732
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1561
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
PADS m_pads
Definition: footprint.h:733

References FP_TEXT::Flip(), FlipLayer(), BOARD_ITEM::GetLayer(), m_boundingBoxCacheTimeStamp, m_cachedHull, m_drawings, m_fp_zones, m_orient, m_pads, m_poly_courtyard_back, m_poly_courtyard_front, m_pos, m_reference, m_textExcludedBBoxCacheTimeStamp, m_value, m_visibleBBoxCacheTimeStamp, MIRROR(), SHAPE_POLY_SET::Mirror(), NORMALIZE_ANGLE_180(), pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, Rotate(), BOARD_ITEM::SetLayer(), and SetPosition().

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

◆ Flip() [2/2]

void BOARD_ITEM::Flip ( const VECTOR2I aCentre,
bool  aFlipLeftRight 
)
inlineinherited

Definition at line 269 of file board_item.h.

270  {
271  Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight );
272  }
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight)
Flip this object, i.e.
Definition: board_item.cpp:196

References BOARD_ITEM::Flip(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 86 of file inspectable.h.

87  {
89  TYPE_ID thisType = TYPE_HASH( *this );
90  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
91  return object ? aProperty->getter( object ) : wxAny();
92  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
virtual wxAny getter(void *aObject) const =0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [2/3]

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

Definition at line 95 of file inspectable.h.

96  {
98  TYPE_ID thisType = TYPE_HASH( *this );
99  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
100  return object ? aProperty->get<T>( object ) : T();
101  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
T get(void *aObject)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Get() [3/3]

template<typename T >
boost::optional<T> INSPECTABLE::Get ( const wxString &  aProperty)
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  boost::optional<T> ret = T();
110 
111  if( prop )
112  {
113  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114 
115  if( object )
116  ret = prop->get<T>( object );
117  }
118 
119  return ret;
120  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
T get(void *aObject)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ GetAllDrawingLayers()

void FOOTPRINT::GetAllDrawingLayers ( int  aLayers[],
int &  aCount,
bool  aIncludePads = true 
) const

Return a set of all layers that this footprint has drawings on similar to ViewGetLayers().

Parameters
aLayersis an array to store layer ids.
aCountis the number of layers stored in the array.
aIncludePadscontrols whether to also include pad layers.

Definition at line 1324 of file footprint.cpp.

1325 {
1326  std::unordered_set<int> layers;
1327 
1328  for( BOARD_ITEM* item : m_drawings )
1329  layers.insert( static_cast<int>( item->GetLayer() ) );
1330 
1331  if( aIncludePads )
1332  {
1333  for( PAD* pad : m_pads )
1334  {
1335  int pad_layers[KIGFX::VIEW::VIEW_MAX_LAYERS], pad_layers_count;
1336  pad->ViewGetLayers( pad_layers, pad_layers_count );
1337 
1338  for( int i = 0; i < pad_layers_count; i++ )
1339  layers.insert( pad_layers[i] );
1340  }
1341  }
1342 
1343  aCount = layers.size();
1344  int i = 0;
1345 
1346  for( int layer : layers )
1347  aLayers[i++] = layer;
1348 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
DRAWINGS m_drawings
Definition: footprint.h:732
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

References m_drawings, m_pads, pad, and KIGFX::VIEW::VIEW_MAX_LAYERS.

◆ GetArea()

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

Definition at line 643 of file footprint.cpp.

644 {
645  EDA_RECT bbox = GetBoundingBox( false, false );
646 
647  double w = std::abs( static_cast<double>( bbox.GetWidth() ) ) + aPadding;
648  double h = std::abs( static_cast<double>( bbox.GetHeight() ) ) + aPadding;
649  return w * h;
650 }
int GetWidth() const
Definition: eda_rect.h:109
int GetHeight() const
Definition: eda_rect.h:110
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:736
Handle the component boundary box.
Definition: eda_rect.h:42

References GetBoundingBox(), EDA_RECT::GetHeight(), and EDA_RECT::GetWidth().

Referenced by sortFootprintsByComplexity(), sortFootprintsByRatsnestSize(), and SpreadFootprints().

◆ GetAttributes()

◆ GetBoard() [1/2]

const BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

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

Definition at line 36 of file board_item.cpp.

37 {
38  if( Type() == PCB_T )
39  return static_cast<const BOARD*>( this );
40 
41  BOARD_ITEM* parent = GetParent();
42 
43  if( parent )
44  return parent->GetBoard();
45 
46  return nullptr;
47 }
Definition: typeinfo.h:84
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

Referenced by ZONE_FILLER::addHoleKnockout(), PAD::BuildEffectivePolygon(), PAD::BuildEffectiveShapes(), ZONE::BuildSmoothedPoly(), calcIsInsideArea(), KIGFX::PCB_PAINTER::Draw(), KIGFX::PCB_PAINTER::draw(), PCB_LAYER_VALUE::EqualTo(), existsOnLayer(), exprFromTo(), PCB_VIA::FlashLayer(), PAD::FlashLayer(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), PCB_TRACK::Flip(), FP_SHAPE::Flip(), PCB_SHAPE::Flip(), FP_TEXT::Flip(), PCB_DIMENSION_BASE::Flip(), PCB_ARC::Flip(), PCB_VIA::Flip(), ZONE::Flip(), PCB_EXPR_CONTEXT::GetBoard(), BOARD_ITEM::GetBoard(), GetBoundingBox(), GetBoundingHull(), BOARD_CONNECTED_ITEM::GetEffectiveNetclass(), PCB_VIA::GetEffectiveShape(), ZONE::GetInteractingZones(), BOARD_ITEM::GetLayerName(), PCB_VIA::GetMinAnnulus(), PCB_DRAW_PANEL_GAL::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), BOARD_CONNECTED_ITEM::GetOwnClearance(), ZONE::GetSelectMenuText(), DRC_ENGINE::GetShape(), FP_TEXT::GetShownText(), PAD::GetSolderMaskMargin(), PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), inDiffPair(), insideArea(), insideBackCourtyard(), insideCourtyard(), insideFrontCourtyard(), isInsideArea(), isInsideCourtyard(), BOARD_ITEM::IsLocked(), BOARD_ITEM::layerMaskDescribe(), PCB_VIA::layerMaskDescribe(), CONVERT_TOOL::makePolysFromCircles(), PAD::MergePrimitivesAsPolygon(), EAGLE_PLUGIN::packageWire(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD::ResolveDRCExclusions(), BOARD_CONNECTED_ITEM::SetNetCode(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), ZONE::TransformSmoothedOutlineToPolygon(), ZONE::TransformSolidAreasShapesToPolygon(), PCB_TRACK::ViewBBox(), ViewBBox(), PCB_VIA::ViewGetLOD(), and PAD::ViewGetLOD().

◆ GetBoard() [2/2]

BOARD * BOARD_ITEM::GetBoard ( )
virtualinherited

Definition at line 50 of file board_item.cpp.

51 {
52  if( Type() == PCB_T )
53  return static_cast<BOARD*>( this );
54 
55  BOARD_ITEM* parent = GetParent();
56 
57  if( parent )
58  return parent->GetBoard();
59 
60  return nullptr;
61 }
Definition: typeinfo.h:84
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

◆ GetBoundingBox() [1/2]

const EDA_RECT 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 736 of file footprint.cpp.

737 {
738  return GetBoundingBox( true, true );
739 }
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:736

Referenced by AR_AUTOPLACER::buildFpAreas(), calcIsInsideCourtyard(), PCB_GRID_HELPER::computeAnchors(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), GetArea(), 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 EDA_RECT FOOTPRINT::GetBoundingBox ( bool  aIncludeText,
bool  aIncludeInvisibleText 
) const

Definition at line 742 of file footprint.cpp.

743 {
744  const BOARD* board = GetBoard();
745 
746  if( board )
747  {
748  if( aIncludeText && aIncludeInvisibleText )
749  {
750  if( m_boundingBoxCacheTimeStamp >= board->GetTimeStamp() )
751  return m_cachedBoundingBox;
752  }
753  else if( aIncludeText )
754  {
755  if( m_visibleBBoxCacheTimeStamp >= board->GetTimeStamp() )
756  return m_cachedVisibleBBox;
757  }
758  else
759  {
762  }
763  }
764 
765  EDA_RECT area;
766 
767  area.SetOrigin( m_pos );
768  area.SetEnd( m_pos );
769  area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area
770 
771  for( BOARD_ITEM* item : m_drawings )
772  {
773  if( item->Type() == PCB_FP_SHAPE_T )
774  area.Merge( item->GetBoundingBox() );
775  }
776 
777  for( PAD* pad : m_pads )
778  area.Merge( pad->GetBoundingBox() );
779 
780  for( FP_ZONE* zone : m_fp_zones )
781  area.Merge( zone->GetBoundingBox() );
782 
783  bool noDrawItems = ( m_drawings.empty() && m_pads.empty() && m_fp_zones.empty() );
784 
785  // Groups do not contribute to the rect, only their members
786  if( aIncludeText || noDrawItems )
787  {
788  for( BOARD_ITEM* item : m_drawings )
789  {
790  if( item->Type() == PCB_FP_TEXT_T )
791  area.Merge( item->GetBoundingBox() );
792  }
793 
794  // This can be further optimized when aIncludeInvisibleText is true, but currently
795  // leaving this as is until it's determined there is a noticeable speed hit.
796  bool valueLayerIsVisible = true;
797  bool refLayerIsVisible = true;
798 
799  if( board )
800  {
801  // The first "&&" conditional handles the user turning layers off as well as layers
802  // not being present in the current PCB stackup. Values, references, and all
803  // footprint text can also be turned off via the GAL meta-layers, so the 2nd and
804  // 3rd "&&" conditionals handle that.
805  valueLayerIsVisible = board->IsLayerVisible( m_value->GetLayer() )
807  && board->IsElementVisible( LAYER_MOD_TEXT );
808 
809  refLayerIsVisible = board->IsLayerVisible( m_reference->GetLayer() )
811  && board->IsElementVisible( LAYER_MOD_TEXT );
812  }
813 
814 
815  if( ( m_value->IsVisible() && valueLayerIsVisible )
816  || aIncludeInvisibleText || noDrawItems )
817  area.Merge( m_value->GetBoundingBox() );
818 
819  if( ( m_reference->IsVisible() && refLayerIsVisible )
820  || aIncludeInvisibleText || noDrawItems )
821  area.Merge( m_reference->GetBoundingBox() );
822  }
823 
824  if( board )
825  {
826  if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
827  {
829  m_cachedBoundingBox = area;
830  }
831  else if( aIncludeText )
832  {
834  m_cachedVisibleBBox = area;
835  }
836  else
837  {
840  }
841  }
842 
843  return area;
844 }
EDA_RECT m_cachedVisibleBBox
Definition: footprint.h:757
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
int GetTimeStamp() const
Definition: board.h:215
show footprints values (when texts are visible)
Definition: layer_ids.h:206
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
FP_TEXT * m_reference
Definition: footprint.h:739
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:758
FP_TEXT * m_value
Definition: footprint.h:740
EDA_RECT m_cachedBoundingBox
Definition: footprint.h:755
FP_ZONES m_fp_zones
Definition: footprint.h:734
virtual bool IsVisible() const
Definition: eda_text.h:207
void SetEnd(int x, int y)
Definition: eda_rect.h:182
wxPoint m_pos
Definition: footprint.h:738
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:756
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:533
show footprints references (when texts are visible)
Definition: layer_ids.h:207
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:473
const EDA_RECT GetBoundingBox() const override
Set absolute coordinates.
Definition: fp_text.cpp:227
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:760
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_RECT m_cachedTextExcludedBBox
Definition: footprint.h:759
DRAWINGS m_drawings
Definition: footprint.h:732
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
Definition: pad.h:57
static constexpr int Millimeter2iu(double mm)
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References BOARD_ITEM::GetBoard(), FP_TEXT::GetBoundingBox(), BOARD_ITEM::GetLayer(), BOARD::GetTimeStamp(), EDA_RECT::Inflate(), BOARD::IsElementVisible(), 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_reference, m_textExcludedBBoxCacheTimeStamp, m_value, m_visibleBBoxCacheTimeStamp, EDA_RECT::Merge(), Millimeter2iu(), pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, EDA_RECT::SetEnd(), and EDA_RECT::SetOrigin().

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

848 {
849  const BOARD* board = GetBoard();
850 
851  if( board )
852  {
853  if( m_hullCacheTimeStamp >= board->GetTimeStamp() )
854  return m_cachedHull;
855  }
856 
857  SHAPE_POLY_SET rawPolys;
858  SHAPE_POLY_SET hull;
859 
860  for( BOARD_ITEM* item : m_drawings )
861  {
862  if( item->Type() == PCB_FP_SHAPE_T )
863  {
864  item->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
865  ERROR_OUTSIDE );
866  }
867 
868  // We intentionally exclude footprint text from the bounding hull.
869  }
870 
871  for( PAD* pad : m_pads )
872  {
873  pad->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
874  ERROR_OUTSIDE );
875  // In case hole is larger than pad
876  pad->TransformHoleWithClearanceToPolygon( rawPolys, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
877  }
878 
879  for( FP_ZONE* zone : m_fp_zones )
880  {
881  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
882  {
883  SHAPE_POLY_SET layerPoly = zone->GetFilledPolysList( layer );
884 
885  for( int ii = 0; ii < layerPoly.OutlineCount(); ii++ )
886  {
887  const SHAPE_LINE_CHAIN& poly = layerPoly.COutline( ii );
888  rawPolys.AddOutline( poly );
889  }
890  }
891  }
892 
893  // If there are some graphic items, build the actual hull.
894  // However if no items, create a minimal polygon (can happen if a footprint
895  // is created with no item: it contains only 2 texts.
896  if( rawPolys.OutlineCount() == 0 )
897  {
898  // generate a small dummy rectangular outline around the anchor
899  const int halfsize = Millimeter2iu( 1.0 );
900 
901  rawPolys.NewOutline();
902 
903  // add a square:
904  rawPolys.Append( GetPosition().x - halfsize, GetPosition().y - halfsize );
905  rawPolys.Append( GetPosition().x + halfsize, GetPosition().y - halfsize );
906  rawPolys.Append( GetPosition().x + halfsize, GetPosition().y + halfsize );
907  rawPolys.Append( GetPosition().x - halfsize, GetPosition().y + halfsize );
908  }
909 
910  std::vector<wxPoint> convex_hull;
911  BuildConvexHull( convex_hull, rawPolys );
912 
915 
916  for( const wxPoint& pt : convex_hull )
917  m_cachedHull.Append( pt );
918 
919  if( board )
921 
922  return m_cachedHull;
923 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
int GetTimeStamp() const
Definition: board.h:215
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
FP_ZONES m_fp_zones
Definition: footprint.h:734
Represent a set of closed polygons.
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:761
int NewOutline()
Creates a new hole in a given outline.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
wxPoint GetPosition() const override
Definition: footprint.h:187
DRAWINGS m_drawings
Definition: footprint.h:732
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
Definition: pad.h:57
static constexpr int Millimeter2iu(double mm)
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733
int m_hullCacheTimeStamp
Definition: footprint.h:762
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...
void BuildConvexHull(std::vector< wxPoint > &aResult, const std::vector< wxPoint > &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(), BuildConvexHull(), SHAPE_POLY_SET::COutline(), ERROR_OUTSIDE, BOARD_ITEM::GetBoard(), GetPosition(), BOARD::GetTimeStamp(), m_cachedHull, m_drawings, m_fp_zones, m_hullCacheTimeStamp, m_pads, Millimeter2iu(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), pad, PCB_FP_SHAPE_T, SHAPE_POLY_SET::RemoveAllContours(), and UNDEFINED_LAYER.

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

◆ GetCenter()

virtual wxPoint 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 PCB_ARC, PAD, PCB_SHAPE, and PCB_MARKER.

Definition at line 81 of file board_item.h.

82  {
83  return GetBoundingBox().GetCenter();
84  }
virtual const EDA_RECT GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:75
const wxPoint GetCenter() const
Definition: eda_rect.h:104

References EDA_ITEM::GetBoundingBox(), and EDA_RECT::GetCenter().

Referenced by PCB_GRID_HELPER::computeAnchors(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), and ALTIUM_PCB::HelperParseDimensions6Radial().

◆ GetClass()

wxString FOOTPRINT::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Implements EDA_ITEM.

Definition at line 603 of file footprint.h.

604  {
605  return wxT( "FOOTPRINT" );
606  }

Referenced by Visit().

◆ GetContextualTextVars()

void FOOTPRINT::GetContextualTextVars ( wxArrayString *  aVars) const

Return the list of system text vars for this footprint.

Definition at line 469 of file footprint.cpp.

470 {
471  aVars->push_back( wxT( "REFERENCE" ) );
472  aVars->push_back( wxT( "VALUE" ) );
473  aVars->push_back( wxT( "LAYER" ) );
474 }

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

1871 {
1872  int textMargin = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
1873  SHAPE_POLY_SET poly;
1874 
1875  if( aItem->Type() == PCB_MARKER_T )
1876  {
1877  const PCB_MARKER* marker = static_cast<const PCB_MARKER*>( aItem );
1878  SHAPE_LINE_CHAIN markerShape;
1879 
1880  marker->ShapeToPolygon( markerShape );
1881  return markerShape.Area();
1882  }
1883  else if( aItem->Type() == PCB_GROUP_T )
1884  {
1885  double combinedArea = 0.0;
1886 
1887  for( BOARD_ITEM* member : static_cast<const PCB_GROUP*>( aItem )->GetItems() )
1888  combinedArea += GetCoverageArea( member, aCollector );
1889 
1890  return combinedArea;
1891  }
1892  if( aItem->Type() == PCB_FOOTPRINT_T )
1893  {
1894  const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( aItem );
1895 
1896  poly = footprint->GetBoundingHull();
1897  }
1898  else if( aItem->Type() == PCB_FP_TEXT_T )
1899  {
1900  const FP_TEXT* text = static_cast<const FP_TEXT*>( aItem );
1901 
1902  text->TransformTextShapeWithClearanceToPolygon( poly, UNDEFINED_LAYER, textMargin,
1903  ARC_LOW_DEF, ERROR_OUTSIDE );
1904  }
1905  else if( aItem->Type() == PCB_SHAPE_T )
1906  {
1907  // Approximate "linear" shapes with just their width squared, as we don't want to consider
1908  // a linear shape as being much bigger than another for purposes of selection filtering
1909  // just because it happens to be really long.
1910 
1911  const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
1912 
1913  switch( shape->GetShape() )
1914  {
1915  case SHAPE_T::SEGMENT:
1916  case SHAPE_T::ARC:
1917  case SHAPE_T::BEZIER:
1918  return shape->GetWidth() * shape->GetWidth();
1919 
1920  case SHAPE_T::RECT:
1921  case SHAPE_T::CIRCLE:
1922  case SHAPE_T::POLY:
1923  {
1924  if( !shape->IsFilled() )
1925  return shape->GetWidth() * shape->GetWidth();
1926 
1928  }
1929 
1930  default:
1932  ARC_LOW_DEF, ERROR_OUTSIDE );
1933  }
1934  }
1935  else if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
1936  {
1937  double width = static_cast<const PCB_TRACK*>( aItem )->GetWidth();
1938  return width * width;
1939  }
1940  else
1941  {
1943  ARC_LOW_DEF, ERROR_OUTSIDE );
1944  }
1945 
1946  return polygonArea( poly );
1947 }
static double GetCoverageArea(const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: footprint.cpp:1870
int GetWidth() const
Definition: eda_shape.h:89
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:847
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
virtual double OnePixelInIU() const =0
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
double Area(bool aAbsolute=true) const
Return the area of this chain.
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool IsFilled() const
Definition: eda_shape.h:81
const COLLECTORS_GUIDE * GetGuide() const
Definition: collectors.h:339
Represent a set of closed polygons.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
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...
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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:73
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:144
SHAPE_T GetShape() const
Definition: eda_shape.h:92
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
static double polygonArea(SHAPE_POLY_SET &aPolySet)
Definition: footprint.cpp:1854

References ARC, SHAPE_LINE_CHAIN::Area(), BEZIER, CIRCLE, ERROR_OUTSIDE, GetBoundingHull(), GENERAL_COLLECTOR::GetGuide(), 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_GROUP_T, PCB_MARKER_T, PCB_SHAPE_T, PCB_TRACE_T, POLY, polygonArea(), RECT, SEGMENT, MARKER_BASE::ShapeToPolygon(), text, BOARD_ITEM::TransformShapeWithClearanceToPolygon(), EDA_ITEM::Type(), and UNDEFINED_LAYER.

Referenced by PCB_SELECTION_TOOL::GuessSelectionCandidates().

◆ GetDescription()

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 157 of file eda_item.h.

158  {
159  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
161 
162  return m_flags & mask;
163  }
#define IS_NEW
New item, just created.
#define IS_RESIZING
Item being resized.
#define IS_DRAGGING
Item being dragged.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_MOVING
Item being moved.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_DRAGGING, IS_MOVING, IS_NEW, IS_PASTED, IS_RESIZING, IS_WIRE_IMAGE, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by 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_TOOL::Properties(), PAD_TOOL::recombinePad(), SCH_EDIT_FRAME::SchematicCleanUp(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ GetEffectiveShape()

std::shared_ptr< SHAPE > FOOTPRINT::GetEffectiveShape ( PCB_LAYER_ID  aLayer = UNDEFINED_LAYER) 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 2016 of file footprint.cpp.

2017 {
2018  std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2019 
2020  // There are several possible interpretations here:
2021  // 1) the bounding box (without or without invisible items)
2022  // 2) just the pads and "edges" (ie: non-text graphic items)
2023  // 3) the courtyard
2024 
2025  // We'll go with (2) for now....
2026 
2027  for( PAD* pad : Pads() )
2028  shape->AddShape( pad->GetEffectiveShape( aLayer )->Clone() );
2029 
2030  for( BOARD_ITEM* item : GraphicalItems() )
2031  {
2032  if( item->Type() == PCB_FP_SHAPE_T )
2033  shape->AddShape( item->GetEffectiveShape( aLayer )->Clone() );
2034  }
2035 
2036  return shape;
2037 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
PADS & Pads()
Definition: footprint.h:169
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
Definition: pad.h:57

References GraphicalItems(), pad, Pads(), and PCB_FP_SHAPE_T.

◆ GetFlag()

int FOOTPRINT::GetFlag ( ) const
inline

Definition at line 241 of file footprint.h.

241 { return m_arflag; }
int m_arflag
Definition: footprint.h:776

References m_arflag.

Referenced by DSN::SPECCTRA_DB::FromBOARD(), AR_AUTOPLACER::pickFootprint(), and sortFootprintsByRatsnestSize().

◆ GetFlags()

◆ GetFocusPosition()

virtual const wxPoint EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

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

Reimplemented in BOARD, PCB_TRACK, and PCB_SHAPE.

Definition at line 258 of file eda_item.h.

258 { return GetPosition(); }
virtual wxPoint GetPosition() const
Definition: eda_item.h:251

References EDA_ITEM::GetPosition().

Referenced by PCB_BASE_FRAME::FocusOnItem(), and SCH_EDIT_FRAME::FocusOnItem().

◆ GetFPID()

const LIB_ID& FOOTPRINT::GetFPID ( ) const
inline

Definition at line 195 of file footprint.h.

195 { return m_fpid; }
LIB_ID m_fpid
Definition: footprint.h:741

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_EDIT_FRAME::editFootprintProperties(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PCB_EDIT_FRAME::ExchangeFootprint(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), BOARD_EDITOR_CONTROL::ExportNetlist(), PCB_PLUGIN::FootprintSave(), FP_LIB_TABLE::FootprintSave(), PCB_PLUGIN::format(), PLACE_FILE_EXPORTER::GenPositionData(), FOOTPRINT_EDIT_FRAME::GetLoadedFPID(), 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(), 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_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), PCB_CONTROL::UpdateMessagePanel(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetFpPadsLocalBbox()

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

714 {
715  EDA_RECT area;
716 
717  // We want the bounding box of the footprint pads at rot 0, not flipped
718  // Create such a image:
719  FOOTPRINT dummy( *this );
720 
721  dummy.SetPosition( wxPoint( 0, 0 ) );
722 
723  if( dummy.IsFlipped() )
724  dummy.Flip( wxPoint( 0, 0 ) , false );
725 
726  if( dummy.GetOrientation() )
727  dummy.SetOrientation( 0 );
728 
729  for( PAD* pad : dummy.Pads() )
730  area.Merge( pad->GetBoundingBox() );
731 
732  return area;
733 }
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:252
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
Handle the component boundary box.
Definition: eda_rect.h:42
Definition: pad.h:57

References dummy(), EDA_RECT::Merge(), pad, and EDA_ITEM::SetPosition().

◆ GetInitialComments()

const wxArrayString* FOOTPRINT::GetInitialComments ( ) const
inline

Definition at line 689 of file footprint.h.

689 { return m_initial_comments; }
wxArrayString * m_initial_comments
Definition: footprint.h:783

References m_initial_comments.

Referenced by PCB_PLUGIN::format().

◆ GetKeywords()

◆ GetLastEditTime()

timestamp_t FOOTPRINT::GetLastEditTime ( ) const
inline

Definition at line 344 of file footprint.h.

344 { return m_lastEditTime; }
timestamp_t m_lastEditTime
Definition: footprint.h:775

References m_lastEditTime.

Referenced by PCB_PLUGIN::format(), and PCB_CONTROL::UpdateMessagePanel().

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Return the primary layer this item is on.

Reimplemented in ZONE.

Definition at line 142 of file board_item.h.

142 { return m_layer; }
PCB_LAYER_ID m_layer
Definition: board_item.h:318

References BOARD_ITEM::m_layer.

Referenced by CN_LIST::Add(), BOARD_ADAPTER::addFootprintShapesWithClearance(), GRAPHICS_CLEANER::areEquivalent(), BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), AR_AUTOPLACER::buildFpAreas(), TRACKS_CLEANER::cleanup(), CreateBoardSection(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewFootprint(), CreateRoutesSection(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_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(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), PCB_TRACK::Flip(), FP_SHAPE::Flip(), PCB_SHAPE::Flip(), FP_TEXT::Flip(), PCB_DIMENSION_BASE::Flip(), Flip(), PCB_ARC::Flip(), PCB_BASE_FRAME::FocusOnItem(), FOOTPRINT_DESC::FOOTPRINT_DESC(), PCB_PLUGIN::FootprintSave(), FootprintWriteShape(), PCB_PLUGIN::format(), PCB_PLUGIN::formatLayer(), FP_TEXT::FP_TEXT(), DSN::SPECCTRA_DB::FromBOARD(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), GetBoundingBox(), ZONE::GetLayer(), getMatchingTextItem(), PCB_TRACK::GetMsgPanelInfo(), PCB_VIA::GetMsgPanelInfo(), PAD::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(), isEdge(), PAD::IsFlipped(), IsFlipped(), PNS_KICAD_IFACE::IsItemVisible(), BOARD_ITEM::IsOnCopperLayer(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_CHECKER::OnSelectItem(), PCB_SHAPE::cmp_drawings::operator()(), PCB_TRACK::cmp_tracks::operator()(), BOARD_ITEM::ptr_cmp::operator()(), FOOTPRINT::cmp_drawings::operator()(), BOARD::cmp_items::operator()(), BOARD::cmp_drawings::operator()(), EAGLE_PLUGIN::packagePad(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintGraphicItems(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), BRDITEMS_PLOTTER::PlotPcbShape(), BRDITEMS_PLOTTER::PlotPcbTarget(), BRDITEMS_PLOTTER::PlotPcbText(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), PAD_TOOL::recombinePad(), CLIPBOARD_IO::SaveSelection(), CONVERT_TOOL::SegmentToArc(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::selectConnectedTracks(), GLOBAL_EDIT_TOOL::swapBoardItem(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncTrack(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), AR_AUTOPLACER::testFootprintOnBoard(), CONNECTIVITY_DATA::TestTrackEndpointDangling(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), BOARD_ADAPTER::transformFPShapesToPolygon(), TransformFPShapesWithClearanceToPolygon(), PCB_TRACK::ViewGetLayers(), FP_TEXT::ViewGetLayers(), FP_TEXT::ViewGetLOD(), FP_ZONE::ViewGetLOD(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::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 75 of file board_item.cpp.

76 {
77  const BOARD* board = GetBoard();
78 
79  if( board )
80  return board->GetLayerName( m_layer );
81 
82  // If no parent, return standard name
84 }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
PCB_LAYER_ID m_layer
Definition: board_item.h:318
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:606

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

Referenced by PCB_TARGET::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_SHAPE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_DIM_LEADER::GetMsgPanelInfo(), PCB_SHAPE::GetSelectMenuText(), PCB_TEXT::GetSelectMenuText(), FP_SHAPE::GetSelectMenuText(), PCB_TRACK::GetSelectMenuText(), PCB_DIMENSION_BASE::GetSelectMenuText(), PCB_TEXT::GetShownText(), and ResolveTextVar().

◆ GetLayerSet()

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

654 {
655  int smd_count = 0;
656  int tht_count = 0;
657 
658  for( PAD* pad : m_pads )
659  {
660  switch( pad->GetProperty() )
661  {
664  continue;
665 
666  case PAD_PROP::HEATSINK:
668  continue;
669 
670  case PAD_PROP::NONE:
671  case PAD_PROP::BGA:
672  case PAD_PROP::TESTPOINT:
673  break;
674  }
675 
676  switch( pad->GetAttribute() )
677  {
678  case PAD_ATTRIB::PTH:
679  tht_count++;
680  break;
681 
682  case PAD_ATTRIB::SMD:
683  smd_count++;
684  break;
685 
686  default:
687  break;
688  }
689  }
690 
691  if( tht_count > 0 )
692  return FP_THROUGH_HOLE;
693 
694  if( smd_count > 0 )
695  return FP_SMD;
696 
697  return 0;
698 }
Smd pad, appears on the solder paste layer (default)
a test point pad
Plated through hole pad.
a pad used as heat sink, usually in SMD footprints
Smd pad, used in BGA footprints.
a fiducial (usually a smd) local to the parent footprint
a fiducial (usually a smd) for the full board
no special fabrication property
a pad with a castellated through hole
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

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

214  {
215  if( aSource )
216  *aSource = wxString::Format( _( "footprint %s" ), GetReference() );
217 
218  return m_localClearance;
219  }
const wxString & GetReference() const
Definition: footprint.h:464
#define _(s)
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
int m_localClearance
Definition: footprint.h:767

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

◆ GetLocalSolderMaskMargin()

int FOOTPRINT::GetLocalSolderMaskMargin ( ) const
inline

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

1287 {
1288  return BITMAPS::module;
1289 }

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

927 {
928  wxString msg, msg2;
929 
930  aList.emplace_back( m_reference->GetShownText(), m_value->GetShownText() );
931 
932  if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER )
934  || aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) )
935  {
936  wxDateTime date( static_cast<time_t>( m_lastEditTime ) );
937 
938  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
939  if( m_lastEditTime && date.IsValid() )
940  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
941  else
942  msg = _( "Unknown" );
943 
944  aList.emplace_back( _( "Last Change" ), msg );
945  }
946  else if( aFrame->IsType( FRAME_PCB_EDITOR ) )
947  {
948  aList.emplace_back( _( "Board Side" ), IsFlipped() ? _( "Back (Flipped)" ) : _( "Front" ) );
949  }
950 
951  auto addToken = []( wxString* aStr, const wxString& aAttr )
952  {
953  if( !aStr->IsEmpty() )
954  *aStr += wxT( ", " );
955 
956  *aStr += aAttr;
957  };
958 
959  wxString status;
960  wxString attrs;
961 
962  if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
963  addToken( &status, _( "Locked" ) );
964 
965  if( m_fpStatus & FP_is_PLACED )
966  addToken( &status, _( "autoplaced" ) );
967 
969  addToken( &attrs, _( "not in schematic" ) );
970 
972  addToken( &attrs, _( "exclude from pos files" ) );
973 
975  addToken( &attrs, _( "exclude from BOM" ) );
976 
977  aList.emplace_back( _( "Status: " ) + status, _( "Attributes:" ) + wxS( " " ) + attrs );
978 
979  aList.emplace_back( _( "Rotation" ), wxString::Format( "%.4g", GetOrientationDegrees() ) );
980 
981  msg.Printf( _( "Footprint: %s" ), m_fpid.GetUniStringLibId() );
982  msg2.Printf( _( "3D-Shape: %s" ), m_3D_Drawings.empty() ? _( "<none>" )
983  : m_3D_Drawings.front().m_Filename );
984  aList.emplace_back( msg, msg2 );
985 
986  msg.Printf( _( "Doc: %s" ), m_doc );
987  msg2.Printf( _( "Keywords: %s" ), m_keywords );
988  aList.emplace_back( msg, msg2 );
989 }
bool IsLocked() const override
Definition: footprint.h:294
timestamp_t m_lastEditTime
Definition: footprint.h:775
FP_TEXT * m_reference
Definition: footprint.h:739
FP_TEXT * m_value
Definition: footprint.h:740
int m_fpStatus
Definition: footprint.h:743
#define _(s)
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
bool IsFlipped() const
Definition: footprint.h:278
double GetOrientationDegrees() const
Definition: footprint.h:192
wxString m_keywords
Definition: footprint.h:773
bool IsType(FRAME_T aType) const
LIB_ID m_fpid
Definition: footprint.h:741
#define PCB_EDIT_FRAME_NAME
wxString GetUniStringLibId() const
Definition: lib_id.h:134
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:289
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:416
wxString m_doc
Definition: footprint.h:772
std::list< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:781
int m_attributes
Definition: footprint.h:742

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, GetOrientationDegrees(), 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().

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

1824 {
1825  std::set<wxString> usedNumbers;
1826 
1827  // Create a set of used pad numbers
1828  for( PAD* pad : m_pads )
1829  usedNumbers.insert( pad->GetNumber() );
1830 
1831  // Pad numbers aren't technically reference designators, but the formatting is close enough
1832  // for these to give us what we need.
1833  wxString prefix = UTIL::GetRefDesPrefix( aLastPadNumber );
1834  int num = GetTrailingInt( aLastPadNumber );
1835 
1836  while( usedNumbers.count( wxString::Format( "%s%d", prefix, num ) ) )
1837  num++;
1838 
1839  return wxString::Format( "%s%d", prefix, num );
1840 }
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

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

Referenced by EDIT_TOOL::Duplicate().

◆ GetOrientation()

◆ GetOrientationDegrees()

double FOOTPRINT::GetOrientationDegrees ( ) const
inline

◆ GetOrientationRadians()

double FOOTPRINT::GetOrientationRadians ( ) const
inline

Definition at line 193 of file footprint.h.

193 { return m_orient * M_PI / 1800; }
double m_orient
Definition: footprint.h:737

References m_orient.

Referenced by KIGFX::PCB_PAINTER::draw(), ALTIUM_PCB::HelperShapeSetLocalCoord(), and ROUTER_TOOL::InlineDrag().

◆ GetPad()

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

Get a pad at aPosition on aLayerMask in the footprint.

Parameters
aPositionA wxPoint 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 1094 of file footprint.cpp.

1095 {
1096  for( PAD* pad : m_pads )
1097  {
1098  // ... and on the correct layer.
1099  if( !( pad->GetLayerSet() & aLayerMask ).any() )
1100  continue;
1101 
1102  if( pad->HitTest( aPosition ) )
1103  return pad;
1104  }
1105 
1106  return nullptr;
1107 }
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

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

1130 {
1131  if( aIncludeNPTH )
1132  return m_pads.size();
1133 
1134  unsigned cnt = 0;
1135 
1136  for( PAD* pad : m_pads )
1137  {
1138  if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
1139  continue;
1140 
1141  cnt++;
1142  }
1143 
1144  return cnt;
1145 }
like PAD_PTH, but not plated
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

References m_pads, NPTH, and pad.

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

◆ GetParent()

BOARD_ITEM_CONTAINER* BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 135 of file board_item.h.

135 { return (BOARD_ITEM_CONTAINER*) m_parent; }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
Abstract interface for BOARD_ITEMs capable of storing other items inside.

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(), EDIT_TOOL::copyToClipboard(), 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(), PCB_MARKER::GetColorLayer(), BOARD_ITEM::GetParentFootprint(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), FP_TEXT::GetSelectMenuText(), PCB_TEXT::GetShownText(), FP_TEXT::GetShownText(), getTopLevelGroup(), GENERAL_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), isInsideArea(), DRC_ENGINE::IsNetTie(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), PCB_SELECTION_TOOL::itemPassesFilter(), LEGACY_PLUGIN::loadMODULE_TEXT(), memberOf(), EDIT_TOOL::MoveExact(), ALTIUM_PCB::ParseTexts6Data(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), POSITION_RELATIVE_TOOL::PositionRelative(), BOARD_COMMIT::Push(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), CLIPBOARD_IO::SaveSelection(), PCB_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), SwapItemData(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), PCB_MARKER::ViewGetLayers(), FP_ZONE::ViewGetLOD(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetParentFootprint()

BOARD_ITEM_CONTAINER * BOARD_ITEM::GetParentFootprint ( ) const
inherited

Definition at line 179 of file board_item.cpp.

180 {
181  BOARD_ITEM_CONTAINER* ancestor = GetParent();
182 
183  while( ancestor && ancestor->Type() == PCB_GROUP_T )
184  ancestor = ancestor->GetParent();
185 
186  return ( ancestor && ancestor->Type() == PCB_FOOTPRINT_T ) ? ancestor : nullptr;
187 }
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References BOARD_ITEM::GetParent(), PCB_FOOTPRINT_T, PCB_GROUP_T, and EDA_ITEM::Type().

Referenced by CN_CONNECTIVITY_ALGO::Add(), PNS::ITEM::collideSimple(), and CONVERT_TOOL::CreatePolys().

◆ GetParentGroup()

◆ GetPath()

◆ GetPlacementCost180()

int FOOTPRINT::GetPlacementCost180 ( ) const
inline

◆ GetPlacementCost90()

int FOOTPRINT::GetPlacementCost90 ( ) const
inline

◆ GetPolyCourtyard()

const SHAPE_POLY_SET& FOOTPRINT::GetPolyCourtyard ( PCB_LAYER_ID  aLayer) const
inline

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

Returns
the courtyard polygon.

Definition at line 696 of file footprint.h.

697  {
698  if( IsBackLayer( aLayer ) )
699  return m_poly_courtyard_back;
700  else
701  return m_poly_courtyard_front;
702  }
SHAPE_POLY_SET m_poly_courtyard_back
Definition: footprint.h:787
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:896
SHAPE_POLY_SET m_poly_courtyard_front
Definition: footprint.h:786

References IsBackLayer(), m_poly_courtyard_back, and m_poly_courtyard_front.

Referenced by AR_AUTOPLACER::buildFpAreas(), calcIsInsideArea(), calcIsInsideCourtyard(), DRC_ENGINE::EvalRules(), BOARD_INSPECTION_TOOL::InspectClearance(), and DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances().

◆ GetPosition()

wxPoint FOOTPRINT::GetPosition ( ) const
inlineoverridevirtual

Reimplemented from EDA_ITEM.

Definition at line 187 of file footprint.h.

187 { return m_pos; }
wxPoint m_pos
Definition: footprint.h:738

References m_pos.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCAD2KICAD::PCB_PAD::AddToFootprint(), 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::FromBOARD(), 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::PlotFootprintGraphicItem(), BOARD_REANNOTATE_TOOL::ReannotateDuplicates(), 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_LVS::testFootprints(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), and EAGLE_PLUGIN::transferPad().

◆ GetProperties()

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

Definition at line 507 of file footprint.h.

507 { return m_properties; }
std::map< wxString, wxString > m_properties
Definition: footprint.h:782

References m_properties.

Referenced by PCB_EDIT_FRAME::ExchangeFootprint(), PCB_PLUGIN::format(), and BOARD_NETLIST_UPDATER::updateFootprintParameters().

◆ GetProperty()

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

Definition at line 509 of file footprint.h.

509 { return m_properties[ aKey ]; }
std::map< wxString, wxString > m_properties
Definition: footprint.h:782

References m_properties.

◆ GetReference()

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

Definition at line 464 of file footprint.h.

465  {
466  return m_reference->GetText();
467  }
FP_TEXT * m_reference
Definition: footprint.h:739
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154

References EDA_TEXT::GetText(), and m_reference.

Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), AR_AUTOPLACER::AutoplaceFootprints(), FOOTPRINT_EDIT_FRAME::CanCloseFPFromBoard(), FOOTPRINT_EDIT_FRAME::canCloseWindow(), CollisionMatchesExpected(), DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), PCB_BASE_FRAME::CreateNewFootprint(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), BOARD_EDITOR_CONTROL::ExportNetlist(), FOOTPRINT_DESC::FOOTPRINT_DESC(), FormatProbeItem(), DSN::SPECCTRA_DB::FromBOARD(), PLACE_FILE_EXPORTER::GenReportData(), GetLocalClearance(), FP_SHAPE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), DIALOG_BOARD_REANNOTATE::GetNewRefDes(), GetSelectMenuText(), getShapeName(), IncrementReference(), GENERAL_COLLECTOR::Inspect(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), EAGLE_PLUGIN::loadElements(), CADSTAR_PCB_ARCHIVE_LOADER::loadNets(), EDA_3D_CANVAS::OnMouseMove(), ALTIUM_PCB::ParsePads6Data(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPad(), DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), BOARD_REANNOTATE_TOOL::ReannotateDuplicates(), BOARD_NETLIST_UPDATER::replaceFootprint(), CLIPBOARD_IO::SaveSelection(), DRC_TEST_PROVIDER_LVS::testFootprints(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), BOARD_NETLIST_UPDATER::updateFootprintParameters(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetSelectMenuText()

wxString FOOTPRINT::GetSelectMenuText ( EDA_UNITS  aUnits) 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 1275 of file footprint.cpp.

1276 {
1277  wxString reference = GetReference();
1278 
1279  if( reference.IsEmpty() )
1280  reference = _( "<no reference designator>" );
1281 
1282  return wxString::Format( _( "Footprint %s" ), reference );
1283 }
const wxString & GetReference() const
Definition: footprint.h:464
#define _(s)
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 _, Format(), and GetReference().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 136 of file eda_item.h.

137  {
138  return m_status & type;
139  }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:477

References EDA_ITEM::m_status.

Referenced by BOARD_ITEM::IsLocked().

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 149 of file eda_item.h.

149 { return m_status; }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:477

References EDA_ITEM::m_status.

◆ GetThermalGap()

int FOOTPRINT::GetThermalGap ( ) const
inline

Definition at line 234 of file footprint.h.

234 { return m_thermalGap; }
int m_thermalGap
Definition: footprint.h:766

References m_thermalGap.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC(), PCB_PLUGIN::format(), and PAD::GetEffectiveThermalGap().

◆ GetThermalWidth()

int FOOTPRINT::GetThermalWidth ( ) const
inline

Definition at line 231 of file footprint.h.

231 { return m_thermalWidth; }
int m_thermalWidth
Definition: footprint.h:765

References m_thermalWidth.

Referenced by FOOTPRINT_DESC::FOOTPRINT_DESC(), PCB_PLUGIN::format(), and PAD::GetEffectiveThermalSpokeWidth().

◆ GetTopLeftPad()

PAD * FOOTPRINT::GetTopLeftPad ( )

Definition at line 1110 of file footprint.cpp.

1111 {
1112  PAD* topLeftPad = m_pads.front();
1113 
1114  for( PAD* p : m_pads )
1115  {
1116  wxPoint pnt = p->GetPosition(); // GetPosition() returns the center of the pad
1117 
1118  if( ( pnt.x < topLeftPad->GetPosition().x ) ||
1119  ( topLeftPad->GetPosition().x == pnt.x && pnt.y < topLeftPad->GetPosition().y ) )
1120  {
1121  topLeftPad = p;
1122  }
1123  }
1124 
1125  return topLeftPad;
1126 }
wxPoint GetPosition() const override
Definition: pad.h:178
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

References PAD::GetPosition(), and m_pads.

◆ GetTypeName()

wxString FOOTPRINT::GetTypeName ( ) const

Get the type of footprint.

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

Definition at line 701 of file footprint.cpp.

702 {
703  if( ( m_attributes & FP_SMD ) == FP_SMD )
704  return _( "SMD" );
705 
707  return _( "Through hole" );
708 
709  return _( "Other" );
710 }
#define _(s)
int m_attributes
Definition: footprint.h:742

References _, FP_SMD, FP_THROUGH_HOLE, and m_attributes.

Referenced by 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 1148 of file footprint.cpp.

1149 {
1150  std::set<wxString> usedNumbers;
1151 
1152  // Create a set of used pad numbers
1153  for( PAD* pad : m_pads )
1154  {
1155  // Skip pads not on copper layers (used to build complex
1156  // solder paste shapes for instance)
1157  if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none() )
1158  continue;
1159 
1160  // Skip pads with no name, because they are usually "mechanical"
1161  // pads, not "electrical" pads
1162  if( pad->GetNumber().IsEmpty() )
1163  continue;
1164 
1165  if( !aIncludeNPTH )
1166  {
1167  // skip NPTH
1168  if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
1169  continue;
1170  }
1171 
1172  usedNumbers.insert( pad->GetNumber() );
1173  }
1174 
1175  return usedNumbers.size();
1176 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
like PAD_PTH, but not plated
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

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

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

◆ GetValue()

◆ GetX()

int BOARD_ITEM::GetX ( ) const
inlineinherited

◆ GetY()

int BOARD_ITEM::GetY ( ) const
inlineinherited

◆ GetZoneConnection()

ZONE_CONNECTION FOOTPRINT::GetZoneConnection ( ) const
inline

◆ GetZoneSettings()

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

Fetch the zone settings for this container.

Reimplemented in BOARD.

Definition at line 83 of file board_item_container.h.

84  {
85  return m_zoneSettings;
86  }

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

173 { return m_drawings; }
DRAWINGS m_drawings
Definition: footprint.h:732

References m_drawings.

◆ Groups() [1/2]

FP_GROUPS& FOOTPRINT::Groups ( )
inline

◆ Groups() [2/2]

const FP_GROUPS& FOOTPRINT::Groups ( ) const
inline

Definition at line 179 of file footprint.h.

179 { return m_fp_groups; }
FP_GROUPS m_fp_groups
Definition: footprint.h:735

References m_fp_groups.

◆ HasFlag()

◆ HasProperty()

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

Definition at line 510 of file footprint.h.

511  {
512  return m_properties.find( aKey ) != m_properties.end();
513  }
std::map< wxString, wxString > m_properties
Definition: footprint.h:782

References m_properties.

◆ HasThroughHolePads()

bool FOOTPRINT::HasThroughHolePads ( ) const

Definition at line 2159 of file footprint.cpp.

2160 {
2161  for( PAD* pad : Pads() )
2162  {
2163  if( pad->GetAttribute() != PAD_ATTRIB::SMD )
2164  return true;
2165  }
2166 
2167  return false;
2168 }
Smd pad, appears on the solder paste layer (default)
PADS & Pads()
Definition: footprint.h:169
Definition: pad.h:57

References pad, Pads(), and SMD.

◆ HitTest() [1/2]

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

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

Parameters
aPositionA reference to a wxPoint 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 1015 of file footprint.cpp.

1016 {
1017  EDA_RECT rect = GetBoundingBox( false, false );
1018  return rect.Inflate( aAccuracy ).Contains( aPosition );
1019 }
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:736
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBoundingBox(), and EDA_RECT::Inflate().

Referenced by GENERAL_COLLECTOR::Inspect().

◆ HitTest() [2/2]

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

Test if aRect intersects this item.

Parameters
aRectA reference to a EDA_RECT 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 1028 of file footprint.cpp.

1029 {
1030  EDA_RECT arect = aRect;
1031  arect.Inflate( aAccuracy );
1032 
1033  if( aContained )
1034  {
1035  return arect.Contains( GetBoundingBox( false, false ) );
1036  }
1037  else
1038  {
1039  // If the rect does not intersect the bounding box, skip any tests
1040  if( !aRect.Intersects( GetBoundingBox( false, false ) ) )
1041  return false;
1042 
1043  // The empty footprint dummy rectangle intersects the selection area.
1044  if( m_pads.empty() && m_fp_zones.empty() && m_drawings.empty() )
1045  return GetBoundingBox( true, false ).Intersects( arect );
1046 
1047  // Determine if any elements in the FOOTPRINT intersect the rect
1048  for( PAD* pad : m_pads )
1049  {
1050  if( pad->HitTest( arect, false, 0 ) )
1051  return true;
1052  }
1053 
1054  for( FP_ZONE* zone : m_fp_zones )
1055  {
1056  if( zone->HitTest( arect, false, 0 ) )
1057  return true;
1058  }
1059 
1060  for( BOARD_ITEM* item : m_drawings )
1061  {
1062  if( item->Type() != PCB_FP_TEXT_T && item->HitTest( arect, false, 0 ) )
1063  return true;
1064  }
1065 
1066  // Groups are not hit-tested; only their members
1067 
1068  // No items were hit
1069  return false;
1070  }
1071 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
FP_ZONES m_fp_zones
Definition: footprint.h:734
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:736
Handle the component boundary box.
Definition: eda_rect.h:42
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
DRAWINGS m_drawings
Definition: footprint.h:732
Definition: pad.h:57
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBoundingBox(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), m_drawings, m_fp_zones, m_pads, pad, and PCB_FP_TEXT_T.

◆ HitTestAccurate()

bool FOOTPRINT::HitTestAccurate ( const wxPoint &  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 1022 of file footprint.cpp.

1023 {
1024  return GetBoundingHull().Collide( aPosition, aAccuracy );
1025 }
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:847
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 240 of file footprint.h.

240 { m_arflag += 1; }
int m_arflag
Definition: footprint.h:776

References m_arflag.

◆ IncrementReference()

void FOOTPRINT::IncrementReference ( int  aDelta)

Bump the current reference by aDelta.

Definition at line 1843 of file footprint.cpp.

1844 {
1845  const wxString& refdes = GetReference();
1846 
1847  SetReference( wxString::Format( wxT( "%s%i" ),
1848  UTIL::GetRefDesPrefix( refdes ),
1849  GetTrailingInt( refdes ) + aDelta ) );
1850 }
void SetReference(const wxString &aReference)
Definition: footprint.h:473
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.
const wxString & GetReference() const
Definition: footprint.h:464
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.

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

◆ IsBrightened()

◆ IsConnected()

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 120 of file eda_item.h.

120 { return m_flags & IS_DRAGGING; }
#define IS_DRAGGING
Item being dragged.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

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

123 { return m_flags & ENTERED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define ENTERED
indicates a group has been entered

References ENTERED, and EDA_ITEM::m_flags.

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

◆ IsFlipped()

bool FOOTPRINT::IsFlipped ( ) const
inline
Returns
true if the footprint is flipped, i.e. on the back side of the board

Definition at line 278 of file footprint.h.

278 { return GetLayer() == B_Cu; }
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142

References B_Cu, and BOARD_ITEM::GetLayer().

Referenced by PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), GetMsgPanelInfo(), DIALOG_PAD_PROPERTIES::initValues(), ALTIUM_PCB::ParseComponentsBodies6Data(), BOARD_EDITOR_CONTROL::PlaceFootprint(), RENDER_3D_OPENGL::renderFootprint(), and DIALOG_TEXT_PROPERTIES::TransferDataToWindow().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 205 of file eda_item.h.

205 { return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:479

References EDA_ITEM::m_forceVisible.

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

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

1433 {
1434  const wxChar * invalids = StringLibNameInvalidChars( false );
1435 
1436  if( aName.find_first_of( invalids ) != std::string::npos )
1437  return false;
1438 
1439  return true;
1440 }
static const wxChar * StringLibNameInvalidChars(bool aUserReadable)
Test for validity of the name in a library of the footprint ( no spaces, dir separators ....
Definition: footprint.cpp:1443

References StringLibNameInvalidChars().

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::checkFootprintName().

◆ IsLocked()

bool FOOTPRINT::IsLocked ( ) const
inlineoverridevirtual
Returns
true if the object is locked, else false.

Reimplemented from BOARD_ITEM.

Definition at line 294 of file footprint.h.

295  {
296  return ( m_fpStatus & FP_is_LOCKED ) != 0;
297  }
int m_fpStatus
Definition: footprint.h:743
#define FP_is_LOCKED
footprint LOCKED: no autoplace allowed
Definition: footprint.h:288

References FP_is_LOCKED, and m_fpStatus.

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

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 117 of file eda_item.h.

117 { return m_flags & IS_CHANGED; }
#define IS_CHANGED
Item was edited, and modified.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNetTie()

bool FOOTPRINT::IsNetTie ( ) const
inline

Definition at line 244 of file footprint.h.

245  {
246  return GetKeywords().StartsWith( wxT( "net tie" ) );
247  }
const wxString & GetKeywords() const
Definition: footprint.h:201

References GetKeywords().

Referenced by DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem().

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

112  {
113  return IsCopperLayer( GetLayer() );
114  }
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:797
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142

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

Referenced by CN_CONNECTIVITY_ALGO::Add(), DRC_ENGINE::EvalRules(), and BOARD_CONNECTED_ITEM::SetNetCode().

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

993 {
994  // If we have any pads, fall back on normal checking
995  if( !m_pads.empty() )
996  return m_layer == aLayer;
997 
998  // No pads? Check if this entire footprint exists on the given layer
999  for( FP_ZONE* zone : m_fp_zones )
1000  {
1001  if( !zone->IsOnLayer( aLayer ) )
1002  return false;
1003  }
1004 
1005  for( BOARD_ITEM* item : m_drawings )
1006  {
1007  if( !item->IsOnLayer( aLayer ) )
1008  return false;
1009  }
1010 
1011  return true;
1012 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
FP_ZONES m_fp_zones
Definition: footprint.h:734
PCB_LAYER_ID m_layer
Definition: board_item.h:318
DRAWINGS m_drawings
Definition: footprint.h:732
A specialization of ZONE for use in footprints.
Definition: zone.h:945
PADS m_pads
Definition: footprint.h:733

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

◆ IsPlaced()

bool FOOTPRINT::IsPlaced ( ) const
inline

Definition at line 312 of file footprint.h.

312 { return m_fpStatus & FP_is_PLACED; }
int m_fpStatus
Definition: footprint.h:743
#define FP_is_PLACED
In autoplace: footprint automatically placed.
Definition: footprint.h:289

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 SCH_SYMBOL, SCH_SHEET, SCH_LABEL, SCH_TEXT, SCH_FIELD, and SCH_SHEET_PIN.

Definition at line 402 of file eda_item.h.

402 { return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 124 of file eda_item.h.

124 { return m_flags & IS_RESIZING; }
#define IS_RESIZING
Item being resized.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 122 of file eda_item.h.

122 { return m_flags & SELECTED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define 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_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::DS_RENDER_SETTINGS::GetColor(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), KIGFX::SCH_PAINTER::getRenderColor(), KIGFX::SCH_PAINTER::getTextThickness(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), EE_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_EDIT_FRAME::SchematicCleanUp(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsTrack()

bool BOARD_ITEM::IsTrack ( ) const
inlineinherited

Test to see if this object is a track or via (or microvia).

Returns
true if a track or via, else false.

Definition at line 210 of file board_item.h.

211  {
212  return ( Type() == PCB_TRACE_T ) || ( Type() == PCB_VIA_T );
213  }
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References PCB_TRACE_T, PCB_VIA_T, and EDA_ITEM::Type().

◆ IsType()

virtual bool EDA_ITEM::IsType ( const 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 PCB_VIA, SCH_LABEL, PCB_DIMENSION_BASE, PAD, SCH_FIELD, FP_TEXT, SCH_LINE, PCB_SHAPE, FP_SHAPE, and PCB_TEXT.

Definition at line 182 of file eda_item.h.

183  {
184  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
185  return true;
186 
187  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
188  {
189  if( m_structType == *p )
190  return true;
191  }
192 
193  return false;
194  }
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:487

References EOT, EDA_ITEM::m_structType, and SCH_LOCATE_ANY_T.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), PCB_TEXT::IsType(), FP_SHAPE::IsType(), PCB_SHAPE::IsType(), SCH_LINE::IsType(), FP_TEXT::IsType(), SCH_FIELD::IsType(), PAD::IsType(), PCB_DIMENSION_BASE::IsType(), SCH_LABEL::IsType(), PCB_VIA::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), EE_SELECTION_TOOL::RequestSelection(), SCH_BASE_FRAME::UpdateItem(), EDA_ITEM::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 121 of file eda_item.h.

121 { return m_flags & IS_WIRE_IMAGE; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_WIRE_IMAGE, and EDA_ITEM::m_flags.

◆ IterateForward() [1/2]

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

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

Definition at line 294 of file eda_item.h.

298  {
299  for( auto it : aList )
300  {
301  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
303  return SEARCH_RESULT::QUIT;
304  }
305 
307  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93

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

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

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

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

Definition at line 313 of file eda_item.h.

315  {
316  for( auto it : aList )
317  {
318  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
320  return SEARCH_RESULT::QUIT;
321  }
322 
324  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93

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.

The BOARD is needed because layer names are customizable.

Reimplemented in PCB_VIA.

Definition at line 87 of file board_item.cpp.

88 {
89  const BOARD* board = GetBoard();
90  LSET layers = GetLayerSet();
91 
92  // Try to be smart and useful. Check all copper first.
93  if( layers[F_Cu] && layers[B_Cu] )
94  return _( "all copper layers" );
95 
96  LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
97  LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
98 
99  for( LSET testLayers : { copperLayers, techLayers, layers } )
100  {
101  for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
102  {
103  if( testLayers[ bit ] )
104  {
105  wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
106 
107  if( testLayers.count() > 1 )
108  layerInfo << wxS( " " ) + _( "and others" );
109 
110  return layerInfo;
111  }
112  }
113  }
114 
115  // No copper, no technicals: no layer
116  return _( "no layers" );
117 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:467
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:829
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
#define _(s)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Definition: layer_ids.h:71
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:147

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 PCB_TRACK::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), and PAD::GetSelectMenuText().

◆ LegacyPadsLocked()

bool FOOTPRINT::LegacyPadsLocked ( ) const
inline

Definition at line 330 of file footprint.h.

330 { return m_fpStatus & FP_PADS_are_LOCKED; }
#define FP_PADS_are_LOCKED
Definition: footprint.h:291
int m_fpStatus
Definition: footprint.h:743

References FP_PADS_are_LOCKED, and m_fpStatus.

◆ Matches() [1/2]

virtual bool EDA_ITEM::Matches ( const wxFindReplaceData &  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_SYMBOL, SCH_SHEET, SCH_TEXT, SCH_FIELD, SCH_SHEET_PIN, ZONE, SCH_PIN, PCB_MARKER, SCH_MARKER, FP_TEXT, and PCB_TEXT.

Definition at line 364 of file eda_item.h.

365  {
366  return false;
367  }

Referenced by SCH_EDITOR_CONTROL::HasMatch(), inDiffPair(), PCB_TEXT::Matches(), FP_TEXT::Matches(), SCH_MARKER::Matches(), PCB_MARKER::Matches(), SCH_PIN::Matches(), ZONE::Matches(), SCH_SHEET_PIN::Matches(), SCH_FIELD::Matches(), SCH_TEXT::Matches(), SCH_EDITOR_CONTROL::ReplaceAndFindNext(), and SCH_EDITOR_CONTROL::UpdateFind().

◆ Matches() [2/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
const wxFindReplaceData &  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 118 of file eda_item.cpp.

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

References FR_MATCH_WILDCARD, FR_SEARCH_REPLACE, EDA_ITEM::IsReplaceable(), next(), and text.

◆ Models() [1/2]

◆ Models() [2/2]

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

Definition at line 184 of file footprint.h.

184 { return m_3D_Drawings; }
std::list< FP_3DMODEL > m_3D_Drawings
Definition: footprint.h:781

References m_3D_Drawings.

◆ Move() [1/2]

void BOARD_ITEM::Move ( const VECTOR2I aMoveVector)
inlineinherited

Definition at line 243 of file board_item.h.

244  {
245  Move( wxPoint( aMoveVector.x, aMoveVector.y ) );
246  }
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238

References BOARD_ITEM::Move(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Move() [2/2]

void FOOTPRINT::Move ( const wxPoint &  aMoveVector)
overridevirtual

Move this object.

Parameters
aMoveVectorthe move vector for this object.

Reimplemented from BOARD_ITEM.

Definition at line 1458 of file footprint.cpp.

1459 {
1460  wxPoint newpos = m_pos + aMoveVector;
1461  SetPosition( newpos );
1462 }
wxPoint m_pos
Definition: footprint.h:738
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1561

References m_pos, and SetPosition().

Referenced by moveFootprintsInArea().

◆ MoveAnchorPosition()

void FOOTPRINT::MoveAnchorPosition ( const wxPoint &  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 1607 of file footprint.cpp.

1608 {
1609  /* Move the reference point of the footprint
1610  * the footprints elements (pads, outlines, edges .. ) are moved
1611  * but:
1612  * - the footprint position is not modified.
1613  * - the relative (local) coordinates of these items are modified
1614  * - Draw coordinates are updated
1615  */
1616 
1617 
1618  // Update (move) the relative coordinates relative to the new anchor point.
1619  wxPoint moveVector = aMoveVector;
1620  RotatePoint( &moveVector, -GetOrientation() );
1621 
1622  // Update of the reference and value.
1623  m_reference->SetPos0( m_reference->GetPos0() + moveVector );
1625  m_value->SetPos0( m_value->GetPos0() + moveVector );
1626  m_value->SetDrawCoord();
1627 
1628  // Update the pad local coordinates.
1629  for( PAD* pad : m_pads )
1630  {
1631  pad->SetPos0( pad->GetPos0() + moveVector );
1632  pad->SetDrawCoord();
1633  }
1634 
1635  // Update the draw element coordinates.
1636  for( BOARD_ITEM* item : GraphicalItems() )
1637  {
1638  switch( item->Type() )
1639  {
1640  case PCB_FP_SHAPE_T:
1641  {
1642  FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
1643  shape->Move( moveVector );
1644  }
1645  break;
1646 
1647  case PCB_FP_TEXT_T:
1648  {
1649  FP_TEXT* text = static_cast<FP_TEXT*>( item );
1650  text->SetPos0( text->GetPos0() + moveVector );
1651  text->SetDrawCoord();
1652  }
1653  break;
1654 
1655  default:
1656  break;
1657  }
1658  }
1659 
1660  // Update the keepout zones
1661  for( ZONE* zone : Zones() )
1662  {
1663  zone->Move( moveVector );
1664  }
1665 
1666  // Update the 3D models
1667  for( FP_3DMODEL& model : Models() )
1668  {
1669  model.m_Offset.x += Iu2Millimeter( moveVector.x );
1670  model.m_Offset.y -= Iu2Millimeter( moveVector.y );
1671  }
1672 
1673  m_cachedBoundingBox.Move( moveVector );
1674  m_cachedVisibleBBox.Move( moveVector );
1675  m_cachedTextExcludedBBox.Move( moveVector );
1676  m_cachedHull.Move( moveVector );
1677 }
EDA_RECT m_cachedVisibleBBox
Definition: footprint.h:757
void Move(const wxPoint &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: eda_rect.cpp:51
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:183
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
double GetOrientation() const
Definition: footprint.h:191
void SetDrawCoord()
Set relative coordinates.
Definition: fp_text.cpp:190
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
FP_TEXT * m_reference
Definition: footprint.h:739
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
FP_TEXT * m_value
Definition: footprint.h:740
EDA_RECT m_cachedBoundingBox
Definition: footprint.h:755
FP_ZONES & Zones()
Definition: footprint.h:175
void Move(const VECTOR2I &aVector) override
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:761
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
void SetPos0(const wxPoint &aPos)
Definition: fp_text.h:165
const wxPoint & GetPos0() const
Definition: fp_text.h:166
EDA_RECT m_cachedTextExcludedBBox
Definition: footprint.h:759
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Definition: fp_shape.cpp:344
Definition: pad.h:57
PADS m_pads
Definition: footprint.h:733

References GetOrientation(), FP_TEXT::GetPos0(), GraphicalItems(), m_cachedBoundingBox, m_cachedHull, m_cachedTextExcludedBBox, m_cachedVisibleBBox, m_pads, m_reference, m_value, Models(), EDA_RECT::Move(), FP_SHAPE::Move(), SHAPE_POLY_SET::Move(), pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, RotatePoint(), FP_TEXT::SetDrawCoord(), FP_TEXT::SetPos0(), text, and Zones().

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

◆ NeedsPlaced()

bool FOOTPRINT::NeedsPlaced ( ) const
inline

Definition at line 321 of file footprint.h.

321 { return m_fpStatus & FP_to_PLACE; }
int m_fpStatus
Definition: footprint.h:743
#define FP_to_PLACE
In autoplace: footprint waiting for autoplace.
Definition: footprint.h:290

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 234 of file eda_item.cpp.

235 {
236  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
237  GetClass() ) );
238 
239  return false;
240 }
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
virtual wxString GetClass() const =0
Return the class name.

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

◆ operator=() [1/2]

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

Definition at line 365 of file footprint.cpp.

366 {
367  BOARD_ITEM::operator=( aOther );
368 
369  m_pos = aOther.m_pos;
370  m_fpid = aOther.m_fpid;
371  m_attributes = aOther.m_attributes;
372  m_fpStatus = aOther.m_fpStatus;
373  m_orient = aOther.m_orient;
374  m_rot90Cost = aOther.m_rot90Cost;
375  m_rot180Cost = aOther.m_rot180Cost;
377  m_link = aOther.m_link;
378  m_path = aOther.m_path;
379 
386  m_cachedHull = aOther.m_cachedHull;
388 
395  m_thermalGap = aOther.m_thermalGap;
396 
397  // Copy reference and value
398  *m_reference = *aOther.m_reference;
399  m_reference->SetParent( this );
400  *m_value = *aOther.m_value;
401  m_value->SetParent( this );
402 
403  std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
404 
405  // Copy pads
406  m_pads.clear();
407 
408  for( PAD* pad : aOther.Pads() )
409  {
410  PAD* newPad = new PAD( *pad );
411  ptrMap[ pad ] = newPad;
412  Add( newPad );
413  }
414 
415  // Copy zones
416  m_fp_zones.clear();
417 
418  for( FP_ZONE* zone : aOther.Zones() )
419  {
420  FP_ZONE* newZone = static_cast<FP_ZONE*>( zone->Clone() );
421  ptrMap[ zone ] = newZone;
422  Add( newZone );
423 
424  // Ensure the net info is OK and especially uses the net info list
425  // living in the current board
426  // Needed when copying a fp from fp editor that has its own board
427  // Must be NETINFO_LIST::ORPHANED_ITEM for a keepout that has no net.
428  newZone->SetNetCode( -1 );
429  }
430 
431  // Copy drawings
432  m_drawings.clear();
433 
434  for( BOARD_ITEM* item : aOther.GraphicalItems() )
435  {
436  BOARD_ITEM* newItem = static_cast<BOARD_ITEM*>( item->Clone() );
437  ptrMap[ item ] = newItem;
438  Add( newItem );
439  }
440 
441  // Copy groups
442  m_fp_groups.clear();
443 
444  for( PCB_GROUP* group : aOther.Groups() )
445  {
446  PCB_GROUP* newGroup = static_cast<PCB_GROUP*>( group->Clone() );
447  newGroup->GetItems().clear();
448 
449  for( BOARD_ITEM* member : group->GetItems() )
450  newGroup->AddItem( ptrMap[ member ] );
451 
452  Add( newGroup );
453  }
454 
455  // Copy auxiliary data: 3D_Drawings info
456  m_3D_Drawings.clear();
457  m_3D_Drawings = aOther.m_3D_Drawings;
458  m_doc = aOther.m_doc;
459  m_keywords = aOther.m_keywords;
460  m_properties = aOther.m_properties;
461 
463  new wxArrayString( *aOther.m_initial_comments ) : nullptr;
464 
465  return *this;
466 }
int m_localSolderPasteMargin
Definition: footprint.h:769
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:39
EDA_RECT m_cachedVisibleBBox
Definition: footprint.h:757
ZONE_CONNECTION m_zoneConnection
Definition: footprint.h:764
double m_localSolderPasteMarginRatio
Definition: footprint.h:770
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
double m_orient
Definition: footprint.h:737
timestamp_t m_lastEditTime
Definition: footprint.h:775
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
FP_TEXT * m_reference
Definition: footprint.h:739
int m_visibleBBoxCacheTimeStamp
Definition: footprint.h:758
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
int m_rot90Cost
Definition: footprint.h:778
PADS & Pads()
Definition: footprint.h:169
FP_TEXT * m_value
Definition: footprint.h:740
KIID m_link
Definition: footprint.h:777
int m_localSolderMaskMargin
Definition: footprint.h:768
EDA_RECT m_cachedBoundingBox
Definition: footprint.h:755
FP_ZONES & Zones()
Definition: footprint.h:175
int m_fpStatus
Definition: footprint.h:743
FP_ZONES m_fp_zones
Definition: footprint.h:734
SHAPE_POLY_SET m_cachedHull
Definition: footprint.h:761
int m_thermalGap
Definition: footprint.h:766
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
wxPoint m_pos
Definition: footprint.h:738
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
Definition: eda_item.cpp:243
int m_boundingBoxCacheTimeStamp
Definition: footprint.h:756
KIID_PATH m_path
Definition: footprint.h:774
FP_GROUPS & Groups()
Definition: footprint.h:178
int m_thermalWidth
Definition: footprint.h:765
wxString m_keywords
Definition: footprint.h:773
int m_localClearance
Definition: footprint.h:767
int m_rot180Cost
Definition: footprint.h:779
int m_textExcludedBBoxCacheTimeStamp
Definition: footprint.h:760
LIB_ID m_fpid
Definition: footprint.h:741
EDA_RECT m_cachedTextExcludedBBox
Definition: footprint.h:759<