Add messages for clearance reports on footprints.

Fixes https://gitlab.com/kicad/code/kicad/issues/13874
This commit is contained in:
Jeff Young 2023-04-02 18:52:58 +01:00
parent 28028c941e
commit 77639a540b
1 changed files with 39 additions and 1 deletions

View File

@ -601,7 +601,45 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
b = *bg->GetItems().begin();
}
// a and b could be null after group tests above.
// a or b could be null after group tests above.
wxCHECK( a && b, 0 );
auto checkFootprint =
[&]( FOOTPRINT* footprint ) -> BOARD_ITEM*
{
if( footprint->Pads().empty() )
{
m_frame->ShowInfoBarError( _( "Cannot generate clearance report on footprint "
"with no pads." ) );
return nullptr;
}
PAD* foundPad = nullptr;
for( PAD* pad : footprint->Pads() )
{
if( !foundPad || pad->SameLogicalPadAs( foundPad ) )
{
foundPad = pad;
}
else
{
m_frame->ShowInfoBarError( _( "Cannot generate clearance report on footprint "
"with multiple pads. Select a single pad." ) );
return nullptr;
}
}
return foundPad;
};
if( a->Type() == PCB_FOOTPRINT_T )
a = checkFootprint( static_cast<FOOTPRINT*>( a ) );
if( b->Type() == PCB_FOOTPRINT_T )
b = checkFootprint( static_cast<FOOTPRINT*>( b ) );
// a or b could be null after footprint tests above.
wxCHECK( a && b, 0 );
DIALOG_BOOK_REPORTER* dialog = m_frame->GetInspectClearanceDialog();