From 2d8cac658e7b86bc0ebf843f2abcc3e4c99f6430 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 23 Jan 2021 00:09:18 +0000 Subject: [PATCH] Allow negative clearances to signal supression of DRC test. --- pcbnew/drc/drc_engine.cpp | 21 ----- pcbnew/drc/drc_test_provider.cpp | 3 + pcbnew/drc/drc_test_provider_annulus.cpp | 2 - .../drc_test_provider_copper_clearance.cpp | 88 ++++++++++--------- .../drc_test_provider_courtyard_clearance.cpp | 4 +- .../drc/drc_test_provider_edge_clearance.cpp | 4 +- .../drc/drc_test_provider_hole_clearance.cpp | 4 +- pcbnew/drc/drc_test_provider_hole_size.cpp | 4 - .../drc/drc_test_provider_silk_clearance.cpp | 48 +++++----- pcbnew/drc/drc_test_provider_silk_to_mask.cpp | 49 ++++++----- 10 files changed, 102 insertions(+), 125 deletions(-) diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 3fbe9853e0..42e216f838 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -1082,27 +1082,6 @@ bool DRC_ENGINE::ReportPhase( const wxString& aMessage ) } -#if 0 -DRC_CONSTRAINT DRC_ENGINE::GetWorstGlobalConstraint( DRC_CONSTRAINT_T ruleID ) -{ - DRC_CONSTRAINT rv; - - rv.m_Value.SetMin( std::numeric_limits::max() ); - rv.m_Value.SetMax( std::numeric_limits::min() ); - for( auto rule : QueryRulesById( ruleID ) ) - { - auto mm = rule->GetConstraint().m_Value; - if( mm.HasMax() ) - rv.m_Value.SetMax( std::max( mm.Max(), rv.m_Value.Max() ) ); - if( mm.HasMin() ) - rv.m_Value.SetMin( std::min( mm.Min(), rv.m_Value.Min() ) ); - } - - return rv; -} -#endif - - bool DRC_ENGINE::HasRulesForConstraintType( DRC_CONSTRAINT_T constraintID ) { //drc_dbg(10,"hascorrect id %d size %d\n", ruleID, m_ruleMap[ruleID]->sortedRules.size( ) ); diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index 489d06fac8..4d80eb7896 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -55,6 +55,9 @@ const wxString DRC_TEST_PROVIDER::GetDescription() const { return ""; } void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr& item, wxPoint aMarkerPos ) { + if( item->GetViolatingRule() ) + accountCheck( item->GetViolatingRule() ); + item->SetViolatingTest( this ); m_drcEngine->ReportViolation( item, aMarkerPos ); } diff --git a/pcbnew/drc/drc_test_provider_annulus.cpp b/pcbnew/drc/drc_test_provider_annulus.cpp index 60e61d71bc..f2f5dea009 100644 --- a/pcbnew/drc/drc_test_provider_annulus.cpp +++ b/pcbnew/drc/drc_test_provider_annulus.cpp @@ -99,8 +99,6 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run() bool fail_min = false; bool fail_max = false; - accountCheck( constraint ); - if( constraint.Value().HasMin() ) { v_min = constraint.Value().Min(); diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index 40a1fe18b6..c4e65653c0 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -273,7 +273,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE ); bool testHoles = !m_drcEngine->IsErrorLimitExceeded( DRCE_HOLE_CLEARANCE ); DRC_CONSTRAINT constraint; - int clearance; + int clearance = -1; int actual; VECTOR2I pos; @@ -289,9 +289,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA { constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, track, other, layer ); clearance = constraint.GetValue().Min(); + } - accountCheck( constraint ); - + if( clearance >= 0 ) + { // Special processing for track:track intersections if( track->Type() == PCB_TRACE_T && other->Type() == PCB_TRACE_T ) { @@ -305,29 +306,32 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA drcItem->SetViolatingRule( constraint.GetParentRule() ); reportViolation( drcItem, (wxPoint) intersection.get() ); - return true; + + return m_drcEngine->GetReportAllTrackErrors(); } } - - std::shared_ptr otherShape = getShape( other, layer ); - - if( trackShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) ) + else { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr otherShape = getShape( other, layer ); - m_msg.Printf( _( "(%s clearance %s; actual %s)" ), - constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + if( trackShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) ) + { + std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); - drce->SetItems( track, other ); - drce->SetViolatingRule( constraint.GetParentRule() ); + m_msg.Printf( _( "(%s clearance %s; actual %s)" ), + constraint.GetName(), + MessageTextFromValue( userUnits(), clearance ), + MessageTextFromValue( userUnits(), actual ) ); - reportViolation( drce, (wxPoint) pos ); + drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); + drce->SetItems( track, other ); + drce->SetViolatingRule( constraint.GetParentRule() ); - if( !m_drcEngine->GetReportAllTrackErrors() ) - return false; + reportViolation( drce, (wxPoint) pos ); + + if( !m_drcEngine->GetReportAllTrackErrors() ) + return false; + } } } @@ -356,9 +360,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA constraint = m_drcEngine->EvalRulesForItems( HOLE_CLEARANCE_CONSTRAINT, other, track ); clearance = constraint.GetValue().Min(); - accountCheck( constraint.GetParentRule() ); - - if( trackShape->Collide( holeShape.get(), clearance - m_drcEpsilon, &actual, &pos ) ) + if( clearance >= 0 && trackShape->Collide( holeShape.get(), + std::max( 0, clearance - m_drcEpsilon ), + &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); @@ -372,6 +376,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA drce->SetViolatingRule( constraint.GetParentRule() ); reportViolation( drce, (wxPoint) pos ); + + if( !m_drcEngine->GetReportAllTrackErrors() ) + return false; } } } @@ -401,7 +408,11 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aItem { auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, aItem, zone, aLayer ); - int clearance = constraint.GetValue().Min(); + int clearance = constraint.GetValue().Min(); + + if( clearance < 0 ) + continue; + int actual; VECTOR2I pos; DRC_RTREE* zoneTree = m_zoneTrees[ zone ].get(); @@ -586,10 +597,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa otherPad ); clearance = constraint.GetValue().Min(); - accountCheck( constraint.GetParentRule() ); - - if( padShape->Collide( otherPad->GetEffectiveHoleShape(), clearance - m_drcEpsilon, - &actual, &pos ) ) + if( clearance >= 0 && padShape->Collide( otherPad->GetEffectiveHoleShape(), + std::max( 0, clearance - m_drcEpsilon ), + &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); @@ -612,10 +622,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa otherPad ); clearance = constraint.GetValue().Min(); - accountCheck( constraint.GetParentRule() ); - - if( otherShape->Collide( pad->GetEffectiveHoleShape(), clearance - m_drcEpsilon, - &actual, &pos ) ) + if( clearance >= 0 && otherShape->Collide( pad->GetEffectiveHoleShape(), + std::max( 0, clearance - m_drcEpsilon ), + &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); @@ -645,9 +654,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, pad, other, layer ); clearance = constraint.GetValue().Min(); - accountCheck( constraint ); - - if( padShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) ) + if( clearance > 0 && padShape->Collide( otherShape.get(), + std::max( 0, clearance - m_drcEpsilon ), + &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); @@ -787,8 +796,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones() if( zoneRef->GetPriority() != zoneToTest->GetPriority() ) continue; - // test for different types - if( zoneRef->GetIsRuleArea() != zoneToTest->GetIsRuleArea() ) + // rule areas may overlap at will + if( zoneRef->GetIsRuleArea() || zoneToTest->GetIsRuleArea() ) continue; // Examine a candidate zone: compare zoneToTest to zoneRef @@ -798,13 +807,6 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones() zoneToTest ); int zone2zoneClearance = constraint.GetValue().Min(); - accountCheck( constraint ); - - // Keepout areas have no clearance, so set zone2zoneClearance to 1 - // ( zone2zoneClearance = 0 can create problems in test functions) - if( zoneRef->GetIsRuleArea() ) // fixme: really? - zone2zoneClearance = 1; - // test for some corners of zoneRef inside zoneToTest for( auto iterator = smoothed_polys[ia].IterateWithHoles(); iterator; iterator++ ) { diff --git a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp index 59a9449b95..cfb5f50261 100644 --- a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp @@ -170,7 +170,7 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() footprint, test, F_Cu ); clearance = constraint.GetValue().Min(); - if( footprintFront.Collide( &testFront, clearance, &actual, &pos ) ) + if( clearance >= 0 && footprintFront.Collide( &testFront, clearance, &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS ); @@ -197,7 +197,7 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() footprint, test, B_Cu ); clearance = constraint.GetValue().Min(); - if( footprintBack.Collide( &testBack, clearance, &actual, &pos ) ) + if( clearance >= 0 && footprintBack.Collide( &testBack, clearance, &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS ); diff --git a/pcbnew/drc/drc_test_provider_edge_clearance.cpp b/pcbnew/drc/drc_test_provider_edge_clearance.cpp index 301b108027..edfc092af5 100644 --- a/pcbnew/drc/drc_test_provider_edge_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_edge_clearance.cpp @@ -91,9 +91,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge( BOARD_ITEM* item, SHAPE* int actual; VECTOR2I pos; - accountCheck( constraint ); - - if( itemShape->Collide( edgeShape.get(), minClearance, &actual, &pos ) ) + if( minClearance >= 0 && itemShape->Collide( edgeShape.get(), minClearance, &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( aErrorCode ); diff --git a/pcbnew/drc/drc_test_provider_hole_clearance.cpp b/pcbnew/drc/drc_test_provider_hole_clearance.cpp index 06963a565b..3bd1827779 100644 --- a/pcbnew/drc/drc_test_provider_hole_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_hole_clearance.cpp @@ -281,9 +281,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::testHoleAgainstHole( BOARD_ITEM* aItem, S auto constraint = m_drcEngine->EvalRulesForItems( HOLE_TO_HOLE_CONSTRAINT, aItem, aOther ); int minClearance = constraint.GetValue().Min(); - accountCheck( constraint.GetParentRule() ); - - if( actual < minClearance ) + if( minClearance >= 0 && actual < minClearance ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE ); diff --git a/pcbnew/drc/drc_test_provider_hole_size.cpp b/pcbnew/drc/drc_test_provider_hole_size.cpp index 6ced36f1f0..f204ab6bc0 100644 --- a/pcbnew/drc/drc_test_provider_hole_size.cpp +++ b/pcbnew/drc/drc_test_provider_hole_size.cpp @@ -134,8 +134,6 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPad( PAD* aPad ) bool fail_max = false; int constraintValue; - accountCheck( constraint ); - if( constraint.Value().HasMin() && holeMinor < constraint.Value().Min() ) { fail_min = true; @@ -200,8 +198,6 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkVia( VIA* via, bool aExceedMicro, bool aE bool fail_max = false; int constraintValue; - accountCheck( constraint ); - if( constraint.Value().HasMin() && via->GetDrillValue() < constraint.Value().Min() ) { fail_min = true; diff --git a/pcbnew/drc/drc_test_provider_silk_clearance.cpp b/pcbnew/drc/drc_test_provider_silk_clearance.cpp index d2675d1d66..a04dbda694 100644 --- a/pcbnew/drc/drc_test_provider_silk_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_silk_clearance.cpp @@ -140,10 +140,7 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() if( m_drcEngine->IsErrorLimitExceeded( DRCE_OVERLAPPING_SILK ) ) return false; - if ( isInvisibleText( aRefItem->parent ) ) - return true; - - if ( isInvisibleText( aTestItem->parent ) ) + if( isInvisibleText( aRefItem->parent ) || isInvisibleText( aTestItem->parent ) ) return true; auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT, @@ -154,12 +151,14 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() if( constraint.IsNull() ) return true; - int minClearance = constraint.GetValue().Min(); + int minClearance = constraint.GetValue().Min(); + + if( minClearance < 0 ) + return true; + int actual; VECTOR2I pos; - accountCheck( constraint ); - // Graphics are often compound shapes so ignore collisions between shapes in a // single footprint or on the board. PCB_SHAPE* refGraphic = dynamic_cast( aRefItem->parent ); @@ -174,27 +173,28 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() return true; } - if( !aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) ) - return true; - - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_SILK ); - - if( minClearance > 0 ) + if( aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) ) { - m_msg.Printf( _( "(%s clearance %s; actual %s)" ), - constraint.GetParentRule()->m_Name, - MessageTextFromValue( userUnits(), minClearance ), - MessageTextFromValue( userUnits(), actual ) ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_SILK ); - drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); + if( minClearance > 0 ) + { + m_msg.Printf( _( "(%s clearance %s; actual %s)" ), + constraint.GetParentRule()->m_Name, + MessageTextFromValue( userUnits(), minClearance ), + MessageTextFromValue( userUnits(), actual ) ); + + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); + } + + drcItem->SetItems( aRefItem->parent, aTestItem->parent ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + + reportViolation( drcItem, (wxPoint) pos ); + + *aCollisionDetected = true; } - drcItem->SetItems( aRefItem->parent, aTestItem->parent ); - drcItem->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drcItem, (wxPoint) pos ); - - *aCollisionDetected = true; return true; }; diff --git a/pcbnew/drc/drc_test_provider_silk_to_mask.cpp b/pcbnew/drc/drc_test_provider_silk_to_mask.cpp index c68d41cd63..499042d259 100644 --- a/pcbnew/drc/drc_test_provider_silk_to_mask.cpp +++ b/pcbnew/drc/drc_test_provider_silk_to_mask.cpp @@ -122,43 +122,46 @@ bool DRC_TEST_PROVIDER_SILK_TO_MASK::Run() if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_MASK_CLEARANCE ) ) return false; - auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT, - aRefItem->parent, - aTestItem->parent ); - - int minClearance = constraint.GetValue().Min(); - int actual; - VECTOR2I pos; - if( isInvisibleText( aRefItem->parent ) ) return true; if( isInvisibleText( aTestItem->parent ) ) return true; - accountCheck( constraint ); + auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT, + aRefItem->parent, + aTestItem->parent ); - if( !aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) ) + int minClearance = constraint.GetValue().Min(); + + if( minClearance < 0 ) return true; - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_SILK_MASK_CLEARANCE ); + int actual; + VECTOR2I pos; - if( minClearance > 0 ) + if( aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) ) { - m_msg.Printf( _( "(%s clearance %s; actual %s)" ), - constraint.GetName(), - MessageTextFromValue( userUnits(), minClearance ), - MessageTextFromValue( userUnits(), actual ) ); + std::shared_ptr drce = DRC_ITEM::Create( DRCE_SILK_MASK_CLEARANCE ); - drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); + if( minClearance > 0 ) + { + m_msg.Printf( _( "(%s clearance %s; actual %s)" ), + constraint.GetName(), + MessageTextFromValue( userUnits(), minClearance ), + MessageTextFromValue( userUnits(), actual ) ); + + drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); + } + + drce->SetItems( aRefItem->parent, aTestItem->parent ); + drce->SetViolatingRule( constraint.GetParentRule() ); + + reportViolation( drce, (wxPoint) pos ); + + *aCollisionDetected = true; } - drcItem->SetItems( aRefItem->parent, aTestItem->parent ); - drcItem->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drcItem, (wxPoint) pos ); - - *aCollisionDetected = true; return true; };