From 07c8596084022b37f07198172a476a4691cd074a Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 15 Oct 2019 06:30:56 -0700 Subject: [PATCH] pcbnew: Check all layers for routing snaps Flipped footprint pads may report their "primary" layer as not the front layer in high contrast. We need to check whether the board item for snaps is visible on the active layers. Fixes: lp:1847877 * https://bugs.launchpad.net/kicad/+bug/1847877 --- pcbnew/router/pns_kicad_iface.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 8327ba7c8d..52af6cac50 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1071,15 +1071,33 @@ bool PNS_KICAD_IFACE::IsAnyLayerVisible( const LAYER_RANGE& aLayer ) bool PNS_KICAD_IFACE::IsItemVisible( const PNS::ITEM* aItem ) { - if( !m_view ) + if( !m_view || !aItem->Parent() ) return false; auto item = aItem->Parent(); - auto activeLayers = m_view->GetPainter()->GetSettings()->GetActiveLayers(); - bool isHighContrast = m_view->GetPainter()->GetSettings()->GetHighContrast(); + bool isOnVisibleLayer = true; - if( item && m_view->IsVisible( item ) - && ( !isHighContrast || activeLayers.count( item->GetLayer() ) ) + if( m_view->GetPainter()->GetSettings()->GetHighContrast() ) + { + int layers[KIGFX::VIEW::VIEW_MAX_LAYERS]; + int layers_count; + auto activeLayers = m_view->GetPainter()->GetSettings()->GetActiveLayers(); + + isOnVisibleLayer = false; + item->ViewGetLayers( layers, layers_count ); + + for( int i = 0; i < layers_count; ++i ) + { + // Item is on at least one of the active layers + if( activeLayers.count( layers[i] ) > 0 ) + { + isOnVisibleLayer = true; + break; + } + } + } + + if( m_view->IsVisible( item ) && isOnVisibleLayer && item->ViewGetLOD( item->GetLayer(), m_view ) < m_view->GetScale() ) return true;