From 13935399a54b738e5903bb2864006af1ebc5248a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 20 Jan 2024 18:41:11 +0000 Subject: [PATCH] Second part of d854de9d681267c1f0211fd75a29bbb4bf74d74d This one for symbol <-> footprint. (Original was for lib footprint <-> board footprint.) Also fixes a major bug in DRC where we bail out of parity checking if DRCE_MISSING_FOOTPRINT is set to ignore (or overflows). Fixes https://gitlab.com/kicad/code/kicad/-/issues/16671 --- pcbnew/board_design_settings.cpp | 1 + pcbnew/dialogs/dialog_drc.cpp | 3 +- pcbnew/drc/drc_item.cpp | 6 +++ pcbnew/drc/drc_item.h | 2 + .../drc_test_provider_schematic_parity.cpp | 47 +++++++++++++++---- pcbnew/pcb_marker.cpp | 1 + .../scripting/pcbnew_scripting_helpers.cpp | 3 +- 7 files changed, 51 insertions(+), 12 deletions(-) diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index ffcc9cc4b8..3aa5d4c94d 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -176,6 +176,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: m_DRCSeverities[ DRCE_DUPLICATE_FOOTPRINT ] = RPT_SEVERITY_WARNING; m_DRCSeverities[ DRCE_EXTRA_FOOTPRINT ] = RPT_SEVERITY_WARNING; m_DRCSeverities[ DRCE_NET_CONFLICT ] = RPT_SEVERITY_WARNING; + m_DRCSeverities[ DRCE_SCHEMATIC_PARITY_ISSUES ] = RPT_SEVERITY_WARNING; m_DRCSeverities[ DRCE_OVERLAPPING_SILK ] = RPT_SEVERITY_WARNING; m_DRCSeverities[ DRCE_SILK_CLEARANCE ] = RPT_SEVERITY_WARNING; diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 27355155ed..6f9b889fd0 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -1192,7 +1192,8 @@ void DIALOG_DRC::updateDisplayedCounts() else if( ii == DRCE_MISSING_FOOTPRINT || ii == DRCE_DUPLICATE_FOOTPRINT || ii == DRCE_EXTRA_FOOTPRINT - || ii == DRCE_NET_CONFLICT ) + || ii == DRCE_NET_CONFLICT + || ii == DRCE_SCHEMATIC_PARITY_ISSUES ) { if( showWarnings && bds.GetSeverity( ii ) == RPT_SEVERITY_WARNING ) footprintsOverflowed = true; diff --git a/pcbnew/drc/drc_item.cpp b/pcbnew/drc/drc_item.cpp index 9114b43f0e..658291b6fc 100644 --- a/pcbnew/drc/drc_item.cpp +++ b/pcbnew/drc/drc_item.cpp @@ -181,6 +181,10 @@ DRC_ITEM DRC_ITEM::netConflict( DRCE_NET_CONFLICT, _( "Pad net doesn't match schematic" ), wxT( "net_conflict" ) ); +DRC_ITEM DRC_ITEM::schematicParityIssues( DRCE_SCHEMATIC_PARITY_ISSUES, + _( "Footprint attributes don't match symbol" ), + wxT( "footprint_symbol_mismatch" ) ); + DRC_ITEM DRC_ITEM::libFootprintIssues( DRCE_LIB_FOOTPRINT_ISSUES, _( "Footprint not found in libraries" ), wxT( "lib_footprint_issues" ) ); @@ -287,6 +291,7 @@ std::vector> DRC_ITEM::allItemTypes( { DRC_ITEM::duplicateFootprints, DRC_ITEM::missingFootprint, DRC_ITEM::extraFootprint, + DRC_ITEM::schematicParityIssues, DRC_ITEM::netConflict, DRC_ITEM::unconnectedItems, @@ -359,6 +364,7 @@ std::shared_ptr DRC_ITEM::Create( int aErrorCode ) case DRCE_DUPLICATE_FOOTPRINT: return std::make_shared( duplicateFootprints ); case DRCE_NET_CONFLICT: return std::make_shared( netConflict ); case DRCE_EXTRA_FOOTPRINT: return std::make_shared( extraFootprint ); + case DRCE_SCHEMATIC_PARITY_ISSUES: return std::make_shared( schematicParityIssues ); case DRCE_LIB_FOOTPRINT_ISSUES: return std::make_shared( libFootprintIssues ); case DRCE_LIB_FOOTPRINT_MISMATCH: return std::make_shared( libFootprintMismatch ); case DRCE_UNRESOLVED_VARIABLE: return std::make_shared( unresolvedVariable ); diff --git a/pcbnew/drc/drc_item.h b/pcbnew/drc/drc_item.h index 9e0200e4e1..e623108001 100644 --- a/pcbnew/drc/drc_item.h +++ b/pcbnew/drc/drc_item.h @@ -71,6 +71,7 @@ enum PCB_DRC_CODE { DRCE_DUPLICATE_FOOTPRINT, // more than one footprints found for netlist item DRCE_EXTRA_FOOTPRINT, // netlist item not found for footprint DRCE_NET_CONFLICT, // pad net doesn't match netlist + DRCE_SCHEMATIC_PARITY_ISSUES, // footprint attributes don't match symbol attributes DRCE_FOOTPRINT_TYPE_MISMATCH, // footprint attribute does not match actual pads DRCE_LIB_FOOTPRINT_ISSUES, // footprint not found in active libraries @@ -187,6 +188,7 @@ private: static DRC_ITEM missingFootprint; static DRC_ITEM extraFootprint; static DRC_ITEM netConflict; + static DRC_ITEM schematicParityIssues; static DRC_ITEM libFootprintIssues; static DRC_ITEM libFootprintMismatch; static DRC_ITEM unresolvedVariable; diff --git a/pcbnew/drc/drc_test_provider_schematic_parity.cpp b/pcbnew/drc/drc_test_provider_schematic_parity.cpp index ae7ec964e3..95fe21eb2d 100644 --- a/pcbnew/drc/drc_test_provider_schematic_parity.cpp +++ b/pcbnew/drc/drc_test_provider_schematic_parity.cpp @@ -38,6 +38,7 @@ - DRCE_MISSING_FOOTPRINT - DRCE_DUPLICATE_FOOTPRINT - DRCE_EXTRA_FOOTPRINT + - DRCE_SCHEMATIC_PARITY_ISSUES TODO: - cross-check PCB netlist against SCH netlist @@ -109,21 +110,47 @@ void DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist( NETLIST& aNetlist ) if( footprint == nullptr ) { - if( m_drcEngine->IsErrorLimitExceeded( DRCE_MISSING_FOOTPRINT ) ) - break; + if( !m_drcEngine->IsErrorLimitExceeded( DRCE_MISSING_FOOTPRINT ) ) + { + wxString msg; + msg.Printf( _( "Missing footprint %s (%s)" ), + component->GetReference(), + component->GetValue() ); - wxString msg; - msg.Printf( _( "Missing footprint %s (%s)" ), - component->GetReference(), - component->GetValue() ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_MISSING_FOOTPRINT ); - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_MISSING_FOOTPRINT ); - - drcItem->SetErrorMessage( msg ); - reportViolation( drcItem, VECTOR2I(), UNDEFINED_LAYER ); + drcItem->SetErrorMessage( msg ); + reportViolation( drcItem, VECTOR2I(), UNDEFINED_LAYER ); + } } else { + if( ( component->GetProperties().count( "dnp" ) > 0 ) + != ( ( footprint->GetAttributes() & FP_DNP ) > 0 ) + && !m_drcEngine->IsErrorLimitExceeded( DRCE_SCHEMATIC_PARITY_ISSUES ) ) + { + wxString msg; + msg.Printf( _( "'%s' settings differ." ), _( "Do not populate" ) ); + + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_SCHEMATIC_PARITY_ISSUES ); + drcItem->SetErrorMessage( drcItem->GetErrorMessage() + wxS( ": " ) + msg ); + drcItem->SetItems( footprint ); + reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER ); + } + + if( ( component->GetProperties().count( "exclude_from_bom" ) > 0 ) + != ( (footprint->GetAttributes() & FP_EXCLUDE_FROM_BOM ) > 0 ) + && !m_drcEngine->IsErrorLimitExceeded( DRCE_SCHEMATIC_PARITY_ISSUES ) ) + { + wxString msg; + msg.Printf( _( "'%s' settings differ." ), _( "Exclude from bill of materials" ) ); + + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_SCHEMATIC_PARITY_ISSUES ); + drcItem->SetErrorMessage( drcItem->GetErrorMessage() + wxS( ": " ) + msg ); + drcItem->SetItems( footprint ); + reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER ); + } + for( PAD* pad : footprint->Pads() ) { if( m_drcEngine->IsErrorLimitExceeded( DRCE_NET_CONFLICT ) ) diff --git a/pcbnew/pcb_marker.cpp b/pcbnew/pcb_marker.cpp index e4a71033dc..24fa2d58a1 100644 --- a/pcbnew/pcb_marker.cpp +++ b/pcbnew/pcb_marker.cpp @@ -68,6 +68,7 @@ PCB_MARKER::PCB_MARKER( std::shared_ptr aItem, const VECTOR2I& aPositio case DRCE_DUPLICATE_FOOTPRINT: case DRCE_EXTRA_FOOTPRINT: case DRCE_NET_CONFLICT: + case DRCE_SCHEMATIC_PARITY_ISSUES: SetMarkerType( MARKER_BASE::MARKER_PARITY ); break; diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 5ffb0ddc81..180e8f5245 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -571,7 +571,8 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT || aItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT || aItem->GetErrorCode() == DRCE_EXTRA_FOOTPRINT - || aItem->GetErrorCode() == DRCE_NET_CONFLICT ) + || aItem->GetErrorCode() == DRCE_NET_CONFLICT + || aItem->GetErrorCode() == DRCE_SCHEMATIC_PARITY_ISSUES ) { footprints.push_back( aItem ); }