From fc1fb7a590ebf2c7f959c14a8d0a67dc860f3491 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 15 Aug 2019 00:21:48 -0700 Subject: [PATCH] PNS: Don't allow routing on hidden layers If the layer is not shown, we should not be allowing it's items to be selected and chosen as the start/end items in the router. --- pcbnew/router/pns_kicad_iface.cpp | 14 ++++++++++++++ pcbnew/router/pns_kicad_iface.h | 1 + pcbnew/router/pns_router.h | 2 ++ pcbnew/router/pns_tool_base.cpp | 3 +++ 4 files changed, 20 insertions(+) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index f66b095237..dfa922924b 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -985,6 +985,7 @@ bool PNS_KICAD_IFACE::syncGraphicalItem( PNS::NODE* aWorld, DRAWSEGMENT* aItem ) return true; } + void PNS_KICAD_IFACE::SetBoard( BOARD* aBoard ) { m_board = aBoard; @@ -992,6 +993,19 @@ void PNS_KICAD_IFACE::SetBoard( BOARD* aBoard ) } +bool PNS_KICAD_IFACE::IsAnyLayerVisible( const LAYER_RANGE& aLayer ) +{ + if( !m_view ) + return false; + + for( int i = aLayer.Start(); i <= aLayer.End(); i++ ) + if( m_view->IsLayerVisible( i ) ) + return true; + + return false; +} + + void PNS_KICAD_IFACE::SyncWorld( PNS::NODE *aWorld ) { int worstPadClearance = 0; diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index 3eaa0a1340..a58e634508 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -52,6 +52,7 @@ public: void SetView( KIGFX::VIEW* aView ); void SyncWorld( PNS::NODE* aWorld ) override; void EraseView() override; + bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) override; void HideItem( PNS::ITEM* aItem ) override; void DisplayItem( const PNS::ITEM* aItem, int aColor = 0, int aClearance = 0, bool aEdit = false ) override; void AddItem( PNS::ITEM* aItem ) override; diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index f5e90f54ee..49e4edb664 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -28,6 +28,7 @@ #include #include +#include #include #include "pns_routing_settings.h" @@ -93,6 +94,7 @@ enum DRAG_MODE virtual void SyncWorld( NODE* aNode ) = 0; virtual void AddItem( ITEM* aItem ) = 0; virtual void RemoveItem( ITEM* aItem ) = 0; + virtual bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) = 0; virtual void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1, bool aEdit = false ) = 0; virtual void HideItem( ITEM* aItem ) = 0; virtual void Commit() = 0; diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 982f98473f..7beb5d4ce7 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -137,6 +137,9 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b if( !IsCopperLayer( item->Layers().Start() ) ) continue; + if( !m_iface->IsAnyLayerVisible( item->Layers() ) ) + continue; + // fixme: this causes flicker with live loop removal... //if( item->Parent() && !item->Parent()->ViewIsVisible() ) // continue;