Name pins after numbers in IPC2581
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16211
This commit is contained in:
parent
343828c552
commit
12d787ecc0
|
@ -152,7 +152,7 @@ wxXmlNode* IPC2581_PLUGIN::appendNode( wxXmlNode* aParent, const wxString& aName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString IPC2581_PLUGIN::genString( const wxString& aStr, const char* aPrefix )
|
wxString IPC2581_PLUGIN::genString( const wxString& aStr, const char* aPrefix ) const
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
|
|
||||||
|
@ -184,6 +184,33 @@ wxString IPC2581_PLUGIN::genString( const wxString& aStr, const char* aPrefix )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString IPC2581_PLUGIN::pinName( const PAD* aPad ) const
|
||||||
|
{
|
||||||
|
wxString name = aPad->GetNumber();
|
||||||
|
|
||||||
|
FOOTPRINT* fp = aPad->GetParentFootprint();
|
||||||
|
size_t ii = 0;
|
||||||
|
|
||||||
|
if( name.empty() && fp )
|
||||||
|
{
|
||||||
|
for( ii = 0; ii < fp->GetPadCount(); ++ii )
|
||||||
|
{
|
||||||
|
if( fp->Pads()[ii] == aPad )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pins are required to have names, so if our pad doesn't have a name, we need to
|
||||||
|
// generate one that is unique
|
||||||
|
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
||||||
|
name = wxString::Format( "NPTH%zu", ii );
|
||||||
|
else if( name.empty() )
|
||||||
|
name = wxString::Format( "PAD%zu", ii );
|
||||||
|
|
||||||
|
return genString( name, "PIN" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString IPC2581_PLUGIN::floatVal( double aVal )
|
wxString IPC2581_PLUGIN::floatVal( double aVal )
|
||||||
{
|
{
|
||||||
wxString str = wxString::FromCDouble( aVal, m_sigfig );
|
wxString str = wxString::FromCDouble( aVal, m_sigfig );
|
||||||
|
@ -1514,13 +1541,9 @@ void IPC2581_PLUGIN::addPad( wxXmlNode* aContentNode, const PAD* aPad, PCB_LAYER
|
||||||
if( fp )
|
if( fp )
|
||||||
{
|
{
|
||||||
wxXmlNode* pinRefNode = appendNode( padNode, "PinRef" );
|
wxXmlNode* pinRefNode = appendNode( padNode, "PinRef" );
|
||||||
wxString name = aPad->GetNumber();
|
|
||||||
|
|
||||||
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
addAttribute( pinRefNode, "pin", pinName( aPad ) );
|
||||||
name = wxString::Format( "NPTH_%d_%d", aPad->GetX(), aPad->GetY() );
|
addAttribute( pinRefNode, "componentRef", genString( fp->GetReference(), "CMP" ) );
|
||||||
|
|
||||||
addAttribute( pinRefNode, "pin", genString( name, "PIN" ) );
|
|
||||||
addAttribute( pinRefNode, "componentRef", genString( fp->GetReferenceAsString(), "CMP" ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2052,19 +2075,12 @@ wxXmlNode* IPC2581_PLUGIN::addPackage( wxXmlNode* aContentNode, FOOTPRINT* aFp )
|
||||||
{
|
{
|
||||||
PAD* pad = fp->Pads()[ii];
|
PAD* pad = fp->Pads()[ii];
|
||||||
wxXmlNode* pinNode = appendNode( packageNode, "Pin" );
|
wxXmlNode* pinNode = appendNode( packageNode, "Pin" );
|
||||||
wxString name = pad->GetNumber();
|
wxString name = pinName( pad );
|
||||||
|
|
||||||
// Pins are required to have names, so if our pad doesn't have a name, we need to
|
|
||||||
// generate one that is unique
|
|
||||||
if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
|
|
||||||
name = wxString::Format( "NPTH%zu", ii );
|
|
||||||
else if( name.empty() )
|
|
||||||
name = wxString::Format( "PAD%zu", ii );
|
|
||||||
|
|
||||||
addAttribute( pinNode, "number", name );
|
addAttribute( pinNode, "number", name );
|
||||||
|
|
||||||
m_net_pin_dict[pad->GetNetCode()].emplace_back(
|
m_net_pin_dict[pad->GetNetCode()].emplace_back(
|
||||||
genString( fp->GetReference(), "CMP" ), genString( name, "PIN" ) );
|
genString( fp->GetReference(), "CMP" ), name );
|
||||||
|
|
||||||
if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
|
if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
|
||||||
addAttribute( pinNode, "electricalType", "MECHANICAL" );
|
addAttribute( pinNode, "electricalType", "MECHANICAL" );
|
||||||
|
|
|
@ -256,10 +256,12 @@ private:
|
||||||
|
|
||||||
size_t shapeHash( const PCB_SHAPE& aShape );
|
size_t shapeHash( const PCB_SHAPE& aShape );
|
||||||
|
|
||||||
wxString genString( const wxString& aStr, const char* aPrefix = nullptr );
|
wxString genString( const wxString& aStr, const char* aPrefix = nullptr ) const;
|
||||||
|
|
||||||
wxString floatVal( double aVal );
|
wxString floatVal( double aVal );
|
||||||
|
|
||||||
|
wxString pinName( const PAD* aPad ) const;
|
||||||
|
|
||||||
void addXY( wxXmlNode* aNode, const VECTOR2I& aVec, const char* aXName = nullptr,
|
void addXY( wxXmlNode* aNode, const VECTOR2I& aVec, const char* aXName = nullptr,
|
||||||
const char* aYName = nullptr );
|
const char* aYName = nullptr );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue