diff --git a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp index ed36595de2..e139ffdc36 100644 --- a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp +++ b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -30,13 +29,11 @@ #include #include -#include #include #include #include -#include /* Differential pair gap/coupling test. @@ -148,14 +145,7 @@ struct DIFF_PAIR_KEY else if( netN > b.netN ) return false; else - { - if( parentRule < b.parentRule ) - return true; - else - { - return false; - } - } + return parentRule < b.parentRule; } } @@ -185,7 +175,7 @@ static void extractDiffPairCoupledItems( DIFF_PAIR_ITEMS& aDp, DRC_RTREE& aTree { for( BOARD_CONNECTED_ITEM* itemP : aDp.itemsP ) { - auto sp = dyn_cast( itemP ); + TRACK* sp = dyn_cast( itemP ); OPT bestCoupled; int bestGap = std::numeric_limits::max(); @@ -230,37 +220,37 @@ static void extractDiffPairCoupledItems( DIFF_PAIR_ITEMS& aDp, DRC_RTREE& aTree if( bestCoupled ) { printf("Best-gap %d\n", bestGap ); - auto excludeSelf = [&] ( BOARD_ITEM *aItem ) - { - if( aItem == bestCoupled->parentN || aItem == bestCoupled->parentP ) - { - return false; - } + auto excludeSelf = + [&] ( BOARD_ITEM *aItem ) + { + if( aItem == bestCoupled->parentN || aItem == bestCoupled->parentP ) + { + return false; + } - if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_VIA_T ) - { - auto bci = static_cast( aItem ); + if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_VIA_T ) + { + auto bci = static_cast( aItem ); - if( bci->GetNetCode() == bestCoupled->parentN->GetNetCode() - || bci->GetNetCode() == bestCoupled->parentP->GetNetCode() ) - return false; - } + if( bci->GetNetCode() == bestCoupled->parentN->GetNetCode() + || bci->GetNetCode() == bestCoupled->parentP->GetNetCode() ) + return false; + } - return true; - }; + return true; + }; - SHAPE_SEGMENT checkSegStart( bestCoupled->coupledP.A, bestCoupled->coupledN.A ); - SHAPE_SEGMENT checkSegEnd( bestCoupled->coupledP.B, bestCoupled->coupledN.B ); + SHAPE_SEGMENT checkSegStart( bestCoupled->coupledP.A, bestCoupled->coupledN.A ); + SHAPE_SEGMENT checkSegEnd( bestCoupled->coupledP.B, bestCoupled->coupledN.B ); - // check if there's anyting in between the segments suspected to be coupled. If - // there's nothing, assume they are really coupled. - - if( !aTree.CheckColliding( &checkSegStart, sp->GetLayer(), 0, excludeSelf ) - && !aTree.CheckColliding( &checkSegEnd, sp->GetLayer(), 0, excludeSelf ) ) - { - aDp.coupled.push_back( *bestCoupled ); - } + // check if there's anyting in between the segments suspected to be coupled. If + // there's nothing, assume they are really coupled. + if( !aTree.CheckColliding( &checkSegStart, sp->GetLayer(), 0, excludeSelf ) + && !aTree.CheckColliding( &checkSegEnd, sp->GetLayer(), 0, excludeSelf ) ) + { + aDp.coupled.push_back( *bestCoupled ); + } } } } @@ -438,54 +428,53 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run() if ( val.HasMax() && totalUncoupled > val.Max() ) { - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG ); - wxString msg = - drcItem->GetErrorText() + " (" + maxUncoupledConstraint->GetParentRule()->m_Name + " "; + auto drce = DRC_ITEM::Create( DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG ); - msg += wxString::Format( _( "maximum uncoupled length: %s; actual: %s)" ), - MessageTextFromValue( userUnits(), val.Max() ), - MessageTextFromValue( userUnits(), totalUncoupled ) ); + m_msg = wxString::Format( _( "(%s maximum uncoupled length: %s; actual: %s)" ), + maxUncoupledConstraint->GetParentRule()->m_Name, + MessageTextFromValue( userUnits(), val.Max() ), + MessageTextFromValue( userUnits(), totalUncoupled ) ); - drcItem->SetErrorMessage( msg ); + drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); - for( auto offendingTrack : it.second.itemsP ) - drcItem->AddItem( offendingTrack ); - for( auto offendingTrack : it.second.itemsN ) - drcItem->AddItem( offendingTrack ); + for( BOARD_CONNECTED_ITEM* offendingTrack : it.second.itemsP ) + drce->AddItem( offendingTrack ); + + for( BOARD_CONNECTED_ITEM* offendingTrack : it.second.itemsN ) + drce->AddItem( offendingTrack ); uncoupledViolation = true; - drcItem->SetViolatingRule( maxUncoupledConstraint->GetParentRule() ); + drce->SetViolatingRule( maxUncoupledConstraint->GetParentRule() ); - reportViolation( drcItem, (*it.second.itemsP.begin())->GetPosition() ); + reportViolation( drce, (*it.second.itemsP.begin())->GetPosition() ); } } - if ( gapConstraint && (uncoupledViolation || !maxUncoupledConstraint ) ) + if ( gapConstraint && ( uncoupledViolation || !maxUncoupledConstraint ) ) { for( auto& cpair : it.second.coupled ) { if( !cpair.couplingOK ) { auto val = gapConstraint->GetValue(); + auto drcItem = DRC_ITEM::Create( DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE ); - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE ); - wxString msg = - drcItem->GetErrorText() + " (" + maxUncoupledConstraint->GetParentRule()->m_Name + " "; + m_msg = drcItem->GetErrorText() + " (" + gapConstraint->GetParentRule()->m_Name + " "; if( val.HasMin() ) - msg += wxString::Format( _( "minimum gap: %s; " ), + m_msg += wxString::Format( _( "minimum gap: %s; " ), MessageTextFromValue( userUnits(), val.Min() ) ); if( val.HasMax() ) - msg += wxString::Format( _( "maximum gap: %s; " ), + m_msg += wxString::Format( _( "maximum gap: %s; " ), MessageTextFromValue( userUnits(), val.Max() ) ); - msg += wxString::Format( _( "actual: %s)" ), + m_msg += wxString::Format( _( "actual: %s)" ), MessageTextFromValue( userUnits(), cpair.computedGap ) ); - drcItem->SetErrorMessage( msg ); + drcItem->SetErrorMessage( m_msg ); drcItem->AddItem( cpair.parentP ); drcItem->AddItem( cpair.parentN );