From a2627fec601690619190cebd1bf36fd5071f4f59 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 19 Aug 2023 20:55:42 +0100 Subject: [PATCH] Don't snap to footprint-private items. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15447 --- common/dialogs/hotkey_cycle_popup.cpp | 3 ++- pcbnew/tools/pcb_grid_helper.cpp | 32 ++++++++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/common/dialogs/hotkey_cycle_popup.cpp b/common/dialogs/hotkey_cycle_popup.cpp index 0c90e47316..b09e1a1409 100644 --- a/common/dialogs/hotkey_cycle_popup.cpp +++ b/common/dialogs/hotkey_cycle_popup.cpp @@ -87,7 +87,8 @@ void HOTKEY_CYCLE_POPUP::Popup( const wxString& aTitle, const wxArrayString& aIt height += extents.y + LIST_BOX_V_PADDING; } - m_listBox->SetMinSize( wxSize( width + LIST_BOX_H_PADDING, height ) ); + m_listBox->SetMinSize( wxSize( width + LIST_BOX_H_PADDING, + height + ( LIST_BOX_V_PADDING * 2 ) ) ); // this line fixes an issue on Linux Ubuntu using Unity (dialog not shown), // and works fine on all systems diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index d4c3ec9f49..4ab77c9f7d 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -381,6 +381,7 @@ std::set PCB_GRID_HELPER::queryVisible( const BOX2I& aArea, std::set items; std::vector selectedItems; + PCB_TOOL_BASE* currentTool = static_cast( m_toolMgr->GetCurrentTool() ); KIGFX::VIEW* view = m_toolMgr->GetView(); RENDER_SETTINGS* settings = view->GetPainter()->GetSettings(); const std::set& activeLayers = settings->GetHighContrastLayers(); @@ -388,23 +389,32 @@ std::set PCB_GRID_HELPER::queryVisible( const BOX2I& aArea, view->Query( aArea, selectedItems ); - for( const KIGFX::VIEW::LAYER_ITEM_PAIR& it : selectedItems ) + for( const auto& [ viewItem, layer ] : selectedItems ) { - BOARD_ITEM* item = static_cast( it.first ); + BOARD_ITEM* boardItem = static_cast( viewItem ); - // If we are in the footprint editor, don't use the footprint itself - if( static_cast( m_toolMgr->GetCurrentTool() )->IsFootprintEditor() - && item->Type() == PCB_FOOTPRINT_T ) + if( currentTool->IsFootprintEditor() ) { - continue; + // If we are in the footprint editor, don't use the footprint itself + if( boardItem->Type() == PCB_FOOTPRINT_T ) + continue; + } + else + { + // If we are not in the footprint editor, don't use footprint-editor-private items + if( FOOTPRINT* parentFP = boardItem->GetParentFootprint() ) + { + if( IsPcbLayer( layer ) && parentFP->GetPrivateLayers().test( layer ) ) + continue; + } } - // The item must be visible and on an active layer - if( view->IsVisible( item ) - && ( !isHighContrast || activeLayers.count( it.second ) ) - && item->ViewGetLOD( it.second, view ) < view->GetScale() ) + // The boardItem must be visible and on an active layer + if( view->IsVisible( boardItem ) + && ( !isHighContrast || activeLayers.count( layer ) ) + && boardItem->ViewGetLOD( layer, view ) < view->GetScale() ) { - items.insert ( item ); + items.insert ( boardItem ); } }