From fb8f05fb3496be9f07ca8d64434816ef635e3e11 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 26 Jan 2024 18:11:10 +0000 Subject: [PATCH] Correctly report body style in symbol checker. Also fixes a bug where off-grid pin locations were truncated. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16770 --- eeschema/lib_item.cpp | 43 ++++++++++------ eeschema/lib_item.h | 3 ++ eeschema/picksymbol.cpp | 3 +- eeschema/sch_pin.cpp | 24 +++++---- eeschema/symbol_checker.cpp | 64 ++++++++++++------------ eeschema/symbol_editor/symbol_editor.cpp | 6 ++- 6 files changed, 85 insertions(+), 58 deletions(-) diff --git a/eeschema/lib_item.cpp b/eeschema/lib_item.cpp index 036d93e0ad..f58dbd2b2f 100644 --- a/eeschema/lib_item.cpp +++ b/eeschema/lib_item.cpp @@ -43,27 +43,42 @@ LIB_ITEM::LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol, int aUnit, int aConvert } +wxString LIB_ITEM::GetUnitDescription( int aUnit ) +{ + if( aUnit == 0 ) + return _( "All" ); + else + return LIB_SYMBOL::LetterSubReference( aUnit, 'A' ); +} + + +wxString LIB_ITEM::GetBodyStyleDescription( int aBodyStyle ) +{ + if( aBodyStyle == 0 ) + return _( "All" ); + else if( aBodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN ) + return _( "Alternate" ); + else if( aBodyStyle == LIB_ITEM::BODY_STYLE::BASE ) + return _( "Standard" ); + else + return wxT( "?" ); +} + + void LIB_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { wxString msg; aList.emplace_back( _( "Type" ), GetTypeName() ); - if( m_unit == 0 ) - msg = _( "All" ); - else - msg = LIB_SYMBOL::LetterSubReference( m_unit, 'A' ); + if( LIB_SYMBOL* parent = GetParent() ) + { + if( parent->GetUnitCount() ) + aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) ); - aList.emplace_back( _( "Unit" ), msg ); - - if( m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE ) - msg = _( "no" ); - else if( m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN ) - msg = _( "yes" ); - else - msg = wxT( "?" ); - - aList.emplace_back( _( "Converted" ), msg ); + if( parent->HasAlternateBodyStyle() ) + aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( m_bodyStyle ) ); + } if( IsPrivate() ) aList.emplace_back( _( "Private" ), wxEmptyString ); diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index ddb54d791c..049277360f 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -123,6 +123,9 @@ public: return false; } + static wxString GetUnitDescription( int aUnit ); + static wxString GetBodyStyleDescription( int aBodyStyle ); + /** * Create a copy of this #LIB_ITEM (with a new Uuid). */ diff --git a/eeschema/picksymbol.cpp b/eeschema/picksymbol.cpp index 0588ab64db..a0778de1e7 100644 --- a/eeschema/picksymbol.cpp +++ b/eeschema/picksymbol.cpp @@ -158,7 +158,8 @@ void SCH_EDIT_FRAME::FlipBodyStyle( SCH_SYMBOL* aSymbol ) if( aSymbol->IsSelected() ) m_toolManager->RunAction( EE_ACTIONS::addItemToSel, aSymbol ); - // TODO: 9.0 "Change Body Style" + // TODO: 9.0 It would be better as "Change Body Style", but we're past string freeze so + // this (existing) string will have to do.... commit.Push( _( "Convert Symbol" ) ); } diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 03e63da190..003b15d440 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -211,18 +211,25 @@ wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - wxString msg; + wxString msg; + SCH_SYMBOL* symbol = GetParentSymbol(); aList.emplace_back( _( "Type" ), _( "Pin" ) ); - if( m_libPin->GetBodyStyle() == LIB_ITEM::BODY_STYLE::BASE ) - msg = _( "no" ); - else if( m_libPin->GetBodyStyle() == LIB_ITEM::BODY_STYLE::DEMORGAN ) - msg = _( "yes" ); - else - msg = wxT( "?" ); + if( LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get() ) + { + if( libSymbol->GetUnitCount() ) + { + aList.emplace_back( _( "Unit" ), + LIB_ITEM::GetUnitDescription( m_libPin->GetUnit() ) ); + } - aList.emplace_back( _( "Converted" ), msg ); + if( libSymbol->HasAlternateBodyStyle() ) + { + aList.emplace_back( _( "Body Style" ), + LIB_ITEM::GetBodyStyleDescription( m_libPin->GetBodyStyle() ) ); + } + } aList.emplace_back( _( "Name" ), GetShownName() ); aList.emplace_back( _( "Number" ), GetShownNumber() ); @@ -237,7 +244,6 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( aFrame ); SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr; - SCH_SYMBOL* symbol = GetParentSymbol(); // Don't use GetShownText(); we want to see the variable references here aList.emplace_back( symbol->GetRef( currentSheet ), diff --git a/eeschema/symbol_checker.cpp b/eeschema/symbol_checker.cpp index baaba4a6bc..a304845036 100644 --- a/eeschema/symbol_checker.cpp +++ b/eeschema/symbol_checker.cpp @@ -115,10 +115,9 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, { if( pin->GetUnit() == 0 || next->GetUnit() == 0 ) { - // TODO: 9.0: change "of converted" to "of alternate body style" msg.Printf( _( "Duplicate pin %s %s at location (%s, %s)" " conflicts with pin %s%s at location (%s, %s)" - " of converted." ), + " in %s body style." ), next->GetNumber(), nextName, aUnitsProvider->MessageTextFromValue( next->GetPosition().x ), @@ -126,14 +125,14 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, pin->GetNumber(), pin->GetName(), aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), - aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) ); + aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), + LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } else { - // TODO: 9.0: change "of converted" to "of alternate body style" msg.Printf( _( "Duplicate pin %s %s at location (%s, %s)" " conflicts with pin %s%s at location (%s, %s)" - " in units %s and %s of converted." ), + " in units %s and %s of %s body style." ), next->GetNumber(), nextName, aUnitsProvider->MessageTextFromValue( next->GetPosition().x ), @@ -143,7 +142,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), aSymbol->GetUnitReference( next->GetUnit() ), - aSymbol->GetUnitReference( pin->GetUnit() ) ); + aSymbol->GetUnitReference( pin->GetUnit() ), + LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } } else @@ -245,24 +245,24 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, { if( aSymbol->GetUnitCount() <= 1 ) { - // TODO: 9.0: change "of converted" to "of alternate body style" msg.Printf( _( "Info: Hidden power pin %s %s at location (%s, %s)" - " of converted." ), - pin->GetNumber(), - pinName, - aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), - aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) ); - } - else - { - // TODO: 9.0: change "of converted" to "of alternate body style" - msg.Printf( _( "Info: Hidden power pin %s %s at location (%s, %s)" - " in unit %c of converted." ), + " in %s body style." ), pin->GetNumber(), pinName, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), - 'A' + pin->GetUnit() - 1 ); + LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + } + else + { + msg.Printf( _( "Info: Hidden power pin %s %s at location (%s, %s)" + " in unit %c of %s body style." ), + pin->GetNumber(), + pinName, + aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), + aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), + 'A' + pin->GetUnit() - 1, + LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } } else @@ -303,24 +303,24 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, { if( aSymbol->GetUnitCount() <= 1 ) { - // TODO: 9.0: change "of converted" to "of alternate body style" msg.Printf( _( "Off grid pin %s %s at location (%s, %s)" - " of converted." ), - pin->GetNumber(), - pinName, - aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), - aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) ); - } - else - { - // TODO: 9.0: change "of converted" to "of alternate body style" - msg.Printf( _( "Off grid pin %s %s at location (%.3s, %.3s)" - " in unit %c of converted." ), + " of %s body style." ), pin->GetNumber(), pinName, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), - 'A' + pin->GetUnit() - 1 ); + LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + } + else + { + msg.Printf( _( "Off grid pin %s %s at location (%s, %s)" + " in unit %c of %s body style." ), + pin->GetNumber(), + pinName, + aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), + aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), + 'A' + pin->GetUnit() - 1, + LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } } else diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 9cc04027b8..a0c14c3b03 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -1277,10 +1277,12 @@ void SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo() AppendMsgPanel( _( "Unit" ), msg, 8 ); - if( m_bodyStyle > 1 ) + if( m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN ) msg = _( "Alternate" ); - else + else if( m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE ) msg = _( "Standard" ); + else + wxT( "?" ); AppendMsgPanel( _( "Body" ), msg, 8 );