From 560f6f87e5101187abdc718f5054b30abbafce58 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 22 May 2024 01:15:08 +0100 Subject: [PATCH] Silkscreen clearance tests are run across layer pairs. (So any rule areas must pretend they're on all the given side's layers to get expected results.) --- pcbnew/pcbexpr_functions.cpp | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pcbnew/pcbexpr_functions.cpp b/pcbnew/pcbexpr_functions.cpp index 2722aaf371..d4bdfeec6e 100644 --- a/pcbnew/pcbexpr_functions.cpp +++ b/pcbnew/pcbexpr_functions.cpp @@ -621,6 +621,31 @@ bool searchAreas( BOARD* aBoard, const wxString& aArg, PCBEXPR_CONTEXT* aCtx, } +class SCOPED_LAYERSET +{ +public: + SCOPED_LAYERSET( BOARD_ITEM* aItem ) + { + m_item = aItem; + m_layers = aItem->GetLayerSet(); + } + + ~SCOPED_LAYERSET() + { + m_item->SetLayerSet( m_layers ); + } + + void Add( PCB_LAYER_ID aLayer ) + { + m_item->SetLayerSet( m_item->GetLayerSet().set( aLayer ) ); + } + +private: + BOARD_ITEM* m_item; + LSET m_layers; +}; + + #define MISSING_AREA_ARG( f ) \ wxString::Format( _( "Missing rule-area argument (A, B, or rule-area name) to %s." ), f ) @@ -660,6 +685,18 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self ) if( !aArea || aArea == item || aArea->GetParent() == item ) return false; + SCOPED_LAYERSET scopedLayerSet( aArea ); + + if( context->GetConstraint() == SILK_CLEARANCE_CONSTRAINT ) + { + // Silk clearance tests are run across layer pairs + if( ( aArea->IsOnLayer( F_SilkS ) && IsFrontLayer( aLayer ) ) + || ( aArea->IsOnLayer( B_SilkS ) && IsBackLayer( aLayer ) ) ) + { + scopedLayerSet.Add( aLayer ); + } + } + LSET commonLayers = aArea->GetLayerSet() & item->GetLayerSet(); if( !commonLayers.any() )