From d65f9ad2d8fe9c3552c9a49451fae80128e5df10 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 24 Feb 2022 21:09:47 +0000 Subject: [PATCH] Implement multi-layer stitching via logic. --- pcbnew/tools/drawing_tool.cpp | 41 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 504ae282d0..f746efba12 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -2615,37 +2615,32 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) int findStitchedZoneNet( PCB_VIA* aVia ) { const VECTOR2I position = aVia->GetPosition(); - const LSET lset = aVia->GetLayerSet(); + const LSET lset = aVia->GetLayerSet(); - std::vector foundZones; - - for( ZONE* zone : m_board->Zones() ) + // first take the net of the active layer + if( lset.test( m_frame->GetActiveLayer() ) ) { - for( PCB_LAYER_ID layer : LSET( zone->GetLayerSet() & lset ).Seq() ) + for( ZONE* z : m_board->Zones() ) { - if( zone->HitTestFilledArea( layer, position ) ) - foundZones.push_back( zone ); + if( z->IsOnLayer( m_frame->GetActiveLayer() ) ) + { + if( z->HitTestFilledArea( m_frame->GetActiveLayer(), position ) ) + return z->GetNetCode(); + } } } - std::sort( foundZones.begin(), foundZones.end(), - [] ( const ZONE* a, const ZONE* b ) - { - return a->GetFirstLayer() < b->GetFirstLayer(); - } ); - - // first take the net of the active layer - for( ZONE* z : foundZones ) - { - if( m_frame->GetActiveLayer() == z->GetLayer() ) - return z->GetNetCode(); - } - // none? take the topmost visible layer - for( ZONE* z : foundZones ) + for( PCB_LAYER_ID layer : LSET( m_board->GetVisibleLayers() & lset ).Seq() ) { - if( m_board->IsLayerVisible( z->GetLayer() ) ) - return z->GetNetCode(); + for( ZONE* z : m_board->Zones() ) + { + if( z->IsOnLayer( m_frame->GetActiveLayer() ) ) + { + if( z->HitTestFilledArea( layer, position ) ) + return z->GetNetCode(); + } + } } return -1;