Honour alternates when getting SCH_PIN description.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16407
This commit is contained in:
Jeff Young 2023-12-22 22:20:25 +00:00
parent 4bdd5e172c
commit af158715e5
3 changed files with 40 additions and 14 deletions

View File

@ -1396,49 +1396,63 @@ BITMAPS LIB_PIN::GetMenuImage() const
} }
wxString LIB_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const
{
return getItemDescription( aAlt );
}
wxString LIB_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString LIB_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{
return getItemDescription( nullptr );
}
wxString LIB_PIN::getItemDescription( ALT* aAlt ) const
{ {
// This code previously checked "m_name.IsEmpty()" to choose the correct // This code previously checked "m_name.IsEmpty()" to choose the correct
// formatting path, but that check fails if the pin is called "~" which is // formatting path, but that check fails if the pin is called "~" which is
// the default for an empty pin name. Instead we get the final display string // the default for an empty pin name. Instead we get the final display string
// that will be shown and check if it's empty. // that will be shown and check if it's empty.
wxString shownName = UnescapeString( GetShownName() ); wxString name = UnescapeString( aAlt ? aAlt->m_Name : GetShownName() );
wxString electricalTypeName = ElectricalPinTypeGetText( aAlt ? aAlt->m_Type : m_type );
wxString pinShapeName = PinShapeGetText( aAlt ? aAlt->m_Shape : m_shape );
if( IsVisible() ) if( IsVisible() )
{ {
if ( !shownName.IsEmpty() ) if ( !name.IsEmpty() )
{ {
return wxString::Format( _( "Pin %s [%s, %s, %s]" ), return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
GetShownNumber(), GetShownNumber(),
shownName, name,
GetElectricalTypeName(), electricalTypeName,
PinShapeGetText( m_shape ) ); pinShapeName );
} }
else else
{ {
return wxString::Format( _( "Pin %s [%s, %s]" ), return wxString::Format( _( "Pin %s [%s, %s]" ),
GetShownNumber(), GetShownNumber(),
GetElectricalTypeName(), electricalTypeName,
PinShapeGetText( m_shape ) ); pinShapeName );
} }
} }
else else
{ {
if( !shownName.IsEmpty() ) if( !name.IsEmpty() )
{ {
return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ), return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
GetShownNumber(), GetShownNumber(),
shownName, name,
GetElectricalTypeName(), electricalTypeName,
PinShapeGetText( m_shape ) ); pinShapeName );
} }
else else
{ {
return wxString::Format( _( "Hidden pin %s [%s, %s]" ), return wxString::Format( _( "Hidden pin %s [%s, %s]" ),
GetShownNumber(), GetShownNumber(),
GetElectricalTypeName(), electricalTypeName,
PinShapeGetText( m_shape ) ); pinShapeName );
} }
} }
} }

View File

@ -250,6 +250,7 @@ public:
BITMAPS GetMenuImage() const override; BITMAPS GetMenuImage() const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const;
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
@ -273,6 +274,8 @@ public:
bool operator>( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; } bool operator>( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; }
protected: protected:
wxString getItemDescription( ALT* aAlt ) const;
struct EXTENTS_CACHE struct EXTENTS_CACHE
{ {
KIFONT::FONT* m_Font = nullptr; KIFONT::FONT* m_Font = nullptr;

View File

@ -194,9 +194,18 @@ SCH_SYMBOL* SCH_PIN::GetParentSymbol() const
wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
LIB_PIN::ALT localStorage;
LIB_PIN::ALT* alt = nullptr;
if( !m_alt.IsEmpty() )
{
localStorage = m_libPin->GetAlt( m_alt );
alt = &localStorage;
}
return wxString::Format( "Symbol %s %s", return wxString::Format( "Symbol %s %s",
UnescapeString( GetParentSymbol()->GetField( REFERENCE_FIELD )->GetText() ), UnescapeString( GetParentSymbol()->GetField( REFERENCE_FIELD )->GetText() ),
m_libPin->GetItemDescription( aUnitsProvider ) ); m_libPin->GetItemDescription( aUnitsProvider, alt ) );
} }