From df48ebfbe70bb9a1d1fe53668da746f42b68da39 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 17 Jan 2024 13:53:21 +0000 Subject: [PATCH] Restore preferential selection treatment for silk items. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16607 --- pcbnew/tools/pcb_selection_tool.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index ede9e78b0a..c6734596b5 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -3261,6 +3261,8 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector { static const LSET silkLayers( 2, B_SilkS, F_SilkS ); static const LSET courtyardLayers( 2, B_CrtYd, F_CrtYd ); + static std::vector singleLayerSilkTypes = { PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, + PCB_SHAPE_T }; if( ADVANCED_CFG::GetCfg().m_PcbSelectionVisibilityRatio != 1.0 ) pruneObscuredSelectionCandidates( aCollector ); @@ -3274,28 +3276,27 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings(); PCB_LAYER_ID activeLayer = m_frame->GetActiveLayer(); + // If a silk layer is in front, we assume the user is working with silk and give preferential + // treatment to single-layer items on *either* silk layer. if( silkLayers[activeLayer] ) { for( int i = 0; i < aCollector.GetCount(); ++i ) { BOARD_ITEM* item = aCollector[i]; - if( item->IsType( { PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_SHAPE_T, - PCB_FOOTPRINT_T } ) - && item->IsOnLayer( activeLayer ) ) - { + if( item->IsType( singleLayerSilkTypes ) && silkLayers[ item->GetLayer() ] ) preferred.insert( item ); - } } } + // Similarly, if a courtyard layer is in front, we assume the user is positioning footprints + // and give preferential treatment to footprints on *both* top and bottom. else if( courtyardLayers[activeLayer] && settings->GetHighContrast() ) { for( int i = 0; i < aCollector.GetCount(); ++i ) { BOARD_ITEM* item = aCollector[i]; - KICAD_T type = item->Type(); - if( type == PCB_FOOTPRINT_T ) + if( item->Type() == PCB_FOOTPRINT_T ) preferred.insert( item ); } }