diff --git a/eeschema/symbol_checker.cpp b/eeschema/symbol_checker.cpp index 94d32563f3..76769d407a 100644 --- a/eeschema/symbol_checker.cpp +++ b/eeschema/symbol_checker.cpp @@ -24,10 +24,15 @@ #include #include #include +#include +#include // helper function to sort pins by pin num static bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ); +static void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector& aMessages, + EDA_DRAW_FRAME* aUnitsProvider ); + /** * Check a lib symbol to find incorrect settings * Pins not on a valid grid @@ -330,9 +335,63 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, 'A' + pin->GetUnit() - 1 ); } } + } + } - msg += wxT( "

" ); - aMessages.push_back( msg ); + CheckLibSymbolGraphics( aSymbol, aMessages, aUnitsProvider ); +} + + +void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector& aMessages, + EDA_DRAW_FRAME* aUnitsProvider ) +{ + if( !aSymbol ) + return; + + wxString msg; + + for( const LIB_ITEM& item : aSymbol->GetDrawItems() ) + { + if( item.Type() != LIB_SHAPE_T ) + continue; + + const LIB_SHAPE* shape = static_cast( &item ); + + switch( shape->GetShape() ) + { + case SHAPE_T::ARC: + break; + + case SHAPE_T::CIRCLE: + if( shape->GetRadius() <= 0 ) + { + msg.Printf( _( "Graphic circle has radius = 0 at location (%s, %s)." ), + aUnitsProvider->MessageTextFromValue(shape->GetPosition().x ), + aUnitsProvider->MessageTextFromValue( -shape->GetPosition().y ) ); + msg += wxT( "
" ); + aMessages.push_back( msg ); + } + break; + + case SHAPE_T::RECTANGLE: + if( shape->GetPosition() == shape->GetEnd() ) + { + msg.Printf( _( "Graphic rectangle has size 0 at location (%s, %s)." ), + aUnitsProvider->MessageTextFromValue(shape->GetPosition().x ), + aUnitsProvider->MessageTextFromValue( -shape->GetPosition().y ) ); + msg += wxT( "
" ); + aMessages.push_back( msg ); + } + break; + + case SHAPE_T::POLY: + break; + + case SHAPE_T::BEZIER: + break; + + default: + UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } } }