From 812c56bdc74417545ff0a0567603c182ed3c593b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 25 Jul 2023 11:05:56 -0700 Subject: [PATCH] Clarify NeighboringSegmentFilter This doesn't affect behavior but makes the code more readable --- pcbnew/router/router_tool.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index aa5dbd7553..98c0a19733 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -2036,7 +2036,20 @@ void ROUTER_TOOL::NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECT int traces = aCollector.CountType( PCB_TRACE_T ); int arcs = aCollector.CountType( PCB_ARC_T ); - if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 ) + // We eliminate arcs because they are not supported in the inline drag code. + if( arcs > 0 ) + return; + + // We need to have at least 1 via or track + if( vias + traces == 0 ) + return; + + // We cannot drag more than one via at a time + if( vias > 1 ) + return; + + // We cannot drag more than two track segments at a time + if( traces > 2 ) return; // Fetch first PCB_TRACK (via or trace) as our reference @@ -2045,6 +2058,10 @@ void ROUTER_TOOL::NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECT for( int i = 0; !reference && i < aCollector.GetCount(); i++ ) reference = dynamic_cast( aCollector[i] ); + // This should never happen, but just in case... + if( !reference ) + return; + int refNet = reference->GetNetCode(); VECTOR2I refPoint( aPt.x, aPt.y );