diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index fabe01fa7e..353a71a6b2 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -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 ); } } } diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 1c970d58ec..287fa28fed 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -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; diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index e40b93ded0..7316b56a83 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -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 ) ); }