From 3a3ceb8ffc8fb4a4707c95a8e60f659be61176fd Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 2 Mar 2024 15:26:28 -0500 Subject: [PATCH] Allow specifying a minimum for a via_count constraint Fixes https://gitlab.com/kicad/code/kicad/-/issues/17234 --- pcbnew/drc/drc_item.cpp | 9 +++++---- pcbnew/drc/drc_item.h | 4 ++-- .../drc/drc_test_provider_matched_length.cpp | 19 +++++++++++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pcbnew/drc/drc_item.cpp b/pcbnew/drc/drc_item.cpp index 658291b6fc..92a8667d91 100644 --- a/pcbnew/drc/drc_item.cpp +++ b/pcbnew/drc/drc_item.cpp @@ -237,8 +237,9 @@ DRC_ITEM DRC_ITEM::skewOutOfRange( DRCE_SKEW_OUT_OF_RANGE, _( "Skew between traces out of range" ), wxT( "skew_out_of_range" ) ); -DRC_ITEM DRC_ITEM::tooManyVias( DRCE_TOO_MANY_VIAS, - _( "Too many vias on a connection" ), +// Note: this used to only check against a max value, hence the settings key too_many_vias +DRC_ITEM DRC_ITEM::viaCountOutOfRange( DRCE_VIA_COUNT_OUT_OF_RANGE, + _( "Too many or too few vias on a connection" ), wxT( "too_many_vias" ) ); DRC_ITEM DRC_ITEM::diffPairGapOutOfRange( DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE, @@ -298,7 +299,7 @@ std::vector> DRC_ITEM::allItemTypes( { DRC_ITEM::heading_signal_integrity, DRC_ITEM::lengthOutOfRange, DRC_ITEM::skewOutOfRange, - DRC_ITEM::tooManyVias, + DRC_ITEM::viaCountOutOfRange, DRC_ITEM::diffPairGapOutOfRange, DRC_ITEM::diffPairUncoupledLengthTooLong, @@ -378,7 +379,7 @@ std::shared_ptr DRC_ITEM::Create( int aErrorCode ) case DRCE_TEXT_THICKNESS: return std::make_shared( textThicknessOutOfRange ); case DRCE_LENGTH_OUT_OF_RANGE: return std::make_shared( lengthOutOfRange ); case DRCE_SKEW_OUT_OF_RANGE: return std::make_shared( skewOutOfRange ); - case DRCE_TOO_MANY_VIAS: return std::make_shared( tooManyVias ); + case DRCE_VIA_COUNT_OUT_OF_RANGE: return std::make_shared( viaCountOutOfRange ); case DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE: return std::make_shared( diffPairGapOutOfRange ); case DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG: return std::make_shared( diffPairUncoupledLengthTooLong ); case DRCE_FOOTPRINT: return std::make_shared( footprint ); diff --git a/pcbnew/drc/drc_item.h b/pcbnew/drc/drc_item.h index c891e98c96..e919292c2a 100644 --- a/pcbnew/drc/drc_item.h +++ b/pcbnew/drc/drc_item.h @@ -95,7 +95,7 @@ enum PCB_DRC_CODE { DRCE_LENGTH_OUT_OF_RANGE, DRCE_SKEW_OUT_OF_RANGE, - DRCE_TOO_MANY_VIAS, + DRCE_VIA_COUNT_OUT_OF_RANGE, DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE, DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG, @@ -202,7 +202,7 @@ private: static DRC_ITEM textThicknessOutOfRange; static DRC_ITEM lengthOutOfRange; static DRC_ITEM skewOutOfRange; - static DRC_ITEM tooManyVias; + static DRC_ITEM viaCountOutOfRange; static DRC_ITEM diffPairGapOutOfRange; static DRC_ITEM diffPairUncoupledLengthTooLong; static DRC_ITEM footprint; diff --git a/pcbnew/drc/drc_test_provider_matched_length.cpp b/pcbnew/drc/drc_test_provider_matched_length.cpp index fe9fc90dda..da276a0179 100644 --- a/pcbnew/drc/drc_test_provider_matched_length.cpp +++ b/pcbnew/drc/drc_test_provider_matched_length.cpp @@ -201,16 +201,31 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts( const DRC_CONSTRAINT& aCo { for( const auto& ent : aMatchedConnections ) { + std::shared_ptr drcItem = nullptr; + if( aConstraint.GetValue().HasMax() && ent.viaCount > aConstraint.GetValue().Max() ) { - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_TOO_MANY_VIAS ); + drcItem = DRC_ITEM::Create( DRCE_VIA_COUNT_OUT_OF_RANGE ); wxString msg = wxString::Format( _( "(%s max count %d; actual %d)" ), aConstraint.GetName(), aConstraint.GetValue().Max(), ent.viaCount ); - drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetErrorMessage( _( "Too many vias on a connection" ) + wxS( " " ) + msg ); + } + else if( aConstraint.GetValue().HasMin() && ent.viaCount < aConstraint.GetValue().Min() ) + { + drcItem = DRC_ITEM::Create( DRCE_VIA_COUNT_OUT_OF_RANGE ); + wxString msg = wxString::Format( _( "(%s min count %d; actual %d)" ), + aConstraint.GetName(), + aConstraint.GetValue().Min(), + ent.viaCount ); + drcItem->SetErrorMessage( _( "Too few vias on a connection" ) + wxS( " " ) + msg ); + } + + if( drcItem ) + { for( auto offendingTrack : ent.items ) drcItem->SetItems( offendingTrack );