Honour alternates when getting SCH_PIN description.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16407

(cherry picked from commit af158715e5)
This commit is contained in:
Jeff Young 2023-12-22 22:20:25 +00:00
parent 2daa432261
commit 76d463dcc8
3 changed files with 42 additions and 16 deletions

View File

@ -1369,49 +1369,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
{
// This code previously checked "m_name.IsEmpty()" to choose the correct
return getItemDescription( nullptr );
}
wxString LIB_PIN::getItemDescription( ALT* aAlt ) const
{
// This code previously checked "m_name.IsEmpty()" to choose the correct
// 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.
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 ( !shownName.IsEmpty() )
if ( !name.IsEmpty() )
{
return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
GetShownNumber(),
shownName,
GetElectricalTypeName(),
PinShapeGetText( m_shape ) );
name,
electricalTypeName,
pinShapeName );
}
else
{
return wxString::Format( _( "Pin %s [%s, %s]" ),
GetShownNumber(),
GetElectricalTypeName(),
PinShapeGetText( m_shape ) );
electricalTypeName,
pinShapeName );
}
}
else
{
if( !shownName.IsEmpty() )
if( !name.IsEmpty() )
{
return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
GetShownNumber(),
shownName,
GetElectricalTypeName(),
PinShapeGetText( m_shape ) );
name,
electricalTypeName,
pinShapeName );
}
else
{
return wxString::Format( _( "Hidden pin %s [%s, %s]" ),
GetShownNumber(),
GetElectricalTypeName(),
PinShapeGetText( m_shape ) );
electricalTypeName,
pinShapeName );
}
}
}

View File

@ -244,6 +244,7 @@ public:
BITMAPS GetMenuImage() const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const;
EDA_ITEM* Clone() const override;
@ -260,6 +261,8 @@ public:
static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType );
protected:
wxString getItemDescription( ALT* aAlt ) const;
struct EXTENTS_CACHE
{
KIFONT::FONT* m_Font = nullptr;

View File

@ -193,9 +193,18 @@ SCH_SYMBOL* SCH_PIN::GetParentSymbol() 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",
UnescapeString( GetParentSymbol()->GetField( REFERENCE_FIELD )->GetText() ),
m_libPin->GetItemDescription( aUnitsProvider ) );
m_libPin->GetItemDescription( aUnitsProvider, alt ) );
}