mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Pcbnew: use R-tree for pad checks in via place tool
Otherwise this is an O(n-pads-on-board) operation for every new candidate via position.
This commit is contained in:
parent
4bebd09bd0
commit
3d8803f579
@ -3661,14 +3661,27 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const VECTOR2I position = aVia->GetPosition();
|
||||
const LSET lset = aVia->GetLayerSet();
|
||||
const BOX2I bbox = aVia->GetBoundingBox();
|
||||
|
||||
for( FOOTPRINT* fp : m_board->Footprints() )
|
||||
const KIGFX::PCB_VIEW& view = *m_frame->GetCanvas()->GetView();
|
||||
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
|
||||
|
||||
view.Query( bbox, items );
|
||||
|
||||
for( const KIGFX::VIEW::LAYER_ITEM_PAIR& it : items )
|
||||
{
|
||||
for( PAD* pad : fp->Pads() )
|
||||
if( !it.first->IsBOARD_ITEM() )
|
||||
continue;
|
||||
|
||||
BOARD_ITEM& item = static_cast<BOARD_ITEM&>( *it.first );
|
||||
|
||||
if( item.Type() == PCB_PAD_T && ( item.GetLayerSet() & lset ).any() )
|
||||
{
|
||||
if( pad->HitTest( position ) && ( pad->GetLayerSet() & lset ).any() )
|
||||
PAD& pad = static_cast<PAD&>( item );
|
||||
|
||||
if( pad.HitTest( position ) )
|
||||
{
|
||||
return pad;
|
||||
return &pad;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user