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
This commit is contained in:
Jeff Young 2024-01-26 18:11:10 +00:00
parent cc9f8f5b83
commit fb8f05fb34
6 changed files with 85 additions and 58 deletions

View File

@ -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<MSG_PANEL_ITEM>& aList ) void LIB_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
wxString msg; wxString msg;
aList.emplace_back( _( "Type" ), GetTypeName() ); aList.emplace_back( _( "Type" ), GetTypeName() );
if( m_unit == 0 ) if( LIB_SYMBOL* parent = GetParent() )
msg = _( "All" ); {
else if( parent->GetUnitCount() )
msg = LIB_SYMBOL::LetterSubReference( m_unit, 'A' ); aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) );
aList.emplace_back( _( "Unit" ), msg ); if( parent->HasAlternateBodyStyle() )
aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( m_bodyStyle ) );
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( IsPrivate() ) if( IsPrivate() )
aList.emplace_back( _( "Private" ), wxEmptyString ); aList.emplace_back( _( "Private" ), wxEmptyString );

View File

@ -123,6 +123,9 @@ public:
return false; return false;
} }
static wxString GetUnitDescription( int aUnit );
static wxString GetBodyStyleDescription( int aBodyStyle );
/** /**
* Create a copy of this #LIB_ITEM (with a new Uuid). * Create a copy of this #LIB_ITEM (with a new Uuid).
*/ */

View File

@ -158,7 +158,8 @@ void SCH_EDIT_FRAME::FlipBodyStyle( SCH_SYMBOL* aSymbol )
if( aSymbol->IsSelected() ) if( aSymbol->IsSelected() )
m_toolManager->RunAction<EDA_ITEM*>( EE_ACTIONS::addItemToSel, aSymbol ); m_toolManager->RunAction<EDA_ITEM*>( 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" ) ); commit.Push( _( "Convert Symbol" ) );
} }

View File

@ -211,18 +211,25 @@ wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
wxString msg; wxString msg;
SCH_SYMBOL* symbol = GetParentSymbol();
aList.emplace_back( _( "Type" ), _( "Pin" ) ); aList.emplace_back( _( "Type" ), _( "Pin" ) );
if( m_libPin->GetBodyStyle() == LIB_ITEM::BODY_STYLE::BASE ) if( LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get() )
msg = _( "no" ); {
else if( m_libPin->GetBodyStyle() == LIB_ITEM::BODY_STYLE::DEMORGAN ) if( libSymbol->GetUnitCount() )
msg = _( "yes" ); {
else aList.emplace_back( _( "Unit" ),
msg = wxT( "?" ); 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( _( "Name" ), GetShownName() );
aList.emplace_back( _( "Number" ), GetShownNumber() ); aList.emplace_back( _( "Number" ), GetShownNumber() );
@ -237,7 +244,6 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ); SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr; SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
SCH_SYMBOL* symbol = GetParentSymbol();
// Don't use GetShownText(); we want to see the variable references here // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( symbol->GetRef( currentSheet ), aList.emplace_back( symbol->GetRef( currentSheet ),

View File

@ -115,10 +115,9 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
{ {
if( pin->GetUnit() == 0 || next->GetUnit() == 0 ) if( pin->GetUnit() == 0 || next->GetUnit() == 0 )
{ {
// TODO: 9.0: change "of converted" to "of alternate body style"
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>" msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
" conflicts with pin %s%s at location <b>(%s, %s)</b>" " conflicts with pin %s%s at location <b>(%s, %s)</b>"
" of converted." ), " in %s body style." ),
next->GetNumber(), next->GetNumber(),
nextName, nextName,
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ), aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
@ -126,14 +125,14 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
pin->GetNumber(), pin->GetNumber(),
pin->GetName(), pin->GetName(),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) ); aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
} }
else else
{ {
// TODO: 9.0: change "of converted" to "of alternate body style"
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>" msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
" conflicts with pin %s%s at location <b>(%s, %s)</b>" " conflicts with pin %s%s at location <b>(%s, %s)</b>"
" in units %s and %s of converted." ), " in units %s and %s of %s body style." ),
next->GetNumber(), next->GetNumber(),
nextName, nextName,
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ), aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
@ -143,7 +142,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
aSymbol->GetUnitReference( next->GetUnit() ), aSymbol->GetUnitReference( next->GetUnit() ),
aSymbol->GetUnitReference( pin->GetUnit() ) ); aSymbol->GetUnitReference( pin->GetUnit() ),
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
} }
} }
else else
@ -245,24 +245,24 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
{ {
if( aSymbol->GetUnitCount() <= 1 ) if( aSymbol->GetUnitCount() <= 1 )
{ {
// TODO: 9.0: change "of converted" to "of alternate body style"
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>" msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
" of converted." ), " in %s body style." ),
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: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
" in unit %c of converted." ),
pin->GetNumber(), pin->GetNumber(),
pinName, pinName,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1 ); LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
else
{
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
" 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 else
@ -303,24 +303,24 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
{ {
if( aSymbol->GetUnitCount() <= 1 ) if( aSymbol->GetUnitCount() <= 1 )
{ {
// TODO: 9.0: change "of converted" to "of alternate body style"
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>" msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
" of converted." ), " of %s body style." ),
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( _( "<b>Off grid pin %s</b> %s at location <b>(%.3s, %.3s)</b>"
" in unit %c of converted." ),
pin->GetNumber(), pin->GetNumber(),
pinName, pinName,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1 ); LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
else
{
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
" 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 else

View File

@ -1277,10 +1277,12 @@ void SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo()
AppendMsgPanel( _( "Unit" ), msg, 8 ); AppendMsgPanel( _( "Unit" ), msg, 8 );
if( m_bodyStyle > 1 ) if( m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN )
msg = _( "Alternate" ); msg = _( "Alternate" );
else else if( m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE )
msg = _( "Standard" ); msg = _( "Standard" );
else
wxT( "?" );
AppendMsgPanel( _( "Body" ), msg, 8 ); AppendMsgPanel( _( "Body" ), msg, 8 );