From aa875e5830321f4020395dc2222eb9ca0b6481f7 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. (cherry picked from commit fc1fb7a590ebf2c7f959c14a8d0a67dc860f3491) --- 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 af5e5538c9..924310b8fb 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1048,6 +1048,7 @@ bool PNS_KICAD_IFACE::syncGraphicalItem( PNS::NODE* aWorld, DRAWSEGMENT* aItem ) return true; } + void PNS_KICAD_IFACE::SetBoard( BOARD* aBoard ) { m_board = aBoard; @@ -1055,6 +1056,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 31501bb73e..69e6c5d052 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 838b2c41b6..7780086dc1 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; + if( std::find( aAvoidItems.begin(), aAvoidItems.end(), item ) != aAvoidItems.end() ) continue;