Separate LIB_PIN and SCH_PIN GetShownName/Number processing.
SCH_PIN wasn't handling the legacy empty string token (~), but more importantly this will allow text variable resolution specific to the schematic. Fixes https://gitlab.com/kicad/code/kicad/issues/8625
This commit is contained in:
parent
b10f156dd0
commit
0484ca5564
|
@ -431,10 +431,10 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_SYMBOL* aSymbol )
|
|||
SCH_PIN* pin = (SCH_PIN*) aItem;
|
||||
aSymbol = pin->GetParentSymbol();
|
||||
|
||||
if( !pin->GetNumber().IsEmpty() )
|
||||
if( !pin->GetShownNumber().IsEmpty() )
|
||||
{
|
||||
return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
|
||||
TO_UTF8( pin->GetNumber() ),
|
||||
TO_UTF8( pin->GetShownNumber() ),
|
||||
TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -584,7 +584,7 @@ int ERC_TESTER::TestMultUnitPinConflicts()
|
|||
continue;
|
||||
|
||||
wxString name = pin->GetParentSymbol()->GetRef( &subgraph->m_sheet ) +
|
||||
+ ":" + pin->GetNumber();
|
||||
+ ":" + pin->GetShownNumber();
|
||||
|
||||
if( !pinToNetMap.count( name ) )
|
||||
{
|
||||
|
@ -597,7 +597,9 @@ int ERC_TESTER::TestMultUnitPinConflicts()
|
|||
|
||||
ercItem->SetErrorMessage( wxString::Format(
|
||||
_( "Pin %s is connected to both %s and %s" ),
|
||||
pin->GetNumber(), netName, pinToNetMap[name].first ) );
|
||||
pin->GetShownNumber(),
|
||||
netName,
|
||||
pinToNetMap[name].first ) );
|
||||
|
||||
ercItem->SetItems( pin, pinToNetMap[name].second );
|
||||
ercItem->SetIsSheetSpecific();
|
||||
|
|
|
@ -168,7 +168,7 @@ void NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol,
|
|||
continue;
|
||||
}
|
||||
|
||||
m_sortedSymbolPinList.emplace_back( pin->GetNumber(), netName );
|
||||
m_sortedSymbolPinList.emplace_back( pin->GetShownNumber(), netName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, LIB_SY
|
|||
continue;
|
||||
}
|
||||
|
||||
m_sortedSymbolPinList.emplace_back( pin->GetNumber(), netName );
|
||||
m_sortedSymbolPinList.emplace_back( pin->GetShownNumber(), netName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ bool NETLIST_EXPORTER_CADSTAR::writeListOfNets( FILE* f )
|
|||
wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
|
||||
|
||||
if( ref_a == ref_b )
|
||||
return a.first->GetNumber() < b.first->GetNumber();
|
||||
return a.first->GetShownNumber() < b.first->GetShownNumber();
|
||||
|
||||
return ref_a < ref_b;
|
||||
} );
|
||||
|
@ -158,7 +158,7 @@ bool NETLIST_EXPORTER_CADSTAR::writeListOfNets( FILE* f )
|
|||
wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
|
||||
wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
|
||||
|
||||
return ref_a == ref_b && a.first->GetNumber() == b.first->GetNumber();
|
||||
return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
|
||||
} ),
|
||||
sorted_items.end() );
|
||||
|
||||
|
@ -170,7 +170,7 @@ bool NETLIST_EXPORTER_CADSTAR::writeListOfNets( FILE* f )
|
|||
SCH_SHEET_PATH sheet = pair.second;
|
||||
|
||||
wxString refText = pin->GetParentSymbol()->GetRef( &sheet );
|
||||
wxString pinText = pin->GetNumber();
|
||||
wxString pinText = pin->GetShownNumber();
|
||||
|
||||
// Skip power symbols and virtual symbols
|
||||
if( refText[0] == wxChar( '#' ) )
|
||||
|
|
|
@ -695,7 +695,7 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
|
|||
wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
|
||||
|
||||
if( refA == refB )
|
||||
return a.m_Pin->GetNumber() < b.m_Pin->GetNumber();
|
||||
return a.m_Pin->GetShownNumber() < b.m_Pin->GetShownNumber();
|
||||
|
||||
return refA < refB;
|
||||
} );
|
||||
|
@ -710,14 +710,15 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
|
|||
wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet );
|
||||
wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
|
||||
|
||||
return refA == refB && a.m_Pin->GetNumber() == b.m_Pin->GetNumber();
|
||||
return refA == refB
|
||||
&& a.m_Pin->GetShownNumber() == b.m_Pin->GetShownNumber();
|
||||
} ),
|
||||
net_record->m_Nodes.end() );
|
||||
|
||||
for( const NET_NODE& netNode : net_record->m_Nodes )
|
||||
{
|
||||
wxString refText = netNode.m_Pin->GetParentSymbol()->GetRef( &netNode.m_Sheet );
|
||||
wxString pinText = netNode.m_Pin->GetNumber();
|
||||
wxString pinText = netNode.m_Pin->GetShownNumber();
|
||||
|
||||
// Skip power symbols and virtual symbols
|
||||
if( refText[0] == wxChar( '#' ) )
|
||||
|
@ -741,8 +742,7 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
|
|||
wxString pinName = netNode.m_Pin->GetShownName();
|
||||
wxString pinType = netNode.m_Pin->GetCanonicalElectricalTypeName();
|
||||
|
||||
// ~ is a char used to code empty strings in libs.
|
||||
if( pinName != "~" && !pinName.IsEmpty() )
|
||||
if( !pinName.IsEmpty() )
|
||||
xnode->AddAttribute( "pinfunction", pinName );
|
||||
|
||||
if( netNode.m_NoConnect )
|
||||
|
@ -774,5 +774,5 @@ XNODE* NETLIST_EXPORTER_XML::node( const wxString& aName,
|
|||
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 )
|
||||
{
|
||||
// return "lhs < rhs"
|
||||
return UTIL::RefDesStringCompare( aPin1->GetNumber(), aPin2->GetNumber() ) < 0;
|
||||
return UTIL::RefDesStringCompare( aPin1->GetShownNumber(), aPin2->GetShownNumber() ) < 0;
|
||||
}
|
||||
|
|
|
@ -87,10 +87,24 @@ wxString SCH_PIN::GetName() const
|
|||
|
||||
wxString SCH_PIN::GetShownName() const
|
||||
{
|
||||
if( !m_alt.IsEmpty() )
|
||||
return m_alt;
|
||||
wxString name = m_libPin->GetName();
|
||||
|
||||
return m_libPin->GetShownName();
|
||||
if( !m_alt.IsEmpty() )
|
||||
name = m_alt;
|
||||
|
||||
if( name == "~" )
|
||||
return wxEmptyString;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_PIN::GetShownNumber() const
|
||||
{
|
||||
if( m_number == "~" )
|
||||
return wxEmptyString;
|
||||
else
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,8 +198,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
|
|||
aList.push_back( MSG_PANEL_ITEM( _( "Converted" ), msg ) );
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetShownName() ) );
|
||||
msg = GetNumber().IsEmpty() ? wxT( "?" ) : GetShownNumber();
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Number" ), msg ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Number" ), GetShownNumber() ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), ElectricalPinTypeGetText( GetType() ) ) );
|
||||
|
||||
msg = PinShapeGetText( GetShape() );
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
wxString GetShownName() const;
|
||||
|
||||
wxString GetNumber() const { return m_number; }
|
||||
wxString GetShownNumber() const { return m_number; }
|
||||
wxString GetShownNumber() const;
|
||||
|
||||
void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
|
||||
|
||||
|
|
|
@ -531,7 +531,7 @@ void BACK_ANNOTATE::processNetNameChange( const wxString& aRef, SCH_PIN* aPin,
|
|||
|
||||
msg.Printf( _( "Change %s pin %s net label from '%s' to '%s'." ),
|
||||
aRef,
|
||||
aPin->GetNumber(),
|
||||
aPin->GetShownNumber(),
|
||||
aOldName,
|
||||
aNewName );
|
||||
|
||||
|
@ -554,15 +554,19 @@ void BACK_ANNOTATE::processNetNameChange( const wxString& aRef, SCH_PIN* aPin,
|
|||
|
||||
if( schPin->IsPowerConnection() )
|
||||
{
|
||||
msg.Printf( _( "Net %s cannot be changed to '%s' because it is driven by a power "
|
||||
"pin." ), aOldName, aNewName );
|
||||
msg.Printf( _( "Net %s cannot be changed to %s because it is driven by a power pin." ),
|
||||
aOldName,
|
||||
aNewName );
|
||||
|
||||
m_reporter.ReportHead( msg, RPT_SEVERITY_ERROR );
|
||||
break;
|
||||
}
|
||||
|
||||
++m_changesCount;
|
||||
msg.Printf( _( "Add label '%s' to %s pin %s net." ), aNewName, aRef, aPin->GetNumber() );
|
||||
msg.Printf( _( "Add label '%s' to %s pin %s net." ),
|
||||
aNewName,
|
||||
aRef,
|
||||
aPin->GetShownNumber() );
|
||||
|
||||
if( !m_dryRun )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue