From 2d13ddc70c279d9c062547dd1329781e83dfa66e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 9 Apr 2023 20:25:22 +0100 Subject: [PATCH] Fix PNS_KICAD_IFACE_BASE::IsFlashedOnLayer() to be able to handle multi-layer queries. --- pcbnew/router/pns_item.cpp | 4 +-- pcbnew/router/pns_kicad_iface.cpp | 44 +++++++++++++++++++++++++++++++ pcbnew/router/pns_kicad_iface.h | 1 + pcbnew/router/pns_router.h | 1 + 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index 6bb07b8258..b4be3c5d04 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -125,11 +125,11 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, { clearance = 0; // keepouts are exact boundary; no clearance } - else if( iface && !iface->IsFlashedOnLayer( this, aHead->Layer() ) ) + else if( iface && !iface->IsFlashedOnLayer( this, aHead->Layers() ) ) { clearance = -1; } - else if( iface && !iface->IsFlashedOnLayer( aHead, Layer() ) ) + else if( iface && !iface->IsFlashedOnLayer( aHead, Layers() ) ) { clearance = -1; } diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index dcf215014c..e623342ba5 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1418,6 +1418,50 @@ bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer } +bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer( const PNS::ITEM* aItem, + const LAYER_RANGE& aLayer ) const +{ + LAYER_RANGE test = aItem->Layers().Intersection( aLayer ); + + if( aItem->Parent() ) + { + switch( aItem->Parent()->Type() ) + { + case PCB_VIA_T: + { + const PCB_VIA* via = static_cast( aItem->Parent() ); + + for( int layer = test.Start(); layer <= test.End(); ++layer ) + { + if( via->FlashLayer( ToLAYER_ID( layer ) ) ) + return true; + } + + return false; + } + + case PCB_PAD_T: + { + const PAD* pad = static_cast( aItem->Parent() ); + + for( int layer = test.Start(); layer <= test.End(); ++layer ) + { + if( pad->FlashLayer( ToLAYER_ID( layer ) ) ) + return true; + } + + return false; + } + + default: + break; + } + } + + return test.Start() <= test.End(); +} + + bool PNS_KICAD_IFACE::IsItemVisible( const PNS::ITEM* aItem ) const { // by default, all items are visible (new ones created by the router have parent == NULL diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index a90e835d8e..7275b2dfcf 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -58,6 +58,7 @@ public: void SyncWorld( PNS::NODE* aWorld ) override; bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const override { return true; }; bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override; + bool IsFlashedOnLayer( const PNS::ITEM* aItem, const LAYER_RANGE& aLayer ) const override; bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; }; void HideItem( PNS::ITEM* aItem ) override {} void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false, diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index bfef0d142b..5dddf40013 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -96,6 +96,7 @@ enum DRAG_MODE virtual bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const = 0; virtual bool IsItemVisible( const PNS::ITEM* aItem ) const = 0; virtual bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const = 0; + virtual bool IsFlashedOnLayer( const PNS::ITEM* aItem, const LAYER_RANGE& aLayer ) const = 0; virtual void DisplayItem( const ITEM* aItem, int aClearance, bool aEdit = false, bool aIsHeadTrace = false ) = 0; virtual void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) = 0; virtual void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aNetCode ) = 0;