KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PAD_MASTER_PROVIDER Class Reference

Public Types

enum class  TYPE {
  AUTO , THT , SMD , NPTH ,
  CONNECTOR , PASTE , MASK
}
 

Public Member Functions

 PAD_MASTER_PROVIDER ()=default
 
PAD GetMasterPad (TYPE aType, const FOOTPRINT *aFootprint, const PAD *aSelectedPad) const
 Get the master pad for the given type, footprint, and selected pad.
 
std::unique_ptr< PAD > MakeDefaultPad (PAD_MASTER_PROVIDER::TYPE aMasterType) const
 Create a default pad for the given master pad type when there is no more obvious source.
 
void RecordNewMasterPad (const PAD &aPlacedPad)
 Record the given pad as the most recently placed pad of its type.
 

Static Public Member Functions

static TYPE TypeFromAction (const TOOL_EVENT &aEvent)
 
static std::optional< TYPE > TypeFromPad (const PAD &aPad)
 Determine the master pad type from the given pad.
 

Private Member Functions

TYPE resolveAutoType (const std::vector< const PAD * > &aFpPads, const PAD *aSelectedPad) const
 Resolve the type a TYPE::AUTO request actually wants.
 

Private Attributes

std::unordered_map< TYPE, KIID > m_lastRealPadsForType
 
TYPE m_lastType = PAD_MASTER_PROVIDER::TYPE::AUTO
 Persistent store of the last pad type.
 

Detailed Description

Definition at line 60 of file pad_tool.cpp.

Member Enumeration Documentation

◆ TYPE

enum class PAD_MASTER_PROVIDER::TYPE
strong
Enumerator
AUTO 
THT 
SMD 
NPTH 
CONNECTOR 
PASTE 
MASK 

Definition at line 63 of file pad_tool.cpp.

Constructor & Destructor Documentation

◆ PAD_MASTER_PROVIDER()

PAD_MASTER_PROVIDER::PAD_MASTER_PROVIDER ( )
default

Member Function Documentation

◆ GetMasterPad()

PAD PAD_MASTER_PROVIDER::GetMasterPad ( TYPE aType,
const FOOTPRINT * aFootprint,
const PAD * aSelectedPad ) const
inline

Get the master pad for the given type, footprint, and selected pad.

If 'auto' is specified for the type, see resolveAutoType for the type resolution logic.

For a given resolved type, the master pad is found by, in order:

  • The selected pad, if the mode is 'auto'
  • The most recently created pad of the requested type in the current footprint (including edits in the meantime)
  • The highest numbered pad of the requested type in the current footprint.
  • A constructed default pad for the requested type if none of the above are found.

Definition at line 90 of file pad_tool.cpp.

References PAD::GetNumber(), m_lastRealPadsForType, MakeDefaultPad(), pad, FOOTPRINT::Pads(), resolveAutoType(), StrNumCmp(), and TypeFromPad().

◆ MakeDefaultPad()

◆ RecordNewMasterPad()

void PAD_MASTER_PROVIDER::RecordNewMasterPad ( const PAD & aPlacedPad)
inline

Record the given pad as the most recently placed pad of its type.

This can then be used when auto-detecting the pad type for new pads.

Definition at line 268 of file pad_tool.cpp.

References m_lastRealPadsForType, m_lastType, EDA_ITEM::m_Uuid, and TypeFromPad().

◆ resolveAutoType()

TYPE PAD_MASTER_PROVIDER::resolveAutoType ( const std::vector< const PAD * > & aFpPads,
const PAD * aSelectedPad ) const
inlineprivate

Resolve the type a TYPE::AUTO request actually wants.

The order is:

  • the selected pad, if any
  • the last pad type placed
  • the first classified pad in the footprint pad list aFpPads
  • a THT default

Definition at line 338 of file pad_tool.cpp.

References m_lastType, pad, and TypeFromPad().

Referenced by GetMasterPad().

◆ TypeFromAction()

static TYPE PAD_MASTER_PROVIDER::TypeFromAction ( const TOOL_EVENT & aEvent)
inlinestatic

◆ TypeFromPad()

static std::optional< TYPE > PAD_MASTER_PROVIDER::TypeFromPad ( const PAD & aPad)
inlinestatic

Determine the master pad type from the given pad.

Returns std::nullopt if the pad does not obviously match any master pad type.

Definition at line 299 of file pad_tool.cpp.

References CONN, PAD::GetAttribute(), PAD::GetLayerSet(), PAD::IsAperturePad(), NPTH, PTH, and SMD.

Referenced by GetMasterPad(), RecordNewMasterPad(), and resolveAutoType().

Member Data Documentation

◆ m_lastRealPadsForType

std::unordered_map<TYPE, KIID> PAD_MASTER_PROVIDER::m_lastRealPadsForType
private

Definition at line 362 of file pad_tool.cpp.

Referenced by GetMasterPad(), and RecordNewMasterPad().

◆ m_lastType

TYPE PAD_MASTER_PROVIDER::m_lastType = PAD_MASTER_PROVIDER::TYPE::AUTO
private

Persistent store of the last pad type.

Definition at line 365 of file pad_tool.cpp.

Referenced by RecordNewMasterPad(), and resolveAutoType().


The documentation for this class was generated from the following file: