From 907f21e73943b31b19f8423fbb13eb765e129b10 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 24 Feb 2025 17:35:23 +0000 Subject: [PATCH] Hatching knockout fixes. --- pcbnew/board_commit.cpp | 16 ++++++++-------- pcbnew/pcb_shape.cpp | 30 +++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 5d3af59573..565e00d00f 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -142,16 +142,16 @@ void BOARD_COMMIT::propagateDamage( BOARD_ITEM* aItem, std::vector* aStal BOX2I bbox = aItem->GetBoundingBox(); LSET layers = aItem->GetLayerSet(); - if( layers.test( Edge_Cuts ) || layers.test( Margin ) ) - layers = LSET::PhysicalLayersMask(); - else - layers &= LSET::AllCuMask(); - - if( layers.empty() ) - return; - if( aStaleZones ) { + if( layers.test( Edge_Cuts ) || layers.test( Margin ) ) + layers = LSET::PhysicalLayersMask(); + else + layers &= LSET::AllCuMask(); + + if( layers.empty() ) + return; + for( ZONE* zone : board->Zones() ) { if( zone->GetIsRuleArea() ) diff --git a/pcbnew/pcb_shape.cpp b/pcbnew/pcb_shape.cpp index 45a85d4153..102c26f548 100644 --- a/pcbnew/pcb_shape.cpp +++ b/pcbnew/pcb_shape.cpp @@ -304,6 +304,9 @@ void PCB_SHAPE::updateHatching() const { EDA_SHAPE::updateHatching(); + static std::initializer_list knockoutTypes = { PCB_TEXT_T, PCB_TEXTBOX_T, + PCB_SHAPE_T }; + if( !m_hatching.IsEmpty() ) { PCB_LAYER_ID layer = GetLayer(); @@ -312,12 +315,33 @@ void PCB_SHAPE::updateHatching() const for( BOARD_ITEM* item : GetBoard()->Drawings() ) { - if( ( item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T ) - && item->GetLayer() == layer - && item->GetBoundingBox().Intersects( bbox ) ) + if( item == this ) + continue; + + if( item->IsType( knockoutTypes ) + && item->GetLayer() == layer + && item->GetBoundingBox().Intersects( bbox ) ) { item->TransformShapeToPolygon( holes, layer, 0, ARC_LOW_DEF, ERROR_OUTSIDE, true ); } + + if( item->Type() == PCB_FOOTPRINT_T ) + { + static_cast( item )->RunOnDescendants( + [&]( BOARD_ITEM* descendant ) + { + if( descendant == this ) + return; + + if( descendant->IsType( knockoutTypes ) + && descendant->GetLayer() == layer + && descendant->GetBoundingBox().Intersects( bbox ) ) + { + descendant->TransformShapeToPolygon( holes, layer, 0, ARC_LOW_DEF, + ERROR_OUTSIDE, true ); + } + } ); + } } m_hatching.BooleanSubtract( holes );